Erasure, dependent protocols, effects, specifications, and partiality
appendix sectionrules
Erasure, dependent protocols, effects, specifications, and partiality
Graded erasure and extraction
Usage is a judgment independent of typing. Its function fragment is
𝑒𝑖▸𝑥𝑖
U-Var
𝛾,𝑝▸𝑡
𝛾▸𝜆𝑝𝑡
U-Lam
𝛾▸𝑡𝛿▸𝑢
𝛾+𝑝𝛿▸𝑡𝑝𝑢
U-App
Natural-number elimination uses
𝛾𝑧▸𝑧𝛾𝑠,𝑝,𝑟▸𝑠𝛾𝑛▸𝑛𝛿,𝑞▸𝐴
𝗇𝗋𝑝,𝑟(𝛾𝑧,𝛾𝑠,𝛾𝑛)▸𝗇𝖺𝗍𝗋𝖾𝖼𝑞𝑝,𝑟(𝐴;𝑧;𝑠;𝑛)
U-Natrec
Simultaneous substitution replaces a usage row by matrix multiplication: if every row 𝑒𝑖Ψ resources 𝜎(𝑖), then 𝛾▸𝑡 entails 𝛾Ψ▸𝑡[𝜎]. The natural-recursion demand is 𝗇𝗋𝑝,𝑟(𝑞𝑧,𝑞𝑠,𝑞𝑛), governed by the five scalar laws 𝑞𝑛≤0⟹𝗇𝗋𝑝,𝑟(𝑞𝑧,𝑞𝑠,𝑞𝑛)≤𝑞𝑧,𝗇𝗋𝑝,𝑟(𝑞𝑧,𝑞𝑠,𝑞𝑛)≤𝑞𝑠+𝑝𝑞𝑛+𝑟𝗇𝗋𝑝,𝑟(𝑞𝑧,𝑞𝑠,𝑞𝑛),𝑞𝑧≤𝑞′𝑧,𝑞𝑠≤𝑞′𝑠,𝑞𝑛≤𝑞′𝑛⟹𝗇𝗋𝑝,𝑟(𝑞𝑧,𝑞𝑠,𝑞𝑛)≤𝗇𝗋𝑝,𝑟(𝑞′𝑧,𝑞′𝑠,𝑞′𝑛),𝗇𝗋𝑝,𝑟(𝑞𝑧,𝑞𝑠,𝑞𝑛)𝑞≤𝗇𝗋𝑝,𝑟(𝑞𝑧𝑞,𝑞𝑠𝑞,𝑞𝑛𝑞),𝗇𝗋𝑝,𝑟(𝑞𝑧,𝑞𝑠,𝑞𝑛)+𝗇𝗋𝑝,𝑟(𝑞′𝑧,𝑞′𝑠,𝑞′𝑛)≤𝗇𝗋𝑝,𝑟(𝑞𝑧+𝑞′𝑧,𝑞𝑠+𝑞′𝑠,𝑞𝑛+𝑞′𝑛). The first three lines are NR-Base, NR-Step, and NR-Mono. The last two are NR-Right and NR-Interchange. All five lift pointwise to usage contexts. At nonzero grade, extraction retains lambdas and applications. At grade zero it uses (𝜆0𝑡)∙=𝑡∙[↺/𝑥],(𝑡0𝑢)∙=𝑡∙. An erased weak-pair match is admitted only at the match grades selected by 𝖯𝗋𝗈𝖽𝗋𝖾𝖼; the open-context restriction in theorem 101.11 remains a theorem hypothesis.
Dependent session quantifiers
For a total functional judgment Ψ⊢𝑀:𝜏, the four added rules are
Ψ,𝑥:𝜏;Γ;Δ⟹𝑃::𝑧:𝐴
Ψ;Γ;Δ⟹𝑧(𝑥).𝑃::𝑧:∀𝑥:𝜏.𝐴
Ψ⊢𝑀:𝜏Ψ;Γ;Δ,𝑦:𝐴[𝑀/𝑥]⟹𝑄::𝑧:𝐶
Ψ;Γ;Δ,𝑦:∀𝑥:𝜏.𝐴⟹𝑦⟨𝑀⟩.𝑄::𝑧:𝐶
and
Ψ⊢𝑀:𝜏Ψ;Γ;Δ⟹𝑃::𝑧:𝐴[𝑀/𝑥]
Ψ;Γ;Δ⟹𝑧⟨𝑀⟩.𝑃::𝑧:∃𝑥:𝜏.𝐴
Ψ,𝑥:𝜏;Γ;Δ,𝑦:𝐴⟹𝑄::𝑧:𝐶
Ψ;Γ;Δ,𝑦:∃𝑥:𝜏.𝐴⟹𝑦(𝑥).𝑄::𝑧:𝐶
A functional value can also cross the process boundary through
Ψ⊢𝑀:𝜏
Ψ;Γ;⋅⟹[𝑧←𝑀]::𝑧:$𝜏
Ψ,𝑥:𝜏;Γ;Δ⟹𝑃::𝑧:𝐶
Ψ;Γ;Δ,𝑥:$𝜏⟹𝑃::𝑧:𝐶
A principal quantifier cut substitutes the communicated functional term in the receiving continuation. Functional substitution changes all protocol indices; linear channel substitution composes processes and requires a disjoint split of the linear channel context.
Dependent call-by-push-value
The value/computation boundary has
Γ⊢𝗏𝑉:𝐴
Γ⊢𝖼𝗋𝖾𝗍𝗎𝗋𝗇𝑉:𝐹𝐴
Return
Γ⊢𝖼𝑀:𝐵――
Γ⊢𝗏𝗍𝗁𝗎𝗇𝗄𝑀:𝑈𝐵――
Thunk
Γ⊢𝗏𝑉:𝑈𝐵――
Γ⊢𝖼𝖿𝗈𝗋𝖼𝖾𝑉:𝐵――
Force
The dependent Kleisli extension is preceded by the nondependent sequencing rule
where 𝗍𝗋𝑥=𝗍𝗁𝗎𝗇𝗄(𝗋𝖾𝗍𝗎𝗋𝗇𝑥). Its beta root is (𝗋𝖾𝗍𝗎𝗋𝗇𝑉)𝗍𝗈𝑥𝗂𝗇𝑁⇝0𝑁[𝑉/𝑥]. A step of 𝑀 is type preserving at this rule only when the classifier has the printed thunkability equation.
Dijkstra computation types
The generated state transformer operations are 𝗋𝖾𝗍𝗎𝗋𝗇𝗐𝗉𝖲𝗍(𝑎)(𝑝)(𝑠)=𝑝(𝑎,𝑠),𝖻𝗂𝗇𝖽𝗐𝗉𝖲𝗍(𝑤,𝑘)(𝑝)(𝑠0)=𝑤(𝜆(𝑎,𝑠1).𝑘(𝑎)(𝑝)(𝑠1))(𝑠0),𝗀𝖾𝗍𝗐𝗉(𝑝)(𝑠)=𝑝(𝑠,𝑠),𝗉𝗎𝗍𝗐𝗉(𝑠′)(𝑝)(𝑠)=𝑝(𝗎𝗇𝗂𝗍,𝑠′). For state with exceptions, the distinctive failure and handler clauses are 𝗋𝖺𝗂𝗌𝖾𝗐𝗉𝖲𝗍𝖤𝗑𝗇(𝑒)(𝑝)(𝑞)(𝑠)=𝑞(𝑒,𝑠),𝖻𝗂𝗇𝖽𝗐𝗉𝖲𝗍𝖤𝗑𝗇(𝑤,𝑘)(𝑝)(𝑞)(𝑠0)=𝑤(𝜆(𝑎,𝑠1).𝑘(𝑎)(𝑝)(𝑞)(𝑠1))(𝑞)(𝑠0),𝖼𝖺𝗍𝖼𝗁𝗐𝗉𝖲𝗍𝖤𝗑𝗇(𝑤,ℎ)(𝑝)(𝑞)(𝑠0)=𝑤(𝑝)(𝜆(𝑒,𝑠1).ℎ(𝑒)(𝑝)(𝑞)(𝑠1))(𝑠0). Computation types use generated transformers through
Γ⊢𝑉:𝐴
Γ⊢𝗋𝖾𝗍𝗎𝗋𝗇𝑉:𝖬𝐴(𝗋𝖾𝗍𝗎𝗋𝗇𝗐𝗉𝑉)
WP-Return
Γ⊢𝑀:𝖬𝐴𝑤Γ,𝑥:𝐴⊢𝑁:𝖬𝐵𝑘(𝑥)
Γ⊢𝑀𝗍𝗈𝑥𝗂𝗇𝑁:𝖬𝐵(𝖻𝗂𝗇𝖽𝗐𝗉(𝑤,𝑘))
WP-Bind
and weakening a specification uses
Γ⊢𝑀:𝖬𝐴𝑤Γ⊢∀𝑝.𝑤′(𝑝)⇒𝑤(𝑝)
Γ⊢𝑀:𝖬𝐴𝑤′
WP-Sub
Partial elements
For 𝐴𝜈, convergence and guarded sequencing are generated by
⟨𝑎⟩⇓𝑎
Conv-Return
𝑥⇓𝑎
▹𝑥⇓𝑎
Conv-Step
⟨𝑎⟩≫=𝑓=𝑓(𝑎),(▹𝑥)≫=𝑓=▹(𝑥≫=𝑓). Weak equality and the approximation order are 𝑥=𝜈𝑦:=∀𝑎.𝑥⇓𝑎↔𝑦⇓𝑎,𝑓⊑𝑔:=∀𝑎,𝑏.𝑓(𝑎)⇓𝑏⇒𝑔(𝑎)⇓𝑏. The monad laws hold at =𝜈, not at raw constructor equality.
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.
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.
Ψ;Γ;⋅⟹𝟎::𝑧:𝟏
Ψ;Γ;Δ⟹𝑃::𝑧:𝐶
Ψ;Γ;Δ,𝑥:𝟏⟹𝑃::𝑧:𝐶
Ψ;Γ;Δ,𝑥:𝐴⟹𝑃::𝑧:𝐵
Ψ;Γ;Δ⟹𝑧(𝑥).𝑃::𝑧:𝐴⊸𝐵
Ψ;Γ;Δ1⟹𝑃::𝑦:𝐴Ψ;Γ;Δ2,𝑥:𝐵⟹𝑄::𝑧:𝐶
Ψ;Γ;Δ1,Δ2,𝑥:𝐴⊸𝐵⟹(𝜈𝑦)𝑥⟨𝑦⟩.(𝑃∣𝑄)::𝑧:𝐶
Ψ;Γ;⋅⟹𝑃::𝑦:𝐴
Ψ;Γ;⋅⟹!𝑧(𝑦).𝑃::𝑧:!𝐴
!R
Ψ;Γ,𝑢:𝐴;Δ⟹𝑃::𝑧:𝐶
Ψ;Γ;Δ,𝑥:!𝐴⟹𝑃[𝑥/𝑢]::𝑧:𝐶
!L
Ψ;Γ;⋅⟹𝑃::𝑥:𝐴Ψ;Γ,𝑢:𝐴;Δ⟹𝑄::𝑧:𝐶
Ψ;Γ;Δ⟹(𝜈𝑢)((!𝑢(𝑥).𝑃)∣𝑄)::𝑧:𝐶
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.
Γ,𝑥:𝖡⊢𝐴:𝖴Γ⊢⋆:𝐴[𝗍𝗋𝗎𝖾/𝑥]Γ⊢⋆:𝐴[𝖿𝖺𝗅𝗌𝖾/𝑥]
Γ,𝑥:𝖡⊢⋆:𝐴
Dep- B-E
Γ⊢𝖼𝖽𝗂𝗏𝖾𝗋𝗀𝖾𝐵――:𝐵――
Diverge
Γ,𝑧:𝑈𝐵――⊢𝖼𝑀:𝐵――
Γ⊢𝖼𝜇𝐵――𝑧𝑀:𝐵――
Rec
Γ⊢𝖼𝖾𝗋𝗋𝗈𝗋𝐵――𝑒:𝐵――
Error
Γ⊢𝖼𝑀:𝐵――
Γ⊢𝖼𝗉𝗋𝗂𝗇𝗍𝑚.𝑀:𝐵――
Print
{Γ⊢𝖼𝑀𝑖:𝐵――}1≤𝑖≤𝑛
Γ⊢𝖼𝖼𝗁𝗈𝗈𝗌𝖾𝑖(𝑀𝑖):𝐵――
Choose
Γ;𝐶――⊢𝗄𝗇𝗂𝗅:𝐶――
Nil
Γ⊢𝗏𝑉:𝐴Γ;𝐵――[𝑉/𝑥]⊢𝗄𝐾:𝐶――
Γ;Π𝑥:𝐴𝐵――⊢𝗄𝑉::𝐾:𝐶――
Arg
Γ⊢𝖼𝑁:𝐵――[𝗍𝗁𝗎𝗇𝗄𝑀/𝑧]
Γ⊢𝖼𝑁:𝐵――[𝗍𝗁𝗎𝗇𝗄(𝗐𝗋𝗂𝗍𝖾𝑠.𝑀)/𝑧]
Incl-Write
Γ⊢𝖼𝑁:𝐵――[𝗍𝗁𝗎𝗇𝗄𝑀𝑠′/𝑧]
Γ⊢𝖼𝑁:𝐵――[𝗍𝗁𝗎𝗇𝗄(𝗋𝖾𝖺𝖽𝗍𝗈𝑠(𝑀𝑠))/𝑧]
Incl-Read
Γ⊢𝖼𝑁:𝐵――[𝗍𝗁𝗎𝗇𝗄𝑀/𝑧]
Γ⊢𝖼𝑁:𝐵――[𝗍𝗁𝗎𝗇𝗄(𝗉𝗋𝗂𝗇𝗍𝑚.𝑀)/𝑧]
Incl-Print
Γ⊢𝖼𝑁:𝐵――[𝗍𝗁𝗎𝗇𝗄𝑀𝑖′/𝑧]
Γ⊢𝖼𝑁:𝐵――[𝗍𝗁𝗎𝗇𝗄(𝖼𝗁𝗈𝗈𝗌𝖾𝑖(𝑀𝑖))/𝑧]
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.
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.
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.
Γ⊢𝑇<:⊤
DOT-Top
Γ⊢⊥<:𝑇
DOT-Bot
Γ⊢𝑇<:𝑇
DOT-Refl
Γ⊢𝑆<:𝑇Γ⊢𝑇<:𝑈
Γ⊢𝑆<:𝑈
DOT-Trans
Γ⊢𝑇∧𝑈<:𝑇
DOT-And_1-
Γ⊢𝑇∧𝑈<:𝑈
DOT-And_2-
Γ⊢𝑆<:𝑇Γ⊢𝑆<:𝑈
Γ⊢𝑆<:𝑇∧𝑈
DOT–And
Γ⊢𝑇<:𝑈
Γ⊢{𝑎:𝑇}<:{𝑎:𝑈}
DOT-Fld–Fld
Γ,𝑥:𝑇⊢𝑑:𝑇
Γ⊢𝜈(𝑥:𝑇)𝑑:𝜇(𝑥:𝑇)
DOT-Obj-I
Γ⊢𝑡:𝑇
Γ⊢{𝑎=𝑡}:{𝑎:𝑇}
DOT-Def-Val
Γ⊢𝑑1:𝑇1Γ⊢𝑑2:𝑇2dom(𝑑1)∩dom(𝑑2)=∅
Γ⊢𝑑1∧𝑑2:𝑇1∧𝑇2
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.
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.