Package eu.bandm.tools.util
Class SAT<P>
java.lang.Object
eu.bandm.tools.util.SAT<P>
- Type Parameters:
P
- base class of propositional variables.
Solver for propositional formulas in conjunctive normal form.
Based on the DPLL algorithm.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Disjunction of literals.protected static class
Conjunction of clauses.static class
Optionally negated propositional variable. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected SAT.Literal<? extends P>
Choose a literal to resolve from a formula.Solve a formula.Set<SAT.Literal<? extends P>>
solve
(Collection<? extends Collection<? extends SAT.Literal<? extends P>>> cnf) Solve a formula.
-
Constructor Details
-
SAT
public SAT()Create a new solver.
-
-
Method Details
-
choose
Choose a literal to resolve from a formula. Subclasses may override this method to implement a custom strategy.The default strategy chooses the first literal of the first clause, as per
form.iterator().next().iterator().next()
.- Parameters:
form
- the current formula, a nonempty collection of nonempty clauses.- Returns:
- a literal occurring in
form
.
-
solve
Solve a formula. Subclasses may override this method for global pre- or post-processing.- Parameters:
form
- a formula to solve.- Returns:
- a satisfiable disjunction-free formula that implies
form
; or a false formula ifform
is unsatisfiable.
-
solve
public Set<SAT.Literal<? extends P>> solve(Collection<? extends Collection<? extends SAT.Literal<? extends P>>> cnf) Solve a formula.- Parameters:
cnf
- a formula to solve, given as a collection of clauses (collections of literals).- Returns:
- a consistent set of literals that jointly imply
form
; or a false formula ifform
is unsatisfiable.
-