YAP 7.1.0
terms.yap
1/*************************************************************************
2* *
3* YAP Prolog *
4* *
5* Yap Prolog was developed at NCCUP - Universidade do Porto *
6* *
7* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
8* *
9**************************************************************************
10* *
11* File: terms.yap *
12* Last rev: 5/12/99 *
13* mods: *
14* comments: Term manipulation operations *
15* *
16*************************************************************************/
17:- module(terms, [
21 instantiated_term_hash/4,
25
28 variable_in_term/2,
31 ]).
32
33
34/** @defgroup Terms Utilities On Terms
35@ingroup YAPLibrary
36@{
37
38The next routines provide a set of commonly used utilities to manipulate
39terms. Most of these utilities have been implemented in `C` for
40efficiency. They are available through the
41`use_module(library(terms))` command.
42
43*/
44/**
45 @pred cyclic_term(? _Term_)
46
47Succeed if the argument _Term_ is a cyclic term.
48
49*/
50
51
52/** @pred term_subsumer(? _T1_, ? _T2_, ? _Subsumer_)
53
54Succeed if _Subsumer_ unifies with the least general
55generalization over _T1_ and
56 _T2_.
57*/
58
59
60
61/** @pred new_variables_in_term(+ _Variables_,? _Term_, - _OutputVariables_)
62
63Unify _OutputVariables_ with all variables occurring in _Term_ that are not in the list _Variables_.
64*/
65
66
67/** @pred subsumes(? _Term1_, ? _Term2_)
68
69Succeed if _Term1_ subsumes _Term2_. Variables in term
70 _Term1_ are bound so that the two terms become equal.
71*/
72
73/** @pred subsumes_chk(? _Term1_, ? _Term2_)
74
75Succeed if _Term1_ subsumes _Term2_ but does not bind any
76variable in _Term1_.
77*/
78
79/** @pred term_hash(+ _Term_, + _Depth_, + _Range_, ? _Hash_)
80
81Unify _Hash_ with a positive integer calculated from the structure
82of the term. The range of the positive integer is from `0` to, but
83not including, _Range_. If _Depth_ is `-1` the whole term
84is considered. Otherwise, the term is considered only up to depth
85`1`, where the constants and the principal functor have depth
86`1`, and an argument of a term with depth _I_ has depth _I+1_.
87
88
89*/
90/** @pred term_hash(+ _Term_, ? _Hash_)
91
92
93
94If _Term_ is ground unify _Hash_ with a positive integer
95calculated from the structure of the term. Otherwise the argument
96 _Hash_ is left unbound. The range of the positive integer is from
97`0` to, but not including, `33554432`.
98
99
100*/
101/** @pred unifiable(? _Term1_, ? _Term2_, - _Bindings_)
102
103
104
105Succeed if _Term1_ and _Term2_ are unifiable with substitution
106 _Bindings_.
107
108
109
110
111 */
112/** @pred variables_within_term(+ _Variables_,? _Term_, - _OutputVariables_)
113
114
115
116Unify _OutputVariables_ with the subset of the variables _Variables_ that occurs in _Term_.
117
118
119*/
120/** @pred variant(? _Term1_, ? _Term2_)
121
122
123
124Succeed if _Term1_ and _Term2_ are variant terms.
125
126
127*/
128%term_hash(X,Y) :-
129% term_hash(X,-1,16'1000000,Y).
130
131subsumes_chk(X,Y) :-
132 \+ \+ subsumes(X,Y).
133
134
135
136/** @} */
137
138
subsumes(? Term1, ? Term2)
subsumes_chk(? Term1, ? Term2)
term_hash(+ Term, ? Hash)
term_hash(+ Term, + Depth, + Range, ? Hash)
term_subsumer(? T1, ? T2, ? Subsumer)
unifiable(? Term1, ? Term2, - Bindings)
variables_within_term(+ Variables,? Term, - OutputVariables)
variant(? Term1, ? Term2)
cyclic_term( + T )
new_variables_in_term(+_CurrentVariables_, ? Term, -_Variables_)