X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=week8.mdwn;h=d3b5c1b7b283f1133ffd9c603210a5fc4627acc1;hp=4388e4407626df6f2452663fae7f82d4aeefe003;hb=d0a9dde6d449c9973b29704d7326ef978cba6da6;hpb=2f32f675472a4cef4f4d6bf47c8531946a717760 diff --git a/week8.mdwn b/week8.mdwn index 4388e440..d3b5c1b7 100644 --- a/week8.mdwn +++ b/week8.mdwn @@ -11,17 +11,14 @@ 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 assignment function threaded through the computation is limited to at -most one assignment. +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:
``` ; Analysis of "Everyone_i thinks he_i left"
@@ -39,23 +36,22 @@ 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
-discussions.
+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*.
+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.)

@@ -70,10 +66,10 @@ let shift (c : char) (v : int reader) (u : 'a reader) =
let lookup (c : char) : int reader = fun (e : env) -> List.assoc c e;;
```
```+    John believes Mary said he thinks she's cute.
+     |             |         |         |
+     |             |---------|---------|
+     |                       |
+     |-----------------------|
+```
+ +It will be convenient to +have a counterpart to the lift operation that combines a monadic +functor with a non-monadic argument: + +
```+    let g f v = ap (unit f) v;;
+    let g2 u a = ap u (unit a);;
+```
+ +As a first step, we'll bind "she" by "Mary": + +
```+believes (z said (g2 (g thinks (g cute she)) she) mary) john
+
+~~> believes (said (thinks (cute mary) he) mary) john
+```
+ +As usual, there is a trail of *g*'s leading from the pronoun up to the +*z*. Next, we build a trail from the other pronoun ("he") to its +binder ("John"). + +
```+believes
+  said
+    thinks (cute she) he
+    Mary
+  John
+
+believes
+  z said
+    (g2 ((g thinks) (g cute she))) he
+    Mary
+  John
+
+z believes
+  (g2 (g (z said)
+         (g (g2 ((g thinks) (g cute she)))
+            he))
+      Mary)
+  John
+```
+ +In the first interation, we build a chain of *g*'s and *g2*'s from the +pronoun to be bound ("she") out to the level of the first argument of +*said*. + +In the second iteration, we treat the entire structure as ordinary +functions and arguments, without "seeing" the monadic region. Once +again, we build a chain of *g*'s and *g2*'s from the currently +targeted pronoun ("he") out to the level of the first argument of +*believes*. (The new *g*'s and *g2*'s are the three leftmost). + +
```+z believes (g2 (g (z said) (g (g2 ((g thinks) (g cute she))) he)) mary) john
+
+~~> believes (said (thinks (cute mary) john) mary) john
+```
+ +Obviously, we can repeat this strategy for any configuration of pronouns +and binders. + +This binding strategy is strongly reminiscent of the translation from +the lambda calculus into Combinatory Logic that we studied earlier +(see the lecture notes for week 2). Recall that bound pronouns ended +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, 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.