Download Ciao Manual - The Ciao System

Transcript
586
The Ciao System
Declares determinacy conditions for a predicate. Conditions Cond are on variables of
arguments of Pred. For example, in:
:- determinate(member(A,B,C), ( A ?= term(B,[1]) ; C?=[_|_]) ).
member(A,[A|B],B).
member(A,[B|C],[B|D]) :A==B,
member(A,C,D).
the declaration states that a call member(A,B,C) is determinate when either A doesn’t
unify with the first argument of B or C doesn’t unify with [_|_].
Usage: :- determinate(Pred,Cond).
States that the predicate Pred is determinate when Cond holds.
− The following properties should hold at call time:
Pred is a Name/Arity structure denoting a predicate name:
predname(P/A) :atm(P),
nnegint(A).
(basic props:predname/1)
Cond is a determinacy condition.
(user(/home/ciaobot/ciaobotdata/pm ubuntu/source/master/CiaoDE/ciao/library/andorra/andorra doc):detcond/1)
112.3 Documentation on exports (andorra_doc)
detcond/1:
REGTYPE
Defined by:
detcond(ground(X)) :var(X).
detcond(nonvar(X)) :var(X).
detcond(instatiated(A,Path)) :var(A),
list(Path,int).
detcond(?\=(Term1,Term2)) :path(Term1),
path(Term2).
detcond(?=(Term1,Term2)) :path(Term1),
path(Term2).
detcond(Test) :( test Test ).
• ground/1 and nonvar/1 have the usual meaning.
• instatiated(A,Path) means that the subterm of A addressed by Path is not a variable. Path is a list of integer numbers describing a path to the subterm regarding the
whole term A as a tree. For example, instantiated(f(g(X),h(i(Z),Y)),[2,1])
tests whether i(Z) is not a variable.
• Term1 ?\= Term2 means “terms Term1 and Term2 do not unify (when instantiated)”.
Term1 and Term2 can be either an argument of the predicate or a term term(V,Path),
which refers to the subterm of V addressed by Path.