:- 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(info(X,Y)):-number(X), 0=<X,X=<1, (Y=infty;number(Y)).

leq(info(X1,Y1),info(X2,Y2)):-X1 =< X2, (Y1=infty;Y1>=Y2).

bot(info(0,infty)).
top(info(1,0)).

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

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

agr_aver(info(X,Xw),info(Y,Yw),info(Z,Zw)) :- pri_add(X,Y,U1),pri_prod(U1,0.5,Z), pri_add(Xw,Yw,Zw).
agr_aver2(info(X,Xw),info(Y,Yw),info(Z,Zw)) :- or_godel(X,Y,U01), or_luka(X,Y,U02), pri_add(U01,U02,U1),pri_div(U1,2,Z), pri_add(Xw,Yw,Zw).

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