Upload
halle-staines
View
215
Download
0
Tags:
Embed Size (px)
Citation preview
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 1
Chapter 3Chapter 3
Structures and Strategies For Space Structures and Strategies For Space State SearchState Search
Contents
• Graph Theory• Strategies for Space State Search• Using the Space State to Represent
Reasoning with the Predicate Calculus
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 2
The city of KönigsbergLeonhard EulerLeonhard Euler
Problem: if there is a walk around the city Problem: if there is a walk around the city that crosses each bridge exactly once?that crosses each bridge exactly once?
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 3
RepresentationsRepresentationsPredicate calculus: connect(X, Y, Z)Predicate calculus: connect(X, Y, Z)connect(i1, i2, b1) connect(i1, i2, b1) connect(i2, i1, b1)connect(i2, i1, b1)connect(rb1, i1, b2)connect(rb1, i1, b2)connect(i1, rb1, b2)connect(i1, rb1, b2)connect(rb1, i1, b3)connect(rb1, i1, b3)connect(i1, rb1, b3)connect(i1, rb1, b3)connect(rb1, i2, b4)connect(rb1, i2, b4)connect(i2, rb1, b4)connect(i2, rb1, b4)connect(rb2, i1, b5)connect(rb2, i1, b5)connect(i1, rb2, b5)connect(i1, rb2, b5)connect(rb2, i1, b6)connect(rb2, i1, b6)connect(i1, rb2, b6)connect(i1, rb2, b6)connect(rb2, i2, b7)connect(rb2, i2, b7)connect(i2, rb2, b7)connect(i2, rb2, b7)Graph theoryGraph theory– NodesNodes– LinkesLinkes– Easy proof: the walk is impossible since all nodes Easy proof: the walk is impossible since all nodes
have odd degreeshave odd degrees
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 4
Graph of the Königsberg bridge systemGraph of the Königsberg bridge system
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 5
A labeled directed graphA labeled directed graph
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 6
A rooted tree, exemplifying family A rooted tree, exemplifying family relationshipsrelationships
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 7
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 8
Finite State Machine (FSM)Finite State Machine (FSM)
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 9
(a) The finite state graph for a flip flop and
(b) its transition matrix.
Flip Flop FSMFlip Flop FSM
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 10
Finite State Accepting MachineFinite State Accepting Machine
Deterministic FSM: transition function for any input value Deterministic FSM: transition function for any input value to a state gives a unique next stateto a state gives a unique next state
Probabilistic FSM: the transition function defines a Probabilistic FSM: the transition function defines a distribution of output states for each input to a statedistribution of output states for each input to a state
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 11
(a)The finite state graph
(b)The transition matrix for string recognition example
String RecognitionString Recognition
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 12
State Space and SearchState Space and Search
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 13
• generated by “move blank” operations
-- up
-- left
-- down
-- left
State Space of the 8-Puzzle State Space of the 8-Puzzle
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 14
The travelling salesperson problemThe travelling salesperson problemFind the Find the shortest shortest path for the path for the salesperson salesperson to travel, to travel, visiting visiting each city each city and and returning to returning to the starting the starting citycity
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 15
Search for the travelling salesperson problem. Each arc is marked with the total weight of all paths from the start node (A) to its endpoint.
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 16
An instance of the travelling salesperson problem with the nearest neighbour path in bold. Note this path (A, E, D, B, C, A), at a cost of 550, is not the shortest path. The comparatively high cost of arc (C, A) defeated the heuristic.
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 17
Strategies for State Space SearchStrategies for State Space Search
Data-driven search – forward chainingData-driven search – forward chaining– Begin with the given facts and a set of legal Begin with the given facts and a set of legal
rules for changing statesrules for changing states– Apply rules to facts to produce new factsApply rules to facts to produce new facts– Repeat rules application until finding a path that Repeat rules application until finding a path that
satisfies the goal conditionsatisfies the goal conditionGoal-driven search – backward chainingGoal-driven search – backward chaining– Begin with the goal and a set of facts and legal Begin with the goal and a set of facts and legal
rulesrules– Search rules that generate this goalSearch rules that generate this goal– Determine conditions of these rules Determine conditions of these rules subgoals subgoals– Repeat until all conditions are factsRepeat until all conditions are facts
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 18
State space in which data-directed search prunes irrelevant data and their consequents and determines one of a number of possible goals.
Data-driven SearchData-driven Search
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 19
State space in which goal-directed search effectively prunes extraneous search paths.
Goal-driven SearchGoal-driven Search
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 20
Search and BacktrackSearch and Backtrack
Search – find a pathSearch – find a path
Backtrack – when the path is dead, Backtrack – when the path is dead, try otherstry others– Backtrack to the most recent node on Backtrack to the most recent node on
the path having unexamined siblingsthe path having unexamined siblings– Continue toward to a new pathContinue toward to a new path– Like a recursionLike a recursion– Implemented in Prolog as an internal Implemented in Prolog as an internal
mechanismmechanism
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 21
Backtrack algorithmBacktrack algorithm
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 22
Backtracking search of a hypothetical Backtracking search of a hypothetical state space space.state space space.
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 23
A trace of backtrack on the previous graphA trace of backtrack on the previous graph
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 24
Depth-First and Breadth-First SearchDepth-First and Breadth-First SearchDetermine the order of nodes (states) to Determine the order of nodes (states) to be examinedbe examinedDepth-first search Depth-first search – When a state is examined, all of its children When a state is examined, all of its children
and their descendants are examined before and their descendants are examined before any of its siblingsany of its siblings
– Go deeper into the search space where Go deeper into the search space where possiblepossible
Breadth-first searchBreadth-first search– When a state is examined, all of its children When a state is examined, all of its children
are examined after any of its siblingsare examined after any of its siblings– Explore the search space in a level-by-level Explore the search space in a level-by-level
fashionfashion
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 25
Graph for search examplesGraph for search examples
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 26
The breadth-first search algorithmThe breadth-first search algorithm
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 27
A trace of breadth-first searchA trace of breadth-first search
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 28
The graph at iteration 6 of breadth-first search. States on open and closed are highlighted
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 29
Breadth-first search of the 8-puzzle, showing order in which states were removed from open
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 30
The depth-first search algorithmThe depth-first search algorithm
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 31
A trace of depth-first searchA trace of depth-first search
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 32
The graph at iteration 6 of depth-first search. States on open and closed are highlighted
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 33
Depth-first search of 8-puzzle with a depth bound of 5
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 34
Comparison between breadth- and Comparison between breadth- and depth-first searchdepth-first search
Breadth-firstBreadth-first– Always find the shortest path to a goalAlways find the shortest path to a goal– High branching factor -- Combinatorial High branching factor -- Combinatorial
explosionexplosion
Depth-firstDepth-first– More efficient More efficient – May get lost May get lost
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 35
State Space Representation of State Space Representation of Logical SystemsLogical Systems
RepresentationRepresentation– Logical expressions as statesLogical expressions as states– Inference rules as linksInference rules as links
CorrectnessCorrectness– Soundness and completeness of Soundness and completeness of
predicate calculus inference rules predicate calculus inference rules guarantee the correctness of guarantee the correctness of conclusionsconclusions
Theorem ProofTheorem Proof– State space search State space search
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 36
State space graph of the State space graph of the propositional calculuspropositional calculus
• Letters as nodes• Implications as links
•qp•rp•vq•sr•tr•su
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 37
And/or graphAnd/or graph
• Or – separate
• And -- connected
• And/or graph of expression q r p
• And/or graph of the expression q r → p
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 38
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 39
And/or graph of a set of propositional And/or graph of a set of propositional calculus expressions.calculus expressions.
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 40
And/or graph of part of the state space for And/or graph of part of the state space for integrating a functionintegrating a function
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 41
The facts and rules of this example are given as English sentences followed by their predicate calculus equivalents:
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 42
The solution subgraph showing that Fred is at the museum.
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 43
Rules for a simple subset of English grammar are:
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 44
And/or graph for the grammar. Some of the nodes (np, art, etc) have been written more than once to simplify drawing the graph.
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 45
And/or graph searched by the financial advisor.
CSC411CSC411 Artificial IntelligenceArtificial Intelligence 46
Parse tree for the sentence “The dog bites the man.”