Simplex in z3 via for-all

2020-08-01 09:07发布

问题:

A very similar questions were asked on SO already, but I couldn't find answer to the following problem. A linear maximization problem can be easily stated using for-all quantifier:

obj = f(x) AND \forall x . Ax <= b => f(x) <= obj

The queries like above can be posed to z3. Consequently I want to ask whether z3 is smart enough to recognize an LP problem when it sees one and will it apply a simplex method to eliminate a for-all quantifier?

I did a few experiments and it seemed to work, but I haven't tried it on more complex examples.

Thanks!

回答1:

Z3 does not recognize it as an LP optimization problem. It most likely applies quantifier elimination first on the universally quantified formula, then the result is quantifier-free linear arithmetic and the model that comes out will provide the maximal value for the objective. This is of course not an efficient way to solve optimization problems. If you have courage to experiment, then the branch called "opt" under z3.codeplex.com contains an extension to Z3 that lets you formulate optimization objectives with Z3. A description of how to use it will be available soon.