`→`

for one-step contraction,
@@ -7,10 +7,7 @@ zero-or-more step reduction. Hindley and Seldin use
`⊳`_{1}

and
`⊳`

.
-As we said in the main notes, when M and N are such that there's some P that M
-reduces to by zero or more steps, and that N also reduces to by zero or more
-steps, then we say that M and N are **beta-convertible**. We write that like
-this:
+As we said in the main notes, when `M` and `N` are such that there's some `P` that `M` reduces to by zero or more steps, and that `N` also reduces to by zero or more steps, then we say that `M` and `N` are **beta-convertible**. We write that like this:
M <~~> N
@@ -31,11 +28,11 @@ when discussing the metatheory. Instead we'll use `<~~>` as we said
above. When we want to introduce a stipulative definition, we'll write
it out longhand, as in:
-> T is defined to be `(M N)`.
+> `T` is defined to be `(M N)`.
or:
-> Let T be `(M N)`.
+> Let `T` be `(M N)`.
We'll regard the following two expressions:
@@ -92,7 +89,7 @@ what (c) reduces to. So if we took (b) to reduce to `\y. y y`, we'd wrongly be
counting (b) to be equivalent to (c), instead of (a).
To reduce (b), then, we need to be careful to that no free variables in what
-we're substituting in get captured by binding λs that they shouldn't be
+we're substituting in get "captured" by binding λs that they shouldn't be
captured by.
In practical terms, you'd just replace (b) with (a) and do the unproblematic substitution into (a).
@@ -147,7 +144,7 @@ furthermore lack any notion of a bound position.
## Review: syntactic equality, reduction, convertibility ##
-Define N to be `(\x. x y) z`. Then N and `(\x. x y) z` are syntactically equal,
+Define `N` to be `(\x. x y) z`. Then `N` and `(\x. x y) z` are syntactically equal,
and we're counting them as syntactically equal to `(\z. z y) z` as well. We'll express
all these claims in our metalanguage as:
@@ -158,16 +155,16 @@ This:
N ~~> z y
-means that N beta-reduces to `z y`. This:
+means that `N` beta-reduces to `z y`. This:
M <~~> N
-means that M and N are beta-convertible, that is, that there's something they both reduce to in zero or more steps.
+means that `M` and `N` are beta-convertible, that is, that there's something they both reduce to in zero or more steps.
The symbols `~~>` and `<~~>` aren't part of what we're calling "the Lambda
Calculus". In our mouths, they're just part of our metatheory for talking about it. In the uses of
the Lambda Calculus as a formal proof theory, one or the other of these
-symbols (or some notational variant of them) is added to the object language.
+symbols (or some notational variant of them) is added to the object language. But only in outermost contexts. It's like the "sequent" symbol (written `=>` or `⊢`

) in [Gentzen-style proof systems](https://en.wikipedia.org/wiki/Sequent_calculus) for logic. You can't embed the `~~>` or `<~~>` symbol inside lambda terms.
See Hankin Sections 2.2 and 2.4 for the proof theory using `<~~>` (which he
writes as `=`). He discusses the proof theory using `~~>` in his Chapter 3.
diff --git a/topics/week2_lambda_intro.mdwn b/topics/week2_lambda_intro.mdwn
index 486a75b4..091e1234 100644
--- a/topics/week2_lambda_intro.mdwn
+++ b/topics/week2_lambda_intro.mdwn
@@ -1,13 +1,12 @@
-## Syntax of Lambda Calculus ##
+# Introduction to the Lambda Calculus #
We often talk about "*the* Lambda Calculus", as if there were just
one; but in fact, there are many, many variations. The one we will
start with, and will explore in some detail, is often called "the pure"
-or "the untyped" Lambda Calculus. Actually, there are many variations even under
-that heading. But all of the variations share a strong family
+or "the untyped" Lambda Calculus. Actually, there are many variations even under that heading. But all of the variations share a strong family
resemblance, so what we learn now will apply to all of them.
-> Fussy note: calling this/these the "pure" lambda calculus is entrenched terminology,
+> Fussy note: calling this the "pure" Lambda Calculus is entrenched terminology,
but it coheres imperfectly with other uses of "pure" we'll encounter. There are
three respects in which the lambda calculus we'll be presenting might claim to
deserve the name "pure": (1) it has no pre-defined constants and a very spare
@@ -15,16 +14,12 @@ syntax; (2) it has no types; (3) it has no side-effects, and is insensitive to
the order of evaluation.
> Sense (3) corresponds most closely to the other uses of "pure" you'll
-see in the surrounding literature. With respect to this point, it may be true that
-this lambda calculus has no side effects. (Let's revisit that assumption
-at the end of term.) But as we'll see next week, it is *not* true that it's insensitive
-to the order of evaluation. So if that's what we mean by "pure", this lambda
-calculus isn't as pure as you might hope to get. Some *typed* lambda calculi will
-turn out to be more pure in that respect.
+see in the surrounding literature. With respect to this point, it may be true that the Lambda Calculus has no side effects. (Let's revisit that assumption
+at the end of term.) But as we'll see next week, it is *not* true that it's insensitive to the order of evaluation. So if that's what we mean by "pure", this lambda calculus isn't as pure as you might hope to get. Some *typed* lambda calculi will turn out to be more pure in that respect.
> But this lambda calculus is at least "pure" in sense (2). At least, it
-doesn't *explicitly talk about* any types. Some prefer to say that this
-lambda calculus *does* have types implicitly, it's just that
+doesn't *explicitly talk about* any types. Some prefer to say that the
+Lambda Calculus *does* have types implicitly, it's just that
there's only one type, so that every expression is a member of
that one type. If you say that, you have to say that functions from
this type to this type also belong to this type. Which is weird... In
@@ -41,13 +36,15 @@ as you might hope to get.
or "the untyped" Lambda Calculus, or even just "the" Lambda Calculus, this
is the system that people will understand you to be referring to.
+## Syntax ##
+
Here is its syntax:
--Each variable is an expression. For any expressions M and N and variable a, the following are also expressions: +Each variable is an expression. For any variable `a` and (possibly complex) expressions `M` and `N`, the following are also expressions:Variables:`x`

,`y`

,`z`

... +Variables:`x`

,`y`

,`z`

...

Abstract:`(λa M)`

@@ -66,13 +63,13 @@ Expressions in the lambda calculus are called "terms". Here is the syntax of the lambda calculus given in the form of a context-free grammar: - T --> Var - T --> ( lambda Var T) - T --> ( T T ) - Var --> x - Var --> y - Var --> z - ... +> T --> Var +> T --> ( λ Var T) +> T --> ( T T ) +> Var --> x +> Var --> y +> Var --> z +> ... Very, very simple. @@ -107,11 +104,11 @@ called the **argument**, and `M` is called the **body**. The rule of beta-reduction permits a transition from that expression to the following: - M [a <-- N] +>`M`

[`a`

<--`N`

] What this means is just `M`, with any *free occurrences* inside `M` of the variable `a` replaced with the term `N` (--- "without capture", which -we'll explain in the [[advanced notes|FIXME]]). +we'll explain in the [[advanced notes|week2_lambda_advanced]]). What is a free occurrence? @@ -160,7 +157,7 @@ say "reduction" for one or more reduction steps. So when we write: M ~~> N -we'll mean that you can get from M to N by one or more reduction +we'll mean that you can get from `M` to `N` by one or more reduction steps. When `M` and `N` are such that there is some common term (perhaps just one @@ -171,9 +168,7 @@ like this: M <~~> N More details about the notation and metatheory of -the lambda calculus here: - -* [[topics/week2_lambda_advanced]] +the lambda calculus are in [[this week's advanced notes|topics/week2_lambda_advanced]]. ## Shorthand ## @@ -204,7 +199,7 @@ and: **Dot notation** Dot means "assume a left paren here, and the matching right -paren as far the right as possible without creating unbalanced +paren as far to the right as possible without creating unbalanced parentheses". So: \x (\y (x y)) @@ -262,10 +257,10 @@ a unique result. The lambda calculus seems to be wonderfully well-suited for representing functions. In fact, the untyped -lambda calculus is Turing Complete (see [[!wikipedia Turing Completeness]]): +lambda calculus is Turing Complete (see [[!wikipedia Turing completeness]]): all (recursively computable) functions can be represented by lambda terms. Which, by most people's lights, means that all functions we can "effectively decide" --- -that is, compute in a mechanical way without requiring any ingenuity or insight --- +that is, always apply in a mechanical way without requiring any ingenuity or insight, and be guaranteed of a correct answer after some finite number of steps --- can be represented by lambda terms. As we'll see, though, it will be fun (that is, not straightforward) unpacking how these things can be so "represented." @@ -275,7 +270,7 @@ For some lambda terms, it is easy to see what function they represent: simply returns `M`: `((\x x) M) ~~> M`. > `(\x (x x))` duplicates its argument (applies it to itself): -`((\x (x x)) M) ~~> (M M)` +`((\x (x x)) M) ~~> (M M)` > `(\x (\y (y x)))` reorders its two arguments: `(((\x (\y (y x))) M) N) ~~> (N M)` @@ -306,7 +301,7 @@ and: (\z z) both represent the same function, the identity function. However, we said -(FIXME in the advanced notes) that we would be regarding these expressions as +[[in the advanced notes|week2_lambda_advanced]] that we would be regarding these expressions as synactically equivalent, so they aren't yet really examples of *distinct* lambda expressions representing a single function. However, all three of these are distinct lambda expressions: @@ -346,8 +341,7 @@ embodied in the lambda calculus. mathematical conception permits many *uncomputable* functions, but the lambda calculus can't express those. -2. More problematically, some lambda terms express "functions" that can take -themselves as arguments. If we wanted to represent that set-theoretically, and +2. More problematically, lambda terms express "functions" that can *take themselves* as arguments. If we wanted to represent that set-theoretically, and identified functions with their extensions, then we'd have to have some extension that contained (an ordered pair containing) itself as a member. Which we're not allowed to do in mainstream set-theory. But in the lambda calculus @@ -357,8 +351,9 @@ this is permitted and common --- and in fact will turn out to be indispensable. (\x x) (\x x) - This is a redex that reduces to the identity function (of course). We can -apply the **K** function to another argument and itself: + This is a redex that reduces to the identity function (of course). + + We can apply the **K** function to another argument and itself: >`@@ -376,7 +371,7 @@ In fact it *does* turn out to be possible to represent the Lambda Calculus set-theoretically. But not in the straightforward way that identifies functions with their graphs. For years, it wasn't known whether it would be possible to do this. But then [[!wikipedia Dana Scott]] figured out how to do it in late 1969, that is, -he formulated the first "denotational semantics" for this lambda calculus. +he formulated the first "denotational semantics" for this Lambda Calculus. Scott himself had expected that this wouldn't be possible to do. He argued for its unlikelihood in a paper he wrote only a month before the discovery. @@ -413,11 +408,15 @@ also count these functions: as equivalent. This additional move is called **eta-reduction**. It's crucial to eta-reduction that the outermost variable binding in the abstract we begin with (here, `\x`) be of a variable that occurs free -exactly once in the body of that abstract, and that it be in the -rightmost position. +exactly once in the body of that abstract, and that that free occurrence be the rightmost outermost constituent. + +The expression: -In the extended proof theory/theories we get be permitting eta-reduction/conversion -as well as beta-reduction, *all computable functions with the same + (\x (\y (y x)) + +can't be eta-reduced, because the rightmost outermost constituent is not `x` but `(\y (y x)`. + +In the extended proof theory/theories we get be permitting eta-reduction/conversion as well as beta-reduction, *all computable functions with the same extension do turn out to be equivalent*, that is, convertible. However, we still shouldn't assume we're working with functions @@ -437,7 +436,9 @@ evaluates to the ordered pair (2, 2). It may be helpful to think of a redex in the lambda calculus as a particular sort of `let` construction. - ((\x BODY) ARG) is analogous to + ((\x BODY) ARG) + +is analogous to let x match ARG in BODY @@ -461,7 +462,7 @@ calculus, an abstract such as `(\x (x x))` is perfectly well-formed and coherent, but it is not possible to write a `let` expression that does not have an `ARG`. That would be like: - `let x match` *missing* + `let x match` *missing* `in x x` Nevertheless, the correspondence is close enough that it can guide our`

KzK