Introduction to
Logic Programming
What
versus
How
 

Exercise 5.1 - Matching


For each of the following patterns and instances, say whether the instance matches the pattern and, if so, give the corresponding matcher.

(a)p(X,Y) and p(a,a) 
  {Xa, Ya} 
  No match 
 
(b)p(X,Y) and p(a,f(a)) 
  {Xa, Yf(a)} 
  No match 
 
(c)p(X,f(Y)) and p(a,f(a)) 
  {Xa, Ya} 
  No match 
 
(d)p(X,X) and p(2,min(2,4)) 
  {X2} 
  No match 
 
(d)p(X,min(2,4)) and p(2,2) 
  {X2} 
  No match