All Topics  
Unification

 

   Email Print
   Bookmark   Link






 

Unification



 
 
In mathematical logic
Mathematical logic

Mathematical logic is a subfield of mathematics and logic with close connections to computer science and philosophical logic. The field includes the mathematical study of logic and the applications of formal logic to other areas of mathematics....
, in particular as applied to computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, a unification of two terms is a join (in the lattice
Lattice (order)

In mathematics, a lattice is a partially ordered set in which subsets of any two elements have a unique supremum and an infimum . Lattices can also be characterized as algebraic structures satisfying certain Axiom identity ....
 sense) with respect to a specialisation order. That is, we suppose a preorder
Preorder

In mathematics, especially in order theory, preorders are binary relations that satisfy certain conditions. For example, all partial orders and equivalence relations are preorders....
 on a set of terms, for which t* = t means that t* is obtained from t by substituting some term(s) for one or more free variables in t. The unification u of s and t, if it exists, is a term that is a substitution instance of both s and t.






Discussion
Ask a question about 'Unification'
Start a new discussion about 'Unification'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In mathematical logic
Mathematical logic

Mathematical logic is a subfield of mathematics and logic with close connections to computer science and philosophical logic. The field includes the mathematical study of logic and the applications of formal logic to other areas of mathematics....
, in particular as applied to computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, a unification of two terms is a join (in the lattice
Lattice (order)

In mathematics, a lattice is a partially ordered set in which subsets of any two elements have a unique supremum and an infimum . Lattices can also be characterized as algebraic structures satisfying certain Axiom identity ....
 sense) with respect to a specialisation order. That is, we suppose a preorder
Preorder

In mathematics, especially in order theory, preorders are binary relations that satisfy certain conditions. For example, all partial orders and equivalence relations are preorders....
 on a set of terms, for which t* = t means that t* is obtained from t by substituting some term(s) for one or more free variables in t. The unification u of s and t, if it exists, is a term that is a substitution instance of both s and t. If any common substitution instance of s and t is also an instance of u, u is called minimal unification.

For example, with polynomial
Polynomial

In mathematics, a polynomial is an expression constructed from variables and constants, using the operations of addition, subtraction, multiplication, and constant non-negative whole number exponents....
s, X 2 and Y 3 can be unified to Z6 by taking X = Z3 and Y = Z2.

Definition of unification for first-order logic


Let p and q be sentences in first-order logic
First-order logic

First-order logic is a formal deductive system used in mathematics, philosophy, linguistics, and computer science. It goes by many names, including: first-order predicate calculus , the lower predicate calculus, the language of first-order logic or predicate logic....
.

UNIFY(p,q) = U where subst(U,p) = subst(U,q)


Where subst(U,p) means the result of applying substitution U on the sentence p. Then U is called a unifier for p and q. The unification of p and q is the result of applying U to both of them.

Let L be a set of sentences, for example, L = . A unifier U is called a most general unifier for L if, for all unifiers U' of L, there exists a substitution s such that applying s to the result of applying U to L gives the same result as applying U' to L:
subst(U',L) = subst(s,subst(U,L)).


Unification in logic programming and type theory


The concept of unification is one of the main ideas behind logic programming
Logic programming

Logic programming is, in its broadest sense, the use of mathematical logic for computer programming. In this view of logic programming, which can be traced at least as far back as John McCarthy 's [1958] Advice taker proposal, logic is used as a purely Declarative programming language representation language, and a automated theorem proving o...
, best known through the language Prolog
Prolog

Prolog is a logic programming language. It is a general purpose language often associated with artificial intelligence and computational linguistics....
. It represents the mechanism of binding the contents of variables and can be viewed as a kind of one-time assignment. In Prolog, this operation is denoted by the equality symbol =, but is also done when instantiating variables (see below). It is also used in other languages by the use of the equality symbol =, but also in conjunction with many operations including +, -, *, /. Type inference
Type inference

Type inference, or implicit typing, refers to the ability to deduce automatically the type of a value in a programming language. It is a feature present in some strongly-typed programming language static typing#Static and dynamic typing languages....
 algorithms are typically based on unification.

In Prolog:
  1. A variable
    Variable

    A variable is a symbol that stands for a value that may vary; the term usually occurs in opposition to constant, which is a symbol for a non-varying value, i.e....
     which is uninstantiated—i.e. no previous unifications were performed on it—can be unified with an atom, a term, or another uninstantiated variable, thus effectively becoming its alias. In many modern Prolog dialects and in first-order logic
    First-order logic

    First-order logic is a formal deductive system used in mathematics, philosophy, linguistics, and computer science. It goes by many names, including: first-order predicate calculus , the lower predicate calculus, the language of first-order logic or predicate logic....
    , a variable cannot be unified with a term that contains it; this is the so called occurs check
    Occurs check

    In computer science, the occurs check is a part of algorithm forsyntactic unification. It causes unification of a logic variable V and a structure S to fail if S contains V....
    .
  2. Two atoms can only be unified if they are identical.
  3. Similarly, a term can be unified with another term if the top function symbols and arities
    Arity

    In logic, mathematics, and computer science, the arity of a function or operation is the number of arguments or operands that the function takes. The arity of a relation is the number of domains in the corresponding Cartesian product....
     of the terms are identical and if the parameters can be unified simultaneously. Note that this is a recursive behavior.


In type theory, the analogous statements are:
  1. Any type variable unifies with any type expression, and is instantiated to that expression. A specific theory might restrict this rule with an occurs check.
  2. Two type constants unify only if they are the same type.
  3. Two type constructions unify only if they are applications of the same type constructor and all of their component types recursively unify.


Due to its declarative nature, the order in a sequence of unifications is (usually) unimportant.

Note that in the terminology of first-order logic
First-order logic

First-order logic is a formal deductive system used in mathematics, philosophy, linguistics, and computer science. It goes by many names, including: first-order predicate calculus , the lower predicate calculus, the language of first-order logic or predicate logic....
, an atom is a basic proposition and is unified similarly to a Prolog term.

French computer scientist Gérard Huet
Gérard Huet

G?rard Huet, born in Bourges on July 7 1947, is a French computer scientist.Graduated from:* Universit? Denis Diderot * Case Western Reserve University...
 gave an algorithm for unification in typed lambda calculus
Typed lambda calculus

A typed lambda calculus is a typed formalism that uses the lambda-symbol to denote anonymous function abstraction. Typed lambda calculi are foundational programming languages and are the base of typed functional programming languages such as ML programming language and Haskell and, more indirectly, typed imperative programming....
 in 1973. There have been many developments in unification theory since then.

Examples of unification


In the convention of Prolog, atoms begin with lowercase letters.

  • A = A : Succeeds (tautology
    Tautology (logic)

    In propositional logic, a tautology is a propositional formula that is true under any possible Valuation of its propositional variables. For example, the propositional formula is a tautology, because the statement is true for any valuation of A....
    )
  • A = B, B = abc : Both A and B are unified with the atom abc
  • abc = B, B = A : As above (unification is symmetric)
  • abc = abc : Unification succeeds
  • abc = xyz : Fails to unify because the atoms are different
  • f(A) = f(B) : A is unified with B
  • f(A) = g(B) : Fails because the heads of the terms are different
  • f(A) = f(B, C) : Fails to unify because the terms have different arity
  • f(g(A)) = f(B) : Unifies B with the term g(A)
  • f(g(A), A) = f(B, xyz) : Unifies A with the atom xyz and B with the term g(xyz)
  • A = f(A) : Infinite unification, A is unified with f(f(f(f(...)))). In proper first-order logic and many modern Prolog dialects this is forbidden (and enforced by the occurs check
    Occurs check

    In computer science, the occurs check is a part of algorithm forsyntactic unification. It causes unification of a logic variable V and a structure S to fail if S contains V....
    )
  • A = abc, xyz = X, A = X : Fails to unify; effectively abc = xyz


See also

  • admissible rule
    Admissible rule

    In logic, a rule of inference is admissible in a formal system if the set of theorems of the system is closed under the rule. The concept of an admissible rule was introduced by Paul Lorenzen ....