Z3

Non-linear arithmetic and uninterpreted functions

て烟熏妆下的殇ゞ 提交于 2019-12-29 08:56:07
问题 (declare-const x Real) (declare-fun f (Real) Real) (assert (= (f 1.0) 0.0)) (assert (= (* x x) (* 1.0 1.0))) (check-sat) (get-model) I have two independent assertions one in non-linear arithmetic and other uninterpreted functions. Z3 gives a "model is not available" to the problem above. Is there a way to set the logic to something that can handle both at the same time? Thank you. 回答1: The new nonlinear solver is not integrated with other theories (arrays, unintepreted functions, bit-vectors)

Substituting function symbols in z3 formulas

僤鯓⒐⒋嵵緔 提交于 2019-12-29 08:03:45
问题 What is the best way to substitute a function symbol (with another function) in a formula? Z3py's substitute seems to only work with expressions, and what I do now is I try to guess all possible combinations of consts/vars to which the function could be applied and then substitute those with an application of another function. Is there a better way to do that? 回答1: We can implement a simple bottom-up rewriter that given a term s , a function f and term t will replace every f -application f(r

Can Z3 check the satisfiability of formulas that contain recursive functions?

大兔子大兔子 提交于 2019-12-29 07:56:19
问题 I'm trying out some of the examples of a Z3 tutorial that involve recursive functions. I've tried out the following example. Fibonacci (Section 8.3) IsNat (Section 8.3) Inductive (Section 10.5) Z3 times out on all of the above examples. But, the tutorial seems to imply that only Inductive is non-terminating. Can Z3 check the satisfiability of formulas that contain recursive functions or it cannot handle any inductive facts? 回答1: These examples from the Z3 tutorial are there to illustrate

Can Z3 check the satisfiability of formulas that contain recursive functions?

旧时模样 提交于 2019-12-29 07:56:09
问题 I'm trying out some of the examples of a Z3 tutorial that involve recursive functions. I've tried out the following example. Fibonacci (Section 8.3) IsNat (Section 8.3) Inductive (Section 10.5) Z3 times out on all of the above examples. But, the tutorial seems to imply that only Inductive is non-terminating. Can Z3 check the satisfiability of formulas that contain recursive functions or it cannot handle any inductive facts? 回答1: These examples from the Z3 tutorial are there to illustrate

Z3 Polarity using Z3 as SAT Solver

让人想犯罪 __ 提交于 2019-12-29 06:54:32
问题 I am trying to solve a SAT problem with 12000+ boolean variables using Z3. I expect that most of the variables will evaluate to false in the solution. Is there a way to guide or hint Z3 as SAT solver to try "polarity false" first? I've tried it with cryptominisat 2 and got good results. 回答1: Z3 is a collection of solvers and preprocessors. We can provide hints for some of the solvers. When the command (check-sat) is used, Z3 will select the solver automatically for us. We should (check-sat

Read func interp of a z3 array from the z3 model

柔情痞子 提交于 2019-12-28 04:20:29
问题 Suppose I have 2 arrays in a formula whose satisfiability I want to check using z3. If z3 returns sat, I want to read in the first array in the z3 model and pretty print it as a key, value pair and a default value. Later I want to convert it to a map and do further analysis on it. Here's the example I run: void find_model_example_arr() { std::cout << "find_model_example_involving_array\n"; context c; sort arr_sort = c.array_sort(c.int_sort(), c.int_sort()); expr some_array_1 = c.constant(

Are C++ parameters :logic and :timeout deprecated in Z3 unstable branch?

时光怂恿深爱的人放手 提交于 2019-12-25 09:09:14
问题 For my application code, I used the following settings for z3 params for my solver z3::params p(context); p.set(":relevancy", static_cast<unsigned>(1)); p.set(":logic", QF_ABV); p.set(":timeout", timeout); solver.set(p); After updating to latest Z# unstable I got C++ exceptions essentially stating that logic and timeout are not valid parameters. I did not find any equivalent option for logic, so I assume that is being deduced automatically. However, for timeout, there are two options soft

How to get the model value in SAT problems using c++ api?

拥有回忆 提交于 2019-12-25 07:35:59
问题 I am using c++ api of z3 to solve a sat problem. When the problem is sat, I want to get the satisfiable assignments of all the variables. I find it easy to print the value of a variable as the following code shows: context c; solver s(c); expr x=c.bool_const("x"); s.add(x); if(s.check()==sat){ model m=s.get_model(); std::cout<<"x:"<<m.eval(x); } But the question is that I need to use it in a 'if' condition statement. for example: if(m.eval(x)==true) std::cout<<"x is true"; Does anybody know

Z3 C++ API yields “unknown” while binary on serialized output yields “unsat”

a 夏天 提交于 2019-12-25 06:46:23
问题 When I build up a certain set of constraints using the Z3 C++ API I get " unknown " in response. However, if I serialize the z3::solver object using operator<<() and pass the output to the z3 binary, it yields " unsat " as expected. Interestingly enough, if I use z3::solver::to_smt2() instead of operator<<(), the Z3 binary outputs " unknown ". Why is this occurring? How can I get Z3 using the C++ API to "see" what the standalone binary "sees"? I've uploaded the serialized constraint files to

Is there a form of bitvector concat in the z3 c++ interface?

空扰寡人 提交于 2019-12-25 03:44:34
问题 The Concat() function in the z3 python interface allows you to concatenate arbitrary bit vectors. Our application is using the C++ interface, though. Is there an easy way to get the same effect with the C++ interface? I'm trying to build up an output bitvector expression out of sub-expressions. I can do it with shift and or operations, but I'd like something simpler if it exists. For example, one of the things I want to do is create a 4-bit bitvector representing the odd bits of an input 8