Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix differences to z3 API #93

Open
yoni206 opened this issue Apr 24, 2024 · 1 comment
Open

Fix differences to z3 API #93

yoni206 opened this issue Apr 24, 2024 · 1 comment
Assignees

Comments

@yoni206
Copy link
Member

yoni206 commented Apr 24, 2024

With cvc5 pythonic API, we can call e.g. Solver("QF_BV"), but in z3 we cannot (instead we need to use SolverFor:
Perhaps we should also not allow supplying the logic name to Solver?

>>> from cvc5.pythonic import *
>>> s = Solver("QF_BV")
>>> from z3 import *
>>> s = Solver("QF_BV")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/yonizohar/Library/Python/3.9/lib/python/site-packages/z3/z3.py", line 6950, in __init__
    assert solver is None or ctx is not None
AssertionError

Getting a value from a model is possible for arbitrary terms with the cvc5 pythonic API, but seems like it is possible only for variables in z3 API:

>>> from cvc5.pythonic import *
>>> a = Int("a")
>>> s = Solver()
>>> s.add(a + a == a)
>>> s.check()
sat
>>> m = s.model()
>>> m[a]
0
>>> m[a+a]
0
>>>
>>> from z3 import *
>>> a = Int("a")
>>> s = Solver()
>>> s.add(a + a == a)
>>> s.check()
sat
>>> m = s.model()
>>> m[a]
0
>>> m[a+a]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/yonizohar/Library/Python/3.9/lib/python/site-packages/z3/z3.py", line 6676, in __getitem__
    _z3_assert(False, "Integer, Z3 declaration, or Z3 constant expected")
  File "/Users/yonizohar/Library/Python/3.9/lib/python/site-packages
/z3/z3.py", line 107, in _z3_assert
    raise Z3Exception(msg)
z3.z3types.Z3Exception: Integer, Z3 declaration, or Z3 constant expected
>>>
@yoni206 yoni206 assigned alex-ozdemir and yoni206 and unassigned alex-ozdemir Apr 24, 2024
@yoni206 yoni206 changed the title Creating a solver for a logic with Solver Fix differences to z3 API Apr 25, 2024
@yoni206
Copy link
Member Author

yoni206 commented Apr 30, 2024

Discussed at the cvc5 meeting. It seems to make sense to disallow the first but to keep the second.

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

No branches or pull requests

2 participants