projects
/
lambda.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
manip trees: more explanation
[lambda.git]
/
hints
/
assignment_7_hint_6.mdwn
diff --git
a/hints/assignment_7_hint_6.mdwn
b/hints/assignment_7_hint_6.mdwn
index
0d9f02e
..
e513284
100644
(file)
--- a/
hints/assignment_7_hint_6.mdwn
+++ b/
hints/assignment_7_hint_6.mdwn
@@
-20,13
+20,15
@@
(* if one_dpm isn't already false at (r, h),
we want to check its behavior when updated with phi
bind_set (unit_set one_dpm) phi === phi one_dpm; do you remember why? *)
(* if one_dpm isn't already false at (r, h),
we want to check its behavior when updated with phi
bind_set (unit_set one_dpm) phi === phi one_dpm; do you remember why? *)
- let (truth_value,
_, _
) = one_dpm (r, h)
+ let (truth_value,
r', h'
) = one_dpm (r, h)
in let truth_value' = truth_value && (truths (phi one_dpm) (r, h) = [])
(* new_dpm must return a (bool, r, h) *)
in let truth_value' = truth_value && (truths (phi one_dpm) (r, h) = [])
(* new_dpm must return a (bool, r, h) *)
- in (truth_value', r
, h
)
+ in (truth_value', r
', h'
)
in unit_set new_dpm;;
in unit_set new_dpm;;
+ **Thanks to Simon Charlow** for catching a subtle error in previous versions of this function. Fixed 1 Dec.
+
* Representing \[[and φ ψ]] is simple:
let and_op (phi : clause) (psi : clause) : clause =
* Representing \[[and φ ψ]] is simple:
let and_op (phi : clause) (psi : clause) : clause =
@@
-36,10
+38,12
@@
* Here are `or` and `if`:
* Here are `or` and `if`:
+ (These probably still manifest the bug Simon spotted.)
+
let or_op (phi : clause) (psi : clause) =
fun one_dpm -> unit_set (
fun (r, h) ->
let or_op (phi : clause) (psi : clause) =
fun one_dpm -> unit_set (
fun (r, h) ->
-
in
let truth_value' = (
+ let truth_value' = (
truths (phi one_dpm) (r, h) <> [] ||
truths (bind_set (negate_op phi one_dpm) psi) (r, h) <> []
) in (truth_value', r, h))
truths (phi one_dpm) (r, h) <> [] ||
truths (bind_set (negate_op phi one_dpm) psi) (r, h) <> []
) in (truth_value', r, h))
@@
-47,7
+51,7
@@
let if_op (phi : clause) (psi : clause) : clause =
fun one_dpm -> unit_set (
fun (r, h) ->
let if_op (phi : clause) (psi : clause) : clause =
fun one_dpm -> unit_set (
fun (r, h) ->
-
in
let truth_value' = List.for_all (fun one_dpm ->
+ let truth_value' = List.for_all (fun one_dpm ->
let (truth_value, _, _) = one_dpm (r, h)
in truth_value = false || truths (psi one_dpm) (r, h) <> []
) (phi one_dpm)
let (truth_value, _, _) = one_dpm (r, h)
in truth_value = false || truths (psi one_dpm) (r, h) <> []
) (phi one_dpm)
@@
-76,6
+80,8
@@
type clause = bool dpm -> bool dpm set;;
type clause = bool dpm -> bool dpm set;;
+* More:
+
(* this generalizes the getx function from hint 4 *)
let get (var : char) : entity dpm =
fun (r, h) ->
(* this generalizes the getx function from hint 4 *)
let get (var : char) : entity dpm =
fun (r, h) ->
@@
-100,8
+106,6
@@
else bind_dpm entity1_dpm (fun e1 -> bind_dpm entity2_dpm (fun e2 -> unit_dpm (f e1 e2)))
in fun one_dpm -> unit_set (bind_dpm one_dpm eliminator);;
else bind_dpm entity1_dpm (fun e1 -> bind_dpm entity2_dpm (fun e2 -> unit_dpm (f e1 e2)))
in fun one_dpm -> unit_set (bind_dpm one_dpm eliminator);;
-
-
let new_peg_and_assign (var_to_bind : char) (d : entity) : bool -> bool dpm =
fun truth_value ->
fun (r, h) ->
let new_peg_and_assign (var_to_bind : char) (d : entity) : bool -> bool dpm =
fun truth_value ->
fun (r, h) ->
@@
-119,6
+123,8
@@
(* include negate_op, and_op, or_op, and if_op as above *)
(* include negate_op, and_op, or_op, and if_op as above *)
+* More:
+
(* some handy utilities *)
let (>>=) = bind_set;;
let getx = get 'x';;
(* some handy utilities *)
let (>>=) = bind_set;;
let getx = get 'x';;