![]() |
YAP 7.1.0
|
Prolog unification is not a complete implementation. More...
Prolog unification is not a complete implementation.
For efficiency considerations, Prolog systems do not perform occur checks while unifying terms As an example, X = a(X)
will not fail but instead will create an infinite term of the form a(a(a(a(a(...)))))
, or rational tree
Rational trees are now supported by default in YAP In previous versions, this was not the default and these terms could easily lead to infinite computation For example, X = a(X), X = X
would enter an infinite loop
The RATIONAL_TREES
flag improves support for these terms Internal primitives are now aware that these terms can exist, and will not enter infinite loops Hence, the previous unification will succeed Another example, X = a(X), ground(X)
will succeed instead of looping Other affected built-ins include the term comparison primitives, numbervars/3 , copy_term/2 , and the internal data base routines The support does not extend to Input/Output routines or to assert/1 YAP does not allow directly reading rational trees, and you need to use write_depth/2
to avoid entering an infinite cycle when trying to write an infinite term
class acyclic_term/1 |
#define UnifyAndTrailGlobalCells | ( | a, | |
b | |||
) |
int Yap_rational_tree_loop | ( | CELL * | pt0, |
CELL * | pt0_end, | ||
CELL ** | tovisit, | ||
CELL ** | tovisit_max | ||
) |
Macros | |
#define | IN_UNIFY_C 1 |
#define | HAS_CACHE_REGS 1 |
#define | tovisit_base ((struct v_record *)AuxSp) |
#define | tovisit_base ((struct v_record *)AuxSp) |
#define | UnifyAndTrailGlobalCells(a, b) |
Functions | |
int | Yap_rational_tree_loop (CELL *, CELL *, CELL **, CELL **) |
bool | Yap_IsAcyclicTerm (Term t) |
int | Yap_IUnify (register CELL d0, register CELL d1) |
int | Yap_Unifiable (Term d0, Term d1) |
void | Yap_InitAbsmi (void) |
void | Yap_TrimTrail (void) |