Skip to content

Commit 2a2de91

Browse files
committed
Make kissat an optional setting at the module level.
1 parent 8dc0254 commit 2a2de91

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

nnf/__init__.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def all_models(names: 't.Iterable[Name]') -> t.Iterator[Model]:
6060
T_NNF_co = t.TypeVar('T_NNF_co', bound='NNF', covariant=True)
6161
_Tristate = t.Optional[bool]
6262

63+
# Valid values: native, kissat, and pysat
64+
SAT_BACKEND = 'native'
65+
6366
if t.TYPE_CHECKING:
6467
def memoize(func: T) -> T:
6568
...
@@ -594,10 +597,17 @@ def to_CNF(self) -> 'And[Or[Var]]':
594597
from nnf import tseitin
595598
return tseitin.to_CNF(self)
596599

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
600+
def _cnf_satisfiable(self: 'And[Or[Var]]') -> bool:
601+
"""Call a SAT solver on the presumed CNF theory."""
602+
if 'native' == SAT_BACKEND:
603+
return self._cnf_satisfiable_native()
604+
elif 'kissat' == SAT_BACKEND:
605+
from nnf import kissat
606+
return kissat.solve(self) is not None
607+
elif 'pysat' == SAT_BACKEND:
608+
raise NotImplementedError('pysat backend not yet implemented')
609+
else:
610+
raise NotImplementedError('Unrecognized SAT backend: '+SAT_BACKEND)
601611

602612
def _cnf_satisfiable_native(self) -> bool:
603613
"""A naive DPLL SAT solver."""

0 commit comments

Comments
 (0)