Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a unification algorithm?

Well I know it might sound a bit strange but yes my question is: "What is a unification algorithm". Well, I am trying to develop an application in F# to act like Prolog. It should take a series of facts and process them when making queries.

I was suggested to get started in implementing a good unification algorithm but did not have a clue about this.

Please refer to this question if you want to get a bit deeper to what I want to do.

Thank you very much and Merry Christmas.

like image 594
Andry Avatar asked Dec 18 '10 10:12

Andry


People also ask

What is unification in programming?

What Does Unification Mean? In computer science and logic, unification is the algorithmic procedure used in solving equations involving symbolic expressions. In other words, by replacing certain sub-expression variables with other expressions, unification tries to identify two symbolic expressions.

What is unification and give an example?

Unification is the act of unifying the different laws valid for different phenomena into a single theory explaining all the different phenomena. Maxwell unified electric, magnetic and optical phenomenon when he explained that light is an electromagnetic wave.

What is the resolution and unification algorithm?

Unification is a key concept in proofs by resolutions. Resolution is a single inference rule which can efficiently operate on the conjunctive normal form or clausal form. Clause: Disjunction of literals (an atomic sentence) is called a clause. It is also known as a unit clause.

What is unification and lifting in AI?

This process is called unification and is a key component of all first-order inference algorithms. The UNIFY algorithm takes two sentences and returns a unifier for them if one exists: Substitution means replacing one variable with another term. It takes two literals as input and make them identical using substitution.


2 Answers

If you have two expressions with variables, then unification algorithm tries to match the two expressions and gives you assignment for the variables to make the two expressions the same.

For example, if you represented expressions in F#:

type Expr = 
  | Var of string              // Represents a variable
  | Call of string * Expr list // Call named function with arguments

And had two expressions like this:

Call("foo", [ Var("x"),                 Call("bar", []) ])
Call("foo", [ Call("woo", [ Var("z") ], Call("bar", []) ])

Then the unification algorithm should give you an assignment:

"x" -> Call("woo", [ Var("z") ]

This means that if you replace all occurrences of the "x" variable in the two expressions, the results of the two replacements will be the same expression. If you had expressions calling different functions (e.g. Call("foo", ...) and Call("bar", ...)) then the algorithm will tell you that they are not unifiable.

There is also some explanation in WikiPedia and if you search the internet, you'll surely find some useful description (and perhaps even an implementation in some functional language similar to F#).

like image 98
Tomas Petricek Avatar answered Nov 15 '22 06:11

Tomas Petricek


I found Baader and Snyder's work to be most informative. In particular, they describe several unification algorithms (including Martelli and Montanari's near-linear algorithm using union-find), and describe both syntactic unification and various kinds of semantic unification.

Once you have unification, you'll also need backtracking. Kiselyov/Shan/Friedman's LogicT framework will help here.

like image 44
Frank Shearar Avatar answered Nov 15 '22 08:11

Frank Shearar