Below solution i am not able to implement in java. Please help me. Below is snippet code which i am trying to implement.
I found the same question: Z3: finding all satisfying models
(Z3Py) checking all solutions for equation
BitVecExpr a = ctx.mkBVConst("a",8);
BitVecExpr b = ctx.mkBVConst("b",8);
BitVecExpr c = ctx.mkBVConst("c",8);
Solver s = ctx.mkSolver();
//s.add(ctx.mkEq(c,ctx.mkBVXOR(a,b))); // I am able to get distinct value for a and b for XOR.
//s.add(ctx.mkEq(c,ctx.mkBVOR(b,a))); // If i swap the position of the a and b then i was able to generate distinct pattern. For example for this add method of OR my code was working.
s.add(ctx.mkEq(c,ctx.mkBVOR(a,b))); // Not working getting same model.
s.add(ctx.mkEq(c,ctx.mkBV(11,8)));
if (s.check() == Status.SATISFIABLE)
{
System.out.println("status :"+ s.check());
Model m = s.getModel();
System.out.println("Model :"+ m);
}
BitVecExpr test1[] = {a,b};
s.add(ctx.mkDistinct(test1)); // If i use this line then only i get distinct pattern
if (s.check() == Status.SATISFIABLE)
{
System.out.println("status :"+ s.check());
Model m = s.getModel();
System.out.println("Model :"+ m);
}
Also i don't have model()[] method in java.In java i have getModel() method without any arguments.
One more question. How can we implement '!=' inside add. For example.
s.add(Or(a != s.model()[a], b != s.model()[b])) For == we have mkEq() method, But i was unable to find any method related to '!='.
I tried using: s.add(ctx.mkOr(ctx.mkEq(a,ctx.mkNot(s.getModel())),ctx.mkEq(a,ctx.mkNot(s.getModel()))));
For which i am getting compilation error. Which i should get because its not possible to implement in that way.