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

Boolean comparison in z3 #146

Closed
IgnaceBleukx opened this issue Nov 3, 2022 · 4 comments
Closed

Boolean comparison in z3 #146

IgnaceBleukx opened this issue Nov 3, 2022 · 4 comments
Labels
Milestone

Comments

@IgnaceBleukx
Copy link
Collaborator

In CPMpy, a user can write something like this:

a,b = boolvar(shape=2)
(a & b) <= 1 

But this is not supported by the z3 API. Currently, the interface raises the following error: TypeError: '<=' not supported between instances of 'BoolRef' and 'int'. We should catch these cases and translate to the proper boolean expression.

@tias
Copy link
Collaborator

tias commented Nov 12, 2022

It goes a bit further even, including (a & b) <= (a | b) as well as (a & 1) or (a & 0) etc, it is simply much stricter on the Booleanness...

So, to fix in next release... (it can be avoided by writing the constraints more carefully as a user, for now)

@tias tias added this to the v0.9.11 milestone Nov 12, 2022
Wout4 added a commit that referenced this issue Dec 8, 2022
introduced helper intvar when comparing boolean expressions
@Wout4
Copy link
Collaborator

Wout4 commented Dec 8, 2022

We have a fix for this in pull request #189

@Wout4
Copy link
Collaborator

Wout4 commented Dec 20, 2022

(a & 1), a | 0, etc will also crash linearize.py when using other solvers as an integer is not an expression. Will open a separate issue for that

@Dimosts
Copy link
Collaborator

Dimosts commented Mar 14, 2023

I tried to replicate this issue, and I saw that this is resolved, as pull request #189 was merged. I am closing this.

@Dimosts Dimosts closed this as completed Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants