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

Z3_solver_reset may not properly reset parser context #7260

Closed
pclayton opened this issue Jun 19, 2024 · 0 comments
Closed

Z3_solver_reset may not properly reset parser context #7260

pclayton opened this issue Jun 19, 2024 · 0 comments

Comments

@pclayton
Copy link

When switching from Z3 4.8.12 to 4.13.0, I have found that Z3_solver_from_string produces an error where it did not previously. With 4.13.0, there is no error the first time a solver s is used. However, after s has been reset using Z3_solver_reset, Z3_solver_from_string produces an error if the string argument declares a const that was previously declared before s was reset. This can be seen in the following Python transcript:

$ python -i
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from z3 import *
>>> s = Solver()
>>> s.from_string("(declare-const r1 Bool)")
>>> s.reset()
>>> s.from_string("(declare-const r1 Bool)")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\msys64\usr\share\python\Lib\site-packages\z3\z3.py", line 7274, in from_string
    Z3_solver_from_string(self.ctx.ref(), self.solver, s)
  File "C:\msys64\usr\share\python\Lib\site-packages\z3\z3core.py", line 4138, in Z3_solver_from_string
    _elems.Check(a0)
  File "C:\msys64\usr\share\python\Lib\site-packages\z3\z3core.py", line 1554, in Check
    raise self.Exception(self.get_error_message(ctx, err))
z3.z3types.Z3Exception: b'(error "line 1 column 23: invalid declaration, constant \'r1\' (with the given signature) already declared")\n'

Strangely, after this error, resetting s again does appear to clear the parser context because no error is produced when the declaration is repeated:

>>> s.reset()
>>> s.from_string("(declare-const r1 Bool)")

This may be related to 815518d introduced in 4.9.0 but I haven't checked. Or have I misunderstood how Z3_solver_reset interacts with parser contexts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant