• Aucun résultat trouvé

Rewriting modulo in Deduction modulo

N/A
N/A
Protected

Academic year: 2021

Partager "Rewriting modulo in Deduction modulo"

Copied!
16
0
0

Texte intégral

(1)

HAL Id: inria-00105625

https://hal.inria.fr/inria-00105625

Submitted on 11 Oct 2006

HAL

is a multi-disciplinary open access archive for the deposit and dissemination of sci- entific research documents, whether they are pub- lished or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.

L’archive ouverte pluridisciplinaire

HAL, est

destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

Rewriting modulo in Deduction modulo

Frédéric Blanqui

To cite this version:

Frédéric Blanqui. Rewriting modulo in Deduction modulo. Rewriting Techniques and Applications,

14th International Conference, RTA 2003, Jun 2003, Valencia, Spain. �inria-00105625�

(2)

inria-00105625, version 1 - 11 Oct 2006

FrédériBlanqui

Laboratoired'Informatiquedel'ÉolePolytehnique

91128 PalaiseauCedex,Frane

Abstrat. Westudytheterminationofrewritingmoduloasetofequa-

tionsintheCalulusofAlgebraiConstrutions,anextensionoftheCal-

ulusofConstrutionswithfuntionsandprediatesdenedbyhigher-

order rewrite rules. In a previous work, we dened general syntati

onditionsbasedonthenotionofomputabilitylosureforensuringthe

terminationoftheombinationofrewritingandβ-redution.

Here,weshowthatthisresultispreservedwhenonsideringrewriting

moduloasetof equationsifthe equivalenelasses generated by these

equationsarenite,theequationsare linearandsatisfy generalsynta-

ti onditions also based onthe notion of omputability losure. This

inludesequationslikeassoiativityandommutativityandprovidesan

originaltreatmentofterminationmoduloequations.

1 Introdution

TheCalulusofAlgebraiConstrutions(CAC)[2,3℄isanextensionoftheCal-

ulusofConstrutions(CC)[9℄withfuntionsandprediatesdenedby(higher-

order)rewriterules.CCembodiesin thesameformalismGirard'spolymorphi

λ-alulusandDeBruijn'sdependenttypes,whihallowsonetoformalizepropo-

sitionsandproofsof(imprediative)higher-orderlogi.Inaddition,CACallows

funtionsandprediatestobedenedbyanysetof(higher-order)rewriterules.

And, in ontrast with (rst-order) Natural Dedution Modulo [13℄, proofs are

partoftheterms.

Verygeneral onditionsare studied in [2,4℄ for preserving the deidability

oftype-hekingandthelogialonsistenyof suh asystem.Butthese ondi-

tionsdonottakeintoaountrewritingmoduloequationslikeassoiativityand

ommutativity (AC), whih would be very useful in proof assistantslike Coq

[22℄ sine itinreasesautomation and dereasesthe size of proofs. Wealready

used the rewritingengine ofCiME [8℄, whih allowsrewriting modulo AC, for

a prototype implementation of CAC, and now work on a new version of Coq

inludingrewritingmoduloAC.Inthispaper,weextendtheonditionsgivenin

[2℄todealwithrewritingmoduloequations.

2 The Calulus of Algebrai Construtions

Weassume thereaderfamiliar with typed λ-aluli[1℄and rewriting[11℄.The

CalulusofAlgebraiConstrutions(CAC)[2℄simplyextendsCCbyonsidering

asetF ofsymbolsand asetRofrewrite rules.ThetermsofCACare:

(3)

t, u∈ T ::=s|x|f |[x:t]u|tu|(x:t)u

where s∈ S ={⋆,2}isasort,x∈ X avariable, f ∈ F,[x:t]uanabstration,

tuanappliation, and(x:t)uadependent produt,writtent⇒uifxdoesnot

freelyourin u.

Thesortdenotes the universe of typesand propositions, and the sort 2

denotestheuniverseofprediatetypes(alsoalledkinds).Forinstane,thetype

nat ofnaturalnumbersisoftype,itself isoftype2and nat⇒⋆,thetype

ofprediatesovernat,isoftype2.

Weuse bold fae letters fordenotingsequenes of terms.Forinstane, t is

thesequenet1. . . tn where n=|t|isthelengthof t,and(x:T)U istheterm (x1:T1). . .(xn:Tn)U (weimpliitlyassumethat|x|=|T|=n).

WedenotebyFV(t)thesetoffreevariablesoft,bydom(θ)thedomainofa

substitutionθ,byPos(t)thesetofDewey'spositionsoft,byt|pthesubtermof

t atposition p,andbyt[u]pthereplaementoft|p byu.

Everysymbolf isequippedwithasortsf,anarityαf andatypeτf whih

maybe any losed term of theform (x : T)U with |x| =αf. The termsonly

builtfromvariablesandappliationsoftheform ftwith|t|=αf arealgebrai.

AtypingenvironmentΓ is anorderedlist oftypedelarationsx:T. Iff is

asymboloftypeτf = (x:T)U,wedenotebyΓf theenvironmentx:T.

ArulefortypingsymbolsisaddedtothetypingrulesofCC:

(symb)

⊢τf :sf

⊢f :τf

Arewriteruleisapairl→rsuhthat(1)lisalgebrai,(2)lisnotavariable,

and(3)FV(r)⊆FV(l).Onlyl hasto bealgebrai:r mayontainappliations, abstrations andproduts.This isapartiularaseofCombinatoryRedution

System(CRS)[18℄whihdoesnotneedhigher-order pattern-mathing.

IfG ⊆ F,RG is thesetofruleswhose left-hand sideisheadedbyasymbol

in G.A symbolf withR{f} =∅ isonstant,otherwiseitis(partially)dened.

Aruleis left-linear (resp.right-linear)if novariableours morethanone

in the left-hand side (resp. right-hand side). A rule is linear if it is both left-

linear and right-linear.A rule is non-dupliating ifno variable ours morein

theright-handsidethanin theleft-hand side.

Atermt R-rewritestoatermt,written t→R t, ifthere existsaposition pint,arulel→r∈ Randasubstitutionσ suhthat t|p=lσ andt=t[rσ]p.

A termt β-rewritesto atermt,written t→β t, ifthereexists aposition pin t suh that t|p = ([x:U]v u)andt =t[v{x7→u}]p.Givenarelationanda

termt,let→(t) ={t∈ T |t→t}.

Finally, in CAC, βR-equivalent typesare identied. Morepreisely, in the typeonversionruleof CC,β isreplaedbyβR:

(onv)

Γ ⊢t:T T ↓βRT Γ ⊢T:s Γ ⊢t:T

(4)

whereu↓βRvithereexistsatermwsuhthatu→βRwandv→βRw,βR

being the reexiveand transitive losure ofβ ∪ →R. This rule means that

anytermt oftypeT in theenvironmentΓ isalso oftype T ifT andT have

aommonredut(andT isoftypesomesorts).Forinstane,ift isaproofof P(2 + 2)thentisalsoaproofof P(4)ifRontainsthefollowingrules:

x+ 0 → x x+ (s y) → s(x+y)

Thisdereasesthesize ofproofsandinreasesautomationaswell.

Asubstitutionθpreserves typingfromΓ to, writtenθ:Γ ;∆,if,forall x∈dom(Γ), ∆ ⊢xθ :xΓ θ, whereisthe typeassoiated to xin Γ. Type-

preservingsubstitutionsenjoythefollowingimportantproperty:ifΓ ⊢t:T and θ:Γ ;∆ then∆⊢tθ:T θ.

For ensuring the subjet redution property (preservation of typing under

redution), everyrulefl→r isequippedwithanenvironmentΓ andasubsti-

tution ρsuh that,1 iff : (x:T)U and γ={x7→l} thenΓ ⊢flρ:U γρ and Γ ⊢r:U γρ.Thesubstitution ρallowsto eliminatenon-linearitiesonlydue to typingand thus makesrewriting moreeientand onuene easierto prove.

Forinstane, the onatenation on polymorphi lists (type list : ⋆ ⇒ ⋆ with

onstrutors nil : (A : ⋆)listA and cons: (A : ⋆)A ⇒ listA⇒ listA)of type (A:⋆)listA⇒listA⇒listAanbedenedby:

app A(nil A)l → l

app A(cons A x l)l → cons A x (app A x l l) app A(app A l l)l′′ → app A l(app A l l′′)

with Γ = A : ⋆, x : A, l : listA, l : listA and ρ = {A 7→ A}. Forinstane, app A (nil A) is not typablein Γ (sine A ∈/ dom(Γ)) but beomes typable

if weapply ρ. This does not matter sine, if an instane app Aσ (nil Aσ) is

typablethenisonvertibletoAσ.

3 Rewriting Modulo

Now, weassumegiven asetE of equationsl =r whih will beseenasaset of

symmetrirules,thatis, asetsuhthatl→r∈ E ir→l∈ E.Theonditions

onrulesimplythat,ifl=r∈ E,then(1)bothl andrarealgebrai,(2)bothl

andrareheadedbyafuntionsymbol,(3)landrhavethesame(free)variables.

Examplesof equationsare:

x+y =y+x (ommutativityof+)

x+ (y+z)=(x+y) +z (assoiativityof+)

x×(y+z)=(x×y) + (x×z) (distributivityof×) x+ 0 =x (neutralityof0)

1

(5)

add A x(add A y S)=add A y (add A x S) union A S S =union A S S

union A S (union A S S′′)=union A(union A S S)S′′

where set : ⋆ ⇒ ⋆, empty : (A : ⋆)setA, add : (A : ⋆)A ⇒ setA⇒ setA and union : (A : ⋆)setA ⇒ setA ⇒ setA formalizenite sets of elements of type A. Exept for distributivity whih is not linear, and the equation x+ 0 = x

whose equivalene lasses are innite, all the other equations will satisfy our

strongnormalizationonditions.Notehoweverthatdistributivityandneutrality

analwaysbeused as rules when orientedfrom left to right. Hene,the word

problemforabeliangroupsorabelianringsforinstaneanbedeidedbyusing

normalizedrewriting[19℄.

Ontheotherhand,thefollowingexpressionsarenotequationssineleftand

right-handsideshavedistintsetsofvariables:

x×0 =0 (0isabsorbingfor×) x+ (−x)=0 (inverse)

Letbe the reexive and transitive losure ofE (is an equivalene

relation sine E is symmetri). We are now interested in the termination of

=→β∪ ∼→R(insteadofβ∪ →R before).Inthefollowing,wemaydenote

E byE,R byRandβ byβ.

Inordertopreserveallthebasipropertiesofthealulus,wedonothange

the shapeof the relationused in the typeonversionrule (onv): twotypesT

and T are onvertibleifT ↓T with→=→β ∪ →R ∪ →E.Butthis raisesthe

questionofhowtohekthisondition,knowingthatmaybenotterminating.

Westudythisproblemin Setion6.

4 Conditions of strong normalization

Inthestrongnormalizationonditions,wedistinguishbetweenrst-ordersym-

bols(set F1)and higher-order symbols (set Fω). To preiselydene what isa

rst-order symbol, we need a little denition before. We say that a onstant

prediatesymbolisprimitiveifitisnotpolymorphiandifitsonstrutorshave

no funtional arguments. This inludes in partiular any rst-order data type

(naturalnumbers,listsofnaturalnumbers,et.).Now,asymbolf isrst-order

ifitisaprediatesymbolofmaximalarity, 2

orifitisafuntion symbolwhose

outputtypeis aprimitiveprediatesymbol.Anyother symbolis higher-order.

LetRι=RFι and Eι=EFι forι∈ {1, ω}.

Sine the pioneer works on the ombination of λ-alulus and rst-order

rewriting [7,20℄, it is well known that the addition at the objet level of a

strongly normalizingrst-order rewritesystem preservesstrong normalization.

Thisomesfrom thefat thatrst-orderrewritingannotreateβ-redexes.On

2

Aprediate symbolf oftype(x:T)U isofmaximalarity ifU =⋆,that is,ifthe

elementsoftypeftarenotfuntions.

(6)

the other hand, higher-order rewriting an reate β-redexes. This is why we

have other onditions on higher-order symbols than merely strong normaliza-

tion.Furthermore,in orderfor thetwosystemstobeombinedwithoutlosing

strongnormalization[23℄,wealsorequirerst-orderrulestobenon-dupliating

[21℄.Notehoweverthatarst-ordersymbolanalwaysbeonsideredashigher-

order(butthestrongnormalizationonditionsonhigher-ordersymbolsmaynot

bepowerfulenoughforprovingthetermination ofitsdening rules).

Thestrongnormalizationonditionsonhigher-orderrewriterulesarebased

on the notionof omputability losure [5℄. Weare going to use this notionfor

theequationstoo.

Typedλ-aluliaregenerallyprovedstronglynormalizingbyusingTaitand Girard's tehnique of omputability prediates/reduibility andidates [14℄. In-

deed, a diret proof of strong normalization by indution on the struture of

termsdoesnotwork.TheideaofTait,laterextendedbyGirardtothepolymor-

phi λ-alulus, is to strengthen the indution hypothesis asfollows.Toevery

typeT,oneassoiatesaset [[T]]⊆ SN (setofstronglynormalizingterms),and provesthat everytermoftypeT isomputable,that is,belongsto [[T]].

Now,ifweextendsuhaaluluswithrewriting,forpreservingstrongnor-

malization,arewriterulehastopreserveomputability.Theomputabilitylo-

sureofatermt isaset oftermsthat areomputablewhenevert itselfisom-

putable.So,iftheright-handsiderofarulefl→rbelongstotheomputability losureofl,aonditionalledtheGeneralShema,thenrisomputablewhen-

everthetermsin lareomputable.

Formally,theomputabilitylosure fora rule(fl→ r, Γ, ρ) with τf = (x: T)U andγ={x7→l}isthesetoftermstsuhthatthejudgmentct:U γρan

bededued fromtherules ofFigure 1,wherethe variablesofdom(Γ)are on-

sideredassymbols(τx=xΓ),>F isawell-foundedquasi-ordering(preedene) onsymbols,withx <Ff forallx∈dom(Γ),>f isthemultisetorlexiographi extension

3

ofthesubtermordering

4,andT ↓f T iT andThaveaommon

redutbyf=→β∪ →R<

f

whereR<f ={gu→v∈ R |g <Ff}.

Inaddition,everyvariable x∈dom(Γ)is requiredto beaessible in some li, that is,is omputable whenever liσ is omputable. The argumentsof a

onstrutor-headed term are always aessible.Fora funtion-headed term ft

with f : (x:T)Cv andC onstant,onlythe ti'ssuhthat C ours positively

in Ti areaessible(X ourspositivelyinY ⇒X andnegativelyinX ⇒Y).

TherelationcissimilartothetypingrelationofCACexeptthatsymbol

appliations are restritedto symbolssmallerthan f, orto argumentssmaller

than l in thease of an appliation of asymbolequivalentto f.So, verifying

that arule satises theGeneral Shema amountsto hekwhether r hastype U γρ withthepreviousrestritionson symbolappliations. Itthereforehasthe sameomplexity.

3

Orasimpleombinationthereof,dependingonthestatusoff.

4

We use a more powerful ordering for dealing with reursive denitions on types

(7)

Fig.1.Computabilitylosure for(fl→r, Γ, ρ)

(ax)

c⋆:2

(symb

<

)

cτg:sg

cg:τg

(g <Ff)

(symb

=

)

cτg:sg δ:Γg ;c

∆⊢cgyδ:V δ

g= (y:U)V, g=Ff andyδ <f l)

(var)

∆⊢cT :s

∆, x:T ⊢cx:T (x /∈dom(∆))

(weak)

∆⊢cT :s ∆⊢cu:U

∆, x:T⊢cu:U (x /∈dom(∆))

(abs)

∆, x:U⊢cv:V ∆⊢c(x:U)V :s

∆⊢c[x:U]v: (x:U)V

(app)

∆⊢ct: (x:U)V ∆⊢cu:U

∆⊢ctu:V{x7→u}

(prod)

∆, x:U⊢cV :s

∆⊢c(x:U)V :s

(onv)

∆⊢ct:T ∆⊢cT :s ∆⊢cT:s

∆⊢ct:T (T ↓f T)

Now, how the omputability losure an help us in dealingwith rewriting

moduloequations?Whenonetriestoprovethateverytermisomputable,inthe

aseofatermft,itissuienttoprovethateveryredutofftisomputable.

Intheaseofahead-redutflσ→rσ,thisfollowsfromthefatthatrbelongs

totheomputabilitylosureoflsine,byindutionhypothesis,thetermsin

areomputable.

Now, with rewriting modulo, a R-step anbepreeded by E-steps: ft →E gu→Rt.Toapplythepreviousmethodwithgu,wemustprovethattheterms

inu areomputable.Thisanbeahievedbyassumingthattheequationsalso

satisfytheGeneralShemainthefollowingsense:anequation(fl→gm, Γ, ρ)

with τg = (x: T)U and γ={x7→m} satisesthe GeneralShemaif, forall i,c mi:Tiγρ,that is,thetermsinm belongtotheomputabilitylosureofl.

Bysymmetry,thetermsinlbelongtotheomputabilitylosureofm.

Oneaneasilyhekthatthisonditionissatisedbyommutativity(what-

everthetypeof+is)andassoiativity(ifbothy andz areaessibleiny+z):

x+y = y+x x+ (y+z) = (x+y) +z

(8)

Forommutativity,thisisimmediateanddoesnotdependonthetypeof+:

bothy andxbelongtotheomputabilitylosureofxandy.

For assoiativity,wemust provethat both x+y andz belong to theom-

putabilitylosureCCofxandy+z.Ifweassumethatbothyandzareaessible

in y+z(whih istheaseforinstaneif+ :nat⇒nat⇒nat),thenzbelongs

to CCand, byusingamultisetstatusforomparing theargumentsof+,x+y

belongstoCCtoosine{x, y}mul{x, y+z}.

Wenowgiveallthestrongnormalizationonditions.

Theorem1 (Strongnormalization ofβ∪ ∼R).Let1 bethe reexiveand

transitivelosureof E1. Therelation=→β ∪ ∼→R isstronglynormalizing if the followingonditions adaptedfrom [2℄aresatised:

• →=→β∪ →R∪ →E isonuent,5

the rulesofR1 arenon-dupliating,

6 R1∩ Fω=E1∩ Fω=∅7and1R1 is

stronglynormalizing onrst-orderalgebrai terms,

the rules ofRω satisfythe General Shemaandare safe,8

rules onprediate symbols have noritialpair, satisfy theGeneral Shema9

andare small, 10

andif the following new onditionsaresatisedtoo:

thereisno equationon prediate symbols,

• E islinear,

the equivalene lassesmoduloarenite,

every rule(fl→gm, Γ, ρ)∈ E satisesthe General Shemain the following

sense: ifτg = (x:T)U andγ={x7→m} then, forall i,cmi:Tiγρ.

Notallowingequationsonprediatesymbolsisanimportantlimitation.How-

ever, one annot have equations on onnetors if one wants to preserve the

Curry-Howardisomorphism.Forinstane, withommutativityon, onelooses

subjetredution.Take∧:⋆⇒⋆⇒⋆,pair: (A:⋆)(B :⋆)A⇒B⇒A∧B and π1: (A :⋆)(B : ⋆)A∧B ⇒A dened by π1 A B (pair A B a b)→a. Then, π1B A (pair A B a b)isof typeB but ais not.

5 Strong normalization proof

Thestrongnormalizationprooffollowstheonegivenin[6℄verylosely.

11

Weonly

givethedenitionsandlemmasthatmustbemodied.Aspreviouslyexplained,

5

Iftherearetype-levelrewriterules.

6

Iftherearehigher-orderrules.

7

First-orderrules/equationsonlyontainrst-ordersymbols.

8

Nopattern-mathingonprediates.

9

Thereareotherpossibilities.See[2℄formoredetails.

10

Arulefl→rissmallifeveryprediatevariableinrisequaltooneoftheli's.

11

Références

Documents relatifs

This encoding allows us, first, to properly define matching modulo β using the notion of higher order rewriting and, secondly, to make available, in the λ Π-calculus Modulo,

Using orthogonality, we have constructed a pre-Boolean algebra of sequents which allows to prove that our classical superconsistency criterion implies cut-elimination in

The theory of deduction modulo is an extension of predicate calculus, which allows us to rewrite terms as well as propositions, and which is well suited for proof search in

The theory of deduction modulo is an extension of predicate calculus, which allows us to rewrite terms as well as propositions, and which is well suited for proof search in

— Generalizing a result of Bombieri, Masser, and Zannier we show that on a curve in the algebraic torus which is not contained in any proper coset only finitely many points are close

We define a partition of the set of integers k in the range [1, m−1] prime to m into two or three subsets, where one subset consists of those integers k which are &lt; m/2,

This last step does NOT require that all indicator be converted - best if only a small percent need to be reacted to make the change visible.. Note the

LondonChoralCelestialJazz, by Bernardine Evaristo: A short story in verse set in the high-octane, adrenaline-charged streets of contemporary London. Inspired by Dylan Thomas, read