Chapter 3 Structures and Strategies For Space State

  • Slides: 46
Download presentation
Chapter 3 Structures and Strategies For Space State Search Contents • Graph Theory •

Chapter 3 Structures and Strategies For Space State Search Contents • Graph Theory • Strategies for Space State Search • Using the Space State to Represent Reasoning with the Predicate Calculus CSC 411 Artificial Intelligence 1

The city of Königsberg Leonhard Euler Problem: if there is a walk around the

The city of Königsberg Leonhard Euler Problem: if there is a walk around the city that crosses each bridge exactly once? CSC 411 Artificial Intelligence 2

Representations Predicate calculus: connect(X, Y, Z) connect(i 1, i 2, b 1) connect(rb 1,

Representations Predicate calculus: connect(X, Y, Z) connect(i 1, i 2, b 1) connect(rb 1, i 1, b 2) connect(rb 1, i 1, b 3) connect(rb 1, i 2, b 4) connect(rb 2, i 1, b 5) connect(rb 2, i 1, b 6) connect(rb 2, i 2, b 7) Graph theory connect(i 2, connect(i 1, connect(i 2, i 1, b 1) rb 1, b 2) rb 1, b 3) rb 1, b 4) rb 2, b 5) rb 2, b 6) rb 2, b 7) – Nodes – Linkes – Easy proof: the walk is impossible since all nodes have odd degrees CSC 411 Artificial Intelligence 3

Graph of the Königsberg bridge system CSC 411 Artificial Intelligence 4

Graph of the Königsberg bridge system CSC 411 Artificial Intelligence 4

A labeled directed graph CSC 411 Artificial Intelligence 5

A labeled directed graph CSC 411 Artificial Intelligence 5

A rooted tree, exemplifying family relationships CSC 411 Artificial Intelligence 6

A rooted tree, exemplifying family relationships CSC 411 Artificial Intelligence 6

CSC 411 Artificial Intelligence 7

CSC 411 Artificial Intelligence 7

Finite State Machine (FSM) CSC 411 Artificial Intelligence 8

Finite State Machine (FSM) CSC 411 Artificial Intelligence 8

Flip Flop FSM (a) The finite state graph for a flip flop and (b)

Flip Flop FSM (a) The finite state graph for a flip flop and (b) its transition matrix. CSC 411 Artificial Intelligence 9

Finite State Accepting Machine Deterministic FSM: transition function for any input value to a

Finite State Accepting Machine Deterministic FSM: transition function for any input value to a state gives a unique next state Probabilistic FSM: the transition function defines a distribution of output states for each input to a state CSC 411 Artificial Intelligence 10

String Recognition (a) The finite state graph (b)The transition matrix for string recognition example

String Recognition (a) The finite state graph (b)The transition matrix for string recognition example CSC 411 Artificial Intelligence 11

State Space and Search CSC 411 Artificial Intelligence 12

State Space and Search CSC 411 Artificial Intelligence 12

State Space of the 8 -Puzzle • generated by “move blank” operations • --

State Space of the 8 -Puzzle • generated by “move blank” operations • -- up • -- left • -- down • -- left CSC 411 Artificial Intelligence 13

The travelling salesperson problem Find the shortest path for the salesperson to travel, visiting

The travelling salesperson problem Find the shortest path for the salesperson to travel, visiting each city and returning to the starting city CSC 411 Artificial Intelligence 14

Search for the travelling salesperson problem. Each arc is marked with the total weight

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. CSC 411 Artificial Intelligence 15

An instance of the travelling salesperson problem with the nearest neighbour path in bold.

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. CSC 411 Artificial Intelligence 16

Strategies for State Space Search Data-driven search – forward chaining – Begin with the

Strategies for State Space Search Data-driven search – forward chaining – Begin with the given facts and a set of legal rules for changing states – Apply rules to facts to produce new facts – Repeat rules application until finding a path that satisfies the goal condition Goal-driven search – backward chaining – Begin with the goal and a set of facts and legal rules – Search rules that generate this goal – Determine conditions of these rules subgoals – Repeat until all conditions are facts CSC 411 Artificial Intelligence 17

Data-driven Search State space in which data-directed search prunes irrelevant data and their consequents

Data-driven Search State space in which data-directed search prunes irrelevant data and their consequents and determines one of a number of possible goals. CSC 411 Artificial Intelligence 18

Goal-driven Search State space in which goal-directed search effectively prunes extraneous search paths. CSC

Goal-driven Search State space in which goal-directed search effectively prunes extraneous search paths. CSC 411 Artificial Intelligence 19

Search and Backtrack Search – find a path Backtrack – when the path is

Search and Backtrack Search – find a path Backtrack – when the path is dead, try others – Backtrack to the most recent node on the path having unexamined siblings – Continue toward to a new path – Like a recursion – Implemented in Prolog as an internal mechanism CSC 411 Artificial Intelligence 20

Backtrack algorithm CSC 411 Artificial Intelligence 21

Backtrack algorithm CSC 411 Artificial Intelligence 21

Backtracking search of a hypothetical state space. CSC 411 Artificial Intelligence 22

Backtracking search of a hypothetical state space. CSC 411 Artificial Intelligence 22

A trace of backtrack on the previous graph CSC 411 Artificial Intelligence 23

A trace of backtrack on the previous graph CSC 411 Artificial Intelligence 23

Depth-First and Breadth-First Search Determine the order of nodes (states) to be examined Depth-first

Depth-First and Breadth-First Search Determine the order of nodes (states) to be examined Depth-first search – When a state is examined, all of its children and their descendants are examined before any of its siblings – Go deeper into the search space where possible Breadth-first search – When a state is examined, all of its children are examined after any of its siblings – Explore the search space in a level-by-level fashion CSC 411 Artificial Intelligence 24

Graph for search examples CSC 411 Artificial Intelligence 25

Graph for search examples CSC 411 Artificial Intelligence 25

The breadth-first search algorithm CSC 411 Artificial Intelligence 26

The breadth-first search algorithm CSC 411 Artificial Intelligence 26

A trace of breadth-first search CSC 411 Artificial Intelligence 27

A trace of breadth-first search CSC 411 Artificial Intelligence 27

The graph at iteration 6 of breadth-first search. States on open and closed are

The graph at iteration 6 of breadth-first search. States on open and closed are highlighted CSC 411 Artificial Intelligence 28

Breadth-first search of the 8 -puzzle, showing order in which states were removed from

Breadth-first search of the 8 -puzzle, showing order in which states were removed from open CSC 411 Artificial Intelligence 29

The depth-first search algorithm CSC 411 Artificial Intelligence 30

The depth-first search algorithm CSC 411 Artificial Intelligence 30

A trace of depth-first search CSC 411 Artificial Intelligence 31

A trace of depth-first search CSC 411 Artificial Intelligence 31

The graph at iteration 6 of depth-first search. States on open and closed are

The graph at iteration 6 of depth-first search. States on open and closed are highlighted CSC 411 Artificial Intelligence 32

Depth-first search of 8 -puzzle with a depth bound of 5 CSC 411 Artificial

Depth-first search of 8 -puzzle with a depth bound of 5 CSC 411 Artificial Intelligence 33

Comparison between breadth- and depth-first search Breadth-first – Always find the shortest path to

Comparison between breadth- and depth-first search Breadth-first – Always find the shortest path to a goal – High branching factor -- Combinatorial explosion Depth-first – More efficient – May get lost CSC 411 Artificial Intelligence 34

State Space Representation of Logical Systems Representation – Logical expressions as states – Inference

State Space Representation of Logical Systems Representation – Logical expressions as states – Inference rules as links Correctness – Soundness and completeness of predicate calculus inference rules guarantee the correctness of conclusions Theorem Proof – State space search CSC 411 Artificial Intelligence 35

State space graph of the propositional calculus • Letters as nodes • Implications as

State space graph of the propositional calculus • Letters as nodes • Implications as links • q p • r p • v q • s r • t r • s u CSC 411 Artificial Intelligence 36

And/or graph • Or – separate • And -- connected • And/or graph of

And/or graph • Or – separate • And -- connected • And/or graph of expression q r p • And/or graph of the expression q r → p CSC 411 Artificial Intelligence 37

CSC 411 Artificial Intelligence 38

CSC 411 Artificial Intelligence 38

And/or graph of a set of propositional calculus expressions. CSC 411 Artificial Intelligence 39

And/or graph of a set of propositional calculus expressions. CSC 411 Artificial Intelligence 39

And/or graph of part of the state space for integrating a function CSC 411

And/or graph of part of the state space for integrating a function CSC 411 Artificial Intelligence 40

The facts and rules of this example are given as English sentences followed by

The facts and rules of this example are given as English sentences followed by their predicate calculus equivalents: CSC 411 Artificial Intelligence 41

The solution subgraph showing that Fred is at the museum. CSC 411 Artificial Intelligence

The solution subgraph showing that Fred is at the museum. CSC 411 Artificial Intelligence 42

Rules for a simple subset of English grammar are: CSC 411 Artificial Intelligence 43

Rules for a simple subset of English grammar are: CSC 411 Artificial Intelligence 43

And/or graph for the grammar. Some of the nodes (np, art, etc) have been

And/or graph for the grammar. Some of the nodes (np, art, etc) have been written more than once to simplify drawing the graph. CSC 411 Artificial Intelligence 44

And/or graph searched by the financial advisor. CSC 411 Artificial Intelligence 45

And/or graph searched by the financial advisor. CSC 411 Artificial Intelligence 45

Parse tree for the sentence “The dog bites the man. ” CSC 411 Artificial

Parse tree for the sentence “The dog bites the man. ” CSC 411 Artificial Intelligence 46