Next: List Processing, Previous: Comparison of Terms, Up: Term Tests and Manipulation [Contents][Index]
These testing predicates are used to determine various properties of the data objects, or apply constraints to the data objects.
Relations:
type(Term, Type)
Succeed if
Term
is a non-variable of typeType
.
type : rel(@term, !typeE(_))
Example:
| ?? type(a, atomic). yes | ?? type(a, int). noThe type can also have a mode as in the following examples.
| ?? type([X], !list(?int)). yes | ?? type([X], !list(!int)). no
ground(Term)
Succeed if
Term
is ground.
ground: rel(@term)
isa(Term, Type)
Succeed if
Term
is of typeType
andType
is a finite type.
isa: (?term, !typeE(_))
The type cannot include a mode but otherwise, when used as a test, is the same as using
type
. However,isa
can also be used to generate all elements of the finite type as below.Example: For this example we assume the following type declarations.
name ::= "Alice" | "Bob" | "Carol" status ::= good(name) | bad(name)| ?? isa(X, status). X = good("Alice") ... X = good("Bob") ... X = good("Carol") ... X = bad("Alice") ... X = bad("Bob") .. X = bad("Carol") | ?? isa(good("Bob"), status). yes | ?? isa(2, nat). Error: nat is not a finite type in isa(2, nat) of isa(2, nat)
template(Term)
Succeed if
Term
is atomic or a compound term with a ground functor.
template :rel(@term)