X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=hints%2Fassignment_7_hint_5.mdwn;h=d44f824b05968d6de85e0cbc5b46ef97c77205b5;hb=23445a4f8be687dbd5be55eea7dcd7e6d2e7de05;hp=46ca442dfeba847526e8f6a5683ce51609aee528;hpb=458cadab1427b0fc0f7bc8689f1dddb18b2201e7;p=lambda.git diff --git a/hints/assignment_7_hint_5.mdwn b/hints/assignment_7_hint_5.mdwn index 46ca442d..d44f824b 100644 --- a/hints/assignment_7_hint_5.mdwn +++ b/hints/assignment_7_hint_5.mdwn @@ -1,49 +1,202 @@ - -* 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 `s` with \[[∃xPx]] as: - -
s >>= \[[∃x]] >>= \[[Px]]
+
+
+* How shall we handle \[[∃x]]? As we said, GS&V really tell us how to interpret \[[∃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 \[[∃xPx]] as:
+
+ u >>= \[[∃x]] >>= \[[Px]]
+ (Extra credit: how does the discussion on pp. 25-29 of GS&V bear on the possibility of this simplification?)
+
What does \[[∃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 ∃xPx. Possibilities in `s` in which no entity has the property P will be eliminated.
- We can defer that to a later step, where we do `... >>= \[[Px]]`.
+ We can defer that to a later step, where we do `... >>= \[[Px]]`. GS&V continue:
- > The referent system of the remaining possibilities will be extended with a new peg, which is associated with `x`. And for each old possibility `i` in `s`, there will be just as many extensions `i[x/d]` in the new state `s'` and there are entities `d` which in the possible world of `i` have the property P.
+ > The referent system of the remaining possibilities will be extended with a new peg, which is associated with `x`. And for each old possibility `i` in `s`, there will be just as many extensions `i[x/d]` in the new state `s'` as there are entities `d` which in the possible world of `i` have the property P.
- Deferring the "property P" part, this says:
+ Deferring the "property P" part, this corresponds to:
- s updated with \[[∃x]] ≡
- s >>= (fun (r, h) -> List.map (fun d -> newpeg_and_bind 'x' d) domain)
+ u updated with \[[∃x]] ≡
+ let extend one_dpm (d : entity) =
+ dpm_bind one_dpm (new_peg_and_assign 'x' d)
+ in set_bind u (fun one_dpm -> List.map (fun d -> extend one_dpm d) domain)
-
- That is, for each pair `(r, h)` in `s`, we collect the result of extending `(r, h)` by allocating a new peg for entity `d`, for each `d` in our whole domain of entities (here designated `domain`), and binding the variable `x` to the index of that peg.
- A later step can then filter out all the possibilities in which the entity `d` we did that with doesn't have property P.
+ where `new_peg_and_assign` is the operation we defined in [hint 3](/hints/assignment_7_hint_3):
+
+ let new_peg_and_assign (var_to_bind : char) (d : entity) : bool -> bool dpm =
+ fun truth_value ->
+ fun (r, h) ->
+ (* first we calculate an unused index *)
+ let new_index = List.length h
+ (* next we store d at h[new_index], which is at the very end of h *)
+ (* the following line achieves that in a simple but inefficient way *)
+ in let h' = List.append h [d]
+ (* next we assign 'x' to location new_index *)
+ in let r' = fun var ->
+ if var = var_to_bind then new_index else r var
+ (* we pass through the same truth_value that we started with *)
+ in (truth_value, r', h');;
+
+ What's going on in this proposed representation of \[[∃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 `(fun (r, h) -> ...)` above \[[∃x]], then `s` updated with \[[∃x]] updated with \[[Px]] is just:
+ If we call the function `(fun one_dom -> List.map ...)` defined above \[[∃x]], then `u` updated with \[[∃x]] updated with \[[Px]] is just:
- s >>= \[[∃x]] >>= \[[Px]]
+ u >>= \[[∃x]] >>= \[[Px]]
or, being explicit about which "bind" operation we're representing here with `>>=`, that is:
- bind_set (bind_set s \[[∃x]]) \[[Px]]
+ set_bind (set_bind u \[[∃x]]) \[[Px]]
-* In def 3.1 on p. 14, GS&V define `s` updated with \[[not φ]] as:
+* Let's compare this to what \[[∃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;;
+ type 'a reader = assignment -> 'a;;
+
+ let reader_unit (value : 'a) : 'a reader = fun r -> value;;
+
+ let reader_bind (u : 'a reader) (f : 'a -> 'b reader) : 'b reader =
+ fun r ->
+ let a = u r
+ in let u' = f a
+ in u' r;;
+
+ Here the type of a sentential clause is:
+
+ type clause = bool reader;;
+
+ Here are meanings for singular terms and predicates:
+
+ let getx : entity reader = fun r -> r 'x';;
+
+ type lifted_unary = entity reader -> bool reader;;
+
+ let lift (predicate : entity -> bool) : lifted_unary =
+ fun entity_reader ->
+ fun r ->
+ let obj = entity_reader r
+ in reader_unit (predicate obj)
+
+ The meaning of \[[Qx]] would then be:
+
+ \[[Q]] ≡ lift q
+ \[[x]] ≡ getx
+ \[[Qx]] ≡ \[[Q]] \[[x]] ≡
+ fun r ->
+ let obj = getx r
+ in reader_unit (q obj)
+
+
+ Recall also how we defined \[[lambda x]], or as [we called it before](/reader_monad_for_variable_binding), \\[[who(x)]]:
+
+ let shift (var_to_bind : char) (clause : clause) : lifted_unary =
+ fun entity_reader ->
+ fun r ->
+ let new_value = entity_reader r
+ (* remember here we're implementing assignments as functions rather than as lists of pairs *)
+ in let r' = fun var -> if var = var_to_bind then new_value else r var
+ in clause r'
+
+ Now, how would we implement quantifiers in this setting? I'll assume we have a function `exists` of type `(entity -> bool) -> bool`. That is, it accepts a predicate as argument and returns `true` if any element in the domain satisfies that predicate. We could implement the reader-monad version of that like this:
+
+ fun (lifted_predicate : lifted_unary) ->
+ fun r -> exists (fun (obj : entity) ->
+ lifted_predicate (reader_unit obj) r)
+
+ That would be the meaning of \[[∃]], which we'd use like this:
+
+ \[[∃]] ( \[[Q]] )
+
+
+ or this:
+
+ \[[∃]] ( \[[lambda x]] \[[Qx]] )
+
+
+ If we wanted to compose \[[∃]] with \[[lambda x]], we'd get:
+
+ let shift var_to_bind clause =
+ fun entity_reader r ->
+ let new_value = entity_reader r
+ in let r' = fun var -> if var = var_to_bind then new_value else r var
+ in clause r'
+ in let lifted_exists =
+ fun lifted_predicate ->
+ fun r -> exists (fun obj -> lifted_predicate (reader_unit obj) r)
+ in fun bool_reader -> lifted_exists (shift 'x' bool_reader)
+
+ which we can simplify to:
+
+
+
+ fun bool_reader ->
+ 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)
+
+ This gives us a value for \[[∃x]], which we use like this:
+
+ \[[∃x]] ( \[[Qx]] )
+
+
+ Contrast the way we use \[[∃x]] in GS&V's system. Here we don't have a function that takes \[[Qx]] as an argument. Instead we have a operation that gets bound in a discourse chain:
+
+ u >>= \[[∃x]] >>= \[[Qx]]
+
- > { i &elem; s | i does not subsist in s[φ] }
+ The crucial difference in GS&V's system is that the distinctive effect of the \[[∃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 \[[∃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:
- where `i` *subsists* in s[φ]
if there are any `i'` that *extend* `i` in s[φ]
.
+ > If ∃x (man x and ∃y y is wife of x) then (x kisses y).
- Here's how we can represent that:
+ See the discussion on pp. 24-5 of GS&V.
- bind_set s (fun (r, h) ->
- let u = unit_set (r, h)
- in let descendents = u >>= \[[φ]]
- in if descendents = empty_set then u else empty_set
-
+* Can you figure out how to handle \[[not φ]] 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.