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, estdestiné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�
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:
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.
Thesort ⋆ denotes 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.Givenarelation→anda
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′
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Γ θ, where xΓ isthe 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
typablethenAσ isonvertibletoA′σ.
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
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)
Let ∼ be the reexive and transitive losure of →E (∼ 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,knowingthat→maybenotterminating.
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.
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}isthesetoftermstsuhthatthejudgment⊢ct: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 andT′haveaommon
redutby→f=→β∪ →R<
f
whereR<f ={gu→v∈ R |g <Ff}.
Inaddition,everyvariable x∈dom(Γ)is requiredto beaessible in some li, that is, xσ 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).
Therelation⊢cissimilartothetypingrelation⊢ofCACexeptthatsymbol
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
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 lσ
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
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).Let∼1 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ω=∅7and∼1→R1 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 lassesmodulo ∼arenite,
• 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