Artificial Intelligence Chapter 3 Structures and Strategies For State Space Search
• Introduction • Structures for State Space search •Graph Theory •The Finite State Machine •State representation of problems • Strategies for Space State Search •Data driven – Goal driven search •Depth Search – Breadth search •Depth First search with Iterative Deepening • Using the State Space to represent Reasoning with the propositional and predicate calculus •And /Or Graphs •Examples
Introduction The importance of the problem space
choice of a problem space makes a big difference in fact, finding a good abstraction is half of the problem Intelligence is needed to figure out what problem space to use the human problem solver is conducting a search in the space of problem spaces
theory of state space search is a primary tool for representing a problem as a state space graph . using graph theory to analyze the structure and complexity of the problem and the search procedure we employ to solve it
The city of Königsberg
Swiss Leonhard Euler 18th cen Problem: if there is a walk around the city that crosses each bridge exactly once?
rb : river bank I : island b : bridge
Graph theory Nodes rb .b EULER noted WALK WAS IMPOSSIBLE UNLESS A GRAPH HAS EXACTLY ZERO OR TWO NODES OF ODD DEGREES Degree no of arcs joining a node
.i Linkes arcs .Representations
Euler’s invented Graph of the Königsberg bridge system.
rb1. b7) Connect :tow lands connected by a particular bridge
. i2. rb2. i2.using predicate calculus
calculus: connect(X. b7)connect(i2. rb1. b6)connect(i1. i1. i2. b4)connect(i2. rb2. b2) connect(rb1. Y. b1) connect(rb1. b6) connect(rb2. Z)
connect(i1. b2)connect(i1. b5) connect(rb2. i1. b5)connect(i1. i1. rb1. i1. i1. b4) connect(rb2.Representing Königsberg bridge system. b3)connect(i1. b1) connect(i2. rb2. b3) connect(rb1.
If Nj is also connected to Ni. A rooted tree has a unique node which has no parents called the root.N2.N2… and a set of arcs connecting the nodes Arcs are orded pairs of nodes ie arc(N3. The edge in the rooted tree are directed away from the root The path in a rooted tree is of length n-1 for a sequence of nodes (N1. Each node in a rooted tree has a unique parent. Nk and Nj are siblings. Nj is called the parent.…. and Nk is called the child.N4)… .)
A graph consists of a set of finite nodes N1. If a directed arc connects Nj and Nk.Nn.
Two nodes are said to be connected if a path exists that includes them both. Tip or Leaf node is the node that has no children
. A tree is a graph in which there is a unique path between every pair of nodes.)Graph Theory (cont’d
On the path of the rooted tree a node is called an ancestor of all node after it and a descendant of all nodes before it path that contains any node more than once is said to contain a cycle or loop.
Strucures for State Space Search
A labeled directed graph
Family relationships in a rooted tree
a is Root a is ancestor of g. i) children of c
(e f g h I j) Leaves or tips
. c . h and i
b is parent of( e f)
(b . h . d ) are siblings
b.e) are( connected
state machines or hierarchies of state machines are sometimes used to describe neurological systems and in linguistics — to describe the grammars of natural languages. communication protocol design. parsing and other engineering applications.org/wiki/Finite-state_machine
.Finite State Machine
Finite-state machines can solve a large number of problems.
There are several action types: Entry action
which is performed when entering the state which is performed when exiting the state which is performed depending on present state and input conditions which is performed when performing a certain transition
http://en.wikipedia. among which electronic design automation. In biology and artificial intelligence research.
)Finite State Machine (FSM
Flip Flop FSM
(a) The finite state graph for a flip flop and (b) its transition matrix.
FSM Used to recognize component of a formal language
S : Set of states – nodes I : Set of input values .The Finite State Machine
Finite State Machine is finite directed connected graph (S.path F : State transaction function
is an abstract model of computation. I .
”Example for FSM for recognizing all strings contain the exact sequence “abc Starting
(a)The finite state graph (b)The transition matrix for string recognition example (c)This called Moore machine – FS accepting M
Finite State Accepting Machine
There are tow FSM techniques
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
with initial state a set of operators (legal moves)which can change one state into another . Pathes are searched until either the goal description is satisfied or abandoned It is important to choose the best path according too the needs of the problem
.The State Space representation of Problems
The problem space consists of: a state space which is a set of states representing the possible configurations of the world.arcs The problem space can be viewed as a graph where the states are the nodes and the arcs represent the operators.
State Space and Search
State Space of Tic – Tac – Toe
•Start state : empty board •Goal state:board with 3x’s in row column diagonal •States are all possible configuration of X’s O’s •It’s a directed graph rather than a tree .goal can be reached by different states •No cycle •Complexity = 9!
or.The 8-puzzle problem as state space search
states: possible board positions operators: one for sliding each square in each of four directions.
. better. we need the path. one for moving the blank square in each of four directions initial state: some given board position goal state: some given board position Note: the “solution” is not interesting here.
State Space of the 8-Puzzle
• generated by “move blank” operations ∀↑ -- up ∀→ -- left ∀↓ -- down ∀← -- left • Cycles may occur:so it’s a graph-multiple parents
The travelling salesperson problem
Find the shortest path for the salesperson to travel, visiting each city and returning to the starting city
The travelling salesperson problem
Complexity = (n-1)!
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.
The goal is the lowest – cost path - Goal 2 reach path not a state
A) defeated the heuristic. A). D.26)n Greedy nearest neighbour( E. at a cost of 550. C. B. The comparatively high cost of arc (C.
. is not the shortest path.Other techniques for solving TSP –
Branch & bound with complexity=(1.
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 Continue until it generate a path that satisfies the goal condition Begin with the goal and a set of facts and legal rules Search rules that generate this goal Determine conditions must be true to use these rules (sub goals) Continue until it works back to the facts of the problem
Goal-driven search – backward chaining
of rules match the facts of the problem
.Goal Driven search
driven is suggested if :
A Goal is given or easily be formulated (diagnostic systems) (theorem to be proved) Data are not given but acquired by solver Large no.
State space in which goal-directed search effectively prunes extraneous search paths.
It measures the amount of absorption of a high frequency inductively coupled magnetic field by nearby object.org/wiki/Dipmeter
.Data Driven search
Driven is suggested if
All or most of the data are given (PROSPECTOR . http://en.Dipmeter) Large no of goals but few ways to use facts Difficult to form a goal
Dipmeter" is a measuring instrument to measure resonant frequency of radio frequency circuits.wikipedia.
State space in which data-directed search prunes irrelevant data and their consequents and determines one of a number of possible goals.
GDS & DDS
goal-driven and data-driven search the same state space graph Order and no. of states are different Preferred strategy is determined by:
Complexity of the rules Shape of state space Availability of problem data
Interactive Deepening search.Depth first. Uniform Cost •guarantee that solution is found •Heuristic search search process takes place by traversing search space with applied rules (information). •Techniques: Greedy Best First Search. •Techniques : Breadth First. A* Algorithm •There is no guarantee that solution is found.
TIN 5013: Artificial Intelligence
•Blind search traversing backtracking the search space until the goal nodes is found (might be doing exhaustive search).
Backtrack to the most recent node Continue until find goal or
on the path having unexamined siblings
all children been searched (backtrack fails back)
– find a path from start until reaches a goal (quit) or dead end (backtrack) Backtrack – when the path is dead.
Stack : From left
Stack : From left SL: start list-if the goal is found have the solution path NSL : nodes waiting evaluation DE: dead end CS :state to evaluate : goal state
.Backtracking search of a hypothetical state space space.
D . F . G
. E . B .The Breadth-first search
When a state is examined. all of its children are examined after any of its siblings (all nodes in a given level before any node in the next level) Explore the search space in a level-by-level fashion queue structured.states are added to the right and removed from the left FIFO
43 1 2
Order of search : A . C .
The breadth-first search algorithm
A trace of breadth-first search
The graph at iteration 6 of breadth-first search. States on open and closed are highlighted
showing order in which states were removed from open
.Breadth-first search of the 8-puzzle.
. all of its children and their descendants are examined before any of its siblings Go deeper into the search space where possible Stack structure descendant states are added and removed from the left of (open) list.Depth-first search
When a state is examined.
Depth-first search 5
The depth-first search algorithm
A trace of depth-first search
States on open and closed are highlighted
.The graph at iteration 6 of depth-first search.
Depth-first search of 8-puzzle with a depth bound of 5
depth d of the shallowest goal node.)
(Russel – Norvig
completeness Is the problem solver guaranteed to find a solution? time complexity how long does it take to find the solution? space complexity memory required for the search optimality When the solution is found is it guranteed to be optimal? main factors for complexity considerations: branching factor b. maximum path length m
High branching factor (high no of children for a state-in open list(need memory). complexity
Bn child on n level
Depth-first More efficient (gets quickly into a deep search space) suitable for graphs with many branches Complexity B*N (open contains just the children of a single state) May get lost missing shorter path or stuck with infinite long path does not lead to goal
.Comparison between breadth)and depth-first search (Luger
Choosing between depends on the problem properties (shortest path-branching factor-available time length – no of needed sol’s Breadth-first Always find the shortest path to a goal.
get exponentail time complexity for worst case
.Depth – first Search with Iterative Deepening
Use the the depth search with depth bound 1-if it fails another search with depth bound 2
Solution lies within a certain depth or time constraints Level by level search = shortest path & space usage =in n level = B*n Guaranteed to find a shortest solution (BFS) & space usage = B*n Complexity O(b*n) Time complexity = O(B^n) = no of nodes grows exponentaily
All these strategies.Blind .
)Iterative Deepening DFS (ID-DFS
TIN 5013: Artificial Intelligence
uninformed search.”Blind search“
and DFS are blind in the sense that they have no knowledge about the problem at all other than the problem space Such techniques are also called brute-force search. or weak methods
Using the State Space to Represent Reasoning with propositional and predicate Calculus
State Space Description of a Logical System AND/OR Graphs Further Examples and Applications MACSYMA (integration) Where is Fred? The Financial Advisor English Grammar
. such as determining whether a particular expression is a logical consequence of a given set of assertions. Inference rules can be used to create and describe the arcs between states. Problems in the predicate calculus. may be solved using search.State Space Description of a Logical System
The propositional and Predicate calculus can be used as the formal specification language for making nodes distinguishable as well as for mapping the nodes of a graph onto the state space.
p] corresponds to the sequence of inferences: s and s→r yields r.propositional calculus
Propositions that are logical consequences of the given set of assertions correspond to the nodes that may be reached along a directed path from a state representing a true proposition.r. r and r→p yields p.
. [s. Determining whether a given proposition is a logical consequence of a set of propositions becomes a problem of finding a path from a boxed node to the goal node.
State space graph of a set of implications
the arcs correspond to logical implications (→) propositions given true (s and t) correspond to the given data of the problem and represented as boxed nodes. v → q. r → p.
. s → u.propositional calculus
set of assertions : q → p. t. t → r. s. s → r.
General Name Formal Name Symbols
Not And Or If… Then/Implies If and only if
Negation Conjunction Disjunction Conditional Biconditional
The Truth Table
P Q NOT )¬(P AND OR P^Q PvQ Implies PQ Biconditional P Q
T T F F
T F T F
F F T T
T F F F
T T T F
T F T T
T F F T
variables_2.Predicate Calculus Logic
Basic idea : operator (variables_1. Universal quantifier (∀X) to show all object is true [Eg: All students (∀X (student (X))] Existential quantifier (∃ X) to show existence / partial object is true [ Eg: Some people ( ∃ X (people (X))]
.…) Example: “She likes chocolate” likes (she. chocolate).
and the arcs from this node are joined by a curved link.And/Or graphs
If the premises of an implication are connected by an ∧ operator.
. which connects nodes by sets of arcs. they are called AND nodes.
And/Or graph is actually a specialization of a type of graph known as a hypergraph.
.connected ∧ .And/or graph • And/or graph of expression q ∨r → p
Or – separate arcs
• And/or graph of the expression q ∧r → p
• and -.
a b c a ∧b d b∧ df a∧ c e f g a ∧e h •Is h true?
Example for goal directed strategy
.And/or graph of a set of propositional calculus expressions.
.And/Or graph Search
operator(and nodes) indicates a problem decomposition in which the problem is broken into subproblems such that all of the subproblems must be solved to solve the original problem. a point at which a choice may be made between alternative problem-solving strategies. ∨ operator indicates a selection.
Examples and Applications for and/or graph searching
is fred?” An English Language Parser and Sentence Generator The Financial Advisor Revisited
MACSYMA : An Example for goal directed.and/or graph
And/or graph of part of the state space for integrating a function (goal directed)
“Where is fred?”: Example for Checking
English sentences Goal-directed and/or graph
The facts and rules of this example are given as English sentences followed by their predicate calculus equivalents:
The solution subgraph showing that Fred is at the museum.
An English Language Parser and Sentence Generator
rules and transform it into another the pattern on one site of the ↔ with the pattern on the other side :
For changing expression from language to another Determine if sentences are well-formed sentences
Rules for a simple subset of English grammar are:
An English Language Parser and Sentence Generator:
A parser needs : Grammar rules Terminals : dictionary of words in the language ( a . bites)
And/or graph for the grammar. art. man . Some of the nodes (np. dog . the . likes .
. etc) have been written more than once to simplify drawing the graph.
•A Well –Formed expression in the grammar consists of terminals and that can be reduce to the sentence symbol •Use data –driven parsing (maching right hand side and replace by the pattern on left •Parsing is important for natural Languages– structuring compilers and interpretors for computer languages
.Parse tree for the sentence “The dog bites the man.
Generating legal sentences by a goal driven search
Begin with sentence as top level goal and end when no more rules to apply Create all acceptable sentence A sentence ia a np followed by a vp(1) Np is replaced by n (2) giving n vp Man is the first n available (8) giving man vp Np is satisfied and vp is attemped (3) replace vp with v giving man v Replace v with likes (10 Man likes the first acceptable sentence – there are 80 correct sentences Repeat until all possible state space has been searched Parsing and generating can be used for completing sentences (correctnes not symentic)
And/or graph searched by the financial advisor.
Press space to begin the search Size of Queue: 0 3 1 Nodes expanded: 0 3 2 1 Queue: Empty11. B. UCS has found the optimal route. 11. C CurrentFINISHED SEARCH action: Waiting…. C15 G B. Press space to end. In relation to path cost. GG S 10. Backtracking Expanding
TIN 5013: Artificial Intelligence
Current level: n/a 2 1 0
.Blind Search: Uniform-Cost
The goal state is achieved and the path S-B-G is returned. C A.