The calculus 𝜆𝖥𝖦 of chapter 9 has the finite type grammar 𝐴,𝐵::=0∣𝑏∣𝐴×𝐵∣𝐴→𝐵∣𝐴∨𝐵∣¬𝐴, with 1≡¬0 and 𝐴∧𝐵≡¬(¬𝐴∨¬𝐵). The relation 𝐴≤𝐵 is semantic inclusion in the universal finite-graph domain of definition 9.5, definition 9.6; it is decided by the finite simulation procedure of definition 9.13. This appendix does not replace that semantic relation by a syntactic subtype table.
Runtime tests, terms, and values are 𝑈::=0∣1∣𝑏∣𝖥𝗎𝗇∣𝑈×𝑈∣𝑈∨𝑈∣𝑈∧𝑈∣¬𝑈,𝑒::=𝑐∣𝑥∣(𝑒,𝑒)∣𝜋𝑖𝑒∣𝜆𝐼𝑥.𝑒∣𝑒𝑒∣𝖼𝖺𝗌𝖾𝖳𝗒𝗉𝖾𝑒𝖺𝗌𝑥𝗂𝗇𝑈⇒𝑒∣𝑒,𝑣::=𝑐∣(𝑣,𝑣)∣𝜆𝐼𝑥.𝑒,𝖥𝗎𝗇≡0→1. Here 𝐼=(𝐴1→𝐵1;…;𝐴𝑛→𝐵𝑛) is nonempty. It is well shaped when 𝑛=1, or, for a multi-arrow interface, when no domain 𝐴𝑖 contains an arrow atom other than the universal function test 𝖥𝗎𝗇=0→1. This is the exact side condition of T-Abs; “well shaped” is not the metatheoretic notion of an admissible rule. Evaluation is weak left-to-right call by value under 𝐸::=[]∣(𝐸,𝑒)∣(𝑣,𝐸)∣𝜋𝑖𝐸∣𝐸𝑒∣𝑣𝐸∣𝖼𝖺𝗌𝖾𝖳𝗒𝗉𝖾𝐸𝖺𝗌𝑥𝗂𝗇𝑈⇒𝑒1∣𝑒2. Its complete root table is
(𝜆𝐼𝑥.𝑒)𝑣⟶𝑒[𝑣/𝑥]
E-Beta
𝑖∈{1,2}
𝜋𝑖(𝑣1,𝑣2)⟶𝑣𝑖
E-Proj
𝑣⊩𝑈
𝖼𝖺𝗌𝖾𝖳𝗒𝗉𝖾𝑣𝖺𝗌𝑥𝗂𝗇𝑈⇒𝑒+∣𝑒−⟶𝑒+[𝑣/𝑥]
E-Case+
𝑣⊮𝑈
𝖼𝖺𝗌𝖾𝖳𝗒𝗉𝖾𝑣𝖺𝗌𝑥𝗂𝗇𝑈⇒𝑒+∣𝑒−⟶𝑒−[𝑣/𝑥]
E-Case-
The structural test judgment is the following recursion on 𝑈: 𝑣⊩0⟺⊥,𝑣⊩1⟺⊤,𝑣⊩𝑏⟺𝑣=𝑐forsome𝑐∈𝐵𝑏,𝑣⊩𝖥𝗎𝗇⟺𝑣=𝜆𝐼𝑥.𝑒forsome𝐼,𝑥,𝑒,𝑣⊩𝑈1×𝑈2⟺𝑣=(𝑣1,𝑣2)forsome𝑣1,𝑣2with𝑣1⊩𝑈1and𝑣2⊩𝑈2,𝑣⊩𝑈1∨𝑈2⟺𝑣⊩𝑈1or𝑣⊩𝑈2,𝑣⊩𝑈1∧𝑈2⟺𝑣⊩𝑈1and𝑣⊩𝑈2,𝑣⊩¬𝑈⟺𝑣⊮𝑈. Thus 𝑣⊮𝑈 is the decidable negation of the displayed recursion; it is not a second primitive judgment.
Write 𝐹∘𝑆 for the computable least application output of definition 9.22, and proj𝑖(𝑃) for the computable least projection output of lemma 9.25. The ordinary rules are
𝑐∈𝐵𝑏
Γ⊢𝑐:𝑏
T-Const
𝑥:𝐴∈Γ
Γ⊢𝑥:𝐴
T-Var
Γ⊢𝑒1:𝐴Γ⊢𝑒2:𝐵
Γ⊢(𝑒1,𝑒2):𝐴×𝐵
T-Pair
Γ⊢𝑒:𝐴𝐴≤𝐵
Γ⊢𝑒:𝐵
T-Sub
Γ⊢𝑒:𝐴Γ⊢𝑒:𝐵
Γ⊢𝑒:𝐴∧𝐵
T-Inter
Γ⊢𝑒:𝑃𝑃≤1×1
Γ⊢𝜋𝑖𝑒:proj𝑖(𝑃)
T-Proj
Γ,𝑥:𝐴𝑖⊢𝑒:𝐵𝑖(1≤𝑖≤𝑛)
Γ⊢𝜆(𝐴1→𝐵1;…;𝐴𝑛→𝐵𝑛)𝑥.𝑒:𝑛⋀𝑖=1(𝐴𝑖→𝐵𝑖)
T-Abs
Γ⊢𝑒1:𝐹Γ⊢𝑒2:𝑆𝐹≤𝑆→𝐵
Γ⊢𝑒1𝑒2:𝐵
T-App
The least-result form belongs to the fixed-annotation synthesizer, rather than replacing the preceding declarative rule:
synΓ(𝑒1)=𝐹synΓ(𝑒2)=𝑆𝐹≤0→1𝐹≤𝑆→1
synΓ(𝑒1𝑒2)=𝐹∘𝑆
T-App-Syn
The union introductions used in the prose are derived subsumption rules:
Γ⊢𝑒:𝐴
Γ⊢𝑒:𝐴∨𝐵
_1
Γ⊢𝑒:𝐵
Γ⊢𝑒:𝐴∨𝐵
_2
A typing judgment is formed only for a term well scoped by its context. The typecase rule makes the otherwise suppressible branch scope explicit:
The partial synthesizer synΓ returns the basic tag for a constant, the context entry for a variable, the product of the two recursive results for a pair, and proj𝑖(𝑃) for a projection when 𝑃≤1×1. An abstraction checks every displayed interface premise and returns their intersection. Application checks 𝐹≤0→1 and 𝐹≤𝑆→1, then returns 𝐹∘𝑆. Typecase checks both scope premises, returns 0 without typechecking an empty branch, recursively synthesizes each nonempty branch under its refined binder, and returns their union. Checking 𝑒:𝐴 succeeds exactly when synthesis returns 𝑆≤𝐴.