:- op(1000,xfy,&). :- op(1100,xfy,exor). solve(true):- !. solve(\+P):- !, \+solve(P). solve( (P, Q) ) :- !, solve(P), solve(Q). solve(write(X)):-!,write(X). solve( P ) :- clause(P, Body), solve(Body). %Note: the 'write' isn't 'pure' prolog/logic %Also note that generating solutions (rather than testing) will be... wonky. %This next one's a bit silly. And, yes, I realize that SWI has a built-in xor. solve( (P exor Q) ):- !,(solve(P)->A=1;A=0),(solve(Q)->B=1;B=0),1 is A+B. %Also silly. An 'and' that *isn't* short-circuited! solve( (P & Q) ):- !,solve(P)->solve(Q);(solve(Q),fail). %Dummy Facts: person(earl). person(moo). person(mindy). %So, solve(person(moo)) succeeds, % solve(person(foxwell)) fails, % solve(person(X)) solves for X. % %solve(person(earl),person(mindy)) will NOT succeed, %however %solve((person(earl),person(mindy)) *will*!