Lectures onType Theory
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

0 nat
Nat-Z
a nat
suc(a) nat
Nat-S
emp tree
Tree-Emp
a1 treea2 tree
node(a1;a2) tree
Tree-Node
0is0
Is-Z
aisb
suc(a)issuc(b)
Is-S
nil list
List-Nil
a nat list
cons(a;) list
List-Cons

Parity is a simultaneous definition. The sum definition refers to the numeral judgment through the premise b nat of Sum-Z:

0 even
Ev-Z
b odd
suc(b) even
Ev-S
a even
suc(a) odd
Od-S
b nat
sum(0;b;b)
Sum-Z
sum(a;b;c)
sum(suc(a);b;suc(c))
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:

a nat
suc(suc(a)) nat
Nat-SS
suc(a) even
a odd
Ev-Inv

Hypothetical derivations have one additional metarule. An assumed judgment is available as

JΓ
J
Hyp

where the premise is the metalevel check that J belongs to the finite hypothesis set Γ; it is not a rule added to the object system.

The arithmetic language and its values are e::=0suc(e)add(e;e),

0 num
Num-Z
n num
suc(n) num
Num-S

Its arithmetic small-step relation is

eAe
suc(e)Asuc(e)
A-Suc
e1Ae1
add(e1;e2)Aadd(e1;e2)
A-Add-L
n1 nume2Ae2
add(n1;e2)Aadd(n1;e2)
A-Add-R
n2 num
add(0;n2)An2
A-Add-Z
n1 numn2 num
add(suc(n1);n2)Asuc(add(n1;n2))
A-Add-S

Reflexive transitive closure and big-step arithmetic evaluation are generated by

eAe
M-Refl
eAe1e1Ae2
eAe2
M-Step
0A0
AB-Z
eAn
suc(e)Asuc(n)
AB-S
e1An1e2An2sum(n1;n2;n3)
add(e1;e2)An3
AB-Add

The full untyped language is e::=xλx.eeettffif(e;e;e)0suc(e)add(e;e). Terms are alpha-equivalence classes of raw expressions. The notation e[a/x] denotes capture-avoiding substitution. Values and numeric values are generated by

λx.b val
V-Lam
tt val
V-True
ff val
V-False
n num
n val
V-Num

Here n num 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

e1e1
e1e2e1e2
E-App-L
v1 vale2e2
v1e2v1e2
E-App-R
v val
(λx.b)vb[v/x]
E-Beta
ee
if(e;e1;e2)if(e;e1;e2)
E-If
if(tt;e1;e2)e1
E-If-T
if(ff;e1;e2)e2
E-If-F
ee
suc(e)suc(e)
E-Suc
e1e1
add(e1;e2)add(e1;e2)
E-Add-L
n1 nume2e2
add(n1;e2)add(n1;e2)
E-Add-R
n2 num
add(0;n2)n2
E-Add-Z
n1 numn2 num
add(suc(n1);n2)suc(add(n1;n2))
E-Add-S

Its reflexive–transitive closure is generated by

ee
CBV-Refl
ee1e1e2
ee2
CBV-Step

Equivalently, evaluation contexts and root contractions are E::=[]EevEif(E;e1;e2)suc(E)add(E;e)add(n;E), (λx.b)v0b[v/x],if(tt;e1;e2)0e1,if(ff;e1;e2)0e2,add(0;n)0n,add(suc(n1);n2)0suc(add(n1;n2)), where v val and n,n1,n2 num. One step is exactly compatible closure by these contexts. The same language’s big-step relation is

v val
vv
B-Val
e1λx.be2v2b[v2/x]v
e1e2v
B-App
ette1v
if(e;e1;e2)v
B-If-T
effe2v
if(e;e1;e2)v
B-If-F
enn num
suc(e)suc(n)
B-Suc
e1n1e2n2sum(n1;n2;n3)
add(e1;e2)n3
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.

Search the book

Type to search the local edition.