5. Term
de Bruijn terms
Informal definition
Replacing named variables by natural numbers, where
the number k stands for “the variable bound by the k’th
enclosing λ.”
Example
λx.x は λ.0,
λx.λy. x (y x) は λ.λ. 1 (0 1) と し て 表現でき る
姜 (本位田研) TAPL6 January 24, 2012 3 / 12
6. Term
6.1.1
f ix = λf. (λx. f (λy. (x x) y)) (λx. f (λy. (x x) y))
は
f ix = λ.(λ. 1 (λ. (1 1) 0)) (λ. 1 (λ. (1 1) 0))
と し て 表現さ れる .
f oo = (λx. (λx. x)) (λx. x)
は
f oo = (λ. (λ. 0)) (λ. 0)
姜 (本位田研) TAPL6 January 24, 2012 4 / 12
7. Term
Definition:Terms
各 term がいく つ自由変数を も つか, を 常に追いながら
term を 定義する
Terms
Let T be the smallest family of sets {T0 , T1 , T2 , . . . } st.
1 k ∈ Tn whenever 0 ≤ k < n;
2 if t1 ∈ Tn and n > 0, then λ.t1 ∈ Tn−1 ;
3 if t1 ∈ Tn and t2 ∈ Tn then (t1 t2 ) ∈ Tn
Tn を n-terms と 呼ぶ
姜 (本位田研) TAPL6 January 24, 2012 5 / 12
8. Term
naming context
Γ=x �→ 4
y �→ 3
z �→ 2
a �→ 1
b �→ 0
こ の Γ が naming context で ,
x (y z) は 4 (3 2) Γ = xn , xn−1 . . . x0 と し て
λw. y w は λ. 4 0 表現でき , こ こ では
λw.λa.λx は λ.λ.6 Γ = x, y, z, a, b
姜
.
である(本位田研) TAPL6 January 24, 2012 6 / 12
10. Shift
Shifting
Definition:Shifting
k (if k < c)
↑d
c (k) =
k + d (if k ≥ c)
�
↑d (λ.t1 ) = λ. ↑d (t1 )
c c+1
↑d (t1 t2 ) = ↑d (t1 ) ↑d (t2 )
c c c
ま た , ↑d は ↑d を あら わす
0
姜 (本位田研) TAPL6 January 24, 2012 8 / 12