:- mpetest.psl -- test file for MPE.

:- op(700,xfx,'<=>').
:- op(700,xfx,'=>').


% here are some sample equal rules for MPE

% arithmatic.
X+Y => Sum :- nonvar(X),nonvar(Y),Sum is X+Y.
X-Y => Difference :- nonvar(X),nonvar(Y),Difference is X-Y.
X*Y => Product :- nonvar(X),nonvar(Y),Product is X*Y.
X/Y => Quotient :- nonvar(X),nonvar(Y),Quotient is X/Y.

factorial(N) => N*factorial(N-1) :- nonvar(N),N>0.
factorial(0) => 1.

% kornfeld's rational number example

rat(N1,D1) => rat(N2,D2) :- 
  times(N1,D2,X),
  times(N2,D1,X).

rat(N,1) => N.
rat(N,D) => I :- times(D,I,N).


  


% programming examples

appnd([X|U],V) => [X|appnd(U,V)].
appnd([],X) => X.


mbr(X,[X|_]) => true.
mbr(X,[_|Rest]) => mbr(X,Rest).


foo(2) if true.
