Download presentation
Presentation is loading. Please wait.
Published byHendra Sudirman Modified over 6 years ago
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 goalKB, return BC(KB,stack) // a known fact for each rule a1..angoal 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.