protocol

# `termp`

Prolog term utility predicates protocol.

Author: Paulo Moura
Version: 1.31
Date: 2010/6/9
Compilation flags:
`static`

(no dependencies on other entities)

## Public interface

### `depth/2`

True if the depth of Term is Depth. The depth of atomic terms is zero; the depth of a compound term is one plus the maximum depth of its sub-terms.

Compilation flags:
`static`
Template:
`depth(Term,Depth)`
Mode and number of proofs:
`depth(@term,?integer)` - `zero_or_one`

### `ground/1`

True if the argument is ground.

Compilation flags:
`static`
Template:
`ground(Term)`
Mode and number of proofs:
`ground(@term)` - `zero_or_one`

### `new/1`

Creates a new term instance (if meaningful).

Compilation flags:
`static`
Template:
`new(Term)`
Mode and number of proofs:
`new(-nonvar)` - `zero_or_one`

### `occurs/2`

True if the variable occurs in the term.

Compilation flags:
`static`
Template:
`occurs(Variable,Term)`
Mode and number of proofs:
`occurs(@var,@term)` - `zero_or_one`

### `subsumes/2`

The first term subsumes the second term.

Compilation flags:
`static`
Template:
`subsumes(General,Specific)`
Mode and number of proofs:
`subsumes(?term,@term)` - `zero_or_one`

### `subterm/2`

The first term is a subterm of the second term.

Compilation flags:
`static`
Template:
`subterm(Subterm,Term)`
Mode and number of proofs:
`subterm(?term,+term)` - `zero_or_more`

### `valid/1`

Term is valid.

Compilation flags:
`static`
Template:
`valid(Term)`
Mode and number of proofs:
`valid(@nonvar)` - `zero_or_one`

### `check/1`

Checks if a term is valid. Throws an exception if the term is not valid.

Compilation flags:
`static`
Template:
`check(Term)`
Mode and number of proofs:
`check(@nonvar)` - `one`

### `variant/2`

Each term is a variant of the other (i.e. they are structurally equivalent).

Compilation flags:
`static`
Template:
`variant(Term1,Term2)`
Mode and number of proofs:
`variant(@term,@term)` - `zero_or_one`

### `variables/2`

Returns a list of all term variables (ordered as found when doing a depth-first, left-to-right traversal of Term).

Compilation flags:
`static`
Template:
`variables(Term,List)`
Mode and number of proofs:
`variables(@term,-list)` - `one`

### `singletons/2`

Returns a list of all term singleton variables (ordered as found when doing a depth-first, left-to-right traversal of Term).

Compilation flags:
`static`
Template:
`singletons(Term,Singletons)`
Mode and number of proofs:
`singletons(@term,-list)` - `one`

## Protected interface

(none)

## Private predicates

(none)

## Operators

(none)

## Remarks

(none)

See also

term