Lectures onType Theory
Finite-graph Boolean semantic subtyping
appendix sectionrules

Finite-graph Boolean semantic subtyping

The calculus λFG of chapter 9 has the finite type grammar A,B::=0bA×BABAB¬A, with 1¬0 and AB¬(¬A¬B). The relation AB 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 U::=01bFunU×UUUUU¬U,e::=cx(e,e)πieλIx.eeecaseType e as x in Uee,v::=c(v,v)λIx.e,Fun01. Here I=(A1B1;;AnBn) is nonempty. It is well shaped when n=1, or, for a multi-arrow interface, when no domain Ai contains an arrow atom other than the universal function test Fun=01. 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 E::=[ ](E,e)(v,E)πiEEevEcaseType E as x in Ue1e2. Its complete root table is

(λIx.e)ve[v/x]
E-Beta
i{1,2}
πi(v1,v2)vi
E-Proj
vU
caseType v as x in Ue+ee+[v/x]
E-Case+
vU
caseType v as x in Ue+ee[v/x]
E-Case-

The structural test judgment is the following recursion on U: v0,v1,vbv=c for some cBb,vFunv=λIx.e for some I,x,e,vU1×U2v=(v1,v2) for some v1,v2with v1U1 and v2U2,vU1U2vU1 or vU2,vU1U2vU1 and vU2,v¬UvU. Thus vU is the decidable negation of the displayed recursion; it is not a second primitive judgment.

Write FS for the computable least application output of definition 9.22, and proji(P) for the computable least projection output of lemma 9.25. The ordinary rules are

cBb
Γc:b
T-Const
x:AΓ
Γx:A
T-Var
Γe1:AΓe2:B
Γ(e1,e2):A×B
T-Pair
Γe:AAB
Γe:B
T-Sub
Γe:AΓe:B
Γe:AB
T-Inter
Γe:PP1×1
Γπie:proji(P)
T-Proj
Γ,x:Aie:Bi(1in)
Γλ(A1B1;;AnBn)x.e:i=1n(AiBi)
T-Abs
Γe1:FΓe2:SFSB
Γe1e2:B
T-App

The least-result form belongs to the fixed-annotation synthesizer, rather than replacing the preceding declarative rule:

synΓ(e1)=FsynΓ(e2)=SF01FS1
synΓ(e1e2)=FS
T-App-Syn

The union introductions used in the prose are derived subsumption rules:

Γe:A
Γe:AB
_1
Γe:B
Γe:AB
_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:

Γe:Sxdom(Γ)fv(e+)fv(e)dom(Γ){x}SU0Γ,x:SUe+:B+S¬U0Γ,x:S¬Ue:BSU0B+=0S¬U0B=0
ΓcaseType e as x in Ue+e:B+B
T-Case

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 proji(P) for a projection when P1×1. An abstraction checks every displayed interface premise and returns their intersection. Application checks F01 and FS1, then returns FS. 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 e:A succeeds exactly when synthesis returns SA.

Search the book

Type to search the local edition.