tweak whole site: caps for Reader monad, etc
[lambda.git] / hints / assignment_7_hint_5.mdwn
index 120c1fd..de1bbe6 100644 (file)
@@ -1,9 +1,22 @@
-
-*      How shall we handle \[[∃x]]? As we said, GS&V really tell us how to interpret \[[∃xPx]], but what they say about this breaks naturally into two pieces, such that we can represent the update of our starting set `u` with \[[∃xPx]] as:
+<!--
+I would like to propose one pedegogical suggestion (due to Ken), which
+is to separate peg addition from non-determinacy by explicitly adding
+a "Let" construction to GSV's logic, i.e., "Let of var * term *
+clause", whose interpretation adds a peg, assigns var to it, sets the
+value to the value computed by term, and evaluates the clause with the
+new peg in place.  This can be added easily, especially since you have
+supplied a procedure that handles the main essence of the
+construction.  Once the Let is in place, adding the existential is
+purely dealing with nondeterminism.
+-->
+
+*      How shall we handle \[[&exist;x]]? As we said, GS&V really tell us how to interpret \[[&exist;xPx]], but for our purposes, what they say about this can be broken naturally into two pieces, such that we represent the update of our starting set `u` with \[[&exist;xPx]] as:
 
        <pre><code>u >>= \[[&exist;x]] >>= \[[Px]]
        </code></pre>
 
+       (Extra credit: how does the discussion on pp. 25-29 of GS&V bear on the possibility of this simplification?)
+
        What does \[[&exist;x]] need to be here? Here's what they say, on the top of p. 13:
 
        >       Suppose an information state `s` is updated with the sentence &exist;xPx. Possibilities in `s` in which no entity has the property P will be eliminated.
@@ -15,9 +28,9 @@
        Deferring the "property P" part, this corresponds to:
 
        <pre><code>u updated with \[[&exist;x]] &equiv;
-               let extend_one : clause = fun one_dpm ->
-                       List.map (fun d -> bind_dpm one_dpm (new_peg_and_assign 'x' d)) domain
-               in bind_set u extend_one
+               let extend one_dpm (d : entity) =
+                       bind_dpm one_dpm (new_peg_and_assign 'x' d)
+               in bind_set u (fun one_dpm -> List.map (fun d -> extend one_dpm d) domain)
        </code></pre>
 
        where `new_peg_and_assign` is the operation we defined in [hint 3](/hints/assignment_7_hint_3):
                                        (* we pass through the same truth_value that we started with *)
                                        in (truth_value, r', h');;
        
-       What's going on in this representation of `u` updated with \[[&exist;x]]? For each `bool dpm` in `u`, we collect `dpm`s that are the result of passing through their `bool`, but extending their input `(r, h)` by allocating a new peg for entity `d`, for each `d` in our whole domain of entities, and binding the variable `x` to the index of that peg.
-
-       A later step can then filter out all the `dpm`s where the entity `d` we did that with doesn't have property P.
+       What's going on in this proposed representation of \[[&exist;x]]? For each `bool dpm` in `u`, we collect `dpm`s that are the result of passing through their `bool`, but extending their input `(r, h)` by allocating a new peg for entity `d`, for each `d` in our whole domain of entities, and binding the variable `x` to the index of that peg. A later step can then filter out all the `dpm`s where the entity `d` we did that with doesn't have property P. (Again, consult GS&V pp. 25-9 for extra credit.)
 
-       So if we just call the function `extend_one` defined above \[[&exist;x]], then `u` updated with \[[&exist;x]] updated with \[[Px]] is just:
+       If we call the function `(fun one_dom -> List.map ...)` defined above \[[&exist;x]], then `u` updated with \[[&exist;x]] updated with \[[Px]] is just:
 
        <pre><code>u >>= \[[&exist;x]] >>= \[[Px]]
        </code></pre>
@@ -50,7 +61,7 @@
        <pre><code>bind_set (bind_set u \[[&exist;x]]) \[[Px]]
        </code></pre>
 
-*      Let's compare this to what \[[&exist;xPx]] would look like on a non-dynamic semantics, for example, where we use a simple reader monad to implement variable binding. Reminding ourselves, we'd be working in a framework like this. (Here we implement environments or assignments as functions from variables to entities, instead of as lists of pairs of variables and entities. An assignment `r` here is what `fun c -> List.assoc c r` would have been in [week6](
+*      Let's compare this to what \[[&exist;xPx]] would look like on a non-dynamic semantics, for example, where we use a simple Reader monad to implement variable binding. Reminding ourselves, we'd be working in a framework like this. (Here we implement environments or assignments as functions from variables to entities, instead of as lists of pairs of variables and entities. An assignment `r` here is what `fun c -> List.assoc c r` would have been in [week7](
 /reader_monad_for_variable_binding).)
  
                type assignment = char -> entity;;
                        
        That would be the meaning of \[[&exist;]], which we'd use like this:
 
-       <pre><code>\[[&exist;]] \[[Q]]
+       <pre><code>\[[&exist;]] ( \[[Q]] )
        </code></pre>
 
        or this:
                                fun r -> exists (fun obj -> lifted_predicate (unit_reader obj) r)
                in fun bool_reader -> lifted_exists (shift 'x' bool_reader)
 
-       which we can simplify as:
+       which we can simplify to:
 
+       <!--
                let shifted clause =
                        fun entity_reader r ->
                                let new_value = entity_reader r
                                        in let r' = fun var -> if var = 'x' then new_value else r var
                                        in bool_reader r'
                        in fun r -> exists (shifted'' r)
+       -->
 
                fun bool_reader ->
-                       let shifted'' r new_value =
+                       let shifted r new_value =
                                        let r' = fun var -> if var = 'x' then new_value else r var
                                        in bool_reader r'
-                       in fun r -> exists (shifted'' r)
+                       in fun r -> exists (shifted r)
 
        This gives us a value for \[[&exist;x]], which we use like this:
 
        <pre><code>u >>= \[[&exist;x]] >>= \[[Qx]]
        </code></pre>
 
-       The crucial difference in GS&V's system is that the distinctive effect of the \[[&exist;x]]---to allocate new pegs in the store and associate variable `x` with the objects stored there---doesn't last only while interpreting clauses supplied as arguments to \[[&exist;x]]. Instead, it persists through the discourse, possibly affecting the interpretation of claims outside the logical scope of the quantifier. This is how we'll able to interpret claims like:
+       The crucial difference in GS&V's system is that the distinctive effect of the \[[&exist;x]]---to allocate new pegs in the store and associate variable `x` with the objects stored there---doesn't last only while interpreting some clauses supplied as arguments to \[[&exist;x]]. Instead, it persists through the discourse, possibly affecting the interpretation of claims outside the logical scope of the quantifier. This is how we'll able to interpret claims like:
 
        >       If &exist;x (man x and &exist;y y is wife of x) then (x kisses y).
 
+       See the discussion on pp. 24-5 of GS&V.
+
 
 *      Can you figure out how to handle \[[not &phi;]] and the other connectives? If not, here are some [more hints](/hints/assignment_7_hint_6). But try to get as far as you can on your own.