meta-predicate

Definition of Reflexive Transitive Closure

我只是一个虾纸丫 提交于 2019-11-25 22:45:22
问题 Many predicates essentially use some form of transitive closure, only to discover that termination has to be addressed too. Why not solve this once and forever with closure0/3 : :- meta_predicate closure0(2,?,?). :- meta_predicate closure(2,?,?). :- meta_predicate closure0(2,?,?,+). % internal closure0(R_2, X0,X) :- closure0(R_2, X0,X, [X0]). closure(R_2, X0,X) :- call(R_2, X0,X1), closure0(R_2, X1,X, [X1,X0]). closure0(_R_2, X,X, _). closure0(R_2, X0,X, Xs) :- call(R_2, X0,X1), non_member(X1

Most general higher-order constraint describing a sequence of integers ordered with respect to a relation

*爱你&永不变心* 提交于 2019-11-25 22:36:01
问题 In CLP(FD), we frequently need to state: \"This is a list of integers and finite domain variables in (sometimes: strictly ) ascending/descending order.\" Is there any CLP(FD) system that provides a general (parametrisable) built-in constraint for this task? SWI-Prolog provides a constraint called chain/2 , which is similar to what I am looking for. However, the name is slightly too specific to encompass all relations that the constraint can describe (example: #< is not a partial order but