コンビネータ論理の抽象化(abstraction)についての演習問題(続編)をいくつか解いてみる。
前編の演習問題はこちら
参考図書は
https://amzn.to/3F1l7iV
Lambda-Calculus and Combinators:An Introduction PDF
定義 2.18(抽象化)
(a)$\ [x].M\equiv {\bf K}M$ if $x\notin FV(M)$
(b)$\ [x].x\equiv {\bf I}$
(c)$\ [x].Ux\equiv U$ if $ x\notin FV(U)$
(f)$\ [x].UV\equiv {\bf S}([x].U)([x].V)$もし(a)も(c)も適用できない場合。
例 2.26
(a) [x,y,z].xzy
$\quad[x,y,z].xzy$
$\equiv[x].([y].([z].xzy))$
$\equiv[x].([y].({\bf S}([z].xz)([z].y)))\quad$ by 2.18(f)
$\equiv[x].([y].({\bf S}x({\bf K}y)))\quad$ by 2.18(c) and (a)
$\equiv[x].({\bf S}([y].{\bf S}x)([y].{\bf K}y))\quad$ by 2.18(f)
$\equiv[x].{\bf S}({\bf K}({\bf S}x)){\bf K}\quad$ by 2.18(a) and (c)
$\equiv{\bf S}([x].{\bf S}({\bf K}({\bf S}x)))([x].{\bf K})\quad$ by 2.18(f)
$\equiv{\bf S}(\underline{[x].{\bf S}({\bf K}({\bf S}x))})({\bf KK})\quad$ by 2.18(a)
$\equiv{\bf S}({\bf S}([x].{\bf S})([x].{\bf K}({\bf S}x)))({\bf KK})\quad$ by 2.18(f)
$\equiv{\bf S}({\bf S}({\bf KS})({\bf S}([x].{\bf K})([x].{\bf S}x)))({\bf KK})\quad$ by 2.18(a) and (f)
$\equiv{\bf S}({\bf S}({\bf KS})({\bf S}({\bf KK}){\bf S}))({\bf KK})\quad$ by 2.18(a) and (c)
検証
$\quad{\bf S}(\underline{{\bf S}({\bf KS})({\bf S}({\bf KK}){\bf S})})(\underline{{\bf KK}})\underline{x}yz$
$\triangleright\ {\bf S}(\underline{{\bf KS}})(\underline{{\bf S}({\bf KK}){\bf S}})\underline{x}({\bf KK}x)yz$
$\triangleright\ (\underline{{\bf KS}x})(\underline{{\bf S}({\bf KK}){\bf S}x})({\bf K})yz$
$\triangleright\ {\bf S}(\underline{{\bf KK}x}({\bf S}x)){\bf K}yz$
$\triangleright\ {\bf S}(\underline{{\bf K}({\bf S}x)})\underline{{\bf K}}\ \underline{y}z$
$\triangleright\ {\bf K}({\bf S}x)y({\bf K}y)z$
$\triangleright\ {\bf S}x({\bf K}y)z$
$\triangleright\ xz({\bf K}yz)$
$\triangleright\ xz(y)\ \triangleright\ xzy\quad\square$
${\bf C}xyz\ \triangleright\ xzy$なので
${\bf C}\equiv{\bf S}({\bf S}({\bf KS})({\bf S}({\bf KK}){\bf S}))({\bf KK})$
(b) [x,y,z].y(xz)
$\quad[x,y,z].y(xz)$
$\equiv[x].([y].([z].y(xz)))$
$\equiv[x].([y].({\bf S}([z].y)([z].xz)))\quad$ by 2.18 (f)
$\equiv[x].([y].({\bf S}({\bf K}y)x))\quad$ by 2.18 (a) and (c)
$\equiv[x].({\bf S}([y].{\bf S}({\bf K}y))([y].x))\quad$ by 2.18 (f)
$\equiv[x].{\bf S}({\bf S}([y].{\bf S})([y].{\bf K}y))({\bf K}x)\quad$ by 2.18 (f) and (a)
$\equiv[x].{\bf S}({\bf S}({\bf KS}){\bf K})({\bf K}x)\quad$ by 2.18 (a) and (c)
$\equiv{\bf S}([x].{\bf S}({\bf S}({\bf KS}){\bf K}))([x].{\bf K}x)\quad$ by 2.18 (f)
$\equiv{\bf S}({\bf K}({\bf S}({\bf S}({\bf KS}){\bf K})))\ {\bf K}\quad$ by 2.18 (a) and (c)
検証
$\quad{\bf S}({\bf K}({\bf S}({\bf S}({\bf KS}){\bf K}))){\bf K}\ x\ y\ z$
$\triangleright\ {\bf K}({\bf S}({\bf S}({\bf KS}){\bf K}))x\ ({\bf K}x)\ y\ z$
$\triangleright\ {\bf S}({\bf S}({\bf KS}){\bf K})\ ({\bf K}x)\ y\ z$
$\triangleright\ {\bf S}({\bf KS}){\bf K}y\ ({\bf K}xy)\ z$
$\triangleright\ {\bf KS}y\ ({\bf K}y)\ x\ z$
$\triangleright\ {\bf S}\ ({\bf K}y)\ x\ z$
$\triangleright\ {\bf K}yz\ (xz)$
$\triangleright\ y(xz)$
${\bf B'}xyz\ \triangleright\ y(xz)$なので
${\bf B'}\equiv{\bf S}({\bf K}({\bf S}({\bf S}({\bf KS}){\bf K})))\ {\bf K}$
(c) [x,y].xyy
$\quad[x,y].xyy$
$\equiv[x].([y].xyy)$
$\equiv[x].{\bf S}([y].xy)([y].y)\quad$ by 2.18 (f)
$\equiv[x].{\bf S}x{\bf I}\quad$ by 2.18 (c) and (b)
$\equiv{\bf S}([x].{\bf S}x)([x].{\bf I})\quad$ by 2.18 (f)
$\equiv{\bf S}{\bf S}({\bf KI})\quad$ by 2.18 (c) and (a)
検証
$\quad{\bf S}{\bf S}({\bf KI})\ x\ y$
$\triangleright\ {\bf S}x\ ({\bf KI}x)\ y$
$\triangleright\ {\bf S}x\ {\bf I}\ y$
$\triangleright\ xy\ ({\bf I}y)$
$\triangleright\ xyy$
${\bf W}xy\ \triangleright\ xyy$なので
${\bf W}\equiv{\bf S}{\bf S}({\bf KI})\quad$