* At the top of p. 13 (this is in between defs 2.8 and 2.9), GS&V give two examples, one for \[[∃xPx]] and the other for \[[Qx]]. In fact it will be most natural to break \[[∃xPx]] into two pieces, \[[∃x]] and \[[Px]]. But first we need to get clear on expressions like \[[Px]].
* GS&V say that the effect of updating an information state `s` with the meaning of "Qx" should be to eliminate possibilities in which the entity associated with the peg associated with the variable `x` does not have the property Q. In other words, if we let `Q` be a function from entities to `bool`s, `s` updated with \[[Qx]] should be `s` filtered by the function `fun (r, h) -> let obj = List.nth h (r 'x') in Q obj`. When `... Q obj` evaluates to `true`, that `(r, h)` pair is retained, else it is discarded.
OK, we face two questions then. First, how do we carry this over to our present framework, where we're working with sets of `dpm`s instead of sets of discourse possibilities? And second, how do we decompose the behavior here ascribed to \[[Qx]] into some meaning for "Q" and a different meaning for "x"?
* Answering the first question: we assume we've got some `bool dpm set` to start with. I won't call this `s` because that's what GS&V use for sets of discourse possibilities, and we don't want to confuse discourse possibilities with `dpm`s. Instead I'll call it `u`. Now what we want to do with `u` is to map each `dpm` it gives us to one that results in `(true, r, h)` only when the entity that `r` and `h` associate with variable `x` has the property Q. I'll assume we have some function Q to start with that maps entities to `bool`s.
Then what we want is something like this:
let eliminate_non_Qxs = (fun truth_value ->
fun (r, h) ->
let truth_value' =
if truth_value
then let obj = List.nth h (r 'x') in Q obj
else false
in (truth_value', r, h))
in bind_set u (fun one_dpm -> unit_set (bind_dpm one_dpm eliminate_non_Qxs))
The first seven lines here just perfom the operation we described: return a `bool dpm` computation that only yields `true` whether its input `(r, h)` associates variable `x` with the right sort of entity. The last line performs the `bind_set` operation. This works by taking each `dpm` in the set and returning a `unit_set` of a filtered `dpm`. The definition of `bind_set` takes care of collecting together all of the `unit_set`s that result for each different set element we started with.
We can call the `(fun one_dpm -> ...)` part \[[Qx]] and then updating `u` with \[[Qx]] will be:
bind_set u \[[Qx]]
or as it's written using Haskell's infix notation for bind:
u >>= \[[Qx]]
* Now our second question: how do we decompose the behavior here ascribed to \[[Qx]] into some meaning for "Q" and a different meaning for "x"?
Well, we already know that \[[x]] will be a kind of computation that takes an assignment function `r` and store `h` as input. It will look up the entity that those two together associate with the variable `x`. So we can treat \[[x]] as an `entity dpm`. We don't worry here about sets of `dpm`s; we'll leave that to our predicates to interface with. We'll just make \[[x]] be a single `entity dpm`. Then what we want is:
let getx = fun (r, h) ->
let obj = List.nth h (r 'x')
in (obj, r, h);;
* Now what do we do with predicates? As before, we suppose we have a function Q that maps entities to `bool`s. We want to turn it into a function that maps `entity dpm`s to `bool dpm`s. Eventually we'll need to operate not just on single `dpm`s but on sets of them, but first things first. We'll begin by lifting Q into a function that takes `entity dpm`s as arguments and returns `bool dpm`s:
fun entity_dpm -> bind_dpm entity_dpm (fun e -> unit_dpm (Q e))
Now we have to transform this into a function that again takes single `entity dpm`s as arguments, but now returns a `bool dpm set`. This is easily done with `unit_set`:
fun entity_dpm -> unit_set (bind_dpm entity_dpm (fun e -> unit_dpm (Q e)))
Finally, we realize that we're going to have a set of `bool dpm`s to start with, and we need to compose \[[Qx]] with them. We don't want any of the monadic values in the set that wrap `false` to become `true`; instead, we want to apply a filter that checks whether values that formerly wrapped `true` should still continue to do so.
This is most easily done like this:
fun entity_dpm ->
fun truth_value ->
if truth_value = false
then empty_set
else unit_set (bind dpm entity_dpm (fun e -> unit_dpm (Q e)))
Doing things this way will discard `bool dpm`s that start out wrapping `false`, and will pass through other `bool dpm`s that start out wrapping `true` but which our current filter transforms to a wrapped `false`. You might instead aim for consistency, and always pass through wrapped `false`s, whether they started out that way or are only now being generated; or instead always discard such, and only pass through wrapped `true`s. But what we have here will work fine too.
If we let that be \[[Q]], then \[[Q]] \[[x]] would be:
let getx = fun (r, h) ->
let obj = List.nth h (r 'x')
in (obj, r, h)
in let entity_dpm = getx
in fun truth_value ->
if truth_value = false
then empty_set
else unit_set (bind_dpm entity_dpm (fun e -> unit_dpm (Q e)))
or, simplifying:
let getx = fun (r, h) ->
let obj = List.nth h (r 'x')
in (obj, r, h)
in fun truth_value ->
if truth_value
then unit_set (bind_dpm getx (fun e -> unit_dpm (Q e)))
else empty_set
which is:
let getx = fun (r, h) ->
let obj = List.nth h (r 'x')
in (obj, r, h)
in fun truth_value ->
if truth_value
then unit_set (
fun (r, h) ->
let (a, r', h') = getx (r, h)
in let u' = (fun e -> unit_dpm (Q e)) a
in u' (r', h')
) else empty_set
which is:
in fun truth_value ->
if truth_value
then unit_set (
fun (r, h) ->
let obj = List.nth h (r 'x')
let (a, r', h') = (obj, r, h)
in let u' = (fun e -> unit_dpm (Q e)) a
in u' (r', h')
) else empty_set
which is:
in fun truth_value ->
if truth_value
then unit_set (
fun (r, h) ->
let obj = List.nth h (r 'x')
in let u' = unit_dpm (Q obj)
in u' (r', h')
) else empty_set
This is a bit different than the \[[Qx]] we had before:
let eliminate_non_Qxs = (fun truth_value ->
fun (r, h) ->
let truth_value' =
if truth_value
then let obj = List.nth h (r 'x') in Q obj
else false
in (truth_value', r, h))
in (fun one_dpm -> unit_set (bind_dpm one_dpm eliminate_non_Qxs))
because that one passed through every `bool dpm` that wrapped a `false`; whereas now we're discarding some of them. But these will work equally well. We can implement either behavior (or, as we said before, the behavior of never passing through a wrapped `false`).
* Reviewing: now we've determined how to define \[[Q]] and \[[x]] such that \[[Qx]] can be the result of applying the function \[[Q]] to the `entity dpm` \[[x]]. And \[[Qx]] in turn is now a function that takes a `bool dpm` as input and returns a `bool dpm set` as output. We compose this with a `bool dpm set` we already have on hand:
bind_set u \[[Qx]]
or:
`u >>=`_{set} \[[Qx]]

* Can you figure out how to handle \[[∃x]] on your own? If not, here are some [more hints](/hints/assignment_7_hint_5).