SLIDE 94 Unification algorithm
d e r e f e r e n c e i s a f u n c t i
t h a t d e r e f e r e n c e s b
n d v a r i a b l e s a n d r e t u r n s t h e i n p u t
h e r w i s e
A f r e e v a r i a b l e c a n b e s e e n a s a p
n t e r t
I L . Wh e n n
f r e e , i t i s s a i d b
n d v a r i a b l e . D e r e f e r e n c i n g a v a r i a b l e m e a n s r e a c h i n g t h e v a l u e t
h i c h i t i s b
n d .
p r
e d u r e u n i f y ( t 1 , t 2 ) t 3 : = d e r e f e r e n c e ( t 1 ) ; t 4 : = d e r e f e r e n c e ( t 2 ) i f t 3 i s a v a r i a b l e t h e n t 3 p
n t s t
4 ; r e t u r n s u c c e s s e l s e i f t 4 i s a v a r i a b l e t h e n t 4 p
n t s t
3 ; r e t u r n s u c c e s s e l s e i f t 3 i s a n a t
a n d t 4 i s a n a t
t h e n i f t 3 = t 4 t h e n r e t u r n s u c c e s s e l s e r e t u r n f a i l e l s e l e t t 3 = f ( t 3 1 , . . , t 3 n ) a n d t 4 = g ( t 4 1 , . . , t 4 m ) i f f = g a n d n = m t h e n f
i : = 1 t
d
f u n i f y ( t 3 i , t 4 i ) f a i l s t h e n r e t u r n f a i l r e t u r n s u c c e s s e l s e r e t u r n f a i l t 1 , t 2 a r e t w
e r m s
a n d m a r g e w h e r e X i s b
n d t
h e v a l u e m a r g e w i l l m a t c h .
a n d Y w h e r e X i s b
n d t
a r g e a n d Y i s b
n d t
a r g e w i l l m a t c h ,
a n d m a r g e w h e r e X i s b
n d t
i s a w i l l n
m a t c h .