logic - Prolog backtracks and executes other statements too -
assume have following facts:
sister(susan, jane). sister(karren,holtby). parent_of(susan,karren). parent_of(susan,holtby).
and following definitions:
sibling(x, y) :- sister(x, y). sibling(x, y) :- parent_of(z, x), parent_of(z, y).
is there reason why goal sibling(susan, jane)
gives true false. both definitions used?
is there way check definitions true , output true if so?
prolog tree based language. let's establish knowledge base
male(mark). female(mary). female(beth). brother(mark, mary). %mark brother of mary brother(mark, beth). %define sister sister(x,y) :- female(x), male(y), brother(y,x).
in case clause sister evaluated such:
- bind mary x
- bind mark y
- check knowledge base brother(mark, mary)
- return true if found
- bind beth x
- bind mark y
- check knowledge base brother(mark, beth)
- return true if found
- no other bindings exist, return false
in prolog possibilities tried. return true cases until can't find one, automatically return false (i.e. nothing can satisfy this). strength , confusion prolog.
Comments
Post a Comment