From e09f2f68249f61576edae39911dc0daa050663c7 Mon Sep 17 00:00:00 2001 From: KokunoYumeto <208192274+KokunoYumeto@users.noreply.github.com> Date: Mon, 30 Nov 2026 22:30:53 +0100 Subject: [PATCH 1/4] lambda-calculus/church-rosser: corrections (11 places) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit beta-eta-reduction.tex: - l. 14: The preceding syntax section defined beta-eta closure but not this one-step notation. - l. 21: The proof is about beta-eta one-step contraction; a pure beta-contraction symbol is incorrect in the eta case. beta-reduction.tex: - l. 16, 20: One-step beta contraction is compatible and can occur inside an abstraction or application; the proof only treats a root redex. - l. 43: English extra verb. parallel-beta-eta-reduction.tex: - l. 22: The premise must use parallel beta-eta reduction. A beta-only relation cannot lift an eta change in the body. - l. 50: The two clauses overlap and may give different alpha-classes, so they do not define a function without priority. - l. 70: The component list omits the body N used in the source term, side condition and premise; include it alongside the binder and reduced body. This is a local metavariable-list omission, not a failure of the eta rule. - l. 83: Eta contraction can turn an abstraction into a non-abstraction, invalidating the beta proof shape assumption. Also the outer eta-redex and a beta contraction in its body require an additional overlap argument. The theorem remains true. parallel-beta-reduction.tex: - l. 20: Uses ordinary beta step instead of parallel reduction. A variable has no ordinary contraction, so literal rule cannot prove lambda abstraction reflexivity. - l. 89: The substituted term is R′, as in the claim. Co-Authored-By: Claude Opus 5.5 --- .../church-rosser/beta-eta-reduction.tex | 14 +++-- .../church-rosser/beta-reduction.tex | 11 +++- .../parallel-beta-eta-reduction.tex | 62 +++++++++++++++---- .../church-rosser/parallel-beta-reduction.tex | 4 +- 4 files changed, 71 insertions(+), 20 deletions(-) diff --git a/content/lambda-calculus/church-rosser/beta-eta-reduction.tex b/content/lambda-calculus/church-rosser/beta-eta-reduction.tex index b4015862..98bd3803 100644 --- a/content/lambda-calculus/church-rosser/beta-eta-reduction.tex +++ b/content/lambda-calculus/church-rosser/beta-eta-reduction.tex @@ -11,17 +11,21 @@ \olsection{$\beta\eta$-reduction} The Church--Rosser property holds for -$\beta\eta$-reduction ($\bered$). +$\beta\eta$-reduction ($\bered$). Write $M\beredone N$ when either +$M\bredone N$ or $M\eredone N$; thus $\beredone$ is the union of the +two compatible one-step contraction relations. \begin{lem}\ollabel{lem:one-par} If $M \beredone M'$, then $M \beredpar M'$. \end{lem} \begin{proof} - By induction on the !!{derivation} of $M \beredone M'$. If $M \bredone - M'$ by $\eta$-conversion (i.e., \olref[syn][eta]{defn:beredone}), we - use \olref[pbe]{thm:refl}. The other cases are as in - \olref[b]{lem:one-par}. + Induct on the compatible one-step contraction derivation. For a + root $\eta$-contraction, $M=\lambd[x][Nx]$, $M'=N$, and + $x\notin\FV{N}$. Use $N\beredpar N$ from + \olref[pbe]{thm:refl}, followed by \olref[pbe]{defn:beredpar5}. + The root $\beta$ case and the abstraction and application contexts + are as in \olref[b]{lem:one-par}. \end{proof} diff --git a/content/lambda-calculus/church-rosser/beta-reduction.tex b/content/lambda-calculus/church-rosser/beta-reduction.tex index 00b305a4..0cb0fe95 100644 --- a/content/lambda-calculus/church-rosser/beta-reduction.tex +++ b/content/lambda-calculus/church-rosser/beta-reduction.tex @@ -13,11 +13,18 @@ \begin{lem}\ollabel{lem:one-par} If $M \bredone M'$, then $M \bredpar M'$. \end{lem} -\begin{proof} If $M \bredone M'$, then $M$ is +\begin{proof} +Induct on the compatible one-step contraction derivation. In the +root-redex case, $M$ is $(\lambd[x][N])Q$, $M'$ is $\Subst{N}{Q}{x}$, for some $x$, $N$, and~$Q$. Since $N \bredpar N$ and $Q \bredpar Q$ by \olref[pb]{thm:refl}, we immediately have $(\lambd[x][N])Q \bredpar \Subst{N}{Q}{x}$ by \olref[pb]{defn:bredpar}\olref[pb]{defn:bredpar4}. +For a contraction inside an abstraction, lift the induction +hypothesis by \olref[pb]{defn:bredpar2}. For a contraction in either +child of an application, combine the induction hypothesis with +\olref[pb]{thm:refl} on the unchanged child and use +\olref[pb]{defn:bredpar3}. \end{proof} \begin{lem}\ollabel{lem:par-red} @@ -40,7 +47,7 @@ by the reduction $Q \bred Q'$. \item The last rule is \olref[pb]{defn:bredpar4}: $M$ is $(\lambd[x][N])Q$ and $M'$ is $\Subst{N'}{Q'}{x}$ for some $x$, - $N$, $M'$, $Q$, $Q'$, where $N \bredpar N'$ and $Q \bredpar Q'$. + $N$, $N'$, $Q$, $Q'$, where $N \bredpar N'$ and $Q \bredpar Q'$. By induction hypothesis we get $Q \bred Q'$ and $N \bred N'$. So $(\lambd[x][N])Q \bred \Subst{N'}{Q'}{x}$ by $N \bred N'$ followed by $Q \bred Q'$ and finally contraction of $(\lambd[x][N'])Q'$ to diff --git a/content/lambda-calculus/church-rosser/parallel-beta-eta-reduction.tex b/content/lambda-calculus/church-rosser/parallel-beta-eta-reduction.tex index 7d7f66f3..debb93a4 100644 --- a/content/lambda-calculus/church-rosser/parallel-beta-eta-reduction.tex +++ b/content/lambda-calculus/church-rosser/parallel-beta-eta-reduction.tex @@ -19,7 +19,7 @@ inductively defined as follows: \begin{enumerate} \item \ollabel{defn:beredpar1} $x \beredpar x$. - \item \ollabel{defn:beredpar2} If $N \xrightarrow{\beta} N'$ then $\lambd[x][N] \beredpar + \item \ollabel{defn:beredpar2} If $N \beredpar N'$ then $\lambd[x][N] \beredpar \lambd[x][N']$. \item \ollabel{defn:beredpar3} If $P \beredpar P'$ and $Q \beredpar Q'$ then $PQ \beredpar P'Q'$. @@ -47,7 +47,9 @@ as follows: \begin{align} \becd{x} &= x \ollabel{defn:becd1} \\ - \becd{(\lambd[x][N])} &= \lambd[x][\becd{N}] \ollabel{defn:becd2}\\ + \becd{(\lambd[x][N])} &= \lambd[x][\becd{N}] + &&\text{if $\lambd[x][N]$ is not an $\eta$-redex} + \ollabel{defn:becd2}\\ \becd{(PQ)} &= \becd{P}\becd{Q} && \text{if $P$ is not a $\lambd$-abstract} \ollabel{defn:becd3} \\ \becd{((\lambd[x][N])Q)} &= \Subst{\becd{N}}{\becd{Q}}{x} @@ -67,7 +69,7 @@ The first four cases are exactly like those in \olref[pb]{lem:comp}. If the last rule is \olref{defn:beredpar5}, then $M$ is - $\lambd[x][Nx]$, $M'$ is $N'$ for some $x$ and~$N'$ where $x \notin + $\lambd[x][Nx]$, $M'$ is $N'$ for some $x$, $N$, and~$N'$ where $x \notin FV(N)$, and $N \beredpar N'$. We want to show that $\Subst{(\lambd[x][Nx])}{R}{y} \beredpar \Subst{N'}{R'}{y}$, i.e., $\lambd[x][\Subst{N}{R}{y} x] \beredpar \Subst{N'}{R'}{y}$. It @@ -80,14 +82,52 @@ \end{lem} \begin{proof} - By induction on the !!{derivation} of $M \beredpar M'$. - - The first four cases are like those in \olref[pb]{lem:cont}. If the - last rule is \olref{defn:beredpar5}, then $M$ is $\lambd[x][Nx]$ and - $M'$ is $N'$ for some $x$, $N$, $N'$ where $x \notin FV(N)$ and $N - \beredpar N'$. We want to show that $N' \beredpar - \becd{(\lambd[x][Nx])}$, i.e., $N' \beredpar \becd{N}$, which is - immediate by induction hypothesis. +Use strong induction on the size of $M$, with representatives chosen +fresh whenever needed. Induction on parallel-reduction derivations +first gives $\FV{A'}\subseteq\FV{A}$ whenever $A\beredpar A'$. +Also $A\beredpar\becd{A}$ follows from the development clauses by +structural induction. These facts preserve every freshness +condition used below. + +The variable case is immediate. Suppose $M=\lambd[x][N]$ is not an +$\eta$-redex. Its parallel reduct is $\lambd[x][N']$, where +$N\beredpar N'$. The induction hypothesis and the abstraction rule +give $\lambd[x][N']\beredpar\lambd[x][\becd{N}]=\becd{M}$. + +Now suppose $M=\lambd[x][Px]$ with $x\notin\FV{P}$, so that +$\becd{M}=\becd{P}$. An outer $\eta$ step gives a reduct $P'$ of $P$, +and induction gives $P'\beredpar\becd{P}$. An abstraction step gives +$\lambd[x][N']$ where $Px\beredpar N'$. If this body step uses the +application rule, $N'=P'x$, and induction followed by the $\eta$ +rule gives $\lambd[x][P'x]\beredpar\becd{P}$. If it uses the +$\beta$ rule, write $P=\lambd[y][T]$ and +$N'=\Subst{T'}{x}{y}$, where $T\beredpar T'$. Since $x$ is fresh, +$\lambd[x][\Subst{T'}{x}{y}]\aeq\lambd[y][T']$. +The latter is a parallel reduct of the smaller term $P$, so induction +again gives a parallel reduction to $\becd{P}$. + +Suppose next that $M=PQ$ and $P$ is not an abstraction. Only the +application rule can be last, and induction gives +$P'Q'\beredpar\becd{P}\becd{Q}=\becd{M}$. + +Finally let $M=(\lambd[x][N])Q$. If the last rule is the $\beta$ +rule, induction and \olref{lem:comp} give +$\Subst{N'}{Q'}{x}\beredpar\Subst{\becd{N}}{\becd{Q}}{x} +=\becd{M}$. If the last rule is application, the reduct is $P'Q'$ +with $\lambd[x][N]\beredpar P'$ and $Q\beredpar Q'$. +When the function reduction uses abstraction, $P'=\lambd[x][N']$; +induction and the $\beta$ rule give the same target. + +The remaining function reduction uses $\eta$: then $N=Sx$, +$x\notin\FV{S}$, and $S\beredpar P'$. If $S$ is not an abstraction, +the target is $\becd{S}\becd{Q}$, reached from $P'Q'$ by induction +and application. If $S=\lambd[y][T]$, the target is +$\Subst{\becd{T}}{\becd{Q}}{y}$, by the capture-free substitution +identity and freshness of $x$. But $P'Q'$ is a parallel reduct of +$SQ$, a term strictly smaller than the original +$(\lambd[x][Sx])Q$. The strong induction hypothesis for $SQ$ gives +exactly that target. This covers both overlaps between $\beta$ and +$\eta$. \end{proof} \begin{thm}\ollabel{thm:cr} diff --git a/content/lambda-calculus/church-rosser/parallel-beta-reduction.tex b/content/lambda-calculus/church-rosser/parallel-beta-reduction.tex index 86c8f55d..0bbc0710 100644 --- a/content/lambda-calculus/church-rosser/parallel-beta-reduction.tex +++ b/content/lambda-calculus/church-rosser/parallel-beta-reduction.tex @@ -17,7 +17,7 @@ Parallel reduction ($\bredpar$) of terms is inductively defined as follows: \begin{enumerate} \item \ollabel{defn:bredpar1} $x \bredpar x$. - \item \ollabel{defn:bredpar2} If $N \xrightarrow{\beta} N'$ then $\lambd[x][N] \bredpar + \item \ollabel{defn:bredpar2} If $N \bredpar N'$ then $\lambd[x][N] \bredpar \lambd[x][N']$. \item \ollabel{defn:bredpar3} If $P \bredpar P'$ and $Q \bredpar Q'$ then $PQ \bredpar P'Q'$. @@ -86,7 +86,7 @@ $\Subst{(\lambd[x][N])}{R}{y} \bredpar \Subst{(\lambd[x][N'])}{R'}{y}$, i.e., $\lambd[x][\Subst{N}{R}{y}] \bredpar - \lambd[x][\Subst{N'}{R}{y}]$. This follows immediately by + \lambd[x][\Subst{N'}{R'}{y}]$. This follows immediately by \olref{defn:bredpar2} and the induction hypothesis. \item The last step is \olref{defn:bredpar3}: Exercise. \item The last step is \olref{defn:bredpar4}: $M$ is From e0cda4c0ae16d375eb0c2b202a1d9061f59022cc Mon Sep 17 00:00:00 2001 From: KokunoYumeto <208192274+KokunoYumeto@users.noreply.github.com> Date: Mon, 30 Nov 2026 22:30:54 +0100 Subject: [PATCH 2/4] lambda-calculus/introduction: corrections (29 places) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit basic-pr-lambda.tex: - l. 17: The zero function is unary (explicitly Zero(x)=0 in OLP 0294). The proposed term is the numeral zero itself; applied to any argument it reduces to lambda y.y, not to numeral zero. composition.tex: - l. 16, 27: This roadmap leaves unspecified how partiality is preserved; the later literal-composition construction can erase divergence. computable-lambda.tex: - l. 18: The outline avoids closure of partial functions under ordinary composition, which does not hold literally: by the normal form theorem, total primitive recursive functions and one search suffice. currying.tex: - l. 44, 54: The shown intermediate lambda y.M captures a free y of M unless the binder is renamed. For M=y and N=z the displayed intermediate reduces to z, whereas capture-avoiding K y z reduces to y. - l. 63: The body introduced throughout this derivation is N; P is unintroduced. fixed-point-combinator.tex: - l. 13: Literal construction requires x not free in g. Otherwise the abstraction captures occurrences belonging to the given term. lambda-definability.tex: - l. 21: The whole lambda expression also includes the binding occurrence of x; n counts occurrences in the body, not the entire written term. - l. 30: The arguments and all subsequent clauses have arity k, not the otherwise unrelated n. minimization.tex: - l. 20: The total case is proved first; the partial case is proved at the end. - l. 33: Only lambda-definability is assumed in the lemma; primitive recursiveness is unsupported. - l. 39, 44, 56, 60: The earlier base-functions file defines the successor term as Succ; identify S as that term rather than silently treating a new symbol as defined. - l. 41: The fixed-point term used is Turing's. - l. 63: A search that finds nothing must have no normal form; this needs leftmost-outermost reduction, and the partial case is completed here. primitive-recursion.tex: - l. 13: The requested term must be F; the step index is x, not z; the initial parameterized equations need the original representing terms G′/H′, while the later absorbed G/H are different terms; v already represents the previous parameter function and must receive zvec alone. - l. 19: The step index is x, not z. - l. 21, 24, 40: The representing terms are G′ and H′, and the term sought is F′. - l. 27: The claim is proved by induction on n, for total g and h. - l. 38: The recursion takes the previous value v(z), since v already stands for the function at u. - l. 79: The equations alone do not preserve undefinedness: the construction is for total functions. - l. 98: S was not defined as the successor term. - l. 129: The induction hypothesis identifies the nth iterate with its pair in the transition to the third displayed line; the second-to-last line instead unfolds T and pairing. syntax.tex: - l. 64: An occurrence is bound only by a lambda binding that same variable; another variable can occur freely within the scope. The source own following example has y inside lambda z yet free. Co-Authored-By: Claude Opus 5.5 --- .../introduction/basic-pr-lambda.tex | 4 +- .../introduction/composition.tex | 8 ++- .../introduction/computable-lambda.tex | 29 ++++++---- .../lambda-calculus/introduction/currying.tex | 8 ++- .../introduction/fixed-point-combinator.tex | 3 +- .../introduction/lambda-definability.tex | 4 +- .../introduction/minimization.tex | 57 +++++++++++++++---- .../introduction/primitive-recursion.tex | 40 +++++++------ .../lambda-calculus/introduction/syntax.tex | 4 +- 9 files changed, 108 insertions(+), 49 deletions(-) diff --git a/content/lambda-calculus/introduction/basic-pr-lambda.tex b/content/lambda-calculus/introduction/basic-pr-lambda.tex index c07ae88f..e58b8942 100644 --- a/content/lambda-calculus/introduction/basic-pr-lambda.tex +++ b/content/lambda-calculus/introduction/basic-pr-lambda.tex @@ -14,8 +14,8 @@ \end{lem} \begin{proof} -$\Zero$ is just -$\lambd[x][\lambd[y][y]]$. +$\Zero$ is !!{lambda defined} by +$\lambd[z][\lambd[x][\lambd[y][y]]]$. The successor function~$\Succ$, is defined by $\fn{Succ}(u) = \lambd[x][\lambd[y][x(uxy)]]$. You should diff --git a/content/lambda-calculus/introduction/composition.tex b/content/lambda-calculus/introduction/composition.tex index f150e14d..b5754bcc 100644 --- a/content/lambda-calculus/introduction/composition.tex +++ b/content/lambda-calculus/introduction/composition.tex @@ -14,6 +14,9 @@ \end{lem} \begin{proof} +We first prove this for total component functions. The general +partial case follows from the independent computability equivalence +completed in \olref[min]{sec}. Suppose $f$ is defined by composition from $h$, $g_0,$ \dots,~$g_{k-1}$. Assuming $h$, $g_0$, \dots,~$g_{k-1}$ are !!{lambda defined} by $H$, $G_0$, \dots,~$G_{k-1}$, @@ -24,7 +27,10 @@ \dots, G_{k-1}(x_0, \dots, x_{l-1})). \] In other words, the language of the lambda calculus is well suited to -represent composition. +represent composition for total components. For partial components +this term alone need not work: a constant-zero outer term can erase +a nonnormalizing inner term, although strict numeric composition is +then undefined. \end{proof} \end{document} diff --git a/content/lambda-calculus/introduction/computable-lambda.tex b/content/lambda-calculus/introduction/computable-lambda.tex index c99cdf1c..99818c1a 100644 --- a/content/lambda-calculus/introduction/computable-lambda.tex +++ b/content/lambda-calculus/introduction/computable-lambda.tex @@ -15,16 +15,25 @@ \end{thm} \begin{proof} -We need to show that every partial computable function~$f$ is -!!{lambda defined} by a lambda term~$F$. By Kleene's normal form -theorem, it suffices to show that every primitive recursive function -is !!{lambda defined} by a lambda term, and then that the functions -!!{lambda definable} are closed under suitable compositions and -unbounded search. To show that every primitive recursive function is -!!{lambda defined} by a lambda term, it suffices to show that the -initial functions are !!{lambda definable}, and that the partial -functions that are !!{lambda definable} are closed under -composition, primitive recursion, and unbounded search. +By Kleene's normal form theorem, for every partial computable +function~$f$ there are primitive recursive functions $r$ and $u$ such +that +\[ +f(\vec x)\simeq u(\umin{t}{r(\vec x,t)}). +\] +First we represent +the initial functions and prove closure under composition and +primitive recursion for \emph{total} functions. This supplies terms +for $r$ and $u$. We then implement a search that returns the decoded +value $u(t)$ only in its successful branch; the construction at the +end of \olref[min]{sec} also proves that an unsuccessful search has +no normal form. This proves the theorem without assuming that +ordinary lambda application preserves undefinedness. + +After this construction, the general partial closure results follow +from the computability of lambda-definable functions +(\olref[cmp]{thm:lambda-computable}) and the corresponding strict +closure operations on partial computable functions. \end{proof} We will use a more conventional notation to make the rest of the proof diff --git a/content/lambda-calculus/introduction/currying.tex b/content/lambda-calculus/introduction/currying.tex index 2c1422c0..2d594e0e 100644 --- a/content/lambda-calculus/introduction/currying.tex +++ b/content/lambda-calculus/introduction/currying.tex @@ -41,7 +41,8 @@ accepts an argument~$x$ and returns the function~$\lambd[y][x]$. The function $\lambd[y][x]$ accepts another argument~$y$, but drops it, and always returns~$x$. Let's see what happens when we apply -$\lambd[x][\lambd[y][x]]$ to two arguments: +$\lambd[x][\lambd[y][x]]$ to two arguments, choosing $y$ not free +in $M$ by renaming the bound variable first if necessary: \begin{align*} (\lambd[x][\lambd[y][x]])MN \bredone & (\lambd[y][M])N \\ @@ -51,7 +52,8 @@ In general, to write a function with parameters $x_1$, \dots,~$x_n$ defined by some term~$N$, we can write $\lambd[x_1][\lambd[x_2][\ldots\lambd[x_n][N]]]$. If we apply $n$ arguments -to it we get: +to it, first choose the $x_i$ pairwise distinct and not free in any +$M_j$, renaming bound variables as necessary. Then we get: \begin{multline*} (\lambd[x_1][\lambd[x_2][\ldots\lambd[x_n][N]]]) M_1 \dots M_n \bredone\\ \begin{aligned} @@ -60,7 +62,7 @@ \eqs {} & (\lambd[x_2][\ldots\lambd[x_n][\Subst{N}{M_1}{x_1}]]) M_2 \dots M_n \\ \vdots & \\ - \bredone {} &\Subst{\Subst{P}{M_1}{x_1}\ldots}{M_n}{x_n} + \bredone {} &\Subst{\Subst{N}{M_1}{x_1}\ldots}{M_n}{x_n} \end{aligned} \end{multline*} The last line literally means substituting $M_i$ for $x_i$ in the body diff --git a/content/lambda-calculus/introduction/fixed-point-combinator.tex b/content/lambda-calculus/introduction/fixed-point-combinator.tex index dff80dcf..65f9ebfe 100644 --- a/content/lambda-calculus/introduction/fixed-point-combinator.tex +++ b/content/lambda-calculus/introduction/fixed-point-combinator.tex @@ -10,7 +10,8 @@ \olsection{Fixed-Point Combinators} Suppose you have a lambda term $g$, and you want another term $k$ with -the property that $k$ is $\beta$-equivalent to $gk$. Define terms +the property that $k$ is $\beta$-equivalent to $gk$. Choose $x$ not free in +$g$, and define terms \[ \fn{diag}(x) = xx \] diff --git a/content/lambda-calculus/introduction/lambda-definability.tex b/content/lambda-calculus/introduction/lambda-definability.tex index da245a8d..3eff8fdf 100644 --- a/content/lambda-calculus/introduction/lambda-definability.tex +++ b/content/lambda-calculus/introduction/lambda-definability.tex @@ -18,7 +18,7 @@ \begin{defn} For each natural number~$n$, define the \emph{Church numeral} $\num{n}$ to be the lambda term $\lambd[x][\lambd[y][(x(x(x(\dots -x(y)))))]]$, where there are $n$ $x$'s in all. +x(y)))))]]$, where the body contains $n$ occurrences of $x$. \end{defn} The terms $\num{n}$ are ``iterators'': on input $f$, $\num{n}$ returns @@ -27,7 +27,7 @@ a function on the natural numbers. \begin{defn} -Let $f(x_0, \dots, x_{k-1})$ be an $n$-ary partial function from $\Nat$ +Let $f(x_0, \dots, x_{k-1})$ be a $k$-ary partial function from $\Nat^k$ to $\Nat$. We say a $\lambd$-term~$F$ \emph{!!{lambda define}s}~$f$ iff for every sequence of natural numbers $n_0$, \dots,~$n_{k-1}$, \[ diff --git a/content/lambda-calculus/introduction/minimization.tex b/content/lambda-calculus/introduction/minimization.tex index e3651e71..2a4b7601 100644 --- a/content/lambda-calculus/introduction/minimization.tex +++ b/content/lambda-calculus/introduction/minimization.tex @@ -18,6 +18,10 @@ \end{lem} \begin{proof} +First assume that $f$ is total; the arbitrary partial case is proved +at the end. Choose its representative closed, replacing any free +variables by closed terms; since every numeric input reduces to a +closed numeral, this preserves all required values. The idea is roughly as follows. Given $x$, we will use the fixed-point lambda term $Y$ to define a function $h_x(n)$ which searches for a~$y$ starting at~$n$; then $g(x)$ is just $h_x(0)$. The function~$h_x$ can @@ -30,18 +34,19 @@ \end{cases} \] -Here are the details. Since $f$ is primitive recursive, it is +Here are the details. By hypothesis, $f$ is !!{lambda defined} by some term $F$. Remember that we also have a lambda term~$D$, such that $D(M, N, \bar{0}) \red M$ and $D(M, N, \bar{1}) \red N$. Fixing $x$ for the moment, to !!{lambda define} $h_x$ we want to find a term~$H$ (depending on~$x$) satisfying \[ -H(\num{n}) \equiv D(\num{n}, H(S(\num{n})), F(x, \num{n})). +H(\num{n}) \equiv D(\num{n}, H(\fn{Succ}(\num{n})), F(x, \num{n})). \] -We can do this using the fixed-point term~$Y$. First, let $U$ be the +Use Turing's fixed-point term~$Y$ from \olref[fix]{sec}, so that +$YU\red U(YU)$. First, let $U$ be the term \[ -\lambd[h][\lambd[z][D(z,(h(Sz)),F(x,z))]], +\lambd[h][\lambd[z][D(z,(h(\fn{Succ}(z))),F(x,z))]], \] and then let $H$ be the term~$YU$. Notice that the only free variable in~$H$ is~$x$. Let us show that $H$ satisfies the equation above. @@ -53,17 +58,49 @@ In particular, for each natural number~$n$, we have \begin{align*} H(\num{n}) & \equiv U(H, \num{n}) \\ -& \red D(\num{n}, H(S(\num{n})), F(x, \num{n})), +& \red D(\num{n}, H(\fn{Succ}(\num{n})), F(x, \num{n})), \end{align*} as required. Notice that if you substitute a numeral $\num{m}$ for~$x$ in the last line, the expression reduces to $\num{n}$ if $F(\num{m}, -\num{n})$ reduces to $\num{0}$, and it reduces to $H(S(\num{n}))$ if +\num{n})$ reduces to $\num{0}$, and it reduces to $H(\fn{Succ}(\num{n}))$ if $F(\num{m}, \num{n})$ reduces to any other numeral. -To finish off the proof, let $G$ be $\lambd[x][H(\num 0)]$. Then $G$ -!!{lambda define}s~$g$; in other words, for every~$m$, $G(\num m)$ -reduces to~$\overline {g(m)}$, if $g(m)$ is defined, and has no normal -form otherwise. +To finish the total-input case, let $G$ be $\lambd[x][H(\num 0)]$. +If the search first succeeds at $n$, finitely many unfoldings give +$G(\num m)\red\num n$. If no candidate succeeds, leftmost-outermost +reduction continually evaluates the next test and returns to the +recursive call in head position. It never reaches a normal form. +Here we use the normalization theorem: leftmost-outermost reduction +reaches a $\beta$-normal form whenever one exists.\footnote{For a +proof, see Andrew D. Ker, \emph{Lambda Calculus and Types} (2009), +Theorem 3.2.3, pp.~35--36.} Thus an unsuccessful search has no normal +form. Merely exhibiting some infinite reduction sequence would not +suffice. + +We can now complete \olref[lrp]{thm:computable-lambda}, without using +closure under arbitrary partial composition. Let the total +primitive recursive $r$ and $u$ be as in its proof outline, and let +closed terms $R$ and $U_0$ represent them. With fresh variables, put +\[ + Q=\lambd[h][\lambd[n][\lambd[\vec x][ + D(U_0(n),h(\fn{Succ}(n),\vec x),R(\vec x,n))]]], + \qquad L=YQ. +\] +Then $\lambd[\vec x][L(\num 0,\vec x)]$ represents $f$. If the least +successful test is $n$, the search selects $U_0(\num n)$, which +reduces to the numeral for $u(n)$. If no test succeeds, the same +leftmost-outermost argument gives no normal form. The decoder is +inside the successful branch, so it cannot erase a failed search. + +Finally, for arbitrary partial lambda-definable component functions, +\olref[cmp]{thm:lambda-computable} makes them partial computable. +Strict composition computes every inner value before applying the +outer function; strict primitive recursion computes the base and +all earlier values; strict minimization tests candidates in order +and is undefined if a required test is undefined. These are partial +computable procedures, so the theorem just completed supplies +lambda representatives. This proves the general partial versions +of all three closure lemmas. \end{proof} \end{document} diff --git a/content/lambda-calculus/introduction/primitive-recursion.tex b/content/lambda-calculus/introduction/primitive-recursion.tex index 1aee7eca..e5aae62a 100644 --- a/content/lambda-calculus/introduction/primitive-recursion.tex +++ b/content/lambda-calculus/introduction/primitive-recursion.tex @@ -10,24 +10,24 @@ \olsection{\usetoken{S}{lambda definable} Functions are Closed under Primitive Recursion} When it comes to primitive recursion, we finally need to do some -work. We will have to proceed in stages. As before, on the assumption -that we already have terms $G$ and $H$ that !!{lambda define} functions -$g$ and~$h$, respectively, we want a term $H$ that !!{lambda define}s the +work. We first prove the direct construction for total component +functions; the general partial case follows at the end of +\olref[min]{sec}. We will proceed in stages. As before, on the assumption +that we already have terms $G'$ and $H'$ that !!{lambda define} functions +$g$ and~$h$, respectively, we want a term $F'$ that !!{lambda define}s the function~$f$ defined by \begin{align*} f(0, \vec z) & = g(\vec z) \\ -f(x+1, \vec z) & = h(z, f(x,\vec z), \vec z). +f(x+1, \vec z) & = h(x, f(x,\vec z), \vec z). \end{align*} -So, in general, given lambda terms $G'$ and~$H'$, it suffices to find -a term~$F$ such that +Given these lambda terms $G'$ and~$H'$, we seek a term~$F'$ such that \begin{align*} -F(\num{0}, \vec z) & \equiv G(\vec z) \\ -F(\overline{n+1}, \vec z) & \equiv H(\num{n}, F(\num{n}, \vec z), \vec z) +F'(\num{0}, \vec z) & \equiv G'(\vec z) \\ +F'(\overline{n+1}, \vec z) & \equiv H'(\num{n}, F'(\num{n}, \vec z), \vec z). \end{align*} -for every natural number~$n$; the fact that $G'$ and~$H'$ !!{lambda define} -$g$ and~$h$ means that whenever we plug in numerals $\num{\vec m}$ -for $\vec z$, $F(\num{n+1}, \num{\vec m})$ will normalize to the -right answer. +For total $g$ and $h$, induction on $n$ then shows that substituting +numerals $\num{\vec m}$ for $\vec z$ makes +$F'(\num{n},\num{\vec m})$ normalize to the right answer. But for this, it suffices to find a term~$F$ satisfying \begin{align*} @@ -35,9 +35,9 @@ F(\overline {n+1}) & \equiv H(\num{n},F(\num{n})) \intertext{for every natural number $n$, where} G & = \lambd[\vec z][G'(\vec z)] \text{ and}\\ -H(u,v) & = \lambd[\vec z][H'(u,v(u,\vec z),\vec z)]. +H(u,v) & = \lambd[\vec z][H'(u,v(\vec z),\vec z)]. \end{align*} -In other words, with lambda trickery, we can avoid having to worry +Set $F'(u,\vec z)=F(u)(\vec z)$. In other words, with lambda trickery, we can avoid having to worry about the extra parameters $\vec z$---they just get absorbed in the lambda notation. @@ -76,7 +76,11 @@ \end{lem} \begin{proof} -We need to show that given any terms, $G$ and $H$, we can find a term +For the total component functions under consideration, it suffices +to construct the following iterator. Its equations hold for any +terms $G$ and $H$, but by themselves do not enforce strict +undefinedness: a step that ignores its previous value can erase an +undefined base. We can find a term $F$ such that \begin{align*} F(\num{0}) & \equiv G \\ @@ -95,7 +99,7 @@ The details are as follows. Define $T(u)$ by \[ -T(u) = \tuple{S((u)_0), H((u)_0,(u)_1)}. +T(u) = \tuple{\fn{Succ}((u)_0), H((u)_0,(u)_1)}. \] Now it is easy to verify that for any number~$n$, \[ @@ -126,8 +130,8 @@ & \equiv (\tuple{\num{n+1}, H(\num{n}, F(\num{n}))})_1 \\ & \equiv H(\num{n}, F(\num{n})). \end{align*} -Here we have used the induction hypothesis on the second-to-last -line. For the first clause, we have +Here we have used the induction hypothesis in the transition to the +third line. For the first clause, we have \begin{align*} \num{n+1} (T, \tuple{\num 0, G}) & \equiv T(\num{n} (T, \tuple{\num 0, G})) \\ diff --git a/content/lambda-calculus/introduction/syntax.tex b/content/lambda-calculus/introduction/syntax.tex index 0fbb2bcb..563f6d91 100644 --- a/content/lambda-calculus/introduction/syntax.tex +++ b/content/lambda-calculus/introduction/syntax.tex @@ -61,8 +61,8 @@ $\lambd[y][y]$. It will be convenient to think of these as being the ``same'' term; in other words, when we say that $M$ and $N$ are the same, we also mean ``up to renamings of the bound variables.'' -Variables that are in the scope of a $\lambd$ are called ``bound'', -while others are called ``free.'' There are no free variables in the +A variable occurrence is called ``bound'' when it is in the scope of +an abstraction binding that same variable, and ``free'' otherwise. There are no free variables in the previous example; but in \[ (\lambd[z][yz])x From ae947a9995a4f405b7bd49076cb3d087289b1a7e Mon Sep 17 00:00:00 2001 From: KokunoYumeto <208192274+KokunoYumeto@users.noreply.github.com> Date: Mon, 30 Nov 2026 22:30:55 +0100 Subject: [PATCH 3/4] lambda-calculus/lambda-definability: corrections (18 places) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit arithmetical-functions.tex: - l. 29: The fully curried term contains the redex (num(n) f); its root is an application whose function is itself an application. Reaching f^n x requires contracting both leading abstractions, not one. - l. 72, 74, 80: These lines each combine multiple curried beta contractions. fixpoints.tex: - l. 24: The displayed pure lambda-term abbreviation uses bare 0 instead of the Church-zero term used in the arithmetic construction. - l. 55: The preceding argument establishes agreement on Church-numeral inputs, which does not imply beta-equivalence of arbitrary representing terms. The fixed-point construction later supplies a particular representative with the stronger property. - l. 89: With Y=UU, Yg=(UU)g has a redex UU as a proper subterm; it is not itself a root redex of the form (lambda x.M)N. - l. 96: The displayed expansion is g(Yg), g(g(Yg)), and so on. That is iteration/nesting around the fixed point, not repeated self-application gg. State the actual displayed operation without suggesting the wrong lambda application shape. - l. 148: Missing parentheses around the first abstraction change the scope of the intended application. - l. 158, 163: The exact displayed lambda term is standardly identified as Curry’s paradoxical combinator. Ker (2009), p. 11 §1.9 and Seldin (n.d.), p. 8 explicitly give the same term; the Church attribution is unsupported. introduction.tex: - l. 75: The displayed function name loses its subscript. This is an identifier typo, not a refutation of the constant-function construction. lists.tex: - l. 15: Without binder freshness, an open component containing s or z is captured; alpha-renaming after insertion cannot restore its free variable. minimization.tex: - l. 37: The subsequent displayed one-directional unfolding preserves Y Search literally at the recursive call and uses the stronger reducing-combinator property. - l. 37: The displayed Search functional calls its parameter g; recursive self-reference belongs to its fixed point Y Search. pairs.tex: - l. 15: Literal insertion can capture a free f in a component; the fresh-binder condition is not explicitly part of the abbreviation. partial-recursive-functions.tex: - l. 28: The example illustrates argument erasure but does not satisfy the numerical-function representation hypothesis: lambda y.y is not a Church numeral under the chapter beta-normal-form definition. primitive-recursive-functions.tex: - l. 126, 128: The lambda macro emits no enclosing parentheses; widest scope places those arguments inside the abstraction rather than applying the abstraction. Co-Authored-By: Claude Opus 5.5 --- .../arithmetical-functions.tex | 12 ++++----- .../lambda-definability/fixpoints.tex | 26 ++++++++++--------- .../lambda-definability/introduction.tex | 2 +- .../lambda-definability/lists.tex | 1 + .../lambda-definability/minimization.tex | 9 ++++--- .../lambda-definability/pairs.tex | 2 +- .../partial-recursive-functions.tex | 4 +-- .../primitive-recursive-functions.tex | 4 +-- 8 files changed, 32 insertions(+), 28 deletions(-) diff --git a/content/lambda-calculus/lambda-definability/arithmetical-functions.tex b/content/lambda-calculus/lambda-definability/arithmetical-functions.tex index c8e01618..61c3bbda 100644 --- a/content/lambda-calculus/lambda-definability/arithmetical-functions.tex +++ b/content/lambda-calculus/lambda-definability/arithmetical-functions.tex @@ -26,8 +26,8 @@ if the argument $a$ is a Church numeral, it reduces to one. Consider:} (\lambd[a][\lambd[fx][f ({a} f x)]])\,\num{n} & \redone \lambd[fx][f ({\num{n}} f x)]. - \intertext{The embedded term $\num{n}fx$ is a redex, since - $\num{n}$ is $\lambd[fx][f^nx]$. So $\num{n}fx \redone f^nx$ and + \intertext{The embedded term $\num{n}fx$ contains a redex, since + $\num{n}$ is $\lambd[fx][f^nx]$. Thus $\num{n}fx \red f^nx$ and so, for the entire term we have} \fn{Succ}\, \num n & \red \lambd[fx][f(f^n(x))], \end{align*} @@ -69,15 +69,15 @@ accepts $f$ and $x$ and returns $af(bfx)$. If $a$ and $b$ are Church numerals $\num{n}$ and $\num{m}$, this reduces to $f^{n+m}(x)$, which is identical to $f^{n}(f^{m}(x))$. Or, slowly:} - (\lambd[{a}{b}][\lambd[fx][{a} f ({b} f x)]])\num n\,\num m & \redone + (\lambd[{a}{b}][\lambd[fx][{a} f ({b} f x)]])\num n\,\num m & \red \lambd[fx][\num{n}\, f (\num {m}\, f x)] \\ - & \redone \lambd[fx][\num{n}\, f (f^m x)] \\ - & \redone \lambd[fx][f^n (f^m x)] \ident \num {n+m}. + & \red \lambd[fx][\num{n}\, f (f^m x)] \\ + & \red \lambd[fx][f^n (f^m x)] \ident \num {n+m}. \intertext{The second representation of addition $\fn{Add'}$ works differently: Applied to two Church numerals $\num{n}$ and $\num{m}$,} \fn{Add}' \num n \,\num m -& \redone \num{n}\, \fn{Succ}\, \num{m}. +& \red \num{n}\, \fn{Succ}\, \num{m}. \intertext{But $\num{n} f x$ always reduces to $f^n(x)$. So,} \num{n}\, \fn{Succ}\, \num{m} & \red \fn{Succ}^n(\num{m}). \end{align*} diff --git a/content/lambda-calculus/lambda-definability/fixpoints.tex b/content/lambda-calculus/lambda-definability/fixpoints.tex index da4852d1..c620a0c5 100644 --- a/content/lambda-calculus/lambda-definability/fixpoints.tex +++ b/content/lambda-calculus/lambda-definability/fixpoints.tex @@ -21,7 +21,7 @@ side. Such recursive definitions involving self-reference are not part of the lambda calculus. Defining a term, e.g., by \[ -\fn{Mult} \ident \lambd[ab][a (\fn{Add}\, b) 0] +\fn{Mult} \ident \lambd[ab][a (\fn{Add}\, b) \num{0}] \] only involves previously defined terms on the right-hand side, such as $\fn{Add}$. We can always remove $\fn{Add}$ by replacing it with its @@ -52,11 +52,13 @@ \] applied to the term $f$, i.e., $\fn{Fac}'\,f$, also represents the factorial function. That is, if we regard $\fn{Fac}'$ as a function -accepting a function and returning a function, the value of -$\fn{Fac'}\, f$ is just~$f$, provided $f$ is the factorial. A -function~$f$ with the property that $\fn{Fac}' \, f \equal[\beta] f$ is called -a \emph{fixpoint} of $\fn{Fac}'$. So, the factorial is a fixpoint of -$\fn{Fac}'$. +accepting a numerical-function representative and returning another +one, $\fn{Fac'}\,f$ agrees with $f$ on Church-numeral inputs whenever +$f$ represents factorial. This numerical agreement does not by itself +imply $\beta$-equivalence of the terms. A term~$f$ satisfying the +stronger equation $\fn{Fac}'\,f\equal[\beta]f$ is called a +\emph{fixpoint} of $\fn{Fac}'$. The construction below supplies such +a fixpoint and proves that it represents factorial. There are terms in the lambda calculus that compute the fixpoints of a given term, and these terms can then be used to turn a term like @@ -86,15 +88,15 @@ Yg$, so $Yg$ is a fixpoint of~$g$. \end{proof} -Of course, since $Yg$ is a redex, the reduction can continue indefinitely: +Of course, since $Yg$ contains a redex, the reduction can continue indefinitely: \begin{align*} Y g &\red g (Y g) \\ &\red g (g (Y g)) \\ &\red g(g (g (Y g)))\\ &\ldots \end{align*} -So we can think of $Yg$ as $g$ applied to itself infinitely many -times. If we apply~$g$ to it one additional time, we---so to +So we can think of $Yg$ as an indefinitely repeated nesting of +applications of~$g$. If we apply~$g$ to it one additional time, we---so to speak---aren't doing anything extra; $g$~applied to~$g$ applied infinitely many times to~$Yg$ is still $g$~applied to~$Yg$ infinitely many times. @@ -145,7 +147,7 @@ that} G\,x_1 \dots x_n & \equal[\beta] \Subst{N}{G}{g}. \intertext{For by the fixpoint theorem,} -G \ident (Y \lambd[g][\lambd[x_1\dots x_n][N]]) & \red \lambd[g][\lambd[x_1\dots x_n][N]](Y \lambd[g][\lambd[x_1\dots x_n][N]])\\ +G \ident (Y \lambd[g][\lambd[x_1\dots x_n][N]]) & \red (\lambd[g][\lambd[x_1\dots x_n][N]])(Y \lambd[g][\lambd[x_1\dots x_n][N]])\\ & \ident (\lambd[g][\lambd[x_1\dots x_n][N]])\,G \intertext{and consequently} G\,x_1 \dots x_n @@ -155,12 +157,12 @@ \end{align*} The $Y$ combinator of \olref{defn:Turing-Y} is due to Alan -Turing. Alonzo Church had proposed a different version which we'll +Turing. Curry's paradoxical combinator is a different version which we'll call~$Y_C$: \[ Y_C \ident \lambd[g][(\lambd[x][g(xx)])(\lambd[x][g(xx)])]. \] -Church's combinator is a bit weaker than Turing's in that $Y_C g +Curry's combinator is a bit weaker than Turing's in that $Y_C g \equal[\beta] g(Y_C g)$ but not $Y_C g \bred g(Y_C g)$. Let $V$ be the term $\lambd[x][g(xx)]$, so that $Y_C \ident \lambd[g][VV]$. Then \begin{align*} diff --git a/content/lambda-calculus/lambda-definability/introduction.tex b/content/lambda-calculus/lambda-definability/introduction.tex index 219b597a..a097f930 100644 --- a/content/lambda-calculus/lambda-definability/introduction.tex +++ b/content/lambda-calculus/lambda-definability/introduction.tex @@ -72,7 +72,7 @@ A very simple example are the constant functions. The term $C_k \ident \lambd[x][\num{k}]$ !!{lambda define}s the function $c_k\colon \Nat \to -\Nat$ such that $c(n) = k$. For $C_k \, \num n \ident +\Nat$ such that $c_k(n) = k$. For $C_k \, \num n \ident (\lambd[x][\num{k}])\num n \redone \num{k}$ for any~$n$. The identity function is !!{lambda defined} by $\lambd[x][x]$. More complex functions are of course harder to define, and often require a lot of diff --git a/content/lambda-calculus/lambda-definability/lists.tex b/content/lambda-calculus/lambda-definability/lists.tex index b153162a..5a47e86f 100644 --- a/content/lambda-calculus/lambda-definability/lists.tex +++ b/content/lambda-calculus/lambda-definability/lists.tex @@ -13,6 +13,7 @@ \[ [M_1, M_2, \ldots, M_n] \ident \lambd[sz][s M_1 (s M_2 (\ldots (s M_n z)))] \] +Choose distinct $s,z$ that are free in none of $M_1,\dots,M_n$. Informally speaking, the term representing a list is the ``accumulator'' function of the list: a function that accepts two terms; the first is a function that receives accumulated value along diff --git a/content/lambda-calculus/lambda-definability/minimization.tex b/content/lambda-calculus/lambda-definability/minimization.tex index 7093464a..5ca0b196 100644 --- a/content/lambda-calculus/lambda-definability/minimization.tex +++ b/content/lambda-calculus/lambda-definability/minimization.tex @@ -34,10 +34,11 @@ \fn{IsZero} (f\, \vec{x}\, y)\, y\, (g\, f\, \vec{x} (\fn{Succ}\, y)]]]\\ H & \ident \lambd[\vec x][(Y \, \fn{Search}) F\, \vec{x}\, \num{0}], \end{align*} - where $Y$ is any fixpoint combinator. Informally speaking, - $\fn{Search}$ is a self-referencing function: starting with~$y$, - test whether $f\, \vec x\, y$ is zero: if so, return~$y$, otherwise call - itself with $\fn{Succ}\, y$. Thus $(Y \, \fn{Search}) F + where $Y$ is the Turing fixpoint combinator of \olref[fp]{defn:Turing-Y}. Informally speaking, + $\fn{Search}$ describes one search step: starting with~$y$, + test whether $f\,\vec x\,y$ is zero; if so, return~$y$, otherwise + call its parameter $g$ with $f$, $\vec x$, and $\fn{Succ}\,y$. + The fixed point $Y\,\fn{Search}$ supplies the recursive search. Thus $(Y \, \fn{Search}) F \num{n_1}\dots\num{n_k}\,\num{0}$ returns the least~$m$ for which $f(n_1, \dots, n_k, m) = 0$. diff --git a/content/lambda-calculus/lambda-definability/pairs.tex b/content/lambda-calculus/lambda-definability/pairs.tex index 54317d9f..cdddb25a 100644 --- a/content/lambda-calculus/lambda-definability/pairs.tex +++ b/content/lambda-calculus/lambda-definability/pairs.tex @@ -12,7 +12,7 @@ \begin{defn} The pair of $M$ and $N$ (written $\tuple{M,N}$) is defined as follows: \[ -\tuple{M,N} \ident \lambd[f][fMN]. +\tuple{M,N} \ident \lambd[f][fMN],\qquad f\notin\FV{M}\cup\FV{N}. \] \end{defn} diff --git a/content/lambda-calculus/lambda-definability/partial-recursive-functions.tex b/content/lambda-calculus/lambda-definability/partial-recursive-functions.tex index d6422a27..a600e4c4 100644 --- a/content/lambda-calculus/lambda-definability/partial-recursive-functions.tex +++ b/content/lambda-calculus/lambda-definability/partial-recursive-functions.tex @@ -25,8 +25,8 @@ functions are partial, this is problematic. When $g(x)$ is undefined, meaning $G x$ has no normal form. In most cases this means that $F (G x)$ has no normal forms either, which is what we want. But consider -when $F$ is $\lambd[x][\lambd[y][y]]$, in which case $F (G x)$ does -have a normal form ($\lambd[y][y]$). +when $F$ is $\lambd[x][\num{0}]$, in which case $F (G x)$ does +have the normal form $\num{0}$. This problem is not insurmountable, and there are ways to !!{lambda define} all partial recursive functions in such a way that diff --git a/content/lambda-calculus/lambda-definability/primitive-recursive-functions.tex b/content/lambda-calculus/lambda-definability/primitive-recursive-functions.tex index 0fd5bed1..00484a10 100644 --- a/content/lambda-calculus/lambda-definability/primitive-recursive-functions.tex +++ b/content/lambda-calculus/lambda-definability/primitive-recursive-functions.tex @@ -123,9 +123,9 @@ Finally, consider \begin{align*} - H\,\num n\,\num m &\ident \lambd[x][\lambd[y][\fn{Snd} (y + H\,\num n\,\num m &\ident (\lambd[x][\lambd[y][\fn{Snd} (y (\lambd[p].\tuple{\fn{Succ} (\fn{Fst}\, p), (G\, x\, - (\fn{Fst}\, p)\, (\fn{Snd}\, p))}) \tuple{\num{0}, F x})]]\\ + (\fn{Fst}\, p)\, (\fn{Snd}\, p))}) \tuple{\num{0}, F x})]])\\ & \qquad\,\num n\, \num m\\ & \red \fn{Snd} (\num m \, \underbrace{(\lambd[p].\tuple{\fn{Succ} (\fn{Fst}\, p), (G \,\num n\, From 2a18ac0eb327bd6c421c467d3906d44f4a630a49 Mon Sep 17 00:00:00 2001 From: KokunoYumeto <208192274+KokunoYumeto@users.noreply.github.com> Date: Mon, 30 Nov 2026 22:30:55 +0100 Subject: [PATCH 4/4] lambda-calculus/syntax: corrections (17 places) alpha.tex: - l. 19: The first definition permits a vacuous self-step (lambda x.z renamed x to x), whereas the later supposedly equivalent inductive definition requires different names. - l. 78: This paraphrase omits reflexivity, which is included in both formal definitions. - l. 161: The cleared variable is x, not the replacement variable y. For N=x the substitution is y, which has y free. - l. 233: Outer freshness alone does not ensure the nested body substitution is defined. - l. 233: The first displayed substitution already ends with an equals sign and the continuation begins with another equals sign, producing a duplicated relation before the first right-hand term. - l. 273: The second pair needs Rdoubleprime alpha R, and definedness must concern its own substitution. conversion.tex: - l. 18: The English file ends with a promise of a definition and supplies no following content. de-bruijn.tex: - l. 49: The recursive context may repeat a variable under nested binders; the lookup must choose its first occurrence to express nearest binding. eta.tex: - l. 15: The macro prints an unparenthesized abstraction: widest scope places N inside the body, contrary to the intended application. - l. 42: The full extensionality theorem uses the general capture-safe eta schema. An unrestricted schema when x is free in M is invalid. free-variables.tex: - l. 24: The scope is the occurrence of the body M, not the containing whole term N. substitution.tex: - l. 76: The abstraction case uses the body P, not an unrelated Q. - l. 105: The substituted variable changes from y to x between premise and expansion. - l. 105: The quantifier both applies to the two substitution operations and requires the plural noun. This is independent of the earlier drop/drops agreement typo, now retained alone in CHK 0262. - l. 112: The theorem hypothesis in this case is x in FV(lambda y.P). - l. 119, 122: The induction-hypothesis expression removes the wrong variables, loses the outer removal of y, and has unbalanced parentheses; the next annotation claims x notin FV(N), which is not assumed. term-revisited.tex: - l. 24: The ordinary prose abbreviation etc. is typeset as mathematical letters instead of text. - l. 51: The displayed right side is a representative term, whereas the operation on classes must return its alpha-equivalence class. Co-Authored-By: Claude Opus 5.5 --- content/lambda-calculus/syntax/alpha.tex | 71 +++++++++---------- content/lambda-calculus/syntax/conversion.tex | 5 +- content/lambda-calculus/syntax/de-bruijn.tex | 2 +- content/lambda-calculus/syntax/eta.tex | 4 +- .../lambda-calculus/syntax/free-variables.tex | 2 +- .../lambda-calculus/syntax/substitution.tex | 14 ++-- .../lambda-calculus/syntax/term-revisited.tex | 7 +- 7 files changed, 54 insertions(+), 51 deletions(-) diff --git a/content/lambda-calculus/syntax/alpha.tex b/content/lambda-calculus/syntax/alpha.tex index 7deabbc6..0e71071e 100644 --- a/content/lambda-calculus/syntax/alpha.tex +++ b/content/lambda-calculus/syntax/alpha.tex @@ -16,7 +16,7 @@ variable in the other. This is called \emph{$\alpha$-conversion}. \begin{defn}[Change of bound variable, $\aconvone$] - If a term $M$ contains an occurrence of $\lambd[x][N]$, $y \notin + If a term $M$ contains an occurrence of $\lambd[x][N]$, $x\ne y$, $y \notin \FV{N}$, and $\Subst{N}{y}{x}$ is defined, then replacing this occurrence by \begin{equation*} @@ -75,7 +75,7 @@ \end{defn} As above, ``smallest'' means the relation only contains pairs required -by transitivity, and $\aconvone$, which leads to the following +by reflexivity, transitivity, and $\aconvone$, which leads to the following equivalent definition: \begin{defn}[$\alpha$-conversion, $\aconv$] \ollabel{defn:aconv} @@ -158,7 +158,7 @@ \item If the last rule is \olref{defn:aconvone4}, then $P$ is of the form $\lambd[x][N]$ and $Q$ of the form $\lambd[y][\Subst{N}{y}{x}]$, where $x \neq y$, $y \notin \FV{N}$ - and $\Subst{N}{y}{x}$ defined. First, we have $y \notin + and $\Subst{N}{y}{x}$ defined. First, we have $x \notin \FV{\Subst{N}{y}{x}}$ by \olref[sub]{thm:clr}. By \olref[sub]{thm:inv} we have that $\Subst{\Subst{N}{y}{x}}{x}{y}$ is not only defined, but also equal to~$N$. Then by @@ -230,37 +230,36 @@ \end{thm} \begin{proof} - By induction on the formation of $M$: - \begin{enumerate} - \item $M$ is a variable~$z$: Exercise. - \item Suppose $M$ is of the form $\lambd[x][N]$. Select a variable - $z$ other than $x$ and $y$ and such that $z \notin \FV{N}$ and $z - \notin \FV{R}$. By inductive hypothesis, we there is $N'$ such - that $N' \aeq N$ and $\Subst{N'}{z}{x}$ is defined. Then - $\lambd[x][N] \aeq \lambd[x][N']$ too, by - \olref{defn:aconvone}\olref{defn:aconvone1}. Now $\lambd[x][N'] - \aeq \lambd[z][\Subst{N'}{z}{x}]$ by - \olref{defn:aconvone}\olref{defn:aconvone4}. We can do this - because $z \ne x$, $z \notin FV(N')$ and $\Subst{N'}{z}{x}$ is - defined. Finally, $\Subst{\lambd[z][\Subst{N'}{z}{x}]}{R}{y}$ is - defined, because $z \neq y$ and $z \notin FV(R)$. - - Moreover, if there is another $N''$ and $R''$ satisfying the same - conditions, - \begin{multline*} - \Subst{(\lambd[z][\Subst{N''}{z}{x}])}{R''}{y} =\\ - \begin{aligned} - &= \lambd[z][\Subst{\Subst{N''}{z}{x}}{R''}{y}] \\ - &= \lambd[z][\Subst{\Subst{N''}{z}{x}}{R}{y}] && \text{by - \olref{lem:sub:R}}\\ - &=\lambd[z][\Subst{\Subst{N'}{z}{x}}{R}{y}] - && \text{by inductive - hypothesis}\\ - &=\Subst{(\lambd[z][\Subst{N'}{z}{x}])}{R}{y} - \end{aligned} - \end{multline*} - \item $M$ is of the form $(PQ)$: Exercise. - \end{enumerate} +Represent a term by its binding tree: application and abstraction +nodes retain their positions; each variable leaf is labelled either +by its free variable name or by a pointer to the nearest abstraction +that binds it. Each allowed change of bound variable preserves this +tree, as follows directly from its freshness and definedness +conditions. + +Conversely, terms with the same binding tree are $\alpha$-equivalent. +For all their abstraction positions choose pairwise distinct fresh +names, avoiding every name in either original term. In each term +rename the binders from innermost to outermost, using the same fresh +name at corresponding positions. Each change is allowed: inner +binders already have distinct fresh names, so the required partial +substitution is defined, and the new name occurs nowhere in the +body. The resulting terms are literally identical. Reversibility +and transitivity of $\alpha$-conversion give the claim. + +For existence, apply this freshening procedure to $M$, also avoiding +$y$ and all names in $R$. Every binder of the resulting $M'$ differs +from $y$ and is absent from $\FV{R}$. Induction on $M'$ using the +substitution clauses now gives that $\Subst{M'}{R}{y}$ is defined. + +For uniqueness, defined substitution replaces exactly the free-$y$ +leaves of a binding tree by copies of the replacement's binding +tree. Internal binding pointers remain internal, and the +definedness conditions prevent capture of free replacement names. +If $M''\aeq M$ and $R''\aeq R$, their respective binding trees agree. +Thus the two defined substitutions in the theorem have the same +binding tree. The converse characterization just proved gives +$\Subst{M'}{R}{y}\aeq\Subst{M''}{R''}{y}$. \end{proof} \begin{prob} @@ -270,8 +269,8 @@ \begin{cor}\ollabel{cor:sub} For any $M$, $R$, and~$y$, there exists a pair of $M'$ and $R'$ such that $M' \aeq M$, $R \aeq R'$ and $\Subst{M'}{R'}{y}$ is - defined. Moreover, if there is another pair $M'' \aeq M$ and $R''$ - with $\Subst{M'}{R'}{y}$ defined, then $\Subst{M'}{R'}{y} \aeq + defined. Moreover, if there is another pair $M'' \aeq M$ and $R''\aeq R$ + with $\Subst{M''}{R''}{y}$ defined, then $\Subst{M'}{R'}{y} \aeq \Subst{M''}{R''}{y}$. \end{cor} diff --git a/content/lambda-calculus/syntax/conversion.tex b/content/lambda-calculus/syntax/conversion.tex index 88201c36..0d463ac2 100644 --- a/content/lambda-calculus/syntax/conversion.tex +++ b/content/lambda-calculus/syntax/conversion.tex @@ -15,7 +15,10 @@ The $\alpha$-conversion is about variable renaming. It is natural to consider $\lambda x. x$ and $\lambda y.y$ representing the same -function (the identity function), we formallize this idea as follows: +function (the identity function). This is formalized by changes of +bound variable in \olref[syn][alp]{sec}. The other two notions, +$\beta$- and $\eta$-reduction, are defined in \olref[bet]{sec} and +\olref[syn][eta]{sec}, respectively. \end{document} diff --git a/content/lambda-calculus/syntax/de-bruijn.tex b/content/lambda-calculus/syntax/de-bruijn.tex index dd06656e..845590d5 100644 --- a/content/lambda-calculus/syntax/de-bruijn.tex +++ b/content/lambda-calculus/syntax/de-bruijn.tex @@ -46,7 +46,7 @@ F_\Gamma(\lambd[x][N]) &= \lambd[][F_{x,\Gamma}(N)] \end{align*} where $\Gamma$ is a list of variables indexed from zero, and - $\Gamma(x)$ denotes the position of the variable $x$ in $\Gamma$. + $\Gamma(x)$ denotes the position of the first occurrence of the variable $x$ in $\Gamma$. For example, if $\Gamma$ is $x,y,z$, then $\Gamma(x)$ is $0$ and $\Gamma(z)$ is $2$. diff --git a/content/lambda-calculus/syntax/eta.tex b/content/lambda-calculus/syntax/eta.tex index 5c6cc407..ecb4beee 100644 --- a/content/lambda-calculus/syntax/eta.tex +++ b/content/lambda-calculus/syntax/eta.tex @@ -12,7 +12,7 @@ There is another relation on $\lambda$ terms. In \olref[fv]{sec} we used the example $\lambd[x][(fx)]$, which accepts an argument and applies $f$ to it. In other words, it is the same function as~$f$: -$\lambd[x][(fx)]N$ and $fN$ both reduce to~$fN$. We use +$(\lambd[x][(fx)])N$ and $fN$ both reduce to~$fN$. We use $\eta$-reduction (and $\eta$-extension) to capture this idea. \begin{defn}[$\eta$-contraction, $\eredone$] @@ -39,7 +39,7 @@ \begin{defn} We extend the equivalence relation $\equal$ with the $\eta$-conversion rule: \[ - \lambd[x][f x] \equal f + \lambd[x][M x] \equal M \qquad\text{provided }x\notin\FV{M} \] and denote the extended relation as $\equal[\eta]$. \end{defn} diff --git a/content/lambda-calculus/syntax/free-variables.tex b/content/lambda-calculus/syntax/free-variables.tex index 166c3898..4f98f7a1 100644 --- a/content/lambda-calculus/syntax/free-variables.tex +++ b/content/lambda-calculus/syntax/free-variables.tex @@ -21,7 +21,7 @@ \begin{defn}[Scope] If $\lambd[x][M]$ occurs inside a term~$N$, then the corresponding -occurrence of~$N$ is the \emph{scope} of the~$\lambd[x]$. +occurrence of~$M$ is the \emph{scope} of the~$\lambd[x]$. \end{defn} diff --git a/content/lambda-calculus/syntax/substitution.tex b/content/lambda-calculus/syntax/substitution.tex index fc9f1fee..cd12d916 100644 --- a/content/lambda-calculus/syntax/substitution.tex +++ b/content/lambda-calculus/syntax/substitution.tex @@ -73,7 +73,7 @@ \item $M$ is of the form $\lambd[y][P]$, and since $\Subst{\lambd[y][P]}{N}{x}$ is defined, it has to be $\lambd[y][\Subst{P}{N}{x}]$. Then $\Subst{P}{N}{x}$ has to be - defined; also, $x \neq y$ and $x \notin \FV{Q}$. Then: + defined; also, $x \neq y$ and $x \notin \FV{P}$. Then: \begin{multline*} \FV{\Subst{\lambd[y][P]}{N}{x}} = \\ \begin{aligned} @@ -102,24 +102,24 @@ \begin{enumerate} \item $M$ is a variable: exercise. \item $M$ is of the form $PQ$: Since - $\Subst{(PQ)}{N}{y}$ is defined, it has to be - $(\Subst{P}{N}{x})(\Subst{Q}{N}{x})$ with both substitution + $\Subst{(PQ)}{N}{x}$ is defined, it has to be + $(\Subst{P}{N}{x})(\Subst{Q}{N}{x})$ with both substitutions defined. Also, since $x \in \FV{PQ}$, either $x \in \FV{P}$ or $x \in \FV{Q}$ or both. The rest is left as an exercise. \item $M$ is of the form $\lambd[y][P]$. Since $\Subst{\lambd[y][P]}{N}{x}$ is defined, it has to be $\lambd[y][\Subst{P}{N}{x}]$, with $\Subst{P}{N}{x}$ - defined, $x \neq y$ and $y \notin \FV{N}$; also, since $y \in - \FV{\lambd[x][P]}$, we have $y \in \FV{P}$ too. Now: + defined, $x \neq y$ and $y \notin \FV{N}$; also, since $x \in + \FV{\lambd[y][P]}$, we have $x \in \FV{P}$ too. Now: \begin{multline*} \FV{\Subst{(\lambd[y][P])}{N}{x}} = \\ \begin{aligned} & = \FV{\lambd[y][\Subst{P}{N}{x}]} \\ & = \FV{\Subst{P}{N}{x}} \setminus \{y\} \\ - & = ((\FV{P} \setminus \{y\}) \cup (\FV{N} \setminus \{x\}) + & = ((\FV{P} \setminus \{x\}) \cup \FV{N}) \setminus \{y\} && \text{by inductive hypothesis} \\ & = (\FV{P} \setminus \{x, y\}) \cup \FV{N} - && x \notin \FV{N} \\ + && y \notin \FV{N} \\ & = (\FV{\lambd[y][P]} \setminus \{x\}) \cup \FV{N} \end{aligned} \end{multline*} diff --git a/content/lambda-calculus/syntax/term-revisited.tex b/content/lambda-calculus/syntax/term-revisited.tex index b80c9368..ae82f6d1 100644 --- a/content/lambda-calculus/syntax/term-revisited.tex +++ b/content/lambda-calculus/syntax/term-revisited.tex @@ -21,7 +21,7 @@ what follows. Letters such as $x, y$ continues to denote a variable. We also adopt the notation $\rep{M}$ to denote an arbitrary -!!{element} of the class~$M$, and $\rep{M}[0], \rep{M}[1], etc. $ if +!!{element} of the class~$M$, and $\rep{M}[0]$, $\rep{M}[1]$, etc. if we need more than one. We reuse the notations from terms to simplify our wording. We @@ -48,8 +48,9 @@ We also reuse the notation for substition into classes: \begin{defn} \ollabel{def:sub} The \emph{substitution} of $R$ for $y$ in $M$, or $\Subst{M}{R}{y}$, is - defined to be $\Subst{\rep{M}}{\rep{R}}{y}$, for any $\rep{M}$ and - $\rep{R}$ making the substition defined. + defined to be the $\alpha$-equivalence class containing + $\Subst{\rep{M}}{\rep{R}}{y}$, for any $\rep{M}$ and + $\rep{R}$ making the substitution defined. \end{defn} This is also well defined as shown in \olref[alp]{cor:sub}.