• Aucun résultat trouvé

Termination www.irif.fr/˜kesner

N/A
N/A
Protected

Academic year: 2022

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

Copied!
43
0
0

Texte intégral

(1)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Termination

(2)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Motivations

Termination is essential to proof correctness of programs.

But

Termination is an undecidable property.

(3)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Undecidability of termination

Leta1,a2,a3, . . .be an enumeration of all the algorithms on integers. We define the

following functions:

end(i,n)≡1ifai(n)terminates Diag(i)≡ ifend(i,i)=1then loop end(i,n)≡0ifai(n)¬terminates else stop

For everyi,Diag(i)terminates iffai(i)does not terminate.

ButDiagis an algorithm, so that∃ajs.t.Diag=aj. We then have Diag(j)terminates iffaj(j)terminates, that is

aj(j)terminatesiffaj(j)does not terminate.

Which is the error in the proof? The existence of the functionend.

(4)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Termination of a very simple system

R={f(g(x),y)7→ f(y,y)}

is not even trivial!

f(g(a),g(a))→ f(g(a),g(a))→ f(g(a),g(a))→. . .

(5)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Techniques to show termination

Reduction orders

Particular case: interpretations

Example of interpretation: polynomial orders Useful orders:

Lexicographic order Multi-set order Simplification orders General result Example : RPO Combination of orders:

Motivations Postponement Projection/simulation Dependency pairs

(6)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Recall

The symbol f∈Σismonotonicw.r.t the relationRiff aiRbiimplies f(a1, . . . ,ai, . . . ,an)R f(a1, . . . ,bi, . . . ,an). Alternatively, a relationRoverT(X,Σ)isstable by contextiff tRt0impliesu[t]pRu[t0]pfor every termuand positionp∈Pos(u). A relationRoverT(X,Σ)isstable by substitutioniff

tRt0impliesθ(t)Rθ(t0)for every substitutionθ.

A relationRiswell-founded(WF) is there is noinfinitesequence of the form a1Ra2Ra3R . . .

(7)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Termination by reduction orders

Pre-order: reflexive and transitive relation.

Partial order: reflexive, antisymmetric and transitive relation.

Strict order: irreflexive and transitive (and thus antisymmetric) relation.

A strict orderover a signatureΣis areduction orderiff

1 is stable by context

2 is stable by substitution

3 is well-founded

Why reduction orders are important?

(8)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Theorem (Termination and Reduction Order)

A rewriting systemRterminatesiffthere exists a reduction orders.t.lrfor every rewriting rulel7→r∈ R.

Proof.

LetRbe a terminating rewriting system. The relation→+Rholds for every rulel7→r∈ R. Moreover,→+Ris a reduction order (stable by substitution, stable by context and WF).

Therefore the property holds for:=→+R.

Letbe a reduction order s.t.lrholds for every rulel7→r∈ R.

Consider any steps→R v. By definitions=u[σ(l)]pandv=u[σ(r)]p, for some rule l7→r∈ R, some substitutionσ, some termu, and some positionpofu. Thereforelr holds by hypothesis. Sinceis a reduction order, then alsosvholds. Therefore every steps→R vgenerates a pairsv. Butis WF by hypothesis, so that the relation→R

must be also terminating.

(9)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

How does it work?

DoesRterminate?

R=

( por(x,t) 7→ t por(t,x) 7→ t

)

The number of symbol decreases....

Let|v|be the size of the termv. Consider the following order ”s1tiff |s|>|t|”.

We havepor(x,t)1tandpor(t,x)1t.

But1is not a reduction order since1is not stable by substitution:

por(x,por(y,t))1por(y,y)butpor(t,por(por(t,t),t))1por(por(t,t),por(t,t)).

Let|v|xbe the number of free occurrences of the variablexinv. Consider the following order ”s2tiff|s|>|t|and for every variablex|s|x≥ |t|x”.

We havepor(x,t)2tandpor(t,x)2t.

And2is a reduction order.

Then by applying the previous theorem, we have proved thatRis terminating.

(10)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Interpretation as particular case of reduction order

A reduction order can also be defined on theinterpretationof terms, and not directly on the terms.

Definition

LetAbe a WF strict order over the domain of aΣ-algebraA. The associated order over the corresponding set of terms is given by:

stiffσ(s)Aσ(t)for all homomorphismsσ:T(X,Σ)→ A

This order on terms is then based on the order relating theinterpretationsofsandt. We consider all possiblevaluationsof variables in the domain ofA.

Theorem

LetAbe aΣ-algebra equipped with a WF strict orderAover the domain ofA. If for every f∈Σ, the interpretation fAismonotonicw.r.t.A, thenis a reduction order.

(11)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Example: polynomial orders

Apolynomialis an expression consisting of variables (indeterminates), addition, subtraction, multiplication, and non-negative integer exponentiation of variables.

Examples of a polynomial are2·x−4·x+7and3·x+2·x·y·z−y·z+1.

ApolynomialΣ-algebraPINis defined by:

A domainDwhich is a subset ofIN+,i.e.D⊆IN+.

A polynomialPf (withnindeterminates and coefficients inIN) for each f/n∈Σ, such that fPIN(a1, . . . ,an)=Pf(a1, . . . ,an).

Example

LetΣ ={a/0,f/2,g/2}. Consider a polynomailΣ-algebra with domain

D={n∈IN|n≥2} ⊆IN+and polynomail interpretationsPa=2,Pf(n,m)=n.mand Pg(n,m)=3.n+m+1. Consider a valuationσon variables such thatσ(x)=5. Then we haveσ(f(a,g(a,x)))=2.(3.2+5+1)=24.

(12)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Towards a polynomial order as interpretation

Problem

Polynomials are not necessarily monotonic, for example ifPf(x,y)=x2we have3>2but Pf(2,3)=4≯4=Pf(2,2).

A polynomialPis said to becompletely monotoniciffPdepends on all its indeterminates and does not contain subtraction.

Example

P(x,y)=3.x+y+2andP(x,y)=x.yare both completely monotonic.P(x,y)=x+2is not completely monotonic.

Theorem

LetPINbe a polynomialΣ-algebra. If every fPINis acompletely monotonicpolynomial, then the orderassociated toPINis a reduction order.

(13)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

How does it work?

DoesRterminate?

R=n

f(x,g(y,z)) 7→ g(f(x,y),f(x,z)) o

1 Define a polynomial for every function symbol:Pf(x,y)=x.yetPg(x,y)=2.x+y+1.

2 Prove thatf(x,g(y,z))g(f(x,y),f(x,z)): this is equivalent to prove that

σ(x).(2.σ(y)+σ(z)+1)PIN2.σ(x).σ(y)+σ(x).σ(z)+1holds for everyσmapping

x,y,zto the domain to be defined.

3 Define the domain as the one in which all the inequalities are valid:

D=IN− {0,1} ⊆IN+.

(14)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Lexicographic order - particular case

Let(A1, >A1)and(A2, >A2)be two strict ordered sets.

(x,y)>lex(x0,y0)iff(x>A1 x0)or(x=x0andy>A2y0)

Example

(4,”abc”)>lex(3,”abc”)>lex(2,”abcde”)>lex

(2,”bcde”)>lex(2,”e”)>lex(1,”e”)>lex(0, )

(15)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Lexicographic order - General case

If every>Aiis a strict order over the setAi, then>lexis a strict order overA1×. . .× An defined as follows:

(x1, . . . ,xn)>lex(x01, . . . ,x0n)iff ∃1≤j≤n

(xj>Aj x0jand∀1≤i<j xi=x0i)

Theorem

Every order>AioverAiis well-founded iff the lexicographic order>lexoverA1×. . .× An is well-founded.

(16)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

How does it work?

Does the following program terminate?

ackerman(0,n) 7→ n+1

ackerman(m+1,0) 7→ ackerman(m,1)

ackerman(m+1,n+1) 7→ ackerman(m,ackerman(m+1,n))

Proof.

We show that ackerman(m,n) terminates by induction on(m,n)w.r.t. the lexicographic

order.

(17)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Another example?

Does the following program terminate?

R=

( f(f(x)) 7→ g(f(x)) g(g(x)) 7→ f(x)

)

Proof.

Define the ordert>uiff(|t|,|t|f)>lex(|u|,|u|f). Show that>is a reduction order.

Show thatf(f(x))>g(f(x))andg(g(x))> f(x).

(18)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Multi-set order

Amulti-setover a setAis a functionM:A →IN. It isfiniteifM(x)>0only for a finite number of elements ofA.

Example

The multiset{{a,a,b}}is represented by the functionMon the set{a,b}such that M(a)=2andM(b)=1.

LetMandNbe two multi-sets. Themulti-set unionis defined by (M ] N)(a)=M(a)+N(a).

Example

{{a,a,b}} ] {{a,a,b,b}}={{a,a,a,a,b,b,b}}.

(19)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Multi-set order

Leta strict order. The associated relationmulis given by thetransitive closureof the following relationmul:

M ]{{x}}mulM ]{{y1, . . . ,yn}}, wheren≥0and∀i,xyi. Example

{{5,3,1,1}} mul{{4,3,3,1}}.

Since{{5,3,1,1}} mul{{4,3,3,1,1}} mul{{4,3,3,1}}

Exercise :Ifis a strict order, thenmulis a strict order.

Theorem

Letbe a strict order overA, thenis WF iffmulis WF.

(20)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

How does it work?

A rich but bored man decides to have fun every day with his money (in euros) in the following way:

either he throw a coin in the fountain,

or he changes a banknote into a finite number of coins of any amount.

Show that the man necessarily becomes poor.

Proof.

Represent the initial amount of money by a multi-set, where the elements are order as follows.

b(500)>b(200)>b(100)>b(50)>b(20)>b(10)>b(5)>

c(2)>c(1)>c(.50)>c(.20)>c(.10)>c(.05)>c(.02)>c(.01) Represent the daily activity of the man by a decreasing order on multi-sets.

(21)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Other known examples

Hercules defeats Hydra

Cut elimination in Gentzen style systems Amoebae reproduction

Recursive Path Orderings

(22)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Simplification orders

Asimplification orderoverT(X,Σ)is an orders.t.

1 is stable by context

2 is stable by substitution

3 t.uimpliestu

(23)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Example: embedding

The relationsDembtholds iff one of the following cases holds

s=xDembx=t

∀i.siDembti

s= f(s1, . . . ,sn)Demb f(t1, . . . ,tn)=t

∃j.sjDembt s=f(s1, . . . ,sn)Dembt

Example

s=f(f(h(h(a)),h(x)),f(h(x),a)).emb f(f(a,x),x)=tsinces,tand aDemba

h(a)Demba h(h(a))Demba

xDembx h(x)Dembx f(h(h(a)),h(x))Demb f(a,x)

xDembx h(x)Dembx f(h(x),a)Dembx f(f(h(h(a)),h(x)),f(h(x),a))Demb f(f(a,x),x)

(24)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Remarks

Intuitively, we can establish an injection between the positions/symbols of the term on the left and those of the right. For example, we can map the bluefon the left into the blue fon the right, etc, and we erase/discard all the black symbols.

Another way to understandDembis by the equality→R

emb=Demb, where the system Remb={f(x1, . . . ,xn)7→xi|f/n∈Σ}discards symbols by projecting subterms.

Indeed, taking again the previous example we have

s=f(f(h(h(a)),h(x)),f(h(x),a)) →Remb

f(f(h(h(a)),h(x)),f(x,a)) →Remb

f(f(h(h(a)),h(x)),x) →Remb

f(f(h(a),h(x)),x) →Remb

f(f(a,h(x)),x) →Remb

f(f(a,x),x)=t Thus,s.embt.

(25)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Termination by simplification orders

Lemma (A)

The relation.embis contained in every simplification order, i.e. ifs.embtandis a simplification order, thenst.

Lemma

Ifis a simplification order, thenis a reduction order (and thus WF).

Proof.

Uses the famous Kruskal’s Theorem.

(26)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

And the inverse?

Question

Is every reduction order also a simplification order?

LetR={f(f(x))7→ f(g(f(x)))}. The systemRterminates (exercise).

Thus→+Ris a reduction order by Theorem (Termination and Reduction Order).

Suppose that→+Ris also a simplification order.

Then by Lemma (A)f(g(f(x))).embf(f(x))implies f(g(f(x)))→+R f(f(x))→+R f(g(f(x))). . ..

Contradicts the fact thatRis terminating.

Conclusion: there are reduction orders that are not simplification orders.

(27)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

An Example of Simplification Order : The Recursive Path Ordering

Let%Σbe a pre-order (reflexive and transitive) over a signatureΣ. We associate to each symbol f ∈Σastatusin the set{LEX,MUL}s.t. iff ∼g, then

fandghave the same status,

and if this status isLEX, thenf andghave the same arity.

We note f∈ΣLEX(resp. f ∈ΣMUL) to indicate that f∈ΣhasLEX(resp.MUL) status. Thus Σ = ΣLEXMUL.

(28)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

The order

rpo

Let%Σbe a pre-order over a signatureΣsuch thatΣis WF. The relationsrpotholds iff one of the following cases holds

1 [sub-term]s=f(s1, . . . ,sn)and∃is.t.sirpotorsi=tor

2 [Two symbols]s=f(s1, . . . ,sn),t=g(t1, . . . ,tm)and one of the following conditions is verified

(a) [precedence]f Σgand for allj,srpotj

(b) [multi-set]f∼ΣghaveMULstatus and{{s1, . . . ,sn}}(rpo)mul{{t1, . . . ,tm}}.

(c) [lexicographic]f∼ΣghaveLEXstatus andn=mand(s1, . . . ,sn)(rpo)lex(t1, . . . ,tn)and for allj,srpotj

(29)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Alternative definition of RPO

∃i.(sirpotorsi=t) [1]

f(s1, . . . ,sn)rpot fΣgand∀j.srpotj

[2.a]

s=f(s1, . . . ,sn)rpog(t1, . . . ,tm) f∼Σg∈ΣMULand{{s1, . . . ,sn}}(rpo)mul{{t1, . . . ,tm}}

[2.b]

s=f(s1, . . . ,sn)rpog(t1, . . . ,tm)=t

f ∼Σg∈ΣLEXand(s1, . . . ,sn)(rpo)lex(t1, . . . ,tn)and∀j.srpotj

[2.c]

s= f(s1, . . . ,sn) rpog(t1, . . . ,tn)=t

(30)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Remarks

Is this definition well-founded?

Ifrpois defined on two terms of sizekandlresp., then the recursive calls of

1 [sub-term]userpoon(k0,l)withk0<k.

2 [precedence]userpoon(k,l0)withl0<l.

3 [multi-set]use(rpo)mulon{{k1, . . . ,kn}}and{{l1, . . . ,lm}}withki<kandlj<l.

4 [lexicographic]use(rpo)lexon(k1, . . . ,kn)and(l1, . . . ,lm)withki<kandlj<l, and also rpoon(k,lj)withlj<l.

Can we avoid conditionsrpotjin case[lexicographic]?

We would have thataΣa0implies f(a,b)rpo f(a0,f(a,b))rpo f(a,b) If all the symbols areLEX, the order is known asLPO.

If all the symbols areMUL, the order is known asMPO.

(31)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Property of

rpo

Theorem

IfΣis WF, then the relationrpois a WF order.

Theorem

IfΣis WF, then the associated relationrpois a reduction order.

As a consequence, to prove that a given rewriting systemRisS N, it is sufficient to find an orderrposuch thatlrporfor everyl7→r∈ R.

The RPO was extended to the higher-order case.

(32)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Simple example

R=













0+y 7→r1 y

s(x)+y 7→r2 s(x+y)

0∗y 7→r3 0

s(x)∗y 7→r4 (x∗y)+y Define+Σ s,∗ Σ+andΣ0, all withMUL(orLEX) status.

Show thatl>rporfor each rulel7→r∈ R.

(33)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Thus for example for rules(x)∗y7→r4(x∗y)+y

Σ+

∗ ∼Σ

x=x s(x)rpo x {{s(x),y}}(rpo)mul{{x,y}}

s(x)∗yrpox∗y

y=y s(x)∗yrpoy s(x)∗yrpo(x∗y)+y

(34)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

More subtle example

R=

( f(g(x,y),z) 7→r1 f(x,y) f(g(a,a),y) 7→r2 f(a,g(a,a))

Define a pre-order on{f,g,a}, and give theMULstatus to all the symbols.

Try to show thatl>rporfor each rulel7→r∈ R. Change the symbol ftoLEXstatus.

Start again to showl>rporfor each rulel7→r∈ R.

(35)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Famous example: cut elimination in intuitionistic logic

x[x/t] 7→ t

y[x/t] 7→ y

(λz.u)[x/t] 7→ λz.u[x/t]

(yofuiswinv)[x/t] 7→ yofu[x/t]iswinv[x/t]

(xofuiswinv)[x/y] 7→ yofu[x/y]iswinv[x/y]

(xofuiswinv)[x/λz.t] 7→ v[x/λz.t][w/t[z/u[x/λz.t]]]

(xofuiswinv)[x/x0oft0iszint] 7→ x0oft0iszin((xofuiswinv)[x/t])

(36)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Combining orders

Suppose two SN relationsR1andR2. What aboutR1∪R2? Famous counter-example by Toyama:

R1={f(x,a,b)7→ f(x,x,x)}

R2=

( g(x,y)7→x g(x,y)7→y

)

The systemsR1andR2(which do not share symbols!) are SN butR1∪R2is not:

f(g(a,b),g(a,b),g(a,b))→R2 f(g(a,b),a,g(a,b))→R2

f(g(a,b),a,b)→R1 f(g(a,b),g(a,b),g(a,b))→. . .

(37)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Termination by Postponement

A relationRcan bepostponedw.r.t. a relationSiff

for alls,t,us.t. s →R t →S u there isv s →+S v →R∪S u

Theorem

LetRandSbe two WF relations s.t.Rcan be postponed w.r.t.S. Then the relation R∪Sis WF.

Corollary :IfSis WF, thenS∪.is WF.

(38)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Proof of Termination by Postponement

Proof.

We will show that any(R∪S)-reduction sequence starting with an arbitrary termsis finite. We reason by (lexicographic) induction on(s,n), wheresis compared using the WF relationS, andnis the number ofR-steps separatingsfrom the firstS-step.

The base case is(s,0), wheresis anS-normal form. The sequence is either empty or contains onlyR-steps, so is finite by hypothesis.

If the(R∪S)-sequence does not contain anyS-step, then it is finite by WF ofR. If the(R∪S)-sequence does not contain anyR-step, then it is finite by WF ofS. If the(R∪S)-sequence starts withn=k+1R-steps, it is of the form

s→kRs0R t→S u. . .. The postponement hypothesis gives a sequence

s→kRs0+Sv→R∪Su. . .. Since(s,k)<lex(s,k+1), then this sequence is finite by thei.h.

If the(R∪S)-sequence starts withs→S t. . ., then the sequence starting attis smaller for the given order than the original one,i.e.(t,m)<lex(s,n)for anym. Then, thei.h.applies to the sequence starting att, and thus the sequence starting att, and thus the one starting atsis finite.

(39)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Example

Consider thesimply typedλ-calculus enriched with a constant>type, equipped with the following rules:

(λx.t)u 7→β t{x\u}

λx.t x 7→η t ifx<fv(t)

t 7→ ? if

( tis of>type t,?

LetR=η∪ΩandS=β. Now, Show thatη∪Ωis WF.

Show thatη∪Ωcan bepostponedw.r.t.β. Sinceβis SN, then conclude thatη∪Ω∪βis SN.

(40)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Termination by projection/simulation

Theorem

LetR1,R2be two relations overOs.t.

1 R2terminates

2 There is asimulationT :O→O0and arelationSoverO0s.t.

(a) a→R1 bimpliesT(a)→+ST(b), (b) a→R2 bimpliesT(a)→ST(b).

(c) Sterminates.

Then,(R1∪R2)also terminates.

RemarkIn particular, one can takeT(a)=T(b)in item 2(b).

Proof.

Suppose(R1∪R2)does not termine. SinceR2terminates by hypothesis (1), every infinite(R1∪R2)-sequence necessarily contains an infiniteR1-sequence. We can then write this sequence as:

a1R

2a2+R

1a3R

2a4+R

1. . . By the simulation hypothesis 2(a) and 2(b) we obtain:

T(a1)→ST(a2)→+ST(a3)→ST(a4)→+S. . .

which contradicts termination ofSwhich is hypothesis 2(c).

(41)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

(Famous) Example

Considersimply typedextensionalλ-calculus

(λx.M)N 7→β M{x\N}

π1hM,Ni 7→π1 M

π2hM,Ni 7→π2 N

M 7→ηexp λx.M x if

( Mis of functional type Mis not aλ-abstraction Mis not applied inC[M]

M 7→spexp1(M), π2(M)i if

( Mis of product type Mis not a pair Mis not projected inC[M]

(42)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Thus for example ifz:A×Bandx: (A×B)→(C→D), then

I x z→β x z →spexp xhπ1(z), π2(z)i →ηexp λy.(xhπ1(z), π2(z)i)y

LetR1=β∪π1∪π2andR2exp∪spexpandS=β∪π1∪π2. Now, Show thatηexp∪spexpis terminating.

Show thatβ∪π1∪π2is terminating (done).

Show thatηexp∪spexpis also confluent.

DefineT(t)as theηexp∪spexp-normal form oft. Show thatt→β∪π1∪π2 t0impliesT(t)→+β∪π

1∪π2T(t0) Show thatt→ηexp∪spexp t0impliesT(t)=T(t0)(evident).

Conclude that all the systemR1∪R2is SN.

(43)

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner

Termination by Dependency Pairs

The technique is due to Aarts and Giesl.

The order does not decrease foreverystep, but for thedependentones.

The technique is very suitable for functional programming.

It was extended to higher-order by Sakai and Kusakari.

It was extended to abstract rewriting by Lengrand.

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 : [email protected]

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 [email protected] www.irif.fr/˜kesner.. S ´emantique des langages

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner..

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner.. The Untyped

Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner.. Typed