Recursive stackbased version of Backchaining using Propositional Logic could be modified to handle variables using unification negation context fail if subgoal is repeated BackchainKBquery ID: 934961
Download Presentation The PPT/PDF document "Forward Chaining (propositional)" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Slide2Slide3Forward Chaining (propositional)
Slide4Recursive 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 a
1
..a
n
goal in KB:
stack.push(a
1
..a
n
)
result
BC(KB,stack)
if result=True, return True
remove
a
1
..a
n
from stack
return False
Slide5KB =
{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 ?
Slide6{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
Slide7Slide8Slide9Slide10Slide11