/* Term ordering example. */ /* This example demonstrates how different orders in the body of the father predicate can make a big difference in efficency. */ /* Note, a predicate of the form pred(X,Y) should be read "X is the pred of Y" */ parent(P,C) :- child(C,P). father(F,C) :- male(F), child(C,F). % inefficient father2(F,C) :- child(C,F), male(F). % efficient mother(M,C) :- child(C,M), female(M). female(marge). female(maggie). female(lisa). male(mr_burns). male(krusty). male(wiggum). male(ralph). male(homer). male(bart). child(lisa, marge). child(lisa, homer). child(bart, homer). child(maggie, homer).