X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=hints%2Fassignment_7_hint_4.mdwn;h=a9c6c05b3ec700ad1b38cb50390191725cab7e03;hp=017a0d3be8166824cfe7de503a1b8ecf53c4bcb6;hb=f5ee0222f8fe5d7b91e1e4c813350d2bd6005940;hpb=824a638b7070e9ae64a5124c4467a03fd0f18b00 diff --git a/hints/assignment_7_hint_4.mdwn b/hints/assignment_7_hint_4.mdwn index 017a0d3b..a9c6c05b 100644 --- a/hints/assignment_7_hint_4.mdwn +++ b/hints/assignment_7_hint_4.mdwn @@ -18,7 +18,7 @@ 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. + The first seven lines here just perfom the operation we described: return a `bool dpm` computation that only yields `true` when 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: @@ -54,7 +54,9 @@ 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. + Applied to an `entity_dpm`, that yields a function that we can bind to a `bool dpm set` and that will transform the doubly-wrapped `bool` into a new `bool dpm set`. + + Doing things this way will discard `bool dpm`s from the set that started 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: @@ -77,7 +79,7 @@ then unit_set (bind_dpm getx (fun e -> unit_dpm (Q e))) else empty_set - which is: + unpacking the definition of `bind_dpm`, that is: let getx = fun (r, h) -> let obj = List.nth h (r 'x') @@ -93,7 +95,7 @@ which is: - in fun truth_value -> + fun truth_value -> if truth_value then unit_set ( fun (r, h) -> @@ -105,7 +107,7 @@ which is: - in fun truth_value -> + fun truth_value -> if truth_value then unit_set ( fun (r, h) ->