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: boolvar-sum with int error #232

Closed
tias opened this issue Feb 17, 2023 · 3 comments · Fixed by #307
Closed

z3: boolvar-sum with int error #232

tias opened this issue Feb 17, 2023 · 3 comments · Fixed by #307
Assignees

Comments

@tias
Copy link
Collaborator

tias commented Feb 17, 2023

a bit artificial, but it exists in bigtest

bv = boolvar(3)
a = [bv[0], 0, bv[2]]
Model(sum(a) > 0).solve("z3")

weirdly, the wsum version does work

bv = boolvar(3)
a = [2*bv[0], 0, 5*bv[2]]
Model(sum(a) > 0).solve("z3")
@IgnaceBleukx IgnaceBleukx changed the title z3: sum with 0 error z3: sum with int error Feb 17, 2023
@IgnaceBleukx IgnaceBleukx changed the title z3: sum with int error z3: boolvar-sum with int error Feb 17, 2023
@IgnaceBleukx
Copy link
Collaborator

It seems z3 really does not like integer arithmetic mixed with boolean variables... Just making a sum with integer variables and constants does work weirdly.
I will open an issue on their github page and check if they can/want to fix it on their side or we should use the same "if-then-else" trick as we have done in z3 many times before...

@Dimosts
Copy link
Collaborator

Dimosts commented Feb 18, 2023

this issue is also linked to the one @Wout4 mentions in the comments of #146. Just an "a & 1" constraint crashes the solver due to 1 being an integer.

@IgnaceBleukx
Copy link
Collaborator

Yes it is certainly related, although I would expect Sum to work with mixed types...
Got response from the maintainers of z3: Z3Prover/z3#6598
I actually was not aware of the IntVal and BoolVal constructs, we might be able to simplify quite a lot of type-fixing we have at the moment with it.

@Wout4 Wout4 linked a pull request May 22, 2023 that will close this issue
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 a pull request may close this issue.

3 participants