|
|
@ -1,4 +1,6 @@ |
|
|
|
"""This module contains an abstract SMT representation of an SMT solver.""" |
|
|
|
"""This module contains an abstract SMT representation of an SMT solver.""" |
|
|
|
|
|
|
|
import os |
|
|
|
|
|
|
|
import sys |
|
|
|
import z3 |
|
|
|
import z3 |
|
|
|
from typing import Union, cast, TypeVar, Generic, List, Sequence |
|
|
|
from typing import Union, cast, TypeVar, Generic, List, Sequence |
|
|
|
|
|
|
|
|
|
|
@ -44,10 +46,14 @@ class BaseSolver(Generic[T]): |
|
|
|
|
|
|
|
|
|
|
|
def check(self) -> z3.CheckSatResult: |
|
|
|
def check(self) -> z3.CheckSatResult: |
|
|
|
"""Returns z3 smt check result. |
|
|
|
"""Returns z3 smt check result. |
|
|
|
|
|
|
|
Also suppresses the stdout when running z3 library's check() to avoid unnecessary output |
|
|
|
:return: |
|
|
|
:return: The evaluated result which is either of sat, unsat or unknown |
|
|
|
""" |
|
|
|
""" |
|
|
|
return self.raw.check() |
|
|
|
old_stdout = sys.stdout |
|
|
|
|
|
|
|
sys.stdout = open(os.devnull, "w") |
|
|
|
|
|
|
|
evaluate = self.raw.check() |
|
|
|
|
|
|
|
sys.stdout = old_stdout |
|
|
|
|
|
|
|
return evaluate |
|
|
|
|
|
|
|
|
|
|
|
def model(self) -> Model: |
|
|
|
def model(self) -> Model: |
|
|
|
"""Returns z3 model for a solution. |
|
|
|
"""Returns z3 model for a solution. |
|
|
|