assignment7 tweaks
[lambda.git] / hints / assignment_7_hint_5.mdwn
1
2 *       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:
3
4         <pre><code>u >>=<sub>set</sub> \[[&exist;x]] >>=<sub>set</sub> \[[Px]]
5         </code></pre>
6
7         What does \[[&exist;x]] need to be here? Here's what they say, on the top of p. 13:
8
9         >       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.
10
11         We can defer that to a later step, where we do `... >>= \[[Px]]`.
12  
13         >       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.
14
15         Deferring the "property P" part, this corresponds to:
16
17         <pre><code>u updated with \[[&exist;x]] &equiv;
18                 let extend_one = fun one_dpm ->
19                         fun truth_value ->
20                                 if truth_value = false
21                                 then empty_set
22                                 else List.map (fun d -> new_peg_and_assign 'x' d) domain
23                 in bind_set u extend_one
24         </code></pre>
25
26         where `new_peg_and_assign` is the operation we defined in [hint 3](/hints/assignment_7_hint_3):
27
28                 let new_peg_and_assign (var_to_bind : char) (d : entity) =
29                         fun ((r, h) : assignment * store) ->
30                                 (* first we calculate an unused index *)
31                                 let newindex = List.length h
32                                 (* next we store d at h[newindex], which is at the very end of h *)
33                                 (* the following line achieves that in a simple but inefficient way *)
34                                 in let h' = List.append h [d]
35                                 (* next we assign 'x' to location newindex *)
36                                 in let r' = fun v ->
37                                         if v = var_to_bind then newindex else r v
38                                 (* the reason for returning true as an initial element should now be apparent *)
39                                 in (true, r',h')
40         
41         What's going on in this representation of `u` updated with \[[&exist;x]]? For each `bool dpm` in `u` that wraps a `true`, we collect `dpm`s that are the result of 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. For `bool dpm`s in `u` that wrap `false`, we just discard them. We could if we wanted instead return `unit_set (unit_dpm false)`.
42
43         A later step can then filter out all the `dpm`s according to which the 
44 entity `d` we did that with doesn't have property P.
45
46         So if we just call the function `extend_one` defined above \[[&exist;x]], then `u` updated with \[[&exist;x]] updated with \[[Px]] is just:
47
48         <pre><code>u >>= \[[&exist;x]] >>= \[[Px]]
49         </code></pre>
50
51         or, being explicit about which "bind" operation we're representing here with `>>=`, that is:
52
53         <pre><code>bind_set (bind_set u \[[&exist;x]]) \[[Px]]
54         </code></pre>
55
56 *       Can you figure out how to handle \[[not &phi;]] on your own? If not, here are some [more hints](/hints/assignment_7_hint_6).