This package defines operations on terms for subsumption checking, "anti-unification", unification with occurs-check, testing acyclicity, and getting the variables.
To load the package, enter the query
| ?- use_module(library(terms)).
subsumes_chk(?General, ?Specific)
subsumes_chk(f(X), f(a)). true | ?- subsumes_chk(f(a), f(X)). no | ?- subsumes_chk(A-A, B-C). no | ?- subsumes_chk(A-B, C-C). true
subsumes(?General, ?Specific)
variant(?Term, ?Variant)
term_subsumer(?Term1, ?Term2, ?General)
| ?- term_subsumer(f(g(1,h(_))), f(g(_,h(1))), T). T = f(g(_B,h(_A))) | ?- term_subsumer(f(1+2,2+1), f(3+4,4+3), T). T = f(_A+_B,_B+_A)
term_hash(?Term, ?Hash)
term_hash(?Term, +Depth, +Range, ?Hash)
[-33554432,33554431]
, the hash value will be platform dependent.
Otherwise, the hash value will be identical across runs and platforms.
The depth of a term is defined as follows: the (principal functor
of) the term itself has depth 1, and an argument of a term with depth
i has depth i+1.
Depth should be an integer >= -1. If Depth = -1 (the default),
Term must be ground, and all subterms of Term are relevant
in computing Hash. Otherwise, only the subterms up to depth
Depth of Term are used in the computation.
Range should be an integer >= 1. The default will give hash values
in a range appropriate for all platforms.
| ?- term_hash([a,b,_], 3, 4, H). H = 2 | ?- term_hash([a,b,_], 4, 4, H). true | ?- term_hash(f(a,f(b,f(_,[]))), 2, 4, H). H = 2
term_hash/(2,4)
is provided primarily as a tool for the construction
of sophisticated Prolog clause access schemes. Its intended use is to
generate hash values for terms that will be used with first argument
clause indexing, yielding compact and efficient multi-argument or deep
argument indexing.
term_variables(?Term, ?Variables)
unify_with_occurs_check(?X, ?Y) [ISO]
acyclic_term(?X)
cyclic_term(?X)
Go to the first, previous, next, last section, table of contents.