





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






















CIS 500, 26 October, 2005
1
CIS 500, 26 October, 2005
2
Theorem:
If
`
t
and
t − →
t (^) ′ , then
t (^) ′
We got to the point where we needed a
substitution lemma
to show the
preservation theorem:
If
x:S
t
and
s
, then
[x
7 →
s ]t
CIS 500, 26 October, 2005
4
true
Bool
T-True
false
Bool
T-False
t 1
Bool
if t
1
then t
2
else t
3
T-If
x:T
T-Var
x:T
λ x:T
1 .t
T-Abs
11
→
T 12
11
12
T-App
CIS 500, 26 October, 2005
5
Lemma [Permutation]:
If
Γ
`
t
and
is a permutation of
then
Lemma [Weakening]:
If
Γ
`
t
and
x 6 ∈
dom
then
x : S ` t : T.
CIS 500, 26 October, 2005
7
Typing rules need a context to deal with variables.
Progress lemma must have an empty context to be true.
Preservation lemma need not (see TAPL).
Application case of preservation lemma needs substitution lemma.
Substitution lemma must be strenthened to non-empty contexts.
Substitution lemma cannot be proved by induction on typing derivation.
CIS 500, 26 October, 2005
8
t
terms
unit
constant
unit
v
values
unit
constant
unit
types
Unit
unit type
New typing rules
t
unit
Unit
T-Unit
CIS 500, 26 October, 2005
10
t
terms
t 1 ;t
2
CIS 500, 26 October, 2005
11
One way to extend a programming language is through
derived forms
A derived form is a new syntax, operational semantics
t − →
E
t (^) ′ and type
system
Γ ` E t : T
for a language such that there is a function
e
that translates
the new language into the old language with the following properties: t − → E t
(^) ′ iff
e ( t ) − → e ( t
(^) ′ ) .
Γ ` t : T
iff
e ( t ) :
Derived forms are also called
syntactic sugar
CIS 500, 26 October, 2005
12
1 ;t
2
λ x:Unit.t
2 ) t
1
where
x
/∈
FV
t 2 )
CIS 500, 26 October, 2005
13
t^ New syntactic forms
terms
let x=t in t
let binding
New evaluation rules
t − →
t (^) ′
let x=v
1
in t
2 − →
[x
7 →
v 1 ]t 2
E-LetV
t 1 − →
t (^1) ′
let x=t
1
in t
2 − →
let x=t
(^1) ′
in t
2
E-Let
New typing rules
t
x:T
let x=t
1
in t
2
2
T-Let
CIS 500, 26 October, 2005
15
t
terms
{t,t}
pair
t.
first projection
t.
second projection
v
values
{v,v}
pair value
types
1 (^) ×
(^) T 2
product type
CIS 500, 26 October, 2005
16
{t
1 ,t
2 }
1 (^) ×
(^) T 2
T-Pair
11
(^) ×
(^) T 12
t 1 .
11
T-Proj
11
(^) ×
(^) T 12
t 1 .
12
T-Proj
CIS 500, 26 October, 2005
18
t
terms
{t
i i ∈ 1 (^) ..n
tuple
t.i
projection
v
values
{v
i i ∈ 1 (^) ..n
tuple value
types
i i ∈ 1 (^) ..n
tuple type
CIS 500, 26 October, 2005
19