remove Solver offline method, fix mypy for test_smt.py

This commit is contained in:
Matthew Yacavone 2021-09-13 18:33:59 -04:00
parent 2ef2a35118
commit 9ebb6d4db4
2 changed files with 6 additions and 14 deletions

View File

@ -32,27 +32,16 @@ class Solver(metaclass=ABCMeta):
"""Returns whether hash consing is enabled (if applicable)."""
return self.__hash_consing
@abstractmethod
def offline(self) -> bool:
"""Returns true iff this solver generates offline queries."""
pass
@abstractmethod
def without_hash_consing(self) -> 'Solver':
"""Returns an identical solver but with hash consing disabled (if applicable)."""
pass
class OnlineSolver(Solver):
def offline(self) -> bool:
return False
def without_hash_consing(self) -> 'OnlineSolver':
return OnlineSolver(name=self.__name, hash_consing=False)
class OfflineSolver(Solver):
def offline(self) -> bool:
return True
def without_hash_consing(self) -> 'OfflineSolver':
return OfflineSolver(name=self.__name, hash_consing=False)

View File

@ -29,6 +29,7 @@ class TestSMT(unittest.TestCase):
ex_false_prove = c.prove(ex_false)
self.assertFalse(ex_false_prove)
self.assertIsInstance(ex_false_prove, cryptol.Counterexample)
if isinstance(ex_false_prove, cryptol.Counterexample):
self.assertEqual(ex_false_prove.type, "predicate falsified")
ex_false_sat = c.sat(ex_false)
self.assertFalse(ex_false_sat)
@ -38,10 +39,12 @@ class TestSMT(unittest.TestCase):
ex_partial_safe = c.safe(ex_partial)
self.assertFalse(ex_partial_safe)
self.assertIsInstance(ex_partial_safe, cryptol.Counterexample)
if isinstance(ex_partial_safe, cryptol.Counterexample):
self.assertEqual(ex_partial_safe.type, "safety violation")
ex_partial_prove = c.prove(ex_partial)
self.assertFalse(ex_partial_prove)
self.assertIsInstance(ex_partial_prove, cryptol.Counterexample)
if isinstance(ex_partial_prove, cryptol.Counterexample):
self.assertEqual(ex_partial_prove.type, "safety violation")
ex_partial_sat = c.sat(ex_partial)
self.assertTrue(ex_partial_sat)