Term unification

These predicates are concerned with the unification of two terms.

1. =/2 (Prolog unify)

If X and Y are not subject to occurs check, then '='(X, Y) is true iff X and Y are unifiable.

Templates and modes for the predicate are as follows:

'='(?term, ?term)

Note that = is a predefined operator.

1.1 Example tests

Let's start with some simple tests verifying success of failure of single goals.

Goal Theory success(String goal,String theory)
'='(1, 1). null true
'='(_, _). null true
'='(X, 1). null true
'='(X, Y). null true
'='(X=Y, X=abc). null true
'='(f(X,def), f(def,Y)). null true

Goal Theory success(String goal,String theory)
'='(1, 2). null false
'='(1, 1.0). null false
'='(g(X), f(f(X))). null false
'='(f(X,1),f(a(X))). null false
'='(f(X, Y, X, 1), f(a(X), a(Y), Y, 2)). null false
'='(f(X, Y, X), f(a(X), a(Y), Y, 2)). null false
'='(X, a(X)). null false
'='(f(X, 1), f(a(X), 2)). null false
'='(f(1, X, 1), f(2, a(X), 2)). null false
'='(f(1, X), f(2, a(X))). null false
Goal Theory Variable Solution success(String goal,String theory,String variable,Strng solution)
'='(X, 1). null X 1 true
'='(X, Y). null X X true
'='(X, Y), '='(X, abc). null X abc true
'='(X, Y), '='(X, abc). null Y abc true
'='(f(X, def), f(def, Y)). null X def true
'='(f(X, def), f(def, Y)). null Y def true

2. unify_with_occurs_check/2 (unify)

unify_with_occurs_check(X, Y) attempts

Templates and modes for the predicate are as follows:

unify_with_occurs_check(?term, ?term)

2.1 Example tests

Let's start with some simple tests verifying success of failure of single goals.

Goal Theory success(String goal,String theory)
unify_with_occurs_check(1,1). null true
unify_with_occurs_check(X,Y). null true
unify_with_occurs_check(_,_). null true
unify_with_occurs_check(X,Y). null true
unify_with_occurs_check(f(X,def),f(def,Y)). null true

Goal Theory success(String goal,String theory)
unify_with_occurs_check(1, 2). null false
unify_with_occurs_check(1, 1.0). null false
unify_with_occurs_check(g(X), f(f(X))). null false
unify_with_occurs_check(f(X,1), f(a(X))). null false
unify_with_occurs_check(f(X,Y,X), f(a(X), a(Y), Y, 2)). null false
unify_with_occurs_check(X, a(X)). null false
unify_with_occurs_check(f(X,1), f(a(X),2)). null false
unify_with_occurs_check(f(1,X,1), f(2,a(X),2)). null false
unify_with_occurs_check(f(1,X), f(2,a(X))). null false
unify_with_occurs_check(f(X,Y,X,1), f(a(X), a(Y), Y, 2)). null false
unify_with_occurs_check(Y, a(Y)). null false

Test With Results

Goal Theory Variable success(String goal,String theory,String variable)
unify_with_occurs_check(X,1). null X 1

3. \=/2 (not Prolog unifiable)

If X and Y are not subject to occurs check, then \=(X, Y) is true iff X and Y are not unifiable.

Templates and modes for the predicate are as follows:

'\='(@term, @term)

Note that \= is a predefined operator.

3.1 Example tests

Let's start with some simple tests verifying success of failure of single goals.

Goal Theory success(String goal,String theory)
'\='(1, 2). null true
'\='(1, 1.0). null true
'\='(g(X), f(f(X))). null true
'\='(f(X, 1), f(a(X))). null true
'\='(f(X, Y, X), f(a(X), a(Y), Y, 2)). null true
'\='(X, a(X)). null true
'\='(f(X, 1), f(a(X), 2)). null true
'\='(f(1, X, 1), f(2, a(X), 2)). null true
'\='(f(1, X), f(2, a(X))). null true
'\='(f(X, Y, X, 1), f(a(X), a(Y), Y, 2)). null true

Goal Theory success(String goal,String theory)
'\='(1, 1). null false
'\='(X, 1). null false
'\='(X, Y). null false
'\='(_, _). null false
'\='(f(X, def), f(def, Y)). null false