|
32 | 32 |
|
33 | 33 | __all__ = ('NNF', 'Internal', 'And', 'Or', 'Var', 'Aux', 'Builder', |
34 | 34 | 'all_models', 'complete_models', 'decision', 'true', 'false', |
35 | | - 'dsharp', 'dimacs', 'amc', 'tseitin', 'operators') |
| 35 | + 'dsharp', 'dimacs', 'amc', 'kissat', 'tseitin', 'operators') |
36 | 36 |
|
37 | 37 |
|
38 | 38 | def all_models(names: 't.Iterable[Name]') -> t.Iterator[Model]: |
@@ -264,10 +264,9 @@ def satisfiable( |
264 | 264 |
|
265 | 265 | if cnf: |
266 | 266 | return self._cnf_satisfiable() |
267 | | - |
268 | | - # todo: use a better fallback |
269 | | - return any(self.satisfied_by(model) |
270 | | - for model in all_models(self.vars())) |
| 267 | + else: |
| 268 | + from nnf import tseitin |
| 269 | + return tseitin.to_CNF(self)._cnf_satisfiable() |
271 | 270 |
|
272 | 271 | def _satisfiable_decomposable(self) -> bool: |
273 | 272 | """Checks satisfiability of decomposable sentences. |
@@ -596,6 +595,11 @@ def to_CNF(self) -> 'And[Or[Var]]': |
596 | 595 | return tseitin.to_CNF(self) |
597 | 596 |
|
598 | 597 | def _cnf_satisfiable(self) -> bool: |
| 598 | + """Call a SAT solver (kissat) on the presumed CNF theory.""" |
| 599 | + from nnf import kissat |
| 600 | + return kissat.solve(self) is not None |
| 601 | + |
| 602 | + def _cnf_satisfiable_native(self) -> bool: |
599 | 603 | """A naive DPLL SAT solver.""" |
600 | 604 | def DPLL(clauses: t.FrozenSet[t.FrozenSet[Var]]) -> bool: |
601 | 605 | if not clauses: |
|
0 commit comments