fruit(orange). veggie(peas). junk(chips). protein(steak). fiber(cereal). cal(orange,50). /* a better way: cal(Food,50) :- fruit(Food). */ cal(peas,20). cal(chips,100). cal(cereal,100). cal(steak,200). /* warning: the following do not work in queries where L is a variable */ good_breakfast(L) :- member(X,L), fiber(X), member(Y,L), fruit(Y). total([], 0). total([Head | Tail], T) :- cal(Head,X1), total(Tail, X2), T is X1 + X2. stay_on_diet(L) :- total(L,T), T < 500. good_diet(L) :- good_breakfast(L), protein(P), member(P,L), stay_on_diet(L).