Library
Module
Module type
Parameter
Class
Class type
val create : unit -> t
Create a problem.
type solution = lit -> bool
Get the assignment for this literal in the discovered solution.
val impossible : t -> unit -> unit
Indicate that the problem is unsolvable, before even starting. This is a convenience feature so that clients don't need a separate code path for problems they discover during setup vs problems discovered by the solver.
Add a clause requiring at least one literal to be True
. e.g. A or B or not(C)
. reason
is used in debug messages.
If the first variable is true, at least one of the others must be. implies p a bs
is equivalent to at_least_one p ((neg a) :: bs)
. reason
is used in debug messages.
val at_most_one : t -> lit list -> at_most_one_clause
Add a clause preventing more than one literal in the list from being True
.
run_solver decider
tries to solve the SAT problem. It simplifies it as much as possible first. When it has two paths which both appear possible, it calls decider ()
to choose which to explore first. If this leads to a solution, it will be used. If not, the other path will be tried. If decider
returns None
, we try setting the remaining variables to False
(decider
will not be called again unless we backtrack). Use this to tidy up at the end, when you no longer care about the order.
val get_best_undecided : at_most_one_clause -> lit option
Return the first literal in the list whose value is Undecided
, or None
if they're all decided. The decider function may find this useful.
val get_selected : at_most_one_clause -> lit option
Return the selected literal, if any.
val explain_reason : lit -> string