Z3

Z3: eliminate don't care variables

梦想的初衷 提交于 2019-12-25 03:27:47
问题 I have a test.smt2 file: (set-logic QF_IDL) (declare-const a Int) (declare-const b Int) (declare-const c Int) (assert (or (< a 2) (< b 2 )) ) (check-sat) (get-model) (exit) Is there anyway to tell Z3 to only output a=1 (or b=1)? Because when a is 1, b's value does not matter any more. I executed z3 smt.relevancy=2 -smt2 test.smt2 (following How do I get Z3 to return minimal model?, although smt.relevancy seems has default value 2), but it still outputs: sat (model (define-fun b () Int 2)

Z3 support for square root

百般思念 提交于 2019-12-25 02:55:21
问题 I've been searching the square root functionality provided by z3. For example, for adding a constraint about a Real number x , that x*x = 2, what is the best way to encode that? I tried: (declare-const x Real) (assert (= 2 (* x x))) (check-sat) The result is unknown. The model is also, unavailable. However, I am sure there should be a way to satisfy this. I am referring strictly to the extended version of smt-lib 2.0 language and not the python api. 回答1: You need to use the nonlinear solver.

Optimizing a Multiplication and Division

二次信任 提交于 2019-12-24 20:18:14
问题 I set up a few boundaries/constraints and wanted to solve them, however when I use the functions multiplication and division the optimisation is not as it should be in my opinion. Here is my Code: import com.microsoft.z3.*; import java.util.*; System.setProperty( "java.library.path", "/local/Programs/z3-4.6.0-x64-osx-10.11.6/bin/" ); //set sys_paths to null final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths"); sysPathsField.setAccessible(true); sysPathsField.set(null,

Can Z3 output “anything” for unconstrained values of UF?

不打扰是莪最后的温柔 提交于 2019-12-24 18:06:26
问题 Some values of uninterpreted functions can be unconstrained during the search. For example, if in smt query only f(1) is called, then f(2) , f(3) can be anything. Is there a way (some option may be) to know which values were not used during the solving and therefore can be anything? 回答1: For quantifier free problems, you can achieve that by using the option :model-partial to true . Here is an example (also available here): (set-option :model-partial true) (declare-fun f (Int) Int) (assert (>

z3 timeout on linux/mac

十年热恋 提交于 2019-12-24 17:50:02
问题 Hi Leonardo: Looks like z3 (v3.2) accepts the command line switch "-T:10" for specifying time-outs on Mac and Linux, but ignores it. (Haven't tried on windows.) It'd be really nice if timeouts were supported on linux/mac releases as well. 回答1: Yes, the -T switch is Windows only in Z3 3.2. This will be fixed in the next release. 来源: https://stackoverflow.com/questions/9273091/z3-timeout-on-linux-mac

z3 timeout on linux/mac

时光毁灭记忆、已成空白 提交于 2019-12-24 17:49:47
问题 Hi Leonardo: Looks like z3 (v3.2) accepts the command line switch "-T:10" for specifying time-outs on Mac and Linux, but ignores it. (Haven't tried on windows.) It'd be really nice if timeouts were supported on linux/mac releases as well. 回答1: Yes, the -T switch is Windows only in Z3 3.2. This will be fixed in the next release. 来源: https://stackoverflow.com/questions/9273091/z3-timeout-on-linux-mac

Creating a transitive and not reflexive function in Z3

橙三吉。 提交于 2019-12-24 17:43:30
问题 I'm trying to create a function in Z3 that is transitive but not reflexive. I.e. if (transitive a b) and (transitive b c) hold then (transitive a c) should hold, but (transitive a a) should not. I've tried to do it the following way, with 5 "tests". The first does what I expect, but the second one fails and results in unknown . (declare-datatypes () ((T T1 T2 T3))) (declare-fun f (T T) Bool) (assert(f T1 T2)) (assert(f T2 T3)) ; Make sure that f is not reflexive (assert (forall ((x T)) (not

Equal lists are permutations of one another. Why does Z3 answer 'unknown'?

孤街浪徒 提交于 2019-12-24 15:33:16
问题 I am trying to verify a sorting algorithm and decided to model lists from the programming language as tuples of (size as Int, contents as Array Int -> Obj) and called them MyList. Then I came accross the following problem: l0 and l1 are such MyLists. When asked (assert (not (permutation l0 l0))) , Z3 answers unsat quickly. When asked (assert (not (permutation l1 l1))) , Z3 answers unsat quickly. But when I ask for (assert (= l1 l0)) (assert (not (permutation l1 l0))) It answers unknown after

Goal Unsupported by Tactic

放肆的年华 提交于 2019-12-24 14:58:57
问题 I have some code, which I want to check with help of some tactics. Since I have lot of if-then-else statements, I want to apply elim-term-ite tactic. I have made use of following tactics (check-sat-using (then (! simplify :arith-lhs true) elim-term-ite solve-eqs lia2pb pb2bv bit-blast sat)) However, if I an error with this as - "goal is in a fragment unsupported by lia2pb" So then, if I try to remove the tactics lia2pb and the ones next to them, I get another error as unknown "incomplete" . I

Parse SMT-LIB2 String using Declarations in Existing Context

我与影子孤独终老i 提交于 2019-12-24 14:08:36
问题 I have an existing Z3 4.1 context created in the .NET API, with many function declarations, sort declarations, assumptions asserted, etc. What is the cleanest way to parse an SMT-LIB2 string using all the existing declarations in this context? Specifically, is there a way to iterate over all the declarations in a context? I did not see any methods in Context that would allow me to access the declarations. Currently, I am doing the following: Context z3 = new Context(); // ... declare sorts,