equal
deleted
inserted
replaced
281 local |
281 local |
282 open PropLogic |
282 open PropLogic |
283 in |
283 in |
284 fun dpll_solver fm = |
284 fun dpll_solver fm = |
285 let |
285 let |
286 (* We could use 'PropLogic.defcnf fm' instead of 'fm', but that *) |
286 (* We could use 'PropLogic.defcnf fm' instead of 'nnf fm', but that *) |
287 (* sometimes introduces more boolean variables than we can handle *) |
287 (* sometimes introduces more boolean variables than we can handle *) |
288 (* efficiently. *) |
288 (* efficiently. *) |
|
289 val fm' = PropLogic.nnf fm |
289 (* int list *) |
290 (* int list *) |
290 val indices = PropLogic.indices fm |
291 val indices = PropLogic.indices fm' |
291 (* int list -> int -> prop_formula *) |
292 (* int list -> int -> prop_formula *) |
292 fun partial_var_eval [] i = BoolVar i |
293 fun partial_var_eval [] i = BoolVar i |
293 | partial_var_eval (x::xs) i = if x=i then True else if x=(~i) then False else partial_var_eval xs i |
294 | partial_var_eval (x::xs) i = if x=i then True else if x=(~i) then False else partial_var_eval xs i |
294 (* int list -> prop_formula -> prop_formula *) |
295 (* int list -> prop_formula -> prop_formula *) |
295 fun partial_eval xs True = True |
296 fun partial_eval xs True = True |
349 if x=i then true |
350 if x=i then true |
350 else if x=(~i) then false |
351 else if x=(~i) then false |
351 else assignment_from_list xs i |
352 else assignment_from_list xs i |
352 in |
353 in |
353 (* initially, no variable is interpreted yet *) |
354 (* initially, no variable is interpreted yet *) |
354 apsome assignment_from_list (dpll [] fm) |
355 apsome assignment_from_list (dpll [] fm') |
355 end |
356 end |
356 end (* local *) |
357 end (* local *) |
357 in |
358 in |
358 SatSolver.add_solver ("dpll", Some o dpll_solver) |
359 SatSolver.add_solver ("dpll", Some o dpll_solver) |
359 end; |
360 end; |