XGitUrl: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=topics%2Fweek4_more_about_fixed_point_combinators.mdwn;h=3d4f50a45a3aab82a4ccfccf0e9dcb8af246edbe;hp=78ffc89d3f124d48a00bf9b66a5555224f84c77b;hb=78224e38c4180c85570589e3c9fabfe1fde5365e;hpb=6694165ac4d6edab602b3ad3651d0a5931b36a0e
diff git a/topics/week4_more_about_fixed_point_combinators.mdwn b/topics/week4_more_about_fixed_point_combinators.mdwn
index 78ffc89d..3d4f50a4 100644
 a/topics/week4_more_about_fixed_point_combinators.mdwn
+++ b/topics/week4_more_about_fixed_point_combinators.mdwn
@@ 60,15 +60,15 @@ Used in a context in which *this sentence meaning* refers to the meaning express
or `\m y n. m n y`, which is the `C` combinator. So in such a
context, (2) might denote
 Y C
 (\h. (\u. h (u u)) (\u. h (u u))) C
 (\u. C (u u)) (\u. C (u u)))
 C ((\u. C (u u)) (\u. C (u u)))
 C (C ((\u. C (u u)) (\u. C (u u))))
 C (C (C ((\u. C (u u)) (\u. C (u u)))))
+ Y C â¡
+ (\h. (\u. h (u u)) (\u. h (u u))) C ~~>
+ (\u. C (u u)) (\u. C (u u))) ~~>
+ C ((\u. C (u u)) (\u. C (u u))) ~~>
+ C (C ((\u. C (u u)) (\u. C (u u)))) ~~>
+ C (C (C ((\u. C (u u)) (\u. C (u u))))) ~~>
...
And infinite sequence of `C`s, each one negating the remainder of the
+An infinite sequence of `C`s, each one negating the remainder of the
sequence. Yep, that feels like a reasonable representation of the
liar paradox.
@@ 161,13 +161,13 @@ of `N`, by the reasoning in the previous answer.
A: Right:
 let Y = \N. (\u. N (u u)) (\u. N (u u)) in
 Y Y
 â¡ \N. (\u. N (u u)) (\u. N (u u)) Y
 ~~> (\u. Y (u u)) (\u. Y (u u))
 ~~> Y ((\u. Y (u u)) (\u. Y (u u)))
 ~~> Y ( Y ((\u. Y (u u)) (\u. Y (u u))))
 ~~> Y (Y (Y (...(Y (Y Y))...)))
+ let Y = \h. (\u. h (u u)) (\u. h (u u)) in
+ Y Y â¡
+ \h. (\u. h (u u)) (\u. h (u u)) Y ~~>
+ (\u. Y (u u)) (\u. Y (u u)) ~~>
+ Y ((\u. Y (u u)) (\u. Y (u u))) ~~>
+ Y ( Y ((\u. Y (u u)) (\u. Y (u u)))) <~~>
+ Y ( Y ( Y (...(Y (Y Y))...)))
@@ 176,8 +176,8 @@ A: Right:
A: Is that a question?
Let's come at it from the direction of arithmetic. Recall that we
claimed that even `succ`the function that added one to any
numberhad a fixed point. How could there be an `Î¾` such that `Î¾ <~~> succ Î¾`?
+claimed that even `succ`  the function that added one to any
+number  had a fixed point. How could there be an `Î¾` such that `Î¾ <~~> succ Î¾`?
That would imply that
Î¾ <~~> succ Î¾ <~~> succ (succ Î¾) <~~> succ (succ (succ Î¾)) <~~> succ (...(succ Î¾)...)
@@ 294,19 +294,101 @@ So for instance:
`A 1 x` is to `A 0 x` as addition is to the successor function;
`A 2 x` is to `A 1 x` as multiplication is to addition;
`A 3 x` is to `A 2 x` as exponentiation is to multiplication
+`A 3 x` is to `A 2 x` as exponentiation is to multiplication 
so `A 4 x` is to `A 3 x` as hyperexponentiation is to exponentiation...
## Q: What other questions should I be asking? ##
* What is it about the variant fixedpoint combinators that makes
 them compatible with a callbyvalue evaluation strategy?
+* What is it about the "primed" fixedpoint combinators `Îâ²` and `Yâ²` that
+ makes them compatible with a callbyvalue evaluation strategy?
+
+* What *exactly* is primitive recursion?
* How do you know that the Ackermann function can't be computed
using primitive recursion techniques?
* What *exactly* is primitive recursion?

* I hear that `Y` delivers the/a *least* fixed point. Least
according to what ordering? How do you know it's least?
Is leastness important?
+
+## Q: I still don't fully understand the Y combinator. Can you explain it in a different way?
+
+Sure! Here is another way to derive `Y`. We'll start by choosing a
+specific goal, and at each decision point, we'll make a reasonable
+guess. The guesses will all turn out to be lucky, and we'll arrive at
+a fixed point combinator.
+
+Given an arbitrary term `h`, we want to find a fixed point `X` such that:
+
+ X <~~> h X
+
+Our strategy will be to seek an `X` such that `X ~~> h X` (this is just a guess). Because `X` and
+`h X` are syntactically different, the only way that `X` can reduce to `h X` is if `X`
+contains at least one redex. The simplest way to satisfy this
+constraint would be for the fixed point to itself be a redex (again, just a guess):
+
+ X â¡ ((\u. M) N) ~~> h X
+
+The result of beta reduction on this redex will be `M` with some
+substitutions. We know that after these substitutions, `M` will have
+the form `h X`, since that is what the reduction arrow tells us. So we
+can refine the picture as follows:
+
+ X â¡ ((\u. h (___)) N) ~~> h X
+
+Here, the `___` has to be something that reduces to the fixed point `X`.
+It's natural to assume that there will be at least one occurrence of
+`u` in the body of the head abstract:
+
+ X â¡ ((\u. h (__u__)) N) ~~> h X
+
+After reduction of the redex, we're going to have
+
+ X â¡ h (__N__) ~~> h X
+
+Apparently, `__N__` will have to reduce to `X`. Therefore we should
+choose a skeleton for `N` that is consistent with what we have decided
+so far about the internal structure of `X`. We might like for `N` to
+syntactically match the whole of `X`, but this would require `N` to contain itself as
+a subpart. So we'll settle for the more modest assumption (or guess) that `N`
+matches the head of `X`:
+
+ X â¡ ((\u. h (__u__)) (\u. h (__u__))) ~~> h X
+
+At this point, we've derived a skeleton for X on which it contains two
+sofar identical halves. We'll guess that the halves will be exactly
+identical. Note that at the point at which we perform the first
+reduction, `u` will get bound to `N`, which now corresponds to a term
+representing one of the halves of `X`. So in order to produce a full `X`,
+we simply make a second copy of `u`:
+
+ X â¡ ((\u. h (u u)) (\u. h (u u)))
+ ~~> h ((\u. h (u u)) (\u. h (u u)))
+ â¡ h X
+
+Success.
+
+So the function `\h. (\u. h (u u)) (\u. h (u u))` maps an arbitrary term
+`h` to a fixed point for `h`.
+
+
+## Q: How does this relate to the discussion in Chapter 9 of The Little Schemer? ##
+
+A: Pages 160172 of *The Little Schemer* introduce you to how to implement recursion in Scheme, without relying on the native capacity to do this expressed in `letrec` or `define`. The expression:
+
+ (lambda (length)
+ (lambda (l)
+ (cond
+ ((null? l) 0)
+ (else (add1 (length (cdr l)))))))
+
+that occurs starting on p. 162 and on several pages following corresponds to `h` in [[our expositionweek4_fixed_point_combinators#littleh]]. The authors of *The Little Schemer* begin by applying that abstract to the argument `eternity`, which is a function that never returns; then they instead apply it to the argument `h eternity`, which is a function that works for lists of length zero, but otherwise never returns; then to the argument `h (h eternity)`, which works for lists of length zero or one, but otherwise never returns; and so on.
+
+They work their way towards the realization that they want an "infinite tower" of applications of `h`, except they don't really need an infinite tower, but rather just a finite tower whose height can't be bounded in advance. This is essentially the observation that they need a fixed point for `h`.
+
+The authors attempt to selfapply `h` on p. 165, just as we did. As we explained in [[our expositionweek4_fixed_point_combinators#derivingy]], though, that doesn't quite work.
+
+On the top of p. 167, the authors have instead moved to our `H`, and attempt to selfapply that, instead. And this works.
+
+However, on p. 168, they attempt to abstract out the part that in our `H` looks like `(u u)` and in their exposition looks like `(mklength mklength)`. Doing that *would* work in our lambda evaluator, but you can't do it in Scheme, because Scheme has callbyvalue evaluation order, which will try to fully reduce this expression before substituting it back into the term it's been abstracted out of. But it can't be fully reduced. Pages 168170 explore this problem, and pp. 170172 hit upon the solution of using what we called in our exposition the `Yâ²` fixedpoint combinator, rather than the `Y` combinator that we derived. The authors of *The Little Schemer* call `Yâ²` the "applicativeorder Y combinator".
+