:- dynamic and_prod/3, and_godel/3, and_luka/3, or_prod/3, or_godel/3, or_luka/3, agr_aver/3, pri_prod/3, pri_div/3, pri_sub/3, pri_add/3, pri_min/3, pri_max/3.

member(n(X)):-number(X), 0=<X,X=<1.

leq(n(X),n(Y)):-X =< Y.

bot(n(0)).
top(n(1)).

and_prod(X,Y,Z) :- pri_prod(X,Y,Z).
and_godel(X,Y,Z) :- pri_min(X,Y,Z).
and_luka(X,Y,Z) :- pri_add(X,Y,U1), pri_sub(U1,n(1),U2), pri_max(U2,n(0),Z).

or_prod(X,Y,Z) :- pri_prod(X,Y,U1), pri_add(X,Y,U2), pri_sub(U2,U1,Z).
or_godel(X,Y,Z) :- pri_max(X,Y,Z).
or_luka(X,Y,Z) :- pri_add(X,Y,U1), pri_min(U1,1,Z).

agr_aver(X,Y,Z) :- pri_add(X,Y,U1),pri_div(U1,n(2),Z).

pri_prod(n(X),n(Y),n(Z)) :- Z is X * Y.
pri_div(n(X),n(Y),n(Z)) :- Z is X / Y.
pri_sub(n(X),n(Y),n(Z)) :- Z is X-Y.
pri_add(n(X),n(Y),n(Z)) :- Z is X+Y.
pri_min(n(X),n(Y),n(Z)) :- (X=<Y,Z=X;X>Y,Z=Y).
pri_max(n(X),n(Y),n(Z)) :- (X=<Y,Z=Y;X>Y,Z=X). % max(x,y) 
