This article needs attention from experts!
By default Prolog does a top-down logic inference.
clever(joe). handsome(joe). hasgirlfriend(X):- clever(X),handsome(X).
We run this as "hasgirlfriend(X)." to get the people who have a girlfriend.
clever(joe). handsome(joe). rule([handsome(joe),clever(joe)],(hasgirlfriend(joe))). run:- call(rule(X,Y)),findall(A,(member(A,X),call(A)),L), length(X,Rulelength), length(L,Rulelength), assert(Y),print(Y).
We run this as "run.".
We don't have to directly ask who has a girlfriend, it gives us all results that can be implied. The benefit of bidirectional inferencing is the speed gain.Last modified on 11 May 2009, at 02:18