Presentation is loading. Please wait.

Presentation is loading. Please wait.

Forward Chaining (propositional) Recursive stack-based version of Back-chaining using Propositional Logic could be modified to handle... variables.

Similar presentations


Presentation on theme: "Forward Chaining (propositional) Recursive stack-based version of Back-chaining using Propositional Logic could be modified to handle... variables."— Presentation transcript:

1

2

3 Forward Chaining (propositional)

4 Recursive stack-based version of Back-chaining using Propositional Logic
could be modified to handle... variables (using unification) negation context (fail if sub-goal is repeated) Backchain(KB,query) stack {query} // initialize return BC(KB,stack) BC(KB,stack) if stack empty, return True goal  stack.pop() if goalKB, return BC(KB,stack) // a known fact for each rule a1..angoal in KB: stack.push(a1..an) result  BC(KB,stack) if result=True, return True remove a1..an from stack return False

5 KB = {CanBikeToWork  CanGetToWork
CanDriveToWork  CanGetToWork CanWalkToWork  CanGetToWork HaveBike  Sunny  CanBikeToWork OwnCar  CanDriveToWork HaveMoney  RentCar  CanDriveToWork HaveMoney  TaxiAvailable  CanDriveToWork Sunny  CanWalkToWork HaveUmbrella  CanWalkToWork Rainy, // facts HaveBike, HaveMoney, RentCar } query = CanGetToWork ?

6 {CanGetToWork} // initialize goal stack with query
{CanBikeToWork} // replace subgoal with rule 1 {HaveBike,Sunny} // push antecedents for rule 4 {Sunny} // HaveBike is fact, so pop it backtrack since Sunny in not a fact and can’t be proved {CanDriveToWork} // rule 2, another way CanGetToWork {OwnCar} // try rule 5 backtrack, not provable {HaveMoney,RentCar} // another way to prove CanDriveToWork {RentCar} // pop HaveMoney since known fact {} // success! empty goal stack, return True

7

8

9

10

11


Download ppt "Forward Chaining (propositional) Recursive stack-based version of Back-chaining using Propositional Logic could be modified to handle... variables."

Similar presentations


Ads by Google