equal
deleted
inserted
replaced
36 |
36 |
37 structure PropLogic : PROP_LOGIC = |
37 structure PropLogic : PROP_LOGIC = |
38 struct |
38 struct |
39 |
39 |
40 (* ------------------------------------------------------------------------- *) |
40 (* ------------------------------------------------------------------------- *) |
41 (* prop_formula: formulas of propositional logic, built from boolean *) |
41 (* prop_formula: formulas of propositional logic, built from Boolean *) |
42 (* variables (referred to by index) and True/False using *) |
42 (* variables (referred to by index) and True/False using *) |
43 (* not/or/and *) |
43 (* not/or/and *) |
44 (* ------------------------------------------------------------------------- *) |
44 (* ------------------------------------------------------------------------- *) |
45 |
45 |
46 datatype prop_formula = |
46 datatype prop_formula = |
79 | SAnd (False, _) = False |
79 | SAnd (False, _) = False |
80 | SAnd (_, False) = False |
80 | SAnd (_, False) = False |
81 | SAnd (fm1, fm2) = And (fm1, fm2); |
81 | SAnd (fm1, fm2) = And (fm1, fm2); |
82 |
82 |
83 (* ------------------------------------------------------------------------- *) |
83 (* ------------------------------------------------------------------------- *) |
84 (* indices: collects all indices of boolean variables that occur in a *) |
84 (* indices: collects all indices of Boolean variables that occur in a *) |
85 (* propositional formula 'fm'; no duplicates *) |
85 (* propositional formula 'fm'; no duplicates *) |
86 (* ------------------------------------------------------------------------- *) |
86 (* ------------------------------------------------------------------------- *) |
87 |
87 |
88 (* prop_formula -> int list *) |
88 (* prop_formula -> int list *) |
89 |
89 |
258 (* prop_formula list * prop_formula list -> prop_formula *) |
258 (* prop_formula list * prop_formula list -> prop_formula *) |
259 |
259 |
260 fun dot_product (xs,ys) = exists (map SAnd (xs~~ys)); |
260 fun dot_product (xs,ys) = exists (map SAnd (xs~~ys)); |
261 |
261 |
262 (* ------------------------------------------------------------------------- *) |
262 (* ------------------------------------------------------------------------- *) |
263 (* eval: given an assignment 'a' of boolean values to variable indices, the *) |
263 (* eval: given an assignment 'a' of Boolean values to variable indices, the *) |
264 (* truth value of a propositional formula 'fm' is computed *) |
264 (* truth value of a propositional formula 'fm' is computed *) |
265 (* ------------------------------------------------------------------------- *) |
265 (* ------------------------------------------------------------------------- *) |
266 |
266 |
267 (* (int -> bool) -> prop_formula -> bool *) |
267 (* (int -> bool) -> prop_formula -> bool *) |
268 |
268 |