Lectures onType Theory
Higher-kinded polymorphism and existential packages
appendix sectionrules

Higher-kinded polymorphism and existential packages

Kinds and constructors are κ::=Tyκκ,A::=uNAAA×Au::κ.Au::κ.Aλu::κ.AAA. Kind contexts contain distinct variables. The complete kinding rules are preceded by formation:

 kctx
KCtx-Empty
Δ kctxudom(Δ)
Δ,u::κ kctx
KCtx-Ext

The kinding rules are

(u::κ)Δ
Δu::κ
K-Var
ΔN::Ty
K-Nat
ΔA::TyΔB::Ty
ΔAB::Ty
K-Arr
ΔA::TyΔB::Ty
ΔA×B::Ty
K-Prod
Δ,u::κA::Ty
Δu::κ.A::Ty
K-All
Δ,u::κA::Ty
Δu::κ.A::Ty
K-Some
Δ,u::κ1A::κ2
Δλu::κ1.A::κ1κ2
K-Abs
ΔA::κ1κ2ΔB::κ1
ΔAB::κ2
K-App

Constructor one-step reduction is generated by constructor beta and the complete congruence family below:

(λu::κ.A)BβA[B/u]
TR-Beta
AβA
ABβAB
TR-App_1
BβB
ABβAB
TR-App_2
AβA
(AB)β(AB)
TR-Arr_1
BβB
(AB)β(AB)
TR-Arr_2
AβA
A×BβA×B
TR-Prod_1
BβB
A×BβA×B
TR-Prod_2
AβA
λu::κ.Aβλu::κ.A
TR-Abs
AβA
u::κ.Aβu::κ.A
TR-All
AβA
u::κ.Aβu::κ.A
TR-Some

Constructor equality is the equivalence and congruence generated by constructor beta. Its complete noncongruence rules are

ΔA::κ
ΔAA::κ
Q-Refl
ΔAB::κ
ΔBA::κ
Q-Sym
ΔAB::κΔBC::κ
ΔAC::κ
Q-Trans
Δ,u::κ1A::κ2ΔB::κ1
Δ(λu::κ1.A)BA[B/u]::κ2
Q-Beta

The complete congruence family is

ΔA1B1::TyΔA2B2::Ty
ΔA1A2B1B2::Ty
Q-Arr
ΔA1B1::TyΔA2B2::Ty
ΔA1×A2B1×B2::Ty
Q-Prod
Δ,u::κAB::Ty
Δu::κ.Au::κ.B::Ty
Q-All
Δ,u::κAB::Ty
Δu::κ.Au::κ.B::Ty
Q-Some
Δ,u::κ1AB::κ2
Δλu::κ1.Aλu::κ1.B::κ1κ2
Q-Abs
ΔA1B1::κ1κ2ΔA2B2::κ1
ΔA1A2B1B2::κ2
Q-App

The first line of the term grammar is the pure Fω language of chapter 9; the second line is the package extension of chapter 10: e::=xλx:A.eeeΛu::κ.ee[A]e,eprjie0suc(e)pack[C,e] as u::κ.Aunpack[u,x]=e in e. Its complete typing table is formed over term contexts generated by

Δ kctx
Δ ctx
Ctx-Empty
ΔΓ ctxΔA::Tyxdom(Γ)
ΔΓ,x:A ctx
Ctx-Ext

The typing rules are

(x:A)Γ
Δ;Γx:A
T-Var
ΔA::TyΔ;Γ,x:Ae:B
Δ;Γλx:A.e:AB
T-Lam
Δ;Γe1:ABΔ;Γe2:A
Δ;Γe1e2:B
T-App
Δ,u::κ;Γe:A
Δ;ΓΛu::κ.e:u::κ.A
T-TLam
Δ;Γe:u::κ.AΔC::κ
Δ;Γe[C]:A[C/u]
T-TApp
Δ;Γe1:A1Δ;Γe2:A2
Δ;Γ(e1,e2):A1×A2
T-Pair
Δ;Γe:A1×A2
Δ;Γprie:Ai
T-Prj
Δ;Γ0:N
T-Zero
Δ;Γe:N
Δ;Γsuc(e):N
T-Suc
Δ;Γe:AΔAB::Ty
Δ;Γe:B
T-Conv

The existential rules, including the nonescape premise, are

ΔC::κΔ,u::κA::TyΔ;Γe:A[C/u]
Δ;Γpack[C,e] as u::κ.A:u::κ.A
T-Pack
Δ;Γe1:u::κ.AΔ,u::κ;Γ,x:Ae2:BΔB::Ty
Δ;Γunpack[u,x]=e1 in e2:B
T-Unpack

The last formation premise is the escape check: u cannot occur free in B because B is formed before u is added.

Call-by-value evaluation uses v::=λx:A.eΛu::κ.e(v1,v2)0suc(v)pack[C,v] as u::κ.A,E::=[]EevEE[C](E,e)(v,E)priEsuc(E)pack[C,E] as u::κ.Aunpack[u,x]=E in e. Deleting the final value and the final two context productions gives a context grammar equivalent to the complete pure congruence family of definition 11.7. The package chapter adds those productions without changing the order of the pure ones. The pure calculus has the three root contractions

(λx:A.e)ve[v/x]
E-Beta
(Λu::κ.e)[C]e[C/u]
E-TBeta
i{1,2}
pri(v1,v2)vi
E-PrjPair

Its complete congruence family is

e1e1
e1e2e1e2
E-App_1
e2e2
v1e2v1e2
E-App_2
ee
e[C]e[C]
E-TApp
e1e1
(e1,e2)(e1,e2)
E-Pair_1
e2e2
(v1,e2)(v1,e2)
E-Pair_2
ee
prieprie
E-Prj
ee
suc(e)suc(e)
E-Suc

The package-opening extension is unpack[u,x]=(pack[C,v] as a::κ.A0) in ee[C/u][v/x]. The contextual rule is eeEeEe; there are no other call-by-value steps.

Compatible term beta is closed under every term constructor and has four roots: (λx:A.e)dβe[d/x],(Λu::κ.e)[C]βe[C/u],pri(e1,e2)βei,unpack[u,x]=(pack[C,d] as a::κ.A0) in eβe[C/u][d/x].

For the static fixed-record boundary used at the end of the chapter, extend the grammars by A::={i:Ai}iI,e::={i=ei}iIe., where the finite label set contains no duplicates. The complete additional static rules are

ΔAi::Ty (iI)
Δ{i:Ai}iI::Ty
Rec-F
Δ;Γei:Ai (iI)
Δ;Γ{i=ei}iI:{i:Ai}iI
Rec-I
Δ;Γe:{i:Ai}iIjI
Δ;Γe.j:Aj
Rec-E
ΔAiBi::Ty (iI)
Δ{i:Ai}iI{i:Bi}iI::Ty
Q-Rec

This record delta is static only; the chapter states no record dynamics.

Search the book

Type to search the local edition.