Next: , Previous: , Up: Terms   [Contents][Index]


4.3.2 Testing of Terms

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 type Type.
type : (??top, !typeE(_)) <=

Example:

| ?? type(a, atomic).

yes

| ?? type(a, int).

no

| ?? type([a,2], [int || atom]).

yes

ground(Term)

Succeed if Term is ground.
ground : (??top) <=

isa(Term, Type)

Succeed if Term is of type Type and Type is a finite type.
isa : (?Term, !typeE(_)) <=

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).

no

template(Term)

Succeed if Term is atomic or a compound term with a ground functor.
template :(??top) <=

ground_inputs(Term)

Succeed if Term is a relation or action term and that the modes of its arguments are correct.
ground_inputs : ??(relcall || actcall) <=