Here is the Z3 model. Z3 is a proof of the theorem from Microsoft. The model is very similar to the previously proposed MIP model.
Enumerating integer solutions in MIP is not completely trivial (this can be done with some effort [link] or with the help of the “technology in advanced MIP-solvers” solution pool). With Z3 it's a little easier. It would be even simpler to use the Constraint Programming (CP) solver: they can automatically list the solutions.
Here we go:
from z3 import * A = [[1, 2, 1], [3, 1, -1]] b = [20, 12] n = len(A[0])
He decides
x0+2x1+x2 = 20 3x0+x1-x2 = 12
The solutions look like this:
[x2 = 2, x0 = 2, x1 = 8] [x2 = 7, x1 = 4, x0 = 5] [x2 = 12, x1 = 0, x0 = 8]
We can print the final model so that we can see how the “deny” restrictions were added:
[And(x0 >= 0, x1 >= 0, x2 >= 0), 1*x0 + 2*x1 + 1*x2 == 20, 3*x0 + 1*x1 + -1*x2 == 12, Or(x0 != 2, x1 != 8, x2 != 2), Or(x0 != 5, x1 != 4, x2 != 7), Or(x0 != 8, x1 != 0, x2 != 12)]