Challenge 2: Extending solve/1 With Disjunction and Negation — Possible Solution ==================================================================== meta_demo.pl: solve(true) :- !. solve((A, B)) :- !, solve(A), solve(B). solve((A ; B)) :- !, (solve(A) ; solve(B)). solve(\+ A) :- !, \+ solve(A). solve(A) :- clause(A, Body), solve(Body). likes(tom, pizza). likes(tom, sushi). Queries: ?- solve((likes(tom, pizza) ; likes(tom, tacos))). true. ?- solve(\+ likes(tom, tacos)). true. Explanation: The first query matches the new disjunction clause: solve((A ; B)) tries solve(likes(tom, pizza)) first, which succeeds directly via clause/2 (a matching fact), so the whole disjunction succeeds without ever needing to try the tacos branch. The second query matches the negation clause: solve(\+ A) calls \+ solve(likes(tom, tacos)) internally -- solve(likes(tom, tacos)) itself fails, since no such fact or rule exists for clause/2 to find, so \+ around that failed call succeeds, and solve/1 reports true. Both new clauses work by directly reusing Prolog's own real ; and \+ on the result of a recursive solve/1 call, exactly as the chapter describes -- no separate disjunction- or negation-solving logic was written from scratch. WHY THIS WORKS AS AN ANSWER ------------------------------ This adds the chapter's own disjunction and negation clauses unmodified, then exercises both with a fresh likes/2 example (not reusing the chapter's own parent/grandparent facts), confirming each new clause correctly delegates to Prolog's real ; and \+ rather than reimplementing their logic.