I have the following linear equations.
m = 2 ** 31 - 1
(207560540 ∗ a + b) modulo m = 956631177
(956631177 ∗ a + b) modulo m = 2037688522
What is the most efficient way to solve these equations?
I used Z3 however it did not find any solution. My code for Z3 to solve the above equations is:
#! /usr/bin/python
from z3 import *
a = Int('a')
b = Int('b')
s = Solver()
s.add((a * 207560540 + b) % 2147483647 == 956631177)
s.add((a * 956631177 + b) % 2147483647 == 2037688522)
print s.check()
print s.model()
I know that the solution is: a = 16807, b = 78125, however, how can I make Z3 solve it?
The other method I tried is by setting a and b to BitVec() instead of Integers as shown below:
a = BitVec('a', 32)
b = BitVec('b', 32)
This gives me an incorrect solution as shown below:
[b = 3637638538, a = 4177905984]
Is there way to solve it with Z3?
Thanks.