The normal method of defining relations in Common Prolog is to use the defrel
macro:
(defrel <relation name> [(declare declaration*)] <clause1> . . <clauseN>)
where each <clause>
is of the form:
(<clause-head> <subgoal1> . . <subgoalN>)
and declarations may include: (mode arg-mode*)
and any of the normal Lisp optimization declarations. Mode declarations determine how much clause indexing will be done on the predicate and can also streamline generated code for a predicate that will only be used in certain ways. A mode declaration consists of the word "MODE" followed by a mode spec for each argument position of the predicate. The possible argument mode specs are:
? |
Generate completely general code for this arg and don't index on it. |
?* |
Generate completely general code and index. |
+ |
Generate code assuming this argument will be bound on entry and index. |
- |
Generate code assuming this argument will be unbound on entry and don't index. |
The default mode specs are ?*
for the first argument and ?
for all the rest.
KnowledgeWorks and Prolog User Guide (Windows version) - 01 Dec 2021 19:36:05