A-4.Unification Algorithm

advertisement
Assignment No. -4(Group -A)
Regularity
(2)
Performance Oral
(5)
(3)
Total Dated
(10) Sign
Aim: Implementation of Unification Algorithm.
Objective:




Understanding the need of unification.
Defining alphabets, terms, and substitutions
Introducing the Martelli-Montanari Algorithm for unification
Proving correctness of the algorithm
Theory:
4 Introduction:
Unification, in computer science and logic, is an algorithmic process of solving
equations between symbolic expressions.Depending on which expressions (also called
terms) are allowed to occur in an equation set (also called unification problem), and
which expressions are considered equal, several frameworks of unification are
distinguished. If higher-order variables, that is, variables representing functions, are
allowed in an expression, the process is called higher-order unification, otherwise firstorder unification. If a solution is required to make both sides of each equation literally
equal, the process is called syntactical unification, otherwise semantically, or educational
unification, or E-unification, or unification modulo theory.
A solution of a unification problem is denoted as a substitution, that is, a mapping
assigning a symbolic value to each variable of the problem's expressions. A unification
algorithm should compute for a given problem a complete, and minimal substitution set,
that is, a set covering all its solutions, and containing no redundant members. Depending
on the framework, a complete and minimal substitution set may have at most one, at most
finitely many, or possibly infinitely many members, or may not exist at all. [note 1][1] In
some frameworks it is generally impossible to decide whether any solution exists.
4.1 Definition :
The unification problem in first-order logic can be expressed as follows: Given two terms
containing some variables, find, if it exists, the simplest substitution (i.e., an assignment
of some term to every variable) which makes the two terms equal. The resulting
substitution is called the most general unifier.
A= U Ai (Ai ∩ Aj= O, i ≠ j) i=0,1 ....n, be a ranked alphabet, where Ai contains the
Italic function symbols (the elements of A0 are constant symbols).Furthermore, let V be
the alphabet of the variables.
4.2 Example :
f(x1, h(x1), x2} = f(g(x3), x4, x3)
б1 = ((g(x3), x1), (x3, x2), (h(g(x3), x4)}
б2= ((g(a), x1), (a, x2), (a, x3), (h(g(a)), x4)}.
4.3 Terms:
The terms are defined recursively as follows:
(1) constant symbols and variables are terms;
(2) if t1 . . . . . tn (n ≥ 1) are terms and f ∈ An,
then f(t1, . . . , tn) is a term.
4.4 Substitution
A substitution б is a mapping from variables to terms,
A substitution can be represented by a finite set of ordered pairs
б= {(t1, x1), (t2, x2 ) , . . . ,
(tm, Xm)} where ti are terms and xi are distinct variables, i = 1 , . . . , m.
4.5 Algorithm 3
(1) repeat
(1.1) Select a multi-equation S =M of U such that the variables in S do not occur
elsewhere in U. If a multi-equation with this property does not exist, stop with
failure (cycle).
(1.2) if M is empty then transfer this multi-equation from U to the end of T.
else begin
(1.2.1) Compute the common part C and the frontier F of M. If M has no common
part, stop with failure (clash).
(1.2.2) Transform U using multi-equation reduction on the selectedMulti-equation
and compactification.
(1.2.3) Transfer the multi-equation S = (C) from U to the end of T.
end
until the U part of R
(2) Stop with success.
5.6 Application:
1. Unification in logic programming
2. Type inference
4.6 Conclusion: Introducing the Martelli-Montanari Algorithm for unification
Proving correctness of the algorithm
Download