(no commit message)
[lambda.git] / week8.mdwn
index cd99b42..e285451 100644 (file)
@@ -9,21 +9,16 @@ Semantics](http://www.springerlink.com/content/j706674r4w217jj5/))
 uses combinators to impose binding relationships between argument
 positions.  The system does not make use of assignment functions or
 variables.  We'll see that from the point of view of our discussion of
-monads, Jacobson's system is essentially a reader monad in which the
+monads, Jacobson's system is essentially a Reader monad in which the
 assignment function threaded through the computation is limited to at
-most one assignment.  More specifically, Jacobson's geach combinator
+most one variable.  It will turn out that Jacobson's geach combinator
 *g* is exactly our `lift` operator, and her binding combinator *z* is
 exactly our `bind` with the arguments reversed!
 
 Jacobson's system contains two main combinators, *g* and *z*.  She
-calls *g* the Geach rule, and *z* effects binding.  (There is a third
-combinator which following Curry and Steedman, I'll call *T*, which
-we'll make use of to adjust function/argument order to better match
-English word order; N.B., though, that Jacobson's name for this
-combinator is "lift", but it is different from the monadic lift
-discussed in some detail below.)  Here is a typical computation (based
-closely on email from Simon Charlow, with beta reduction as performed
-by the on-line evaluator):
+calls *g* the Geach rule, and *z* performs binding.  Here is a typical
+computation.  This implementation is based closely on email from Simon
+Charlow, with beta reduction as performed by the on-line evaluator:
 
 <pre>
 ; Analysis of "Everyone_i thinks he_i left"
@@ -41,25 +36,24 @@ Several things to notice: First, pronouns denote identity functions.
 As Jeremy Kuhn has pointed out, this is related to the fact that in
 the mapping from the lambda calculus into combinatory logic that we
 discussed earlier in the course, bound variables translated to I, the
-identity combinator.  This is a point we'll return to in later
-discussions.
+identity combinator (see additional comments below).  We'll return to
+the idea of pronouns as identity functions in later discussions.
 
 Second, *g* plays the role of transmitting a binding dependency for an
-embedded constituent to a containing constituent.  If the sentence had
-been *Everyone_i thinks Bill said he_i left*, there would be an
-occurrence of *g* in the most deeply embedded clause (*he left*), and
-another occurrence of *g* in the next most deeply
-embedded constituent (*said he left*), and so on (see below).
-
-Third, binding is accomplished by applying *z* not to the element that
-will (in some pre-theoretic sense) bind the pronoun, here, *everyone*,
-but by applying *z* instead to the predicate that will take *everyone*
-as an argument, here, *thinks*.  The basic recipe in Jacobson's system
-is that you transmit the dependence of a pronoun upwards through the
-tree using *g* until just before you are about to combine with the
-binder, when you finish off with *z*.  
-
-Last week we saw a reader monad for tracking variable assignments:
+embedded constituent to a containing constituent.
+
+Third, one of the peculiar aspects of Jacobson's system is that
+binding is accomplished not by applying *z* to the element that will
+(in some pre-theoretic sense) bind the pronoun, here, *everyone*, but
+rather by applying *z* instead to the predicate that will take
+*everyone* as an argument, here, *thinks*.  
+
+The basic recipe in Jacobson's system, then, is that you transmit the
+dependence of a pronoun upwards through the tree using *g* until just
+before you are about to combine with the binder, when you finish off
+with *z*.  (There are examples with longer chains of *g*'s below.)
+
+Last week we saw a Reader monad for tracking variable assignments:
 
 <pre>
 type env = (char * int) list;;
@@ -72,15 +66,15 @@ let shift (c : char) (v : int reader) (u : 'a reader) =
 let lookup (c : char) : int reader = fun (e : env) -> List.assoc c e;;
 </pre>
 
-(We've used a simplified term for the bind function in order to
+(We've used a simplified term for the bind function here in order to
 emphasize its similarities with Jacboson's geach combinator.)
 
-This monad boxed up a value along with an assignment function, where
+This monad boxes up a value along with an assignment function, where
 an assignemnt function was implemented as a list of `char * int`.  The
 idea is that a list like `[('a', 2); ('b',5)]` associates the variable
 `'a'` with the value 2, and the variable `'b'` with the value 5.
 
-Combining this reader monad with ideas from Jacobson's approach, we
+Combining this Reader monad with ideas from Jacobson's approach, we
 can consider the following monad:
 
 <pre>
@@ -95,7 +89,7 @@ let z (f: 'a -> e -> 'b) (u: 'a link) : e -> 'b = fun (x:e) -> f (u x) x;;
 </pre>
 
 I've called this the *link* monad, because it links (exactly one)
-pronoun with a binder, but it's a kind of reader monad.  (Prove that
+pronoun with a binder, but it's a kind of Reader monad.  (Prove that
 `ap`, the combinator for applying a linked functor to a linked object,
 can be equivalently defined in terms of `bind` and `unit`.)
 
@@ -104,18 +98,10 @@ kind of value that can be linked into a structure is an individual of
 type `e`.  It is easy to make the monad polymorphic in the type of the
 linked value, which will be necessary to handle, e.g., paycheck pronouns.
 
-Note that in addition to `unit` being Curry's K combinator, this `ap`
-is the S combinator.  Not coincidentally, recall that the rule for
-converting an arbitrary application `M N` into Combinatory Logic is `S
-[M] [N]`, where `[M]` is the CL translation of `M` and `[N]` is the CL
-translation of `N`.  There, as here, the job of `ap` is to take an
-argument and make it available for any pronouns (variables) in the two
-components of the application.
-
-In the standard reader monad, the environment is an assignment
+In the standard Reader monad, the environment is an assignment
 function.  Here, instead this monad provides a single value.  The idea
-is that this is the value that will replace the pronouns linked to it
-by the monad.
+is that this is the value that will be used to replace the pronoun
+linked to it by the monad.
 
 Jacobson's *g* combinator is exactly our `lift` operator: it takes a
 functor and lifts it into the monad.  Surely this is more than a coincidence.
@@ -136,7 +122,7 @@ link`, and returns a `'b link`, i.e., the result is in the link monad.
 order), but returns something that is not in the monad.  Rather, it
 will be a function from individuals to a computation in which the
 pronoun in question is bound to that individual.  We could emphasize
-the parallel with the reader monad even more by writing a `shift`
+the parallel with the Reader monad even more by writing a `shift`
 operator that used `unit` to produce a monadic result, if we wanted to.
 
 The monad version of *Everyone_i thinks he_i left*, then (remembering
@@ -154,16 +140,16 @@ everyone (z thinks (g (t bill) (g said (g left he))))
 
 So *g* is exactly `lift` (a combination of `bind` and `unit`), and *z*
 is exactly `bind` with the arguments reversed.  It appears that
-Jacobson's variable-free semantics is essentially a reader monad.
+Jacobson's variable-free semantics is essentially a Reader monad.
 
-One of Jacobson's main points survives: restricting the reader monad
+One of Jacobson's main points survives: restricting the Reader monad
 to a single-value environment eliminates the need for variable names.
 
 Binding more than one variable at a time
 ----------------------------------------
 
 It requires some cleverness to use the link monad to bind more than
-one variable at a time.  Whereas in the standard reader monad a single
+one variable at a time.  Whereas in the standard Reader monad a single
 environment can record any number of variable assignments, because
 Jacobson's monad only tracks a single dependency, binding more than
 one pronoun requires layering the monad.  (Jacobson provides some
@@ -248,6 +234,6 @@ the lambda calculus into Combinatory Logic that we studied earlier
 up translating to I, the identity combinator, just like Jacobson's
 identity functions for pronouns; abstracts (\a.M) whose body M did not
 contain any occurrences of the pronoun to be bound translated as KM,
-just like our unit, K; and abstracts of the form (\a.MN) translated to 
-S[\aM][\aN], just like our ap rule.
-
+just like our unit, which you will recognize as an instance of K; and
+abstracts of the form (\a.MN) translated to S[\aM][\aN], just like our
+ap rule.