40 likes | 242 Views
Examples of the Unification Algorithm. { X = int, Y = X X }. unify ({ X = int, Y = X X } ) S=X, T=int, C’={Y = X X} = [ X int ] ; unify ({ Y = int int }) S=Y, T=int int, C’={ } = [ X int ] ; [ Y int int ] ; unify ({ })
E N D
Examples of the Unification Algorithm { X = int, Y = XX } unify({ X = int, Y = XX }) S=X, T=int, C’={Y = XX} = [ X int ] ; unify({ Y = intint }) S=Y, T=intint, C’={ } = [ X int ] ; [ Y intint ] ; unify({ }) = [ X int ] ; [ Y intint ] ; [ ] = [ X int, Y intint ] { intint = XY } unify({ intint = XY }) S=intint, T=XY, C’={ } = unify({ int = X, int = Y }) S=int, T=X, C’={ int = Y } = [ X int ] ; unify({ int = Y }) S=int, T=Y, C’={ } = [ X int ] ; [ Y int ] ; unify({ }) = [ X int, Y int ]
Examples of the Unification Algorithm { XY = YZ, Z = UW } unify({ XY = YZ, Z = UW }) S=XY, T= YZ, C’={Z = UW} = unify({ Z = UW, X = Y, Y = Z }) S=Z, T=UW, C’={ X = Y, Y = Z } = [ Z UW ] ; unify({ X = Y, Y = UW }) = [ Z UW ] ; [ X Y ] ; unify({ Y = UW }) = [ Z UW ] ; [ X Y ] ; [ Y UW ] = [ Z UW, X Y ] ; [ Y UW ] = [ Z UW, X UW, Y UW ]
Examples of the Unification Algorithm { int = intY } unify({ int = intY }) S=int, T= intY, C’={ } fails { Y = intY } unify({ Y = intY }) S=Y, T= intY, C’={ } fails { } unify({ }) = [ ]
Reference http://www.dcs.gla.ac.uk/~simon/teaching/tpl/