swer for Unification Examples

1?- one = one.
yes

2?- one  = two .
no

3?- one  = X .
X = one

4?- r( a, X ) =  r( Y, b).
X = b
Y =a

5?- r( X )  = f( X ).
no

6?- [ a | Tail ] = [ Head | [ x , y ] ] .
Tail = [ x, y ]
Head = a

7?- [ a | T ] = [ a ] .
T = [ ]

8?- r( a, f( X ) )  =  r( Y , b )
no

9?- r( a, f ( X ) ) = r( Y,  f( b ) ).
X = b
Y = a

10?-  r( X ) = r( X , Y ).
no

11? – f(a) = f( X ,a).
/*NO MATCH, diff. arity*/
 

12? – X = f( X  ).
            /*    NO, error if occurs check implemented, otherwise a useless match:
                    X = f (f (f (f (f (….) ) ) ) )
             */

13? – [A, B | X] = [2, 1].
            /* YES */
        A = 2
        B = 1
        X = [ ]
 
 

14? – p( X , X ) = p(Y, f(Y )).
    /* NO, implicit occurs check, X = Y but then X = f(Y ).
        Hence Y = f(Y ), which fails or gives X = Y
        Y = f (f (f (f (f (….) ) ) ) )
  */

15? – f( X , g( X  )) = f(a, Y ).
        /* YES */
        X = a
        Y = g(a)
 

16? – f( X , b, g( X  )) = f(A, A, g(a)).
         /* NO, First X = A, then A = b, so X = A = b.
             Finally, g(b) has to match g(a),
             which fails */
 
 

17? - (X,R) = (a,b,c,d).

     /* Yes */

     X = a
     R = b, c, d

18? - [X] = [a,b,c,d].

         /* No, [X] is a list with exactly one element */

19? - (X) = (a,b,c,d).

       X = a, b, c, d