A predicate is uniquely identified by its module (not always specified), name and arity (number of arguments). In Quintus Prolog these are the ways of specifying a predicate as an argument of a predicate:
clause/[2,3]
. This is the
case when one is manipulating Prolog programs themselves.
Module is optional; if omitted, the predicate is assumed to be in the source module.
When the skeletal specification is used as an input argument, the values of Term1,Term2, ...,TermN are not significant; they only serve as place-holders for determining the arity of Name. For example,
| ?- predicate_property(put(97), P1), predicate_property(put(98), P2). P1 = P2 = built_in ; no
When the skeletal specification is used as an output argument, Module:Name(Term1,Term2, ...,TermN) is made to be the most general term with name Name and arity N (that is, Term1, Term2, ..., TermN are each made to be variables, distinct from each other and any others in the system). For example,
| ?- compile(user). | foo(1, 2, 3). | ^D % user compiled, 0.100 sec 196 bytes yes | ?- source_file(X, user). X = foo(_224,_225,_226) ; no | ?- source_file(foo(7,8,9), user). yes
The Module:Name/Arity form is an alternative representation to the skeletal form. Arity can be a single arity, or a list of arities and/or arity ranges.
Module is optional; if omitted, the predicate is assumed to be in the current module. For example,
prog1:foo/1
specifies predicatefoo
, arity 1 in moduleprog1
.foo/1
specifies predicatefoo
of arity 1 in the current module.
Notes:
abolish/2
is the only predicate that does not use either of the
above specifications. Its first argument is the Name of the
predicate and the second argument is the Arity. For
consistency, it is recommended that abolish/1
be used instead.
The following predicate can be used to convert between the Name/Arity specification and the skeletal specification, or to verify that two specifications identify the same predicate.
predicate_specification(NameAritySpec, SkeletalSpec) :- (nonvar(NameAritySpec) ; nonvar(SkeletalSpec)), !, NameAritySpec = Name/Arity, functor(SkeletalSpec, Name, Arity), atom(Name).