where `i` *subsists* in <code>s[φ]</code> if there are any `i'` that *extend* `i` in <code>s[φ]</code>.
------- wrong....
-
- In our framework, we just have to convert the operation <code>>>= \[[ψ]]</code> into another operation <code>>>= \[[ψ]] >>= neg</code>, where `neg` flips the truth-value of all the `bool dpm`s it operates on:
+ Here's how to do that in our framework:
type clause_op = bool dpm -> bool dpm set;;
+
+ (* filter out which bool dpms in a set are true when receiving (r, h) as input *)
+ let extensions set (r, h) = List.filter (fun one_dpm -> let (truth_value, _, _) = one_dpm (r, h) in truth_value) set;;
let negate_op (phi : clause_op) : clause_op =
- let neg : clause_op = fun one_dpm ->
- unit_set (fun (r, h) ->
- let (truth_value, r', h') = one_dpm (r, h)
- in (not truth_value, r', h'))
- in fun one_dpm -> bind_set (phi one_dpm) neg;;
-
-
- let negate_op (phi : clause_op) : clause_op =
- fun one_dpm ->
- if blah
- then unit_set one_dpm
- else empty_set
-------
+ fun one_dpm -> unit_set (
+ fun (r, h) ->
+ let truth_value' = extensions (phi one_dpm) (r, h) = []
+ in (truth_value', r, h)
+ )
* Representing \[[and φ ψ]] is simple:
let and_op (phi : clause_op) (psi : clause_op) : clause_op =
fun one_dpm -> bind_set (phi one_dpm) psi;;
-* We define the other connectives in terms of `not` and `and`:
+* Here are `or` and `if`:
let or_op (phi : clause_op) (psi : clause_op) =
- negate_op (and_op (negate_op phi) (negate_op psi))
+ (* NOT: negate_op (and_op (negate_op phi) (negate_op psi)) *)
+ fun one_dpm -> unit_set (
+ fun (r, h) ->
+ in let truth_value' = extensions (phi one_dpm) (r, h) <> [] || extensions (bind_set (negate_op phi one_dpm) psi) (r, h) <> []
+ in (truth_value', r, h))
+
+ let if_op (phi : clause_op) (psi : clause_op) : clause_op =
+ (* NOT: negate_op (and_op phi (negate_op psi)) *)
+ fun one_dpm -> unit_set (
+ fun (r, h) ->
+ in let truth_value' = List.for_all (fun one_dpm ->
+ let (truth_value, _, _) = one_dpm (r, h)
+ in truth_value = false || extensions (psi one_dpm) (r, h) <> []
+ ) (phi one_dpm)
+ in (truth_value', r, h));;
- let if_op (phi : clause_op) (psi : clause_op) =
- negate_op (and_op phi (negate_op psi));;
* Now let's test everything we've developed:
let antecedent = fun one_dpm -> exists 'x' one_dpm >>= lift_predicate male getx >>= exists 'y' >>= lift_predicate2 wife_of getx gety;;
(* "if a man x has a wife y, x kisses y" *)
- run (initial_set >>= if_op antecedent lift_predicate2 kisses getx gety);;
+ run (initial_set >>= if_op antecedent (lift_predicate2 kisses getx gety));;
(* Bob has wife Carol, and kisses her; and Ted has wife Alice and kisses her; so this is true! *)
(* "if a man x has a wife y, x misses y" *)
- run (initial_set >>= if_op antecedent lift_predicate2 misses getx gety);;
+ run (initial_set >>= if_op antecedent (lift_predicate2 misses getx gety));;
(* Bob has wife Carol, and misses her; but Ted misses only Carol, not his wife Alice; so this is false! *)