200 likes | 437 Views
State Space Representation:. Representing Logic by Graph. Motivations. You have seen how to use first-order logic to represent knowledge and programs. Prolog is happy to do reasoning by this kind of logical representation.
E N D
State Space Representation: Representing Logic by Graph
Motivations • You have seen how to use first-order logic to represent knowledge and programs. • Prolog is happy to do reasoning by this kind of logical representation. • Humans, however, prefer to reason with pictures, diagrams, geometries, and mathematical spaces. • In this lecture, you will learn about one such representation call state space.
Objectives • Logical representation to graph representation • Finite state machines • State space
Königsberg bridges • Königsberg is today's Kaliningrad in Russia. • Problem: Is there a walk around the city that crosses each bridge exactly once? • Swiss Mathematician, Leonhard Euler, solved the problem.
Predicate representation Predicate calculus: • connect(X, Y, B) connect(Y, X, B)X, Y are land places • Interpretation: connect(i1, i2, b1) connect(i2, i1, b1) connect(rb1, i1, b2) connect(i1, rb1, b2) connect(rb1, i1, b3) connect(i1, rb1, b3) connect(rb1, i2, b4) connect(i2, rb1, b4) connect(rb2, i1, b5) connect(i1, rb2, b5) connect(rb2, i1, b6) connect(i1, rb2, b6) connect(rb2, i2, b7) connect(i2, rb2, b7) • Again: Is there a walk around the city that crosses each bridge exactly once?
Graph representation • Use a node to represent a riverbank place or an island place • 2 riverbank places • 2 island places • use an arc to represent a bridge • 7 bridges • Again: Is there a walk around the city that crosses each bridge exactly once?
Euler's Proof • Degree of a node is the number arcs joining it. • Ignore the beginning and the end nodes of the walk. • Focus on just one intermediate node, you must come via one bridge and leave via a different bridge. • You cannot stay in this node because it is not the beginning node or end node. • This node must have an even number degree. • But all nodes here have odd degrees. • Therefore, the walk is impossible.
Finite State Machine: Flip Flop (a) The finite state graph for a flip flop and (b) its transition matrix.
String Recognition • The finite state graph • The transition matrix for string recognition example
State Space of the 8-Puzzle • “move blank” operations • -- up • -- left • -- down • -- left
FW F FG FC FW State space graph F, W, G, C
Travelling salesperson problem Find the shortest path for the salesperson to travel, visiting each city and returning to the starting city.
Greedy heuristic: Visit the closest one next Nearest neighbour path (A, E, D, B, C, A).Cost is 550. Are there better ways to search in this intractable space?
Summary • Given a problem • The right representation will facilitate in finding a solution. • In some cases, graph representation is better map representation or predicates. • In programming, choosing the right data structures will help you to write better codes or software.