% Predicates in lambda Prolog that define some of `higher-order'
% mapping operations.
module preds.
% Relates a binary predicate P and two lists if corresponding elements
% of the two lists are P-related.
mappred P nil nil.
mappred P (X :: L) (Y :: K) :- P X Y, mappred P L K.
% Relates a predicate and a list if every element in the list satisfies P.
forevery P nil.
forevery P (X :: L) :- P X, forevery P L.
% Relates a predicate and a list if some element in the list satisfies P.
forsome P (X :: L) :- P X ; forsome P L.
% Relates a predicate with two lists if the second is a subkist of the
% first, all of whose elements are members of the first list.
sublist P (X::L) (X::K) :- P X, sublist P L K.
sublist P (X::L) K :- sublist P L K.
sublist P nil nil.
% Transitive closure of a relation
trans R X Y :- R X Y.
trans R X Z :- R X Y, trans R Y Z.