Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restricting the use of Solver(): no specification of logic #95

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions cvc5_pythonic_api/cvc5_pythonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions test/pgm_outputs/multiple_solvers.py.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions test/pgms/multiple_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading