4.6 Verify Type of a Term

Type tests are semi-deterministic predicates that succeed if the argument satisfies the requested type. Type-test predicates have no error condition and do not instantiate their argument. See also library library(error).

[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.36As 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.
blob(@Term, ?Type)
True if Term is a blob of type Type. See section 9.4.7.
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]
true.

?- string("hello").
false.

?- is_list("hello").
true.
[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.
[ISO]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.
[ISO]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.37The predicates cyclic_term/1 and acyclic_term/1 are compatible with SICStus Prolog. Some Prolog systems supporting cyclic terms use is_cyclic/1 .
[ISO]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.