0

Hi for all...
i have to implement unifiction algorithm (in first order logic) using c++ language so can any help me with basic ideas??

2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by iamthwee
0

The language known as 'Prolog' relies heavily on this idea, however, all you need to do is consider using this...


Here are a few examples to clarify whether you really understand what unification is...

Here are some examples of terms that will unify:

f(a,b)

f(a,X)

X = b


f(plus(4,5), g(5))

f(X, Y)

X = plus(4,5)

Y = g(5)


f(plus(plus(4,5),7), b)

f(plus(Y,X), b)

Y = plus(4,5)

X = 7

However, here are some examples where unification will fail:

f(apple, pie)

f(pie, apple)


f(jim, X)

f(X, fred)

And now for the algorithm...
http://www.ale.cs.toronto.edu/docs/ref/ale_trale_ref/ale_trale_ref-node4.html

Using the first case for its brevity I shall outline a procedure for C++

f(a,b)

f(a,X)

X = b

First create some strings.

string one = "f(a,b)"
string two = "f(a,X)"
string three="X=b"

Using step one check that the tail head is the same in both string one and two. They are.

f(whatever,whatever) f(whatever,whatever)

Next find the first disagreement pair, which would be

b and X

Substitue the X with X=b and then check if both expressions are the same (the substitution could be done using recursion) Repeat until finished.

God bless.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.