Professional Documents
Culture Documents
Types 2
Types 2
t2 : T2
(λx : T1 .t2 ) : T1 ⇒ T2
But consider:
λx : Bool. if x then s2 else s3
x : Bool ⊢ t2 : T2
{w : T1 , x : T2 , y : T3 } ⊢ z : T4 (1)
· ctx (C-Empty)
Γ ctx
(C-Extend)
Γ, x : T ctx
Well-formedness is implicitly assumed. Rather than using · for the empty
context, we instead leave it blank:
⊢ t1 : T1
x :T ∈Γ
(T-Var)
Γ⊢x :T
Γ, x : T1 ⊢ t2 : T2
(T-Abs)
Γ ⊢ (λx : T1 .t2 ) : T1 ⇒ T2
Let’s try (see board):
Γ ⊢ t1 : T1 ⇒ T2 Γ ⊢ t2 : T1
(T-App)
Γ ⊢ t1 t2 : T2
Γ ⊢ x : R =⇒ x : R ∈ Γ (I-Var)
Γ ⊢ (λx : T1 .t2 ) : R
(I-Abs)
=⇒ ∃R2 | R = (T1 ⇒ R2 ) ∧ Γ, x : T1 ⊢ t2 : R2
A later theorem will let us generalize from the empty context. Terms
typeable in the empty context are called closed.
Points of variations show up here, i.e. linear types, union types, dependent
types, etc.
Γ, x : S ⊢ t : T ∧ Γ ⊢ s : S =⇒ Γ ⊢ [x 7→ s]t : T (3)
Proof will proceed by induction over typing derivations, and using a case
analysis over typing rules.
As a reminder:
T-Abs: t = λy : T3 .t1 ∧ T = T3 ⇒ T4 ∧ Γ, x : S, y : T3 ⊢ t1 : T4
By our meta-rule of substitutions in λ expressions, we derive:
x ̸= y y∈
/ FV (s)
Γ, y : T3 , x : S ⊢ t1 : T4
Γ, y : T3 ⊢ s : S
Γ, y : T3 ⊢ [x 7→ s]t1 : T4 .
Recall T-Abs:
Γ, x : T1 ⊢ t2 : T2
Γ ⊢ λx : T1 .t2 : T1 ⇒ T2
Applying this to last equation Γ, y : T3 ⊢ [x 7→ s]t1 : T4 , get
Γ ⊢ λy : T3 .[x 7→ s]t1 : T3 ⇒ T4