28
SUBMITTED TO: SUBMITTED BY: MR. RAVI KHATWAL KRATI KATYAL MCA 5 TH SEM AO* ALGORITHM & PROBLEM REDUCTION

And or graph problem reduction using predicate logic

Embed Size (px)

Citation preview

Page 1: And or graph problem reduction using predicate logic

SUBMITTED TO: SUBMITTED BY:MR. RAVI KHATWAL KRATI KATYAL

MCA 5TH SEM

AO* ALGORITHM & PROBLEM REDUCTION

Page 2: And or graph problem reduction using predicate logic

Topic Covered

AND/OR Graph AO* Problem Reduction Algorithm

Forward Chaining Backward Chaining

Proof Tree Generated by Forward/Backward Chaining References

Page 3: And or graph problem reduction using predicate logic

AND/OR graphs

Some problems are best represented as achieving subgoals, some of which achieved simultaneously and independently (AND)

Up to now, only dealt with OR options

Complete Assignment

Copy Assignment Study Topic Do Assignment

Page 4: And or graph problem reduction using predicate logic

Searching AND/OR graphs

A solution in an AND-OR tree is a sub tree whose leafs are included in the goal set

Cost function: sum of costs in AND nodef(n) = f(n1) + f(n2) + …. + f(nk)

How can we extend A* to search AND/OR trees? The AO* algorithm.

Page 5: And or graph problem reduction using predicate logic

AND/OR search

We must examine several nodes simultaneously when choosing the next move

A

B C D(3)(4)

(5)(9)

A

B C D38

E F G H I J17 9 27

(5) (10) (3) (4) (15) (10)

Page 6: And or graph problem reduction using predicate logic

AND/OR Best-First-Search

Traverse the graph (from the initial node) following the best current path.

Pick one of the unexpanded nodes on that path and expand it. Add its successors to the graph and compute f for each of them

Change the expanded node’s f value to reflect its successors. Propagate the change up the graph.

Reconsider the current best solution and repeat until a solution is found

Page 7: And or graph problem reduction using predicate logic

AND/OR Best-First-Search example

Page 8: And or graph problem reduction using predicate logic

AND/OR Best-First-Search example

Page 9: And or graph problem reduction using predicate logic

A Longer path may be better

Page 10: And or graph problem reduction using predicate logic

AO* algorithm

1. Let G be a graph with only starting node INIT.2. Repeat the followings until INIT is labeled SOLVED

or h(INIT) > FUTILITYa) Select an unexpanded node from the most promising path

from INIT (call it NODE)b) Generate successors of NODE. If there are none, set

h(NODE) = FUTILITY (i.e., NODE is unsolvable); otherwise for each SUCCESSOR that is not an ancestor of NODE do the following:

i. Add SUCCESSSOR to G.ii. If SUCCESSOR is a terminal node, label it SOLVED and set

h(SUCCESSOR) = 0.iii. If SUCCESSPR is not a terminal node, compute its h

Page 11: And or graph problem reduction using predicate logic

AO* algorithm (Cont.)

c) Propagate the newly discovered information up the graph by doing the following: let S be set of SOLVED nodes or nodes whose h values have been changed and need to have values propagated back to their parents. Initialize S to Node. Until S is empty repeat the followings:

i. Remove a node from S and call it CURRENT.ii. Compute the cost of each of the arcs emerging from CURRENT.

Assign minimum cost of its successors as its h.iii. Mark the best path out of CURRENT by marking the arc that

had the minimum cost in step iiiv. Mark CURRENT as SOLVED if all of the nodes connected to it

through new labeled arc have been labeled SOLVEDv. If CURRENT has been labeled SOLVED or its cost was just

changed, propagate its new cost back up through the graph. So add all of the ancestors of CURRENT to S.

Page 12: And or graph problem reduction using predicate logic

An Example

Page 13: And or graph problem reduction using predicate logic

An Example

Page 14: And or graph problem reduction using predicate logic

An Example

Page 15: And or graph problem reduction using predicate logic

An Example

Page 16: And or graph problem reduction using predicate logic
Page 17: And or graph problem reduction using predicate logic
Page 18: And or graph problem reduction using predicate logic
Page 19: And or graph problem reduction using predicate logic

Proof Tree Generated by Forward/Backward Chaining

Consider The Following Sentences1. It is a crime for an American to sell weapons to hostile Nations. 2. Pakistan has some missiles. 3. All of its(Paksitan’s) missiles were sold to it by Colonel West. 4. Missiles are weapons 5. Enemy of America counts as “hostile”. 6. West is American. 7. The country Pakistan is an enemy of America.

Page 20: And or graph problem reduction using predicate logic

a) Translate these sentenses into Formula in Predicate Logic.b) Prove that “West is criminal” using forward chaining.c) Prove that “West is criminal” using Backward chaining.

Page 21: And or graph problem reduction using predicate logic

Solution A:

1. ∀X, Y, Z american(X) ⋀ weapon(Y) ⋀ sells(X,Y,Z) ⋀ hostile(Z) → criminal(X)

2. ∃X owns(pakistan, X) ⋀ missile(X)3. ∀X missile(X) ⋀ owns(pakistan, X) → sells(west, X, pakistan)4. Missile(X) → weapon(X)5. Enemy(X, america) → hostile(X)6. American(west)7. Enemy(pakistan,america)

Page 22: And or graph problem reduction using predicate logic

Solution B: Own(pakistan,m1)⋀missile(m1) ⋀ american(west) ⋀ enemy(pakistan,

america)↓ Rule(3) and {m1/X}

Own(pakistan,m1)⋀missile(m1) ⋀ sells(west,m1, pakistan) ⋀ american(west) ⋀enemy(pakistan, america)

↓ Rule(4) and {m1/X} Own(pakistan,m1) ⋀ missile(m1) ⋀ weapon(m1) ⋀ sells(west, m1,

pakistan,) ⋀ enemy(pakistan, america) ⋀ american(west)↓ Rule(5) and {pakistan/X}

Own(pakistan,missile(m1) ⋀weapon(m1) ⋀ sells(west, m1, pakistan) ⋀ hostile(pakistan) ⋀ enemy(pakistan,america) ⋀ american(west)

↓ Rule(1) {west/X, Y/m1, Z/pakistan} criminal (west)

Page 23: And or graph problem reduction using predicate logic

Showing Procedure Using AND/OR Graph

Page 24: And or graph problem reduction using predicate logic

Solution C:

Here, we start with our goal as given in figure Criminal(west) ↑ Rule(1) & {west/X} american(west) ⋀ weapon(Y) ⋀ sells(wet, Y, Z) ⋀ hostile(Z) ↑ Rule(6) weapon(Y) ⋀ sells(west, Y, Z) ⋀ hostile(Z) ↑ Rule(5) & {Z/X} weapon(Y) ⋀ sells(west, Y, Z) ⋀ enemy(Z, America) ↑ Rule(7) & {pakistan/Z} weapon(Y) ⋀ sells(west, Y, pakistan) ↑ Rule(4) & {Y/X}

Page 25: And or graph problem reduction using predicate logic

missile(Y) ⋀ sells(west, Y, pakistan) ↑ Rule(2,b) and {Y/m1} sells(west, Y, pakistan) ↑ Rule(3) {Y/X} missile(Y) ⋀ owns(pakistan, Y) ↑ Rule(2, a)and (2, b) and {Y/m1} Nil

Page 26: And or graph problem reduction using predicate logic

Showing Procedure Using AND/OR Graph

Page 27: And or graph problem reduction using predicate logic

References

Book Reference Artificial Intelligence – Amit Barjatiya & Dinesh Diggiwal Artificial Intelligence – Russell & Norvig

Web Reference www.wikipedia.org artificialintelligence-notes.blogspot.in

Page 28: And or graph problem reduction using predicate logic