From 26574827b88c32f00baaf941c4eac1aaebac839d Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Fri, 19 Nov 2010 09:22:49 -0500 Subject: [PATCH] assignment7 tweaks Signed-off-by: Jim Pryor --- hints/assignment_7_hint_3.mdwn | 3 ++- hints/assignment_7_hint_5.mdwn | 57 ++++++++++++++++++++++++------------------ hints/assignment_7_hint_6.mdwn | 16 ++++++++++++ 3 files changed, 50 insertions(+), 26 deletions(-) create mode 100644 hints/assignment_7_hint_6.mdwn diff --git a/hints/assignment_7_hint_3.mdwn b/hints/assignment_7_hint_3.mdwn index bbdea694..0914b79d 100644 --- a/hints/assignment_7_hint_3.mdwn +++ b/hints/assignment_7_hint_3.mdwn @@ -40,7 +40,8 @@ It will be useful to have a shorthand way of referring to this operation: (* next we assign 'x' to location newindex *) in let r' = fun v -> if v = var_to_bind then newindex else r v - in (r',h') + (* the reason for returning true as an initial element will emerge later *) + in (true, r',h') * Is that enough? If not, here are some [more hints](/hints/assignment_7_hint_4). diff --git a/hints/assignment_7_hint_5.mdwn b/hints/assignment_7_hint_5.mdwn index 46ca442d..591fd31d 100644 --- a/hints/assignment_7_hint_5.mdwn +++ b/hints/assignment_7_hint_5.mdwn @@ -1,7 +1,7 @@ -* 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: +* 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: -
s >>= \[[∃x]] >>= \[[Px]]
+	
u >>=set \[[∃x]] >>=set \[[Px]]
 	
What does \[[∃x]] need to be here? Here's what they say, on the top of p. 13: @@ -12,38 +12,45 @@ > 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. - 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 = fun one_dpm ->
+			fun truth_value ->
+				if truth_value = false
+				then empty_set
+				else List.map (fun d -> new_peg_and_assign 'x' d) domain
+		in bind_set u extend_one
 	
+ + 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) = + fun ((r, h) : assignment * store) -> + (* first we calculate an unused index *) + let newindex = List.length h + (* next we store d at h[newindex], 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 newindex *) + in let r' = fun v -> + if v = var_to_bind then newindex else r v + (* the reason for returning true as an initial element should now be apparent *) + in (true, r',h') - 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. + What's going on here? 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)`. - A later step can then filter out all the possibilities in which the entity `d` we did that with doesn't have property P. + A later step can then filter out all the `dpm`s according to which the +entity `d` we did that with doesn't have property P. - So if we just call the function `(fun (r, h) -> ...)` above \[[∃x]], then `s` updated with \[[∃x]] updated with \[[Px]] is just: + So if we just call the function `extend_one` 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]]
+	
bind_set (bind_set u \[[∃x]]) \[[Px]]
 	
-* In def 3.1 on p. 14, GS&V define `s` updated with \[[not φ]] as: - - > { i &elem; s | i does not subsist in s[φ] } - - where `i` *subsists* in s[φ] if there are any `i'` that *extend* `i` in s[φ]. - - Here's how we can represent that: - -
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 φ]] on your own? If not, here are some [more hints](/hints/assignment_7_hint_6). diff --git a/hints/assignment_7_hint_6.mdwn b/hints/assignment_7_hint_6.mdwn new file mode 100644 index 00000000..e30514b5 --- /dev/null +++ b/hints/assignment_7_hint_6.mdwn @@ -0,0 +1,16 @@ + +* In def 3.1 on p. 14, GS&V define `s` updated with \[[not φ]] as: + + > { i &elem; s | i does not subsist in s[φ] } + + where `i` *subsists* in s[φ] if there are any `i'` that *extend* `i` in s[φ]. + + Here's how we can represent that: + +
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
+		
+ + -- 2.11.0