aa r X i v : . [ c s . L O ] F e b SEQUENCE TYPES AND INFINITARY SEMANTICS
PIERRE VIALInria Paris-Saclay, France e-mail address : [email protected]
Abstract.
We introduce a new representation of non-idempotent intersectiontypes, using sequences (families indexed with natural numbers) instead of lists ormultisets. This allows scaling up intersection type theory to the infinitary λ -calculus.We thus characterize hereditary head normalization (Klop’s Problem) and wegive a unique type to all hereditary permutators (TLCA Problem Presentation
The results presented in this article lie at a meeting point between intersection type theory and an infinitary λ -calculus , which is closely related to Böhm trees (all the italicizedwords of this incipit will be explained below). This culminates in the type-theoretic characterization of two sets of terms: • The set of
Hereditary Head Normalizing (HHN) terms (Theorem 5), which arethe terms whose Böhm trees do not contain ⊥ : this gives a positive answer to Klop’sProblem . • The set of
Hereditary Permutators (HP) (Theorem 7), which are βη -invertibleterms. We actually characterize hereditary permutators with a unique type: this givesa positive answer to TLCA Problem .Tatsuta [34, 35] proved that these two problems do not have a solution in the finitecase, but we will come back to this. Interestingly, answering Klop’s Problem gives anew proof (a semantic one, as opposed to the existing syntactic ones) of certificationfor an asymptotic reduction strategy , which generalizes a standard by-product of finiteintersections type theories.The two characterizations above are obtained by resorting to intersection types that have the following three features: • They are infinitary : intersection of infinite families of types are allowed and intersec-tion can be infinitarily nested into another. This is necessary, since the two sets belowcannot be characterized with finite intersection types, as was proved by Tatsuta. • They are non-idempotent : the type-theoretic intersection ∧ does not satisfy theequality A ∧ A = A as the set-theoretic intersection does ( X ∩ X = X ). This featuresgreatly simplifies the combinatorics of proofs. In the finite case, the implication “ t is Key words and phrases: intersection types, infinitary lambda-calculus, coinduction, non-idempotentintersection, sequence types, Böhm trees, hereditary permutators.
Preprint submitted toLogical Methods in Computer Science © P. Vial CC (cid:13) Creative Commons
P. VIAL typable ⇒ t is normalizing” becomes trivial (no need for reducibility candidates or an ad hoc well-founded order). • They are rigid : this more technical point, related to the impossibility to use multisetto define a certain validity criterion , is briefly discussed in Sec. 2.6.This is not all: infinitary intersection types are required to characterize HHN and HPbut, on a more elementary level, finite intersection types bring information on infinitary reduction.A word should be said on intersection type theory: intersection types provide static characterizations of dynamic/semantic properties ( i.e. properties pertaining to reduc-tion, or invariant under reduction). By static, we just mean here that a term does notneed to be evaluated to be typed, nor a derivation to be checked. Since the halting prob-lem is undecidable in the λ -calculus (which is Turing complete), type-inference is oftenundecidable in presence of intersection types (but not always, e.g. , in [25]). But intersec-tion types often give as by-product elegant proofs of semantic equivalences ( e.g. , givena program t , between “there is a reduction path from t to a normal form” and “leftmost-outermost evaluation terminates on t ”). As we said above, one of the theoretical interestsof our approach is precisely that we extend methods pertaining to intersection-typing inthe λ -calculus to an infinitary calculus. Structure of the paper.
This article is organized as follows: in Sec. 2, we give high-level presentations of infinitary normalization and of the mechanisms of intersection typeswithout too much technical details. This first section only requires a basic knowledge ofthe simply typed finite λ -calculus. In Sec. 3, we formally recall the infinitary λ -calculusand the finitary non-idempotent intersection type system of Gardner-de Carvalho (sys-tem R ) which use multisets to represent intersection. Sec. 3.3 is partly informal: weexplain how we will be able to perform later in this article infinitary subject expansion(bring a typing backwards along an infinite sequence of reduction steps) and why thisactually cannot be done with multiset intersection. In Sec. 4, we formally define system S and sequence types. In Sec. 5, we study the one-step dynamics of system S : we defineresiduals and we prove a deterministic subject reduction property and the subject expan-sion property Approximability is defined in Sec. 6 and the infinitary subject reductionproperty and the normalization of typable terms are proved. Sec. 7 is devoted to typ-ing infinite normal forms and proving the infinitary subject expansion property. Thisconcludes the study of Klop’s Problem and of hereditary head normalization. In theshort Sec. 8, we use the previous contributions to characterize hereditary permutatorsin system S . In the last section (Sec. 9), we define an extension of system S , system S hp , that we prove to be sound and complete and to characterize hereditary permutatorswith a unique type. Reading guidelines. • The reader well acquainted with the infinitary calculus and intersection type theorymay start reading from Sec. 3.4 on, after a quick look on Sec. 2.7 and 2.8 in theintroduction. • The most important informal sections in this paper, which are helpful to understandthe technique, are Sec. 2.7, 2.8, 3.5 and 5.3. They may respectively help to understandtracking, approximability, how infinitary subject expansion may be achieved and thedeterministic dynamics of system S . Important intuitions about hereditary permuta-tors, which are defined in Sec. 3.2, are given in the very beginning of Sec. 8, 9 and 9.2.One also suggest having a good look at Fig. 3, 12 and 15.This articles contains two contributions: EQUENCE TYPES AND INFINITARY SEMANTICS 3 • Theorem 5: from Sec. 3.5 to Sec. 7, we solve Klop’s Problem: we give a type theoreticcharacterization of hereditary head normalization. For that, we start with introducingsequence types and we define system S . • Theorem 7: finally, in Sec. 8 and 9, we build an extension of system S , system S hp ,which characterizes with hereditary permutators with a unique type.2. Introduction
In this section, we give intuitions on the main notions of this article: the infinitary λ -calculus (Sec. 2.2), how intersection type systems work (Sec. 2.3 and 2.4), includingthe distinction between idempotency vs. non-idempotency. Klop’s Problem and TLCAProblem tracking and approximability are presentedin Sec. 2.7 and 2.8 . Takeaways.
In Sec. 2.1 and 2.2, the reader will be recalled: • The slight difference between the the termination of an evaluation strategy ( e.g. , thehead reduction strategy) on a term t and the existence of some reduction path of anunspecified shape from t to a normal form ( e.g. , a head normal form) • The notion of asymptotic convergence to an infinite normal form and the computationof Böhm trees.After reading Sec. 2.3 and 2.4, one should have an understanding of: • The way that a characterization property in a given intersection type system is usuallyproved (the circular proof scheme, Fig. 3). • How the use of an “empty” type allows partial typing. • Why intersection types allows certifying strategies. • The syntactic mechanisms of intersection, in particular, how the typing of all normalforms and subject expansion are achieved. • Non-idempotent intersection and non-duplication (linearity). • Strict intersection, relevance and syntax-direction.2.1.
Normalization and Reduction Strategies.
We start by fixing some notationsand recalling some basic notions: β -reduction is denoted → β and β -conversion (the leastcongruence containing → β ) is denoted ≡ β . The transitive closure of → β is → ∗ β and t → kβ t ′ means that there is a reduction path from t to t ′ containing exactly k steps. If t and u are terms and x is a variable, then t [ u/x ] is the capture-free substitution of x with u inthe term t . We set: ∆ = λx.x x Ω = ∆ ∆ I = λx.x ∆ f = λx.f ( x x ) Y f = ∆ f ∆ f Y = λf. Y f We have: ∆ u → β u u (for any u ) Ω → β Ω Y f → β f ( Y f ) Thus, ∆ is the “self-application” and Ω the “self–self-application”: Ω is the epitomy ofnon-terminating terms in functional programming. Moreover, Y f → β f ( Y f ) entails that,for any λ -term u , Y u ≡ β u ( Y u ) : the term Y is Curry fixpoint . A term of the form λx . . . x p .x t . . . t q where t , . . . , t q are terms, is called a Head Normal Form (HNF) .A β - or a full Normal Form (NF) is a term without any redex. P. VIAL
Evaluation strategies.
We consider the following restrictions of β -reduction: • The head reduction , denoted → h , consists in reducing the head redex ( λx.r ) s ofa head reducible term λx . . . x p . ( λx.r ) s t . . . t q (notice that any term that is not aHNF is head reducible). • The leftmost-outermost reduction , denoted → ℓ , consists in reducing the leftmost-outermost redex of a β -reducible term t , i.e. the one whose λx is the leftmost onein t (seen as string of characters).This leads us to consider some reduction strategies (without giving a general definitionof the notion, which can be found in the chapter 9 of [24]). For instance: • The head reduction strategy is the iteration of head reduction as long as a headnormal form is not reached. • The leftmost-outermost reduction strategy is the iteration of leftmost-outermostreduction as long as a β -normal form is not reached.When the head reduction strategy terminates on a term t (and thus, ends by outputtinga head normal form), this term t is said to be solvable .The hereditary head reduction strategy also aims at computing a β -normalform: for a given term t , it starts by applying the head reduction strategy on t until itstops (otherwise, it loops). In that case, the current term is of the form λx . . . x p .x t . . . t q .Then one applies the head reduction strategy on each head argument t , . . . , t q untilthey are all in head normal forms (if it does not loop for one of the t i ). Then one goeson with head reducing each new argument at constant applicative depth and so on. Thestrategy stops if a β -normal form is reached. Hereditary head reduction may be seenas a more balanced variant of leftmost-outermost reduction. Moreover, when hereditaryhead reduction strategy does not stop but keeps on reducing deeper and deeper, it maybe seen as asymptotically computing an infinite term (Sec. 2.2). Normalization.
In rewriting theory [24], normalization also describes other forms oftermination. The two important ones in this article are the following: • A λ -term t is Head Normalizing (HN) if there is a reduction path from t to a headnormal form. • A term λ -term t is Weakly Normalizing (WN) if there is a reduction path from t to a full normal form.Notice that head normalization seems to be more general/less constrained than solvabil-ity: head normalization pertains to the existence of a reduction path (to a head normalform) of an unspecified form whereas the head reduction strategy reduces terms in a deterministic way. Thus, if the head reduction strategy terminates on a term t , then t is clearly head normalizing. Likewise, if the leftmost-outermost strategy terminateson t , then t is weakly normalizing. Moreover, it is well-known of that the converse ofthese two implications is true, i.e. if a term t is head normalizing (resp. weakly normaliz-ing) then the head reduction strategy (resp. the leftmost-outermost reduction strategy)terminates on t . However, these two converse implications are non-trivial and involvestandardization, as we recall in the following paragraph. The Standardization Theorem and Reduction Strategies.
The standardizationtheorem, due to Curry and Feys [12], roughly states that if t → ∗ β t ′ , then there is areduction path from t to t ′ that never reduces on the left-hand side of a residual of aredex that has already been contracted (a proof may be found in chapter 11 of [2] orchapter 3 of the electronic version of [26]). The fact that the head reduction strategy EQUENCE TYPES AND INFINITARY SEMANTICS 5 is complete for head normalization is usually proved as a corollary of the standardiza-tion theorem (or a slightly weaker result known as pseudo-standardization). However,(pseudo-)standardization is quite non-trivial: one needs to prove that the confluence ofthe λ -calculus (Church-Rosser property), the finite developments theorem and then useinvolved arguments to prove that series of developments can be commuted.Besides, it is easy to prove the equivalence between the assertions “the head reduc-tion strategy is complete for head normalization” and “the leftmost-outermost reductionstrategy is complete for weak normalization”, but it requires the Church-Rosser property.Yet, as we will see in Sec. 2.2, the infinitary λ -calculus only satisfies a weak (but not lessdifficult) form of confluence. ✬✫ ✩✪ Variable xx Abstraction λx.uu λx Application u v v u @ Figure 1.
Lambda Terms as Labelled Trees2.2.
Infinitary Normalization and Böhm Trees.
Lambda terms can be seen aslabelled trees following the pattern of Fig. 1. We orient these labelled trees as typingderivation usually are: the root is put at the bottom of the figure (and not at the top),because the derivations of the type systems to come can be represented is as refinementsof parsing trees of λ -terms (see in particular Fig. 11 on p. 29). We say that u is the argument of the application t u . This representation gives to the standard notions of position in a λ -term, represented as words on { , , } (the set of words on { , , } is denoted { , , } ∗ ), and support supp ( t ) of a term t (the set of positions in t ). If b ∈ supp ( t ) , then t ( b ) is the label at position b in t and t | b is the subterm rooted at b .For instance, if t = λx.x y , then supp ( t ) = { ε, , · , · } where ε is the empty word, t ( ε ) = λx , t (0) = @ , t (0 ·
1) = x , t (0 ·
2) = y and t | = x y . The applicative depth of a position b in a term t is the number of times that b is nested inside the argumentsof an application. For instance, if u u u u are terms and t = λx. (( y u )(( y u ) u )) u , b = 0 · · , b = 0 · · · · , b = 0 · · , b = 0 · , then t | b i = u i and ad ( b ) = ad ( b ) = 1 , ad ( b ) = ad ( b ) = 2 . In other words, if b = b · b . . . · b n (with b i integer), then ad ( b ) = { i ∈ { , . . . , n } | b i = 2 } , i.e. ad ( b ) is the number of 2 that b contains.Trees help understand how the infinitary λ -calculus arises: Y f reduces in n stepsinto f ( f ( . . . ( f ( Y f ) . . . ) =: f n ( Y f ) , which is actually the only way to reduce Y f . After n steps, for any value of n , the obtained reduct f n ( Y f ) still contains a redex Y f , so that Y f is not weakly normalizing. But the redex of f n ( Y f ) occurs at applicative depth n ,as shown in Fig. 2. Moreover, below applicative depth n , the term cannot be affectedby reduction: all the positions whose applicative depth is less than n are in a normalprefixing subtree of f n ( Y f ) . So Y f is not normalizing, but intuitively, after an infinite number of reduction steps, the redex Y f disappears and f n ( Y f ) “converges” toward an infinite term, that we call f ω , whose tree could be the obtained by repeating infinitelymany times the pattern of the tree on the right-hand side of Fig. 2. The term f ω can bewritten f ( f ( . . . )) and we notice that f ω = f ( f ω ) (whereas Y f ≡ β f ( Y f ) ). Intuitively, f ω does not contain any redex and may be thus considered as the infinite normal form of P. VIAL the term Y f . Thus, Y f is not weakly normalizing in the usual sense, but it is infinitarilyweakly normalizing . ✬✫ ✩✪ Y f @ f Y f @ f @ f Y f @ f @ f @ f Y f @ f @ f @ f @ f Y f −→ β f ( Y f ) −→ β f ( Y f ) −→ β f ( Y f ) −→ ∗ β f n ( Y f ) Figure 2.
Reducing Y f Böhm Trees and Klop’s Problem.
This notion of infinite normal forms is refinedinto Böhm trees (Chapter 10 of [2], in particular, Theorem 10.4.2.), a notion that wassuggested by the proof of the Böhm Separation Theorem. The Böhm tree of a λ -termcorresponds to the whole evaluation of this term. Böhm trees provide a natural semanticsfor the λ -calculus, meaning that if t ≡ β u , then BT ( t ) = BT ( u ) , where BT ( t ) denotes theBöhm tree of t . They are deeply involved in the study of observational equivalence(read [29] for a survey).The Böhm tree of a term is its (possibly infinite) normal form, in which everyargument of variable that is not head normalizing is replaced by the special constantsymbol ⊥ (indicating a meaningless computation), e.g. , BT ( t ) = ⊥ if t is not HN, and BT ( x Ω y ) = x ⊥ y because the subterm Ω is not head normalizing. Moreover, BT ( Y f ) = f ω holds in a formal sense, as expected. Observe that replacing any unsolvable term t with ⊥ implicitly relies on an undecidable oracle, since solvability is semi-decidable.The set of Hereditary Head Normalizing (HHN) terms is defined as the set ofterms t such that BT ( t ) does not contain the symbol ⊥ , whether BT ( t ) is infinite or not.For instance, Y f is HHN. Characterizing HHN is Klop’s Problem (Sec. 2.5). Confluence in the infinitary λ -calculus. The infinitary λ -calculus is not confluent,for instance, t := ( λx.I ( x x ))( λx.I ( x x )) → β Ω , which only reduces to itself. Moreover, t → h I t → β I ( I t ) → h I ( I ( I t )) . . . , so that t asymptotically reduces to I ω := I ( I ( I . . . )) ,which also only reduces to itself. Thus, the two reducts Ω and I ω of t do not have acommon reduct.However, the infinitary λ -calculus satisfies a weak form of confluence: in the exampleabove, observe that t , Ω and I ω are not head normalizing. Intuitively, they are mean-ingless terms and in the Böhm trees formalism, they would be replaced by the constant ⊥ . This is how confluence is retrieved: the infinitary λ -calculus has the Church-Rosserproperty up to the identification of any pair of unsolvable subterm. This is weaker thantrue confluence, but the proof of this fact is actually quite involved and spans on dozenof pages [1, 22, 23]. contrary to the confluence of the finite λ -calculus. Remark 1 (Variants of the infinitary λ -calculus) . The infinitary λ -calculus has actuallyseven main variants, which were introduced by Klop and its collaborators [23]. Among EQUENCE TYPES AND INFINITARY SEMANTICS 7 those, only three behave well, i.e. satisfy the weak form of confluence mentioned above.The infinitary calculus that is considered here is one of these 3 calculi, which is referredto as Λ and as we have seen, its normal forms are the Böhm trees (without ⊥ ).The two other well-behaved infinitary calculi are Λ and Λ and their normal formsrespectively correspond to the Berarducci trees [4, 5] and the Lévy-Longo trees [27, 28].2.3. Intersection Types.
Normalization (termination) is a dynamic property: it per-tains to the reduction of λ -terms, i.e. their evaluation . For instance, proving that a term t is head normalizing consists (in principle) in giving a sequence of β -reduction stepsstarting at t and ending with a head normal form.On another hand, typing is static in the following sense: in a given type system,let t be a term, finding a derivation typing t or checking that a given tree of typingjudgments is a correct derivation is done without having to perform reduction stepsbut just by considering the structure of terms and verifying that the typing rules arecorrectly applied.Type systems usually ensure normalization, e.g. , if a term t is typable in Girard’ssystem F, then it is strongly normalizing [19, 21] ( i.e. no infinite reduction path startsat t ). Thus, type systems provide static proofs of dynamic properties. In other words,when we have managed to type a program t , we do not need to execute t to know that t isterminating, which is one of the main interests of typing. However, in most type systems, e.g. , in polymorphic or dependent ones, typability is a sufficient condition for normal-ization but not a necessary one: many normalizing terms are not typable. For instance, ∆ = λx.x x is not typable in the simply typed λ -calculus, and ( λz.λy.y ( z I )( z K ))( λx.x x ) ,although strongly normalizing, is not typable in system F.Intersection type systems, introduced by Coppo and Dezani around 1980 [3,10,11,30],were designed to provide characterization of normalization properties (head, weak, weakhead, strong. . . ): in an intersection type system, typability is usually equivalent with(a notion of) normalization. Since the λ -calculus is Turing-complete, this makes typeinference undecidable in most intersection type systems. As an exception to this rule,intersection types were famously used by Kobayashi and Ong [25] to prove that MonadicSecond Order logic is decidable for higher-order recursion schemes. Mechanisms of intersection type theory.
Intersection type systems usually give in-teresting properties pertaining to reduction strategies. To illustrate this, let us imaginefor a moment that we have an intersection type system H characterizing head normal-ization, i.e. that satisfies the following theorem (let us call it T HN ):“ Theorem T HN : for every λ -term t , t is is typable in system H iff t is head normalizing ”In practice, this characterization theorem is proved in two steps: ⇒ A proof of “If t is H -typable (typable in system H ), then the head reduction strategy terminates on t ”. ⇐ A proof of “If there is a reduction path from t to a HNF, then t is H -typable”.Observe that for ⇒ , we actually prove that a typable t is terminating for the headreduction strategy, which is a priori stronger than just the fact that t is head normalizing,as we saw in Sec. 2.1. Since the termination of head reduction obviously ensures headnormalization, the implication ⇐ gives us theorem T HN but also the following, non-trivialstatement: “A term t is head normalizingiff it is termination for the head reduction strategy.” P. VIAL ✬✫ ✩✪
Some reduction strategynormalizes t e.g., the head red. strat.terminates on t t can reach a terminalstate e.g., ∃ red. path to a HNF ( H ead N ormalization) t is typable Figure 3.
Characterizing a notion of normalization with intersectiontypesA remarkable aspect of this equivalence is that it is not type-theoretic: it states that acertain reduction strategy is complete for a certain notion of normalization. But it wasproved using types instead of syntactic techniques. The structure of this kind of proofis summarized in Fig. 3.
Subject reduction and expansion.
Now, let us explain more precisely how the im-plication ⇒ and ⇐ above are usually obtained. ⇒ Typability implies normalization: – One proves subject reduction , meaning that typing is preserved under reduction(if t → β t ′ and Γ ⊢ t : B , then Γ ⊢ t ′ : B ). – Using subject reduction and an additional argument (the nature and the difficultyof this additional argument is discussed below), one proves that some reductionstrategy normalizes any typable term. ⇐ Proving that normalization implies typability is usually easier and relies on two ar-guments: – One proves subject expansion , meaning that typing is preserved under anti-reduction (if t → β t ′ and Γ ⊢ t ′ : B , then Γ ⊢ t : B ). – One types the terminal states (in our example, head normal forms). Only an induc-tion on the structure of these terminal states is needed (see Sec. 2.4). As we willsee, this will be more or less true for infinite normal forms as well.This brings up several remarks: • Typability implies normalization uses subject reduction along with an additional ar-gument: this argument varies in nature depending on the type system. – In the simply typed λ -calculus, this is based upon the decrease of a suitable well-founded measure, usually a multiset containing the size of some types of the sub-terms in the subject of the derivation. This corresponds more or less to Gentzen’sproof of cut-elimination [18]. – In polymorphic type systems, one needs to use the reducibility candidates technique,due to Tait [33] and extended by Girard to system F. This method sometimesrequires dozens of pages. – In idempotent intersection type system, one can use the reducibility technique oran argument à la Gentzen [36]. – Very interestingly, non-idempotent intersection types provide the simplest possi-ble proofs of normalization, because, in a such a system, duplication of types is In the inductive case. When considering infinite reduction paths, we will see that it is the maindifficulty, cf.
Sec. 3.5
EQUENCE TYPES AND INFINITARY SEMANTICS 9 disallowed and derivations “decrease” at each reduction step,. As a consequence,reduction on typed terms must stop at some point. • Subject expansion does not hold in a type system without intersection: in particular,it is not satisfied in usual polymorphic or dependent type systems.
Remark 2.
The proof scheme of Fig. 3 applies to other notions of normalization (weak,weak head) but not to strong normalization, for which it needs to be adapted. Indeed,strong normalization is not preserved under anti-reduction, e.g. , t ′ := y is stronglynormalizing, t := ( λx.y )Ω → β t ′ but t is not strongly normalizing. The subject expansionproperty for intersection type systems characterizing strong normalization usually holdsin a restricted form.2.4. Intersection from the syntax perspective.
Intersection types extend the syn-tax of the simply typed λ -calculus by resorting to a new type constructor ∧ (intersection).Naively, intersection would represent the set-theoretic intersection. Thus, t : A ∧ B isderivable when t : A and t : B are derivable. For instance, since I : A → A and I : ( A → B ) → ( A → B ) are derivable, one has: I : A → A I : ( A → B ) → ( A → B ) I : ( A → A ) ∧ ( A → B ) → ( A → B ) ∧ -intro In turn, ∧ can be eliminated in the obvious way: if t : A ∧ B , we may assert t : A as well as t : B . Note that intersection type systems also allow assigning several typesto a variable in a context, e.g. , if x is assigned A ∧ ( B → C ) in a context, then x maybe used both as a term of type A and as a term of type B → C .Intuitively, intersection provides a finite form of polymorphism, e.g. , the type ( A → A ) ∧ ( A → B ) → ( A → B ) can be thought as a double instance of the polymorphictype ∀ X.X → X (with X = A and X = A → B ). However, intersection is alsoless constrained than usual polymorphism à la system F. For instance, the assignment x : o ∧ ( o ′ → o ) ∧ ( o → o → o ′ ) (with o and o ′ two distinct type variables) is sound,although the only polymorphic type that instantiates into o , ( o ′ → o ) and ( o → o → o ′ ) is ∀ X.X , i.e. the type representing falsehood in system F.The unconstrained nature of ∧ may give us intuitions on why normalization impliestypability in an intersection type system: • All normal forms can be typed.
A simple structural induction allows typing everynormal form. Indeed, let t = λx . . . x p .x t . . . t q be a normal form (so that t , . . . , t q are also normal forms). The, we can explain why a simple structural induction showsthat t is typable: assume that t , . . . , t q are respectively typed with types A , . . . , A q (induction hypothesis), then we type t by assigning to the head variable of t a suitablearrow type as follows: ax x : A → . . . → A q → B t : A app x t : A → . . . → A q → B t : A app ∗ x t . . . t q − : A q → B t q : A q app x t . . . t q : B abs ∗ λx . . . x p .x t . . . t q : C → . . . → C p → B The star ∗ indicates several ( > ) rules. For instance, let t = ( x ( x y )) ( x I ) . Necessar-ily, I has a type of the form B → B . We can then type t as follows: x : C → C → C x : A → C y : Ax y : C x ( x y ) : C → C x : ( B → B ) → C ... I : B → Bx I : C ( x ( x y )) ( x I ) : C Note we have assigned to x the 3 types A → C (to type x y ), ( B → B ) → C (totype x I ) and C → C → C (to type the whole term). • Subject expansion holds.
Consider ∆ I → β I I → β I and say that the rightmostoccurrence of I has been typed with A → A in the usual way. Then one can also type I I with A → A in the simply typed λ -calculus by typing the occurrence of I on theleft-hand side of the application with ( A → A ) → ( A → A ) . I : ( A → A ) → ( A → A ) I : A → A I I : A → A app However, the term ( λx.x x ) I is not typable because x should be assigned both thetypes A → A and A in x x , which is impossible and makes subject expansion fail inthe simply typed λ -calculus. In contrast, with the intersection operator, we can doso: x x is typed with A in the context x : ( A → A ) ∧ A , so that ∆ can be typed with (( A → A ) ∧ A ) → A . x : ( A → A ) → ( A → A ) x : A → Ax x : A → Aλx.x x : ((( A → A ) → ( A → A )) ∧ ( A → A )) → ( A → A ) I : ( A → A ) → ( A → A ) I : A → A ( λx.x x ) I : A → A In general, since intersection type systems allow assigning several types, a variable x (bound in a redex) can be used as a (typed) placeholder for the occurrences of asame term u , even if u occurs with different types. This explains why intersectiontypes can satisfy subject expansion. Partial typings.
Many intersection type systems also feature a universal type U whichcan be assigned to every term, so that a judgment of the form t : U is meaningless. How-ever, such a meaningless U allows partially typing a term. Actually, every, every headnormal form becomes typable: if one assigns U → . . . → U → A (with n arrows) andtypes the t i with U , then x t . . . t q has type A ). The possibility to leave some argumentsuntyped is crucial for type systems to remain sound while ensuring semantic guaranteesare less restrictive than strong normalization ( e.g. , head or weak normalization). Whenconsidering such a universal type U , every term becomes typable and thus, typed judg-ments should be considered sound only when U does not have ill-placed occurrences,called positive occurrences (technically, an occurrence is positive when it is nested in aneven number of arrow domains). Non-idempotent intersection.
Non-idempotent intersection type systems were inde-pendently introduced by Gardner [17] and de Carvalho in his PhD [9, 14]. They havebeen since extensively studied (read [8] for a survey). In this setting, the intersectionoperator is not idempotent, i.e. the types A and A ∧ A are not equivalent anymore.This expresses the fact that, from the quantitative point of view, using the type A once EQUENCE TYPES AND INFINITARY SEMANTICS 11 ✬✫ ✩✪ ax x : A ax x : A ax x : A . . . , x : A ∧ A ∧ A ⊢ r : B . . . ⊢ λx.r : A ∧ A ∧ A → B Π a s : A Π s : A Π b s : A ( λx.r ) s : B Non-idempotently typed redex Π a s : A Π s : A Π b s : A r [ s/x ] : B Derivation reduct Non-idempotency : • x : A ∧ A ∧ A ; in r , x has been typed twice with A and once with A • In the redex, 3 arg. derivations because x typed 3 times • During reduction, duplication is disallowed for types(no arg. derivation typing is duplicated) • After reduction, the derivation has decreased in size(1 app , 1 abs and 3 ax -rules destroyed) Figure 4.
Non-Idempotent Typing, Reduction and Decreaseor twice is not the same. Thus, non-idempotent intersection is closely related to Gi-rard’s Linear Logic [20]. From the dynamic perspective, non-idempotency forbids theduplication of typing certificates during reduction: • In a usual type system (system F, CIC, idempotent intersection type) satisfying subjectreduction, if the derivation Π types ( λx.r ) s is typed and Π s is the subderivation of Π typing s , then the derivation Π ′ typing r [ s/x ] contains n copies of Π s , where n is thenumber of typed axiom rules typing x in r (this description is a bit too simple in thecase of idempotent intersection types). This may cause a phenomenon of size explosion,which is the main reason why normalization proofs are difficult (see Sec. 2.3). • In a non-idempotent intersection type system, no such duplication may occur. Con-sequently, the argument s must be typed sufficiently many times in Π so that noduplication is needed and each axiom rule typing x is replaced by a pairwise distinctsubderivation typing s . For instance, if x has 3 typed occurrences of type A in Π , thenthere are also in Π s with A . Intuitively, this makes deriva-tions big with a lot of redundant parts, but on another hand, the lack of duplicationcauses the derivations to grow smaller and smaller along a reduction sequence (no sizeexplosion). Consequently, reduction of a typed term must stop at some point, i.e. anormal form is reached. This strongly suggests indeed that the termination of typedterms is usually very easy to to prove in non-idempotent frameworks.Concretely, the decrease of derivation under reduction corresponds to weightedsubject reduction properties, e.g. , if t → β t ′ is a head step and Γ ⊢ t : B is derivable,then Γ ⊢ t ′ : B is derivable using strictly less judgments. Since there is no sequence ofnatural numbers of infinite length, then head reduction must stops when it is applied on a term which is typable in a non-idempotent system. The weighted aspect of proofreduction is illustrated in Fig. 4: a redex ( λx.r ) s is typed. There are three axiom rulestyping the variable x of the redex, assigning twice type A and once type A . Thismeans that, in the environment of r , x is assigned the type A ∧ A ∧ A , whereas in an idempotent setting , the type of x would have been collapsed with A ∧ A and intuitively,the information giving the number of axiom rules typing x would have been lost. Thus, λx.r has an arrow type with 3 types in its domain. Also because of non-idempotency,the argument s must be typed three times, with matching types. When we fire the redex,no duplication of an argument derivation needs to take place, since s has been typedthe right number of times. We thus obtain a smaller derivation typing the reduct r [ s/x ] :the application and the abstraction rules of the redex have been destroyed, as well asthe axioms typing x . Additional properties.
Actually, the simplicity of normalization proof is not the onlygood feature of non-idempotent intersection, which explains that it is also interestingin an infinite setting (where the well-foundedness of N cannot be used in all generality).It turns out that non-idempotent intersection types also enable simple combinatorialfeatures, that we will thoroughly use: • Strictness.
Intersection is allowed only on the left-hand side of arrows, for instance ( A ∧ B ) → C is allowed whereas A → ( B ∧ C ) is not. We then do not considerintroduction and elimination rules for ∧ , as the ones below. See Sec. 3.2.1 of [39] formore details. Γ ⊢ t : A Γ ⊢ t : B intro Γ ⊢ t : A ∧ B Γ ⊢ t : A ∧ B elim − l Γ ⊢ t : A Γ ⊢ t : A ∧ B elim − r Γ ⊢ t : B • Syntax-direction.
To simplify the type system even more, non-idempotent intersec-tion may be represented with multisets, e.g. , the multiset [ A, B, A ] may represent theintersection A ∧ B ∧ A . This allows avoiding using a permutation rule stating thatthe types A ∧ B ∧ A and A ∧ A ∧ B are equivalent (as the one shown below), because [ A, B, A ] = [
A, A, B ] . Γ , x : A ∧ . . . ∧ A n ⊢ t : B σ permutation perm Γ , x : A σ (1) ∧ . . . ∧ A σ ( n ) ⊢ t : B Note that, without introduction and elimination rules for ∧ , such a permutation rulewould be necessary to make A ∧ B and B ∧ A equivalent. • Relevance.
By taking into account an exact record of how many times each type isassigned, non-idempotent intersection enable relevant type systems, i.e. type systemwithout weakening (actually, strict idempotent intersection type systems cannot satisfyboth subject reduction an expansion, see e.g. , Sec. 3.2.2 of [39] for more details). Ina relevant type system, axiom rules have conclusions of the form x : A ⊢ x : A (andnot for instance x : A ∧ B ⊢ x : A or x : A ∧ B ∧ C, y : D ⊢ x : A ), with one assignment on the left-hand side. That is, an axiom rule typing an occurrence of x just assigns one type to this occurrence and nothing more. In particular, the typingcontext of an axiom rule can be identified by just looking at its left-hand side. Byinduction, in a relevant setting, typing contexts by inspecting axiom rules above themand thus, do not need to be mentioned in derivations, because they can be computedby inspecting axiom rules (see Remark 3). However, it is more convenient to indicatethem to write derivations. From the dynamic point of view, in a relevant derivation,reduction does not cause erasure of types, and in particular, erasable subterms arealways left untyped. EQUENCE TYPES AND INFINITARY SEMANTICS 13
With strictness and relevance, proof reduction boils down to moving parts of the deriva-tions, without duplication and erasure and without structural rules popping up in theprocess (elimination,introduction, permutation). This gives rise to syntax-directed systems, which feature only 3 rules (one for variables, one for abstractions and one forapplications): such a system is given in Sec. 3.3.2.5.
Klop’s Problem and Hereditary Permutators.
The semantic characteriza-tions of various normalization properties led Klop and Dezani to formulate the followingquestion: can the set of hereditary head normalizing terms ( i.e. the terms whose Böhmtree does not contain ⊥ ) be characterized by means of an intersection type system?Klop’s Problem [34] is answering this question.Another characterization problem arises in the study of the βη -invertible λ -terms,pioneered by Curry and Feys [12] and consolidated by Dezani [15] who gave a charac-terization of weakly normalizing invertible terms w.r.t. their normal forms. This cha-racterization was extended by Bergstra and Klop [6] for any term: βη -invertible termswere proved to have Böhm trees of a certain form, generalizing that given by Curry andFeys and suggesting to name them hereditary permutators . Indeed, given a variable x , t is a x -hereditary permutator iff coinductively , t reduces to λx . . . x n .x h σ (1) . . . h σ ( n ) where h i is a x i -hereditary permutator and σ is a permutation of { , . . . , n } (the fulldefinition is given in Sec. 3.1). Hereditary permutators lacked a characterization withintersection types, so that the problem of finding a type system assigning a unique typeto all hereditary permutators (and only to them) was inscribed in TLCA list of openproblems by Dezani in 2006 (Problem Tatsuta’s Argument.
Tatsuta [34, 35] proved in 2008 that the answer to these twoquestions is negative in the inductive case by: • making the observation that, in an inductive type system, the set of typable terms isrecursively enumerable. • proving that the set of hereditary head normalizing terms and that of hereditarypermutator are not recursively enumerable.This leaves the question open as to whether an infinitary/coinductive type system is ableto characterize hereditary head normalization. The first contribution presented here isproving that Klop’s Problem has a positive answer with a suitable coinductive typesystem. This contribution was presented in [38] with some proof sketches. The secondcontribution is giving a positive answer to TLCA Problem Tools and Difficulties.
Before concluding this introduction, we give a glimpseon the key concepts, sequence types and approximability, which allow us to prove thecontributions presented here.To solve Klop’s Question and characterize hereditary permutators, we will use aquantitative, resource-aware type system, which is inspired by system R of Gardnerand de Carvalho [9, 14, 17] presented in Sec. 3.3. In the simplest form of this system,intersection is represented with multisets, as explained at the end of Sec. 2.4. Of course,the simple termination argument based on the well-foundedness of N (which we alludedto in Sec. 2.3 and 2.4) cannot be straightforwardly adapted in an infinitary framework.However, quantitative type derivations do have very simple and readable combinatorialfeatures, e.g. , reduction inside a derivation almost boils down to moving parts of theinitial derivation (see Fig. 13 and discussion in Sec. 5.4). Actually, it turns out that a direct coinductive adaptation of R with infinite mul-tisets cannot work for two major reasons : • It would lead to the possibility of typing some unsolvable terms , like Ω . That is whya validity criterion is needed to discard irrelevant derivations, as in other infinitaryframeworks [32]. This validity criterion relies on the idea of approximability , whichwe informally develop in Sec. 3.5, 3.6 and formally define in Sec. 6.2 and 9.2. • Moreover, as it turns out, multisets are not fit to formally express such a notion ofposition, meaning for instance that we cannot distinguish the two occurrences of σ in [ σ, τ, σ ] . This motivates the need for rigid constructions: multisets are then (coinduc-tively) replaced by sequences , i.e. families indexed by (non necessarily consecutive)natural numbers called tracks . We explain all this in Sec. 2.7 below.This leads us to define a type system that we call system S , in which intersection isrepresented by sequences of types (intersection is said to be sequential). Tracks, whichact as identifiers , constitute the main feature of system S presented here. With thosepointers, any type can be tracked through the rules of a whole typing derivation. Ourframework is deterministic, e.g. , there is a unique canonical way to produce a derivationfrom another one when reducing a redex, contrary to system R , and we can characterizeinfinitary semantics (more details in Sec. 5.4).2.7. Sequence and tracking.
Naive multisets do not allow defining a notion of po-sition: we say that they do not allow tracking . To see this, consider the equality [ A, B, A ] = [
A, B ] + [ A ] . There is no way to associate the occurrence of A in [ A ] , locatedin the right-hand side of the equality to one of the two occurrences of A in [ A, B, A ] , inthe left-hand side. This shows that there is not way to point to a particular occurrenceof A inside [ A, B, A ] . Actually, if we swap the two occurrences of A in [ A, B, A ] , weobtain [ A, B, A ] . If we do not do anything, we also obtain [ A, B, A ] : the possible swapcannot be seen. It has actually no formal meaning.To retrieve tracking and thus, the possibility to point at an element, we may anno-tate elements of multisets with pairwise distinct integers, that we call tracks . Such adecorated multiset is called a sequence and we use the constructor ( _ ) for sequencesinstead of [ _ ] for multisets. For instance, (2 · A, · B, · A ) is a sequence, there is oneoccurrence of A on track ⊎ , e.g. , (2 · A, · B, · A ) = (2 · A, · B ) ⊎ (5 · A ) . Thanks totracks, each occurrence of A in one side of the equality are unambiguously associatedwith another on the other side, and in the left-hand side, we may point to the occurrenceof A on track 2 rather than the one on track 5. Disjoint union is not defined for twosequences sharing a same track, e.g. , (2 · A, · B ) ⊎ (3 · B, · A ) is not defined (becausethe two operands both use track 3, even though the same type B occurs): we say thatthere is a track conflict . Moreover, ⊎ is a commutative and associative, but par-tial operator. Observe that (2 · A, · B, · A ) may be written six different ways, e.g. , (5 · A, · A, · B ) and (2 · A, · A, · B ) : if we perform a swap in a sequence, we will seeit. To sum up, in many ways, sequence types work like multiset types, e.g. , they giverise to a syntax-directed, strict and relevant typing system with only three rules ( cf. Sec. 2.4), but they allow tracking, constructing a suitable pointing mechanism insidederivations and thus, defining approximability, the validity criterion that will help usdiscard the unsound coinductive derivations. This will enable us characterizing infinitaryweak normalization and hereditary permutators. Actually, R , we proved that the coinductive version of R types every terms [40] EQUENCE TYPES AND INFINITARY SEMANTICS 15
Approximability.
As we have hinted at before, coinductive type grammar giverise to unsound derivations, e.g. , derivations typing of Ω , but we introduce a validitycriterion allowing to discard them. This criterion is called approximability . Intuitively,an infinite proof/typing derivation is approximable when it is obtained by superposinginfinitely many finite proofs, growing over and over, as in Fig. 5: the outer trianglerepresents an infinite proof/typing derivation Π and the inner polygons represent finiteproofs that “fit” in Π . The idea is that we know that finite proof systems are semanticallysound, so that an approximable derivation may be infinite, but it is asymptoticallyobtained from finite/sound proofs. Equivalently, a derivation is approximable when it isthe join of its finite truncations , also called approximations . ✬✫ ✩✪ Figure 5.
An Approximable Derivation as an Infinite SuperpositionInterestingly, derivations need not to be infinite to characterize head normalization inthe infinite calculus: infinite derivations are required to characterize weak normalizationin the infinite calculus, if only to have derivation that type infinite normal forms t without leaving any subterm of t untyped. Moreover, finite derivations allows us toprove operational properties of the infinite calculus in a simpler way that the usualsyntactic methods (more details in Sec. 3.4).Just to give a more precise idea of what is meant by superposition, the derivation Π below can be superposed upon Π (as before, we omit the typing assumptions andthe possible premises of the top judgments): Π = f : ( A ∧ B ) → A → C x : A x : B f ( x ) : A → C Π = f : ( A ∧ B ∧ ( B → C )) → ( A ∧ C ) → D x : A x : B x : B → D f ( x ) : ( A ∧ C ) → C Indeed, Π is obtained from Π by removing the symbols colored in red: Π = f : ( A ∧ B ∧ ( B → C )) → ( A ∧ C ) → D x : A x : B x : B → D f ( x ) : ( A ∧ C ) → C Thus, Π can be seen as a truncation or an approximation of Π . Infinite superpositionstrongly hints at the presence of complete lattices and complete partial orders, which isformalized in Sec. 6.With this concept of approximation, we retrieve, in an infinitary setting, the maintools of finite intersection type theory that we sketched in Sec. 2.3: subject reduction,subject expansion, typing of normal forms (terminal states). Actually, following the scheme of Fig. 3, we will prove that hereditary head reduction (Sec. 2.1) is asymptotically complete for infinitary weak normalization.3. Finite Intersection and Infinite Terms
In Sec. 3.1 and 3.2, we define the infinitary λ -calculus and Böhm trees. Gardner-deCarvalho’s system R are recalled in Sec. 3.3, in particular how weak normalizationis characterized by considering unforgetful derivations. In Sec. 3.4, we explain howsystem R can still be applied to infinite terms. We encounter a first use of subjectsubstitution, i.e. replacing the subject t of a derivation Π by another u which is equal to t in the typed parts of Π . We present the main ideas to solve Klop’s Problem in Sec. 3.5and 3.6: we informally explain (1) how infinitary subject expansion could be performedby truncating derivations and taking the joins of directed families (2) how coinductiongives rise unsound derivations, e.g. , derivations typing the unsolvable term Ω and howsoundness can be retrieved with approximability .3.1. Infinite Lambda Terms.
In this section, we present Böhm trees (chapter 10 of [2])and the construction of one of the infinitary calculi introduced in [23]. See also [1,13,16]for alternative presentations. We reuse and refine some notions from Sec. 2.2.The set Λ ∞ of infinitary λ -terms is coinductively defined by: t, u := x ∈ V k ( λx.t ) k ( t @ u ) When there is no ambiguity, we usually just write λx.t and t u . . . u n instead of ( λx.t ) and ( . . . ( t @ u ) . . . @ u n ) . If t is an infinitary term, then supp ( t ) , the support of t (theset of positions in t ) is defined by supp ( x ) = { ε } , supp ( λx.t ) = { ε } ∪ · supp ( t ) and supp ( t u ) = { ε } ∪ · supp ( t ) ∪ · supp ( u ) by coinduction (contrary to Sec. 2.2). Thenotations t ( b ) and t | b are defined by induction on b (as in Sec. 2.2).Let t ∈ Λ ∞ . An infinite branch of t is an infinite word γ such all the finite prefixesof γ are in t . The notion of applicative depth ad ( _ ) is straightforwardly extended toinfinite branches: Example 1. • Let us formally define the term f ω from Sec. 2.2 by the equation f ω = f ( f ω ) , i.e. f ω is the labelled tree such that supp ( f ω ) = { n | n ∈ N } ∪ { n · | n ∈ N } , f ω (2 n ) = @ and f ω (2 n ·
1) = f for all n ∈ N . Then, f ω has one infinite branch ω , which is theinfinite repetition of : indeed, for all n ∈ N , n ∈ supp ( f ω ) . We have ad (2 ω ) = + ∞ . • Likewise, the infinite term ω x ∈ Λ ∞ defined by ω x = ( ω x ) x , so that ω x = ((( . . . ) x ) x ) x satisfies supp ( ω x ) = { n | n ∈ N } ∪ { n · | n ∈ N } , so supp ( ω x ) has the infinite branch ω (this indicates a leftward infinite branch), which satisfies ad (1 ω ) = 0 since 2 doesnot occur in ω .If a ∈ supp ( t ) , the subterm (resp. the constructor) of t at position a is denoted t | a (resp. t ( a ) ), e.g. , if t = λx. ( x y ) z and a = 0 · (resp. a = 0 · ), then t | a = x y and t ( a ) = @ ) (resp. t | a = t ( a ) = z ). This generalizes the notations from Sec. 2.2. Definition 1 (001-Terms) . Let t ∈ Λ ∞ . Then t is a , if, for all infinitebranches γ in supp ( t ) , ad ( γ ) = ∞ . The set of 001-terms is denoted Λ .Once again, the vocable “001-term” comes from [23]. For instance, f ω is a 001-termsince its unique infinite branch ω satisfies ad (2 ω ) = + ∞ , whereas ω x defined is not a001-term since its infinite branch ω satisfies ad (1 ω ) = 0 . EQUENCE TYPES AND INFINITARY SEMANTICS 17
The computation of Böhm trees.
Let t, u ∈ Λ ∞ . The notation t [ u/x ] denotesthe term obtained from t by the capture-free substitution of the occurrences of x with u (a formal definition can be founds in [23] in the infinitary setting). One easily checksthat if t, u are 001-terms, then t [ u/x ] also is a 001-term. The β -reduction → β is obtainedby the contextual closure of ( λx.t ) u → β t [ u/x ] and t b → β t ′ denotes the reduction of aredex at position b in t , e.g. , λy. (( λx.x ) u ) v · → β λy.u v . Thus, the relation t b → β t ′ isdefined by induction on b ∈ { , , } ∗ , the set of words on { , , } : ( λx.r ) s ε → β r [ s/x ] t b → β t ′ λx.t · b → β λx.t ′ t b → β t t t · b → β t ′ t t t · b → β t t ′ t b → β t ′ The definitions of Sec. 2.1 generalize to Λ , e.g. , a is a 001-term that does not contain a redex. Thus, the set of 001-NF, denoted NF ∞ ,can be defined coinductively by: t, t i ::= λx . . . x p .x t . . . t q ( p, q > A term t ∈ Λ is solvable if t → ∗ h λx . . . x p .x t . . . t q (with t , . . . , t p ∈ Λ ), which isa Head Normal Form (HNF) of arity p . A term t ∈ Λ is Head Normalizing (HN) if there is a finite reduction path from t to a HNF t ′ ( i.e. t → β t ′ ). In particular, theimplication “ t solvable” ⇒ “ t is HN” straightforwardly holds. The converse implication(“HN ⇒ solvable”) also holds, and we will give a simple semantic proof of this fact inSec. 3.4. Definition 2 (Böhm tree of a term) . Let t be a 001-term.The Böhm tree BT ( t ) of t is coinductively defined by: • BT ( t ) = λx . . . x p .x BT ( t ) . . . BT ( t q ) if t → ∗ h λx . . . x p .x t . . . t q . • BT ( t ) = ⊥ if t is unsolvable.For instance, BT (Ω) = ⊥ where Ω = ( λx.x x )( λx.x x ) and BT ( t ) = t if t a 001-normalform. Intuitively, the computation of Böhm trees is done by a possibly infinite seriesof head reductions at deeper and deeper levels. This corresponds to the asymptoticreduction strategy known as hereditary head reduction (Sec. 2.1).In the wake of Definition 2, we may now define hereditary permutators. Definition 3. • For all x ∈ V , the sets HP ( x ) of x -headed Hereditary Permutators ( x -HP) ( x ∈ V ) are defined by mutual coinduction : h ∈ HP ( x ) . . . h n ∈ HP ( x n ) ( n > , σ ∈ S n , x i = x, x i pairwise distinct ) and h → ∗ h λx . . . x n .x h σ (1) . . . h σ ( n ) h ∈ HP ( x ) • A closed hereditary permutator , or simply, a Hereditary Permutator (HP) is aterm of the form h = λx.h with h ∈ HP ( x ) for some x .Thus, a headed hereditary permutator is the head reduct of a hereditary permutatorapplied to a variable. Theorem 1 (Bergstra-Kop, [6]) . A λ -term t is a hereditary permutator iff t is invertiblemodulo βη -conversion for the operation · defined by u · v = λx.u ( v x ) , whose neutralelement is I = λx.x . Thus, u is invertible when there exists v such that λx.u ( v x ) = βη = λx.v ( u x ) = βη I .An extensive presentation of hereditary permutators and their properties is given inChapter 21 of [2].Definition 3 can be read as the specification of a set of terms whose Böhm trees havea particular form. Infinitary convergence.
Some reduction paths are of infinite length but asymptoti-cally produce a term:
Definition 4 (Productive reduction paths) . Let t = t b → β t b → β t . . . t n b n → β t n +1 . . . be a reduction path of length ℓ ω .Then, this reduction path is said to be productive if either it is of finite length ( ℓ ∈ N ),or ℓ = ∞ and ad ( b n ) tends to infinity (remember that ad ( · ) is applicative depth).A productive reduction path is called a strongly converging reduction sequence in [23],in which numerous examples are found. When BT ( t ) does not contain ⊥ , the hereditaryhead reduction strategy on a term t gives a particular case of productive path. Lemma 5 (Limits of productive paths) . Let t = t b → β t b → β t . . . t n b n → β t n +1 . . . be aproductive reduction path of infinite length.Then, there is a unique 001-term t ′ such that, for every d > , there is N ∈ N such that,for all n > N , supp ( t n ) ∩ { b ∈ { , , } ∗ | ad ( b ) d } = supp ( t ′ ) ∩ { b ∈ { , , } ∗ | ad ( b ) d } and t n ( b ) = t ′ ( b ) on supp ( t ′ ) ∩ { b ∈ { , , } ∗ | ad ( b ) d } .The existence and the unicity of the term t ′ in the statement of Lemma 5 is easyto prove, and t ′ is called the limit of the productive path. Intuitively, when t ′ is thelimit of ( t n ) n > , then t ′ induces the same tree as t n at fixed applicative depth aftersufficiently many reduction steps. We then write t → ∞ β t ′ if t → ∗ β t ′ or t is the limit of aproductive path starting at t . For instance, if ∆ f = λx.f ( x x ) , Y f = ∆ f ∆ f (with f ∈ V ),then Y f ε → β f ( Y f ) , which gives the productive path Y f ε → β f ( Y f ) → β . . . f n ( Y f ) n → β f n +1 ( Y f ) . . . since ad (2 n ) −→ ∞ . The limit of this path (which implements hereditaryhead reduction on Y f ) is f ω , i.e. Y f → ∞ β f ω and also BT ( Y f ) = f ω . This formalizesobservations of Sec. 2.2.A 001-term t is said to be infinitary weakly normalizing (WN ∞ ) if there isa 001-NF t ′ such that t → ∞ β t ′ . It turns out that t is WN ∞ iff its Böhm tree does notcontain ⊥ . Notice that, if BT ( t ) does not contain ⊥ ( e.g. , when t = Y f ), then it is obviousthat t is WN ∞ by Definitions 2 and 4, but the converse implication is not, especially inthe infinite case [23], as we explained in Sec. 2.1. The statement is proved in [23] in asyntactical way, but Theorem 5 gives an alternative semantic proof of this fact.3.3. The Finitary Type System R and Unforgetfulness. In this section, wepresent a well-known variant system of Gardner-de Carvalho’s using multisets to rep-resent non-idempotent intersection. This system characterizes head normalization. Westate its main properties (subject reduction and expansion) and then we explain how italso enables characterizing weak normalization, using unforgetfulness .System R features non-idempotent intersection types [9, 17], given by the following inductive grammar: σ, τ ::= o | [ σ i ] i ∈ I → τ where the constructor [ ] is used for finite multisets ( I is finite), and the type variable o ranges over a countable set O . We write [ σ ] n to denote the multiset containing σ withmultiplicity n . The multiset [ σ i ] i ∈ I is meant to be the non-idempotent intersection of EQUENCE TYPES AND INFINITARY SEMANTICS 19 the types σ i , taking into account their multiplicity , and intersection is strict, i.e. doesnot occur on codomain of arrows, as explained Sec. 2.4.In system R , a judgment is a triple Γ ⊢ t : τ , where Γ is a context, i.e. a total function from the set V of term variables to the set of multiset types [ σ i ] i ∈ I , t is aninfinitary term and τ is a type. The context x : [ σ i ] i ∈ I is the context Γ such that Γ( x ) = [ σ i ] i ∈ I and Γ( y ) = [ ] for all y = x . The multiset union +, satisfying e.g. , [ τ, σ ] + [ σ ] = [ τ, σ, σ ] , is extended point-wise on contexts, e.g. , Γ + ∆ maps x on Γ( x ) +∆( x ) . We set dom (Γ) = { x ∈ V | Γ( x ) = [ ] } , the domain of the context Γ . When dom (Γ) ∩ dom (∆) = ∅ , we may write Γ; ∆ instead of
Γ + ∆ . The set of R -derivations isdefined inductively by the rules in Fig. 6: ★✧ ✥✦ ax x : [ τ ] ⊢ x : τ Γ; x : [ σ i ] i ∈ I ⊢ t : τ abs Γ ⊢ λx.t : [ σ i ] i ∈ I → τ Γ ⊢ t : [ σ i ] i ∈ I → τ (∆ i ⊢ u : σ i ) i ∈ I app Γ + i ∈ I ∆ i ⊢ t u : τ Figure 6.
System R We write Π (cid:3) Γ ⊢ t : τ to mean that the finite derivation Π concludes with thejudgment Γ ⊢ t : τ and (cid:3) Γ ⊢ t : τ to mean that Γ ⊢ t : τ is derivable.No weakening is allowed ( relevance ). In particular, the ax -rule concludes with x : [ σ ] ⊢ x : σ and not with Γ , x : [ σ i ] i ∈ I ⊢ x : σ i (for some i ∈ I ). Relevance ensuresthat λx.x (resp. λx.y ) can be typed with [ τ ] → τ (resp. [ ] → τ ), but not with [ τ, σ ] → τ (resp. [ τ ] → τ ). ax x : [ τ ] ⊢ x : τ abs ⊢ λx.x : [ τ ] → τ ax y : [ τ ] ⊢ y : τ abs ⊢ λx.y : [ ] → τ A straightforward induction shows that if Γ ⊢ t : τ is derivable, then dom (Γ) is finite.The definition below allows formulating quantitative properties of the system. Remark 3 (Relevance and redundancy of context) . Contexts are actually superfluousin system R . We can see this by proceeding by induction on Π . By induction on Π (cid:3) Γ ⊢ t : τ , for all x ∈ V , Γ( x ) is the multiset of the types assigned to x in axiomrules. All the cases are straightforward. In a non-relevant system, this does not hold,since x may have been assigned types via the weakening rule. However, we prefer tokeep contexts explicit in system R although they are superfluous, since they make thesystem easier to formulate. Definition 6.
Let Π be a R -derivation. Then the size of Π , denoted sz (Π) , is thenumber of judgments in R .Observe that system R is essentially finite (a derivation contains a finite number ofjudgments, judgments contains finite number of types, types are finite trees), althoughit may type infinite terms, which can appear as untyped arguments of applications, e.g. , f ω ( := f ( f ω ) ) in: Π ′ = ax f : [[ ] → o ] ⊢ f : [ ] → o app f : [[ ] → o ] ⊢ f ω : o The Π ′ is finite: it contains only two judgments, and finite types and contexts. System R enjoys both subject reduction and expansion , meaning that typesare invariant under (anti-)reduction (if t → t ′ , then (cid:3) Γ ⊢ t : τ iff (cid:3) Γ ⊢ t ′ : τ ). Noticethe decrease of size in subject reduction statement. Proposition 7 (Weighted Subject Reduction and Expansion in system R ) . Assume t → β t ′ . • If Γ ⊢ t : τ is R -derivable, so is Γ ⊢ t ′ : τ .Moreover, if Π (cid:3) Γ ⊢ t : τ , then there is Π ′ (cid:3) Γ ⊢ t ′ : τ such that sz (Π ′ ) sz (Π) , withactually sz (Π ′ ) < sz (Π) when t → h t ′ . • If Γ ⊢ t ′ : τ is R -derivable, so is Γ ⊢ t : τ . Proof.
Both points are proved by induction on the position of the reduction, using thefollowing Substitution and Anti-Substitution Lemmas in the base case.
Lemma 8 (Substitution and Anti-Substitution in R ) . Let r and s be two 001-terms. • If Π (cid:3) Γ; x : [ σ i ] i ∈ I ⊢ r : τ and, ∀ i ∈ I , Φ i (cid:3) ∆ i ⊢ s : σ i , then there is a derivation Π ′ (cid:3) Γ + (+ i ∈ I ∆ i ) ⊢ r [ s/x ] : τ such that sz (Π ′ ) = sz (Π) + (+ i ∈ I sz (Φ i )) • If Π ′ (cid:3) Γ ′ ⊢ r [ s/x ] : τ , then there are derivations Π (cid:3) Γ; x : [ σ i ] i ∈ I ⊢ r : τ and ∀ i ∈ I , Φ i (cid:3) ∆ i ⊢ s : σ i such that Γ ′ = Γ + (+ i ∈ I ∆ i ) . Proof.
Substitution is proved by structural induction on Π . Anti-substitution is provedby induction on Π ′ , with a case-analysis on the last constructor of r .The following result was proved in [9] for Λ . We have slightly adapted it for Λ : Theorem 2 (de Carvalho) . A 001-term is HN iff it is typable in system R . Proof.
Assume that Π (cid:3) Γ ⊢ t : τ . Let n = sz (Π) . Then weighted subject reductionentails that the head reduction strategy outputs a HNF in less than n steps. Conversely,HNF are easily R -typable: to type λx . . . x p .x t . . . t q , we just need to assign [ ] → . . . → [ ] → o (with q arrows) to the head variable x , so that t , . . . , t q are left untyped.We then use subject expansion to conclude that every HN term is typable.Characterizing finitary weak normalization. A term t ∈ Λ is (finitarily) weakly nor-malizing when there is a reduction path from t to a finite normal form t ′ (note that if u is infinite, then ( λx.y ) u is infinite but reduces to the finite normal form y and is thusfinitarily weakly normalizing).To understand how it is done, observe first that system R characterizes head nor-malization (and not weak normalization) because the arguments of a head variable canbe left untyped: for instance, x is assigned [ ] → τ , then x t is typable with type τ forany term t – which is left untyped as a subterm of x t – even if t is not head normalizing. ax x : [[ ] → τ ] ⊢ x : [ ] → τ app x : [[ ] → τ ] ⊢ x t : τ As we explained in Sec. 2.4 (Partial typings), the possibility to have untyped argumentsis crucial to characterize head normalization because this does not forbid, e.g. , the headnormal form x Ω to be typed.On another hand, in order to characterize weak normalization, we must guaranteesomehow that every subterm is typed, except the subterms that can be erased in areduction paths, e.g. , the subterm u in ( λx.y ) u , since ( λx.y ) u → β y . To achieve this, [ ] should not occur at bad positions in a derivation Π . Actually, it is enough to only lookat the judgment concluding Π . We recall that [ ] occurs negatively in [ ] → τ and that [ ] occurs positively (resp. negatively) in [ σ i ] i ∈ I → τ if [ ] occurs positively (resp. negatively) EQUENCE TYPES AND INFINITARY SEMANTICS 21 in τ or negatively (resp. positively) in some σ i , i.e. the polarity of the occurrences of [ ] in a type is preserved in the codomain of arrows and inverted in the domain of arrows.We say here that judgment Γ ⊢ t : τ is unforgetful when [ ] occurs neither negativelyin any Γ( x ) nor positively in τ . A term t is unforgetfully typable if an unforgetfuljudgment Γ ⊢ t : τ is derivable. This is given by the following theorem [14], which is thenon-idempotent counterpart of a similar characterization with idempotent intersectionbased on unforgetfulness: Theorem 3.
A term t is weakly normalizing iff it is unforgetfully typable in R A straightforward induction on the structure of t shows that, if t is a normal formand Π (cid:3) Γ ⊢ t : τ is unforgetful, then every subterm of t is typed in Π . Thus, no partof the normal form of a term t is “forgotten” in an unforgetful derivation. This roughlyjustifies why the above theorem holds. In general, the unforgetfulness criterion givesa characterization of weak normalization in any type system which characterizes head normalization.For now (in particular for Sec. 3.5), it is enough to keep in mind that a sufficientcondition of unforgetfulness is to be [ ] -free : t is weakly normalizing as soon as (cid:3) Γ ⊢ t : τ ,where Γ and τ do not contain [ ] . Throughout this article, we will frequently invokesystem R and this section to illustrate or motivate our choices.3.4. Infinitary subject reduction and expansion for finite derivations.
Now, letus explain why subject reduction and expansion hold for infinite productive reductionpath (and not just finite ones). The fact that if (cid:3) Γ ⊢ t : τ and t → ∞ β t ′ then there is (cid:3) Γ ⊢ t ′ : τ (infinitary subject reduction) is actually an easy consequence of Definition 4.In contrast, the fact that if Π (cid:3) Γ ⊢ t ′ : τ and t → ∞ β t ′ , then (cid:3) Γ ⊢ t : τ (infinitary subjectexpansion) relies on the finiteness of the derivations in R and a technical observationthat we call subject substitution and that will be a key tool in Sec. 3.5 and 7.4 to obtainfull infinitary subject expansion.From an observation above, recall that in a derivation Π typing a term t , somesubterms of the subject may be untyped. We remark that we can replace the untypedparts of the term without compromising the correctness of the derivation Π . This remarkwill allow us to “jump” to the limit of a productive reduction path, and also to jumpback from the limit to a finite section of such a path. Example 2.
Consider: Π = x : [[ ] → o ] ⊢ x : [ ] → ox : [[ ] → o ] ⊢ x ( y z ) : o Π = x : [[ ] → o ] ⊢ x : [ ] → ox : [[ ] → o ] ⊢ x Ω : o We transform Π into Π by substituting the subject x ( y z ) with x Ω . This is licit becausewe replace y z , which is an untyped subterm of x ( y z ) in the derivation Π .To formulate subject substitution, we need to define the set of positions of the typedsubterms in a derivation Π : Definition 9.
Let Π a derivation typing a term t . We define the set ˆΠ ⊂ supp ( t ) of the typed positions in Π by the following induction on Π : • If Π ends with an axiom rule ( t = x ), then ˆΠ = { ε } = supp ( t ) . • If Π ends with an abs -rule ( t = λx.t ) and Π is its depth 1 subderivation, then ˆΠ = { ε } ∪ · ˆΠ . • If Π ends with an app -rule ( t = t t ), Π is its left premise (concluding with t :[ σ i ] i ∈ I → τ ) and the (Π i ) i ∈ I (concluding respectively with t : σ i ) are its right premises,then ˆΠ = { ε } ∪ · ˆΠ ∪ ( ∪ i ∈ I ˆΠ i ) In the app -case, if I = ∅ , t is not typed and we only have ˆΠ = { ε } ∪ · ˆΠ , asexpected. In the typings of x ( y z ) and x Ω in Example 2, we have ˆΠ = ˆΠ = { ε, } .The applicative depth of a typed position inside Π cannot exceed the size of Π (this canbe proved by induction on Π ): Observation 10.
Let Π be a R -derivation. If b ∈ ˆΠ , then ad ( b ) < sz (Π) . Lemma 11 (Subject Substitution) . Let t, u ∈ Λ ∞ . If Π (cid:3) R Γ ⊢ t : τ , ˆΠ ⊆ supp ( u ) and,for all b ∈ ˆΠ , u ( b ) = t ( b ) , then there exists a R -derivation Ψ such that Ψ (cid:3) Γ ⊢ u : τ and ˆΨ = ˆΠ . Proof.
Straightforward by induction on Π .To obtain infinitary subject expansion in R , the idea is to perform subject substi-tution in the considered infinite productive reduction path. Indeed, if Π types t and t and u differ only for positions b ∈ { , , } ∗ such that | b | > sz (Π) (where | b | is the lengthof b ), then Lemma 11 can be applied on Π . Proposition 12 (Infinitary suject reduction (system R )) . If t → ∞ β t ′ and (cid:3) R Γ ⊢ t : τ , then (cid:3) R Γ ⊢ t ′ : τ . Proof.
When t → ∞ β t ′ in a finite number of steps, this results from inductive applicationof Proposition 7. Let us then assume that t = t b → β t b → β t → ∞ β t ′ is an infinite pathand that Π (cid:3) R Γ ⊢ t : τ .Let k = sz (Π) ( k < + ∞ !). Let N such that, for all n > N , ad ( b n ) > k (such a n exists, since the reduction path is productive). By Proposition 7, there is Π N (cid:3) Γ ⊢ t N : τ such that sz (Π N ) k .By Observation 10, for all n > N , b n / ∈ ˆΠ N . Then, by induction on n > N , for all b ∈ ˆΠ N , t n ( b ) = t N ( b ) . By Lemma 5, this implies that, for all b ∈ ˆΠ N , t ′ ( b ) = t N ( b ) . Bysubject substitution (Lemma 11) applied to Π N , there is a derivation Π ′ (cid:3) Γ ⊢ t ′ : B .This concludes the proof.Actually, we do not even need to consider finite derivations for Lemma 11 to hold.This is just a consequence of the productivity of the reduction paths. See Proposition 31where it is formally done.In contrast, the proof of infinitary subject expansion below crucially relies on thefact that R -derivations are finite: Proposition 13 (Infinitary suject expansion (system R )) . If t → ∞ β t ′ and (cid:3) R Γ ⊢ t ′ : B , then (cid:3) R Γ ⊢ t : B . Proof.
When t → ∞ β t ′ in a finite number of steps, this is an obvious consequence of Propo-sition 7. Let us then assume that t = t b → β t b → β t → ∞ β t ′ is an infinite path and that Π (cid:3) R Γ ⊢ t ′ : τ . Let k = sz (Π ′ ) . Let N such that, for all n > N , ad ( b n ) > k (such a n exists, since the reduction path is productive). By definition of the limit (Lemma 5), thisimplies that supp ( t N ) ∩{ b ∈ { , , } ∗ | ad ( b ) k } = supp ( t ′ ) ∩{ b ∈ { , , } ∗ | ad ( b ) k } and that, on this set, t N ( b ) = t ′ ( b ) . In particular, by Observation 10, t N ( b ) = t ′ ( b ) iswell-defined and holds on ˆΠ ′ .By subject substitution (Lemma 11) applied to Π ′ and t N , there is a derivation Π N (cid:3) Γ ⊢ t N : τ .By Proposition 7 applied N times, there is Π (cid:3) Γ ⊢ t : τ such that sz (Π) k . Thisconcludes the proof. Remark 4.
The lemmas of this section all apply to Λ ∞ (Sec. 3.1) and not only to Λ with minor changes. In particular, for any t ∈ Λ ∞ , there is a reduction path from t to aNF iff the head reduction terminates on t . Notice that some t ∈ Λ ∞ are headless , e.g. , ω x from Example 1, which has neither a head variable nor a head redex, because of itsleftward infinite branch, but such a headless term is not typable in R .3.5. Roadmap to solve Klop’s Problem.
Since hereditary head normalization is aform of infinitary weak normalization, we want to adapt the proof of Proposition 3which gives a type-theoretic characterization of finitary weak normalization. The twomain ingredients follow the principles of Sec. 2.4: • Typing (infinitary) normal forms in unforgetful judgment (in this section, f ω ). • Using a form of infinitary subject expansion to obtain a derivation typing the expandedterm (here, Y f )The second point (infinitary subject expansion) is delicate, but we give intuitions abouthow it may achieved just below. This will allow us to present the key notions of trun-cation and approximability . Fig. 7 illustrates the main ideas of this section. A complete trial on Y f . The first point (typing NF) is easier to grasp: notice that ina type system characterizing infinitary weak normalization, derivations should be ableto type infinite normal forms fully , i.e. without leaving subterms untyped. For instance,the following derivation Π ′ , which fully types f ω , should be allowed (this derivation isalso represented on top of Fig. 7): Π ′ = ax f : [[ o ] → o ] ⊢ f : [ o ] → o Π ′ (cid:3) f : [[ o ] → o ] ω ⊢ f ω : o app f : [[ o ] → o ] ω ⊢ f ω : o To define Π ′ , we have informally used an infinitary version of system R that wecall system R (system R is formally defined in Appendix E). System R allows infinitemultisets ( e.g. , [ o ] ω is the multiset in which o occurs with an infinite multiplicity, so that [ o ] ω = [ o ] + [ o ] ω ), proofs of infinite depth and also infinitary nestings, e.g. , the type σ defined by σ = [ σ ] → o , so that σ = [[ . . . ] → o ] → o , is legal. Step 1 (truncations/approximations).
Notice that Π ′ is of infinitary depth and fully types f ω ( i.e. no subterm of f ω is left untyped in Π ′ ). Actually, Π ′ is [ ] -free andin particular, it is unforgetful (recall the discussion surrounding Theorem 3).Thus, Π ′ is the kind of derivation we want to expand, so that get a derivation Π typing Y f and witnessing that this term is infinitarily weakly normalizing. Since Y f → ∞ β f ω (infinite number of reduction steps), we are stuck.But notice that Π ′ can be truncated into the derivation Π ′ n below, for any n > .To define these derivations, we have set Γ n = f : [[ o ] → o ] n − + [[ ] → o ] and we write x : τ instead of x : [ τ ] ⊢ x : τ for ax -rules): Π ′ n = ax f : [ o ] → o ax f : [ o ] → o ax Γ ⊢ f : [ ] → o app Γ ⊢ f ω : o app Γ ⊢ f ω : o ... Γ n − ⊢ f ω : o app Γ n ⊢ f ω : o Derivations Π ′ and Π ′ are represented in the middle of Fig. 7. By truncation or approximation , we mean, as suggested in Sec. 2.8, that the finite derivation Π ′ n can be Π ′ (cid:3) f : [[ o ] → o ] ω ⊢ f ω : o Π ′ is an infinite derivation typing the infinite term f ω EveryVariable isTyped [ o ] → o o [ o ] → o o [ o ] → o o [ o ] → o o [ o ] → o o f @ f @ f @ f @ f @Π ′ can be truncated into e.g. , , Π ′ (cid:3) f : [[ o ] → o ] + [[ ] → o ] ⊢ f ω : o Both Π ′ and Π ′ are finite derivations typing the infinite term f ω [ ] → o o [ o ] → o o [ o ] → o o f @ f @ f @ f @ f @ or Π ′ (cid:3) f : [[ o ] → o ] + [[ ] → o ] ⊢ f ω : o [ ] → o o [ o ] → o o [ o ] → o o [ o ] → o o f @ f @ f @ f @ f @ The untyped parts of the subject can be substituted e.g. , f ω can be replaced by f ( Y f ) in Π ′ and Π ′ , yielding respectively. . . Π (cid:3) f : [[ o ] → o ] + [[ ] → o ] ⊢ f ( Y f ) : o Both Π and Π are finite derivations typing the finite term f ( Y f )[ ] → o o [ o ] → o o [ o ] → o o Y f f @ f @ f @ f @ Π (cid:3) f : [[ o ] → o ] + [[ ] → o ] ⊢ f ( Y f ) : o [ ] → o o [ o ] → o o [ o ] → o o [ o ] → o o Y f f @ f @ f @ f @ Figure 7.
Truncation and Subject Substitution
EQUENCE TYPES AND INFINITARY SEMANTICS 25 informally obtained from the infinite one Π ′ by erasing some elements from the infinitemultisets appearing in the derivation. We also informally write Π ′ Π ′ Π ′ . . . tomean that Π ′ n approximates Π ′ n +1 . Thus, Π ′ n Π ′ for all n ∈ N .Conversely, we see that Π ′ is the graphical join of the Π ′ n : Π ′ is obtained by super-posing suitably all the derivations Π ′ n on the same infinite sheet of paper. Step 2 (expand the finite approximations). • Substituting f ω . Observe now that, although we do not know yet how to expand Π ′ ,we can expand the Π ′ n , because the Π ′ n are R -derivations (thus, they are finite ): bysubject expansion in system R (Proposition 7), for all n > , there is a R -derivation Π ′ n concluding with Γ n ⊢ Y f : o . In the particular case of Π ′ , we can detail the process:(1) Π ′ n leaves f ω untyped beyond depth n and (2) for any k > n , f ω and f k ( Y f ) are similar below depth n , so using subject substitution, for any k > n , Π ′ n yields aderivation Π kn typing f k ( Y f ) . We have represented Π and Π at the bottom of Fig. 7. • Finite expansions.
Thus, Π kn types f k ( Y f ) , the rank k reduct of Y f , so we can expandit k times, obtaining a derivation Π n . It can easily be observed that Π n does notdepend on k , because Π kn and Π nn have the same typed parts. Step 3 (joining the finite expansions).
We can then define Π , the expected ex-pansion of Π ′ , as the join of all the derivations Π n . This is justified by the followingpoints:(1) for any n ∈ N , we have Π n Π n . . . Π nn (see Fig. 7, bottom)(2) proof reduction and expansion are monotonic in this case. Thus, since Π , Π ,. . . , Π n are respectively obtained after n expansion steps from Π n , Π n ,. . . , Π nn , we have Π Π . . . Π n . This intuitively explains why the Π n (typing Y f ) have aninfinitary join Π , although the construction of this join is delicate for reasons to bepresented in the next section. Summary.
Thus, given an infinite derivation Π ′ typing t ′ and a productive reductionsequence t = t → β t → β . . . → ∞ β t ′ , the main ingredients to perform infinitary subjectexpansion are:1 Approximating Π ′ into finite derivations f Π ′ also typing t ′ , so that Π ′ is the (asymp-totic) join of the f Π ′ .2.a. In each f Π ′ , replacing t ′ with t n for a sufficiently large n ( n depends on f Π ′ ). Thisgives f Π n , which is also finite, but types the term t n instead of t ′ .2.b Expanding f Π n n times. This gives f Π , which type t .3 Obtaining Π , the expansion of Π ′ typing t by taking the join of the finite f Π .3.6. Problems with infinitary typing and how to solve them.
Thus, the ideasof truncation, subject substitution and join guides us about how to perform ∞ -subjectexpansion. The particular form of Π n and Π does not matter (but they are given inAppendix A for the curious reader). Let us just say here that the Π n involve a familyof finite types ( ρ ) n > inductively defined by ρ = [ ] → o and ρ n +1 = [ ρ k ] k n → o and Π involves an infinite type ρ satisfying ρ = [ ρ ] ω → o : if t and u are typed with ρ , then t u may be typed with o . But proof reduction is not monotonic in all cases, simply because, in general, it is non-deterministicin system R . See Sec. 5.4 Problem 1 ( Ω is typable). Unfortunately, it is not difficult to see that the type ρ alsoallows the unsolvable term Ω = ∆∆ to be typed. Indeed, x : [ ρ ] ω ⊢ x x : o is derivable,so ⊢ ∆ : ρ and ⊢ ∆ ∆ : o also are.This last observation shows that the naive extension of the standard non-idempotenttype system to infinite terms is unsound as unsolvable terms can be typed (actually, ev-ery term is typable in system R [40]: this means that every λ -term has a non-emptydenotation in the infinitary relational model). Therefore, we need to discriminate bet-ween sound derivations (like Π typing Y f ) and unsound ones. For that, we define aninfinitary derivation Π to be valid or approximable when it is the join of all its finite approximations (Figure 5). For instance, Π ′ is approximable (it is the join of the Π ′ n )and Π , defined as the join of the directed family (Π n ) n > is approximable. Problem 2 (validity is not definable with multisets).
It turns out that approx-imability cannot be formally defined in system R , i.e. with multisets as intersectiontypes. We managed to define in the example of Y f and f ω only because we explainedthe concept informally and in those terms, two equal subterms are assigned the sametyping. Intuitively, approximability cannot be defined in system R because multisetsdisable tracking, as explained in Sec. 2.7. Another (informal) argument will be givenlater in Sec. 5.4: since proof reduction is not deterministic in system R , the reductiondynamics of a R -derivation Π may be very different from that of finite its approxima-tions. We give a formal argument in Appendix E.4, once we have presented system S and defined approximability in this system: we find two distinct S -derivations P and P , which both collapse on the same R -derivation Π , but such that P is approximable(in system S ) whereas P is not. This proves that approximability cannot be lifted from R to S . 4. Tracking types in derivations
In this section, we define system S , which is based on the key construct of sequence (presented in Sec. 2.7) which we use to represent intersection in a rigid way, i.e. whichenables tracking. • We first coinductively define arrow types as function types whose domains are sequenceof types. A notion of typing judgment naturally follows. • We then define derivations trees such that arguments of applications are typed witha sequence of judgments.
General notations.
Some of these notations generalize or refine those of Sec. 2.2and 3.1. • A track k is any natural number. When k > , k is called an argument track . Aswe saw in Sec. 2.2, 0 is dedicated to the constructor λx , 1 is dedicated to the left-handside of applications. Not only 2 but all the k > to the possibly multiple typings ofthe arguments of applications. For instance, in system S , while typing an application t u , a subderivation on track (or on track 2, track 3 and so on) will be a subderivationtyping the argument u . This also explains why 0 and 1 will have a particular statusin the definitions to come, and motivates the definition of collapse below. • The set of finite words on N is denoted with N ∗ , ε is the empty word, a · a ′ theconcatenation of a and a ′ . The prefix order is defined on N ∗ by a a ′ if there is a such that a ′ = a · a , e.g. , · · · · . When the denotation is clear, we mayjust write instead of · · · . EQUENCE TYPES AND INFINITARY SEMANTICS 27
T, S k ::= o k ( k · S k ) k ∈ K → T Figure 8. S -Types • The applicative depth ad ( a ) generalizes to any a ∈ N ∗ : it still represents the numberof nestings inside arguments, i.e. ad ( a ) is defined inductively by ad ( ε ) = 0 , ad ( a · k ) = ad ( a ) if k = 0 or k = 1 and ad ( a · k ) = ad ( a ) + 1 if k > . • The collapse is defined on N by k = min( k, and on N ∗ inductively by ε = ε , a · k = a · k , e.g. , , and · · · · · · . Intuitively, the collapseconverts a position in system S into a position in a λ -term (with only 0s, 1s or 2s) .This extends to words of infinite length, the collapse of ω and (1 · · ω are ω and (1 · ) ω . • A sequence of elements of a set X is a family ( k · x k ) k ∈ K with K ⊆ N \ { , } . Inthis case, if k ∈ K , x k is the element of ( k · x k ) k ∈ K on track k . We often write ( k · x k ) k ∈ K for ( x k ) k ∈ K , which, for instance, allows us to denote by (2 · a, · b, · a ) or (4 · b, · a, · a ) the sequence ( x k ) k ∈ K with K = { , , } , x = x = a and x = b .In this sequence, the element on track 4 is b . If S = ( k · x k ) k ∈ K is a sequence, wewrite K = Rt ( S ) ( Rt stands for “ roots ”). Sequences come along with an (infinitary) disjoint union operator, denoted ⊎ : let S j := ( k · x k,j ) k ∈ K j be sequences for all j ∈ J (where J is a possibly infinite set): – If the ( K j ) j ∈ J are pairwise disjoint, then ⊎ j ∈ J S j is the sequence ( k · x k ) k ∈ K where K = ∨ j ∈ J K j and, for all k ∈ K , x k = x k,j where j is the unique index such that k ∈ K j . In that case, we say that the S j are disjoint . – If the ( K j ) j ∈ J are not pairwise disjoint, then ⊎ j ∈ J S j is not defined.When J is finite, we use ⊎ as an infix operator: S ⊎ S etc.The operator ⊎ is partial, and infinitarily associative and commutative. For in-stance, (2 · a, · b, · a ) ⊎ (4 · a, · c ) = (4 · a, · c ) ⊎ (2 · a, · b, · a ) = (2 · a, · b, · a, · a, · c ) ,but (2 · a, · b, · a ) ⊎ (3 · b, · c ) is not defined, because track 3 is in the roots of bothsequences ( track conflict ). • A tree A of N ∗ is a non-empty subset of N ∗ that is downward-closed for the prefixorder ( a a ′ ∈ A implies a ∈ A ). A forest is a set of the form A \ { ε } for sometree A such that , / ∈ A . Formally, a labelled tree T (resp. labelled forest F )is a function to a set Σ , whose domain, called its support supp ( T ) (resp. supp ( F ) ),is a tree (resp. a forest). If U = T or U = F , then U | a is the function defined on { a ∈ N ∗ | a · a ∈ supp ( U ) } and U | a ( a ) = U ( a · a ) . If U is a labelled tree (resp.forest and a = ε ), then U | a is a tree.4.1. Rigid Types.
We start now to implement the ideas of Sec. 2.7 to overcome theproblems concluding Sec. 3.6: to enable tracking (so that we may define approximability),every argument derivation or type in the domain of an arrow must now receive a trackfor label.Let O be a countable set of types variables (metavariable o ). The sets of (rigid)types Typ (metavariables T , S i , . . . ) is coinductively defined in Fig. 8.A sequence type F = ( k · S k ) k ∈ K is a sequence of types in the above meaning andis seen as an intersection of the types S k . We write ( ) for the empty sequence , i.e. thesequence type whose support is empty. A sequence type of the form ( k · T ) is called a singleton sequence type . Remark 5.
The equality between two types (resp. sequence types) may be defined bymutual coinduction: F → T = F ′ → T ′ if F = F ′ and T = T ′ and ( T k ) k ∈ K = ( T ′ k ) k ∈ K ′ if K = K ′ and for all k ∈ K, T k = T ′ k . ✗✖ ✔✕ → o o o o Figure 9.
The S -type (7 · o , · o , · o ) → o as a tree ★✧ ✥✦ ax x : ( k · T ) ⊢ x : T C ; x : ( S k ) k ∈ K ⊢ t : T abs C ⊢ λx.t : ( S k ) k ∈ K → TC ⊢ t : ( S k ) k ∈ K → T ( D k ⊢ u : S k ) k ∈ K app C ⊎ ( ⊎ k ∈ K D k ) ⊢ t u : T Figure 10.
System S The support of a type (resp. a sequence type ), which is a tree of N ∗ (resp. a forest),is defined by mutual coinduction: supp ( o ) = { ε } , supp ( F → T ) = { ε } ∪ supp ( F ) ∪ · supp ( T ) and supp (( T k ) k ∈ K ) = ∪ k ∈ K k · supp ( T k ) .Thus, S -types may be seen as labelled trees. For instance, (7 · o , · o , · o ) → o isrepresented in Fig. 9Thus, for types, track 1 is dedicated to the codomains of arrows.A type of Typ is in the set
Typ if its support does not hold an infinite branchending by ω . For instance, this excludes the T defined by T = ( ) → T ( i.e. T = ( ) → ( ) → . . . ). This restriction means that we may only have finite series of arrows in a type.Indeed, 001-normal forms, even though they may be infinite, contain only finite seriesof abstraction nodes ( e.g. , λx.λx . . . is not legal).We just write Typ for
Typ and consider only sequence types which hold only typesfrom
Typ .When a family of sequence types ( F i ) i ∈ I is disjoint, then there is no overlapping oftyping information between the F i , and ⊎ i ∈ I F i is defined.4.2. Rigid Derivations. A S -context C is a total function from V to the set of se-quence types, for instance, x : ( S k ) k ∈ K is the context which assigns ( S k ) k ∈ K to x and ( ) to every other variable. The domain of C is dom ( C ) = { x ∈ V | C ( x ) = ( ) } . We definethe join of contexts pointwise. If dom ( C ) ∩ dom ( D ) = ∅ , we may write C ; D instead of C ⊎ D . A judgment is a triple of the form C ⊢ t : T , where C is a context, t a 001-termand T ∈ Typ . A sequence judgment is a sequence of judgments ( C k ⊢ t : T k ) k ∈ K (notice that these judgments have the same subject t ). For instance, if ∈ K , then thejudgment on track 5 is C ⊢ t : S .The set of S -derivations (metavariable P ) is defined coinductively by the rules ofFig. 10. In the axiom rule, k is called an axiom track . In the app -rule, the contextsmust be disjoint, so that no track conflict occurs. Otherwise, app -rule cannot be applied.Derivations from system S may be seen as labelled trees: we define the support of P (cid:3) C ⊢ t : T coinductively: supp ( P ) = ε if P is an axiom rule, supp ( P ) = { ε } ∪ · supp ( P ) if t = λx.t and P is the subderivation typing t , supp ( P ) = { ε } ∪ · supp ( P ) ∪ k ∈ K k · supp ( P k ) if t = t t , P is the left subderivation typing t and P k thesubderivation typing t on track k . The P k ( k ∈ K ) are called argument derivations .Graphically, an app -rule may represented as in the top of Fig. 11: In this figure, argumentjudgments are on tracks 2, 4 and 5 (indicated in red) and the left-hand side judgment ison track 1 (compare with Fig. 1). The same app -rule has an alternative representation at EQUENCE TYPES AND INFINITARY SEMANTICS 29 ✬✫ ✩✪ C ⊢ t : (2 · S , · S , · S ) → T D ⊢ u : S D ⊢ u : S D ⊢ u : S C ⊎ D ⊎ D ⊎ D ⊢ t u : T Application node as a labelled tree C ⊢ t : (2 · S , · S , · S ) → T D ⊢ u : S [2] D ⊢ u : S [3] D ⊢ u : S [5] C ⊎ D ⊎ D ⊎ D ⊢ t u : T Compact representationFigure 11.
Representing app -nodes in system S the bottom of Fig. 11, where argument tracks are indicated between red square bracketsinside the argument judgments, whereas track 1 is omitted. Example 3.
In order to gain space, we do not write right-hand sides of axioms. Weset S ex = (8 · o, · o ′ , · o ) → o ′ . We indicate the track of argument derivations betweenbrackets e.g. , x : (2 · o ′ ) [3] means that judgment x : (2 · o ′ ) ⊢ x : o ′ is on track 3. P ex = ax x :(4 · S ex ) ax x : (9 · o ) [2] ax x : (2 · o ′ ) [3] ax x : (5 · o ) [8] app x : (2 · o ′ , · (8 · o, · o ′ , · o ) → o ′ , · o, · o ) ⊢ xx : o ′ abs ⊢ λx.xx : (2 · o ′ , · (8 · o, · o ′ , · o ) → o ′ , · o, · o ) → o ′ In the ax -rule concluding with x : (5 · o ) ⊢ x : o , the axiom track is 5.In Example 3 above, supp ( P ex ) = { ε, , · , · , · , · } and we have P ex (0 ·
8) = x :(5 · o ) ⊢ x : o . In particular, this judgment is on the argument track 8 of the app -ruleat position 0.When we forget about tracks, a sequence naturally collapses on a multiset e.g. , (3 · a, · b, · a ) collapses on [ a, b, a ] . If this collapse is performed coinductively, then thederivations of S will collapse on derivations of R . For instance, if we set σ ex = [ o, o ′ , o ] → o ′ , the derivation P ex of Example 3 collapses on: Π ex = x : σ ex x : [ o ] x : [ o ′ ] x : [ o ] x : [ o ′ , [ o, o ′ , o ] → o ′ , o, o ] ⊢ xx : o ′ ⊢ λx.xx : [ o ′ , [ o, o ′ , o ] → o ′ , o, o ] → o ′ Useful notations.
For the proofs of Sec. 7, the following notations will be needed: • For applications: assume a ∈ supp ( P ) and a = a ∗ · n . Then t | a ∗ is of the form t | a t . . . t n – The set
ArgTr iP ( a ) (for i n ) contains the tracks of argument derivationstyping the i -th argument t i below a . – The set
ArgPos iP ( a ) contains the positions of those subderivations.Formally, we set i n , ArgTr iP ( a ) = { k > | a ∗ · n − i · k ∈ supp ( P ) } and ArgPos iP ( a ) = a ∗ · n − i · ArgTr i ( a ) = { a ∗ · n − i · k ∈ supp ( P ) | k > } . When i is omitted, i = 1 is assumed, i.e. ArgTr P ( a ) = ArgTr P ( a ) . • For variables and binding: If a ∈ A := supp ( P ) and x ∈ V , we set Ax Pa ( x ) = { a ∈ A | a a , t ( a ) = x, ∄ a ′ , a a ′ a , t ( a ′ ) = λx } . Thus, Ax Pa is the set positions of ax -rules in P above a typing occurrences of x that are not bound at a . If a ∈ A isan axiom, we write tr P ( a ) for its associated axiom track. • We write Ax P for the set of all axiom positions in supp ( P ) .Usually, P is implicit and we write only ArgTr i ( a ) , ArgPos i ( a ) , Ax a ( x ) and tr ( a ) .For instance, in P ex (Example 3), ArgTr (0 ·
1) = { , , } and ArgPos (0 ·
1) = { · , · , · } (with a = 0 ). Moreover, Ax ( x ) = { , , , } , Ax ε ( x ) = ∅ and tr (01) = 4 , tr P (08) = 5 , whereas tr P (0) is not defined.5. Statics and Dynamics
In this section, we present bipositions , which allow pointing inside S -derivation (Sec. 5.1).We use this notion to present and prove the subject reduction and the subject expansionproperties (Sec. 5.3). Proof expansion is actually defined uniformly . We notice that proofreduction is deterministic in system S . This leads us to define a notion of residuation and to formulate a first argument showing that approximability is indeed not definablewhile working with multiset intersection (Sec. 5.4).5.1. Bipositions and Bisupport.
In a rigid setting as system S , we can identify andpoint to every part of a derivation, thus allowing to formulate many useful notions.If a ∈ supp ( P ) , then a points to a judgment inside P typing t | a . We write thisjudgment C ( a ) ⊢ t | a : T ( a ) : we say a is an outer position of P ( a is defined on p. 27).The context C ( a ) and the type T ( a ) should be written C P ( a ) and T P ( a ) but we oftenomit P . From now on, we shall also write t | a and t ( a ) instead of t | a and t ( a ) .In Example 3, P ex (01) = x : (4 · S ) ⊢ x : S , so C (01) = x : (4 · S ) i.e. C (01)( x ) =(4 · S ) . Since S = (8 · o, · o ′ , · o ) → o ′ , we have C (01)( x )(4) = → , C (01)( x )(43) = o ′ , T (01)( ε ) = → , T (01)(1) = o ′ . Likewise, P ex (03) = x : (2 · o ′ ) ⊢ o ′ , so that C (03) = x : (2 · o ′ ) and T (03) = o ′ . Thus, C (03)( x )(2) = o ′ and T (03)( ε ) = o ′ . We also have C (0)( x ) = (2 · o ′ , · (8 · o, · o ′ , · o ) → o ′ , · o, · o ) , so that C (0)( x )(2) = o ′ and C (0)( x )(42) = o .This motivates the notion of bipositions : a biposition (metavariable p ) is a pointerinto a type nested in a judgment of a derivation. Definition 14 (Bisupport) . • A pair ( a, c ) is a right biposition of P if a ∈ supp ( P ) and c ∈ supp ( T P ( a )) . • A triple ( a, x, k · c ) is a left biposition if a ∈ supp ( P ) , x ∈ V and k · c ∈ supp ( C P ( a )( x )) . • The bisupport of a derivation P , written bisupp ( P ) , is the set of its (right or left)bipositions.We consider a derivation as a function from its bisupport to the set O ∪ {→} and write now P ( a, c ) for T P ( a )( c ) and P ( a, x, k · c ) for C P ( a )( x )( k · c ) . For instance, (01 , ε ) , (01 , , (03 , ε ) are right bipositions in P ex and P ex (01 , ε ) = → , P ex (01 ,
1) = o ′ , P ex (03 , ε ) = o ′ . Moreover, (01 , x, , (01 , x, and (0 , x, are left bipositions of P ex and P ex (01 , x,
4) = → , P ex (01 , x,
43) = o ′ and P ex (0 , x,
42) = o . EQUENCE TYPES AND INFINITARY SEMANTICS 31 ✬✫ ✩✪ C ; x : ( S k ) k ∈ K ⊢ t : T C ⊢ λx.r : ( S k ) k ∈ K → T C ⊎ D ⊎ D ⊎ D ⊢ ( λx.r ) s : T h a i P r ♥ h a · · α ♥ i x : (2 · S ) h a · · a i x : (7 · S ) h a · · a i x : (3 · S ) h a · · a i P D ⊢ s : S P D ⊢ s : S P D ⊢ s : S ♣ h a · · α ♣ i Subderivation typing the redex P r ♥ h a · α ♥ i C ⊎ D ⊎ D ⊎ D ⊢ r [ s/x ] : T h a i P D ⊢ s : S h a · a i P D ⊢ s : S ♣ h a · a · α ♣ i h a · a i P D ⊢ s : S h a · a i Subderivation typingthe reductFigure 12.
Subject Reduction and Residuals5.2.
Quantitativity and Coinduction.
The presence of an infinite branch inside aderivation makes it possible that a type in a context is not “created” in an axiom rule.For instance, we set, for all k > , j k = f : ( i · (2 · o ) → o ) i > k , x : (8 · o ′ ) ⊢ f ω : o andwe coinductively define a family ( P k ) k > of S -derivations by P k = ax f : k · (2 · o ) → o ⊢ f : (2 · o ) → o P k +1 (cid:3) j k +1 [2] app f : ( i · (2 · o ) → o ) i > k , x : (8 · o ′ ) ⊢ f ω : o We observe that the P k are indeed correct derivations of S . However, notice that x hasbeen assigned a type (on track 8) although x does not appear in the typed term f ω andthe part of the context assigned to x cannot be traced back to any axiom rule typing x with o ′ (using axiom track 8). This motivates the notion of quantitative derivation, inwhich this does not happen: Definition 15.
A derivation P is quantitative when, for all a ∈ A and x ∈ V , C P ( a )( x ) = ⊎ a ′ ∈ Ax Pa ( x ) ( tr P ( a ′ ) · T P ( a ′ )) .Now, assume P is quantitative. Then Rt ( C ( a )( x )) = { tr ( a ) | a ∈ Ax a ( x ) } and forall a ∈ A, x ∈ V and k ∈ Rt ( C ( a )( x )) , we write pos ( a, x, k ) for the unique position a ′ ∈ Ax a ( x ) such that tr ( a ′ ) = k .Actually, pos ( a, x, k ) can be defined by a downward induction on a as follows: • If a ∈ Ax P , then actually a ∈ Ax ( x ) and tr ( a ) = k and we set pos ( a, x, k ) = a . • If a · ∈ A , we set pos ( a, x, k ) = pos ( a · ℓ, x, k ) , where ℓ is the unique positive integersuch that k ∈ Rt ( C ( a · ℓ )( x )) . • If a · ∈ A , we set pos ( a, x, k ) = pos ( a · , x, k ) One Step Subject Reduction and Expansion.
System S enjoys both subjectreduction and expansion, meaning that types are invariant under (anti)reduction. In-deed, if t → ∗ t ′ , then (cid:3) C ⊢ t : T iff (cid:3) C ⊢ t ′ : T : Proposition 16 (One Step Subject Reduction) . Assume t → β t ′ and P (cid:3) C ⊢ t : T .Then there exists a derivation P ′ such that P ′ (cid:3) C ⊢ t ′ : T . Proposition 17 (One Step Subject Expansion) . Assume t → β t ′ and P ′ (cid:3) C ⊢ t ′ : T .Then there exists a derivation P such that P (cid:3) C ⊢ t : T .We shall consider only the quantitative case, although these propositions are alsovalid for non-quantitative derivations. They may be proven using coinduction. Wegive an alternative proof using residuals and defining directly derivation P ′ in Sec. 5.5.Details can be found in Appendix C. We also explain here why subject reduction maybeen as a deterministic process in system S . Subject expansion is not deterministic, butit may be processed uniformly .All this is illustrated by Fig. 12: we assume that t | b = ( λx.r ) s and t b → t ′ , P is aquantitative derivation concluding with C ⊢ t : T . We also assume that a ∈ P is suchthat a = b (thus, a is the position of a judgment typing the redex to be fired) and thatthere are exactly 3 ax -rules typing x above a , using axiom tracks 2, 3 and 7. Noticethat ax -rule typing x on track 7 must be above a · , so that its position is of the form a · · a . Likewise for the two other axioms.Now, let us have a look at how reduction is performed inside P . We omit ax -rulesright-hand sides. We also indicate the position of a judgment between angle brackets, e.g. , h a · · a i means that judgment x : (3 · S ) ⊢ x : S is at position a · · a .Notice how this transformation is deterministic : for instance, assume ∈ K . Theremust be an axiom rule typing x using axiom track 7, e.g. , x : (7 · S ) ⊢ x : S at position a · · a and also a subderivation at argument track 7, namely, P concluded by s : S at position a · . Then, when we fire the redex at position b , the subderivation P must replace the axiom rule on track 7, even if there may be other k = 7 such that S k = S ,in contrast to system R (see Sec. 5.4).Thus, Proposition 16 canonically gives only one derivation P ′ typing t ′ , so that wemay also write P b → P ′ .Now, we observe that subject expansion cannot be deterministic in the same sense.When we pass from a derivation typing r [ s/x ] to a derivation typing ( λx.r ) s , we createnew axiom rules that will type x . Those axiom rules must be assigned axiom tracks.But if for instance, 3 axiom rules are created above position a , there is no more reasonto choose tracks 2, 3 and 7 than the tracks 8, 4, 38: the axiom tracks may be chosenarbitrarily, as long as they do not raise track conflicts. This explains the non-determinismof subject expansion.However, as it will turn out in Sec. 7.4, we will need to expand simultaneously families of derivations — and this, infinitely many times. For that, we should find away to perform subject expansion uniformly. Let then ⌊·⌋ be any injection from N ∗ to N \ { , } . We write Exp b ( P ′ , ⌊·⌋ , t ) for the unique expansion of P ′ such that P b → P ′ and, for all a ∈ N ∗ , if there is an ax -rule typing x created at position a , then the axiomtrack that has been assigned is ⌊ a ⌋ . Since ⌊·⌋ is injective, no track conflict may occur.This is done in Appendix C.3. The term t must be indicated in the expression, because,for one t ′ and one b , there may be several t such that t b → t ′ . Remark 6. If P is quantitative, then Red b ( P ) is quantitative. If P ′ is quantitative,then any Exp b ( P ′ , ⌊·⌋ , t ) is quantitative (for any choice of ⌊·⌋ ). Residuals.
Deterministic subject reduction naturally allows defining the residuals ofpositions and right bipositions after reduction, extending the notion of residuals forposition in λ -terms. We define then more precisely in Sec. 5.5, to sktech the formaldetails of the proof of the subject reduction property.In Fig. 12, ♥ represents a judgment nested in P r . Thus, its position must be ofthe form a · · α ♥ . After reduction, the app -rule and abs -rule at positions a and a · EQUENCE TYPES AND INFINITARY SEMANTICS 33 ✬✫ ✩✪ Π r τ ax x : σ ax x : σ λx [ σ, σ ] → τ @ τ Π s σ Π s σ reduces into Π , r [ s/x ] τ Π s s : σ s : σ Π s or Π , r [ s/x ] τ Π s s : σ s : σ Π s Figure 13.
Non-Determinism of Subject Reduction (MultisetIntersection)have been destroyed and the position of this judgment ♥ will be a · α ♥ . We set then Res b ( a · · α ♥ ) = a · α ♥ .Likewise, ♣ represents a judgment nested in the argument derivation P on track7 above a . Thus, its position must be of the form a · · α ♣ where a · is the root of P . After reduction, P will replace the ax -rule typing x on track 7, so its root will beat a · a (by definition of a ) . Thus, after reduction, the position of judgment ♣ will be a · a · α ♣ . We set then Res b ( a · · α ♣ ) = a · a · α ♣ .We can thus define the residuals of most positions α ∈ supp ( P ) , but not all, e.g. , a · , that corresponds to the abstraction of the redex, is destroyed during reduction anddoes not have a residual. For right bipositions, when ( a, c ) ∈ bisupp ( P ) and a ′ = Res b ( a ) is defined, we set Res b ( a, c ) = ( a ′ , c ) .Note that defining residuals in system R would be impossible: system R lackspointers and is not deterministic (Sec. 5.4 and Fig. 13).5.4. Safe Truncations of Typing Derivations.
Now that we have described thedeterministic reduction dynamics of system S , we can explain why the non-deterministicsystem R , based multiset intersection, is unfit to express the notion of approximability ,informally introduced at the end of Sec. 3.5.Let us consider a redex t = ( λx.r ) s and its reduct t ′ = r [ s/x ] . If a R -derivation Π types t , then Π has one subderivation Π r of the form Π r (cid:3) Γ , [ σ i ] i ∈ I ⊢ r : τ .Notice that proof reduction is non-deterministic in system R : let us consider aredex t = ( λx.r ) s and its reduct r [ s/x ] . Assume that t is typed so that s is typedexactly twice with the same type. For instance, say that Π is a derivation typing t which has a subderivation Π r (cid:3) Γ , x : [ σ, σ ] ⊢ r : τ (thus λx.r : [ σ, σ ] → τ ) and twosubderivations Π s and Π s concluding with ∆ i ⊢ s : σ (one may assume Π s = Π s ). Thissituation is represented in Fig. 13 and in particular, there are two different axiom rulestyping x with σ in r . Then, to obtain a derivation reduct typing t ′ = r [ s/x ] with τ ,there are two possibilities depending on which argument derivation Π is replaces whichaxiom rule typing x .This makes a sharp difference with system S : assume that S = S = S = S so thatargument derivation P , P , P type s with the same type S . Then each P k ( k ∈ K ) willreplace axiom rule at position a · · a k (see Fig. 12) without other choice. In system S ,there is a unique (canonical) derivation reduct.In contrast, let us dig into the following independent situations in system R : • Assume Π s and Π s (typing s ), both concluding with the same type σ = σ = σ , as inFig. 13. Thus, we also have two axiom leaves x : [ σ ] ⊢ x : σ .In that case, during reduction, the axiom rules Π s (in that case, axiom Π s ) or with Π s (in that case, axiom Π s ), because the types of axioms Π s and Π s . When we truncate Π into a finite f Π , the subderivations Π s and Π s are also cut into two derivations f Π s and f Π s . In each f Π is , σ can be cut intoa type f σ i . When Π s and Π s are different, it is possible that f σ = f σ for every finitetruncation of Π . Thus, it is possible that, for every truncation f Π , the axiom leaf f Π : indeed, a match between axiom rule and argument derivationthat is possible in Π could be impossible for any of its truncations. • Assume this time σ = σ . When we truncate Π into a finite f Π , both σ and σ canbe truncated into the same finite type f σ . In that case, we can associate f Π withaxiom f Π with axiom f Π in f Π (which is impossible in Π ), thusproducing a reduct derivation f Π ′ typing t ′ , which has no meaning w.r.t. Π ( f Π ′ wouldnot be a truncation of any derivation reduct of Π ).That is why we need the deterministic association between the argument derivationsand the axiom rules typing each in system S (thanks to tracks), so that the associationsbetween them are preserved even when we truncate derivations. system R does notallow to formulate a well-fit notion of approximability for derivations that would bestable under (anti)reduction and hereditary for subterms. Whereas determinism ensuresthat proof reduction is monotonic in system S , it is not monotonic in system R .Another, more formal argument proving that approximability cannot be definedin system R is presented in Appendix E.4: there exists a R -derivation Π and two S -derivations P and P that both collapse on Π such that P is approximable (Definition 20to come) and P is not.5.5. Proving Subject Reduction.
In this section, we sketch a proof of the subjectreduction property. A detailed proof can be found in Appendix C, although Fig. 12synthetizes the core arguments. For that, we define and use the notion of residual ofa bipositions, which will be instrumental to prove that approximability is stable underreduction and expansion.We assume again that P is a (quantitative or not) S -derivation typing t and t | b =( λx.r ) s . We set t ′ = r [ s/x ] , so that t b → β t ′ .We then use the following notations and conventions: • Let β ∈ supp ( t ) . We set Rep P ( β ) = { α ∈ supp ( P ) | α = β } . If α ∈ Rep P ( β ) , we saythat α is a representative of β (inside P ). • The metavariable a ranges over Rep P ( b ) , i.e. over the representatives the position ofthe fired redex. The metavariable α will be used for any position in N ∗ . • If a ∈ Rep P ( b ) , we set Ax λP ( a ) = Ax a · ( x ) and Tr λP ( a ) = { tr ( α ) | α ∈ Ax λ ( a ) } . Thus, Ax λP ( a ) is the set of positions of the redex variable (to be substituted) above a and Tr λP ( a ) is the set of the axiom tracks that have been used for them. We often omit P in the notations.For instance, in Fig 12, Ax λ ( a ) = { a · · a , a · · a , a · · a } and Tr λ ( a ) = { , , } .Since P is quantitative, C ( a · x ) must be of the form ( S k ) k ∈ K where K = Tr λ ( a ) , forany a ∈ Rep P ( b ) .For k ∈ Tr λ ( a ) , we write a k for the unique a k ∈ N ∗ such that pos ( a · , x, k ) = a · · a k : thus, a · · a k is the position of the axiom rule typing x above a using axiomtrack k Assume α ∈ A, α = a, a · , a · · a k for no a ∈ Rep P ( b ) and k ∈ RedTr ( a ) . Wefollow Fig. 12 and the residual position of α , written Res b ( α ) , is defined as follows: • If α > a · k · α for some a ∈ Rep P ( b ) and k > (paradigm ♣ ), then Res b ( α ) = a · a k · α • If α = a · · α for some a ∈ Rep P ( b ) with α / ∈ a k (paradigm ♥ ), then Res b ( α ) = a · α EQUENCE TYPES AND INFINITARY SEMANTICS 35 • If a (cid:11) b , Res b ( α ) = a .By case analysis, we notice that t ′ ( Res b ( a )) = t ( a ) for all a ∈ dom ( Res b ) .We set A ′ = codom ( Res b ) (we call A ′ residual support of P ). Now, whenever α ′ := Res b ( α ) is defined, the residual biposition of p := ( α, γ ) ∈ bisupp ( P ) is Res b ( p ) =( α ′ , γ ) .We notice that Res b is an partial injective function (both for positions and rightbipositions). In particular, Res b is a bijection from dom ( Res b ) to A ′ and we write Res − b for its inverse. We set, for all α ′ ∈ A ′ , T ′ ( α ) = T ( Res − b ( α ′ ) .For any α ′ ∈ A ′ , let C ′ ( α ′ ) be the context defined by C ′ ( α ′ ) = ( C ( α ) \ x ) ⊎ ( ⊎ k ∈ K ( α ) C ( α · k )) , where α = Res − b ( α ′ ) and K ( a ) = Rt ( C ( a )( x )) and C ′ ( α ′ ) \ x is the context C ′ suchthat C ′ ( x ) = ( ) and C ′ ( y ) = C ′ ( α ′ )( y ) for all y = x . Intuitively, C ′ ( α ′ ) erases the typesassigned to x and replace them by the contexts assigned to the matching occurrences of s , as expected in the reduct, where the argument s has replaced x .Notice that C ′ ( α ) = C ( α ) for any α ∈ A such that α ≯ b , e.g. , C ′ ( ε ) = C ( ε ) = C .Moreover, since Res b ( ε ) = ε , T ′ ( ε ) = T ( ε ) = T .We define now P ′ as the labelled tree such that supp ( P ′ ) = A ′ and P ′ ( α ′ ) is C ′ ( α ′ ) ⊢ t ′ | α ′ : T ′ ( α ′ ) . We claim that P ′ is a correct derivation concluded by C ⊢ t ′ : T : indeed, A ′ ⊂ supp ( t ′ ) stems from A ⊂ supp ( t ) . Then, for any α ′ ∈ A ′ and α = Res − b ( α ) , t ′ ( α ′ ) = t ( α ) and the rule at position α ′ is correct in P ′ because the rule at position α in P is correct after we notice that: • In the abstraction case, t ′ ( α ′ ) = λy implies C ′ ( α ′ · y ) = C ( α · y ) ). • If t ′ | α ′ is a substituted occurrence of s , then, t ( α ) = x and P ( α ) = x : ( k · T ( α )) ⊢ x : T ( α ) with α = a · · a k for some a ∈ Rep P ( b ) and the typing rules ensure that T ( α ) = T ( a · k ) = T ′ ( α ′ ) .Thus, P ′ is a derivation concluding with C ⊢ t ′ : T . This proves that subject reductionproperty holds in system S .6. Approximable Derivations and Unforgetfulness
We formally define approximation and approximability (Sec. 6.1). We prove that one-step proof reduction is monotonic (Sec. 6.2). In Sec. 6.3, we define the unforgetfulnesscriterion in system S . We prove infinitary subject reduction and that the infinite proofreduction actually preserves approximability (Sec. 6.4). As a by-product, we prove thatif a term is suitably typed, then it is hereditary head normalizing, which is one ofthe two implication of the fundamental equivalence between typability and infinitarynormalization.6.1. The Lattice of Approximation.
In Sec. 5.4, we saw R is unfit to recover sound-ness through approximability. Let us now work with system S only and formalize thisnotion.As seen in Sec. 3.5, we must be able to truncate derivations (notion of approximation)and define the join of some families of derivations. This can be properly done in system S : Definition 18 (Approximations) . • Let P and P ∗ be two derivations typing a same term t . We say P ∗ is a approx-imation of P , and we write P ∗ ∞ P , if bisupp ( P ∗ ) ⊆ bisupp ( P ) and for all p ∈ bisupp ( P ∗ ) , P ∗ ( p ) = P ( p ) . • We write
Approx ∞ ( P ) for the set of approximations of a derivation P and Approx ( P ) for the set of finite approximations of P .Thus, P ∗ ∞ P if P ∗ is a correct restriction of P of a subset of bisupp ( P ) ( i.e. arestriction that gives an S -derivation). We usually write f P for a finite approximation of P ( i.e. bisupp ( f P ) is finite) and in that case only, we write f P P instead of f P ∞ P .Actually, ∞ and are associated to lattice structures induced by the set-theoreticinclusion, union and intersection on bisupports : Theorem 4.
Let t be a 001-term. The set of derivations typing t is a directed completesemi-lattice w.r.t. ∞ : • If D is a directed set of derivations typing t : – The join sup D of D is the function P defined by dom ( P ) = ∪ P ∗ ∈ D bisupp ( P ∗ ) and P ( p ) = P ∗ ( p ) (for any P ∗ ∈ D such that p ∈ bisupp ( P ∗ ) ), which also is a derivation. – The meet inf D of D is the function P defined by dom ( P ) = ∩ P ∗ ∈ D bisupp ( P ∗ ) and P ( p ) = P ∗ ( p ) (for all P ∗ ∈ D ), which also is a derivation. • If P is a derivation typing t , Approx ∞ ( P ) is a complete lattice and Approx ( P ) is alattice. Proof.
See Appendix B for the details.
Remark 7.
Some S -derivations do not have any finite approximations, e.g. , any S -derivation typing Ω , because Ω is unsolvable.Approximation is compatible with reduction: Lemma 19 (Monotonicity of approximation) . • Reduction is monotonic: if P ∗ ∞ P, P ∗ b → P ′∗ and P b → P ′ , then P ′∗ ∞ P ′ . • Moreover, if P b → P ′ , then, for any P ′∗ ∞ P ′ , there is a unique P ∗ ∞ P such that P ′∗ b → P ′∗ . • Uniform expansion is monotonic: let ⌊·⌋ : N ∗ → N \ { , } an injection. If P ′ types t ′ , t b → t ′ and P ′∗ ∞ P ′ , then P ∗ ∞ P with P ∗ = Exp b ( P ′∗ , ⌊·⌋ , t ) , P = Exp b ( P ′ , ⌊·⌋ , t ) .6.2. Approximability.
We define here our validity condition, i.e. approximability: aderivation P is approximable when it is the join of all its finite approximations. Intu-itively, this means that P is approximable if all its bipositions are meaningful, i.e. canbe part of a finite derivation f P approximating P . Definition 20. A S -derivation P is said to be approximable if P is the join of its finite approximations, i.e. P = sup f P P f P .By definition of , we immediately obtain the following characterization of approxima-bility: Lemma 21. A S -derivation P is approximable iff, for all finite B ⊆ bisupp ( P ) , thereis a f P P such that B ⊆ bisupp ( f P ) .Quantitativity (Definition 15) is necessary to ensure approximability. Lemma 22. (1) If P is not quantitative, then P is not approximable.(2) If P b → P ′ , then P is approximable iff P ′ is approximable. Proof sketch.
EQUENCE TYPES AND INFINITARY SEMANTICS 37 (1) If P is not quantitative, then P contains some left biposition p := ( a, x, k · c ) thatdoes not come from an ax -rule. That is, there are infinitely many a ′ > a such that ( a ′ , x, k · c ) ∈ bisupp ( P ) . An approximation P ∗ ∞ P that contains p has to containall those ( a ′ , x, k · c ) and thus, cannot be finite. So P cannot be approximable.(2) Assume P approximable. Let us show that P ′ is also approximable. Then, let B ′ ⊆ bisupp ( P ′ ) be a finite set of bipositions. We can find a finite set of B ⊆ bisupp ( P ) such that B ′ ⊆ Res b ( B ) .Since P is approximable, there is f P P such that B ⊆ f P . We set f P ′ = Res b ( f P ) . By Lemma 19, f P ′ P ′ . This is enough to conclude.The converse implication is proven likewise. However, Res b is not defined for everybiposition ( e.g. , left ones) and our argument is faulty. It is not hard to avoid thisproblem (it is done in Appendix C), using a suitable notion of interdependencies between bipositions (two interdependent bipositions are said to be equinecessay ). Remark 8 (Root approximability) . Approximability (Definition 20) is a condition per-taining to a whole derivation P in the sense that P is approximable iff each biposition p in P is inside some finite approximation of P . One may wonder whether it is possible toreformulate approximability such that it pertains only to the conclusion of P , as someother criteria ( e.g. , unforgetfulness, Sec. 3). We prove in Appendix C.6 that there is noway to do so, at least naively.6.3. Unforgetfulness.
We remember from Sec. 3.3 that weak normalization for thefinite calculus is characterized in system R by means of unforgetful derivations. Inorder to characterize weak normalization in Λ (Sec. 3.2), we want to adapt Theorem 3to system S . This will yield Theorem 5, one of the main results of this paper, stated asfollows: Theorem.
A term t is weakly-normalizing in Λ if and only if t is typable by meansof an approximable unforgetful derivation, and if and only if t is hereditary head nor-malizing.To state and prove this theorem, we must first export the definition of unforget-fulness to system S . We recall that the targets of arrows are regarded as positive andtheir sources as negative. The following definitions are straightforward adaptations fromsystem R . Definition 23.
Inductively: • For all types T , ( ) occurs negatively in ( ) → T . • ( ) occurs positively (resp. negatively) in ( S k ) k ∈ K if there exists k ∈ K such that ( ) occurs positively (resp. negatively) in S k . • ( ) occurs positively (resp. negatively) in ( S k ) k ∈ K → T if ( ) occurs positively (resp.negatively) in T or negatively (resp. positively) in ( S k ) k ∈ K . Definition 24 (Unforgetfulness) . • A judgment C ⊢ t : T is unforgetful when ( ) does not occur positively in T and ( ) does not occur negatively in C ( x ) for any x ∈ V . • A derivation is unforgetful when it concludes with an unforgetful judgment.We easily check by induction on b ∈ supp ( t ) that, if t is a 001-NF and P (cid:3) C ⊢ t : T is unforgetful, then every subterm t | b of t is typed in P ( i.e. ∀ b ∈ supp ( t ) , ∃ a ∈ supp ( P ) , a = b ). ✬✫ ✩✪ clev qq − p x t @ t q − @ t q @ λx p λx Subtree of a NF t Corresponding types ( S k ) k ∈ K (1) → . . . → ( S qk ) k ∈ K ( q ) → T h ˚ a q i ( S k ) k ∈ K (1) ( S k ) k ∈ K (2) → . . . → ( S qk ) k ∈ K ( q ) → T h ˚ a q − i ( S q − k ) k ∈ K ( q − ( S qk ) k ∈ K ( q ) → T h ˚ a i ( S qk ) k ∈ K ( q ) T h ˚ a i C (˚ a )( x p ) → T h ˚ a − i C (˚ a − p )( x ) → . . . → C (˚ a )( x p ) → T h ˚ a − p i Figure 14.
Typing Normal Forms
Lemma 25. If P (cid:3) C ⊢ t : T is an unforgetful derivation typing a head normal form t = λx . . . x p .x t . . . t q , then, there are unforgetful subderivations of P typing t , t ,. . . , t q . Moreover, if P is approximable, so are they. Proof.
Whether x = x i for some i or not, the unforgetfulness condition ensures thatevery argument of the head variable x is typed, since ( ) cannot occur negatively in itsunique given type. Lemma 26. If P (cid:3) C ⊢ t : T is a finite derivation, then t is head normalizing. Proof. • By the typing rules, the head redex—if it exists i.e. if t is not already in HNF—mustbe typed. • When we reduce a typed redex, the number of rules of the derivation must strictlydecrease (at least one app -rule and one abs -rule disappear). See Figure 12. • Since there is no infinite decreasing sequence of natural number, the head reductionstrategy must halt at some point, meaning that a HNF is reached.
Proposition 27.
If a term t is typable by a unforgetful approximable derivation, then t is hereditarily head normalizing. Proof.
Consequence of Lemmas 25 and 26 via hereditary head reduction (Sec. 3.2).6.4.
The Infinitary Subject Reduction Property.
In this section, we prove subjectreduction for productive reduction path. The initial derivation may be approximable ornot. Thus, we have to construct a derivation P ′ typing t ′ from a derivation P typing aterm t that strongly converges towards t ′ . The main intuition is the following: when areduction is performed at applicative depth n , the contexts and types are not affectedbelow depth n . Thus, a productive reduction path stabilizes contexts and types at anyfixed applicative depth. It allows to define a derivation typing the limit t ′ .The following (and straightforward) subject substitution lemma , similar toLemma 11, is very useful while working with productive paths. It states that we canfreely change the untyped parts of a term in a typing derivation. EQUENCE TYPES AND INFINITARY SEMANTICS 39
Lemma 28.
Assume P (cid:3) C ⊢ t : T and for all a ∈ supp ( P ) , t ( a ) = t ′ ( a ) ( P is notnecessarily assumed to be approximable).Let P [ t ′ /t ] be the labelled tree obtained from P by replacing t by t ′ (more precisely, P [ t ′ /t ] is the labelled tree P ′ such that supp ( P ′ ) = supp ( P ) and, for all a ∈ supp ( P ) , P ′ ( a ) = C P ( a ) ⊢ t ′ | a : T P ( a ) ).Then P [ t ′ /t ] is a correct derivation.Now, let us formally prove the infinitary subject reduction property. For that, weassume: • t → ∞ t ′ . For instance, say that t = t b → t b → . . . b n − → t n b n → t n +1 b n +1 → . . . with b n ∈ { , , } ∗ and ad ( b n ) −→ ∞ and t ′ is the limit of this path. • There is a derivation P (cid:3) C ⊢ t : T and A = supp ( P ) .By following step by step the reduction path, b , b , . . . , we get a sequence of deriva-tions P n (cid:3) C ⊢ t n : T of support A n . We then write C n , T n for C P n and T P n . Whenperforming t n b n → t n +1 , notice that C n ( a ) and T n ( a ) are not modified for any a such that b n (cid:10) a i.e. C n ( a ) = C n +1 ( a ) and T n ( a ) = T n +1 ( a ) if b n (cid:10) a .Let a ∈ N ∗ and N ∈ N be such that, for all n > N, ad ( b n ) > ad ( a ) . There are twocases: • a ∈ A n for all n > N . Moreover, C n ( a ) = C N ( a ) , T n ( a ) = T N ( a ) for all n > N , and t ′ ( a ) = t n ( a ) = t N ( a ) . • a / ∈ A n for all n > N .We set A ′ = { a ∈ N ∗ | ∃ N, ∀ n > N, a ∈ A n } . We define a labelled tree P ′ whosesupport is A ′ by P ′ ( a ) = C n ( a ) ⊢ t ′ | a : T n ( a ) and we set C ′ ( a ) = C n ( a ) , T ′ ( a ) = T n ( a ) forany n > N ( ad ( a )) (where N ( ℓ ) is the smallest rank N such that ∀ n > N, ad ( a n ) > ℓ ) . Lemma 29.
The labelled tree P ′ is a derivation. Proof.
Let a ∈ A ′ and n > N ( | a | + 1) . Thus, t ′ ( a ) = t n ( a ) and the types and contextsinvolved at node a and its premises are the same in P ′ and P n . So the node a of P ′ iscorrect, because it is correct in P n . Lemma 30. If P is approximable, so is P ′ . Proof.
Let B ⊆ bisupp ( P ′ ) . We set ℓ = max { ad ( p ) | p ∈ B } ( ad ( p ) is the applicativedepth of the underlying a ∈ supp ( P ) ).By productivity, there is N such that, ∀ n > N, ad ( b n ) > ℓ + 1 , and thus, t N ( a ) = t n ( a ) = t ′ ( a ) , C N ( a ) = C n ( a ) = C ′ ( a ) and T N ( a ) = T n ( a ) = T ′ ( a ) for all a such that ad ( a ) ℓ and n > N . In particular, B ⊆ bisupp ( P N ) .Since P is approximable, by Lemma 22, P N is approximable. So, there is f P N P such that B ⊆ bisupp ( f P N ) .Let d = bisupp ( f P N ) and N ′ > N such that, for all n > N ′ , ad ( b n ) > d . Let f P N ′ the derivation defined by f P N b N → β . . . b N ′− → β f P N ′ . Since b ∈ supp ( f P N ′ ) implies ad ( b ) N ′ < d < ad ( b n ) for any n > N ′ , t N ′ and t ′ do not differ on supp ( f P N ′ ) and wecan apply Lemma 28. Thus, let f P ′ be the derivation obtained by replacing t N ′ with t ′ in f P . We have B ⊆ f P ′ P ′ . Thus, P ′ is approximable. Proposition 31 (Infinitary Subject Reduction) . Assume t → ∞ t ′ and P (cid:3) C ⊢ t : T .Then there exists a derivation P ′ such that P ′ (cid:3) C ⊢ t ′ : T .Moreover, if P is approximable, P ′ may be chosen to be approximable. Proof.
Consequence of Lemmas 29 and 30. Typing Normal Forms and Subject Expansion
In this section, we prove that (possibly infinite) normal forms are fully typable ( i.e. without leaving untyped subterms) in system S and that all the quantitative derivationstyping a normal form are approximable.Indeed, as hinted at in Sec. 2.3 and Sec. 3.3, a proof of Weakly Normalizing ⇒ Typable proceed by giving first an unforgetful typing of normal forms, and then, using asubject expansion property.Actually, we will describe all the quantitative derivations typing any 001-normalform (and prove them to be approximable). Then, we will prove an infinitary subjectexpansion property, what is enough to show the above implication.Describing all the possible typings of 001-normal forms is based on the distinctionbetween what we call constrained and unconstrained positions in a normal form. Weuse this notions from Sec. 7.1 to Sec. 7.3.
Constrained and Unconstrained Positions.
Normal forms are coinductive assem-blages of head normal forms ( cf.
Sec. 3.2). It is then important to understand how a HNF t = λx . . . λx p .x t . . . t q may be typed. Let us have a look at figure 14 and ignore forthe moment the clev and positions (between chevrons) annotations: the head variable x has been assigned an arrow type ( S k ) k ∈ K (1) → . . . → ( S qk ) k ∈ K ( q ) → T whereas thefirst argument t is typed with types S k ( k ranging over K (1) ),. . . , the q -th argument t q is typed with types S qk ( k ranging over K ( q ) ).In t , the subterms x, x t , x t t , . . . , x t . . . t q − , which are “partial” applications,are typed with arrow types, as well as the subterms λx p .x t . . . t q , λx p − x p .x t . . . t q , . . . and λx . . . x p .x t . . . t q , which start with abstractions. By contrast, notice that subterm x t . . . t n , where x is “fully” applied, has type T and that this type T may be any type.So, we say that the type of subterm x t . . . t q is unconstrained (in t ), whereas forinstance: • x t . . . t q − has type ( S qk ) k ∈ K ( q ) → T : this type depends on the types S qk given to thesubterm t q . We say informally that it calls for the types of the subterm t q . • λx p .x t . . . t q has type C (0 p )( x p ) → T : this type depends on the types assigned to x p deeper in the term, which are stored in C (0 p )( x p ) . We say informally that it calls forthe types of variable the x p .7.1. Support Candidates.
Before using the notion of constrained position above, wemust devote our attention to the possible forms of the support A := supp ( P ) of aderivation P typing a 001-normal form t . This is done by considering the preorder ≺ defined below, extending the prefix order.If a, a ′ ∈ supp ( t ) , we write a ≺ a ′ when there exists a such that a a, a a ′ , ad ( a ) = ad ( a ) and we observe that if P is a derivation typing t , then supp ( P ) isdownward closed for ≺ over supp ( t ) , meaning by that, for all a such that a ∈ supp ( t ) and a ∈ supp ( P ) , then a ≺ a implies a ∈ supp ( P ) . Intuitively, a ≺ a ′ holds when a and a ′ are in the same sub-HNF of t or if a ′ is nested in an argument derivation of thesub-HNF containing a .For instance, ≺ since , and ad (02103) = ad (021031) = 2 . If ∈ supp ( P ) , since is an argument track, t (02103) = @ ( i.e. points to an app -rule in P ). Last, , which is this app -rule left-handside, should also be in supp ( P ) , as well as every prefix of . And we have thus ∈ supp ( P ) as expected.Conversely, a non-empty set A downward closed for ≺ over supp ( t ) such that A ⊆ supp ( t ) will be called a support candidate for a derivation typing t and we prove EQUENCE TYPES AND INFINITARY SEMANTICS 41 that, for all support candidates A associated with a NF t , there is indeed a derivation P typing t such that A = supp ( P ) . This will be Lemma 32.For now, assume that there is a derivation P typing the 001-normal form t . Each a ∈ A is either an unconstrained position or related to an unconstrained position, whichwe denote ˚ a . The constrain level clev ( a ) of a is defined as the distance between a and ˚ a . More precisely, given a ∈ A := supp ( P ) , we have t | a = λx . . . x n .u , where u isnot an abstraction. The integer n is sometimes called the order (as in [7]) of t | a . Wesay then that a is an order n position. • If n > , we say that a is a non-zero position and we set ˚ a = a · n (so that t | ˚ a = u )and clev ( a ) = n . • If n = 0 , we distinguish two subcases, by first defining ˚ a as the shortest prefix a a such that a = a · ℓ (for some ℓ ) and setting clev ( a ) = ℓ :- If ℓ = 0 , then we set ˚ a = a and we say that a is a unconstrained position .- If ℓ > , we say that a is a partial position .As it has been observed above, a is unconstrained when, intuitively, the type of theunderlying subterm does not depend on deeper parts of the derivation. If i > , we write ˚ a i for ˚ a · i and ˚ a − i for the rank i prefix of ˚ a ( e.g. , ˚ a = ˚ a − · if t | ˚ a is of order > ).More generally, following the discussion beginning Sec. 7, we observe that if clev ( a ) = d ,then T ( a ) is an arrow type F → . . . → F d → T (˚ a ) , where T (˚ a ) is an unconstrained type.More precisely, using Fig. 14 to guide us: • When a is a non-zero position i.e. ˚ a = a · d and t | a is of the form λx q − d +1 . . . λx p .x t . . . t q with t | ˚ a = x t . . . t q , then F = C ( a · x q − d +1 ) , F = C ( a · )( x q − d +2 ) , . . . , F d = C ( a · d )( x p ) = C (˚ a )( x p ) . • When a is partial i.e. a = ˚ a · d and t | ˚ a is of the form x t . . . t q with t | a = x t . . . t p − d ,then t | ˚ a = t | a t p − d +1 . . . t q and F := ( k · T (˚ a · d − · k )) k ∈ ArgTr ( a ) , . . . , F d := ( k · T (˚ a · k )) k ∈ ArgTr k ( a ) (see end of Sec. 4.2 for notation ArgTr i ): thus, F i is the sequence oftypes given to the i -th argument t p − d + i of t | a w.r.t. position a .7.2. Natural Extensions.
Let A be a support candidate for t and ˚ T a function from ˚ A to the set of types. We want to extend ˚ T on T so that we get a correct derivation P typing t .First, note that clev ( a ) may be defined in A as it was for a derivation P in theprevious section. We set a ∈ ˚ A iff ( a · / ∈ A and there is no a ′ such that a = a ′ · ).Moreover, if a ∈ A \ ˚ A , then either there are unique a ′ ∈ ˚ A and n > such that a ′ = a · n ,or there are unique a ′ ∈ ˚ A and n > such that a = a ′ · n . In both cases, we set ˚ a = a ′ and clev ( a ) = n .As we have seen in Sec. 7.1, we must capture the way calls are made in a derivationby a type to other types which are deeper in the derivation. For that, to each a ∈ N ∗ ,we attribute an indeterminate X a . Intuitively, X a calls for T ( a ) , the type given to thesubterm at position a . For all a ∈ A, x ∈ V , we set A a ( x ) = { a ∈ A | a a , t ( a ) = x, ∄ a ′ , a a ′ a , t ( a ′ ) = λx } so that we intend to have Ax Pa ( x ) = A a ( x ) (as well as tr P ( a ) = ⌊ a ⌋ ) when P is built.Combining all the above intuitions, we set, for all a ∈ A, x ∈ V , E ( a )( x ) = ( ⌊ a ⌋ · X a ) a ∈ A a ( x ) (thus, E ( a )( x ) calls for the types given to x in ax -rules above a ). If a ∈ A is partial or unconstrained, d = clev ( a ) ( i.e. a = ˚ a · d ) and i d , we define thesequence R i ( a ) by R i ( a ) = ( k · X ˚ a d − i · k ) k ∈ ArgTr iA ( a ) with ArgTr iA defined as for derivationsby ArgTr iA = { k > | a ∗ · d − i · k ∈ A } . The intuition is that R i ( a ) calls for the typesgiven to the argument of the i -th application below a . • If a ∈ A is a non zero position, e.g. , t | a is of the form λx . . . x d .t | ˚ a . We then set: Call ( a ) = E ( a · x ) → . . . → E (˚ a )( x d ) → ˚ T (˚ a ) • If a ∈ A is partial, we set: Call ( a ) = R ( a ) → . . . → R n ( a ) → ˚ T (˚ a ) • If a ∈ A is unconstrained, we set Call ( a ) = ˚ T ( a ) .We then extend ˚ T (defined on unconstrained positions only, for the time being) to A bythe following coinductive definition: for all a ∈ A , T ( a ) = Call ( a )[ T ( a ′ ) /X a ′ ] a ′ ∈ N ∗ For all a ∈ A , we define the contexts C ( a ) by: C ( a )( x ) = E ( a )( x )[ T ( a ′ ) /X a ′ ] a ′ ∈ A a ( x ) Those definitions are well-founded, because whether a is non zero position or apartial one, every occurrence of an X k is at depth > and the coinduction is productive .Finally, let P be the labelled tree whose support is A and such that, for a ∈ A , P ( a ) is C ( a ) ⊢ t | a : T ( a ) . Lemma 32.
The labelled tree P defined above is a derivation. Proof.
Let a ∈ A . Whether t ( a ) is x , λx or @ , we check the associated rule has beencorrectly applied. Roughly, this comes from the fact that the variable X a ′ is “on thegood track” ( i.e. ⌊ a ′ ⌋ ) in E ( a )( x ) , as well as in R i ( a ) , thus allowing to retrieve correcttyping rules.We call then the derivation P built above the natural extension of the pair ( A, ˚ T ) .Natural extension give all the possible quantitative derivations typing a normal form.For our purpose, they also give: Lemma 33.
A normal form t is unforgetfully typable. Proof sketch.
We set A = supp ( t ) and ˚ T ( a ) = o for each unconstrained position (where o is a type variable). Then, the extension P of ( A, ˚ T ) is an unforgetful derivation typing t .7.3. Approximability.
In this section, we prove that (1) for derivations typing 001-normal forms, it is enough to be quantitative to be valid and that (2) as a corollary, all001-normal forms are approximably and unforgetfully typable.To prove the following lemma, we define the rank of a position as follows:
Definition 34.
Let a ∈ N ∗ . The rank of a , denoted rk ( a ) is defined by rk ( a ) =max( ad ( a ) , max( a )) .Thus, rk ( a ) bounds the “width” and applicative depth of a . For instance, rk (0 · ) = 5 and rk (2 · ·
3) = 8 . Lemma 35. If P is a quantitative derivation typing a 001-normal form t , then P isapproximable. Proof sketch.
Let P (cid:3) C ⊢ t : T be a quantitative derivation typing a 001-normal form t . Let us prove that P is approximable. For that, we will build, for any finite subset B of bisupp ( P ) , a finite derivation f P P containing B . We will proceed as follows: • Choosing a finite support candidate f A ⊆ A of t i.e. we will discard all positions in A but finitely many. • Then, choosing, for each ˚ a ∈ f A , a finite approximation f T (˚ a ) of T (˚ a ) . EQUENCE TYPES AND INFINITARY SEMANTICS 43
The natural extension of ( f A, f T ) will be a finite derivation f P P typing t such that B ⊆ supp ( f P ) .Actually, we define P n , the rank n truncation of P as follows: • We define A n by discarding every position a ∈ A such that ad ( a ) > n or a containsa track > n , i.e. we set A n = { a ∈ A | rk ( a ) n } . Since t ∈ Λ , A does not haveinfinite branch of finite applicative depth and thus, A n is a finite set of positions. • For each ˚ a ∈ ˚ A n , we define ˚ T n (˚ a ) by discarding every c ∈ supp ( T (˚ a )) such that ad ( c ) > n or c has a track > n , i.e. we restrict define ˚ T n so that supp (˚ T n (˚ a )) = { c ∈ supp ( T n (˚ a )) | rk ( c ) n } ). Since T n (˚ a ) ∈ Typ (and not in
Typ − Typ ), ˚ T n (˚ a ) is a finite type.We define now P n as the natural extension of ( A n , ˚ T n ) . Using the quantitativity of P ,we may prove then that, for all B ⊆ bisupp ( P ) , there exists a large enough n such that B ⊆ bisupp ( P n ) . The idea is the following: as we have seen, each biposition p may“call” a chain of deeper bipositions. However, the set of bipositions called by p is finiteand we may define the called rank cr ( p ) of p as the maximal applicative depth of abiposition called by p . Then, since B is finite, we define n as max( { cr ( p ) | p ∈ B } ) andwe check that B ⊆ P n (see Appendix D for a detailed proof).Using Lemmas 33 and 35, we can now assert: Proposition 36.
Every 001-normal form is approximably and unforgetfully typable insystem S .7.4. The Infinitary Subject Expansion Property.
In Sec. 6.4, we defined the deriva-tion P ′ resulting from a productive reduction path from any (approximable or not)derivation P . Things do not work so smoothly for subject expansion when we try todefine a good derivation P which results from a derivation P ′ typing the limit of aproductive reduction path. Indeed, approximability play a central role w.r.t. expansion.Assume that: • t → ∞ β t ′ . Say by means of the productive reduction path t = t b → β t b → β . . . t n b n → β t n +1 → β . . . with b n ∈ { , , } ∗ and ad ( b n ) −→ ∞ . • P ′ is an approximable derivation of C ′ ⊢ t ′ : T ′ . • We fix an arbitrary injection a
7→ ⌊ a ⌋ from N ∗ to N \ { , } .We want to show that there exists a derivation P concluding with C ′ ⊢ t : T ′ . We mayfind a complete proof in Appendix C.5.The main point is to understand how subject expansion works with a finite derivation f P ′ P ′ . The techniques of Sec. 3.5 can now be formally performed. We give a sketchof the proof.Since f P ′ is finite, for a large enough n , t ′ can be replaced by t n inside f P ′ , accordingto Lemma 28: we set f P n = f P ′ [ t n /t ′ ] , which is a finite derivation typing t n . But when t n is typed instead of t ′ , we can perform n steps of ⌊·⌋ -expansion (starting from f P n ) toobtain a finite derivation f P typing t .By monotonicity of uniform expansion (Lemma 19), the set D containing all the f P is a directed set. Then, by Theorem 4, we define P as the join of the f P when f P ′ rangesover Approx ( P ′ ) . This yields a derivation satisfying the desired properties. Proposition 37.
Assume t → ∞ β t ′ and P ′ (cid:3) C ′ ⊢ t ′ : T ′ .If P ′ is approximable, then there exists an approximable derivation P such that P (cid:3) C ′ ⊢ t : T ′ . Since infinitary subject reduction and expansion (for productive reduction paths)preserve unforgetful derivations, it yields our main characterization theorem :
Theorem 5.
Let t be a 001-term. Then t is weakly normalizing in Λ if and only if t is typable by means of an approximable unforgetful derivation, and if and only iff t ishereditarily head normalizing. Proof.
We follow the proof scheme of Fig. 3. • If t is typable by means of an approximable and unforgetful derivation, then t is HHNby Proposition 27. • If t is HHN, then t is obviously 001-WN. • If t is 001-WN, let t ′ be the 001-normal form of t . By Lemma 33, there is an approx-imable and unforgetful derivation P ′ concluding with P ′ (cid:3) C ⊢ t ′ : T for some C and T . By Proposition 37, there is an approximable derivation P (cid:3) C ⊢ t : T . Since P ′ isunforgetful, P also is. Remark 9.
Theorem 5 proves that hereditary head reduction is asymptotically completefor infinitary weak normalization: it asymptotically computes the 001-normal form of a001-term, whenever this term is 001-weakly normalizing or not.8.
Characterizing hereditary permutators in system S We now give our attention to TLCA Problem • In this section, we characterize the set of hereditary permutators in system S , i.e. wefind a set of S -types H such that t is a hereditary permutator iff there is a type T ∈ H such that ⊢ t : T is approximably derivable (Theorem 6). • Then, in Sec. 9, we extend system S so that there is a unique type ptyp characterizinghereditary permutators (Theorem 7).Let us start with a few words on the way we proceed for this latter part: Tat-suta [35] defines a type system with a family of type constants ptyp d (with d ∈ N ) suchthat t : ptyp d iff t is a hereditary permutator on d levels. Then, a term is a hereditary per-mutator iff t : ptyp d is derivable for all d ∈ N . However, given a hereditary permutator t , there is no explicit relation between the different typings t : ptyp d when d ranges over N . We reuse this idea here, but the notion of approximability hinted at above allows for-mally expressing the typing derivations concluding with t : ptyp d as extensions of thoseconcluding with t : ptyp d with d < d . Actually, we define a type constant ptyp , whichcan be assigned to hereditary permutators and to them only, which is the supremum ofall ptyp d i.e. such that a typing t : ptyp is an extension of typings t : ptyp d for all d ∈ N . Proper permutator pairs.
We now want to define the permutator pairs ( S, T ) (with S, T types of system S ) so that the judgments of the form x : (2 · S ) ⊢ t : T characterizethe x -HP ( i.e. there is an approximable P (cid:3) x : (2 · S ) ⊢ t : T iff t is an x -HP). Informally,if h = λx . . . x n .x h σ (1) . . . h σ ( n ) and h is typed with a type of arity n and x , . . . , x n arethe respective head variables of h , . . . , h n , then we have: • Type of h = (type of x ) → . . . → (type of x n ) → o ( eq ) • Type of x = (type of h σ (1) ) → . . . → (type of h σ ( n ) ) → o ( eq ) Since x , . . . , x n are the respective head variables of the headed hereditary permutators h , . . . , h n , the equations ( eq ) and ( eq ) , which are the golden thread of the proofs tocome in this section, suggest the following coinductive definition: EQUENCE TYPES AND INFINITARY SEMANTICS 45 ✬✫ ✩✪ x h b · p · p i S = T σ (1) → . . . → T σ ( n ) → o b C ⊢ t : T σ (1) @ C p − ⊢ t p − : T σ ( p − @ C p ⊢ t p : T σ ( p ) @ h b · p i : T σ ( p +1) → . . . → T σ ( p ) → o = S p +1 → . . . → S p → o λx p S p → . . . → S n → o λx h b i t : T = S → . . . → S n → o Arguments (part 1): • t i has type T σ ( i ) (proper) • so t i is free-headed • so the head var. of t i is one of the x j • so the head var. of t i is x σ ( i ) : S σ ( i ) Arguments (part 2): • C ⊎ . . . ⊎ C p = x : (2 · S ) , . . . , x p : (2 · S p ) • the head var. of t i is x : S σ ( i ) • so C i = x : (2 · S σ ( i ) ) . Figure 15.
Hereditary permutators and permutator pairs
Definition 38 (Permutators pairs) . • When o ranges over O (the set of type atoms), the set PP ( o ) of o -permutator pairs ( S, T ) , where S and T are S -types, is defined by mutual coinduction: ( S , T ) ∈ PP ( o ) , . . . , ( S n , T n ) ∈ PP ( o n ) o , . . . , o n , o pairwise distinct σ ∈ S n ((2 · T σ (1) ) → . . . → (2 · T σ ( n ) ) → o, (2 · S ) → . . . (2 · S n ) → o ) ∈ PP ( o ) • A pair ( S, T ) ∈ PP ( o ) is said to be proper , if, for all o ′ ∈ O , o ′ occurs at most oncein S and in T . The set of proper o -permutator pairs is denoted PPP ( o ) .Actually, we could allow other tracks than 2 in the definition ( e.g. , T = ( ℓ · S ) → . . . → ( ℓ n · S n ) → o would be fine), but it is more convenient to consider this restriction,so that we are relieved of the care of specifying the values of ℓ , . . . , ℓ n .The condition of properness is here to ensure that every term variable occurs atexactly one level deeper than its binder and to distinguish them from one another: it isa key point of the proof of Claim 2, because two distinct variables will have types withdistinct targets.The first implication of the characterization is quite natural to prove: Claim 1 (From hereditary permutators to permutator pairs) . Let y ∈ V and t be a y -head hereditary permutator. Then there is an approximable S -derivation P and aproper permutator pair ( S, T ) such that P (cid:3) y : (2 · S ) ⊢ h : T . Proof.
We skip the proof of this property (it is given in Appendix F.1). Observe thatDefinition 38 is designed so that it holds. The converse claim (Claim 2) is more difficultto prove and requires to be carefully verified.
Claim 2 (From permutator pairs to hereditary permutators) . Let t ∈ Λ be a 001-normal form, ( S, T ) a proper permutator pair and P a quantitative S -derivation typing t . • If P (cid:3) ⊢ t : (2 · S ) → T , then t is a hereditary permutator. • If P (cid:3) x : (2 · S ) ⊢ T , then t is a x -headed hereditary permutator.In both cases, supp ( P ) = supp ( t ) . Claim 3.
The proof uses the following observation: let us say that a HNF is free-headed when its head variable is free. If ( S, T ) is a proper permutator pair and t = λx . . . x p .x i t . . . t q (with i p ) is a HNF which is not free headed, then t cannot have the types S and T , since the target of the type of x i appears twice in thetype of t .We now start the proof, whose main stages are summarized in Fig. 15, in which weabusively write S instead of (2 · S ) . Assume S = (2 · T σ (1) ) → . . . → (2 · T σ ( n ) ) → o and T = (2 · S ) → . . . → (2 · S n ) → o . We first prove that the first point of the claim reducesto the second one.Since the context in ⊢ t : (2 · S ) → T is empty, the head variable of t is boundand the arity of t is > . Thus, t = λx .λx . . . x p .x t . . . t q with t , . . . , t q normal formswhose respective head variables are denoted y , . . . , y q . Note that: • x is x , . . . , x p or x since x is bound. • The type assigned to x is S . The respective types assigned to x , . . . x p are S , . . . , S p . • The common target type of T and the type of x is o .Since ( S, T ) is proper, o does not occur in S , . . . , S n , so necessarily, x = x and x : (2 · S ) ⊢ λx . . . x p .x t . . . t q : T is derivable by means of a quantitative derivation P ∗ . Thus, we are now in the second case. The type of x t . . . t q is both T σ ( q +1) → . . . → T σ ( n ) → o since x : S and S p +1 → . . . → S n → o since t : T , so p = q and for p + 1 i n , σ ( i ) = i and S i = T i . Let us denote o , . . . , o n the respective targettypes of S , . . . , S n . Since the type of x is S , the respective types of t , . . . , t p mustbe T σ (1) , . . . , T σ ( p ) . Moreover, since the “tail” of S is made of singleton sequence types (2 · T σ ( i ) ) , t , . . . , t p are typed once in P and the head variables y , . . . , y p of t , . . . t p arealso typed exactly once. In particular, P ∗ has a subderivation at depth n of the form: ax x : (2 · S ) ⊢ x : S P (cid:3) C ⊢ t : T σ (1) [2] app x : (2 · S ) , C ⊢ x t : (2 · S σ (2) ) → . . . → o . . . app . . . P p (cid:3) C p ⊢ t p : T σ ( p ) [2] app x : (2 · S ) , C ⊎ . . . ⊎ C p ⊢ x t . . . t p : T ′ where T ′ = T σ ( p +1) → . . . → T σ ( n ) → o = S p +1 → . . . → S n → o .Let us prove now that, for all i p , the unique argument derivation of x in P typing t i , that we denote P i , concludes with x σ ( i ) : (2 · S σ ( i ) ) ⊢ t i : T σ ( i ) .First, since t i is normal, t i = λz . . . z p ′ .y i u . . . u ′ q . Since t i : T σ ( i ) , t i is free-headedby the observation above. Moreover, the head variable of t i is typed once in P ∗ since t i is typed once. Thus, y i is one of the x , . . . , x p . The only possibility is y i = x σ ( i ) sincethe types of x , . . . , x p have pairwise distinct targets.Since P is quantitative and (2 · S i ) is a singleton sequence type, x , . . . , x p must beexactly typed once in P ∗ , the subderivation of P typing x t . . . t p . This entails that the ax -rule typing x σ ( i ) as the head variable of t i concludes with x σ ( i ) : (2 · S σ ( i ) ) ⊢ x σ ( i ) : S σ ( i ) .Thus, P i concludes with a judgment of the form x σ ( i ) : (2 · S σ ( i ) ) ⊎ C ′ i ⊢ t i : T σ ( i ) (2ndargument).Since ⊎ i p ( x σ ( i ) : (2 · S σ ( i ) ) ⊎ C ′ i ) = x : (2 · S ) , . . . , x p : (2 · S p ) , we deduce that C ′ i is empty for all i p (3rd argument). Thus, P i concludes with x σ ( i ) : (2 · S σ ( i ) ) ⊢ t i : T σ ( i ) .This easily implies that x : (2 · S ) ⊢ t σ − (1) : T , . . . , x p : (2 · S p ) ⊢ t σ − ( p ) : T p arejudgments of P ∗ . In particular, they are approximably derivable. Thus, t , . . . , t p also EQUENCE TYPES AND INFINITARY SEMANTICS 47 satisfy the hypothesis of point 2 of the claim. Since t = λx . . . x p .x t . . . t p , we concludeusing Definition 3.The two claims, which are valid for 001-normal forms, along with infinitary subjectreduction and expansion, give a type-theoretical characterization of hereditary permuta-tors in system S : Theorem 6.
Let t be a 001-term. Then t is a hereditary permutator iff ⊢ t : (2 · S ) → T is approximably derivable for some proper permutator pair ( S, T ) . Proof. • The implication ⇐ is given by Claim 2 and Proposition 37. • Implication ⇒ : let t be a hereditary permutator. By Definition 3, its Böhm tree isof the form λx.h where h is a normal x -headed hereditary permutator. By Claim 1,there is a proper permutator pair ( S, T ) and an approximable derivation P such that P (cid:3) x : (2 · S ) ⊢ h : T . By Proposition 37, ⊢ t : (2 · S ) → T is also approximablyderivable. 9. A unique type to rule them all
In this section, we explain how to enrich system S with type constants and typing rulesso that there is one type characterizing the set of hereditary permutators, as expected.In Sec. 8, we proved that a term t is a hereditary permutator iff it can be assigneda type of the form (2 · S ) → T where ( S, T ) is a proper permutator pair. To obtain aunique type for all the hereditary permutators, one idea is to collapse all the types ofthe form (2 · S ) → T (where ( S, T ) ranges over PPP ) into a type constant ptyp . However,since quotienting types may bring unsoundness ( e.g. , if o and o → o are identified, Ω becomes typable), one must then verify that the correctness and the completeness ofsystem S is preserved, and that the approximability criterion can be suitably extended.The main argument, given by Lemma 42, is that the notions of hereditary permutatorsand permutators pairs, which are infinitary, have arbitrarily big finite approximations,which are defined as truncations at some applicative depth d . Thus, we may expresshereditary permutators and permutator pairs as asymptotic limits of finite objects andadapt the general methods of system S .Our approach parallels that of Tatsuta [35], which uses a family of constants ptyp d ,with a few differences: in the finite restriction of our system, it is easier to deal withhereditary permutators (simplt because normalization is easier to prove in finite non-idempotent type systems), but of course we have to treat the infinitary typings and weconsider the constant ptyp , which is subsumed under all the ptyp d , which representhereditary permutators under level d .9.1. Permutator schemes.
Before presenting the system giving a unique type to allhereditary permutators, we must first explain how the typings of hereditary permutatorsare approximated in system S . Definition 39 (Permutator schemes) . Let d > . A term t is a x -headed (resp. closed)permutator scheme of degree d if its Böhm tree is equal to that of a hereditary permutatoron { b ∈ { , , } ∗ | ad ( b ) d } . The set of x -headed (resp. closed) permutators schemesof degree d is denoted PS d ( x ) (resp. PS d ). Equivalently, any term is in PS and t is in PS d +1 ( x ) if t → ∗ β λx . . . x n .x h σ (1) . . . h σ ( n ) where σ is a permutation and h i ∈ PS d ( x i ) for all i n . The sequence ( PS d ) isdecreasing, i.e. PS d ⊇ PS d +1 , and HP = ∩ d > PS d . Definition 40 (Permutator pairs of degree d ) . Let d ∈ N . • When o ranges over O , the set PP d ( o ) of o -permutator pairs of degree d ( S, T ) ,where S and T are S -types, is defined by induction on d : (( ) → . . . ( ) | {z } n → o, ( ) → . . . → ( ) | {z } n → o ) ∈ PP ( o )( S , T ) ∈ PP d − ( o ) , . . . , ( S n , T n ) ∈ PP d − ( o n ) o , . . . , o n , o pairwise distinct σ ∈ S n ((2 · T σ (1) ) → . . . → (2 · T σ ( n ) ) → o, (2 · S ) → . . . (2 · S n ) → o ) ∈ PP d ( o ) • A pair ( S, T ) ∈ PP d ( o ) is said to be proper if every type variable occurs at most oncein S and T . The set of proper permutator pairs of degree d is denoted PPP d .We can also see permutator pairs of degree d as truncation of permutator pairs: let U be a S -type or a sequence type and d ∈ N . We denote by ( U ) d the truncation of T at depth d , i.e. supp (( U ) d ) = supp ( U ) ∩ { c ∈ N ∗ | ad ( c ) d } and ( U ) d ( c ) = U ( c ) for all c ∈ supp (( U ) d ) . It is easy to check that ( U ) d is a correct type or sequencetype. We extend the notation to S -contexts. Note that, if d > , (( S k ) k ∈ K → T ) d =(( S k ) d − ) k ∈ K → ( T ) d and d = 1 , then (( S k ) k ∈ K → T ) d = ( ) → ( T ) . By inductionon d , this entails that, if ( S, T ) ∈ PPP , then (( S ) d , ( T ) d ) ∈ PPP d . Indeed, the base case ( d = 0) is obvious and if d > , T = (2 · S ) → . . . → (2 · S n ) → o and S = (2 · T σ (1) ) → . . . → (2 · T σ ( n ) ) → o with σ ∈ S n , ( S i , T i ) ∈ PPP for i n , then: • ( T ) d = (2 · ( S ) d − ) → . . . → (2 · ( S ) d − ) → o ( eq ) • ( S ) d = (2 · ( T σ (1) ) d − ) → . . . → (2 · ( T σ ( n ) ) d − ) → o ( eq ) so that, by Definition 40, (( S ) d , ( T ) d ) ∈ PPP d ( o ) . Proposition 41 (Characterizing permutation schemes) . Let d > and t be a 001-term.Then t ∈ PS d iff ⊢ t : (2 · S ) → T is approximably derivable for some ( S, T ) ∈ PPP d . Proof. ⇒ Straightforward induction on the structure of t . The proof is simpler than that ofClaim 1 because in the latter case, coinduction is difficult to handle. ⇐ The proof is the same as Claim 2, we also obtain that x σ ( i ) : (2 · S σ ( i ) ⊢ t i : T σ ( i ) arejudgments of P , except that ( S i , T i ) ∈ PPP d − instead of ( S i , T i ) ∈ PPP .It is not enough to know that a x -headed hereditary permutator t is approximablytypable in a judgment x : (2 · S ) ⊢ t : T with ( S, T ) ∈ PPP , which implies that T is the supremum of a direct family of finite types which be assigned to t : in order toprove soundness regarding quotienting, we must prove that this typing is the supremumof typings ensuring that t is a permutator scheme of degree d , i.e. by Proposition 41,one must type t with ( S d , T d ) ∈ PPP d for all d . The lemma below is the missing thirdingredient (along with Claims 1 and 2) of this article and will allow us to define inSec. 9.2 an extension of system S giving a unique type to hereditary permutators: Lemma 42 (Approximations and permutator pairs) . If P (cid:3) x : (2 · S ) ⊢ t : P is ap-proximable, where ( S, T ) ∈ PPP , then, for all d ∈ N , there is a finite P d P such that P d (cid:3) x : (2 · S d ) ⊢ t : T d with ( S d , T d ) ∈ PPP d . EQUENCE TYPES AND INFINITARY SEMANTICS 49
Proof.
Since ( ) does not occur in S and T , by Theorem 5, we can assume that t is a001-normal form without loss of generality. We then reason by induction on d .Let us present the argument informally (a formal proof is given in Appendix F.2).Say that t = λx . . . x p .x t . . . t p , S = T σ (1) → . . . → T σ ( n ) → o and T = S → . . . → S n → o (we omit some argument tracks). Intuitively, t : T with x : S and for i p , t i : T σ ( i ) is a hereditary permutator headed by x σ ( i ) : S σ ( i ) , as specified by Fig. 15. When wetruncate the type of t at applicative depth d , we have now t : ( T ) d with x : ( S ) d . But,by ( eq ) and ( eq ) , we must truncate the types of t , . . . , t p and x , . . . , x p at applicativedepth d − . Inductively, this requires that we truncate the types of the arguments of t , . . . , t p at applicative depth d − . By proceeding so, we obtain a finite derivation P d P concluding with x : (2 · ( S ) d ) ⊢ t : ( T ) d .9.2. System S hp . Let ptyp and ptyp d ( d ∈ N ) be a family of type constants. The setof S hp -types is defined by: T, S k ::= o k ptyp d k ptyp k ( S k ) k ∈ K → T System S hp has the same typing rules as system S with the addition of: x : (2 · S ) ⊢ t : T ( S, T ) ∈ PPP d hp d ⊢ λx.t : ptyp d x : (2 · S ) ⊢ t : T ( S, T ) ∈ PPP hp ⊢ λx.t : ptyp Thus, rule hp d allows assigning the constant ptyp d to any normal permutator schemeof degree d and rule hp assign the constant ptyp to any normal hereditary permutatorby Claims 1 and 2. Intuitively, ptyp = ptyp ∞ and we will make this idea more precisewith Definition 43. Note also that if t : ptyp d or t : ptyp , t cannot be applied to anargument u , even if t is an abstraction: the rules hp d / hp freeze the terms.The notions of support, bisupport, permutator pairs etc naturally extend to S hp . Wedefine an order on O ∪ {→ , ptyp } ∪ { ptyp d | d ∈ N } by o o , → → , ptyp d ptyp and ptyp d ptyp d ′ for d d ′ . Definition 43 (Approximation and Approximability in system S hp ) . • A S hp -derivation is finite when bisupp ( P ) is finite. • Let P and P be two S hp -derivations. We write P ∞ P ( P is an approximation of P ) if bisupp ( P ) ⊆ bisupp ( P ) and, for all p ∈ bisupp ( P ) , P ( p ) P ( p ) . If P isfinitary, we write P P . • Let P be a S hp -derivation. Then P is approximable if P is the supremum of its finiteapproximations.This extends Definition 20: for all S -derivations P , P is approximable for system S iff it is approximable for system S hp . We first notice that rules hp ( d ) are invertible forHNF: Lemma 44 (Inverting rules ( hp d ) for head normal forms) . Let t be a HNF. If ⊢ t : ptyp d (resp. P (cid:3) ⊢ t : ptyp ) is approximably derivable, then t = λx.t with x : (2 · S ) ⊢ t : T approximably derivable, for some ( S, T ) ∈ PPP d (resp. ( S, T ) ∈ PPP ). Proof.
We consider the case ptyp (the case ptyp d is similar), i.e. we assume that P ′ (cid:3) ⊢ t : ptyp is approximable. For one, t = x t . . . x n is impossible, because we would have C ( x ) = ( ) since the head variable x is free in x t . . . t n . So, t is an abstraction, i.e. t = λx.t and thus, the last rule of P is either abs , hp d , hp . But it is neither abs ( t would have an arrow type and not ptyp ) nor hp d ( t would have type ptyp d ), so it is hp and thus, P ′ is of the form: P ′ = P (cid:3) x : (2 · S ) ⊢ t : T ( S, T ) ∈ PPP hp ⊢ t : ptyp Since P ′ is approximable, P also is.All is now in place to obtain the expected properties of system S hp : Lemma 45 (Characterizing normal hereditary permutators) . Let t be a 001-normalform. • t ∈ PS d iff ⊢ t : ptyp d is approximably derivable. • t ∈ HP iff ⊢ t : ptyp is approximably derivable. Proof.
The two points are handled similarly. We do not prove the first one, which usesProposition 41: • If t = λx.h is a HP, then, by Claim 1, there is ( S, T ) ∈ PPP and P a S -derivation suchthat P (cid:3) x : (2 · S ) ⊢ h : T . We then set: P ′ = P (cid:3) h : (2 · S ) ⊢ p : T hp ⊢ t : ptyp By Lemma 42, for all d ∈ N , there is a finite S -derivation P d P such that P d (cid:3) x :(2 · S d ) ⊢ h : T d with ( S d , T d ) ∈ PPP d and P = sup d P d . We then set: P ′ d = P d (cid:3) x : (2 · S d ) ⊢ h : T d hp d ⊢ t : ptyp d By construction, sup d P ′ d = P ′ . • Conversely, assume that P ′ (cid:3) ⊢ t : ptyp is approximable. By Lemma 44, P ′ concludeswith the hp -rule, so P ′ is of the form: P ′ = P (cid:3) x : (2 · S ) ⊢ t : T ( S, T ) ∈ PPP hp ⊢ t : ptyp Let d ∈ N . Since P ′ is the supremum of its finite approximations, there is a finiteapproximation P ′ P ′ concluding with ⊢ t : ptyp or ⊢ t : ptyp d ′ with d ′ > d . Thus, t ∈ PS d ′ ⊆ PS d or t ∈ HP . This proves that t ∈ ∩ d > PS d = HP . Soundness.
Let us now prove soundness of system S hp . It is routine work in non-idempotent type systems: we only use structural induction.We define the size sz ( P ) of a finite S hp -derivation P by induction: the size of P is equal to 1 plus the sum of the size of all its depth 1 subderivations. Thus, sz ( P ) isequal to the number of judgments in P . Lemma 46 (Substitution) . Let P (cid:3) C, x : ( S k ) k ∈ K ⊢ r : T and ( P k (cid:3) D k ⊢ s : S k ) k ∈ K be finite S hp -derivation (in particular, K is finite) such that C ′ := C ⊎ ( ⊎ k ∈ K D k ) isdefined (there is no track conflict).Then, there is a finite S hp -derivation P such that P (cid:3) C ′ ⊢ r [ s/x ] : T and sz ( P ) = sz ( P ) + (+ k ∈ K sz ( P k )) . Proof.
By induction P . Lemma 47 (Root Reduction) . Let P (cid:3) C ⊢ ( λx.r ) s : T be a finite S hp -derivation. Thenthere is a finite S hp -derivation P ′ (cid:3) C ⊢ r [ s/x ] : T such that sz ( P ′ ) < sz ( P ) . The case P ′ (cid:3) ⊢ t : ptyp is possible: there are finite HP and PPP, e.g. , λx.x and ( o, o ) . EQUENCE TYPES AND INFINITARY SEMANTICS 51
Proof.
This is a straightforward consequence of Lemma 46.Notice that in the above lemmas, r and s are not assumed to be finite: only thederivations are. Again, the strict decrease comes from the fact that reduction destroysone abs - and one app -rule and possibly k > axioms. Lemma 48 (Weighted Head Reduction (finite case)) . Let P (cid:3) C ⊢ t : T be a finite S hp -derivation and assume t → h t ′ . Then there is a finite S hp -derivation P ′ (cid:3) C ⊢ t ′ : T such that sz ( P ′ ) < sz ( P ) . Proof.
By induction on t → h t ′ (which is an inductive relation). The base case is justLemma 47.Now, we may prove: Lemma 49 (Soundness of system S hp ) . If t is approximably typable in system S hp , then t is head normalizing. Proof. If t is approximably typable, there is a finite S hp -derivation P (cid:3) C ⊢ t : T . If t isa HNF, we are done. In the other case, t → h t ′ for some t ′ .Since sz ( P ) ∈ N and N is well-founded, Lemma 48 entails that head reductionterminates on t . Corollary 50. If ⊢ t : ptyp is approximably derivable, then t is infinitary weaklynormalizing. Proof.
By Lemma 49, t reduces to a HNF t ′ . By subject reduction, ⊢ t ′ : ptyp is alsoapproximably derivable. Then, Lemma 44 entails that t = λx.t and x : (2 · S ) ⊢ t : T isapproximably derivable in system S for some t and permutation pair ( S, T ) . Since thislatter judgment is ( ) -free, Theorem 5 entails that t is WN ∞ . Thus, t also is WN ∞ . Remark 10.
Notice that, to prove Corollary 50, we do not need using infinitary subjectreduction in system S hp (which we state below), but only its restriction in system S .More generally, the dynamic properties of system S are preserved in system S hp . Thefollowing statements generalize Proposition 31 and 37: Proposition 51 (Infinitary subject reduction) . If t → ∞ t ′ and P (cid:3) C ⊢ t : T is anapproximable S hp -derivation, then there exists an approximable derivation P ′ (cid:3) C ⊢ t ′ : T . Proof.
The proof does not significantly differ from that motivating Proposition 31.
Proposition 52 (Infinitary subject expansion) . If t → ∞ t ′ and P ′ (cid:3) C ⊢ t ′ : T is anapproximable S hp -derivation, then there exists an approximable derivation P (cid:3) C ⊢ t : T . Proof.
See Appendix C.5.We now give a positive answer to TLCA Problem
Theorem 7 (Characterizing hereditary permutators with a unique type) . Let t ∈ Λ .Then t is a hereditary permutator iff ⊢ t : ptyp is approximably derivable in system S hp . Proof. ⇒ If t is a HP, let t ′ be its 001-NF. By Lemma 45, there is an approximable derivation P ′ (cid:3) ⊢ t ′ : ptyp . By Proposition 52, there is P (cid:3) ⊢ t ′ : ptyp approximable. ⇐ Given by Corollary 50.
Conclusion
We have provided two characterizations, one of the set
HHN of hereditary head normal-izing terms (the terms whose Böhm trees does not contain ⊥ ) and another of the set HP of hereditary permutators (the terms which are invertible under composition up to βη -conversion), giving the latter a unique type. These characterizations are stated inTheorems 5 (answer to Klop Problem) and 7 (answer to TLCA Problem HHN and HP were previously proved non -recursively enumerable byTatsuta [34, 35], and thus impossible to characterize in an inductive type system.To obtain type-theoretical characterizations of these sets, we had then to built a coinductive type system, system S , which allows characterizing HHN , and an extension ofthis system, system S hp , which allows characterizing HP with a unique type.The two characterizations are based on intersection type theory (whose main ideaswe presented in the first part of the paper), which allows not only soundness (the impli-cation: if a term is typable, then it has some expected semantic property) as in mosttype systems, but also completeness (the converse implication: if a term has some ex-pected semantic property, then it is typable). More precisely, our characterization uses non-idempotent intersection type theory, introduced by Gardner and de Carvalho [14,17].System S ans S hp enjoy the main properties of non-idempotent intersection typesystem: they are quantitative (in the finite-case), syntax-directed, relevant and have asimple reduction combinatorics. Their main novel features are: • They are infinitary, meaning that types and derivations are coinductively generated. • They have a validity condition called approximability . An infinitary derivation isapproximable when it is the join of its finite approximations . Approximability is usedto discard unsound coinductive derivations. • They are based on sequence types , which are annotated multisets allowing tracking and retrieving determinism . Sequence types are necessary to define approximability.Besides, system S hp implicitly uses some quotienting so that it assigns to hereditarypermutators a unique type. This quotienting is proved to be sound.These contributions show that non-idempotent intersection type theory extends toinfinitary settings. It paves the way for other semantic characterizations in other in-finitary settings, in particular while considering Lévy-Longo trees and Berarducci trees,which provide semantics refining Böhm trees.It also seems that approximability, which is defined here in terms of directed sets,should admit a categorical generalization and could help define infinitary models in amore generic way. References [1] Patrick Bahr. Strict ideal completions of the lambda calculus. In
FSCD 2018, July 9-12, Oxford ,pages 8:1–8:16, 2018.[2] Henk Barendregt.
The Lambda-Calculus: Its Syntax and Sematics . Ellis Horwood series in comput-ers and their applications. Elsevier, 1985.[3] Henk Barendregt, Mario Coppo, and Mariangiola Dezani-Ciancaglini. A filter lambda model andthe completeness of type assignment.
Bulletin of Symbolic Logic , 48:931–940, 1983.[4] A. Berarducci. Infinite lambda-calculus and non-sensible models.
Lecture Notes in Pure and AppliedMathematics , 180:339–377, 1996.[5] Alessandro Berarducci and Benedetto Intrigila. Some new results on easy lambda-terms.
Theor.Comput. Sci. , 121(1&2):71–88, 1993.[6] Jan A. Bergstra and Jan Willem Klop. Invertible terms in the lambda calculus.
Theor. Comput.Sci. , 11:19–37, 1980.[7] Antonio Bucciarelli, Alberto Carraro, Giordano Favro, and Antonino Salibra. Graph easy sets ofmute lambda terms.
Theor. Comput. Sci. , 629:51–63, 2016.
EQUENCE TYPES AND INFINITARY SEMANTICS 53 [8] Antonio Bucciarelli, Delia Kesner, and Daniel Ventura. Non-idempotent intersection types for thelambda-calculus.
Mathematical Structures in Computer Science. , 2017.[9] Daniel De Carvalho.
Sémantique de la logique linéaire et temps de calcul . PhD thesis, UniversitéAix-Marseille, November 2007.[10] Mario Coppo and Mariangiola Dezani-Ciancaglini. A new type assignment for lambda-terms.
Archive for Mathematical Logic , 19:139–156, 1978.[11] Mario Coppo and Mariangiola Dezani-Ciancaglini. An extension of the basic functionality theoryfor the λ -calculus. Notre Dame Journal of Formal Logic , 4:685–693, 1980.[12] Haskell B. Curry and Robert Feys.
Combinatory Logic , volume I. North-Holland Co., Amsterdam,1958. (3rd edn. 1974).[13] Lukasz Czajka. A coinductive confluence proof for infinitary lambda-calculus. In
Rewriting andTyped Lambda Calculi - Joint International Conference, RTA-TLCA, Vienna, Austria, July 14-17 ,pages 164–178, 2014.[14] Daniel de Carvalho. Execution time of λ -terms via denotational semantics and intersection types. Math. Struct. Comput. Sci. , 28(7):1169–1203, 2018.[15] Mariangiola Dezani-Ciancaglini. Characterization of normal forms possessing inverse in the lambda-beta-eta -calculus.
Theor. Comput. Sci. , 2(3):323–337, 1976.[16] Jörg Endrullis, Helle Hvid Hansen, Dimitri Hendriks, Andrew Polonsky, and Alexandra Silva. Acoinductive framework for infinitary rewriting and equational reasoning. In
RTA, Warsaw , 2015.[17] Philippa Gardner. Discovering needed reductions using type theory. In
TACS, Sendai , 1994.[18] Gerhard Gentzen. Untersuchungen über das logische schließen.
Mathematische Zeitschrift ,(39):405–431, 1934.[19] Jean-Yves Girard.
Interprétation fonctionnelle et élimination des coupures dans l’arithmétiqued’ordre supérieur . PhD thesis, Université Paris 7, 1972.[20] Jean-Yves Girard. Linear logic.
Theoretical Computer Science , 50:1–102, 1987.[21] Jean-Yves Girard, Yves Lafont, and Paul Taylor.
Proofs and Types . Cambridge University Press,1990.[22] Felix Joachimski. Confluence of the coinductive [lambda]-calculus.
Theor. Comput. Sci. , 311(1-3):105–119, 2004.[23] Richard Kennaway, Jan Willem Klop, M. Ronan Sleep, and Fer-Jan de Vries. Infinitary lambdacalculus.
Theor. Comput. Sci. , 175(1):93–125, 1997.[24] J. W. Klop, Marc Bezem, and R. C. De Vrijer, editors.
Term Rewriting Systems . CambridgeUniversity Press, New York, NY, USA, 2001.[25] Naoki Kobayashi and C.-H. Luke Ong. A type system equivalent to the modal mu-calculus modelchecking of higher-order recursion schemes. In
Proceedings of the 24th Annual IEEE Symposiumon Logic in Computer Science, LICS, 11-14 August 2009, Los Angeles, CA, USA , pages 179–188.IEEE Computer Society, 2009.[26] Jean-Louis Krivine.
Lambda-calculus, types and models . Ellis Horwood series in computers and theirapplications. Masson, 1993.[27] Jean-Jacques Lévy. An algebraic interpretation of equality in some models of the lambda calculus.
Lambda Calculus and Computer Science Theory ( LNCS No. 37) , 1975.[28] G. Longo. Set-theoretical models of lambda calculus: Theories, expansions and isomorphisms.
An-nals of Pure and Applied Logic , 1983.[29] Giulio Manzonetto.
Lambda Calculus, Linear Logic and Symbolic Computation . Mémoired’habilitation à diriger des recherches, Université Paris-Nord, 2017.[30] Betti Venneri Mario Coppo, Mariangiola Dezani-Ciancaglini. Functional characters of solvableterms.
Mathematical Logic Quarterly , 27:45–58, 1981.[31] Damiano Mazza. An infinitary affine lambda-calculus isomorphic to the full lambda-calculus. In
Pro-ceedings of the 27th Annual IEEE Symposium on Logic in Computer Science, LICS 2012, Dubrovnik,Croatia, June 25-28, 2012 , pages 471–480. IEEE Computer Society, 2012.[32] Luigi Santocanale. A calculus of circular proofs and its categorical semantics. Technical ReportRS-01-15, BRICS, Dept. of Computer Science, University of Aarhus, May 2001.[33] William W. Tait. Intensional interpretations of functionals of finite type I.
J. Symb. Log. , 32(2):198–212, 1967.[34] Makoto Tatsuta. Types for hereditary head normalizing terms. In
FLOPS, Ise, Japan, April 14-16 ,pages 195–209, 2008.[35] Makoto Tatsuta. Types for hereditary permutators. In
LICS, 24-27 June, Pittsburgh , pages 83–92,2008.[36] Silvio Valentini. An elementary proof of strong normalization for intersection types.
Arch. Math.Log. , 40(7):475–488, 2001. [37] Steffen van Bakel. Intersection type assignment systems.
Theor. Comput. Sci. , 151(2):385–435,1995.[38] Pierre Vial. Infinitary intersection types as sequences: a new answer to Klop’s problem. In
LICS,Reykjavik , 2017.[39] Pierre Vial.
Non-Idempotent Typing Operator, beyond the Lambda-Calculus . Phd thesis, UniversitéSorbonne Paris-Cité, 2017, available on .[40] Pierre Vial. Every λ -term is meaningful in the infinitary relational model. In LICS, Oxford, July9-12 , 2018.[41] Pierre Vial. Sequence types for hereditary permutators. In
FSCD, Dortmund, June 25-28 , 2019.
EQUENCE TYPES AND INFINITARY SEMANTICS 55
Contents
1. Presentation 1Structure of the paper. 2Reading guidelines 22. Introduction 32.1. Normalization and Reduction Strategies 3Evaluation strategies 4Normalization 4The Standardization Theorem and Reduction Strategies 42.2. Infinitary Normalization and Böhm Trees 5Confluence in the infinitary λ -calculus 62.3. Intersection Types 7Subject reduction and expansion 82.4. Intersection from the syntax perspective 9Partial typings. 10Non-idempotent intersection 10Additional properties 122.5. Klop’s Problem and Hereditary Permutators 132.6. Tools and Difficulties 132.7. Sequence and tracking 142.8. Approximability 153. Finite Intersection and Infinite Terms 163.1. Infinite Lambda Terms 163.2. The computation of Böhm trees 17Infinitary convergence. 183.3. The Finitary Type System R and Unforgetfulness 183.4. Infinitary subject reduction and expansion for finite derivations 213.5. Roadmap to solve Klop’s Problem 233.6. Problems with infinitary typing and how to solve them 254. Tracking types in derivations 26General notations 264.1. Rigid Types 274.2. Rigid Derivations 285. Statics and Dynamics 305.1. Bipositions and Bisupport 305.2. Quantitativity and Coinduction 315.3. One Step Subject Reduction and Expansion 315.4. Safe Truncations of Typing Derivations 335.5. Proving Subject Reduction 346. Approximable Derivations and Unforgetfulness 356.1. The Lattice of Approximation 356.2. Approximability 366.3. Unforgetfulness 376.4. The Infinitary Subject Reduction Property 387. Typing Normal Forms and Subject Expansion 407.1. Support Candidates 407.2. Natural Extensions 417.3. Approximability 427.4. The Infinitary Subject Expansion Property 438. Characterizing hereditary permutators in system S S hp Π ′ n and Π ′ S hp n R EQUENCE TYPES AND INFINITARY SEMANTICS 57
Appendix A. Expanding the Π ′ n and Π ′ In this Appendix, we build the derivation Π n which are discussed in Sec. 3.5 and 3.6We define a family ( ρ n ) n > by induction: • ρ = [ ] → o • ρ n +1 = [ ρ k ] k n → o Thus, a term t typed with ρ n +1 can be fed with an argument u typed with ρ , . . . , ρ n togive the term t u of type o .We also set, for all n > , Γ n = x : ([[ o ] → o ] n − + [ ] → o ) .We set: Ψ = f : [[ ] → o ] ⊢ f : [ ] → of : [[ ] → o ] ⊢ f ( x x ) : of : [[ ] → o ] ⊢ ∆ f : ρ and, for all k > : Ψ k = f : [[ o ] → o ] ⊢ f : [ o ] → o x : [ ρ k − ] ⊢ x : ρ k (cid:0) x : [ ρ i ] ⊢ x : ρ i (cid:1) i
For all n > , the derivation Π n is obtained from Π nn by n steps of subjectexpansion.The last part of this appendix is more informal. We explain how the derivation Π ′ typing f ω can be expanded into a derivation Π typing Y f by taking the infinitereduction sequence Y f → ∞ f ω backwards. The derivations Π n play a key role and Π will be obtained by taking their join them. First, we observe that, for all k < n : • The type ρ k is a truncation of ρ n since [ ρ i ] i
Figure 16.
Expanding the Π kn and Π ′ EQUENCE TYPES AND INFINITARY SEMANTICS 59 ρ n for some great enough n ). We define Ψ = f : [[ o ] → o ] ⊢ f : [ o ] → o x : [ ρ ] ⊢ x : ρ (cid:0) x : [ ρ ] ⊢ x : ρ (cid:1) ω x : [ ρ ] ω ⊢ x x : of : [[ o ] → o ]; x : [ ρ ] ω ⊢ f ( x x ) : of : [[ o ] → o ] ⊢ ∆ f : ρ Then Ψ is the “infinitary join” of the Ψ n , notably because the ρ is the infinitary join ofthe ρ n . Π = Ψ n (cid:3) f : [[ o ] → o ] ⊢ ∆ f : ρ (Ψ k (cid:3) f : [[ o ] → o ] ⊢ ∆ f : ρ ) ω Γ ⊢ Y f : o We notice likewise that, intuitively, Π is the “infinitary join” of the Π n , and Π conclude,as expected, with Γ ⊢ Y f : o . Appendix B. Lattices of (finite or not) approximations
In this Appendix, we generalize Theorem 4 to S hp and we prove it, i.e. we show that theset of S hp -derivations typing a given term t is a d.c.p.o. Notation. • Let P be a S hp -derivation. The set of approximations of P is denoted Approx ∞ ( P ) and the set of finite approximations of P is denoted Approx ( P ) . • We write ptyp ∞ , PPP ∞ and hp ∞ and ptyp , PPP and hp . This allows us to treat thespecific constants, rules and notions of system S hp uniformly, whether they are finitaryor not. Definition 53. If U = F → T , we set Tl ( U ) = F and Hd ( U ) = T ( tail and head ).We define now approximations for types, contexts and context sequences. Definition 54 (Approximations of context sequences) . • Let T and T ′ two S hp -types. We write T T ′ if supp ( T ) ⊆ supp ( T ′ ) and for all a ∈ supp ( T ) , T ( a ) T ′ ( a ) . • Let ( S k ) k ∈ K and ( S ′ k ) k ∈ K ′ . We write ( S k ) k ∈ K ( S ′ k ) k ∈ K ′ if K ⊆ K ′ and for all k ∈ K , S k S ′ k . • Let C and C ′ two S hp -contexts. We write C C ′ if, for all x ∈ V , C ( x ) ∞ C ′ ( x ) . • Let ( C j ) j ∈ J and ( C ′ j ) j ∈ J ′ two context families. We write ( C j ) j ∈ J ∞ ( C ′ j ) j ∈ J ′ if J ⊆ J ′ and, for all j ∈ J , C j ∞ C ′ j .We say a family ( C j ) j ∈ J of contexts is compatible context family when ⊎ k ∈ K C k is defined (no track conflict). We easily prove: Lemma 55.
In system S hp , the sets of types, sequence types, contexts and compatiblecontext families are c.p.o.Moreover, to prove that the set of S hp -derivations typing a same term are also ac.p.o., we need: Lemma 56. • If ( P i ) i ∈ I is a directed family of S hp -derivations and P = sup i ∈ I P i , then supp ( P ) = ∪ i ∈ I supp ( P i ) , bisupp ( P ) = ∪ i ∈ I bisupp ( P i ) . Moreover, if a ∈ supp ( P ) , then P ( a ) =sup i ∈ I | a ∈ supp ( P i ) P i ( a ) . • If ( k i · T i ) i ∈ I is a direct family of singleton sequence types, then, for all i ∈ I , k i = k for some k ∈ N \ { , } , ( T i ) i ∈ I is directed and sup i ∈ I ( k i · T i ) = ( k · sup i ∈ I T i ) . • Let ( T i ) i ∈ I , ( T ′ i ) i ∈ I and ( F i ) i ∈ I a directed families of S hp -types, of S hp -arrow types andof S hp -sequence types respectively. – If ∀ i ∈ I , Hd ( T ′ i ) = T i , then Hd (sup i ∈ I T ′ ( i )) = sup i ∈ I T ( i ) – If ∀ i ∈ I , Tl ( T ′ i ) = F i , then Tl (sup i ∈ I T ′ ( i )) = sup i ∈ I F i . • If ( S i ) i ∈ I and ( T i ) i ∈ I are directed families such that ( S i , T i ) ∈ PPP d i (for some d i ) forall ii ∈ I , S = sup i ∈ I S i , and T = sup i ∈ I T i , then ( S, T ) ∈ PPP d for d = sup i ∈ I d i ∈ N ∪ {∞} . • Let ( C i ) i ∈ I be a directed sequence of contexts and x ∈ V . Then have (sup i ∈ I C i )( x ) =sup i ∈ I ( C i ( x )) . • Let (( C ik ) k ∈ K i ) i ∈ I a directed family of compatible context families. Then ( C k ) k ∈ K , thesupremum of this family, is a sequence of compatible context such that K = ∪ i ∈ I K i ,for all k ∈ K , C k = sup { i ∈ I | k ∈ K i } C ik and ⊎ k ∈ K C k = sup i ∈ I ( ⊎ k ∈ K i C ik ) .B.1. Meets and Joins of Directed Derivations Families.Lemma 57. . Let ( P i ) i ∈ I be a directed (and non-empty) family of S hp -derivations typingthe same term t .We define P by bisupp ( P ) = ∪ i ∈ I bisupp ( P i ) and P ( p ) = sup i ∈ I P i ( p ) .Then P is a S hp -derivation and we write P = sup i ∈ I P i .If I is finite and all the P i are, then P is also finite. Proof.
We set A i = supp ( P i ) , B i = bisupp ( P i ) for all i ∈ I , A = ∪ i ∈ I A i , B = bisupp ( P i ) , so that B = dom ( P ) . For all a ∈ A , let I a denote the set { i ∈ I | a ∈ supp ( P i ) } . We write T i and C i instead of T P i and C P i and so on.Let us check now that P is a correct S hp -derivation (such that A = supp ( P ) ): thisis actually enough to prove the whole statement since, if P is correct, any derivation P ′ > P i for all i ∈ I will clearly verify P ′ > P by definition of .For all a ∈ A , let C ( a ) denote the restriction of P ( a ) on V × N ∗ and let T ( a ) denotethe restriction of P on N ∗ . Thus, we have T ( a ) = sup i ∈ I a T i ( a ) and C ( a ) = sup i ∈ I a C i ( a ) .By Lemma 55, for all a ∈ A , T ( a ) and C ( a ) are a S hp -type and context respectively.For any a ∈ A such that t ( a ) = @ , we set AT ( i ) = { k > | a · k ∈ A } , i.e. AT ( i ) = ∪ i ∈ I ArgTr P i ( a ) ( AT ( i ) is simply ArgTr P ( a ) , but this latter notation is notproved to be licit yet, as long as P is not proved to be a correct S hp -derivation!).We prove the correctness of P according to which constructor is t ( a ) , for any a ∈ A . • Case t ( a ) = x . Let i, i ′ ∈ I such that a ∈ supp ( P i ) and P i P i ′ . Thus, P i ( a ) and P i ′ ( a ) have the form: P i ( a ) = x : k i · T i ( a ) ⊢ x : T i ( a ) ( i ∈ { i, i ′ } ) with k i = tr i ( a ) and C i ( a ) = x : k i · T i ( a ) . Since P i P i ′ , k i = k ′ i .By Lemma 56, C i ( a ) = sup i ∈ I ( tr i ( a ) · T i ( a )) = k · , where k is defined by tr i ( a ) for any i ∈ I such that a ∈ supp ( P ) . Thus, P ( a ) = x : k · T ( a ) ⊢ x : T ( a ) , i.e. a is a correctaxiom node in P . • Case t ( a ) = λx . Then t | a = λx.u for some u . Let i, i ′ ∈ I such that a ∈ supp ( P i ) and P i P i ′ . First note that one of the following cases holds (a) T i ( a ) is an arrow type(this implies that T i ( a )(0) = → and that P i is an ( abs ) -node) (b) T i ( a ) = ptyp d i (for d i ∈ N ∪ {∞} ) (and a is an ( hp d i ) -node in P i ).(a) T i ( a )(0) = → . Since P i P i ′ , we also have T i ′ ( a )(0) = → . Thus, P i ( a ) and P i ′ ( a ) have the form: P i ( a ) = C i ( a · ⊢ u : T i ( a · absC i ( a ) ⊢ λx.u : C i ( a · x ) → T i ( a ·
0) ( i ∈ { i, i ′ } ) EQUENCE TYPES AND INFINITARY SEMANTICS 61 with C i ( a ·
0) = C i , x : C i ( a · , T i ( a ) = C i ( a · → T i ( a · . Since P i P i ′ , wehave C i ( a ) C i ′ ( a ) , T i ( a · T i ′ ( a · and C i ( a · C i ′ ( a · x ) .By Lemma 56, the above equalities implies that C ( a ·
0) = C ( a ) , x : C ( a · x ) and T ( a ) = C ( a · → T ( a · . Thus, a is a correct abs -node in P .(b) T i ( a ) = ptyp d i . Since P i P i ′ , T i ′ ( a ) = ptyp d ′ for some d ′ i ∈ N ∪ {∞} with d i d ′ i and P i ( a ) , P i ′ ( a ) have the form: P ( a ) = C ( a · ⊢ u : T ( a ·
0) ( C i ( a · x ) , T i ( a · ∈ PPP d i hp d i C ( a ) ⊢ λx.u : ptyp d i with T i ( a ) = ptyp d i , C i ( a ·
0) = C i ( a ) , x : C i ( a · x ) . Since P i P i ′ , we have ptyp d i ptyp d i ′ , C i ( a ) C i ′ ( a ) and C i ( a · x ) C i ′ ( a · .By Lemma 56, the above equalities implies that C ( a ·
0) = C ( a ) , x : C ( a · x ) , ( C ( a · x ) , T ( a · ∈ PPP d for some d and T ( a ) = ptyp d (for this same d ). Thus, a is a correct hp d -node in P . • Case t ( a ) = @ : then t | a = u v for some u and v . Moreover, P i ( a ) and P i ′ ( a ) have theform: P i ( a ) = C i ( a · ⊢ u : T i ( a ·
1) ( C i ( a · k ) ⊢ v : T i ( a · k ) [ k ]) k ∈ ArgTr Pi ( a ) appC i ( a ) ⊢ u v : T i ( a ) where Hd ( T i ( a · T i ( a ) , Tl ( T i ( a · k · T i ( a · k )) k ∈ ArgTr Pi ( a ) and C i ( a ) = ⊎ k ∈{ }∪ ArgTr Pi C i ( a · k ) . Since P i P i ′ , T i ( a · T i ′ ( a · and ( C i ( a · k )) { }∪ ArgTr Pi ( a ) ( C i ′ ( a · k )) { }∪ ArgTr Pi ′ ( a ) .By Lemma 56, the above equalities implies that Hd ( T ( a · T ( a ) , Tl ( T ( a · ⊎ k ∈ AT ( a ) ( k · T ( a · k )) and C ( a ) = ⊎ k ∈{ }∪ AT ( a ) C ( a · k ) . Thus, a is a correct app -nodein P . Lemma 58.
Let ( P i ) i ∈ I be a non-empty family of S hp -derivations typing the same term t , such that ∀ i, j ∈ I, ∃ P ∈ Deriv , P i , P j ∞ P .We define P by bisupp ( P ) = ∩ i ∈ I bisupp ( P i ) and P ( p ) = inf i ∈ I P i ( p ) for any i ∈ I .Then, P defines a correct derivation (that is finite if one of the P i is finite). We write P = inf i ∈ I P i . Proof.
We prove this in the same fashion as Lemma 57.The previous lemmas define the join and the meet of derivations (under the samederivation) as their set-theoretic union and intersection. More precisely, the statementbelow (valid for system S hp ) entails Theorem 4: Theorem.
The set of S hp -derivations typing a same term t endowed with ∞ is adirected complete semi-lattice. • If D is a directed set of derivations typing t : – The join sup D of D is the function P defined by dom ( P ) = ∪ P ∗ ∈ D bisupp ( P ∗ ) and P ( p ) = sup P ∗ ∈ D P ∗ ( p ) , which also is a derivation. – The meet inf D of D is the function P defined by dom ( P ) = ∩ P ∗ ∈ D bisupp ( P ∗ ) and P ( p ) = inf P ∗ ∈ D ( p ) , which also is a derivation. • If P is a S hp -derivation typing t , Approx ∞ ( P ) is a complete lattice and Approx ( P ) isa lattice. Appendix C. Reduction and Approximability
In this Appendix, we prove that (1) approximability in system S hp is stable under reduc-tion and expansion (Lemma 22), and (2) the infinitary subject expansion property.We start with a few lemmas which are useful to obtain these results. A technicaldifficulty is that (1) approximability (Definitions 20 and 43) pertains to both right andleft bipositions and (2) residuation is (naturally) defined only for right bipositions, sothat, when P b → β P ′ , there is no natural way to relate left bipositions of P and P ′ .The solution to overcome this is to observe that every left biposition in a S hp -derivationis “intrinsically” related to a right biposition: this will be captured by the notion of equinecessity below. Thus, approximability can be restated while handling only byright bipositions (Definition 14).In this appendix, right bipositions play a particular role, so we set: Notation.
Let P be a S hp -derivation. The set of right bipositions in P is denoted bisupp R ( P ) ( i.e. bisupp R ( P ) = bisupp ( P ) ∩ N ∗ × N ∗ ).C.1. Quasi-Residuation in System S hp . In this section, we define the notion of quasi-residuation in system S hp . This extends Sec. 5.3. Hypotheses.
For the remainder of this section, we assume that P (cid:3) C ⊢ t : T isa S hp -derivation and t | b = ( λx.r ) s , t b → β t ′ , so that t ′ | b = r [ s/x ] . We follow Fig. 12and we reuse some notations of Sec. 5.3, 5.4 and Sec. 5.5, which do not need to bechanged for system S hp , including Rep P ′ ( b ) , Tr λP ( a ) . We set, for all a ∈ Rep P ′ ( b ) , K ( a ) = { tr P ( α ) | α ∈ Ax Pa · ( x ) } . If P is quantitative, K ( a ) = Tr λP ( a ) holds.For all k ∈ K ( a ) , we also denote by a k the unique α ∈ N ∗ such that a · · α ∈ Ax λ ( a ) and tr P ( a · · α ) = k , i.e. a · · a k is the unique axiom assigning track k to x above a (note that a k implicitly depends on P ). Residuation.
Let α ∈ supp ( P ) , we define Res b ( α ) case-wise. • If α > b , Res b ( α ) = { α } . • If α = a · · · α for some a ∈ Rep P ( b ) and t ( a ) = x , Res b ( a ) = a · α • If α = a · k · α for some α ∈ Rep P ( b ) and k ∈ K ( a · , then Res b ( α ) = a · a k · α • In any other case,
Res b ( a ) is not defined. Right bipositions.
Let ( α, γ ) ∈ supp ( P ) . If α ′ = Res b ( α ) is defined, then we set Res b ( α, γ ) = ( α ′ , γ ) . In any other case, Res b ( α, γ ) is not defined. Quasi-Residuation.
Let α ∈ supp ( P ) . We define QRes b ( α ) , the quasi-residual of α . • Extension of
Res b : if Res b ( α ) is defined, then QRes b ( α ) = Res b ( α ) . • Variable of the redex: if α = a · · a k for some a ∈ Rep P ( b ) and k ∈ K a , then QRes b ( α ) = a · a k . • Root of the redex: if α = a ∈ Rep P ( b ) , then QRes b ( α ) = α .Thus, the only case when QRes b ( α ) is not defined is when α = b · . Right bipositions.
Let ( α, γ ) ∈ supp ( P ) , we define QRes b ( α, γ ) case-wise: • If α ′ = QRes b ( α ) is defined, then QRes b ( α, γ ) = ( α ′ , γ ) . • Abstraction of the redex: If α = a · for some a ∈ Rep P ( b ) ( i.e. t ( α ) = λx ): – if γ = 1 · γ for some γ ∈ N ∗ , then QRes b ( a · , γ ) = ( a, γ ) . – If γ = k · γ for some k > and γ ∈ N ∗ , then k ∈ K ( a ) and QRes b ( a · , γ ) = ( a · a k , γ ) . EQUENCE TYPES AND INFINITARY SEMANTICS 63 – If γ = ε , then QRes b ( a · , ε ) = ( a, ε ) .Note that Res b and QRes b implicitly depend on P in the argument of the redex, since themapping of (bi)positions in the argument derivations typing s depend on axiom tracksinside P . First properties.
We observe by case-analysis that
Res b is injective. For all α ′ ∈ Res b ( supp ( P )) , we set T ′ ( α ′ ) = T ( α ) and C ′ ( α ′ ) = C ( α ) if α ≯ b · and C ′ ( α ′ ) = C ( Res b ( α ′ )) \ x ) ⊎ ( ⊎ k ∈ K ( α ) C ( a · k )) if α > b · , where α = Res − b ( α ) and a is the uniqueprefix of α such that a = b and K ( α ) := Rt ( C ( α )( x )) . Intuitively, C ′ ( α ′ ) erases the typesassigned to x and replace them by the contexts assigned to the matching occurrencesof s , as expected in the reduct (in which the argument s has replaced x ). We define P ′ := Res b ( P ) (and we write P b → β P ′ ) as the tree labelled with S hp -judgments by supp ( P ′ ) = Res b ( supp ( P )) and for all α ′ ∈ supp ( P ′ ) , P ′ ( α ′ ) = C ′ ( α ′ ) ⊢ t ′ | α ′ : T ′ ( α ) .Quasi-residuation preserves types. Residuation preserves constructors: Lemma 59.
Assume P b → β P ′ . Let α ∈ supp ( P ) • If α ′ = Res b ( α ) is defined, then t ′ ( α ′ ) = t ( α ) . • If α ′ = QRes b ( α ) is defined, then T ′ ( α ′ ) = T ( α ) .Lemma 59 is pivotal to prove: Lemma 60.
Assume P b → β P ′ . Then the labelled tree P ′ is a correct S hp -derivation. Proof.
We reason by case analysis to prove that each node of P ′ is a correct typing ruleof system S hp , using Lemma 59 and the definition of C ′ . For α ′ ∈ supp ( P ′ ) , a specialcare must be given when α ′ or one of its children corresponds to b or an occurrence of s . Lemma 61.
Assume that P is a quantitative S hp -derivation and P b → β P ′ . • Res b is a bijection from a subset of bisupp R ( P ) to bisupp R ( P ′ ) . • QRes b is a total surjective function from bisupp R ( P ) to bisupp R ( P ′ ) . Moreover, forall p ′ ∈ bisupp ( P ′ ) , p has at most six antecedents by QRes b In short, the last point of Lemma 61 holds, because
QRes b ( α, γ ) is defined in 6 cases,each one being injective. A derivation typing a redex of the form ( λx.x ) s shows thatthis number may be reached. Remark 11.
Note that, for all p ∈ bisupp R ( P ) and p ′ := QRes b ( p ) , we have P ( p ) = P ′ ( p ′ ) except maybe when p = ( a · , ε ) for some a ∈ Rep P ′ ( b ) . Actually, for that reason, wecould have left QRes ( a · , ε ) undefined, but it is more convenient that QRes b should betotal function for the proof of Lemma 64 (approximability is stable by conversion). Monotonicity.
Observe that P ∞ P iff P and P type the same term, supp ( P ) ∞ supp ( P ) and for all a ∈ supp ( P ) , C ( a ) ∞ C ( a ) (Definition 54) and T ( a ) ∞ T ( a ) .In particular, if P ∞ P type t , t b → β t ′ , then Res b ( supp ( P )) ⊆ Res b ( supp ( P )) and T ′ ( Res b ( α )) = T ( α ) ∞ T ( α ) = T ′ ( Res b ( α ′ )) . Last, C ′ i ( α ′ )( y ) = ( tr ( ′ ) i ( α ′ ) · T ′ ( α ′ )) α ′ ∈ Ax Pi ( α ′ )( y ) . Since Ax P α ′ ( y ) ⊆ Ax P α ′ ( y ) for all α ′ ∈ supp ( P ′ ) (because supp ( P ) ⊆ supp ( P ) ), we have C ′ ( α ′ )( y ) ∞ C ′ ( α ′ )( y ) for all α ′ ∈ supp ( P ′ ) and y ∈ V . Thus, Res b is monotonic on the set of S hp -derivations typing t . C.2.
Equinecessary bipositions.
In this section, we use the notion of equinecessity to prove that we can forget about left bipositions while working with approximability,as we suggested in the beginning of Sec. C.
Definition 62.
Let P a S hp -derivation and p , p two bipositions of P . • We say p subjugates p if, for all P ∗ ∞ P , p ∈ P ∗ implies p ∈ P ∗ . • We say p and p are equinecessary (written p ↔ p ) if, for all P ∗ ∞ P , p ∈ P ∗ iff p ∈ P ∗ . • Let B , B ⊆ bisupp ( P ) . We also write B ↔ B if, for all P ∗ ∞ P , B ⊆ bisupp ( P ) iff B ⊆ bisupp ( P ) .Note that subjugation and equinecessity are implicitly defined w.r.t. P . There aremany elementary equinecessity cases that are easy to observe. We need only a few onesand we define asc ( p ) and Asc ( p ) (standing for “ascendance”) so that p ↔ asc ( p ) and p ↔ Asc ( p ) for all p ∈ bisupp ( P ) . • asc ( p ) is defined for any p ∈ bisupp ( P ) which is not in an axiom leaf. – Left bipositions: asc ( a, x, k · c ) = ( a · ℓ, x, k · c ) , where ℓ > is the unique integersuch that ( a · ℓ, x, k · c ) ∈ bisupp ( P ) . – Right bipositions ( abs ): if t ( a ) = λx , asc ( a, ε ) = ( a · , ε ) , asc ( a, · c ) = ( a · , c ) and asc ( a, k · c ) = ( a · , x, k · c ) if k > . – Right bipositions ( app ) : if t ( a ) = @ , asc ( a, c ) = ( a · , · c ) . • Asc ( p ) is a right biposition and is defined as the highest right biposition related to p by asc . – Right bipositions: if p = ( a, c ) , let h be maximal such that asc h ( p ) is defined. Inthat case, we set Asc ( p ) = asc h ( p ) . – Left bipositions: if p = ( a, x, k · c ) , let h be maximal (if it exists) such that asc h ( p ) exists. In that case, asc h ( p ) is of the form ( a , x, k · c ) with t ( a ) = x . We set then Asc ( p ) = ( a , c ) .Since t ∈ Λ (and not in Λ \ Λ ), Asc ( p ) is defined for any right biposition p . If P is quantitative, then Asc ( p ) is also defined for any left biposition.An examination of the app -rule shows that, if t ( a ) = @ , for all k > and c ∈ N ∗ : ( a · , k · c ) ↔ ( a · k, c ) Indeed, if u v is typed, the domain of the arrow typing u correspond to the types assignedto the argument u .Assume t | b = ( λx.r ) s . A very important case of equinecessity is this one, with thesame notations as in Sec. C.1 e.g. , a = b : ( a · , k · c ) ↔ ( a · · a k , x, k · c ) and ( a · , k · c ) ↔ ( a · k, c ) The first relation specifies that the domain of the arrow type of λx.r correspond to thetypes assigned to x . The second one specifies that the domain of the arrow type of λx.r correspond to the types of the argument s .This entails: ( a · · a k , c ) ↔ ( a · k, c ) This relation specifies that the types of the occurrences of x match the types of theargument s of the redex. EQUENCE TYPES AND INFINITARY SEMANTICS 65
C.3.
Uniform Subject Expansion.
We prove now the uniform subject expansionproperty for system S hp . By uniform , we mean that we use a function ⌊·⌋ : N → N ∗ todecide the value of the axiom tracks in the axiom rules created during anti-reduction.Uniformity is crucial to ensure that subject expansion is monotonic.Assuming t | b = ( λx.r ) s and t b → β t ′ , we will built a derivation P typing t from aderivation P ′ typing t ′ . The constructions is based on the following observation: thereare three kinds of positions in t ′ : (1) positions outside the reduct r [ s/x ] (2) positions in-side r (but outside an occurrence of s ) (3) positions inside an occurrence of s . Things area bit less clear in t : we have (1) positions outside the redex ( λx.r ) s (2) positions inside r (3) positions inside s (4) positions corresponding to the application or the abstractionof the redex ( λx.r ) s . Moreover, inside r , one should distinguish positions correspondingto x (which is destroyed during reduction) and the other positions. All this has beenillustrated with Fig. 12. Hypotheses.
Let P ′ (cid:3) Γ ⊢ t ′ : τ a quantitative S hp derivation with t ′ | b = r [ s/x ] and t the term such that t | b = ( λx.r ) s and t b → β t ′ . Let ⌊·⌋ be an injective function from N \ { , } to N ∗ . We set A ′ = supp ( P ′ ) . Building the support of P . We first build A := supp ( P ) and a quasi-residuationfunction QR b from A to A ′ .We write T ′ , C ′ and tr ′ for T P ′ , C P ′ and tr P ′ . We set B = supp ( t ) , B ′ = supp ( t ′ ) and A ′ = supp ( P ) . Let B x = { β ∈ B | t ( β ) = x } (we assume Barendregt convention), B ′ sε = Res b ( B ) , B ′ s = β ′ · β ′ ∈ B ′ | β ′ ∈ B ′ sε and A b = Rep P ′ ( b ) , A ′ sε = { α ′ ∈ A ′ | α ′ ∈ B ′ sε } and A ′ s = { α ′ ∈ A ′ | α ′ ∈ B ′ s } . Thus, A ′ sε (resp. A ′ s ) is the set of positions (in P ′ )of the occurrences of s (resp. inside an occurrence of s ) resulting from substitution Weset A ′ s i = A ′ s \ A sε for the set of positions internal to an occurrence of s . Outside the redex and inside r . First, we set A b = { α ′ ∈ A ′ | α ′ > b } , A ′ r = { al ′ ∈ A ′ | α ′ > b, α ′ / ∈ A ′ s i } (note that we have α ′ ∈ supp ( r ) ) and A r = { a · · α ′ | a ∈ Rep P ′ ( b ) , α ′ ∈ N ∗ , a · α ′ ∈ A ′ r } . Thus, A b is the set of position outside the reduct in t ′ and A r corresponds to the set of positions inside the subterm r in t . We define QR b asthe identity on A b and by QR b ( a · · α ′ ) = a · α ′ from A r to A ′ r .We split A r in two: let A xb = { a · · α ′ | a ∈ Rep P ′ ( b ) a · α ′ ∈ A ′ sε } and A b = A r \ A xb .Intuitively, A xb corresponds to the occurrences of x in t (which are in r ) whereas A b corresponds to the other positions inside the subterm r in t . Inside s . We set A s = { a · ⌊ a · · α ′ ⌋ · α | a ∈ Rep P ′ ( b ) , a · α ∈ A ′ sε , a · α ′ · α ∈ A ′ } .Intuitively, A s will correspond to the position of s in P . Indeed, a · α ′ (resp. a · · α ′ )corresponds to an occurrence of s in t ′ (resp. of x in t ) whereas a points to an app -ruletyping the application of the redex ( λx.r ) s below. As we explained above, the naturalnumber k := ⌊ a · · α ⌋ gives us the axiom track that the occurrence of x at position a · · α should be assigned while typing t . Then, we should add an argument at app -node a on track k . Hence, a · ⌊ a · α ⌋ . We define QR b from A s to A ′ s by mapping a · ⌊ a · · α ′ ⌋ · α on a · α ′ · α (note that a · α ′ ∈ A ′ s ). Observe that this induces abijection from A s to A ′ s .We may now define A , which will be the support of P , as a disjoint union: A := A b ∪ A xb ∪ A b ∪ A s ∪ Rep P ′ ( b ) ∪ Rep P ′ ( b ) · We define QR b on Rep P ′ ( b ) as the identity and we leave it undefined on Rep P ′ ( b ) · (which corresponds to the abstraction λx.r ). Since A ′ = A b ∪ A ′ r ∪ A ′ s , we have that QR b is a function from A \ Rep P ′ ( b ) · to A ′ . Building types and contexts.
We set, for all α ∈ A \ Rep P ′ ( b ) · , T ( α ) = T ′ ( α ′ ) with α ′ = QR b ( α ) . If a ∈ Rep P ′ ( b ) , we set T ( a ·
1) = T ( a · k ) k ∈ K → T ( a ) where K = { k > | a · k ∈ A } .In order to define the contexts in P , we must observe that, in r (inside ( λx.r ) s ), x is a placeholder for occurrence of s .Since P ′ is quantitative, we have, for all α ′ ∈ A ′ , y ∈ V , C ′ ( α ′ )( y ) = ( tr ′ ( α ′ ) · T ′ ( α ′ )) α ′ ∈ A ′ ( α ′ ,y ) where A ′ ( α ′ , y ) := Ax P ′ α ′ ( y ) .Let α ∈ A r and α ′ := QR b ( α ) . For all y ∈ V , we set A ′ ( α ′ , y ) := A ′ ( α ′ , y ) \ A ′ s , theset of positions of axioms typing y (in P ′ ) above α ′ which are not in any occurrence of s .We set A ( x, α ) = { α ∈ A xb | α > α } (the positions of x in A above α ). If α ∈ A ( x, α ) ,then the axiom rule typing x at position α is a placeholder for a typed occurrence of s at position QR b ( α ) in P ′ . We set A ′ x ( α ′ , y ) := { α ′ ∈ A ′ sε | α ′ > α ′ } , which is the set ofpositions in P ′ pointing to occurrences of s above α ′ . We then define C ( α ) case-wise: • If α ∈ A r , then C ( α ) = ( tr ′ ( α ′ ) · T ′ ( α ′ )) α ′ ∈ A ′ ( al ′ ,y ) . for all y = x and C ( α )( x ) =( ⌊ α ⌋ · T ′ ( QR b ( α ))) α ∈ A ( α,x ) . This latter definition is correct since ⌊·⌋ is injective. • If α > b ( i.e. α ∈ A b ) or α ∈ A s , then C ( α ) = C ′ ( α ′ ) • If α = a · for some a ∈ Rep P ′ ( b ) , then we set C ( α ) = ( tr ′ ( α ′ ) · T ′ ( α ′ )) α ′ ∈ A ′ ( al ′ ,y ) . forall y = x and C ( α )( x ) = ( ) We define
Exp b ( P ′ , ⌊·⌋ , t ) as the tree P labelled with S hp -judgments such that supp ( P ) = A and for all α ∈ A , P ( α ) = C ( α ) ⊢ t | α : T ( α ) . For instance, the construction of A r depends on t . The construction of A s depends on ⌊·⌋ .We have, for all α ∈ A \ Rep P ′ ( b ) and α ′ = QR b ( α ) : T ( α ) = T ′ ( α ′ ) (type preservation) Correction and monotonicity.
Let α ∈ A . We set Ch ( α ) := { α · k ∈ A | k ∈ N } ( Ch stands for “children”). Thus, Ch ( α ) corresponds to the premises of α in A . Let α ′ ∈ A ′ . We set likewise Ch ′ ( α ′ ) := { α ′ · k ∈ A ′ | k ∈ N } . A case analysis shows that, if α ∈ A b ∪ A b ∪ A s and α ′ = QR b ( α ) , then QR b induces a bijection from Ch ( α ) to Ch ′ ( α ′ ) .By type preservation, this implies that for all α ∈ A b ∪ A b ∪ A s , α is given by a correct S hp -rule.We must also check that, for α ∈ A xb ∪ Rep P ′ ( b ) ∪ Rep P ′ ( b ) · , α is correct: thiseasily follows from the definition of C and T . Thus, P is correct and concludes with C ( ε ) ⊢ t : T ( ε ) , i.e. C ⊢ t : T , as expected.To prove monotonicity, i.e. P ′ ∞ P ′ implies Exp b ( P ′ , ⌊·⌋ , t ) ∞ Exp b ( P ′ , ⌊·⌋ , t ) ,one needs to remark the two following crucial points: (1) the construction of A s , whichdepends on ⌊·⌋ , is monotonic (2) if t ( α ) = x , then ( ⌊ α ⌋ · T ( α )) ∞ ( ⌊ α ⌋ · T ( α )) becausewe assign the same axiom rule in the two singleton sequence types. This ensures that C ( α ) ∞ C ( α ) in all cases. Remark 12. • The function ⌊·⌋ does not need to be total on N \ { , } , nor injective for the aboveconstruction to work. It needs to be defined only for the positions of the axiom rulesthat are created ( i.e. ⌊·⌋ must be defined on A xb ), so that an axiom track is for eachaxiom rule that is created by expansion. And for all Rep P ′ ( b ) , ⌊·⌋ needs to be injectiveon { α ∈ A xb | α > a } , so that no track conflict occurs. • Thus, the monotonicity of expansion thus admits a variant, without having to specifya function ⌊·⌋ : if f P ′ P type t ′ and t a → β t ′ , then there exists f P P typing t EQUENCE TYPES AND INFINITARY SEMANTICS 67 such that P b → β P ′ and f P b → β f P . For that, consider the function ⌊·⌋ defined by ⌊ α ⌋ = tr P ( α ) for all α ∈ supp ( P ) such that t ( α ) is the variable of the redex. • One way wonder how the expansion P depends on the choice of ⌊·⌋ . It actually doesnot matter that much, because all the possible expansions of P ′ are (in some sense) isomorphic , whatever the values of the new axiom tracks are.C.4. Approximability is stable under (anti)reduction.
We need first this lemma:
Lemma 63. If P b → β P ′ , then P is quantitative iff P ′ is quantitative. Proof. • Assume that P (cid:3) C ⊢ t : T is not quantitative, t | b = ( λx.r ) s and that t respectsBarendregt convention. Thus, there are α ∈ supp ( P ) , y ∈ V and k > such that, forall d > , there is α > a such that | α | > d , k ∈ supp ( C ( α )( y )) . Thus, B := { α > a | k ∈ supp ( C ( α )( x )) } , the set of ascendants of ( α , y, k ) , defines (the postfix of) aninfinite branch of supp ( P ) . There are three cases: (1) B visits an occurrence of s ( i.e. there is α ∈ B such that α > b · ) (2) B visits r but no occurrence of s (3) B doesnot visit the redex ( λx.r ) s . By case analysis and using the definition of C , we obtainan infinite branch B ′ in the derivation reduct P ′ which is in an occurrence of s in case(1), in r but does not visit an occurrence of s in case 2, is outside r [ s/x ] in case (3). Incase (1), we may replace ( α, y, k ) by one of its ascendant and assume that α is in anoccurrence of s without losing generality. Likewise, in case (2), we may assume that ( α, y, k ) is in r . • The converse implication is proved by following back the steps of the above proof andconsidering the definition of C .We may now prove that approximability is stable under reduction and expansion: Lemma 64.
Let P and P ′ two S hp -derivation such that P b → β P ′ . • If P is approximable, then P ′ is also approximable. • If P ′ is approximable, then P is also approximable. Proof.
By the first item of Lemma 22, if P is approximable, then P is quantitative. Wefirst observe:(o1) if p ′ ∈ bisupp R ( P ′ ) , then QRes − b ( p ′ ) is not empty either.(o2) if P is quantitative and p ∈ bisupp R ( P ) , then QRes b ( p ) is not emptyThen, we prove each point of the statement: • Let B ′ ⊆ bisupp ( P ′ ) . We set B = QRes − b ( Asc ( B )) . By Lemma 61, B is finite.Since P is approximable, there is f P P a finite approximation such that B ⊆ bisupp ( P ) . Let f P ′ such that that f P b → β f P ′ . By monotonicity of reduction, f P ′ P ′ and by (o1), asc B ′ ⊆ supp ( f P ′ ) . Since Asc ( B ′ ) ⊆ QRes b ( B ) ⊆ bisupp ( f P ′ ) and Asc ( B ′ ) ↔ B ′ , we have B ′ ⊆ bisupp ( f P ′ ) , • Since P ′ is approximable, it is quantitative. By Lemma 64, P is quantitative. Let B ⊆ bisupp ( P ) . We set B ′ = QRes b ( Asc ( B )) . Since P ′ is approximable, there is f P ′ P a finite approximation such that B ′ ⊆ bisupp ( f P ′ ) . By monotonicity ofexpansion (see item 2 of Remark 12), there is a unique f P P such that f P b → βf P ′ . By (o2), Asc ( B ) = ⊆ QRes − b ( B ′ ) . Thus, Asc ( B ) ⊆ f P . Moreover, since P isquantitative, B ↔ Asc ( B ) . This implies B ⊆ bisupp ( f P ) C.5.
Proof of the infinitary subject expansion property.
We prove now infinitarysubject expansion for system S hp (Proposition 52). First, subject substitution holds: Lemma 65.
Let P (cid:3) C ⊢ t : T be a S hp -derivation such that for all a ∈ supp ( P ) , t ( a ) = t ′ ( a ) ( P is not necessarily assumed to be approximable).Let P [ t ′ /t ] be the labelled tree obtained from P by replacing t by t ′ (more precisely, P [ t ′ /t ] is the labelled tree P ′ such that supp ( P ′ ) = supp ( P ) and, for all a ∈ supp ( P ) , P ( a ) = C ( a ) ⊢ t ′ | a : T ( a ) ).Then P [ t ′ /t ] is a correct derivation.As mentioned in Sec. 5.3, performing an expansion of a term inside a derivationrequires that we choose new axiom tracks. We will do this uniformly , i.e. we fix aninjection ⌊·⌋ from N ∗ to N − { , } and any axiom rule created at position a will usethe axiom track value ⌊ a ⌋ . As we have seen (Sec. C.3), this ensures that expansion ismonotonic. Hypotheses.
We consider an approximable S hp -derivation P ′ (cid:3) C ′ ⊢ t ′ : T ′ and a pro-ductive reduction path t = t b → β t b → β t . . . t n b n → β t n +1 → ∞ t ′ . Thus, ad ( b n ) → ∞ .We and set A ′ = supp ( P ′ ) .Assume f P ′ P ′ . Let N ∈ N such that, for all n > N, b n / ∈ f A ′ with f A ′ = supp ( f P ′ ) . For n > N , we write f P ′ ( n ) for the derivation replacing t ′ by t n in f P ′ . Thisderivation is correct according to the subject substitution lemma (Lemma 65), since t n ( a ) = t ′ ( a ) for all a ∈ f A ′ .We then write f P ′ ( n, k ) (with k n ) the derivation obtained by performing k expansions (w.r.t. our reduction sequence and ⌊·⌋ ). Since b n is not in A , we observethat f P ′ ( n + 1 ,
1) = f P ′ ( t n ) . Therefore, for all n > N, f P ′ ( n, n ) = f P ′ ( N, N ) . Sincewe could replace N by any n > N , f P is morally f P ′ ( ∞ , ∞ ) . We write P = init ( P ′ ) to refer to this deterministic construction (which implicitly depends on ⌊·⌋ ).We set D = { init ( f P ′ ) | f P ′ P ′ } . Let us show that D is a directed set.Let f P ′ , f P ′ P ′ . We set f P ′ = sup( f P ′ , f P ′ ) , so that f P ′ is also finite. Let N begreat enough so that ∀ n > N , b n / ∈ f A ′ with f A ′ = supp ( f P ′ ) .We have f P ′ i f P ′ , so f P ′ i ( N ) f P ( N ) . Thus, by monotonicity of uniform expan-sion, f P ′ i ( N, N ) f P ′ ( N, N ) i.e. init ( f P i ) init ( f P ) .Since D is directed, we can set P = sup { f P ′ | f P ′ P ′ } init ( f P ′ ) . Since for any f P ′ P and the associated usual notations, f C ( ε ) = f C ′ ( ε ) , f T ( ε ) = f T ′ ( ε ) and, by Lemma 56, C ( ε ) , C ′ ( ε ) , T ( ε ) , T ′ ( ε ) are the respective infinite joins of f C ( ε ) , f C ′ ( ε ) , f T ( ε ) , f T ′ ( ε ) when f P ′ ranges over Approx ( P ′ ) , we conclude that C ( ε ) = C ′ ( ε ) = C ′ and T ( ε ) = T ′ ( ε ) = T ′ .In particular, C ′ ⊢ t : T ′ is approximably derivable. This concludes the proof of theinfinitary subject expansion property.C.6. Equinecessity and Bipositions of Null Applicative Depth.
One may wonderwhether every biposition (in a quantitative derivation P ) is equinecessary with a rootbiposition i.e. a biposition that is located in the judgment concluding P . Such abiposition is of the form p = ( ε, c ) with c ∈ supp ( T P (0)) or p = ( ε, x, k · c ) with k · c ∈ supp ( C P (0)( x )) .This would imply that, for a derivation P to be approximable, it is enough to have:“ P is quantitative and, for all B ⊆ bisupp ( P ) finite set of root bipositions, there exists EQUENCE TYPES AND INFINITARY SEMANTICS 69 ✬✫ ✩✪ t −→ y t z @@ λz Figure 17.
Reduction of t ✬✫ ✩✪ [ o ] → o y [ o ] → o t o z @@ λz [ o ] → o Ψ ′ (cid:3) y : [[ o ] → o ] ω ⊢ λz.y ( t z ) : [ o ] → o [ o ] → o y [ ] → o t z @@ λz [ ] → o Ψ ′ (cid:3) y : [[ o ] → o ] ω ⊢ λz.y ( t z ) : [ ] → o Figure 18.
Two Derivations typing t ′ := λz.y ( t z ) f P P such that B ⊆ bisupp ( f P ) ”. We call this condition root approximability . p ∈ B ,This is actually true in the finite case and so, for the approximable derivation.However, this is not true for any derivation. We exhibit a counter-example of thisconjecture in this section i.e. a derivation that root approximable but not approximable.We present this counter example with a R -derivation whereas it should be a S -derivation(since approximability is only an informal notion for System R ), but it is easier tounderstand that way. Corresponding S -derivations are not difficult to define from ourpresentation.The idea is to use a productive reduction path t → t → t → . . . → ∞ t ′ such thatno reduction step is erasing but there is a variable x ∈ fv ( t ) = fv ( t ) = . . . such that x / ∈ fv ( t ′ ) ( i.e. there is an asymptotic erasure).Let ∆ ∗ = λx. ( λz.y ( x x z ) and t = ∆ ∗ ∆ ∗ , so that t → λz.y ( t z ) (see Fig. 17). Wehave t ≡ β Y ( λtx. ( λz.y ( tx ))) .Note that t f converges to the term t ′ = y ω , which does not contain f . Indeed, t f → ( λz.y ( t z )) f → y ( t f ) (non-erasing steps).There are two derivations Ψ and Ψ respectively concluding with y : [[ o ] → o ] ω ⊢ λz.y ( t z ) : [ o ] → o and y : [[ o ] → o ] ω ⊢ λz.y ( t z ) : [ ] → o . They are obtained from Ψ ′ and Ψ ′ from Fig 17 by a one-step expansion:Let Π Ω a derivation concluding with ⊢ Ω : o . This derivation is unsound and isintuitively not approximable: it is impossible to find a finite derivation (of R ) conclud-ing with ⊢ Ω : o . Then using Ψ and Π Ω and an app -rule we can build a derivation Π concluding with y : [[ o ] → o ] ω ⊢ t Ω : o , in which the subterm Ω is typed. We can also build a derivation Π from Ψ that also concludes with y : [[ o ] → o ] ω ⊢ t Ω : o . Thistimes, the subterm Ω is not typed.It is not difficult to see that Π is intuitively approximable, whereas Π is rootapproximable but not fully approximable. Roughly speaking, the subderivation of Π typing Ω is the only non-approximable part of Π . Indeed: • Π is not approximable since it contains a subderivation typing the mute term Ω . • Every (finite) approximation of Π is an approximation of Π . Thus, the join of thefinite approximations of Π is actually Π .This proves that root approximability is not equivalent to approximability, and that rootapproximability actually accepts derivations which are partially unsound. Appendix D. Approximability of normal derivations
In this Appendix, we describe all the quantitative derivations typing normal forms insystem S and we prove that all of them are approximable.Actually, this statement could be generalized to system S hp it is somewhat clear thatevery quantitative derivation typing a normal form in system S hp is also approximable,but: • This would be more tedious, because it is a bit more complicated to describe naturalextensions in system S hp : indeed, we must consider all the subpositions of supp ( t ) which correspond to an element of HP d for some d ∈ N ∪ ∞ . • We do not need it to obtain the main theorem of characterization in system S hp (Theorem 7).D.1. Called rank of a position inside a type in a derivation.
We recall that therank rk ( a ) of a ∈ N ∗ is defined by rk ( a ) = max( ad ( a ) , max( a )) (Definition 34). Wereuse the notation for constrain levels clev defined in Sec. 7.1 and the notation Call ( a ) define in Sec. 7.2.For each a in A and each position c in Call ( a ) such that Call ( a )( c ) = X a ′ (for some a ′ ), we define the numbers cr out ( a, c ) and cr in ( a, c ) by: • When a is a unconstrained node, cr out ( a, c ) is rk ( a ) and cr in ( a, c ) = rk ( c ) . • When a is a non-zero position: the respective values of cr out ( a, c ) and cr in ( a, c ) forthe positions colored in red are rk ( a ) and rk ( c ) . E (˚ a )( x ) → E (˚ a )( x ) → . . . → E (˚ a )( x n ) → T (˚ a ) where n = clev ( a ) . In particular, cr out ( a, i ) = ad ( a ) and cr in ( a, i ) = 0 for i n .. • When a is partial: the respective values of cr out ( a, c ) and cr in ( a, c ) for the positionscolored in red are rk ( a ) and rk ( c ) . R ( a ) → . . . → R n ( a ) → T (˚ a ) where n = clev ( a ) . In particular, cr out ( a, i ) = ad ( a ) for i n and cr out ( a, n · c ) = ad ( a ) .For each a ∈ A and each position c in T ( a ) , we define cr out ( a, c ) and cr in ( a, c ) byextending cr out and cr in via substitution (this is formally done in the next section).Again, for each a ∈ A , each variable x and each position c in C ( a )( x )( c ) , we define cr out ( a, x, c ) and cr in ( a, x, c ) by extending cr out via substitution.The definition of cr out ( a, c ) , cr out ( a, x, c ) , cr in ( a, c ) and cr in ( a, x, c ) ) are sound,because in E ( a )( x ) and R i ( x ) , the X a ′ occur at depth > in Call ( a ′ ) . EQUENCE TYPES AND INFINITARY SEMANTICS 71
Definition 66. If p ∈ bisupp ( P ) , we define called rank of p by cr ( p ) = max( cr out ( p ) , cr in ( p )) D.2.
Truncation of rank n . We present more formally the definitions of the last sec-tion and we recall that rk ( a ) = max( ad ( a ) , max( a )) for a ∈ N ∗ .As we saw above, a quantitative derivation typing a normal form can be recon-structed from its supports and the types assigned in the unconstrained positions. Thus,in a quantitative derivation P typing a normal form t such that supp ( P ) = A , every p ∈ bisupp ( P ) (with p = ( a, c ) or p = ( a, x, c ) ) must come from (so to say) an ( a ′ , c ′ ) with a > a ′ . We call a ′ the calling outer position and c ′ the calling inner position of p .Let us define them formally now.For all a ∈ A and k ∈ N , we set, by induction on k , T ( a ) = X a and T k +1 ( a ) = T k ( a )[ Call ( a ′ ) /X a ′ ] a ′ ∈ N ∗ and for all k ∈ N , we set supp ∗ ( T k ( a )) = { c ∈ supp ( T k ( a )) | ∀ a ′ ∈ N ∗ , T k ( a )( c ) = X a ′ } . Thus, supp ( T ( a )) = ∪ k ∈ N supp ∗ ( T ∗ ( a )) for all a ∈ A .If c ∈ supp ( T ( a )) , there is a minimal k ∈ N such that c ∈ supp ∗ ( T k ( a )) . We denoteit cd ( a )( c ) (call-depth of c at pos. a ).When k = cd ( a )( c ) , there are unique c ′ ∈ supp ( T ( a )) , c ′′ ∈ N ∗ and a ′ ∈ A such that c = c ′ · c ′′ , T k − ( a )( c ′ ) = X a ′ (we have necessarily a a ′ since a ′ is called by a ), c ′′ ∈ supp ∗ ( Call ( a ′ )) and Call ( a ′ )( c ′′ ) = T ( a )( c ) . We write a ′ = cop ( a, c ) ( calling outer posi-tion of c at position a ), c ′ = cip ( a, c ) ( calling inner position of c at position a ) and c ′′ = pf ( a, c ) ( postfix of c at position a ). Then, we set cr out ( a, c ) := rk ( a ′ ) and cr in ( a, c ) = rk ( c ′′ ) . Finally, we may define cr ( a, c ) by cr ( a, c ) = max( cr out ( a, c ) , cr in ( a, c )) . Implic-itly, cr ( a, c ) depends on P , but P is omitted from the notation. • We set A n = { a ∈ A | rk ( a ) n } . • For all ˚ a ∈ ˚ A n , we define ˚ T n (˚ a ) by removing all the positions c such that rk ( c ) > n , i.e. ˚ T n (˚ a ) is the restriction of ˚ T (˚ a ) on { c ∈ supp (˚ T (˚ a )) | rk ( c ) n } .Since t is in Λ (and not in Λ \ Λ ), A n is finite. Since, for all a ∈ A , T ( a ) is in Typ (and not in
Typ \ Typ ), the type ˚ T n (˚ a ) is finite for all ˚ a ∈ ˚ A n .We define P n as the natural extension of ( A n , ˚ T n ) . We retrieve contexts C n andtypes T n such that, for all a ∈ A n , P n = C n ( a ) ⊢ t | a : T n ( a ) . Lemma 67.
For all k ∈ N , a ∈ A, c ∈ N ∗ , we have rk ( a ) n and c ∈ supp ( T kn ( a )) iff c ∈ supp ( T k ( a )) and cr ( a, c ) n .In that case, T k ( a )( c ) = T kn ( a )( c ) . Proof.
By a simple but tedious induction on k . The notations cop n , cip n , pf n and T kn for the ad hoc definitions of calling outer positions and so on for P n . • Case k = 0 : ⇒ : if rk ( a ) n and c ∈ supp ( T n ( a )) , then rk ( a ) n and c = ε . By definition, cr out ( a, ε ) = rk ( a ) n and cr in ( a )( ε ) = rk ( ε ) = 0 . Thus, cr ( a, c ) n . ⇐ : conversely, if c ∈ supp ( T ( a )) and cr ( a, c ) n , we have likewise c = ε and cop ( a, ε ) = a , so rk ( a ) = cr out ( a, c ) n . So c = ε ∈ T n ( a ) . • Case k + 1 : ⇒ : we assume that rk ( a ) n and c ∈ supp ( T kn ( a )) . We have two cases,whether c ∈ supp ∗ ( T kn ( a )) or not. If c ∈ supp ∗ ( T kn ( a )) , then T k +1 n ( a )( c ) = T kn ( a )( c ) . By induction hypothesis, we have T kn ( a )( c ) = T k ( a )( c ) . This implies T k +1 ( a )( c ) = T k ( a )( c ) and also, T k +1 n ( a )( c ) = T k +1 ( a )( c ) . Thus, let us assume c / ∈ supp ∗ ( T kn ( a )) .We have once again two cases, whether c ∈ supp ( T kn ( a )) or not.Assume first that c ∈ supp ( T kn ( a )) . Since c / ∈ supp ∗ ( T kn ( a )) , we have T kn ( a )( c ) = X a ′ where a ′ = cop ( a, c ) . Then T k +1 n ( a )( c ) = T = Call n ( a ′ )( ε ) . Moreover, the inductionhypothesisapplies to ( a, c ) and gives cr ( a, c ) n and T k ( a )( c ) == T kn ( X a ′ ) . Thus, T k +1 ( a )( c ) = Call ( a ′ )( ε ) and rk ( a ′ ) = cr out ( a, c ) n . Since a a ′ , we have rk ( a ) n . Since rk ( ε ) = 0 , we have Call n ( a ′ )( ε ) = Call ( a ′ )( ε ) . So T k +1 ( a )( c ) = T k +1 n ( a )( ε ) = Call n ( a ′ )( ε ) .We assume now that c / ∈ supp ( T kn ( a )) . Since c ∈ supp ( T k +1 n ( a )) \ supp ( T kn ( a )) , thereare unique a ′ ∈ A n , c ′′ ∈ supp ( T kn ( a )) and c ′′ ∈ N ∗ such that c = c ′ · c ′′ , T kn ( a )( c ) = X a ′ .In particular, T kn ( a )( c ) = T kn ( a ′ )( c ′′ ) . We have two subcases: – Case T k +1 n ( a )( c ) = X a ′′ for all a ′′ . In that case, a ′ = cop n ( a, c ) , c ′ = cip n ( a, c ) and c ′′ = pf n ( a, c ) . We have c ′′ ∈ supp ∗ ( Call n ( a ′ )) supp ( Call ( a ′ )) . This entails inparticular T k +1 ( a )( c ) = Call n ( a ′ )( c ) = T k +1 n ( a, c ) .Moreover, we have cr out ( a, c ) = rk ( a ′ ) n since a ∈ A n and cr in ( a, c ) = rk ( c ′′ ) n since c ′′ ∈ supp ( T n ( a ′ )) . Thus, cr ( a, c ) n . – Case T k +1 n ( a )( c ) = X a ′′ for some a ′′ > a ′ . In that case, a ′′ = cop n ( a, c ) , c = cip n ( a, c ) and pf n ( a, c ) = ε . Due to the form of Call n ( _ ) , ′′ = 1 i · ℓ for some j < clev ( a ′ ) and ℓ = ⌊ a ′ ⌋ > . By induction hypothesis, T k ( a )( c ′ ) = T kn ( a )( c ′ ) , so T k ( a )( c ′ ) = X a ′ . Since c ′′ = 1 i · ℓ ∈ supp ( Call n ( a ′ )) and Call n ( a ′ ) Call ( a ′ ) , wealso have Call ( a ′ )( c ′′ ) = X a ′′ . Thus, T k +1 ( a )( c ) = X a ′′ = T k +1 n ( a )( c ) .Moreover, cr out ( a, c ) = rk ( a ′′ ) n since a ′′ ∈ A n , and cr in ( a, c ) = rk ( ε ) = 0 , so cr ( a, c ) n . ⇐ : conversely, if a ∈ A, c ∈ supp ( T k +1 ( a )) and cr ( a, c ) n , we assume that a / ∈ supp ∗ ( T k ( a )) (if a ∈ supp ∗ ( T k ( a )) , the case is straightforwardly handled by inductionhypothesis).Assume first that c ∈ supp ( T k ( a )) and T k ( a ) = X a ′ . Then rk ( a ′ ) = cr out ( a, c ) n ,so that a ′ ∈ A n , and T k +1 ( a ) = Call n ( a ′ )( ε ) . By induction hypothesison ( a, c ) , a ∈ A n , c ∈ supp ( T kn ( a )) and T kn ( a )( c ) = X a ′ , so T k +1 n ( ε ) = Call n ( a ′ )( ε ) . Since Call n ( a ′ ) Call ( a ) , we have Call n ( a ′ ) = Call ( a ′ )( ε ) , which is equal to T k +1 ( a )( c ) since T k ( a )( c ) = X a ′ . Thus, T k +1 n ( a )( cc ) = T k +1 ( a )( c ) .We assume now that c / ∈ supp ( T k ( a )) . Since c ∈ supp ( T k +1 ( a )) \ supp ( T k ( a )) , thereare unique a ′ ∈ A , c ′ ∈ supp ( T k ( a )) and c ′′ ∈ N ∗ such that c = c ′ · c ′′ , T k ( a )( c ) = X a ′ .By induction hypothesison c ′ , rk ( a ) n , c ′ ∈ supp ( T kn ( a )) and T kn ( a )( c ′ ) = T k ( a )( c ) = X a ′ . In particular, T k ( a )( c ) = T k ( a ′ )( c ′′ ) . We have two subcases: – If T k +1 ( a )( c ) = X a ′′ for all a ′′ , then a ′ = cop ( a, c ) , c ′ = cip ( a, c ) and c ′′ = pf ( a, c ) .Moreover, rk ( c ′′ ) = cr in ( a, c ) cr ( a, c ) n , so ′′ ∈ supp ( Call n ( a ′ )) . By def-inition of T k +1 n ( a ) , T k +1 = Call n ( a ′ )( c ′ ) . Since Call n ( a ′ ) Call ( a ′ ) , we have Call n ( a ′ )( c ′ ) = Call ( a )( c ′ ) , which is equal to T k +1 ( a )( c ) . Thus, T k +1 n ( a )( c ) = T k +1 ( a )( c ) . – If T k +1 ( a )( c ) = X a ′′ for some a ′′ > a ′ . In that case, a ′′ = cop ( a, c ) , c = cip ( a, c ) and pf ( a, c ) = ε . Due to the form of Call ( _ ) , ′′ = 1 j · ℓ for some j < clev ( a ′ ) and ℓ = ⌊ a ′ ⌋ > . By definition of Call n ( _ ) , we also have j ∈ Call n ( a ′ ) and Call n ( a ′ )( c ′′ ) = X a ′′ ( Call n ( a ′ ) and Call ( a ′ ) may only differ on positions > clev ( a ′ ) by construction). By definition of T k +1 n , we have T k +1 n ( a )( c ) = Call n ( a ′ )( X a ′′ ) . Inparticular, T k +1 n ( a )( c ) = T k +1 ( a )( c ) . EQUENCE TYPES AND INFINITARY SEMANTICS 73
D.3.
A Complete Sequence of Derivation Approximations.
We now prove Lemma 35:
Lemma 68. If P is a quantitative derivation typing a normal form t , then P is approx-imable. Proof.
Let B ⊂ bisupp ( P ) a finite subset. We set n = max { cr ( p ) | p ∈ B } . Then B ⊆ bisupp ( P n ) .In order to conclude, it is enough to prove that P n is a finite derivation. For that,we notice that A n is finite and, for all a ∈ A n , Call n ( a ) is finite and T k +1 n ( a ) = T n +1 n ( a ) for all k > n + 1 , since T n +1 n ( a ) does not contain any X a ′ . In particular, T n ( a ) is finite.Since A n and all the T n ( a ) ( a ranging over A ) are finite, P n is finite. Appendix E. Infinitary Multiset Types
We present here a definition of type assignment system R , which is an infinitary versionof Gardner-de Carvalho’s system R .Intuitively, a multiset is a sequence in which we have the positions (the tracks) ofthe elements has been collapsed, e.g. , the multiset [ o , o , o ] may be seen indifferently asthe collapse of the sequences (3 · o , · o , · o ) , (2 · o , · o , · o ) or (3 · o , · o , · o ) .Since there are nesting of multisets in the finite types from System R , the types of R may be seen as an inductive/nested collapse of finite types of System S .In order to build an infinitary version of R whose types will feature infinitary nest-ings of multisets, it is natural to define those types as coinductive collapse of sequences.E.1. Types.
Let U and U be two labelled trees or two sequences of labelled trees. A from U to U is a bijection φ from supp ( U ) to supp ( U ) suchthat: • φ is monotonic for the prefix order. • If a · k ∈ supp ( U ) with k = 0 or k = 1 , then φ ( a · k ) = φ ( a ) = c • For all a ∈ supp ( U ) , U ( φ ( a )) = U ( a ) .Thus, a 01-stable isomorphism is either an isomorphism of labelled trees or an isomor-phism of sequences, which preserves tracks 0 and 1. We write U ≡ U when there is a01-stable isomorphism from U to U . If U and U are types (resp. sequence types), φ is called a type isomorphism (resp. sequence type isomorphism ).Alternatively, we can define U ≡ U for types and sequence types by coinduction,without reference to 01-stable isomorphism: • o ≡ o • ( S k ) k ∈ K ≡ ( S ′ k ) k ∈ K ′ if there is a bijection ρ : K → K ′ such that, for all k ∈ K , S k ≡ S ′ ρ ( k ) . • ( S k ) k ∈ K → T ≡ ( S ′ k ) k ∈ K ′ → T ′ if ( S k ) k ∈ K ≡ ( S ′ k ) k ∈ K ′ and T ≡ T ′ .The set Typ R of types of System R is defined as the quotient set Typ / ≡ .If U is a S -type or a sequence type, its equivalence class is written U . We may nowdefine coinductively the notation of the collapses of S -types: • The equivalent class of a sequence type F = ( S k ) k ∈ K is the multiset type written [ S k ] k ∈ Rt ( F ) • We write F → T for F → T . • If o is a type variable, o is the singleton { o } . In that case, we just write (abusively) o instead of o or { o } .Countable sum + i ∈ I F i is defined on the set of multisets types by using an arbitrarybijection j from the pairwise disjoint countable sum N × ( N \ { , } ) to N \ { , } .Let ( F i ) i ∈ I = (( S ik ) k ∈ K ( i ) ) i ∈ I a countable family of sequence type such that I ⊆ N .We define j + i ∈ I F i as the sequence type F = ( S k ) k ∈ K such that K = { j ( i, k ) | i ∈ I, k ∈ K ( i ) } and, for all k ∈ K , S k is S ik where ( i, k ) is the unique pair such that i ∈ I, k ∈ K ( i ) and k = j ( i, k ) . We may then prove that (1) if for all i ∈ I , F i ≡ G i ,then j + i ∈ I F i ≡ j + i ∈ I G i (2) the class of j + i ∈ I F i does not depend on j . Thus, we maydefine countable sum operator + on multiset types. It is routine work to prove that + infinitarily associative and commutative on multiset types, as expected.E.2. Typing rules. An R -context is a total function from the set of term variables V to the set of infinitary multiset types. An R -judgment is a triple of the form Γ ⊢ t : τ where G is a R -context, t a 001-term and τ a R -types. The set of semi-rigid derivationsis the set of trees (labelled with R -judgments) defined coinductively by the followingrules: ax x : [ τ ] ⊢ x : τ Γ; x : [ σ i ] i ∈ I ⊢ t : τ abs Γ − x ⊢ λx.t : [ σ i ] i ∈ I → τ Γ ⊢ t : [ σ i ] i ∈ I → τ (∆ k ⊢ u : σ k ) k ∈ K app Γ + k ∈ K ∆ k ⊢ t u : τ Why do we say that these derivations are semi-rigid ? Because the argument ofderivations are still placed on argument tracks k ∈ K , while obviously, they should notmatter when we work with multisets. Let P and P be two semi-rigid derivations. Wedefine the set of R -derivation as the quotient set of that of semi-derivation by the relation ≡ . An element of Deriv R is usually written Π , whereas an element of Deriv ∗ is written P (as for system S ). Notice the derivation Π and Π ′ of Sec. 3.5 and Fig. 7 are objectsof Deriv .E.3.
Quantitativity and Coinduction in System R . Let Γ be any context. Exactlyas in Sec. 5.2, we can use the infinite branch of f ω to give the following variant ofderivation Π ′ from Sec. 3.5, which respects the rules of system R : ax f : [[ o ] → o ] ⊢ f : [ o ] → o Π ′ Γ (cid:3) f : [[ o ] → o ] ω + Γ ⊢ f ω : o app f : [[ o ] → o ] ω + Γ ⊢ f ω : o The notion of quantitativity (Definition 15) can be adapted while considering mul-tisets:
Definition 69. • A semi-rigid derivation P is quantitative if, for all a ∈ supp ( P ) , Γ( a )( x ) = [ τ ( a ′ )] a ′ ∈ Ax Pa x . • A R -derivation Π is quantitative if any of its semi-rigid representatives is (in thatcase, all of them are quantitative). EQUENCE TYPES AND INFINITARY SEMANTICS 75 P ′ = f : (2 · (2 · o ) → o ) [1] f : (3 · (2 · o ) → o ) [1] P ′ (cid:3) f : ( k · (2 · o ) → o ) k > ⊢ f ω : o [2] f : ( k · (2 · o ) → o ) k > ⊢ f ω : o [2] f : ( k · (2 · o ) → o ) k > ⊢ f ω : o ˜ P ′ = f : (2 · (2 · o ) → o ) [1] f : (4 · (2 · o ) → o ) [1] ˜ P ′ (cid:3) f : ( k · (2 · o ) → o ) k =3 ∨ k > ⊢ f ω : o [2] f : ( k · (2 · o ) → o ) k > ⊢ f ω : o [2] f : ( k · (2 · o ) → o ) k > ⊢ f ω : o ˜ P ′ k = f : ( k · (2 · o ) → o ) [1] ˜ P ′ k +1 (cid:3) f : ( i · (2 · o ) → o ) i =3 ∨ i > k +1 ⊢ f ω : o [2] f : ( i · (2 · o ) → o ) i > k ⊢ f ω : o (for k > ) Figure 19.
Representing Π ′ In the next subsection, we show that a derivation Π from system R can have bothquantitative and not quantitative, approximable and not approximable representativesin System S . It once again shows that rigid constructions allow a more fine-grainedcontrol than system R does on derivations.E.4. Representatives and Dynamics. A S -derivation P represents a derivation Π if the semi-rigid derivation P ∗ defined by supp ( P ∗ ) = supp ( P ) and P ∗ ( a ) = C ( a ) ⊢ t | a : T ( a ) , is a semi-rigid representative of Π . We write P ≡ R P when two S -derivations P and P both represent the same R -derivation Π . Proposition 70.
If a S -derivation P is quantitative, then the R -derivation P is quan-titative in system R .Using natural extensions (Sec. 7.2), it easy to prove: Proposition 71. If Π is a quantitative derivation typing a 001-normal form, then, thereis a quantitative rigid derivation P such that P = Π . Proof.
Let P ( ∗ ) be a semi-rigid derivation representing Π . We set A = supp ( P ( ∗ )) andfor all full position a ∈ A , we choose a representative T (˚ a ) of τ ( a ) . We apply then thecanonical construction of Sec. 7.2, which yields a rigid derivation P such that P ∗ = P ( ∗ ) (we show that, for all a ∈ A , T ( a ) represents τ ( a ) ).We can actually prove that every quantitative R -derivation can be represented witha S -quantitative rigid derivation and that we can endow it with every possible infinitaryreduction choice [40]. However, a quantitative derivation can also have a not quantitativerigid representative, as we see below with Π ′ and ˜ P ′ .We omit again the right side of axiom rules, e.g. , f : ((2 · o ) → o ) stands for f : ((2 · o ) → o ) ⊢ f : (2 · o ) → o . Moreover, outer tracks are indicated between redsquare brackets. • We define R o by R o := ( k · R o ) k > → o and Let P k ( k > ) and P be the following S -derivations: P k = f : ( k · (2 · o ) → o ) [1] x : (2 · R o ) [1] ( x : ( i · R o ) [ i −
1] ) i > x : ( i · R o ) i > ⊢ x x : o [2] f : ( k · (2 · o ) → o ) ⊢ f ( x x ) : o [0] f : ( k · (2 · o ) → o ) ⊢ ∆ f : R o P = P [1] ( P k [ k − k > f : ( k · (2 · o ) → o ) k > ⊢ ∆ f ∆ f • Let ˜ P k ( k > ) and ˜ P be the following S -derivations: ˜ P k = f : ( k · (2 · o ) → o ) [1] x : (3 · R o ) [1] x : (2 · R o ) [2] ( x : ( i · R o ) [ i −
1] ) i > x : ( i · R o ) i > ⊢ x x : o [2] f : ( k · (2 · o ) → o ) ⊢ f ( x x ) : o [0] f : ( k · (2 · o ) → o ) ⊢ ∆ f : R o ˜ P = ˜ P [1] ( ˜ P k [ k − k > f : ((2 · o ) → o ) k > ⊢ ∆ f ∆ f • The rigid derivations P and ˜ P both represent Π . Intuitively, subject reduction in P will consist in taking the first argument P , placing it on the first occurrence of x in f ( x x ) (in P ) and putting the other P k ( k > ) in the different axiom rules typing thesecond occurrence of x in the same order, i.e. , for k > , P k is moved from track k − to track k − . There is a simple decrease on the track number and we can go this waytowards P ′ typing f ω .The rigid derivation ˜ P process the same way, except it will always skip ˜ P ( ˜ P willremain on track 2). Morally, we perform subject reduction “by-hand” while avoiding toever place ˜ P in head position, i.e. ˜ P is never “consumed” by reduction.A computation shows that infinitary reductions performed in P and ˜ P yield respec-tively to P ′ and ˜ P ′ of Fig. 19.Thus, P ′ and ˜ P ′ both represent Π ′ (from Sec. 3.5), but P ′ is quantitative whereas ˜ P ′ is not (the track type assigned to f does not end in an axiom leaf). This provesthat quantitativity is not stable up to the limit of a productive reduction path and that ˜ P is not approximable by Proposition 31.Moreover, by Proposition 36, P ′ is approximable. By infinitary subject expansion, P also is (actually, one may also use the S -representatives of Π n and Π ′ n in Fig. 7 toapproximate P and P ′ arbitrarily). Conclusion.
Thus, Π and Π ′ have both approximable and not approximable represen-tatives. Actually, Π has a representative which is quantitative but not approximable.This proves that approximability cannot be defined in system R . EQUENCE TYPES AND INFINITARY SEMANTICS 77
Appendix F. Characterization of Hereditary Permutators
F.1.
Hereditary Permutators are Typable with Permutator Pairs.Claim (given on p. 45) . Let y ∈ V and t be a y -head hereditary permutator. Thenthere is an approximable S -derivation P and a permutator pair ((2 · S ) , T ) such that P (cid:3) y : (2 · S ) ⊢ h : T . Proof.
Claim 1 is proved by using techniques akin to those we used to deal with naturalextensions in Sec. 7.2.Let ι be an injection from B = supp ( t ) to O . We associate to each b ∈ supp ( t ) twoindeterminates X b and Y b . The idea is that X b is a placeholder for the types of headvariables and Y b is a placeholder for the types of the sub-hereditary permutators of t . Notations to handle sub-hereditary permutators in t . We denote by B hp the set of po-sitions b of subterms of t that are x -HP for some x ∈ V and, for all b ∈ B hp , hvp ( b ) denotes the position of the head variable of t | b ( hvp stands for “head variable position”).Formally: • B hp = { ε } ∪ { b · ∈ supp ( t ) | b ∈ { , , } ∗ } since b ∈ B hp iff b is the root of t or it isthe argument of an application in t • For all b ∈ B hp , hvp ( b ) is the longest b such b ∈ b · { , } ∗ For all b ∈ B hp , then we denote by x b the head variable of hv ( t | b ) , e.g. , if t = λz z . ( y ( λz z .z t t ))( λz .z t ) ,then hvp ( ε ) = 0 · and x ε = y . Moreover, t | · = λz .z t , so hvp (0 ·
2) = 0 · · · and x · = z , hvp (0 · ·
2) = 0 · · · · and x · · = z . Observe that, if b ∈ B hp and n = ar ( t | b ) , then hvp ( b ) = b · n · n ∈ B hp . We just write o b instead of ι ( hvp ( t | b )) ,so that o b will be the type atom assigned to the head variable y = t ( hvp ( b )) of t | b , whichis a y -HP. Defining the permutations pairs inside t . Moreover, for b ∈ B hp , then t | b is of the form λx . . . x n .x b h x σ (1) . . . h x σ ( n ) with n = ar ( t | b ) > and σ ∈ S n . We then denote by σ b the permutator σ and we set b ( k ) = b · n · k − · for k n , so that b ( k ) is theposition of h x σ ( k ) . For k n , we also abusively write b ( σ ( k )) instead of b ( σ b ( k )) .We then set, for all b ∈ B hp : F ( b ) = (2 · Y b ( σ (1)) ) → . . . → (2 · Y b ( σ ( n )) ) → o b G ( b ) = (2 · X b (1) ) → . . . → (2 · X b ( n ) ) → o b We may then implement ( eq ) and ( eq ) by coinductively defining, for all b ∈ B hp , S ( b ) = F ( b )[ S ( b ′ ) /X b ′ , T ( b ′ ) /Y b ′ ] b ′ ∈ B hp T ( b ) = G ( b )[ S ( b ′ ) /X b ′ , T ( b ′ ) /Y b ′ ] b ′ ∈ B hp The definition of S ( b ) and T ( b ) is well founded since if X b ′ or Y b ′ occur at position c in S ( b ) or T ( b ) , then ad ( c ) > . By construction, for all b ∈ B hp , ( S ( b ) , T ( b )) is a proper permutator pair. Let us now construct a quantitative S -derivation P , such that, for all b ∈ B hp , P ( b ) = x b : (2 · S ( b )) ⊢ t | b : T ( b ) . In particular, with b = ε , we will have P (cid:3) x : (2 · S ) ⊢ t : T with S = S ( ε ) and T = T ( ε ) . Since t is a normal form, byLemma 35, P will be approximable, which will conclude the proof. Construction of P : we now build P . The construction is illustrated with Fig. 20. Onceagain, the notation h·i indicates the position, e.g. , h b i means that the node labelledwith λx is at position b . Let b ∈ supp ( t ) . There are three possibilities: • t ( b ) = y for some y ∈ V : then b = b · n · n with b ∈ B hp and n > . • t ( b ) = @ : then b = b · n · i with b ∈ B hp , n > and i < n . ✬✫ ✩✪ x h b · n · n i S = T σ (1) → . . . → T σ ( n ) → o b h σ (1) : T σ (1) h b i headed by x σ (1) : S σ (1) @ h σ ( n − : T σ ( n − h b n − i @ h σ ( n ) : T σ ( n ) h b n i headed by x σ ( n ) : S σ ( n ) @ h b · n i : o b λx n S n → o λx h b i h : T = S → . . . → S n → o Figure 20.
Typing a hereditary permutator • t ( b ) = λy for some y ∈ V : then b = b · i with b ∈ B hp and i < n = ar ( t | b ) .Let b ∈ B hp . Then t | b is of the form h = λx . . . x n .y h σ (1) . . . h σ ( n ) for some n > , σ ∈ S n and h , . . . , h n hereditary permutators respectively headed with x , . . . , x n . Beforedefining the judgments in P , we give some preliminary notations and observations: weset b j = b · n · n − j · so that b j is the position of h σ ( j ) for j n . In particular, b j ∈ B hp and S ( b j ) , T ( b j ) have been defined in the first part of the proof. We also set b ′ j = b σ − ( j ) . The type of h σ ( j ) is intended to be T ( b j ) and that of x σ ( j ) to be S ( b j ) (sothat he type of x j should be S ( b ′ j ) ). We may now define P ( b ) case-wise: • For b = b · n · i with i n , then t | b = y h σ (1) . . . h σ ( k ) with k = n − i , so that fv ( t | b ) = { y, x σ (1) , . . . , x σ ( k ) } . We define: P ( b ) = y : (2 · S ( b )) , x σ (1) : (2 · S ( b )) , . . . , x σ ( k ) : (2 · S ( b k )) ⊢ t | b : T ( b ) → . . . → T ( b k ) → o b In particular, when i = n , P ( b ) = y : (2 · S ( b )) ⊢ y : S ( b ) . • For b = b · i with i n , then t | b = λx i +1 . . . x n .y h σ (1) . . . h σ ( n ) , so that fv ( t | b ) = { y, x , . . . , x i } . We define: P ( b ) = y : (2 · S ( b )) , x : (2 · S ( b ′ )) , . . . , x i : (2 · S ( b ′ i )) ⊢ t | b : S ( b ′ i +1 ) → . . . S ( b ′ n ) → o b Note that the definition agree with the previous case when i = n . In the case i = 0 , i.e. b = b , we obtain y : (2 · S ( b )) ⊢ t | b : T ( b ) as expected.Thus, P ( b ) is defined for all b ∈ supp ( t ) . We just need to check that P is a correctderivation. For this, let us use the same notations and observe then that, for i nP ( b i ) = x σ ( i ) : (2 · S ( b i )) ⊢ h σ ( i ) : T ( b i ) , which proves that every application andabstraction node has correct premises in the case-wise definition of P ( b ) above.F.2. Approximating permutator pairs.
The lemma below is enough to prove Lemma 42:
Lemma 72. If t is a 001-NF and P (cid:3) x : (2 · S ) ⊢ t : P is approximable, where ( S, T ) ∈ PPP , then, for all d ∈ N , there is a finite P d P such that P d (cid:3) x : (2 · ( S ) d ) ⊢ t : ( T ) d . Proof.
By Theorem 6, t is a hereditary permutator. Assume that t = λx . . . x p .x t . . . t p with x = x i , S = (2 · T σ (1) ) → . . . → (2 · T σ ( n ) ) → o and T = (2 · S ) → . . . → (2 · S n ) → o .By syntax-direction of system S , P is of the form given by Fig. 15. In particular, we EQUENCE TYPES AND INFINITARY SEMANTICS 79 have unique subderivations P , . . . , P p of P at applicative depth 1, respectively typing t , . . . , t p . We proceed by induction on d . • Case d = 0 . We set S = T = ( ) → . . . → ( ) → o (arity n ) so that ( S , T ) ∈ PPP .Let P = ax x : (2 · S ) ⊢ s : S app x : (2 · S ) ⊢ x t : ( ) → . . . ( ) → o (arity n − ) app ... app x : (2 · S ) ⊢ x t . . . t p : ( ) → . . . ( ) → o (arity n − p ) abs x : (2 · S ) ⊢ λx .x t . . . t p : ( ) → . . . ( ) → o (arity n − p + 1 ) abs ... abs x : (2 · S ) ⊢ λx . . . x p .x t . . . t p : T By construction, P P . • Case d > : by the induction hypothesis, there are P d − i P i concluding with x σ ( i ) : (2 · ( S σ ( i ) ) d − ⊢ t i : ( T σ ( i ) ) d − . We set: P d = ax x : (2 · ( S ) d ) ⊢ x : ( S ) d P d − app ... P d − p app x : (2 · ( S ) d ) , x : (2 · ( S σ (1) ) d − ) , . . . ⊢ x t . . . t p : (2 · ( T σ ( p +1) ) d − ) → o abs ... abs x : (2 · ( S ) d ) ⊢ t : ( T ) d Since P d − i P i for i p , we conclude that P d P as expected. This work is licensed under the Creative Commons Attribution License. To view a copyof this license, visit https://creativecommons.org/licenses/by/4.0/https://creativecommons.org/licenses/by/4.0/