Introduction Non-Idempotent Types Inhabitation
Linear Logic and Intersection Types
Introduction Non-Idempotent Types Inhabitation
Agenda for Today
1 Introduction
2 Non-Idempotent Types
3 Inhabitation
Introduction Non-Idempotent Types Inhabitation
Agenda
1 Introduction
2 Non-Idempotent Types
3 Inhabitation
Introduction Non-Idempotent Types Inhabitation
Simply versus Intersection Types
Simply typedterms⊆strongly-normalizingterms.
Simply typedterms+strongly-normalizingterms.
(e.g.λx.xx).
Finite polymorphism
Simply types No
Intersection Types Yes x:(σ→σ)∧σ`xx:σ
Intersection typedterms=strongly-normalizingterms.
Intersection type systems areundecidable.
Introduction Non-Idempotent Types Inhabitation
Intersection Types
SystemC(Coppo-Dezani).
Contains aconstant typeωto typeALLterms.
SystemP(Pottinger).
No constant type.
Types in both systems enjoy ACI Axioms.
Associativity (σ∧ρ)∧τ ∼ σ∧(ρ∧τ) Commutativity σ∧ρ ∼ ρ∧σ
Idempotence σ∧σ ∼ σ
Introduction Non-Idempotent Types Inhabitation
Some Typical Results in λ -Calculus by means of Intersection Types
Definition
LetRbe any reduction sequence.
A termtis anR-normal formiff there is nopsuch thatt→Rp.
A termtisR-weakly normalizingiff there is some reduction sequencet→∗Rp, wherepis a normal form.
A termtisR-strongly normalizingiff there is no infinite reduction sequence t→R→R. . ..
The previous three notions will be considered for different reduction relations, notably for β-reduction.
A termtisβ-head normalizingifft→∗βλx1...xn.yt1...tm(n,m≥0). Ahead contextis a context of the shape(λx1...xn.)t1...tm(n,m≥0) A termtissolvableiff there is a head contextCs.t.C[t]→∗βλx.x
Introduction Non-Idempotent Types Inhabitation
Some Typical Results by means of Intersection Types
Theorem
A termtissolvableiff it isβ-head normalizingiffΓ`t:σin systemCfor someΓand σsuch thatσ/ω.
Theorem
A termtisβ-weakly normalizingiffΓ`t:σin systemCfor someΓandσsuch that ω<pos+([Γ, σ]).
Theorem
A termtisstrongly-normalizingiffΓ`t:σin systemPfor someΓandσ.
Introduction Non-Idempotent Types Inhabitation
Comments
Only qualitative (and not quantitative) information is provided in the previous theorems.
No relation between types and consumption of resources.
Introduction Non-Idempotent Types Inhabitation
Towards Non-Idempotent Intersection Types
The idempotence axiom is ruled out, i.e.σ∧σ/σ
The non-idempotent intersection operator∧can be seen as the multiplicative linear logic connective⊗.
Quantitave models forλ-calculi (De Carvalho, Ehrhard).
Head-Normalization, Solvability, Weak-Normalization and Strong-Normalization can be proved bycombinatorialarguments (weightedsubject reduction properties).
Implicit Complexity⇒use of ressources (e.g. substitution) can be measured.
Partial substitution (c.f. Proof-Nets) can be seen as a measured operation of substitution.
Introduction Non-Idempotent Types Inhabitation
Agenda
1 Introduction
2 Non-Idempotent Types
3 Inhabitation
Introduction Non-Idempotent Types Inhabitation
Towards non-idempotent types
Pioneers: P. Gardner, A. Kfoury, D. de Carvalho.
Several typing systems sharing the same principles.
Intuitionistic calculi, classical calculi, etc.
Called alsoquantitative types.
We choose here to present the main principles of non-idempotent types on a language with partial substitution.
Introduction Non-Idempotent Types Inhabitation
The Linear Substitution Calculus
Inspired from Milner’s calculus with partial substitution and the structural lambda calculus.
Terms:λ-terms withexplicit substitutions.
Contexts are terms with one whole.
Reduction Relation→LSCis at adistanceand performspartialsubstitution:
(λx.t)[y1/v1]. . .[yn/vn]u 7→B t[x/u][y1/v1]. . .[yn/vn] C[[x]][x/u] 7→c C[[u]][x/u]
t[x/u] 7→Gc t if|t|x=0
Example
(xx)[x/I]→c(xI)[x/I]→c(II)[x/u]→GcII→Bx[x/I]→cI[x/I]→Gc I
Introduction Non-Idempotent Types Inhabitation
Linear-Head Reduction
Inspired from Milner’s calculus.
With Linear-Logic Proof-Nets flavour.
Conexion with Krivine’s Abstract Machine.
Linear-Head Reduction is astandard strategy.
Linear-Head Reduction (lineary) performs reduction only onhead-positions.
Linear-Head Reductiondoes not eraseterms.
Introduction Non-Idempotent Types Inhabitation
Linear-Head Reduction Formally
Linear-Head Contexts:LH::=|λx.LH|LHt|LH[x/t].
Linear-Head Reduction (written→lhr): rules{B,hc}closed byhead-linear contexts.
(λx.t)[y1/v1]. . .[yn/vn]u 7→B t[x/u][y1/v1]. . .[yn/vn]
LH[[x]][x/u] 7→hc LH[[u]][x/u]
Remark:→lhr⊆→LSC.
Example
(xx)[x/I]→hc(I x)[x/I]→By[y/x][x/I]→hcx[y/x][x/I]→hcI[y/x][x/I]
is a linear-head reduction
(xx)[x/I]→c(xI)[x/I]→c(II)[x/I]→Gc II→By[y/I]→cI is not
Introduction Non-Idempotent Types Inhabitation
Types for Milner’s calculus
Types:
Strict Types
Non-idempotent intersection
Intersection types are represented by multisets (σ∧σis{{σ, σ}}).
σ ::= α|A→σ (linear types) A ::= {{ }} |B (multiset types)
B ::= {{σk}}k∈K(I,∅) (non-empty multiset types) Typing Rules:
Relevance (no weakening) Multiplicative rules
Syntax-directed typing rules
Typed termsmay containuntyped subterms(I=∅)
Introduction Non-Idempotent Types Inhabitation
The Type System H W
x:{{σ}} `x:σ (var) Γ`t:σ
Γ\x`λx.t:Γ(x)→σ (→I) Γ`t:{{σk}}k∈K→σ (∆k`u:σk)k∈K
Γ +k∈K∆k`tu:σ (→E) x:{{σk}}k∈K;Γ`t:σ (∆k`u:σk)k∈K
Γ +k∈K∆k`t[x/u] :σ (Cut)
Introduction Non-Idempotent Types Inhabitation
Example
(var) x:{{{{ }} →σ}} `x:{{ }} →σ
(→E) x:{{{{ }} →σ}} `xv:σ
(Cut) x:{{{{ }} →σ}} `(xv)[y/u] :σ
Typed terms may contain (pink) untyped subterms.
Introduction Non-Idempotent Types Inhabitation
Measuring Typing Derivations
Definition
Given a type derivationΦ, we define themeasureM(Φ)as the number of occurrences of typing rulesvar,→I,→EandCutinΦ.
Example
(var) x:{{{{ }} →σ}} `x:{{ }} →σ
(→E)
x:{{{{ }} →σ}} `xv:σ
(Cut) x:{{{{ }} →σ}} `(xv)[y/u] :σ
The measure of this type derivation is3.
Introduction Non-Idempotent Types Inhabitation
Relevance
Lemma (Weak Relevance)
IfΓ`H W t:σ, thendom(Γ)⊆fv(t).Introduction Non-Idempotent Types Inhabitation
Technical Tools for Characterizing Head-Linear Normalization
Positionof terms are finite words on the alphabet{0,1}.
A positionp∈pos(t)is atyped occurrenceofΦif eitherp=, orp=ip0(i=0,1) andp0∈pos(t|i)is a typed occurrence ofsomeof their corresponding
subderivations.
A redex occurrence oftwhich is also a typed occurrence ofΦis atyped redex occurrenceoftinΦ.
x:{{{{τ, τ}} →τ}} `x:{{τ, τ}} →τ
y:{{{{ }} →τ}} `y:{{ }} →τ y:{{{{ }} →τ}} `yz:τ
y:{{{{τ}} →τ}} `y:{{τ}} →τ z:{{τ}} `z:τ y:{{{{τ}} →τ}},z:{{τ}} `yz:τ x:{{{{τ, τ}} →τ}},y:{{{{ }} →τ,{{τ}} →τ}},z:{{τ}} `x(yz):τ
x:{{{{τ, τ}} →τ}} `x:{{τ, τ}} →τ
y:{{{{ }} →τ}} `y:{{ }} →τ y:{{{{ }} →τ}} `yz:τ
y:{{{{ }} →τ}} `y:{{ }} →τ y:{{{{ }} →τ}} `yz:τ x:{{{{τ, τ}} →τ}},y:{{{{ }} →τ,{{ }} →τ}} `x(yz):τ
Introduction Non-Idempotent Types Inhabitation
Results: towards characterization of head-linear normalization
Lemma (Weighted Subject Reduction for Typed Redex Occurrences)
WheneverΠ:Γ`H Wt:σandt→LSCt0reduces atyped redex occurrence, then Π0:Γ`H Wt0:σandM(Π)>M(Π0).Corollary (Weighted Subject Reduction for Linear-Head Reduction)
WheneverΠ:Γ`H Wt:σandt→lhrt0, thenΠ0:Γ`H Wt0:σandM(Π)>M(Π0).Lemma (Subject Expansion for the Linear Substitution Calculus)
IfΠ:Γ`H Wt:σandt0→LSCt, thenΠ0:Γ`H W t0:σ.Corollary (Subject Reduction for Linear-Head Reduction)
IfΠ:Γ`H Wt:σandt0→lhrt, thenΠ0:Γ`H W t0:σ.Introduction Non-Idempotent Types Inhabitation
Results: characterization of head-linear normalization
Theorem
The following statements are equivalent:
tislhr-weakly normalizing.
tisH W-typable.
Proof.uses, between others,
WeightedSubject Reduction (combinatorial argument for non-idempotent types).
Subject Expansion.
Introduction Non-Idempotent Types Inhabitation
Results: towards characterization of weak normalization
PositiveandNegativeoccurrences of types are defined as follows.
A∈pos+(A).
A∈pos+({{σk}}k∈K)if∃kA∈pos+(σk);A∈pos−({{σk}}k∈K)if∃kA∈pos−(σk). A∈pos+(E→τ)ifA∈pos−(E)orA∈pos+(τ);A∈pos−(E→τ)ifA∈pos+(E)or A∈pos−(τ).
A∈pos+(Γ)if∃y∈dom(Γ)s.t.A∈pos−(Γ(y));A∈pos−(Γ)if∃y∈dom(Γ)s.t.
A∈pos+(Γ(y)).
A∈pos+([Γ, τ])ifA∈pos+(Γ)orA∈pos+(τ);A∈pos−([Γ, τ])ifA∈pos−(Γ)or A∈pos−(τ).
As an example,{{ }} ∈pos+({{ }}), so that{{ }} ∈pos−({{ }} →σ),{{ }} ∈pos+(x:{{{{ }} →σ}})and {{ }} ∈pos+([x:{{{{ }} →σ}}, σ]).
Introduction Non-Idempotent Types Inhabitation
Results: characterization of weak normalization
Theorem (Weak-Normalization)
A termtisLSC-weakly normalizingiffΓ`t:σin systemH Wfor someΓandσsuch that{{ }}<pos+([Γ, σ]).
The following term isLSC-weakly normalizing:
z:α`(λx.z)(∆∆) :α The following term is notLSC-weakly normalizing:
z:{{{{ }} →α}} `z(∆∆) :α
Introduction Non-Idempotent Types Inhabitation
The Type System S
x:{{σ}} `x:σ (var) Γ`t:σ
Γ\x`λx.t:Γ(x)→σ (→I) Γ`t:{{σk}}k∈K→σ (∆k`u:σk)k∈K I,∅
Γ +k∈K∆k`tu:σ (→E1)
x:{{σk}}k∈K;Γ`t:σ (∆k`u:σk)k∈K I,∅ Γ +k∈K∆k`t[x/u] :σ (Cut1) Γ`t:{{ }} →σ ∆`u:τ
Γ + ∆`tu:σ (→E2) Γ`t:σ ∆`u:τ x<dom(Γ) Γ + ∆`t[x/u] :σ (Cut2)
Introduction Non-Idempotent Types Inhabitation
Relevance
Lemma (Strong Relevance)
IfΓ`St:σ, thendom(Γ)=fv(t).Introduction Non-Idempotent Types Inhabitation
Results: characterization of strong normalization
Theorem (Strong-Normalization)
A termtisLSC-strongly normalizingifftisS-typable.
Proof.uses
Postponementoferasingsteps (which does not hold inλ-calculus).
WeightedSubject Reduction for systemS. Subject Expansion for systemS.
Introduction Non-Idempotent Types Inhabitation
Agenda
1 Introduction
2 Non-Idempotent Types
3 Inhabitation
Introduction Non-Idempotent Types Inhabitation
Turning the inhabitation problem into a decidable
question
Introduction Non-Idempotent Types Inhabitation
Typing and Inhabitation Problems
Typing Inhabitation
?`t: ? Γ`?:A
Simple Types: Decidable Decidable
Idempotent Types: Undecidable Undecidable (Urzyczyn) Non-idempotent Types: Undecidable Decidable
(Bucciarelli-K.-Ronchi Della Rocca)
Decidability of restricted classes of idempotent types (Kurata & Takahashi), (Urzyczyn), (Bunder), (Ku´smierek), (Dudenhefner & Rehof), . . .
Introduction Non-Idempotent Types Inhabitation
The Typing System for the Lambda-Calculus
x:{{σ}} `x:σ (var) Γ`t:σ
Γ\x`λx.t:Γ(x)→σ (→I) Γ`t:{{σi}}i∈I→σ (∆i`u:σi)i∈I
Γ +i∈I∆i`tu:σ (→E)
Introduction Non-Idempotent Types Inhabitation
Approximants
How to restrict the search space of the algorithm?
We use the normalization property to restrict the search space toapproximants:
a,b,c ::= Ω| N N ::= λx.N | L L ::= x| La
Introduction Non-Idempotent Types Inhabitation
The Algorithm
a∈T(Γ +(x:A), τ) x<dom(Γ)
λx.a∈T(Γ,A→τ) (Abs)
Γ = +i=1...nΓi (bi∈TI(Γi, σi))i=1...n
xb1. . .bn∈T(Γ +(x:{{A1→. . .→An→τ}}), τ) (Head)
(ai∈T(Γi, σi))i∈I ↑i∈Iai _
i∈I
ai∈TI(+i∈IΓi,{{σi}}i∈I) (Union)
Introduction Non-Idempotent Types Inhabitation
Soundness and Completeness
Theorem
The algorithm terminates, is sound and complete.
Introduction Non-Idempotent Types Inhabitation
Some Final Remarks
Non-idempotentintersection types are particularly pertinent for calculi with ressources.
Arithmeticalarguments for terminating proofs.
New logical characterization oflinear-headnormalization.
The inhabitation problem for intersection types has been proved to be undecidable, but breaking the idempotency of intersection types makesinhabitation decidable.