• Aucun résultat trouvé

Unification www.irif.fr/˜kesner

N/A
N/A
Protected

Academic year: 2022

Partager "Unification www.irif.fr/˜kesner"

Copied!
11
0
0

Texte intégral

(1)

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner

Unification

(2)

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner

Unification

Two termssandtareunifiableiff there exists a substitution (calledunifier) s.t.θ(s)=θ(t).

Example

f(x,g(x,a))and f(f(a),y)are unifiable withθ={x/f(a),y/g(f(a),a)}

f(x,g(x,a)) f(f(a),y) f(f(a),g(f(a),a)) = f(f(a),g(f(a),a)) f(x,g(x,a))and f(f(a),f(b,a))are not unifiable.

(3)

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner

Principal substitutions

Letθandτbe two substitutions andSbe a set of substitutions.

Thecompositionofθandτis(θ◦τ)(x)=bθ(τ(x))for every variablex∈ X.

θis aninstanceofτ(orτismore generalthanθ) iff there exists a substitutionρs.t.

for every variablex∈ X,(ρ◦τ)(x)=θ(x).

τ∈ Sisprincipal(ormost general) iff every substitutionθ∈ Sis an instance ofτ.

Example

Letσ1={y/b,z/h(c)}andσ2={x/f(y),y/z}. σ1◦σ2={x/f(b),y/h(c),z/h(c)}.

σ2is more general thanσ1◦σ2.

(4)

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner

Principal unifier

Theorem

LetSbe a non-empty set of unifiers ofsandt. Then, there exists aprincipal unifierθ∈ S s.t. for everyτ∈ S,θis more general thanτ. Moreover, this principal unifier isunique modulo renaming.

(5)

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner

Idempotent unifiers

A substitutionθisidempotentiffθ◦θ=θ. Example

{y/b,z/h(c)}is idempotent.

{x/f(y),y/z}is not idempotent.

Theorem

Ifsandtare unifiable, then there exists aprincipal unifier ofsandtwhich isidempotent.

How we can construct this unifier?

(6)

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner

Equational systems

An(Σ)equational systemis a set of (Σ)equations of the formst.

An equational systemEisunifiableiff there exists a unifier (calledsolution) for all the equations ofE.

Finiteequational systems are denoted{s1t1, . . . ,sntn}.

(7)

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner

Solved forms

The equational systemE={s1t1, . . . ,sntn}is insolved formiff All thesiaredistinct variables.

Nosiappears intj.

Example

E0={xy,zf(a)}is in solved form butE1={xy,xf(a)}, E2={xy,yf(a)},

E3={xz,yf(y)}do not.

Notation :For the solved systemE={x1t1, . . . ,xntn}we noteE~the substitution {x1/t1, . . . ,xn/tn}.

(8)

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner

The transformation rules

E∪{ss}

E (erase)

E∪{tx} t<X

E∪{xt} (orient)

E∪{f(s1, . . . ,sn)f(t1, . . . ,tn)}

E∪{s1t1, . . . ,sntn} (decompose)

E∪{xs} x∈Var(E) x<Var(s)

E{x\s}∪ {xs} (substitute)

(9)

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner

The unification algorithm

1 Take an equational systemE

2 Compute a new systemPby applying thetransformation rulesas far as possible.

3 If the systemPis insolved form then send the answerP~ else fail

(10)

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner

Example

Unification of the system{p(a,x,f(g(y)))p(z,f(z),f(u))}

p(a,x,f(g(y)))p(z,f(z),f(u)) d az,x f(z),f(g(y))f(u)

o za,xf(z),f(g(y))f(u)

s za,xf(a),f(g(y))f(u)

d za,x f(a),g(y)u

o za,xf(a),ug(y)(solved f orm) yields the (idempotent) substitution{z/a,x/f(a),u/g(y)}.

(11)

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner

Soundness and completeness of the algorithm

Theorem

The algorithm terminates.

Theorem

(Soundness)If the algorithm finds a substitution~Sfor the problemP, thenPis unifiable andS~is a m.g.u. ofP.

That is,

IfPis not unifiable, then the algorithm fails.

Theorem

(Completeness)If the systemPis unifiable, then the algorithm computes the m.g.u. of P.

That is,

If the algorithm fails, then the systemPis not unifiable.

Références

Documents relatifs

&gt;&gt; c = spatm(b,2) % spatial mapping using smoothing of sigma = 2.0 16384 by 6 dataset with 1 class: [16384]. Let us visualise the resulting dataset c

Delia Kesner et Giovanni Bernardi IRIF, Université Paris-Diderot. Emails : kesner@irif.fr

dénitions inductives, principe d'induction bien fondée, preuves par induction, ordres bien fondés.. Calcul

dénitions inductives, principe d'induction bien fondée, preuves par induction, ordres bien fondés.. Calcul

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner.. S ´emantique des langages

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner..

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner.. The Untyped

Delia KESNER IRIF, CNRS et Universit ´e Paris kesner@irif.fr www.irif.fr/˜kesner.. Typed