[ Comparing and Sorting | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]

# instance(?Instance, ?Term)

Succeeds if Instance is an instance of Term.

Instance
  An arbitrary term.
Term
  An arbitrary term.

## Description

Succeeds if it is possible to find an instantiation of free variables in Term such that Term and Instance are equal. The result is undefined if Term and Instance share variables. Note that no unification actually occurs.

### Modes and Determinism

- instance(?, ?) is semidet

### Fail Conditions

Fails if Instance is not an instance of Term.

## Examples

       Success:
       instance(atom,X).
       instance(f(a,b),X).
       instance(f(a,b),f(X,Y)).
       instance(f(a,X),f(Y,X)).
       instance(f(a,X),f(X,Y)).
       instance(f(X,Y),f(Y,X)).
       instance([a,b,c],[A,B,C]).
       instance([a,f(1,b,X),Y|Z],T).
       instance(f(X),X).         % with occur_check off
       Fail:
       instance(f(a,b),f(X,X)).
       instance(X,a).
       instance(f(X),X).         % with occur_check on

## See Also

compare_instances / 3, prune_instances / 2, variant / 2