Problem Solving Well-formed predicate calculus expressions provide a means of describing objects and relations in a problem domain and inference rule. These inferences define a space that is searched to find a problem solution. Questions: • Is the problem solver guaranteed to find a solution? • Will the problem solver always terminate, or can it become caught in an infinite loop? • What is the complexity of the search process in terms of time usage? Space usage? • How can the interpreted most effectively reduce search complexity? • How can an interpreter be designed to most effectively utilize a representation language? PROBLEM STATE SPACE GRAPH!
GRAPH A graph consists of a set of nodes and a set of arcs and links connecting pairs of nodes. In the state space model of problem solving, the nodes of a graph are taken to represent discrete states in a problem solving process, such as the results of logical inferences or configuration of a game board. The arcs of the graph represent transitions between states. These transitions correspond to logical inferences or legal moves of a game. In expert systems for example, states describe our knowledge of a problem instance at some stage of a reasoning process. Expert knowledge in the form of If.. Then.. Else…, allows us to generate new information; the act of applying a rule is represented as an arc between states.
The city of Konigsberg The Austrian mathematician Leonhard Euler invented graph theory to solve the “bridges of Konigsberg problem”. The city of Konigsberg occupied both banks and two islands of a river. The islands and the riverbanks were connected by seven bridges: RIVERBANK 1 4 2 3 ISLAND 1 ISLAND 2 1 5 6 7 RIVERBANK 2
The city of Konigsberg (cont.) The bridges of Konigsberg problem asks if there is a walk around the city that crosses each bridge exactly once! Although the residents had failed to find such a walk and doubled that it was possible, no one had proved its impossibility. Euler graph theory rb1: riverbank 1 rb2: riverbank 2 rb1 b2 b4 b3 b1 i1 i2 b6 b7 b5 rb2
The city of Konigsberg (cont.) The graph representation ignores features such as distance and direction! Predicate Calculus: 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) rb1 b2 b4 b3 b1 i1 i2 b6 b7 b5 rb2
A river runs through it! North Shore F W C G South Shore A farmer wishes to carry a wolf (the family pet), a goat and a cabbage across a river, from the south to the north shore. The farmer is the proud owner of a small rowing boat called Bounty which he feels is easily up to the job. Unfortunately the boat is only large enough to carry at most the farmer and one other item. Worse again, if left unattended the wolf will eat the goat and the goat will eat the cabbage. How can the farmer safely transport the wolf, goat and cabbage to the opposite shore?
Problem Representation The key to problem solving is a good representation. A good representation scheme has the following properties:- • Make important objects and relations explicit • Suppress unimportant and irrelevant detail • Expose natural constraints • Concise – efficiently describe a given scenario • Complete – everything necessary can be described Described in English the river problem is confusing enough to be difficult to solve. It emphasizes irrelevant detail (the wolf being a family pet, the name of the boat etc.) and disguises relevant information (the position of the objects, etc.)
States & Operators We can come up with a much better representation… One way is to think in terms of states. A state is a description of a system at some point in time. Many problems can be formally defined by the following components: - • An initial state • A goal state • An operator set – each operator can transform one state into another A problem is solved by moving from the initial state to the goal state by applying valid operators in sequence – this defines the problem state space, the set of states reachable from a particular initial state. A problem solution is simply the set of operators (actions) needed to reach the goal state from the initial state
Initial 01 02 03 04 Goal
For Example… Consider again the farmer and his boat. In this problem state information can be represented in the form of the following 4-tuple ( a? b? c? d? ) Farmer Wolf Goat Cabbage • Each variable position stores the location of a particular object. For example the initial state where everyone is on the south bank is given by (S,S,S,S) while the goal state is represented by (N,N,N,N). There are 4 state transforming operators:- • Farmer-Takes-Self: • (a?,b?,c?,d?) (Opposite(a?), b?,c?,d?) • Farmer-Takes-Wolf: • (a?,b?,c?,d?) (Opposite(a?), Opposite(b?),c?,d?) • Farmer-Takes-Goat: • (a?,b?,c?,d?) (Opposite(a?), b?,Opposite(c?),d?) • Farmer-Takes-Cabbage: • (a?,b?,c?,d?) (Opposite(a?), b?, c?,Opposite( d?)) Finally, a state is safe as long as the wolf and goat or the goat and cabbage are not left unattended – this precondition each operator.
Cont.. Here is one 7 step solution to the boating problem. There are of course other possibilities. S1: (S,S,S,S) S2: (N,S,N,S) N F G F W G C W C S4: (S,S,N,S) S3: (N,N,N,S) F W G G C F W C S5: (S,N,S,S) S6: (N,N,S,N) W F W C F G C G S8: (N,N,N,N) S7: (S,N,S,N) F W G C W C F G