X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=hints%2Fassignment_7_hint_5.mdwn;h=d44f824b05968d6de85e0cbc5b46ef97c77205b5;hp=40df3b81971f5b8c31139c6fcfd7bc942fbdce24;hb=8cf1fe240800a66d644f907fad8d618b014efd7d;hpb=ddcb99cc42fe32a7a16ba2fe78b9228c354807d0 diff --git a/hints/assignment_7_hint_5.mdwn b/hints/assignment_7_hint_5.mdwn index 40df3b81..d44f824b 100644 --- a/hints/assignment_7_hint_5.mdwn +++ b/hints/assignment_7_hint_5.mdwn @@ -1,3 +1,15 @@ + + * 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]]
@@ -17,8 +29,8 @@

u updated with \[[∃x]] ≡
let extend one_dpm (d : entity) =
-			bind_dpm one_dpm (new_peg_and_assign 'x' d)
-		in bind_set u (fun one_dpm -> List.map (fun d -> extend one_dpm d) domain)
+			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)

where `new_peg_and_assign` is the operation we defined in [hint 3](/hints/assignment_7_hint_3):
@@ -46,18 +58,18 @@

or, being explicit about which "bind" operation we're representing here with `>>=`, that is:

-	bind_set (bind_set u \[[∃x]]) \[[Px]]
+	set_bind (set_bind u \[[∃x]]) \[[Px]]

-*	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 [week6](
+*	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](

type assignment = char -> entity;;
type 'a reader = assignment -> 'a;;

-		let unit_reader (value : 'a) : 'a reader = fun r -> value;;
+		let reader_unit (value : 'a) : 'a reader = fun r -> value;;

fun r ->
let a = u r
in let u' = f a
@@ -77,7 +89,7 @@
fun r ->

The meaning of \[[Qx]] would then be:

@@ -86,7 +98,7 @@
\[[Qx]] ≡ \[[Q]] \[[x]] ≡
fun r ->
let obj = getx r

Recall also how we defined \[[lambda x]], or as [we called it before](/reader_monad_for_variable_binding), \\[[who(x)]]:
@@ -103,7 +115,7 @@

fun (lifted_predicate : lifted_unary) ->
fun r -> exists (fun (obj : entity) ->

That would be the meaning of \[[∃]], which we'd use like this:

@@ -124,7 +136,7 @@
in clause r'
in let lifted_exists =
fun lifted_predicate ->
-				fun r -> exists (fun obj -> lifted_predicate (unit_reader obj) r)
+				fun r -> exists (fun obj -> lifted_predicate (reader_unit obj) r)

which we can simplify to:
@@ -137,7 +149,7 @@
in clause r'
in let lifted_exists =
fun lifted_predicate ->
-				fun r -> exists (fun obj -> lifted_predicate (unit_reader obj) r)
+				fun r -> exists (fun obj -> lifted_predicate (reader_unit obj) r)

@@ -146,11 +158,11 @@