Docsity

Unification Algorithms and Tree Automata in Equational Theories - Prof. Jose Meseguer, Study notes of Computer Science

Partial preview of the text

Download Unification Algorithms and Tree Automata in Equational Theories - Prof. Jose Meseguer and more Study notes Computer Science in PDF only on Docsity!

Program Verification:

Lecture 7 Jos´e Meseguer

Computer Science DepartmentUniversity of Illinois at Urbana-Champaign

Overlaps as Unification Problems We reduced confluence (under the termination assumption)to joinability of context-free nested simplifications withoverlap. But note that we can have a context-free overlapsituation with equations^ u^ =

′^ ′^ v and u=^ v(again, with disjoint variables) if and only if there is a nonvariableposition^ ν^ in^ u^ and a substitution

θ^ such that,′ (†) θ(u/ν) =^ θ(u). Therefore,^ finding all possible context-free nestedsimplifications with overlap

can be reduced to finding, for all pairs of equations

′^ u = v and u=^ ′^ vin^ E^ and all nonvariable positions

ν^ in^ u, all solutions to

(†). Problems of the form^ (†)^ are called

unification problems

.^2

A-Unification The standard unification problem is to try to unify two terms. But we have already encountered situations, such asthe relation^ −→

, in which it is very useful to deal notE/A with terms, but with

equivalence classes

of terms^ modulo some equational axioms

A.

Therefore, it is natural, given a set of equational axioms

A,

such as the associativity, commutativity, and identity ofsome operators, to generalize the unification problem to thefollowing^ A-unification

problem: given an equation

′^ t = tare

there substitutions

θ^ such that^ θ(t)^ ≡θ(tA^

A-Unification (II) For^ A^ any combination of associativity, commutativity, andidentity axioms, there are known algorithms that can find afamily of^ most general unifiers

for each given unification ′problem t = t. However, for the case of associativity alone,or of associativity and identity alone, this family of mostgeneral unifiers may be infinite. In particular, under very reasonable assumptions about theunderlying signature

Σ^ (such as finiteness) if we choose A^ =^ C, where^ C is a collection of

commutativity^

axioms for

different (subsort-overloaded) binary operators in

Σ, there is

indeed an algorithm that, given a

C-unification problem, either declares the problem unsolvable, or finds a finite setof most general unifiers solving it. Such a

C-unification algorithm is indeed used by the Church-Rosser Checker.

More on Unification (II) This simplest version is the case of a sensible

many-sorted signature^ Σ^ without ad-hoc overloading.The key idea of a unification algorithm is to

transform^ the original equation we want to solve into a

set^ of equations equivalent to the original equation, in the sense that bothsets have the same solutions.We then stop either with failure, or with a set of equations in solved form, that is, equations having the shape, {x=^ t,... , x=^1 1 n^

t}. But this is just another garb for an substitution^ θ^ :^ x

7 →^ t.i i

The Unification Algorithm We can describe the unification algorithm, `

a la Martelli-Montanari, as a set of

inference rules, that transform a set of equations

E^ into another set of equations that is equivalent to it from the solvability point of view, orinto the constant

failure. The inference rules assume that equality is commutative and are the following:^ •^ Delete:^

{E, t^ =^ t}^ {E}

-^ Decompose: {E, f^ (t,... , t) =^1 n

′′ f (t,... , t)} 1 n ′′ {E, t= t,... , t=^ t)} 1 n 1 n

The Unification Algorithm (III) • Eliminate:^ {E, x

=^ t} {E(x/t), x^ =^ t} if^ x^6 ∈^ vars(t), t^6 ∈

V, x^ ∈^ vars(E). We can illustrate the use of these rules by finding the mostgeneral unifier for a relatively simple, yet nontrivial,unification problem, namely, solving the equation,

f^ (g(x, h(y)), z) =^

f^ (z, g(k(u), v)) for which the above rules give us the followingtransformations: {f^ (g(x, h(y)), z) =

f^ (z, g(k(u), v))} −→

(Decompose)

The Unification Algorithm (IV) {g(x, h(y)) = z, z^ =^ g(k(u), v)} −→

(Eliminate) {g(x, h(y)) =^ g(k(

u), v), z^ =^ g(k(u)

, v)} −→^ (Decompose

{x^ =^ k(u), v^ =^ h(

y), z^ =^ g(k(u), v)

} −→^ (Eliminate

{x^ =^ k(u), v^ =^ h(

y), z^ =^ g(k(u), h(

y))}, which is the desired most general unifier, yielding theidentity, f^ (g(k(u), h(y)), g(

k(u), h(y))) =^ f^ (g

(k(u), h(y)), g(k(u

), h(y))).^11

Where to Go from Here (II) Detailed inference rules for order-sorted

C-unification, which is implemented in the Curch-Rosser Checker can be foundin, F. Dur´an and J. Meseguer, “A Church-Rosser Checker Toolfor Maude Specifications,” 2000, in http://maude.csl.sri.com

.

Where to Go from Here (III) A good survey of unification, including different unificationalgorithms for different theories can be found in,J.-P. Jouannaud and C. Kirchner, “Solving Equations inAbstract Algebras,” in J.-L. Lassez and G.Plotkin, eds.,Computational Logic: Essays in Honor of Alan Robinson.A general treatment of order-sorted

A-unification can be found in,J. Meseguer, J.A. Goguen, and G. Smolka, “Order-SortedUnification,”^ J. Symbolic Computation

, Volume 8, 1989, pages 383–413.

What Are Critical Pairs?

(II)

Proof: We had already reduced checking confluence tochecking that, for each pair of equations

′^ u = v and u=^ v ′^ in

E, for each nonvariable position

ν^ in^ u, and for each C-unifier^ μ^ such that

′ μ(u/ν) ≡μ(u)C , we have, (♭)^ μ(v)^ ↓μ(E/C^

′u)[ν ← μ(v)]. But if^ {θ,... θ}^1 n

, are the most general

C-unifiers for the equation^ u/ν^ =^ u

′, then we can find a

θand a substitutioni^ ρ^ :^ V^ −→^ T(V^ )^ such that,Σ

μ^ =^ θ;^ ρ.i We are then done if we prove the following (

Note: the generalization to

−→is left as an exercise)E/C^

16

What Are Critical Pairs?

(III)

Substitution Lemma

∗′^ : If t −→tandE^ ρ^ is a substitution, ∗then ρ(t) −→ρE^ ′(t). Proof: Note that, since

ρ^ is by definition a Σ-homomorphism, we have the identity,

ρ(t[π^ ←^ u]) =^ ρ(t)[

π^ ←^ ρ(u)]. Therefore, if^ t^ −→

′t, then^ ρ(t)^ −→E

′ρ(t). The reflexive andE transitive extension is then trivial. q.e.d.q.e.d.

In Summary What the Church-Rosser Checker does is:^ •^ it checks that the equations

E^ are sort-decreasing;

-^ it forms all the critical pairs for the equations

E^ and tries to join them; • it returns as proof obligations those equationspecializations that it could not prove sort-decreasing,and those simplified critical pairs that it could not join.The arguments in Lecture 6 and in this lecture have shownthat this method is^

correct^ for checking confluence, under the termination assumption.

Checking Sufficient Completeness We need methods to check that an equational theory

(Σ, E)

is^ sufficiently complete

. For arbitrary equational theories sufficient completeness is in general

undecidable. This is not so bad: it just means that we may have to do someinductive theorem proving.Sufficient completeness is

decidable^ for a very broad class of order-sorted theories, namely, unconditional theories of theform^ (Σ, E^ ∪^ A)^ with

A^ a set of axioms for operators allowing any combination of associativity and/or commutativityand/or identity, except associativity alone, or associativityand identity alone, and

E: (i) left-linear; (ii) ground confluent and sort-decreasing; and (iii) weakly terminating.