I wanted to ask a question about assigning distinct values in Z3.
suppose that I have 6 variables A,B,C,D,E,F.
Now, I would like to assign distinct values to some of them and some of them will be zero. How many variables will be distinct and how many variables are zero is unknown before-hand. It depends on certain other conditions.
generally for all the variables I shall write
(assert (distinct A B C D E F))
However is it possible to write constraint such as A, B, D are zero and others are distinct? Again remember that A,B, D are just example variables. They can change dynamically depending on the constraints.
Thanks !
As far as I understand, you have a set V of variables v1, …, vn, where each variable vi is either zero or different from all other variables vj, j ≠ i.
As an example, let
V = {a, b, c, d}.You could encode your constraints as
Adding two constraints and querying Z3 for a model
then yields
Since generating the “zero or distinct” constraints is a tedious task you’d probably want to work with a Z3 front-end such as PyZ3 or Scala^Z3.