Intelligence Artificial Intelligence Ian Gent [email protected] Search: 1.

18
Artificial Intelligence Intelligence Ian Gent [email protected] Search: 1

Transcript of Intelligence Artificial Intelligence Ian Gent [email protected] Search: 1.

Page 1: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

Artificial IntelligenceIntelligence

Ian [email protected]

Search: 1

Page 2: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

Artificial IntelligenceIntelligence

Part I : What is Search?Part II: Presenting search abstractlyPart III: Basic search algorithms

Search: 1

Page 3: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

3

What is AI?

Very hard to define Artificial Intelligence not attempt at building machine to pass Turing Test

Perhaps, exploiting power of machines to do tasks normally considered intelligence?

Practical day to day answer is:AI is what we don’t know how to do yet

Once we know how to do something, it’s not AI e.g. optical character recognition, speech recognition Many AI problems involve combinatorial search

Page 4: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

4

Example Search Problem: SAT

We need to define problems and solutionsPropositional Satisfiability (SAT)

really a logical problem -- I’ll present as a letters game

Problem is a list of words contains upper and lower case letters (order unimportant) e.g. ABC, ABc, AbC, Abc, aBC, abC, abc

Solution is choice of upper/lower case letter one choice per letter each word to contain at least one of our choices e.g. AbC is unique solution to above problem.

Page 5: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

5

Why is SAT a search problem?

There is no efficient algorithm known for SAT all complete algorithms are exponential time

3-SAT is NP-Complete 3-SAT = each word contains exactly 3 letters

NP-Complete we can recognise solutions in polynomial time

easy to check letter choice satisfies each word all other NP problems can be solved by translation to SAT

Many AI problems fall into NP-Complete class

Page 6: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

6

Example: Travelling Salesperson

Problem: graph with an cost for each edge e.g.

Solution: tour visiting all nodes returning to base meeting some cost limit (or reaching minimum cost) e.g. minimum cost is 21 above

TSP is NP-Complete easy to check that tour costs no more than limit (finding optimal cost in technically different complexity class)

4

23

4

5

2

1

42

Page 7: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

7

Example (Not): Sorting

Problem, a list of numbers e.g. 5 6 3 2 4 8

Solution, list in ascending order e.g. 2 3 4 5 6 8

In NP (easy to check that result in ascending order)Not NP-complete

cannot solve SAT via sorting can be solved in O(n log n) time

We know how to do it efficiently, so it’s not AI

Page 8: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

8

Final Example: Games

Problem: a position in a Chess/Go/… gameSolution: a strategy to guarantee winning gameHarder than NP problems

it is not easy to check that a strategy wins can solve SAT via games

Technically, games usually PSPACE-complete All NP-complete problems in PSPACE

Games are valid AI applicationAI usually attacks NP-complete or harder search

problems

Page 9: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

9

Presenting Search Abstractly

Helps to understand the abstract nature of search search states, search spaces, search trees… know what particular search algorithms are trying to do

There are two kinds of search algorithm Complete

guaranteed to find solution or prove there is none Incomplete

may not find a solution even when it existsoften more efficient (or there would be no point)e.g. Genetic Algorithms

For now concerned with complete algorithms

Page 10: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

10

Search States

Search states summarises the state of search A solution tells us everything we need to know

e.g. in SAT, whether each letter is UPPER or lower case in TSP, route taken round nodes of graph

This is a (special) example of a search state it contains complete information it solves the problem

In general a search state may not do either of those it may not specify everything about a possible solution it may not solve the problem or extend to a solution

Page 11: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

11

Search States

Search states summarise the state of search E.g. in SAT

a search state might be represented by aB

E.g. in TSP a search state might specify some of the order of visits

E.g. in Chess a search state might be represented by the board position

(quiz for chessplayers: …and what else?)

Page 12: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

12

Generalising Search

With search states we can generalise search not just finding a solution to a problem

Generally, find a solution which extends search state e.g. find solution to ABC, ABc, AbC, Abc, aBC, abC, abc

which extends aB there is no such solution though whole problem solvable

Original search problem is to extend null stateSearch in AI by structured exploration of search

states

Page 13: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

13

Search Space and Search Trees

Search space is logical space composed of nodes are search states links are all legal connections between search states

e.g. in chess, no link between states where W castles having previously moved K.

always just an abstraction think of search algorithms trying to navigate this extremely

complex space

Page 14: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

14

Search Trees

Search trees do not summarise all possible searches instead an abstraction of one

possible search Root is null state edges represent one choice

e.g. to set value of A first

child nodes represent extensions children give all possible choices

leaf nodes are solutions/failures Example in SAT

algorithm detects failure early need not pick same variables

everywhere

B(a B )

Im p oss ib le

b(a b )

Im p oss ib le

a(a )

C h oose B

B(A B C )

Im p oss ib le

b(A b C )

S o lu tion

C(A C )

C h oose B

cA c

im p oss ib le

A(A )

C h oose C

A B C , A B c , A b C , A b c , aB C , ab C , ab cs ta te = ()C h oose A

Page 15: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

15

Why are search trees abstract?

Search trees are very useful concept but as an abstraction

Search algorithms do not store whole search trees that would need exponential space we can discard nodes in search tree already explored

Search algorithms store frontier of search I.e. nodes in search tree with some unexplored children

Very many search algorithms understandable in terms of search trees and specifically how they explore the frontier

Page 16: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

16

Some classic search algorithms

Depth-first search I.e. explore all nodes in subtree of current node before any

other nodes pick leftmost and deepest element of frontier

Breadth-first search explore all nodes at one height in tree before any other

nodes pick shallowest and leftmost element of frontier

Best-first search pick whichever element of frontier seems most promising

Page 17: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

17

More classic search algorithms

Depth-bounded depth first search like depth first but set limit on depth of search in tree

Iterative Deepening search use depth-bounded search but iteratively increase limit

Page 18: Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 1.

18

Next week on Search in AI

Presentation of search algorithms in terms of lists e.g. depth-first = stack, breadth-first = queue

Heuristics in search how to pick which variable to set