-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
How to define Integer log function #5965
Comments
The problem here is that >>> x = Int('x')
>>> (x ** x).sort()
Real I'm not sure if this is on purpose, or if it's a bug. @NikolajBjorner can opine. Assuming this is on purpose (or until the bug is fixed) you can write your axioms as: from z3 import *
s = Solver()
Z3_log = Function('log', IntSort(), IntSort(), IntSort())
base = Int('base')
value = Int('value')
s.add(ForAll([base, value], Z3_log(base, ToInt(base ** value)) == value))
s.add(ForAll([base, value], ToInt(base ** (Z3_log(base, value))) == value)) Or, alternatively: s.add(ForAll([base, value], Z3_log(base, ToInt(base ** value)) == value))
s.add(ForAll([base, value], base ** ToReal(Z3_log(base, value)) == ToReal(value))) I'm not sure which version would be preferable. I doubt either will perform all that well without well-chosen pattern instantiations. But that's a tangential question. |
2 ** -1 is not an integer so the range type cannot be integer. |
is_bool was not defined, this was now fixed. The original formula still throws an exception because the ** returns a Real, which is not a sub-sort of Int, as required by the signature of Z3_log. The formula isn't well typed. |
Hello everyone,
I'm interested in writing various helper mathematical function in Z3 to use in automated proofs. One of those functions is the Log function. I'm interested in writing both the ceiling Log, flooring log and a normal log. But even a normal log I can't get to work. Here I'm using Z3Py:
but I get an exception:
Is this expected? In addition how could I write the same log function but it should round up or down if it's it does not have an exact integer solution.
The text was updated successfully, but these errors were encountered: