Z3

max element in Z3 Seq Int

拥有回忆 提交于 2020-01-16 09:43:06
问题 I'm trying to write a max function that operates on Seq Int . It should return the index with maximal value . Here is what I have: (declare-fun max ((Seq Int)) Int) (assert (forall ((A (Seq Int))) (=> (> (seq.len A) 0) (and (<= 0 (max A)) (< (max A) (seq.len A)) (forall ((i Int)) (=> (and (<= 0 i) (< i (seq.len A))) (<= (seq.nth A i) (seq.nth A (max A)))))))) ) (assert (= (max (seq.++ (seq.unit 8) (seq.unit 3))) 0)) ;(assert (= (max (seq.++ (seq.unit 8) (seq.unit 3))) 1)) (check-sat) When I

Is there any difference between Z3 versions 2.19 and 3.2 w.r.t. SMTLIB-2 code syntax?

若如初见. 提交于 2020-01-16 00:55:17
问题 After installing Z3 V3.1, following SMT-LIB code is not working. It was quite good in my earlier version (Z3 V2.19). (define-fun getIP ((o0 Int) (o1 Int) (o2 Int) (o3 Int)) BitVec[32] (bvor (bvshl (int2bv[32] o0) (int2bv[32] 24)) (bvshl (int2bv[32] o1) (int2bv[32] 16)))) (declare-funs ((dip BitVec[32]) (m BitVec[32]))) (declare-funs ((s Bool) (d Bool) (y Int) (z Int))) (declare-funs ((r0 Bool) (r1 Bool) (f Bool))) (declare-funs ((r0do0 Int) (r0do1 Int) (r0do2 Int) (r0do3 Int) (r0m Int) (r0nh

Substitution in Z3 java

左心房为你撑大大i 提交于 2020-01-15 12:24:08
问题 Noticed that when call substitution in z3, it always simplifies the expression, but in our project, it is necessary to just substitute and keep the original structure. According to the following post, such feature will be fixed, wonder if it is already there? Or if there's any way to turn the simplification off? substitution in Z3Py 回答1: Yes, this problem has been fixed in the unstable branch (see here); this should now behave exactly as expected. 来源: https://stackoverflow.com/questions

Substitution in Z3 java

泄露秘密 提交于 2020-01-15 12:24:08
问题 Noticed that when call substitution in z3, it always simplifies the expression, but in our project, it is necessary to just substitute and keep the original structure. According to the following post, such feature will be fixed, wonder if it is already there? Or if there's any way to turn the simplification off? substitution in Z3Py 回答1: Yes, this problem has been fixed in the unstable branch (see here); this should now behave exactly as expected. 来源: https://stackoverflow.com/questions

Getting the smaller model for a SMT formula

走远了吗. 提交于 2020-01-15 10:09:34
问题 Let say that I have some formulas that can be sat but I want to get the smaller (or larger) possible value so sat that formula. Is there a way to tell the SMT solver to give that kind of small solution? Example: a+1>10 In that example I want the SMT solver to give me the solution 10 instead of 100. Cheers NOTE: I have just seen a similar question answered by one of the z3 authors saying, three years ago, that they were implementing that functionality in z3. Do you know if it is already

Statistics in Z3

谁说胖子不能爱 提交于 2020-01-15 07:36:44
问题 I am using Java API of Z3 and I would like to get some statistics from the solver such as solving time, number of variables/symbols, memory usage. The post here (Z3py: how to get the list of variables from a formula?) claims that there is a utility implementation in Python but I was wondering if there is any for JavaAPI. Thanks. 回答1: Those particular utilities are an external contribution to Z3 and only available for the Python API. It should be possible to follow the same ideas in Java

Label on SMT-LIB 2.0 assertions in z3

南楼画角 提交于 2020-01-15 05:24:29
问题 Could you tell me how to name assertions in a z3 SMT-LIB 2.0 benchmark? I would prefer to use the standard syntax of SMT-LIB, but as z3 seems not to understand it, I'm just looking for one working with z3. The need is to get unsat cores with labels. Here is an example of benchmark I tested: (set-option enable-cores) (set-logic AUFLIA) (declare-fun x () Int) (declare-fun y () Int) (declare-fun z () Int) (assert (! (<= 0 x) :named hyp1)) (assert (! (<= 0 y) :named hyp2)) (assert (! (<= 0 z)

java的mock测试框架

自闭症网瘾萝莉.ら 提交于 2020-01-14 07:24:01
  在做单元测试的时候,有的时候用到的一些类,我们构造起来不是那么容易,比如HttpRequest,或者说某个Service依赖到了某个Dao,想构造service还得先构造dao,这些外部对象构造起来比较麻烦。 所以出现了Mock! 我们可以用 Mock 工具来模拟这些外部对象,来完成我们的单元测试。   实现Mock技术的优秀开源框架有很多,下面以Mockito为例,用几个简单例子来介绍Mock工具的基本使用: 1.Mockito的第一个示例 1 @Test 2 public void simpleTest(){ 3 4 //创建mock对象,参数可以是类,也可以是接口 5 List<String> list = Mockito.mock(List.class); 6 7 //设置方法的预期返回值 (如果list.get(0) 被调用 ,调用之后返回 helloworld) 8 //当然前提是要创建了Mock对象,如这里就是创建了跟 List相关的 Mock对象 9 //这里还看不出什么作用,因为Mock 还看不出来,List很容易就能创建 10 //假如是一个很复杂的对象,构造这样一个对象很有难度,使用Mock就很方便了,我们不用去一步一步填充它的属性去构造, 11 //只需要Mock 一下,就可以拿到这个对象,去测试它的方法,(当然,如果方法有参数我们是需要传递的,像get

parthood definition in Z3

女生的网名这么多〃 提交于 2020-01-14 02:53:06
问题 I'm trying to define in Z3 the parthood relation (called C in the code below) between pairs of sets (defined using array). I wrote 3 asserts to define reflexivity, transitivity, and antisymmetry but Z3 returns "unknown" and I don't understand why. (define-sort Set () (Array Int Bool)) (declare-rel C (Set Set)) ; reflexivity (assert (forall ((X Set)) (C X X))) ; transitive (assert (forall ((X Set)(Y Set)(Z Set)) (=> (and (C X Y) (C Y Z)) (C X Z) ) )) ; antisymmetric (assert (forall ((X Set)(Y

Issues with utilizing Z3 for MAX-SAT

陌路散爱 提交于 2020-01-13 17:57:08
问题 I am interested in MAX-SAT and was hoping Z3 would have this as a built-in feature. Are there any plans to do this in the near future? In the absence of the above, I have tried using the example maxsat application from the command line. Unfortunately, whenever I do exec.sh "filename.z3", I always get the following response: "checking whether hard constraints are satisfiable...result: 0". What am I doing wrong? I assure you that this response appears to be quite independent of the actual