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 cannot simplify (v << 3) + 1 - (v << 3) #7546

Open
fkil opened this issue Feb 4, 2025 · 0 comments
Open

z3 cannot simplify (v << 3) + 1 - (v << 3) #7546

fkil opened this issue Feb 4, 2025 · 0 comments

Comments

@fkil
Copy link

fkil commented Feb 4, 2025

I am working with z3 and making use of simplify. I've encountered an expression that should be easy to simplify, but isn't simplified. Most notably, if one replaces the bitshifts with multiplications, z3 can simplify it. Here's a python snippet to demonstrate it:

import z3

v = z3.BitVec('v', 32)

f1 = (v << 3) + 1 - (v << 3)
f2 = (v * 8) + 1 - (v * 8)

print(z3.simplify(f1))
print(z3.simplify(f2))

I've encountered this behavior on version 4.13.4.

I have the following questions:

  • Is there a reason why bitshifts are harder to simplify than multiplications?
  • Is there any way to make z3 simplify this? My current approach is to simply replace all bitshifts with multiplication
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