In standard PROLOG
X = male
In micro PROLOG
tom(X)
---------
tom(male)
mP has Tabular output.
>
> -? wff(if(1,0))
> having found wff(X) :- t(X).
> wants to evaluate t(if(1,0)).
> having found t(if(X,Y)) :- if(X,Y).
> wants to evaluate if(1,0).
> having found if(X,Y) := t(X), t(Y).
> wants to evalueate t(1).
> Find t(1)
> RETURNS success.
> wants to evaluate t(0).
> RETURNS failure.
> wants to evaluate t(if(if(1,0),Y) :- if(if(1,0),Y)
> wants to evaluate if(1,0)
> ...
Haha! Very clever Gary!
Here is a FOX, GOAT, LETTUCE problem for you to try.
f(0).
t(1).
f(1) :- t(0).
t(0) :- f(1).
f(f(X)) :- t(X).
wff(X) :- t(X).
wff(X) :- f(X).
what(X,true) :- t(X).
what(X,false) :- f(X).
t(if(X,Y)) :- t(X), t(Y).
t(if(X,Y)) :- f(X), f(Y).
t(if(X,Y)) :- f(X), t(Y).
t(or(X,Y)) :- t(X).
t(or(X,Y)) :- t(Y).
t(and(X,Y)) :- t(X),t(Y).
t(iff(X,Y)) :- t(X),t(Y).
t(iff(X,Y)) :- f(X),f(Y).
t(xor(X,Y)) :- t(X),f(Y).
t(xor(X,Y)) :- f(X),t(Y).
f(if(X,Y)) :- t(X),f(Y).
f(or(X,Y)) :- f(X),f(Y).
f(and(X,Y)) :- f(X).
f(and(X,Y)) :- f(Y).
f(iff(X,Y)) :- t(X),f(Y).
f(iff(X,Y)) :- f(X),t(Y).
f(xor(X,Y)) :- t(X),t(Y).
f(xor(X,Y)) :- f(X),f(Y).
t(R) :- if(L,R), t(L).
if( river(M,F,F,L,T), river(F,F,F,L,T) ). ***
if( river(M,F,G,G,T), river(G,F,G,G,T) ).
river(0,0,0,0,0).
river(f(M),f(F),G,L2,s(T)) :- river(M,F,G,L,T).
river(f(M),F,f(G),L2,s(T)) :- river(M,F,G,L,T).
river(M,F,G,L2,s(T)) :- river(f(M),f(F),G,L,T).
river(M,F,G,L2,s(T)) :- river(f(M),G,f(G),L,T).
*** = if the Fox and Goat are on the same side of the river at the
same time T
then the Man must be on the same side as them. F,F,F (all on same
side)
I got it working out simple trips across the River.
?- river(A,B,C,D,s(s(0))).
This will return all the possible trips after crossing the river
twice!
Herc