
$textbf{Lecture Notes on the Lambda Calculus }$读书笔记。
看到第六章就看不下去了,先缓缓。未完成。
1.Introduction
- 1.1 Extensional vs. intensional view of functions:
- functions as graphs
- functions as formulas
- 1.2 The lambda calculus:
- One advantage of the lambda notation is that it allows us to easily talk about higher-order functions.
- 1.3 Untyped vs. typed lambda-calculi:
- Untyped lambdacalculus.
- Simply-typed lambda calculus.
- Polymorphically typed lambda calculus.
- 1.4 Lambda calculus and computability
- 1.5 Connections to computer science
- Many real-world programming languages can be regarded as extensions of the lambda calculus.
- 1.6 Connections to logic
- The connection between lambda calculus and constructive logics is via the “proofs-as-programs” paradigm.
2.The untyped lambda calculus
- 2.1 Syntax
- lambda terms: variables, applications, and lambda abstractions
- Backus-Naur Form:$$M,N ::= xmid (MN)mid (lambda x.M)$$
- 2.2 Free and bound variables, $alphatextit{-equivalence}$
- If $x, y$ are variables, and $M$ is a term, we write $M{y/x}$ for the result of renaming $x$ as $y$ in $M$.
- We define $alphatextit{-equivalence}$ to be the smallest congruence relation $=_{alpha}$ on lambda terms, such that for all terms $M$ and all variables $y$ that do not occur in $M$,$$lambda x.M =_{alpha} lambda y.(M{y/x}),ynotin FV(M)$$
- 2.3 Substitution
- We will write $M[N/x]$ for the result of replacing $x$ by $N$ in $M$.
- We should only replace free variables.
- 2.4 Introduction to $betatextit{-reduction}$
- We will often use the ordinary equality symbol $M = N$ to denote $alphatextit{-equivalence}$.
- The process of evaluating lambda terms by “plugging arguments into functions” is called $betatextit{-reduction}$.$$(lambda x.M)Nrightarrow_{beta}M[N/x]$$
- A lambda term without any β-redexes is said to be in $betatextit{-normal form}$.
- 2.5 Formal definitions of $betatextit{-reduction}$ and $betatextit{-equivalence}$
- $mathbf{Definition.}$ We write $Mtwoheadrightarrow_{beta} M’$ if $M$ reduces to $M’$ in zero or more steps. Formally, $twoheadrightarrow_{beta}$ is defined to be the reflexive transitive closure of $rightarrow_{beta}$.
- $mathbf{Definition.}$ We write $M =_{beta} M’$ if $M$ can be transformed into $M’$ by zero or more reduction steps and/or inverse reduction steps.Formally, $=_{beta}$ is defined to be the reflexive symmetric transitive closure of $rightarrow_{beta}$.
- 好好看一下Closure
3.Programming in the untyped lambda calculus
- 3.1 Booleans
- $$begin{split}&T=lambda xy.xcr &F=lambda xy.yend{split}$$
- 如果逻辑运算符“and”定义为:$lambda ab.abF$,则$$begin{split}&mathbf{and} TTtwoheadrightarrow_{beta}Tcr &mathbf{and} TFtwoheadrightarrow_{beta}Fcr &mathbf{and} FTtwoheadrightarrow_{beta}Fcr &mathbf{and} FFtwoheadrightarrow_{beta}Fcrend{split}$$
- 3.2 Natural numbers
- 3.3 Fixed points and recursive functions
- If $F$ and $N$ are lambda terms, we say that $N$ is a fixed point of $F$ if $FN =_{beta} N$
- $mathbf{Theorem 3.1}textit{ In the untyped lambda calculus, every term F has a fixed point.}$
- $mathbf{Proof}$. Let $A = lambda xy.y(xxy)$, and define $theta = AA$. Now suppose $F$ is any lambda term, and let $N = theta F$ . We claim that $N$ is a fixed point of $F$ . This is shown by the following calculation:$$begin{split}N&=theta Fcr
&=AAFcr
&=(lambda xy.y(xxy))AFcr
&rightarrow_{beta}F(AAF)cr
&=F(theta F)cr
&=FNend{split}$$ - The term $theta$ used in the proof is called Turing’s fixed point combinator.
- 3.4 Other data types: pairs, tuples, lists, trees, etc.
4.The Church-Rosser Theorem
- 4.1 Extensionality, $eta$-equivalence, and $eta$-reduction
- $etatextit{-reduction}$:$$lambda x.Mxrightarrow_{eta} M, textit{where} xnotin FV(M)$$
- Single-step $betaeta$-reduction $rightarrow_{betaeta}$ is defined as the union of the single-step $beta$- and $eta$-reductions
- 4.2 Statement of the Church-Rosser Theorem, and some con- sequences
- $mathbf{Theorem 4.2}$ (Church and Rosser, 1936):
Suppose $M$, $N$, and $P$ are lambda terms such that $M twoheadrightarrow N$ and $M twoheadrightarrow P$. Then there exists a lambda term $Z$ such that $N twoheadrightarrow Z$ and $P twoheadrightarrow Z$.
- $mathbf{Theorem 4.2}$ (Church and Rosser, 1936):
- 4.3 Preliminary remarks on the proof of the Church-Rosser Theorem
- 很有意思,帮助理解,但一些图太难画了。
- 4.4 Proof of the Church-Rosser Theorem
- We begin by defining a new relation $M rhd M’$ on terms, called $textit{parallel one-step reduction}$. We define $rhd$ to be the smallest relation satisfying:$$begin{split}&frac{}{xrhd x}cr
&frac{Prhd P’,Nrhd N’}{PNrhd P’N’}cr
&frac{Nrhd N’}{lambda x.Nrhdlambda x.N’}cr
&frac{Qrhd Q’,Nrhd N’}{(lambda x.Q)Nrhd Q’[N’/x]}cr
&frac{Prhd P’(xnotin FV(P))}{lambda x.Pxrhd P’}end{split}$$ - $mathbf{Lemma 4.6}$:
- (a) For all $M$, $M’$, if $Mrightarrow_{betaeta} M’$ then $M rhd M’$.
- (b) For all $M$, $M’$, if $Mrhd M’$ then $M twoheadrightarrow_{betaeta} M’$.
- (c) $twoheadrightarrow_{betaeta}$ is the reflexive transitive closure of $rhd$.
- $mathbf{Lemma 4.7}$ (Substitution).If $M rhd M’$ and $U rhd U’$, then $M[U/y] rhd M’[U’/y]$.
- $mathbf{Lemma 4.8}$ (Maximal parallel one-step reductions). Whenever $M rhd M’$, then $M’ rhd M^*$.
- $mathbf{Lemma 4.9}$ (Diamond property for $rhd$). If $M rhd N$ and $M rhd P$ , then there exists $Z$
such that $N rhd Z$ and $P rhd Z$. - $textit{Proof of Theorem 4.2}$: Since $rhd$ satisfies the diamond property, and its reflexive transitive closure $twoheadrightarrow_{betaeta}$ also satisfies the diamond property,and the diamond property for $twoheadrightarrow_{betaeta}$ is just the Church-Rosser property for $rightarrow_{betaeta}$.
- We begin by defining a new relation $M rhd M’$ on terms, called $textit{parallel one-step reduction}$. We define $rhd$ to be the smallest relation satisfying:$$begin{split}&frac{}{xrhd x}cr
5.Combinatory algebras
-
5.1 Applicative structures
- $mathbf{Definition.}$ Let $(A, ·)$ be an applicative structure. the set of polynomials is given by the following grammar:
$$t,s ::= x|a|ts$$
- $mathbf{Definition.}$ Let $(A, ·)$ be an applicative structure. the set of polynomials is given by the following grammar:
-
5.2 Combinatory completeness
- $mathbf{Definition}$ (Combinatory completeness). An applicative structure $(A, ·)$ is combinatorially complete if for every polynomial $t(x_1 , . . . , x_n )$ of $n geqslant 0$ variables, there exists some element $a in A$ such that
$$ax_1 …x_n = t(x_1,…,x_n)$$
holds in A. - $mathbf{Theorem 5.1.}$ An applicative structure $(A, ·)$ is $textit{combinatorially complete}$ if and only if there exist two elements $s, k in A$, such that the following equations are satisfied for all $x, y, z in A$:$$begin{split}&sxyz = (xz)(yz),cr &kxy = xend{split}$$
- 已经看得云里雾里了,不明白定义和定理的用意。
- $mathbf{Definition}$ (Combinatory completeness). An applicative structure $(A, ·)$ is combinatorially complete if for every polynomial $t(x_1 , . . . , x_n )$ of $n geqslant 0$ variables, there exists some element $a in A$ such that
-
5.3 Combinatory algebras
6.Simply-typed lambda calculus, propositional logic, and the Curry-Howard isomorphism
- 6.1 Simple types and simply-typed terms
- We usually use the Greek letter $iota$ to denote a basic type. The set of simple types is given by the following BNF:
$$textit{Simple types}: A,B::=iotamid Ato B mid A×B mid 1$$
- We usually use the Greek letter $iota$ to denote a basic type. The set of simple types is given by the following BNF:
- 6.2 Connections to propositional logic
- whether it is possible to find a closed term of the given type.
- This connection between simply-typed lambda calculus and propositional logic is known as the “Curry-Howard isomorphism”.
- The main difference between intuitionistic and classical logic is that the former misses the principles of “proof by contradiction” and “excluded middle”.
- Intuitionistic logic is also known as constructive logic. The disadvantage of constructive logic is that it is generally more difficult to prove things. The advantage is that once one has a proof, the proof can be transformed into an algorithm.
- 6.3 Propositional intuitionistic logic
- 6.11 Classical logic vs. intuitionistic logic




近期评论