Z3

Equivalent Quantifier Free Formulas

。_饼干妹妹 提交于 2019-12-11 11:07:43
问题 I want to know if Z3 can show equivalent formulas after Quantifier Elimination. Example (exists k) (i x k) = 1 and k > 5 is equivalent to i > 0 and 5 i - 1 < 0. Here, quantifier k has been eliminated. Is this possible? Thanks, Kaustubh. 回答1: Yes, Z3 can check whether two formulas are equivalent. To check whether p and q are equivalent. We must check whether (not (iff p q)) is unsatisfiable. Your example uses nonlinear arithmetic i*k . The quantifier elimination module in Z3 has limited

Encoding of first order differential equation as First order formula

こ雲淡風輕ζ 提交于 2019-12-11 10:52:34
问题 Can somebody help me in pointing out what will be the best encoding of following equation using first order formula so as to give it as input to the SMT solver?? x`=Ax+b 回答1: You can encode the differential equation easily in Z3 as it is just a set of n linear (affine) functions over n^2 + n real constants (n^2 from a_ij, n from b_i) and n real variables (x_i). You can encode this directly in Z3. dotx_1 = a_11 * x_1 + a_12 * x_2 + a_13 * x_3 + ... + a_1n * x_n + b_1 dotx_2 = a_21 * x_1 + a_22

timeout for z3 solver in python

人盡茶涼 提交于 2019-12-11 10:37:21
问题 I have problems setting a timeout for my solver: s = Solver() encoding = parse_smt2_file("ex.smt2") s.add(encoding) s.set("timeout", 600) solution = s.check() but I get the following error Traceback (most recent call last): File "/Users/X/Documents/encode.py", line 145, in parse_polyedra("file") File "/Users/X/Documents/encode.py", line 108, in parse_polyedra s.set("timeout",1) File "/Users/X/z3/build/z3.py", line 5765, in set Z3_solver_set_params(self.ctx.ref(), self.solver, p.params) File "

How to correctly use Solver() command in Python API of Z3 with declared function

断了今生、忘了曾经 提交于 2019-12-11 10:22:51
问题 I'm getting unexpected results with some script using Python API of Z3. I think that I'm misunderstanding some process or simply using some command wrong. For example, suppose I have the following script: from z3 import * x = Int('x') def g(x): if x == 0: return 1 elif x > 0: return x**(x+1) s = Solver() s.add(g(x) > x) print s.check() if s.check()== sat: m = s.model() m.evaluate(x, model_completion=True) print m This will return the following output: sat [x = 0] That it's OK, but if I

Some proofs of validity using Z3Py online and a strategy proposed by Nikolaj Bjorner

限于喜欢 提交于 2019-12-11 10:06:41
问题 Lemma: forall x : R, x <> 0 -> (x / x) = 1. Proof: x = Real('x') s = Solver() s.add(Or(x >0, x < 0), Not(x/x ==1)) print s.check() and the output is : unsat Qed. Lemma: forall x y : R, x <> 0, y <> 0 -> (x / x + y / y) = 2. Proof: x, y = Reals('x y') s = Solver() s.add(Or(x >0, x < 0), Or(y >0, y < 0), Not(x/x + y/y ==2)) print s.check() and the output is: unsat Qed. Lemma: forall x y : R, x <> 0, y <> 0 -> (x / x + x / y) = ((x + y) / y). Proof: x, y = Reals('x y') s = Solver() s.add(Or(x >0

How to run Z3 in Java from SMT-Lib standard?

戏子无情 提交于 2019-12-11 09:03:51
问题 Up to now, I can run Z3 to get solution of equations in cmd on Window: z3 -smt2 path_smt_lib_file But how I can run Z3 with SMT-Lib standard input in Java. Thank in advance. 回答1: You should be able to find all you need in JavaExample.java in the folder examples/java . Check out the API. In particular, if you want to read an SMT2 file, see Context.parseSMTLIB2File(). 来源: https://stackoverflow.com/questions/30568447/how-to-run-z3-in-java-from-smt-lib-standard

Z3 JAVA-API for solver timeout

馋奶兔 提交于 2019-12-11 08:58:59
问题 How to set solver's timeout for Z3 JAVA API? Back to this question again: Here is my code: Context ctx = getZ3Context(); solver = ctx.MkSolver(); Params p = ctx.MkParams(); p.Add("timeout", 1); solver.setParameters(p); Not work, the solver just running the query forever. Any idea about this? 回答1: I haven't used the Java API, but from Looking at the official Java example and at this snippet, I'd assume that something along the following lines should work: Solver s = ctx.MkSolver(); Params p =

algebraic reals: does z3 do rounding when pretty printing?

谁说胖子不能爱 提交于 2019-12-11 08:16:24
问题 If I issue: (set-option :pp-decimal true) (set-option :pp-decimal-precision 10) Does Z3 do any rounding after the 10th digit of the real number? Or does it just chop the remaining digits without any rounding? 回答1: In Z3 4.0, an algebraic number alpha is represented using a univariate polynomial p and two binary rationals: lower and upper . A binary rational is a rational number of the form a/2^k where a is an integer and k a natural number. We have that alpha is the only root of p in the

Z3 C API manage Z3_VAR_AST

你离开我真会死。 提交于 2019-12-11 07:55:34
问题 I try to write a custom print for a Z3_ast of Z3 in C, but I do not know how to manage the Z3_ast_kind of Z3_VAR_AST and Z3_FUNC_DECL_AST, I only know how to print the Z3_sort of Z3_VAR_AST (Z3_get_sort), about this variable value I have no ideas ???. And about the Z3_FUNC_DECL_AST, I couldn't find any accessors can get the function name, number of parameters and the parameters. Could you guys please help me? Cheers 回答1: I suggest you take a look at the file 'python/z3printer.py' in the Z3

Scalability of z3

混江龙づ霸主 提交于 2019-12-11 07:48:42
问题 I would like to improve the scalability of SMT solving. I have actually implemented the incremental solving. But I would like to improve more. Any other general methods to improve it without the knowledge of the problem itself? 回答1: There's no single "trick" that can make z3 scale better for an arbitrary problem. It really depends on what the actual problem is and what sort of constraints you have. Of course, this goes for any general computing problem, but it really applies in the context of