Lectures onType Theory
Dependent subtyping, object paths, and classical control
appendix sectionrules

Dependent subtyping, object paths, and classical control

Dependent subtyping and refinement entailment

Dependent products compare their codomains under the client domain:

ΓA2<:A1Γ,x:A2B1<:B2
ΓΠx:A1B1<:Πx:A2B2
Π-Sub

The refinement ledger uses a distinct relation. Its annotated A-normal term syntax and evaluation contexts are e::=vev,v::=xmm1,,mkλx:R.e,E::=[]Ev. It reduces only by (λx:R.e)ve[v/x] and the compatible rule eeE[e]E[e]. Its base and function subtyping clauses are

Entails(Φ(Γ)ϕ1,ϕ2)
ΓDRef{ν:Bϕ1}<:{ν:Bϕ2}
R-Base-Sub
ΓDRefR2<:R1Γ,x:R2DRefS1<:S2
ΓDRefΠx:R1S1<:Πx:R2S2
R-Π-Sub

Base introduction, variables, and array introduction are

Γ(x)=R
ΓDRefx:R
R-Var
ΓDRef{ν:Intϕ}typeEntails(Φ(Γ),ϕ[m/ν])
ΓDRefm:{ν:Intϕ}
R-Int
ΓDRef{ν:Arrϕ}typeEntails(Φ(Γ),ϕ[m1,,mk/ν])
ΓDRefm1,,mk:{ν:Arrϕ}
R-Arr

Refinement abstraction, application, and subsumption are

Γ,x:RDRefe:S
ΓDRefλx:R.e:Πx:RS
R-Lam
ΓDReff:Πx:RSΓDRefv:R
ΓDReffv:S[v/x]
R-App
ΓDRefe:RΓDRefR<:S
ΓDRefe:S
R-Sub

For a requested difference constraint, Entails accepts either a replayed path of weight at most the requested bound or a replayed closed cycle whose recomputed weight is negative. A claimed weight without the corresponding contiguous edge sequence is not a certificate. A GCIC cast is a run-time term cast[BA](t), not either subtyping judgment. A failed constructor or index test reduces to errB.

Variable-path DOT

Type selection, recursive self, and object members use

Γx:{A:S..U}
ΓS<:x.A
DOT-Sel-L
Γx:{A:S..U}
Γx.A<:U
DOT-Sel-U
ΓS2<:S1ΓU1<:U2
Γ{A:S1..U1}<:{A:S2..U2}
DOT-Type-Mem-Sub
Γx:T
Γx:μ(x:T)
DOT-Rec-I
Γx:μ(z:T)
Γx:T[x/z]
DOT-Rec-E
Γx:{a:T}
Γx.a:T
DOT-Fld-E

An inert recursive object type has pairwise distinct fields and only tight members {A:T..T}. Tight selection replaces the two general rules by

Γ!x:{A:T..T}
Γ#T<:x.A
DOT-T-Sel-L
Γ!x:{A:T..T}
Γ#x.A<:T
DOT-T-Sel-U

Concrete type definitions are tight by construction:

ΓTtype
Γ{A=T}:{A:T..T}
DOT-Def-Type

Stable paths and pDOT

Stable paths are variables and immutable field paths:

x:TΓ
Γxpath
P-Var
Γp:{a:T}
Γp.apath
P-Fld

Singletons propagate only toward a typeable target prefix:

Γp:q.typeΓq:T
Γp:T
Sngl-Trans
Γp:q.typeΓq.apath
Γp.a:q.a.type
Sngl-E

One-occurrence replacement is formation-indexed. The path-prefix relation checks every complete changed prefix:

Γqpath
ΓRPath(p,p,q,q)
RP-Here
ΓRPath(r,p,q,r)Γr.apath
ΓRPath(r.a,p,q,r.a)
RP-Fld

The selected leaf is also formed after replacement:

ΓRPath(r,p,q,r)Γr.Atype
ΓReplace(r.A,p,q,r.A)
R-Sel
ΓRPath(r,p,q,r)Γr.typetype
ΓReplace(r.type,p,q,r.type)
R-Sngl

Structural replacement descends through exactly one field, member bound, or intersection component. For function domains it checks the unchanged codomain under the replaced domain; for function codomains and recursive self types it alpha-renames the binder away from the two paths and checks the target codomain or recursive type. One-occurrence replacement is then bidirectional at subtyping:

Γp:q.typeΓqpathΓReplace(T,p,q,U)
ΓT<:U
Repl-pq
Γp:q.typeΓppathΓReplace(T,q,p,U)
ΓT<:U
Repl-qp

Nested initialization substitutes the installed path for inner self and requires a tight record:

p.a;Γd[p.a/y]:T[p.a/y]TightRecord(T)
p;Γ{a=ν(y:T)d}:{a:μ(y:T)}
Def-New

The body premise can be derived only after every path in d[p.a/y] and T[p.a/y] passes the path-formation rules. The source rule has no third path premise. Path lookup follows immutable stored fields; it is separate from term reduction.

Proof-dependent classical control

Proofs, left contexts, and commands have the three regular judgments Γp:AΔ, Γe:AΔ, and c:(ΓΔ). Regular judgments carry no dependency list. Their control core is

Γp:AΔΓe:AΔ
pe:(ΓΔ)
Cut
c:(Γα:A,Δ)
Γμα.c:AΔ
μ-R
c:(Γ,a:AΔ)
Γμ~a.c:AΔ
μ-L

Dependent products use

Γ,a:Ap:BΔ
Γλa.p:Πa:A.BΔ
Π-R
Γq:AΔΓe:B[q/a]ΔqNEFaFV(B)
Γqe:Πa:A.BΔ
Π-L

Thus a proof outside NEF is permitted only when the codomain is independent of the proof variable. The complete mutually generated fragment used here is pN::=Vp(t,pN)μ.cNprfpNsubstpNqN,cN::=pNeN,eN::=μ~a.cN. Here is the single continuation local to the fragment; it is not the calculus continuation tp^. Thus μ.cN is admitted only with a command and context generated by the two displayed clauses. An ordinary μα.c proof and an application spine are rejected, while variables, lambdas, positive pairs, reflexivity, and the displayed delimited μ form are admitted. The principal roots are Vμ~a.cc[V/a],μα.cec[e/α]. The dependent mode alone carries a list σ::=ϵσ{rq}. Formula compatibility is Aϵ={A},Aσ{rq}={Aσ(A[q/r])σ,qNEF,Aσ,qNEF. Its judgments are Γe:AdΔ,tp^:B;σ and c:(ΓdΔ,tp^:B;σ). The bridge rules include

c:(ΓdΔ,tp^:A;ϵ)
Γμtp^.c:AΔ
μtp
Γp:AΔΓe:AdΔ,tp^:B;σ{p}
pe:(ΓdΔ,tp^:B;σ)
Cut-d

The proof premise of Cut-d is regular. The dependent context uses the open list entry to reconcile its formula with the regular proof’s formula. The distinguished continuation tp^ freezes the enclosing context while that dependency is open.

Graded erasure: additional formation, equality, usage, and dynamics

Together with the graded-erasure card immediately above, the rules below record the noninherited part of the signature in definition 101.2, definition 101.3, definition 101.4, definition 101.5, definition 101.9. Appendix A does not repeat the binder, congruence, and constructor schemas displayed in those definitions; those point-of-use displays are the complete signature.

ϵ
Ctx-ε
x0:A[]Γ.A
V-Zero
xi:AΓ
xi+1:A[]Γ.B
V-Suc
ΓA:U
ΓA
Ty-U
Γ.AB
ΓΠpqAB
Ty-Π
Γ.AB
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sndt:B[fstt]
R-Snd
Γ.ABΓt:AΓu:B[t]
Γsnd(t,u)&u:B[fst(t,u)&]
R-Snd-β
Γtt:ΣqABΓ.ΣqABCΓ.A.Bu:C[2,(x1,x0)]
Γprodrecrq(C;t;u)prodrecrq(C;t;u):C[t]
R-Prodrec
Γ.ΣqABCΓt1:AΓt2:B[t1]Γ.A.Bu:C[2,(x1,x0)]
Γprodrecrq(C;(t1,t2);u)u[t1,t2]:C[(t1,t2)]
R-Prodrec-β
Γnn:NΓz:A[zero]Γ.N.As:A[2,sucx1]
Γnatrecp,rq(A;z;s;n)natrecp,rq(A;z;s;n):A[n]
R-Natrec
Γz:A[zero]Γ.N.As:A[2,sucx1]
Γnatrecp,rq(A;z;s;zero)z:A[zero]
R-Nat-Zero
Γz:A[zero]Γ.N.As:A[2,sucx1]Γn:N
Γnatrecp,rq(A;z;s;sucn)s[n,natrecp,rq(A;z;s;n)]:A[sucn]
R-Nat-Suc
ΓAΓtt:
Γemptyrecp(A;t)emptyrecp(A;t):A
R-Emptyrec
(λv)wv[w]
E-β
vv
vwvw
E-App
vv
fstvfstv
E-Fst
fst(v,w)v
E-Fst-β
snd(v,w)w
E-Snd-β
vv
sndvsndv
E-Snd
vv
prodrec(v;w)prodrec(v;w)
E-Prodrec
prodrec((v,v);w)w[v,v]
E-Prodrec-β
natrec(z;s;zero)z
E-Nat-Zero
vv
natrec(z;s;v)natrec(z;s;v)
E-Natrec
natrec(z;s;sucv)s[v,natrec(z;s;v)]
E-Nat-Suc

Dependent sessions: additional base-rule delta

The quantifier and functional-passing rules are printed in the dependent session card above. The propositions-as-sessions rules are inherited from subappendix A.61; the seven rules below are the additional base rules used by definition 102.1. Thus every omitted rule has one named earlier card rather than an implicit premise.

Ψ;Γ;0::z:1
Ψ;Γ;ΔP::z:C
Ψ;Γ;Δ,x:1P::z:C
Ψ;Γ;Δ,x:AP::z:B
Ψ;Γ;Δz(x).P::z:AB
Ψ;Γ;Δ1P::y:AΨ;Γ;Δ2,x:BQ::z:C
Ψ;Γ;Δ1,Δ2,x:AB(νy)xy.(PQ)::z:C
Ψ;Γ;P::y:A
Ψ;Γ;!z(y).P::z:!A
!R
Ψ;Γ,u:A;ΔP::z:C
Ψ;Γ;Δ,x:!AP[x/u]::z:C
!L
Ψ;Γ;P::x:AΨ;Γ,u:A;ΔQ::z:C
Ψ;Γ;Δ(νu)((!u(x).P)Q)::z:C
Cut^!

Dependent effects: additional operation and inclusion delta

The value/computation boundary and both bind rules are printed in the card above. The following rules supplement the point-of-use operation, stack, and machine signatures in definition 103.4, definition 103.8. Those definitions display the complete transition relation; this card does not duplicate every constructor-preserving machine frame.

Γ,x:BA:UΓ:A[true/x]Γ:A[false/x]
Γ,x:B:A
Dep- B-E
ΓcdivergeB:B
Diverge
Γ,z:UBcM:B
ΓcμzBM:B
Rec
ΓcerrorBe:B
Error
ΓcM:B
Γcprintm.M:B
Print
{ΓcMi:B}1in
Γcchoosei(Mi):B
Choose
Γ;Cknil:C
Nil
ΓvV:AΓ;B[V/x]kK:C
Γ;Πx:ABkV::K:C
Arg
ΓcN:B[thunkM/z]
ΓcN:B[thunk(writes.M)/z]
Incl-Write
ΓcN:B[thunkMs/z]
ΓcN:B[thunk(readtos(Ms))/z]
Incl-Read
ΓcN:B[thunkM/z]
ΓcN:B[thunk(printm.M)/z]
Incl-Print
ΓcN:B[thunkMi/z]
ΓcN:B[thunk(choosei(Mi))/z]
Incl-Choose

Weakest preconditions: execution rules

The transformer equations and WP-Return, WP-Bind, and WP-Sub are printed in the preceding card. These are the two additional execution rules of definition 104.6.

Γe:PureAwΓp.w(p)
Γrune:TotA
WP-Run
run(Pure.returnv)v
R-Run

Dependent subtyping: additional algorithmic rule delta

The declarative product, refinement, and cast rules are printed in the card above. The following formation and bidirectional rules form the algorithmic delta of definition 106.1, definition 106.4; the complete rule families remain displayed at those definitions.

ΓA:UΓ,x:AB:U
ΓΠx:AB:U
Π-F
Γ,x:AM:B
Γλx:A.M:Πx:AB
Π-I
ΓF:Πx:ABΓN:A
ΓFN:B[N/x]
Π-E
fv(ϕ)dom(Γ){ν}Γvertices(ϕ)well-sorted
ΓDRef{ν:Bϕ}type
R-Base-F
ΓDRefRtypeΓ,x:RDRefStype
ΓDRefΠx:RStype
R-Π-F
ΓDRefm[m]Int
A-Int
ΓDRefRtypeΓ,x:RDRefeS
ΓDRefλx:R.eΠx:RS
A-Lam
ΓDRefeΠx:RSΓDRefvR
ΓDRefevS[v/x]
A-App
ΓDRefeRΓDRefR<:S
ΓDRefeS
A-Check

Dependent object types: additional structural rule delta

The selection, recursive-self, field, and tight-member rules are printed in the object-type card above. The following structural and definition rules supplement the complete point-of-use family in definition 107.2; this card does not duplicate its application, let, and evaluation-context schemas.

ΓT<:
DOT-Top
Γ<:T
DOT-Bot
ΓT<:T
DOT-Refl
ΓS<:TΓT<:U
ΓS<:U
DOT-Trans
ΓTU<:T
DOT-And_1-
ΓTU<:U
DOT-And_2-
ΓS<:TΓS<:U
ΓS<:TU
DOT–And
ΓT<:U
Γ{a:T}<:{a:U}
DOT-Fld–Fld
Γ,x:Td:T
Γν(x:T)d:μ(x:T)
DOT-Obj-I
Γt:T
Γ{a=t}:{a:T}
DOT-Def-Val
Γd1:T1Γd2:T2dom(d1)dom(d2)=
Γd1d2:T1T2
DOT-Def-And

Fully path-dependent types: additional replacement and lookup delta

The stable-path, singleton, replacement-leaf, and nested-initialization rules are printed in the pDOT card above. The following rules complete the named replacement descent and lookup deltas; all unchanged DOT rules are inherited from definition 107.2.

Γqpath
p;Γ{a=q}:{a:q.type}
Def-Path
ΓReplace(S,p,q,S)
ΓReplace({a:S},p,q,{a:S})
R-Fld
ΓReplace(S,p,q,S)
ΓReplace({A:S..U},p,q,{A:S..U})
R-Mem-L
ΓReplace(U,p,q,U)
ΓReplace({A:S..U},p,q,{A:S..U})
R-Mem-U
ΓReplace(S,p,q,S)
ΓReplace(SU,p,q,SU)
R-And-L
ΓReplace(U,p,q,U)
ΓReplace(SU,p,q,SU)
R-And-R
ΓReplace(S,p,q,S)Γ,x:SUtype
ΓReplace((x:S)U,p,q,(x:S)U)
R-All-Dom
Γ,x:SReplace(U,p,q,U)xfv(p)fv(q)
ΓReplace((x:S)U,p,q,(x:S)U)
R-All-Cod
Γ,x:μ(x:T)Replace(T,p,q,T)Γμ(x:T)typexfv(p)fv(q)
ΓReplace(μ(x:T),p,q,μ(x:T))
R-Rec
γ(x)=v
Lookupγ(x)=v
Lookup-Var
Lookupγ(p)=ν(z:T)(d1{a=s}d2)
Lookupγ(p.a)=s[p/z]
Lookup-Val
Lookupγ(p)=q
Lookupγ(p.a)=q.a
Lookup-Path

Proof-dependent classical control: additional dependent rule delta

The cut, control, dependent-product, NEF, and dependency-list rules are printed in the classical-control card above. The following rules form the distinctive delta of definition 109.1, definition 109.4; the ordinary positive and equality schemas remain at those point-of-use definitions.

Γt:NΓp:A[t/x]Δ
Γ(t,p):x:N.AΔ
-R
Γp:x:N.AΔpD
Γwit(p):N
Wit
Γp:x:N.AΔpD
Γprf(p):A[wit(p)/x]Δ
Prf
BAσ
Γtp^:AdΔ,tp^:B;σ{p}
tp
c:(Γ,a:AdΔ,tp^:B;σ{ap})
Γμ~a.c:AdΔ,tp^:B;σ{p}
μ-d
Γabortα:α:P,Δ
-L

Search the book

Type to search the local edition.