Lectures onType Theory
Positive Self, F-bounds, matching, and state
appendix sectionrules

Positive Self, F-bounds, matching, and state

The functional Self+ delta

Definition 16.4 extends the bounded-subtyping core by positive Self types and two primitive term forms: S::=SelfX.R(X),a::=packSelf C with a as SuseSelf a as X<:S,x:R(X) in b. Every field type in R(X) is positive in X. The Self-specific calculus extends reflexive–transitive subtyping by

X<:AΔ
ΔX<:A
S-Bound
ΔA<:Top
S-Top
ΔA<:AΔB<:B
ΔAB<:AB
S-Arrow
JIΔAj<:Bj(jJ)
Δ{i:Ai}iI<:{j:Bj}jJ
S-Record

Its ordinary term rules are

x:AΓ
Δ;Γx:A
T-Var
Δ;Γn:Nat
T-Const
b{true,false}
Δ;Γb:Bool
T-Bool
Δ;Γunit:Unit
T-Unit
Δ;Γa:Nat
Δ;Γsucc(a):Nat
T-Succ
Δ;Γ,x:Aa:B
Δ;Γλx:A.a:AB
T-Abs
Δ;Γa:ABΔ;Γb:A
Δ;Γab:B
T-App
Δ;Γa:BoolΔ;Γb:AΔ;Γc:A
Δ;Γif a then b else c:A
T-If
Δ;Γai:Ai(iI)
Δ;Γ{i=ai}iI:{i:Ai}iI
T-Record
Δ;Γa:{i:Ai}iIjI
Δ;Γa.j:Aj
T-Proj
Δ;Γ,x:Aa:A
Δ;Γfix x:A.a:A
T-Fix
Δ;Γa:AΔA<:B
Δ;Γa:B
T-Sub

The Self-specific subtyping and typing rules are

Δ,X<:TopR(X)<:R(X)
ΔSelfX.R(X)<:SelfX.R(X)
S-Self
S=SelfX.R(X)ΔC<:SΔ;Γa:R(C)
Δ;ΓpackSelf C with a as S:S
T-PackSelf
S=SelfX.R(X)Δ;Γa:SΔ,X<:S;Γ,x:R(X)b:DXFV(D)
Δ;ΓuseSelf a as X<:S,x:R(X) in b:D
T-UseSelf

Derived selection and its root are aj:=useSelf a as X<:S,x:R(X) in x.j,p=packSelf C with v as S0,u=useSelf p as X<:S,x:R(X) in b,ub[C/X][v/x]. The selection body is subsumed from Bj(X) to Bj(S) by positivity; the reduction substitutes the hidden type before the payload term. The functional evaluation contexts are those of definition 16.5; they do not enter lambdas, recursion bodies, or Self-use bodies.

F-bounded comparison calculus

The separate equi-recursive calculus Feq has A::=μX.AX<:F(X).A,a::=ΛX<:F(X).aa[A]. It uses equi-recursive conversion μX.A=A[μX.A/X] and the F-bound rules

Δ,X<:F(X)A type
ΔX<:F(X).A type
F-All
Δ,X<:F(X);Γa:A
Δ;ΓΛX<:F(X).a:X<:F(X).A
F-Intro
Δ;Γa:X<:F(X).AΔC<:F(C)
Δ;Γa[C]:A[C/X]
F-Elim

The root (ΛX<:F(X).a)[C]a[C/X] uses the displayed post-fixpoint premise; it grants no subtype comparison between distinct post-fixpoints.

Higher-order matching target

The restricted target Hμ distinguishes kinds and , pointwise operator subtyping FG, bounded operator quantification, and iso-recursion. Proper-type subtyping includes

ΩA<:AΩB<:B
ΩAB<:AB
S-H-Arrow
JIΩAj<:Bj(jJ)
Ω{i:Ai}iI<:{j:Bj}jJ
S-H-Record

The ordinary target term rules are

x:AΓ
Ω;Γx:A
T-H-Var
Ω;Γ,x:At:B
Ω;Γλx:A.t:AB
T-H-Abs
Ω;Γt:ABΩ;Γu:A
Ω;Γtu:B
T-H-App
Ω;Γti:Ai(iI)
Ω;Γ{i=ti}iI:{i:Ai}iI
T-H-Record
Ω;Γt:{i:Ai}iIjI
Ω;Γt.j:Aj
T-H-Proj
Ω;Γt:AΩA<:B
Ω;Γt:B
T-H-Sub

Operator kinding and subtyping are

Ω,X:A:
ΩλX:.A:
K-OpAbs
ΩF:ΩA:
ΩF(A):
K-OpApp
ΩF:Contr(F)
ΩμF:
K-Mu
Ω,X:F(X)<:G(X)
ΩFG
S-OpPoint
ΩFGΩA:
ΩF(A)<:G(A)
S-OpApp
ΦF:Ω
ΩΦF
S-OpBound
ΩF:Contr(F)Ω,ΦF:A:
ΩΦF.A:
K-AllOp
Ω,ΦF;Γt:A
Ω;ΓΛΦF.t:ΦF.A
T-AllOp-I
Ω;Γt:ΦF.AΩG:Contr(G)ΩGF
Ω;Γt[G]:A[G/Φ]
T-AllOp-E
Ω;Γt:F(μF)
Ω;ΓfoldF(t):μF
T-Fold
Ω;Γt:μF
Ω;ΓunfoldF(t):F(μF)
T-Unfold

For source object types, matching is defined only by translated operator comparison: ΞA#BΞOper(A)Oper(B). It licenses match abstraction, match application, and selection through a match-bound variable. It does not license source subsumption. The separate source typing judgment is generated by

x:DΓ
Ξ;Γx:D
T-Match-Var
Ξ;Γ,x:Dt:E
Ξ;Γλx:D.t:DE
T-Match-Abs
Ξ;Γt:DEΞ;Γu:D
Ξ;Γtu:E
T-Match-App
Ξ,X#O;Γt:D
Ξ;ΓΛX#O.t:X#O.D
T-Match-I
Ξ;Γt:X#O.DΞC#O
Ξ;Γt[C]:D[C/X]
T-Match-E
X#μZ.R(Z)Ξx:XΓR(X)()=D
Ξ;Γx.:D
T-Match-Proj

Invariant references and configuration roots

The state extension uses Δ;Σ;Γa:A, invariant RefA, and Σσdom(Σ)=dom(σ)  ;Σ;σ():Σ()(dom(Σ)). The reference rules are

Δ;Σ;Γa:A
Δ;Σ;Γref a:RefA
T-Ref
Δ;Σ;Γa:RefA
Δ;Σ;Γ!a:A
T-Deref
Δ;Σ;Γa:RefAΔ;Σ;Γb:A
Δ;Σ;Γa:=b:Unit
T-Assign
Σ()=A
Δ;Σ;Γ:RefA
T-Loc

Allocation extends both store and store typing; dereference and assignment preserve the current store typing: σ,ref vσ[v],(dom(σ)),σ,!σ,σ(),σ,:=vσ[v],unit.

Search the book

Type to search the local edition.