% ================================================================= :- pred constr(bool). :- mode constr(in). :- ignore constr/1. % ================================================================= % Program % rev(L,R): % list R is the reversal of list L :- pred rev(list(int),list(int)). :- mode rev(in,out). rev([],[X,Y]) :- constr(X (H= (H>=HdT & ResT))). % ------ listMin(L,IsDef,Min): IsDef=true iff L is a nonempty list and % if IsDef then Min is the minimum element on the list L :- pred listMin(list(int),bool,int). :- mode listMin(in,out,out). :- cata listMin/3-1. listMin([],IsDef,Min) :- constr( ~IsDef & Min=0 ). % 0 can be any int. listMin([H|T],IsDef,Min) :- listMin(T,IsDefT,MinT), constr( (IsDef & (Min = ite(IsDefT, ite(H=8>=7>=... :- pred ff1. ff1 :- constr( ~(BL=>BR) ), isASorted(L,BL), rev(L,R), isDSorted(R,BR). % ------ Verification of contract on snoc: :- pred ff2. ff2 :- constr( ~((BA & BE) => BC) ), isDSorted(A,BA), leq_all(X,A,BE), snoc(A,X,C), isDSorted(C,BC). % ========================================================== :- query ff1/0. :- query ff2/0. % ==========================================================