-
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
Feature request: API for "a = b (mod m)" for a fixed "m" #723
Comments
What about the encoding: (a - b) mod m = 0? |
@NikolajBjorner Seems to be much slower in practice than the divisibility encoding. Choose three random primes prime1, prime2, prime3.
|
Actually, disregard the comment about the wrong sort, that was my mistake. |
I created a test according to your example with three primes and also a formulation using fresh quotient variables. One observation is that Z3 uses different tactics for these formulations. Thus, it could be that you are seeing different behavior because the modulus terms are not recognized by certain tactics. Try to run your example with /v:10 and see if this is the case. |
Signed-off-by: Nikolaj Bjorner <[email protected]>
Hi,
Is it possible to request an API
Z3_mk_equal_modulo(Z3_ast a, Z3_ast b, long m)
, wherea
andb
are integers, andm
is a constant?It's a linear constraint, both when it's positive:
\exists k . a = b + k * m
andwhen it's negative:
\exists k, d . a = b + k * m + d /\ d != 0 /\ d < m
.It's difficult for us to do this outside of the solver, as if we introduce the existential quantifier explicitly, it might become a difficult constraint under negation.
Currently we encode this as
((a - b) / m) * m = (a - b)
, which I think is suboptimal and non-linear.The text was updated successfully, but these errors were encountered: