Lectures onType Theory
Immutable-record subtyping and bounded quantification
appendix sectionrules

Immutable-record subtyping and bounded quantification

This section records the exact immutable-record and bounded-subtyping systems. The fixed records at the end of the preceding section were a static boundary for Fω and had no reduction rules. The records below instead belong to an immutable call-by-value calculus. They are finite maps at both the type and term levels, and their fields evaluate in a fixed total order. Thus this section does not add dynamics to the preceding Fω fragment.

The first-order declarative calculus

The complete first-order type grammar is A,B::=TopBotUnitBoolNatABA×BA+B{i:Ai}iI. The index set I is finite, displayed labels are distinct, and reordering a display does not change the finite map. The first-order context Γ contains term declarations only. All rules below are schemas over well-formed types. Formation of the complete grammar is

Γ ctx
ΓTop type
B-Ty-Top
Γ ctx
ΓBot type
B-Ty-Bot
Γ ctx
ΓUnit type
B-Ty-Unit
Γ ctx
ΓBool type
B-Ty-Bool
Γ ctx
ΓNat type
B-Ty-Nat
ΓA typeΓB type
ΓAB type
B-Ty-Arr
ΓA typeΓB type
ΓA×B type
B-Ty-Prod
ΓA typeΓB type
ΓA+B type
B-Ty-Sum
ΓAi typefor every iI
Γ{i:Ai}iI type
B-Ty-Rcd

The declarative subtype judgment is ΓA<:B.

ΓA type
ΓA<:A
S-Refl
ΓA<:BΓB<:C
ΓA<:C
S-Trans
ΓA type
ΓA<:Top
S-Top
ΓA type
ΓBot<:A
S-Bot
ΓB1<:A1ΓA2<:B2
ΓA1A2<:B1B2
S-Arr
ΓA1<:B1ΓA2<:B2
ΓA1×A2<:B1×B2
S-Prod
ΓA1<:B1ΓA2<:B2
ΓA1+A2<:B1+B2
S-Sum
JIΓAj<:Bjfor every jJ
Γ{i:Ai}iI<:{j:Bj}jJ
S-Rcd

The term grammar is the inherited explicitly typed call-by-value grammar with the delta t::=0suc(t)natrec(t;t0;x.y.ts)::={i=ti}iIt.,v::=0suc(v){i=vi}iI. The natural-number typing delta is

Γ0:Nat
T-Zero
Γt:Nat
Γsuc(t):Nat
T-Suc
Γt:NatΓt0:AΓ,x:Nat,y:Ats:A
Γnatrec(t;t0;x.y.ts):A
T-NatRec

Subsumption, record introduction, and projection are exactly

Γt:AΓA<:B
Γt:B
T-Sub
Γti:Aifor every iI
Γ{i=ti}iI:{i:Ai}iI
T-Rcd
Γt:{i:Ai}iIkI
Γt.k:Ak
T-Proj

Natural-number evaluation adds the two congruences and two roots

tt
suc(t)suc(t)
E-Suc
tt
natrec(t;t0;x.y.ts)natrec(t;t0;x.y.ts)
E-NatRec
natrec(0;t0;x.y.ts)t0
E-NatZero
natrec(suc(v);t0;x.y.ts)ts[xv,ynatrec(v;t0;x.y.ts)]
E-NatSuc

Record evaluation adds the following three rules. In E-Rcd, i<k refers to the fixed total order of labels.

tktkti is a value for every i<k
{,k=tk,}{,k=tk,}
E-Rcd
kI
{i=vi}iI.kvk
E-Proj
tt
t.kt.k
E-ProjCong

There is no runtime form and no reduction rule for subsumption.

Kernel bounded quantification

Kernel F<: extends precisely the grammar above by A,B::=XX<:A.B,t,u::=ΛX<:A.tt[B]. Contexts now mix term declarations and type bounds. Every declaration is checked in the prefix to its left, so a newly declared X cannot occur in its own bound. Lookup of a type bound is written Γ(X)=A.

 ctx
C-Empty
Γ ctxΓA typexdom(Γ)
Γ,x:A ctx
C-Term
Γ ctxΓA typeXdom(Γ)
Γ,X<:A ctx
C-Type

Type-variable and bounded-universal formation are

Γ(X)=A
ΓX type
B-Ty-Var
ΓA typeΓ,X<:AB type
ΓX<:A.B type
B-Ty-All

The Kernel subtype and term rules added to the first-order tables are

Γ(X)=A
ΓX<:A
S-Var
Γ,X<:AB<:C
ΓX<:A.B<:X<:A.C
S-AllK
Γ,X<:At:B
ΓΛX<:A.t:X<:A.B
T-TAbs
Γt:X<:A.BΓC<:A
Γt[C]:B[C/X]
T-TApp

The two bounds in S-AllK are the same constructor modulo alpha-equivalence; the rule does not compare distinct bounds.

Type abstractions are values, type application evaluates its operator, and the one new root contraction is v::=ΛX<:A.t,E::=E[C],(ΛX<:A.t)[C]t[C/X].

The deterministic Kernel algorithm

The judgment ΓaA<:B is read by priority: test alpha-equality, then a top target, then a bottom source, then source-variable promotion, and only then matching outer constructors. A universal comparison fails when its two bounds are not alpha-identical. The following guards make that priority part of the derivation rather than an unstated implementation convention.

AαB
ΓaA<:B
A-Eq
AαTop
ΓaA<:Top
A-Top
BαBotBαTop
ΓaBot<:B
A-Bot
XαBBαTopΓ(X)=UΓaU<:B
ΓaX<:B
A-Var
A1A2αB1B2ΓaB1<:A1ΓaA2<:B2
ΓaA1A2<:B1B2
A-Arr
A1×A2αB1×B2ΓaA1<:B1ΓaA2<:B2
ΓaA1×A2<:B1×B2
A-Prod
A1+A2αB1+B2ΓaA1<:B1ΓaA2<:B2
ΓaA1+A2<:B1+B2
A-Sum
{i:Ai}iIα{j:Bj}jJJIΓaAj<:Bjfor every jJ
Γa{i:Ai}iI<:{j:Bj}jJ
A-Rcd
X<:A.BαX<:A.CΓ,X<:AaB<:C
ΓaX<:A.B<:X<:A.C
A-AllK

For records, target labels and their recursive premises are visited in the fixed label order. There is no target-promotion rule and no algorithmic transitivity rule.

Boundary table: full F<: is a replacement system

Full F<: omits bottom, products, sums, records, and the guarded Kernel algorithm. Its type grammar and contexts are A::=XAAX<:A.ATop,Γ::=Γ,X<:A. It retains only S-Refl, S-Trans, S-Top, S-Var, and S-Arr, restricted to this grammar, and replaces S-AllK by the rule below. Its body premise is checked under the target bound T1.

ΓT1<:S1Γ,X<:T1S2<:T2
ΓX<:S1.S2<:X<:T1.T2
S-AllF

A closed decision input may have a nonempty bound context. Precisely, Γ=X1<:A1,,Xn<:An is closed when each Ai mentions only earlier Xj, and ΓS<:T is closed when every free variable of S,T is declared in Γ. This is the input class of theorem 8.29; it is not restricted to Γ=.

Search the book

Type to search the local edition.