markdown
置換とα同値の基本md 8886dac
lecture/information/programming-languages/foundation/substitution-and-alpha-equivalence-basics.lecture.n.md
Download PDF

置換ちかんとα同値どうち基本きほん

informationprogramming-languageslambda-calculuslecture

1導入どうにゅう

この講義こうぎでは、変数へんすう自由出現じゆうしゅつげんだけをこう置換ちかんする操作そうさ定義ていぎする。単純たんじゅん文字列置換もじれつちかん自由変数じゆうへんすう意図いとせず束縛そくばくするため、束縛変数そくばくへんすう改名かいめいによって変数捕縛へんすうほばくvariable capture回避かいひする必要ひつようがある。この改名かいめい形式化けいしきかするα同値どうち定義ていぎする。

2置換ちかん捕縛ほばく

M[x:=N] は、M における x自由出現じゆうしゅつげんこう N置換ちかんした結果けっかあらわす。束縛出現そくばくしゅつげん置換ちかん対象たいしょうではない。たとえば

(λx.xy)[x:=N]=λx.xy

である。一方いっぽう(λy.x)[x:=y]機械的きかいてきλy.y とすると、置換前ちかんまえ自由じゆうであった右辺うへんyλy束縛そくばくされる。この変化へんか変数捕縛へんすうほばくである。ただしい結果けっかは、束縛子そくばくしさき改名かいめいした λz.y である。

3fresh 変数へんすう

こう有限集合ゆうげんしゅうごう Sたいし、S出現しゅつげんするどの変数名へんすうめいともことなる変数へんすう zSたいしてfreshフレッシュであるという。[PARSE ERROR: Undefined("Command(\"mathcal\")")]V無限むげんであり、有限個ゆうげんここう出現しゅつげんする変数名へんすうめい有限個ゆうげんこなので、fresh変数へんすうつね選択せんたくできる。以下いかでは、改名かいめいによる混同こんどうけるため、zMN双方そうほう出現しゅつげんしないように選択せんたくする。

4捕縛回避置換ほばくかいひちかん

捕縛回避置換ほばくかいひちかん構文こうぶんかんして再帰的さいきてき定義ていぎする。

x[x:=N]=N,y[x:=N]=y(yx),
(M1M2)[x:=N]=(M1[x:=N])(M2[x:=N]).

λ抽象ちゅうしょうにはみっつの場合ばあいがある。

(λx.M)[x:=N]=λx.M,
(λy.M)[x:=N]=λy.(M[x:=N])(yx,yFV(N)),
(λy.M)[x:=N]=λz.((M[y:=z])[x:=N])(yx,yFV(N)),

ただし、最後さいご場合ばあいzMNたいしてfreshである。より厳密げんみつには、xFV(M) なら置換結果ちかんけっかM 自身じしんであり、改名かいめい不要ふようである。うえ最後さいご場合ばあいxFV(M) のときに適用てきようすればよい。

れいとして、zx,yことなるfresh変数へんすうえらぶと、

(λy.xy)[x:=y]=λz.((xz)[x:=y])=λz.yz.

挿入そうにゅうされた y結果けっかでも自由じゆうである。

5α変換へんかんとα同値どうち

束縛子そくばくしと、それが束縛そくばくする出現しゅつげん一斉いっせいにfresh変数へんすう改名かいめいする操作そうさをα変換へんかんという。yFV(M) のとき、

λx.M=αλy.(M[x:=y])

とする。ここで右辺うへん置換ちかん捕縛回避置換ほばくかいひちかんである。α同値どうち =α は、この基本的きほんてき改名かいめい任意にんい部分項ぶぶんこうゆるし、反射性はんしゃせい対称性たいしょうせい推移性すいいせいたす最小さいしょう合同関係ごうどうかんけいである。したがって

λx.x=αλy.y,

だが、自由変数じゆうへんすう改名かいめいできないため λx.xy[PARSE ERROR: Undefined("Command(\"not\")")]=αλx.xz である。また λx.λy.x[PARSE ERROR: Undefined("Command(\"not\")")]=αλx.λy.y であり、α同値どうち束縛構造そくばくこうぞう保存ほぞんする。

6β簡約かんやくへの接続せつぞく

β簡約かんやく

(λx.M)NβM[x:=N]

定義ていぎされ、右辺うへんには捕縛回避置換ほばくかいひちかんもちいる。たとえば

(λx.λy.x)yβλz.y

であり、λy.y ではない。fresh変数へんすう選択せんたくによって結果けっか表記ひょうきことなりるが、いずれの結果けっかもα同値どうちである。

7関連かんれんリンク

data/lecture/information/programming-languages/foundation/variable-binding-and-free-variables-basics.lecture.n.md data/lecture/information/programming-languages/lambda-calculus/lambda-calculus-basics.lecture.n.md

Basics of Substitution and Alpha-Equivalence

1Introduction

This lecture defines the operation that replaces only the free occurrences of a variable by a term. Naive textual replacement may accidentally bind a free variable, so bound variables must sometimes be renamed to avoid variable capture. Alpha-equivalence formalizes these harmless renamings.

2Substitution and capture

M[x:=N] denotes the result of replacing the free occurrences of x in M by the term N. Bound occurrences are not targets of substitution. For example,

(λx.xy)[x:=N]=λx.xy.

By contrast, mechanically turning (λy.x)[x:=y] into λy.y makes the inserted occurrence of y bound by λy, although it was free before insertion. This change is variable capture. The correct result first renames the binder and is λz.y.

3Fresh variables

For a finite set of terms S, a variable z is fresh for S if its name occurs in none of the terms in S. Because [PARSE ERROR: Undefined("Command(\"mathcal\")")]V is infinite and finitely many terms contain only finitely many variable names, a fresh variable can always be chosen. Below, z is chosen not to occur in either M or N, avoiding ambiguity during renaming.

4Capture-avoiding substitution

Capture-avoiding substitution is defined recursively on syntax:

x[x:=N]=N,y[x:=N]=y(yx),
(M1M2)[x:=N]=(M1[x:=N])(M2[x:=N]).

There are three abstraction cases:

(λx.M)[x:=N]=λx.M,
(λy.M)[x:=N]=λy.(M[x:=N])(yx,yFV(N)),
(λy.M)[x:=N]=λz.((M[y:=z])[x:=N])(yx,yFV(N)),

where z in the last clause is fresh for both M and N. More precisely, if xFV(M), the result is M itself and no renaming is needed; the last clause need only be applied when xFV(M).

For example, choosing z fresh and distinct from x,y gives

(λy.xy)[x:=y]=λz.((xz)[x:=y])=λz.yz.

The inserted occurrence of y remains free in the result.

5Alpha-conversion and alpha-equivalence

Alpha-conversion simultaneously renames a binder and the occurrences that it binds to a fresh variable. If yFV(M), then

λx.M=αλy.(M[x:=y]),

where the substitution on the right is capture-avoiding. Alpha-equivalence =α is the least congruence relation that permits this elementary renaming in any subterm and is reflexive, symmetric, and transitive. Consequently,

λx.x=αλy.y,

but free variables cannot be renamed, so λx.xy[PARSE ERROR: Undefined("Command(\"not\")")]=αλx.xz. Moreover, λx.λy.x[PARSE ERROR: Undefined("Command(\"not\")")]=αλx.λy.y: alpha-equivalence preserves binding structure.

6Connection to beta-reduction

Beta-reduction is defined by

(λx.M)NβM[x:=N],

using capture-avoiding substitution on the right. For example,

(λx.λy.x)yβλz.y,

not λy.y. Different choices of a fresh variable may produce different spellings, but all resulting terms are alpha-equivalent.

7Related links

data/lecture/information/programming-languages/foundation/variable-binding-and-free-variables-basics.lecture.n.md data/lecture/information/programming-languages/lambda-calculus/lambda-calculus-basics.lecture.n.md
raw .n.md をコピー
loc をコピー (filepath:line ~ line)
copy share link
copy encoded share link
path をコピー
copy share link
copy encoded share link
copy share link
copy encoded share link
タブを全て閉じる