The predicates in this section are meta-logical and perform operations that require reasoning about the current instantiation of terms or decomposing terms into their constituents. Such operations cannot be expressed using predicate definitions with a finite number of clauses.
var(?X) ISO,meta-logicalvar is
short for variable). An uninstantiated variable is
one that has not been bound to anything, except possibly another
uninstantiated variable. Note that a compound term
with some components that are uninstantiated is not itself
considered to be uninstantiated. Thus the query
| ?- var(foo(X, Y)).
always fails, despite the fact that X and Y are
uninstantiated.
nonvar(?X) ISO,meta-logicalvar/1.
ground(?X) meta-logicalground/1 a monotone
predicate.
atom(?X) ISO,meta-logicalfloat(?X) ISO,meta-logicalinteger(?X) ISO,meta-logicalnumber(?X) ISO,meta-logicalatomic(?X) ISO,meta-logicalsimple(?X) meta-logicalcompound(?X) ISO,meta-logicalcallable(?X) meta-logicalis_mutable(?X) meta-logicalfunctor(+Term,?Name,?Arity) ISO,meta-logicalfunctor(?Term,+Name,+Arity) ISO,meta-logicalarg(+ArgNo,+Term,?Arg) ISO,meta-logical =.. ?List ISO =.. +List ISO | ?- product(0, n, n-1) =.. L.
L = [product,0,n,n-1]
| ?- n-1 =.. L.
L = [-,n,1]
| ?- product =.. L.
L = [product]
If Term is uninstantiated, then List must be
instantiated either to a list of determinate length whose
head is an atom, or to a list of length 1 whose
head is a number. Note that this predicate is not strictly
necessary, since its functionality can be provided by arg/3 and
functor/3, and using the latter two is usually more efficient.
name(+Const,?CharList) obsolescentname(?Const,+CharList) obsolescent | ?- name(product, L).
L = [112,114,111,100,117,99,116]
| ?- name(product, "product").
| ?- name(1976, L).
L = [49,57,55,54]
| ?- name('1976', L).
L = [49,57,55,54]
| ?- name((:-), L).
L = [58,45]
If Const is uninstantiated, CharList must be instantiated to a code-list. If CharList can be interpreted as a number, Const is unified with that number; otherwise, with the atom whose name is CharList. E.g.:
| ?- name(X, [58,45]).
X = :-
| ?- name(X, ":-").
X = :-
| ?- name(X, [49,50,51]).
X = 123
Note that there are atoms for which
name(Const,CharList) is true, but which will not be
constructed if name/2 is called with Const
uninstantiated. One such atom is the atom
'1976'. It is recommended that new programs use
atom_codes/2 or number_codes/2, as these predicates
do not have this inconsistency.
atom_codes(+Const,?CodeList) ISOatom_codes(?Const,+CodeList) ISOname(Const,CodeList), but Const is
constrained to be an atom.
number_codes(+Const,?CodeList) ISOnumber_codes(?Const,+CodeList) ISOname(Const,CodeList), but Const is
constrained to be a number.
atom_chars(+Const,?CharList) ISO onlyatom_chars(?Const,+CharList) ISO onlyatom_codes/2, but CharList is a
char-list instead of a code-list.
atom_chars(+Const,?CodeList) SICStus onlyatom_chars(?Const,+CodeList) SICStus onlyatom_codes(Const,CharList).
number_chars(+Const,?CharList) ISO onlynumber_chars(?Const,+CharList) ISO onlynumber_codes/2, but CharList is a
char-list instead of a code-list.
number_chars(+Const,?CodeList) SICStus onlynumber_chars(?Const,+CodeList) SICStus onlynumber_codes(Const,CharList).
char_code(+Char,?Code) ISOchar_code(?Char,+Code) ISOatom_length(+Atom,?Length) ISOatom_concat(+Atom1,+Atom2,?Atom12) ISOatom_concat(?Atom1,?Atom2,+Atom12) ISO | ?- atom_concat(A, B, 'ab').
A = '',
B = ab ? ;
A = a,
B = b ? ;
A = ab,
B = '' ? ;
no
sub_atom(+Atom,?Before,?Length,?After,?SubAtom) ISO | ?- sub_atom(abrakadabra, Before, _, After, ab).
After = 9,
Before = 0 ? ;
After = 2,
Before = 7 ? ;
no
copy_term(?Term,?CopyOfTerm) ISO,meta-logical copy_term(X, Y) :-
assert('copy of'(X)),
retract('copy of'(Y)).
The implementation of copy_term/2 conserves space by not copying
ground subterms.