Is it possible to ask Z3 to prove satisfiability of a system of integer polynomial inequalities with 2 different variables (or in general case) by approximating the original system with a system of linear inequalities?
By default, Z3 will try to solve a nonlinear integer problem as a linear one. The basic trick is to treat nonlinear terms such as x*y as new "variables". Nonlinear integer arithmetic is not well supported in Z3, the following post has a summary on how Z3 handles nonlinear integer arithmetic:
How does Z3 handle non-linear integer arithmetic?
Related
I understand that in general, non-linear integer arithmetic is undecidable.
However, this is not the case for the arithmetic of finite fields mod p, as in particular this can be reduced to a SAT problem over finite bit vectors. The reduction to SAT is however, it seems, somewhat inefficient for large primes p (this is Z3's default behaviour).
Is there a more efficient way of modelling arithmetic operations in Z3 over such a finite field? Perhaps performance improvements can be made over Z3's default strategy from the knowledge that all arithmetic operations are over the same finite field?
what is the usual precision for Real variables in Z3? Is exact arithmetic used?
Is there a way to set the accuracy level manually?
If Real means that exact arithmetic must be used, is there any other data type for floating point values which has limited precision?
Finally: from this point of view, is z3 different with respect to the other popular SMT solvers, or is this standardised in the SMT-LIB definition?
See this answer: z3 existential theory of the reals
Regarding printing precision, see this one: algebraic reals: does z3 do rounding when pretty printing?
In short, yes they are precisely represented as roots of polynomials. Not every real number can be represented by the Real type (transcendentals, e, pi, etc.); but all polynomial roots are representable.
This paper discusses how to also deal with transcendentals.
I am using this link to compile and see the result (http://rise4fun.com/Z3)
I just want to write 2^n say 2^100 in Z3.
Please help me how to write?
Like so: (^ 2 n), see example.
Note that Z3 will often give up on non-linear arithmetic (as is the case in the example). See also: How does Z3 handle non-linear integer arithmetic? and Z3 support for nonlinear arithmetic.
Does z3's SAT solver(s) obtain a complete assignment to the propositional(ized) part of an SMT problem before doing a theory consistency check? In particular, I am curious to know what is done by default for each of the following background theories/combination (if this is theory-dependent): Linear Real Arithmetic (LRA), Linear Integer Real Arithmetic (LIRA), Non-Linear Integer Real Arithmetic (NIRA)? Also, where in the actual code (codeplex stable z3 v4.3.1) is a propositional literal (heuristically) decided by the SAT solver?
No, Z3 does not obtain a complete assignment before doing theory consistency checks.
However, it delays "expensive" checks. "Expensive" checks are performed in a step called final_check that is performed only when a (complete) proprositional assignment is produced. Here the word "expensive" is relative. Linear real arithmetic consistency checks can be quite expensive due to big number arithmetic computations, but they are considered "cheap" in Z3.
Linear real arithmetic checks are done eagerly. Nonlinear and linear integer arithmetic checks are done at the final_check step.
Note that Z3 contains more than one solver. The behavior above is for the one implemented in the directory smt. The nonlinear real arithmetic solver (nlsat directory) works in a completely different way, and it does not use the final_check approach described above.
I'm aware that there is a simplex solver implemented in z3. Is it possible to use the solver for linear optimization? Where is the interface for the solver located in the z3 source code?
Yes, Z3 has a solver based on the Simplex method. It is implemented in the files src\smt\theory_arith*. The main files are src\smt\theory_arith.h and src\smt\theory_arith_core.h.
This solver has very basic support for optimization in the file src\smt\theory_arith_aux.h. This functionality is not "exposed" by the solver. It is used internally in the extensions/heuristics for integer and nonlinear arithmetic.
BTW, recall that Z3 solver is based on rational (precise) arithmetic. So, it is much slower than solvers based on floating point arithmetic. Moreover, this solver does not use the revised simplex method.