diff --git a/cvc5_pythonic_api/cvc5_pythonic.py b/cvc5_pythonic_api/cvc5_pythonic.py index bae370f..b86884c 100644 --- a/cvc5_pythonic_api/cvc5_pythonic.py +++ b/cvc5_pythonic_api/cvc5_pythonic.py @@ -5979,16 +5979,16 @@ class Solver(object): * get-model, * etc.""" - def __init__(self, logic=None, ctx=None, logFile=None): - # save logic so that we can re-build the solver if needed. - self.logic = logic + def __init__(self, ctx=None, logFile=None): # ignore ctx (the paramter is kept for z3 compatibility) self.solver = None + self.logic = None self.initFromLogic() self.scopes = 0 self.assertions_ = [[]] self.last_result = None self.resetAssertions() + assert ctx is None or type(ctx) == Context def initFromLogic(self): """Create the base-API solver from the logic""" @@ -6368,7 +6368,10 @@ def SolverFor(logic, ctx=None, logFile=None): # sat # >>> s.model() # [x = 1] - return Solver(logic=logic, ctx=ctx, logFile=logFile) + s = Solver(ctx=ctx, logFile=logFile) + s.logic = logic + s.initFromLogic() + return s def SimpleSolver(ctx=None, logFile=None): diff --git a/test/pgm_outputs/multiple_solvers.py.out b/test/pgm_outputs/multiple_solvers.py.out index 2ff6275..fbc8671 100644 --- a/test/pgm_outputs/multiple_solvers.py.out +++ b/test/pgm_outputs/multiple_solvers.py.out @@ -5,6 +5,7 @@ The logic was specified as QF_BV, which doesn't include THEORY_ARITH, but got a The atom: (= x (* 2 y)) Can't solve integer problems with QF_BV solver +got an exception, which is good unsat unsat Can't eagerly BB with models and ALL diff --git a/test/pgms/multiple_solvers.py b/test/pgms/multiple_solvers.py index ece9f7a..003081a 100644 --- a/test/pgms/multiple_solvers.py +++ b/test/pgms/multiple_solvers.py @@ -21,6 +21,12 @@ print(e) print("Can't solve integer problems with QF_BV solver") +# Can't specify logic unless using `SolverFor` +try: + s = Solver("QF_BV") +except Exception as e: + print("got an exception, which is good") + # QF_NIA s = SolverFor("QF_BV")