% ================================================================= :- pred constr(bool). :- mode constr(in). :- ignore constr/1. % ==================================================== % Program. :- pred member(int,list(int),bool). :- mode member(in,in,out). member(X,[],B) :- B=false. member(X,[Y|Ys],B) :- constr( B=ite(X=Y,false,B1) ) , % error: false should be true member(X,Ys,B1). :- pred cons(int,list(int),list(int)). :- mode cons(in,in,out). cons(H,T,[H|T]). % ==================================================== % catamorphism :- pred listMin(list(int),bool,int). :- mode listMin(in,out,out). :- cata listMin/3-1. listMin([],IsDef,A) :- constr( ((~IsDef) & A=0) ). listMin([H|T],IsDef,Min) :- constr( (IsDef & ( Min = ite(IsDefT, ite(H B), (~B)))), listMin(L,IsDefMinL,MinL), member(X,L,B). :- pred ff2. ff2 :- % listMin constr( ~(MinHT =< H) ), cons(H,T,HT), listMin(HT,IsDefMinHT,MinHT). :- pred ff3. ff3 :- % cons constr( ~( IsDefMinHT & (MinHT = ite(IsDefMinT,ite(H