[ Comparing and Sorting | 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.

Attributed variables are handled via the attribute's compare_instances handler. In particular, domain variables should be handled correctly.

Modes and Determinism

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).
   X::1..5, instance(3,X).
   X::2..4, Y::1..5, instance(X,Y).

   Fail:
   instance(f(a,b),f(X,X)).
   instance(X,a).
   X::2..4, Y::1..5, instance(Y,X).

See Also

compare_instances / 3, prune_instances / 2, variant / 2