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

nullary and unary ands and ors #96

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

nullary and unary ands and ors #96

wants to merge 2 commits into from

Conversation

yoni206
Copy link
Member

@yoni206 yoni206 commented Jun 6, 2024

This PR is a proposal to make our pythonic API act similarly to z3 when the user tries to create nullary/unary and/or terms.

our current main:

>>> x = Bool("x")
>>> And(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/panda/git/cvc5_pythonic_api/cvc5_pythonic_api/cvc5_pythonic.py", line 1720, in And
    return _nary_kind_builder(Kind.AND, *args)
  File "/home/panda/git/cvc5_pythonic_api/cvc5_pythonic_api/cvc5_pythonic.py", line 1125, in _nary_kind_builder
    return _to_expr_ref(ctx.solver.mkTerm(kind, *[a.ast for a in args]), ctx)
  File "cvc5.pxi", line 1438, in cvc5_python_base.Solver.mkTerm
RuntimeError: Invalid kind 'AND', expected Terms with kind AND must have at least 2 children and at most 67108863 children (the one under construction has 1)
>>> And()
Traceback (most recent call last):
  ...  
>>> solve(And())
Traceback (most recent call last):
  ...
>>> solve(Or())
Traceback (most recent call last):
...

After this PR:

>>> x = Bool("x")
>>> And(x)
x
>>> And()
True
>>> solve(And())
[]
>>> solve(Or())
no solution

z3:

>>> x = Bool("x")
>>> And(x)
And(x)
>>> And()
And
>>> solve(And())
[]
>>> solve(Or())
no solution

There will still be a difference between the printing of such terms (z3: And, And(x), cvc5: True, x), but at least it will be supported and will have the same semantics.

What do you think?

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

Successfully merging this pull request may close these issues.

2 participants