Foundational judgments and untyped operational semantics
appendix sectionrules
Foundational judgments and untyped operational semantics
The elementary judgments of chapter 1 use the finite constructors displayed in their conclusions. The primitive rules, in the sense of section 1.4, are
𝟢𝗇𝖺𝗍
Nat-Z
𝑎𝗇𝖺𝗍
𝗌𝗎𝖼(𝑎)𝗇𝖺𝗍
Nat-S
𝖾𝗆𝗉𝗍𝗋𝖾𝖾
Tree-Emp
𝑎1𝗍𝗋𝖾𝖾𝑎2𝗍𝗋𝖾𝖾
𝗇𝗈𝖽𝖾(𝑎1;𝑎2)𝗍𝗋𝖾𝖾
Tree-Node
𝟢𝗂𝗌𝟢
Is-Z
𝑎𝗂𝗌𝑏
𝗌𝗎𝖼(𝑎)𝗂𝗌𝗌𝗎𝖼(𝑏)
Is-S
𝗇𝗂𝗅𝗅𝗂𝗌𝗍
List-Nil
𝑎𝗇𝖺𝗍ℓ𝗅𝗂𝗌𝗍
𝖼𝗈𝗇𝗌(𝑎;ℓ)𝗅𝗂𝗌𝗍
List-Cons
Parity is a simultaneous definition. The sum definition refers to the numeral judgment through the premise 𝑏𝗇𝖺𝗍 of Sum-Z:
𝟢𝖾𝗏𝖾𝗇
Ev-Z
𝑏𝗈𝖽𝖽
𝗌𝗎𝖼(𝑏)𝖾𝗏𝖾𝗇
Ev-S
𝑎𝖾𝗏𝖾𝗇
𝗌𝗎𝖼(𝑎)𝗈𝖽𝖽
Od-S
𝑏𝗇𝖺𝗍
𝗌𝗎𝗆(𝟢;𝑏;𝑏)
Sum-Z
𝗌𝗎𝗆(𝑎;𝑏;𝑐)
𝗌𝗎𝗆(𝗌𝗎𝖼(𝑎);𝑏;𝗌𝗎𝖼(𝑐))
Sum-S
The following two displayed schemes are not primitive. Nat-SS is derivable from Nat-S; Ev-Inv is admissible for the parity system but is not derivable there:
𝑎𝗇𝖺𝗍
𝗌𝗎𝖼(𝗌𝗎𝖼(𝑎))𝗇𝖺𝗍
Nat-SS
𝗌𝗎𝖼(𝑎)𝖾𝗏𝖾𝗇
𝑎𝗈𝖽𝖽
Ev-Inv
Hypothetical derivations have one additional metarule. An assumed judgment is available as
𝐽∈Γ
𝐽
Hyp
where the premise is the metalevel check that 𝐽 belongs to the finite hypothesis set Γ; it is not a rule added to the object system.
The arithmetic language and its values are 𝑒::=𝟢∣𝗌𝗎𝖼(𝑒)∣𝖺𝖽𝖽(𝑒;𝑒),
𝟢𝗇𝗎𝗆
Num-Z
𝑛𝗇𝗎𝗆
𝗌𝗎𝖼(𝑛)𝗇𝗎𝗆
Num-S
Its arithmetic small-step relation is
𝑒⟼𝖠𝑒′
𝗌𝗎𝖼(𝑒)⟼𝖠𝗌𝗎𝖼(𝑒′)
A-Suc
𝑒1⟼𝖠𝑒′1
𝖺𝖽𝖽(𝑒1;𝑒2)⟼𝖠𝖺𝖽𝖽(𝑒′1;𝑒2)
A-Add-L
𝑛1𝗇𝗎𝗆𝑒2⟼𝖠𝑒′2
𝖺𝖽𝖽(𝑛1;𝑒2)⟼𝖠𝖺𝖽𝖽(𝑛1;𝑒′2)
A-Add-R
𝑛2𝗇𝗎𝗆
𝖺𝖽𝖽(𝟢;𝑛2)⟼𝖠𝑛2
A-Add-Z
𝑛1𝗇𝗎𝗆𝑛2𝗇𝗎𝗆
𝖺𝖽𝖽(𝗌𝗎𝖼(𝑛1);𝑛2)⟼𝖠𝗌𝗎𝖼(𝖺𝖽𝖽(𝑛1;𝑛2))
A-Add-S
Reflexive transitive closure and big-step arithmetic evaluation are generated by
𝑒⟼∗𝖠𝑒
M-Refl
𝑒⟼𝖠𝑒1𝑒1⟼∗𝖠𝑒2
𝑒⟼∗𝖠𝑒2
M-Step
𝟢⇓𝖠𝟢
AB-Z
𝑒⇓𝖠𝑛
𝗌𝗎𝖼(𝑒)⇓𝖠𝗌𝗎𝖼(𝑛)
AB-S
𝑒1⇓𝖠𝑛1𝑒2⇓𝖠𝑛2𝗌𝗎𝗆(𝑛1;𝑛2;𝑛3)
𝖺𝖽𝖽(𝑒1;𝑒2)⇓𝖠𝑛3
AB-Add
The full untyped language is 𝑒::=𝑥∣𝜆𝑥.𝑒∣𝑒𝑒∣𝗍𝗍∣𝖿𝖿∣𝗂𝖿(𝑒;𝑒;𝑒)∣𝟢∣𝗌𝗎𝖼(𝑒)∣𝖺𝖽𝖽(𝑒;𝑒). Terms are alpha-equivalence classes of raw expressions. The notation 𝑒[𝑎/𝑥] denotes capture-avoiding substitution. Values and numeric values are generated by
𝜆𝑥.𝑏𝗏𝖺𝗅
V-Lam
𝗍𝗍𝗏𝖺𝗅
V-True
𝖿𝖿𝗏𝖺𝗅
V-False
𝑛𝗇𝗎𝗆
𝑛𝗏𝖺𝗅
V-Num
Here 𝑛𝗇𝗎𝗆 is the judgment generated by Num-Z and Num-S above; the full grammar adds no new numeric values. The full-language call-by-value relation is
𝑒1⟼𝑒′1
𝑒1𝑒2⟼𝑒′1𝑒2
E-App-L
𝑣1𝗏𝖺𝗅𝑒2⟼𝑒′2
𝑣1𝑒2⟼𝑣1𝑒′2
E-App-R
𝑣𝗏𝖺𝗅
(𝜆𝑥.𝑏)𝑣⟼𝑏[𝑣/𝑥]
E-Beta
𝑒⟼𝑒′
𝗂𝖿(𝑒;𝑒1;𝑒2)⟼𝗂𝖿(𝑒′;𝑒1;𝑒2)
E-If
𝗂𝖿(𝗍𝗍;𝑒1;𝑒2)⟼𝑒1
E-If-T
𝗂𝖿(𝖿𝖿;𝑒1;𝑒2)⟼𝑒2
E-If-F
𝑒⟼𝑒′
𝗌𝗎𝖼(𝑒)⟼𝗌𝗎𝖼(𝑒′)
E-Suc
𝑒1⟼𝑒′1
𝖺𝖽𝖽(𝑒1;𝑒2)⟼𝖺𝖽𝖽(𝑒′1;𝑒2)
E-Add-L
𝑛1𝗇𝗎𝗆𝑒2⟼𝑒′2
𝖺𝖽𝖽(𝑛1;𝑒2)⟼𝖺𝖽𝖽(𝑛1;𝑒′2)
E-Add-R
𝑛2𝗇𝗎𝗆
𝖺𝖽𝖽(𝟢;𝑛2)⟼𝑛2
E-Add-Z
𝑛1𝗇𝗎𝗆𝑛2𝗇𝗎𝗆
𝖺𝖽𝖽(𝗌𝗎𝖼(𝑛1);𝑛2)⟼𝗌𝗎𝖼(𝖺𝖽𝖽(𝑛1;𝑛2))
E-Add-S
Its reflexive–transitive closure is generated by
𝑒⟼∗𝑒
CBV-Refl
𝑒⟼𝑒1𝑒1⟼∗𝑒2
𝑒⟼∗𝑒2
CBV-Step
Equivalently, evaluation contexts and root contractions are 𝐸::=[−]∣𝐸𝑒∣𝑣𝐸∣𝗂𝖿(𝐸;𝑒1;𝑒2)∣𝗌𝗎𝖼(𝐸)∣𝖺𝖽𝖽(𝐸;𝑒)∣𝖺𝖽𝖽(𝑛;𝐸),(𝜆𝑥.𝑏)𝑣⇝0𝑏[𝑣/𝑥],𝗂𝖿(𝗍𝗍;𝑒1;𝑒2)⇝0𝑒1,𝗂𝖿(𝖿𝖿;𝑒1;𝑒2)⇝0𝑒2,𝖺𝖽𝖽(𝟢;𝑛)⇝0𝑛,𝖺𝖽𝖽(𝗌𝗎𝖼(𝑛1);𝑛2)⇝0𝗌𝗎𝖼(𝖺𝖽𝖽(𝑛1;𝑛2)), where 𝑣𝗏𝖺𝗅 and 𝑛,𝑛1,𝑛2𝗇𝗎𝗆. One step is exactly compatible closure by these contexts. The same language’s big-step relation is
𝑣𝗏𝖺𝗅
𝑣⇓𝑣
B-Val
𝑒1⇓𝜆𝑥.𝑏𝑒2⇓𝑣2𝑏[𝑣2/𝑥]⇓𝑣
𝑒1𝑒2⇓𝑣
B-App
𝑒⇓𝗍𝗍𝑒1⇓𝑣
𝗂𝖿(𝑒;𝑒1;𝑒2)⇓𝑣
B-If-T
𝑒⇓𝖿𝖿𝑒2⇓𝑣
𝗂𝖿(𝑒;𝑒1;𝑒2)⇓𝑣
B-If-F
𝑒⇓𝑛𝑛𝗇𝗎𝗆
𝗌𝗎𝖼(𝑒)⇓𝗌𝗎𝖼(𝑛)
B-Suc
𝑒1⇓𝑛1𝑒2⇓𝑛2𝗌𝗎𝗆(𝑛1;𝑛2;𝑛3)
𝖺𝖽𝖽(𝑒1;𝑒2)⇓𝑛3
B-Add
The arithmetic and full-language big-step relations use different judgment macros and rule names; the chapter proves their agreement on arithmetic expressions.