4.5 Verify Type of a Term

[ISO]var(+Term)
True if Term currently is a free variable.
[ISO]nonvar(+Term)
True if Term currently is not a free variable.
[ISO]integer(+Term)
True if Term is bound to an integer.
[ISO]float(+Term)
True if Term is bound to a floating point number.
rational(+Term)
True if Term is bound to a rational number. Rational numbers include integers.
rational(+Term, -Numerator, -Denominator)
True if Term is a rational number with given Numerator and Denominator. The Numerator and Denominator are in canonical form, which means Denominator is a positive integer and there are no common divisors between Numerator and Denominator.
[ISO]number(+Term)
True if Term is bound to an integer or floating point number.24As rational numbers are not atomic in the current implementation and we do not want to break the rule that number/1 implies atomic/1, number/1 fails on rational numbers. This will change if rational numbers become atomic.
[ISO]atom(+Term)
True if Term is bound to an atom.
string(+Term)
True if Term is bound to a string. Note that string here refers to the built-in atomic type string as described in section 4.23, Text in double quotes such as "hello" creates a list of character codes. We illustrate the issues in the example queries below.
?- write("hello").
[104, 101, 108, 108, 111]
?- string("hello").
No
?- is_list("hello").
Yes
[ISO]atomic(+Term)
True if Term is bound to an atom, string, integer or floating point number. Note that string refers to the built-in type. See string/1. Strings in the classical Prolog sense are lists and therefore compound.
[ISO]compound(+Term)
True if Term is bound to a compound term. See also functor/3 and =../2.
callable(+Term)
True if Term is bound to an atom or a compound term, so it can be handed without type-error to call/1, functor/3 and =../2.
ground(+Term)
True if Term holds no free variables.
cyclic_term(+Term)
True if Term contains cycles, i.e. is an infinite term. See also acyclic_term/1 and section 2.16.25The predicates cyclic_term/1 and acyclic_term/1 are compatible to SICStus Prolog. Some Prolog systems supporting cyclic terms use is_cyclic/1 .
acyclic_term(+Term)
True if Term does not contain cycles, i.e. can be processed recursively in finite time. See also cyclic_term/1 and section 2.16.