ebook img

Sound and Complete Typing for lambda-mu PDF

0.14 MB·
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Sound and Complete Typing for lambda-mu

Sound and Complete Typing for λµ Steffen vanBakel DepartmentofComputing,ImperialCollegeLondon,180Queen’sGate,LondonSW72BZ,UK [email protected] InthispaperwedefineintersectionanduniontypeassignmentforParigot’scalculusλµ. Weshow that this notion is complete (i.e. closed under subject-expansion), and show also that it is sound (i.e.closedundersubject-reduction). Thisimpliesthatthisnotionofintersection-uniontypeassign- mentissuitabletodefineasemantics. Introduction TheIntersectionTypeDisciplinehasproventobeanexpressivetoolforstudyingterminationandseman- tics for the λ-calculus [12, 10]. Intersection type assignment is defined as an extension of the standard, implicative type assignment known as Curry’s system [15] (see also [24]), which expresses function composition and application; the extension made consists of relaxing the requirement that a parameter forafunctionshouldhaveasingletype,addingthetypeconstructor ∩ nextto→. Thissimpleextension allowsforagreatleapincomplexity: notonlycana(filter)modelbebuiltfortheλ-calculususinginter- sectiontypes,alsostrongnormalisation(termination)canbecharacterisedviaassignabletypes;however, typeassignmentbecomesundecidable. Theliteratureonintersection typesisvast;itwasfirstdefinedby Coppo and Dezani-Ciancaglini in [13] and its development took place over a number of years, culmi- natinginthepaperbyBarendregt, Coppo,andDezani-Ciancaglini [11],andhasbeenexploredbymany peoplesince. It is natural to ask if these results can be achieved for other calculi (reduction systems) as well, andinpreviouspaperstheauthorinvestigated(incollaboration) TermRewritingSystems[6],andObject OrientedCalculi[5];Maffeislookedatintersectiontypesinthecontextoftheπ-calculus[26]. Inorderto cometoacharacterisation ofstrongnormalisation forCurienandHerbelin’s(untyped) sequent calculus λµµ˜ [14], Dougherty, Ghilezan and Lescanne presented System M∩∪ [17], that defines a notion of intersection anduniontypingforthatcalculus; inalaterpaper[18],theypresented animprovedversion oftheiroriginal system. In[3],theauthorrevisited SystemM∩∪,andshowedthatthatsystemwasneithersound (i.e.closed under reduction), nor complete (i.e. closed under reverse reduction); the same holds for the system pre- sented in [18]. To address completeness, [3] adds ⊤ as the maximal and ⊥ as the minimal type, and extends the set of derivation rules; however, soundness is shown to be impossible to achieve without restricting typeability (effectively making less terms typeable). In[4], the author attempted tosolve the sameissue,butthistimeinthecontextofthesequentcalculus X,asdefinedbyLengrand[25],andlater studied by Lescanne and the author [7, 8]; X is a sequent calculus in that it enjoys the Curry-Howard isomorphism withrespect totheimplicative fragment ofGentzen’s LK [20]. Theadvantage ofusing the sequent approach isthatitisnowpossible toexplore theduality ofintersection andunionfully, through which we can study and explain various anomalies of union type assignment [32, 9] and quantification [22,27]. AlsoforX,thecompleteness resultfollowsrelatively easily,butsoundness canonlybeshown E.Pimentel,B.VenneriandJ.Wells(Eds.):Workshopon IntersectionTypesandRelatedSystems2010(ITRS2010). EPTCS45,2011,pp.31–44,doi:10.4204/EPTCS.45.3 32 SoundandCompleteTypingforλµ forrestrictedsystems(effectivelycall-by-name andcall-by-value reduction, butitmightbepossiblethat othersound restrictions existaswell). Themainconclusion ofthosepapersisthat, insymmetriccalculi (like λµµ˜ and X) it is inevitable that intersection and union are truly dual, and that the very nature of thosecalculimakesasoundandcompletesystemunachievable. In this paper we will continue on this path and bring intersection types to the context of classical logic, by presenting a notion of intersection and union type assignment for the (untyped) calculus λµ, thatwasfirstdefinedbyParigotin[31],andwaslaterextensively studied byvariousauthors. Intersectionanduniontypeshavealsobeenstudiedinthecontextoftheλ-calculusin[9];alsoforthe systemdefinedinthatpapersoundnessislost,whichcanonlyberecoveredbylimitingtoparallelreduc- tion, i.e.allresiduals ofaredexneedtobecontracted inparallel. Theproblem oflossofsoundness also appearsinothercontexts,suchasthatofML withside-effects [22,33,27],andthatofusingintersection anduniontypesinanoperationalsetting[16,19]. Ashere,alsotherethecauseoftheproblemisthatthe type-assignment rules are not fully logical, making the context calls (which form part of the reduction in X) unsafe; this has, in part, already been observed in [23] in the context of Curien and Herbelin’s calculus λµµ˜ [14]. This also explains why, for ML with side-effects, quantification is no longer sound [22,27]: alsothe(∀I)and(∀E)rulesofML arenotlogical. In the view of those failures, the result presented here comes as a surprise. We will define a notion of type assignment for λµ that uses intersection and union types, and show that it is both sound and complete. The system presented is a natural extension of the strict intersection type assignment system as defined in[2]; this implies that intersection models the distribution of arguments in aparameter call. Butitisalsoanaturalextensionofthesystemforλµ,andinordertoachievecompletenessforstructural reduction, as in the papers mentioned above, union types are added. However, the union types are no longerdualtointersection types;uniontypesplayonlyamarginalrole,aswasalsotheintentionof[18]. Contrary to that paper, however, we do not see union as negated intersection, but see a union type as a stricttype;inparticular, wedonotallowthenormal(∪I)and(∪E)rulesasusedin[9],whichweknow create thesamesoundness problem. Moreover, although onecanlinkintersection typeswiththelogical connector and, the union types we use here have no relation with or; one could argue that therefore perhapsunionisnottherightnametouseforthistypeconstructor, butwewillstickwithitnonetheless. The limited view of union types is mirrored by λµ’s limited (with respect to λµµ˜ and X) notion of context1. In λµ, we distinguish control structures as those terms that start with a context switch µα.[β]M, followed by a number of arguments; since union types allow us to express that the various continuations (all called α) need not have the same type, weuse adifferent formulation for rule (→E), which has an implicit use of union elimination (see Definition 3.2). The type system defined here will beshowntobethenaturalone,inthatintersection andunionplaytheirexpectedrolesforcompleteness. Becausetheuseofintersection andunionislimitedinthatacontextvariablecannothaveanintersection type,andalthoughweallowuniontypesfortermvariables,wedonothavethenormalunionelimination rule;thankstothesetworestrictions, wecanshowsoundness aswell. 1 The calculus λµ Parigot’s λµ-calculus [29] is a proof-term syntax for classical logic, expressed in Natural Deduction, definedasanextension oftheCurrytypeassignment systemfortheλ-calculus. Wequicklyrevisesome basicnotions: 1Inparticular,λµµ˜’sµ˜x.cisnotrepresented. SteffenvanBakel 33 Definition1.1 (LAMBDA TERMS AND β-CONTRACTION [10]) 1. λ-termsaredefinedby: M,N ::= x|λx.M| MN 2. Thereduction relation → isdefinedasthecontextual closureoftherule: β (λx.M)N → M[N/x] β Curry(orsimple)typeassignmentfortheλ-calculus isdefinedas: Definition1.2 1. Let ϕrangeoveracountable(infinite)setoftype-variables. ThesetofCurry-types isdefinedbythegrammar: A,B ::= ϕ|(A→B) 2. Curry-type assignment isdefinedbythefollowingnatural deduction system. Γ,x:A⊢M:B Γ⊢M:A→B Γ⊢N:A (Ax): (→I): (→E): Γ,x:A⊢x:A Γ⊢λx.M:A→B Γ⊢ MN:B With λµ Parigot created amulti-conclusion typing system which corresponds to classical logic; the derivable statements have the shape Γ ⊢ M:A|∆, where A is the main conclusion of the statement, λµ expressed as the active conclusion, and ∆ contains the alternative conclusions, consisting of pairs of Greek characters and types; the left-hand context Γ, as usual, contains pairs of Roman characters and types, andrepresents thetypesofthefreetermvariables of M. AswithImplicative Intuitionistic Logic, thereductionrulesforthetermsthatrepresenttheproofscorrespondtoproofcontractions; thedifference is that the reduction rules for the λ-calculus are the logical reductions, i.e. deal with the elimination of atype construct that hasbeen introduced directly above. Inaddition tothese, Parigot expresses also the structuralrules,whereeliminationtakesplaceforatypeconstructorthatappearsinoneofthealternative conclusions (the Greek variable is the name given to a subterm): he therefore needs to express that the focus of the derivation (proof) changes, and this is achieved by extending the syntax with two new constructs [α]M and µα.M that act as witness to deactivation and activation, which together move the focusofthederivation. Wewillnowpresentthevariantofλµweconsiderinthispaper,asconsideredbyParigotin[30];for convenience, wesplittermsintotwocategories: wedefineterms,andcontrolstructure: Definition1.3 (SYNTAX OFλµ) Theλµ-termsweconsider are: M,N ::= x|λx.M| MN |µα.[β]M. Wealsodefinecontrolstructure asasubsetofterms: C ::= µα.[β]M |CM. Toshortenproofsandnotation, wewilltreat µα.Masatermaswell,wheneverconvenient. Asusual,λx.MbindsxinM,andµα.[β]MbindsαinM,andthenotionsoffreeandboundvariables are defined accordingly; the notion of α-conversion extends naturally to bound names, and we assume Barendregt’s convention onfreeandboundvariables. In λµ, reduction of terms is expressed via implicit substitution; as usual, M[N/x] stands for the substitution ofalloccurrences of x in M by N, and M[N·γ/α] stands fortheterm obtained from M in whichevery(pseudo) sub-term oftheform [α]M′ issubstituted by [γ](M′N) (γ isafreshvariable) (in Parigot’snotation: (µα.[β]M)N →µγ.[β]M[[γ]PN/[α]P]). Wedefineformallyhowtopreform theµ-substitution; thisisconvenient inlaterproofs. 34 SoundandCompleteTypingforλµ Definition1.4 Wedefine M[N·γ/α]byinduction overthestructure oftermsby: ∆ x[N·γ/α] = x ∆ (λx.M)[N·γ/α] = λx.(M[N·γ/α]) ∆ (M1M2)[N·γ/α] = M1[N·γ/α] M2[N·γ/α] ∆ (µδ.[α]M)[N·γ/α] = µδ.[γ](M[N·γ/α]N) ∆ (µδ.[β]M)[N·γ/α] = µδ.[β](M[N·γ/α]) β6=α Wehavethefollowingrulesofcomputation inλµ: Definition1.5 (λµREDUCTION) Parigotdefinesanumberofreduction rules: twocomputational rules logical (β): (λx.M)N → M[N/x] structural (µ): (µα.[β]M)N → µγ.([β]M[N·γ/α]) aswellasthesimplification rules: renaming: µα[β](µγ.[δ]M) → µα.[δ]M[β/γ] erasing: µα.[α]M → M ifαdoesnotoccurin M. ηµ: µα.[β]M → λxµγ.[β]M[x·γ/α] whichareaddedmainlytosimplifythepresentation ofhisresults2. Reduction onλµ-termsisdefinedasthecompatible closureoftheserules. Itispossible todefinemorereduction rules, butParigotrefrained fromthatsince heaimedatdefininga confluentreduction system. The intuition behind the structural rule is given by de Groote [21]: “in a λµ-term µα.M of type A→B,onlythesubtermsnamedbyαarereallyoftype A→B(...);hence,whensuchaµ-abstractionis applied toanargument, thisargument mustbepassedovertothesub-termsnamedbyα.” Inthispaper, we will only deal with the logical, structural and renaming rule; this is also the restriction made by de Grootein[21]. Type assignment for λµ is defined by the following natural deduction system; there is a main, or active,conclusion, labelled byatermofthiscalculus, andthealternativeconclusions arelabelledbythe setofGreekvariables α,β,etc. Definition1.6 (TYPING RULES FORλµ) Our types are those of Definition 1.2, extended with the type constant ⊥thatisessentially addedtoexpressnegation, i.e.: A,B ::= ϕ|⊥|(A→B) (A6=⊥) Thetypeassignmentrulesare: (Ax): Γ ⊢ x:A|∆ (x:A∈Γ) (µ): ΓΓ⊢⊢µMα.[:βB]M|α::AA,|ββ:B:B,∆,∆ ΓΓ⊢⊢µMα.[:αA]M|α::AA,|∆∆ Γ,x:A ⊢ M:B|∆ Γ ⊢ M:A→B|∆ Γ ⊢ N:A|∆ (→I): (→E): Γ ⊢ λx.M: A→B|∆ Γ ⊢ MN:B|∆ 2Infact,Parigotformulatestherenamingruleas[β](µγ.M)→M[β/γ];since[β](µγ.M)isnotaterm,wewritetherule differently. SteffenvanBakel 35 We can think of [α]M as storing the type of M amongst the alternative conclusions by giving it the nameα-thesetofGreekvariablesiscalledthesetofcontext variables(ornames). Asanexampleillustratingthefactthatthissystemismorepowerfulthanthesystemfortheλ-calculus, hereisaproofofPeirce’sLaw(duetoOngandSteward[28]): (Ax) x:(A→B)→A,y:A ⊢ y:A|α:A,β:B (⊥) x:(A→B)→A,y:A ⊢ [α]y:⊥|α:A (µ) x:(A→B)→A,y:A ⊢ µβ.[α]y:B|α:A (Ax) (→I) x:(A→B)→A ⊢ x:(A→B)→A|α:A x:(A→B)→A ⊢ λy.µβ.[α]y:A→B|α:A (→E) x:(A→B)→A ⊢ x(λy.µβ.[α]y):A|α:A (⊥) x:(A→B)→A ⊢ [α](x(λy.µβ.[α]y)):⊥|α:A (µ) x:(A→B)→A ⊢ µα.[α](x(λy.µβ.[α]y)):A| (→I) ⊢ λx.µα.[α](x(λy.µβ.[α]y)):((A→B)→A)→A| Noticethat⊥playsnopartinthisproof. Indeed,wecandefinethesetoftypeswithout⊥;theunderlying logicofsuchasystemthencorresponds tominimalclassical logic[1]. Since we allow ⊥ as a proper type, we can even express negation (of course, it is also implicitly present in the right-hand type environment), and can give a derivation for ¬¬A→A, so can express doublenegation elimination; soinλµwecanrepresent fullClassicalLogic. (Ax) x:A ⊢ x:A|α:A,δ:⊥ (µ) x:A ⊢ µδ.[α]x:⊥|α:A (Ax) (→I) y:(A→⊥)→⊥ ⊢ y:(A→⊥)→⊥| β:⊥ ⊢ λx.µδ.[α]x:A→⊥|α:A (→E) y:(A→⊥)→⊥ ⊢ y(λx.µδ.[α]x):⊥|α:A,β:⊥ (µ) y:(A→⊥)→⊥ ⊢ µα.[β]y(λx.µδ.[α]x):A| β:⊥ (→I) ⊢ λy.µα.[β]y(λx.µδ.[α]x):((A→⊥)→⊥)→A| β:⊥ Noticethatthistermisnotclosed, since βisfree,albeitoftype⊥. DeGroote[21]considers avariantof λµ whichseparates thenamingand µ-binding features3. This gives a considerable different system, that allows for ¬¬A→A to be inhabited via (the closed term) λy.µα.y(λx.[α]x). DeGroote’svariantofλµ [21]usesthesyntax M,N ::= x|λx.M| MN |µα.M|[β]M andsplitsrule(µ)into Γ ⊢ M:⊥|α:A,∆ Γ ⊢ M:A| β:A,∆ (µ): (⊥): Γ ⊢ µα.M:A|∆ Γ ⊢ [β]M:⊥| β:A,∆ 3NoticethatthenParigot’srenamingruleiscorrect. Wecouldhavepresentedourresultsforthismorepermissivesystem, butwouldhavehadtosacrificesoundnessandcompletenessfortherenamingrule. Noticethatwewouldstillhavesoundness andcompletenessforthetwocomputationalrules,whicharearguablythemostimportant. 36 SoundandCompleteTypingforλµ Inthissystemwecanderive (Ax) x:A ⊢ x:A|α:A (⊥) x:A ⊢ [α]x:⊥|α:A (Ax) (→I) y:(A→⊥)→⊥ ⊢ y:(A→⊥)→⊥| ⊢ λx.[α]x:A→⊥|α:A (→E) y:(A→⊥)→⊥ ⊢ y(λx.[α]x):⊥|α:A (µ) y:(A→⊥)→⊥ ⊢ µα.y(λx.[α]x):A| (→I) ⊢ λy.µα.y(λx.[α]x):((A→⊥)→⊥)→A| Forthemoment,wewilldealwithParigot’soriginalsystemonly;weaimtoextendourresultstode Groote’svariantinfuturework. 2 The Strict Intersection Type Assignment System for the λ-calculus Theremainder ofthis paper will be dedicated anotion of intersection/union typing on λµ. This willbe defined as a natural extension of the Strict Intersection System [2] for the λ-calculus. Before we come tothat,wewillbrieflysummarisethelatter. Definition2.1 (STRICT TYPES) 1. Let ϕrangeoveraninfinite,enumerablesetoftypevariables. The setT ofstricttypes,rangedoverby A,B,etcisdefinedthroughthegrammar: s A,B ::= ϕ|⊤→B|(A1∩···∩An)→B (n≥1) The set T of intersection types is defined as the union of {⊤} and the closure of T under inter- s section; wewill use A,B,etc for intersection types as well, and mention which set they belong to whennecessary. 2. A statement is an expression of the form M:A, with M∈Λ and A∈T. M is the subject and A thepredicate of M:A. 3. A type-environment Γ is apartial mapping from term variables to intersection types, and wewrite x:A∈ΓifΓ(x)= A. Soifwewriteatypeas A→B,then B∈T ,and A∈T . s In the notation of types, asusual, right-most outer-most parentheses in arrow types willbe omitted, andweassume ∩ tobindstronger than→. Fromhereon, wewillwritenfortheset{1,...,n}. Wewillconsiderapre-orderontypeswhichtakesintoaccounttheidem-potence, commutativityand associativity oftheintersection typeconstructor, anddefines ⊤tobethemaximalelement. Definition2.2 1. Therelation‘≤’isdefinedastheleastpre-order onT suchthat: A1∩···∩An ≤ Ai, foralli∈n,n≥1 B≤ Ai, foralli∈n ⇒ B≤ A1∩···∩An, n≥0 2. OnT ,therelation ‘∼’isdefinedby: A≤B≤A ⇒ A∼B A∼B&C∼D ⇐⇒ A→C∼B→D SteffenvanBakel 37 3. The relations ‘≤’ and ‘∼’, are extended to contexts by: Γ≤Γ′ if and only if for every x:A′∈Γ′ thereisan x:A∈Γsuchthat A≤ A′,and: Γ∼Γ′ ⇐⇒ Γ≤Γ′≤Γ. T will be considered modulo ∼; then ≤ becomes a partial order. It is easy to show that both (A∩B)∩C∼ A∩(B∩C)and A∩B∼B∩A,sothetypeconstructor ∩ isassociativeandcommutative, and we will write ∩nAi for A1∩···∩An, and consider ⊤ to be the empty intersection: ⊤ = ∩0Ai. Moreover, wewillassume,unlessstatedexplicitlyotherwise, thatin∩ A each A isstrict. n i i Definition2.3 The strict type assignment is defined by the following natural deduction system (where alltypesmentionedarestrict,withtheexception of Ainrule(→I)and(→E)): (∩E): Γ,x:∩nAi⊢x:Aj (n≥1,j∈n) (∩I): Γ⊢ΓM⊢:AMi:∩(∀Ai∈n) (n≥0) n i Γ,x:A⊢ M:B Γ⊢ M:A→B Γ⊢N:A (→I): (→E): Γ⊢λx.M:A→B Γ⊢MN:B WewillwriteΓ⊢ M:Aforstatementsthatarederivedusingtheserules. NoticethatΓ⊢ M:⊤forallΓ,Mbyrule(∩I). Properties ofthissystem havebeenstudiedin[2]. 3 Intersection and union type assignment for λµ Wewillnowdefineanotionoftypeassignment forλµ thatusesintersection anduniontypes. We see the context variables α as names for possible continuations that in the philosophy of inter- section types need not all be typed with the same type; we therefore allow multiple types for a context variable intheenvironment ∆,groupedusinganewtypeconstructor, whichwecallunion. Bindingacontextvariablethengeneratesacontextswitchµα.[β]M,whichnaturallyhasauniontype ∪ A ;reductionoftheterm(µα.[β]M)N willbringtheoperand N toeachofthepseudosubtermsin M n i oftheshape[α]Q(‘named’withα),whereQhastype A ;sinceNgetsplacedbehindQ,thisimpliesthat i A =C→B andthatthereforethetypeforαshouldbe∪ (C→B);thisthenalsoimpliesthatNshould i i i n i i have all the types C (∀i∈n); rule (→E) as below expresses exactly that. The only ‘functionality’ we i needforuniontypestherefore istheabilitytochoose acollection oftypesforαamongstthosestoredin ∆;thisisrepresented byrule(∪E). Definition3.1 (THE SYSTEM ⊢∩∪) 1. The set of strict types we consider for the intersection-union λµ typeassignmentis: A,B ::= ϕ|B1∪···∪Bm |(A1∩···∩An)→B (n,m≥0) As above, we call A1∩···∩An (with n ≥ 0) an intersection type, and call B1∪···∪Bm (with m≥0)auniontype;weuse⊤fortheemptyintersection type,and⊥fortheemptyuniontype. 2. Therelation ≤ofDefinition2.2isextended tointersection-union typesby: A1∩···∩An ≤ Ai, foralli∈n,n≥1 B≤Ai, foralli∈n ⇒ B≤ A1∩···∩An, n≥0 Bj ≤ B1∪···∪Bm, forall j∈m,m≥1 Bj≤A, forall j∈m ⇒ B1∪···∪Bm≤ A, m≥0 38 SoundandCompleteTypingforλµ OnT ,therelation ‘∼’isdefinedbythesamewayasinDefinition2.2. 3. A left environment Γ is a partial mapping from term variables to intersections of strict types, and wewrite x:A∈Γ if Γ(x)= A. Similarly, aright environment ∆ contains only strict types, which canbeuniontypes. 4. Therelations‘≤’and‘∼’,areextended toleftandrightenvironments by: Γ≤Γ′ ifandonlyiffor every x:A′∈Γ′ there isan x:A∈Γ such that A≤ A′,and Γ∼Γ′ ⇐⇒ Γ≤Γ′≤Γ,and ∆≤∆′ if foreveryα:A∈∆thereexists α:A′∈∆′ suchthat A≤ A′,and∆∼∆′ ⇐⇒ ∆≤∆′≤∆. Notice that we consider union types to be strict as well; this implies that we allow an intersection of uniontypes,aunionofuniontypes,butnotaunionofintersection types. Definition3.2 (THE SYSTEM ⊢∩∪) Intersection-union typeassignment forλµisdefinedvia: λµ Γ ⊢ M:A |∆ (∀i∈n) (∩E): Γ,x:∩nAi ⊢ x:Ai |∆ (∩I): Γ ⊢ Mi:∩ A |∆ (n≥0,n6=1) n i Γ,x:A ⊢ M:B|∆ Γ ⊢ M:∪ (A →B)|∆ Γ ⊢ N:A |∆(∀i∈n) (→I): (→E): n i i i (n≥1) Γ ⊢ λx.M:A→B|∆ Γ ⊢ MN:∪ B |∆ n i Γ ⊢ M:∪ B | β:∪ A,α:B,∆ Γ ⊢ M:∪ B | β:∪ A,∆ (∪E): Γ ⊢ µα.[βm]Mj :B| βn:∪i A,∆ (∪mBj≤∪nAi) Γ ⊢ µβ.[βm]Mj :∪ An |i∆ (∪mBj≤∪nAi) n i n i WewriteΓ ⊢∩∪ M:A|∆ifthisstatementisderivableusingtheserules. λµ Wewillnormallynotdistinguish betweenthetwovariants of(∪E). Noticethatthetraditional (→E)ofDefinition2.3isobtained bytaking n=1. Moreover, all A can i beintersectiontypes,soeachcanbe⊤;thisiswhythatruleisnotformulatedusingΓ ⊢∩∪ N:∩ A |∆. λµ n i If x:∪ B ∈Γ, then we can only derive Γ ⊢∩∪ x:∪ B |∆, i.e. we have no way of eliminating a union m j λµ m j assigned to a term variable. Moreover, we have no traditional rules (∪I) and (∪E) on terms, which wouldbeformulated (asin[9]),via Γ ⊢ M:A|∆ Γ ⊢ N:A∪B|∆ Γ,x:A ⊢ M:C|∆ Γ,x:B ⊢ M:C|∆ (∪I): (∪E): Γ ⊢ M:A∪B|∆ Γ ⊢ M[N/x]:C|∆ Thesecreatethesubject-reduction problem dealtwithinthatpaperbylimitingtoparallelreduction. Notice that both the strict system for the λ-calculus and the system for λµ are true subsystems; the firstbynotallowinguniontypes, oralternative conclusions, thesecondbylimitingtoCurrytypes. Lemma3.3 (GENERATIONLEMMA) • IfΓ ⊢∩∪ x:A|∆,thenthereexists x:B∈Γsuchthat B≤ A. λµ • If Γ ⊢∩∪ λx.M:A|∆, then there exists B,C (∀i∈n) such that A = ∩ (B→C), and, for all λµ i i n i i i∈n,Γ,x:B ⊢∩∪ M:C |∆. i λµ i • If Γ ⊢∩∪ MN:A|∆, then A = ∪ A, and for every i∈n there exists B ∈T such that Γ ⊢∩∪ λµ n i i λµ M:∪ (B→A )|∆andΓ ⊢∩∪ N:B |∆. n i i λµ i • If Γ ⊢∩∪ µα.[β]M:A|∆, then there are A (∀i∈n) such that A = ∩ A , and, for every i∈n, λµ i n i therearemi,m′i withm′i≤mi and Bij (∀j∈mi)suchthatΓ ⊢λ∩µ∪ M:∪m′iBki |β:∪miBij,α:Ai,∆. Proof. Byeasyinduction. SteffenvanBakel 39 The system ⊢∩∪ does not have choice, i.e. we cannot show that, if Γ ⊢∩∪ M:A∪B|∆, then either λµ λµ Γ ⊢∩∪ M:A|∆ofΓ ⊢∩∪ M:B|∆aswouldholdinanintuitionistic system. Take: λµ λµ (∩E) x:A ⊢ x:A| β:B,δ:A∪(A→B) (∪E) x:A ⊢ µβ.[δ]x:B|δ:A∪(A→B) (→R) ⊢ λx.µβ.[δ]x:A→B|δ:A∪(A→B) (∪E) ⊢ µδ.[δ](λx.µβ.[δ]x): A∪(A→B)| Notice that we cannot derive ⊢∩∪ µδ.[δ](λx.µβ.[δ]x) : A|, nor ⊢∩∪ µδ.[δ](λx.µβ.[δ]x) : A→B|, λµ λµ since the twooccurrences of [δ] need tobe typed differently, but withrelated types. Thisiscomparable toboth Aand A→Btobeneededasassumption for xtotypeλx.xx. Wecanshowthatageneral (∩E)(forallterms)isadmissible. Lemma3.4 IfΓ ⊢∩∪ M:∩ A |∆,thenΓ ⊢∩∪ M:A |∆,foralli∈n. λµ n i λµ i Proof. Easy. Thefollowingresultisstandard. Lemma3.5 (THINNING &WEAKENING) 1. Let Γ ⊢∩∪ M:A|∆; take Γ′ = {x:B∈Γ | x∈fv(M)} λµ and∆′ ={α:B∈∆|α∈fv(M)},thenΓ′ ⊢∩∪ M:A|∆′. λµ 2. LetΓ ⊢∩∪ M:A|∆,andΓ′≤Γand∆≤∆′,thenΓ′ ⊢∩∪ M:A|∆′. λµ λµ Proof. Byeasyinduction. Asaconsequence, thefollowingrulesareadmissible: Γ ⊢ M:A|∆ (T): {x:B∈Γ|x∈fv(M)} ⊢ M:A|{α:B∈∆|α∈fv(M)} Γ ⊢ M:A|∆ (W): (Γ′≤Γ,∆≤∆′) Γ′ ⊢ M:A|∆′ 4 Subject reduction and expansion Wewillnowshowourmainresults,byshowingthatournotionoftypeassignmentissoundandcomplete. Westartbyshowingtwovariantsofthesubstitution lemma. Lemma4.1 (TERMSUBSTITUTION LEMMA) Let A be strict; Γ ⊢∩∪ M[N/x]:A|∆ if and only if there λµ exists C∈T suchthatΓ,x:C ⊢∩∪ M:A|∆andΓ ⊢∩∪ N:C|∆. λµ λµ Proof. Byinduction on M. M≡x: ⇒: IfΓ ⊢∩∪ x[N/x]:A,thenΓ,x:A ⊢∩∪ x:AandΓ ⊢∩∪ N:A. λµ λµ λµ ⇐: If Γ ⊢∩∪ x:A|∆, then there exists A (∀i∈n) such that A = A from some k∈n, and λµ i k Γ=Γ′,x:∩ A ,soΓ′,x:∩ A ⊢∩∪ x:A |∆. FromΓ ⊢∩∪ N:∩ A |∆andLemma3.4,we n i n i λµ k λµ n i haveΓ ⊢∩∪ N:A|∆,soΓ ⊢∩∪ x[N/x]:A|∆. λµ λµ 40 SoundandCompleteTypingforλµ M≡y6=x: ⇒: ByLemma3.5,since y[N/x]≡y,and x6∈fv(y). ⇐: Γ ⊢∩∪ y[N/x]:A|∆⇒Γ ⊢∩∪ y:A|∆. TakeC=⊤;byLemma3.5,Γ,x:⊤ ⊢∩∪ y:A|∆. λµ λµ λµ M′ = M1M2 : Let A=∪rAj,withr≥1. Noticethat(M1M2)[N/x]= M1[N/x]M2[N/x]. ⇒: Then,byLemma3.3,thereareDj∈T (∀j∈r)suchthatΓ ⊢λ∩µ∪ M1[N/x]:∪r(Dj→Aj)|∆ and Γ ⊢λ∩µ∪ M2[N/x]:Dj |∆, for all j∈r. Thenby induction, there are C1,C21,...,C2r such that: • Γ,x:C1 ⊢λ∩µ∪ M1:∪r(Dj→Aj)|∆andΓ ⊢λ∩µ∪ N:C1|∆,aswellas • Γ,x:C2j ⊢λ∩µ∪ M2:Dj |∆andΓ ⊢λ∩µ∪ N:C2j |∆,forall j∈r. TakeC=C1∩C21∩···∩C2r;thenbyweakeningand(→E),wegetΓ,x:C ⊢λ∩µ∪ M1M2:A|∆; noticethat Γ ⊢∩∪ N:C|∆by(∩I). λµ ⇐: If Γ,x:C ⊢λ∩µ∪ M1M2:∪rAj |∆, then by Lemma 3.3 there exists Dj ∈T (j∈r) such that Γ,x:C ⊢λ∩µ∪ M1:∪r(Dj→Aj)|∆ and Γ,x:C ⊢λ∩µ∪ M2:Dj |∆, for j∈r. Then, by induction, Γ ⊢λ∩µ∪ M1[N/x]:∪r(Dj→Aj)|∆and Γ ⊢λ∩µ∪ M2[N/x]:Dj |∆forall j∈r;theresultfol- lowsby(→E). M≡λy.M′; M≡µα.[β]M′: Byinduction. Because of Lemma 3.4, we can extend the above results also to the case that A is an intersection type;noticethatthisisimplicitly usedinthethirdcase,where D canbeanintersection type. j Dually,wehave: Lemma4.2 (STRUCTURAL SUBSTITUTION LEMMA) Γ ⊢λ∩µ∪ M′[N·γ/α]:C|γ:∪nBi,∆ifandonlyifthere are A (∀i∈n) such that for every A there exists a B such that, for all i∈n, Γ ⊢∩∪ N:A |∆, and i i i λµ i Γ ⊢∩∪ M′:C|α:∪ (A →B),∆. λµ n i i Proof. Weonlyshowtheinteresting cases. M′ =x: Then x[N·γ/α]=x;asabovetheresultfollows,ineitherdirection, bythinning andweaken- ing. M′ =λx.M: Byinduction. M′ = M1M2 : Then M1M2[N·γ/α]= M1[N·γ/α] M2[N·γ/α];assumeCisstrict. ⇒: Let C = ∪ C , with r ≥ 1. Then, by Lemma 3.3, there exists D ∈T (∀j∈r) such that r j j Γ ⊢λ∩µ∪ M1[N·γ/α]:∪r(Dj→Cj)|γ:∪mBj,∆ and Γ ⊢λ∩µ∪ M2[N·γ/α]:Dj |γ:∪mBj,∆, for j∈r. Thenbyinduction, thereare A (∀i∈k)and A′ (∀i∈l)withk+l=msuchthat i i • Γ ⊢λ∩µ∪ M1:∪r(Dj→Cj)|α:∪k(Ai→Bi),∆ and, for all i∈k, Γ ⊢λ∩µ∪ N:Di |∆, as well as • Γ ⊢λ∩µ∪ M2:Dj |α:∪l(A′i→Bi),∆forall j∈r,and,foralli∈l,Γ ⊢λ∩µ∪ N:A′i |∆. Thenbyweakeningand(→E),wegetΓ ⊢λ∩µ∪ M1M2:∪rCj |α:∪k(Ai→Bi)∪∪l(A′i→Bi),∆; noticethat Γ ⊢∩∪ N:F|∆forall F∈{A (∀i∈k), A′ (∀i∈l)}. λµ i i ⇐: If Γ ⊢λ∩µ∪ M1M2:∪rCj |α:∪n(Ai→Bi),∆, then A = ∪nAi, and there are Dj ∈T (∀j∈r) such that Γ ⊢λ∩µ∪ M1:∪r(Dj→Cj)|α:∪n(Ai→Bi),∆ and Γ ⊢λ∩µ∪ M2:Dj |α:∪n(Ai→Bi),∆, for j ∈r. Then, by induction, Γ ⊢λ∩µ∪ M1[N·γ/α]:∪r(Dj→Cj)|γ:∪mBj,∆ and Γ ⊢λ∩µ∪ M2[N·γ/α]:Dj |γ:∪mBj,∆forall j∈r;theresultfollowsby(→E).

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.