Z3

printing internal solver formulas in z3

一笑奈何 提交于 2019-12-18 05:55:49
问题 The theorem proving tool z3 is taking a lot of time to solve a formula, which I believe it should be able to handle easily. To understand this better and possibly optimize my input to z3, I wanted to see the internal constraints that z3 generates as part of its solving process. How do I print the formula that z3 produces for its back-end solvers, when using z3 from the command line? 回答1: Z3 command line tool does not have such option. Moreover, Z3 contains several solvers and pre-processing

(get-unsat-core) returns empty in Z3

喜你入骨 提交于 2019-12-18 04:11:25
问题 I am using Z3 to extract the unsat-core of an unsatisfiable formula. I am using Z3@Rise interface (web based) to write the following code, (set-logic QF_LIA) (set-option :produce-unsat-cores true) (declare-fun ph1 () Int) (declare-fun ph1p () Int) (declare-fun ph3 () Int) (declare-fun ph3p () Int) (declare-fun ph4 () Int) (declare-fun ph4p () Int) (define-fun one () Bool (= ph3p (+ ph1 1))) (define-fun two () Bool (= ph3 (+ ph1 1))) (define-fun three () Bool (= ph1p (+ ph1 1))) (define-fun

The exact mechanism of mapping WhyML into SMT logic

纵饮孤独 提交于 2019-12-14 03:57:32
问题 Good day, auto deduction and verification hackers! In order to gain a deeper understanding of how exactly WhyML provides proofs for ACSL-annotated C programs I am trying to manually "reproduce" the job Why3 does with WhyML program while translating it into SMT logic and feeding it into Z3 prover. Lets say we have the following C fragment: const int L = 3; int a[L] = {0}; int i = 0; while (i < L) { a[i] = i; i++; } assert (a[1] == 1); I am trying to encode it into SMT logic like this: (set

Incremental SMT solver with ability to drop specific constraint

本秂侑毒 提交于 2019-12-14 03:48:33
问题 Is there an incremental SMT solver or an API for some incremental SMT solver where I can add constraints incrementally, where I can uniquely identify each constraint by some label/name? The reason I want to identify the constraints uniquely is so that I can drop them later by specifying that label/name. The need for dropping constraints is due to the fact that my earlier constraints become irrelevant with time. I see that with Z3 I cannot use the push/pop based incremental approach because it

how to get constraint of variables in Fixedpoint using z3?

喜欢而已 提交于 2019-12-14 02:32:31
问题 I wish to get the constraint of the element in the fixedpoint phi, in the following example, the constraint should be c2<=c1+5.0, c1>=5.0 it should be how to realize it in Z3? Or is there any way to do it not using fixedpoint in Z3 (set-option :produce-models true) (set-option :dl_engine 1) (set-option :dl_pdr_use_farkas true) (declare-var c1 Real) (declare-var c2 Real) (declare-var lambda Real) (declare-rel phi(Real Real)) (rule (=> (and (>= lambda 0.0) (phi c1 c2) ) (phi (+ c1 lambda) (+ c2

Z3: Is it possible to sum up a BitVec and a Real?

依然范特西╮ 提交于 2019-12-13 18:07:03
问题 I'm using Z3py to try to make some experiments on round-off error problem, it turns out that i have to sum up the a BitVec and a Real. However, when I try to do so, i get a 'sort mismatch' error. This is my code: x = BitVecVal(8, 6) y = Real('y') solve(y + x == 5) Is there a way to sum a BitVec and a Real? or just to get the Int value of BitVec? 回答1: the Z3 C based API does contain conversion functions from bit-vectors to numerals (integers) and integers can be coerced to reals. However, the

Simplifying CNF formula while preserving all solutions wrt certain variables

随声附和 提交于 2019-12-13 17:25:01
问题 Related: CNF simplification (in fact, I think the submitter of that question might have been after what I want here) A number of tools exist for simplifying (or "preprocessing" before solving) DIMACS format CNF formulas, and most SAT solvers incorporate some. However, all that I am aware of simplify a trivially satisfiable formula into a trivially satisfiable CNF with zero or one variables, i.e. they only attempt to preserve the satisfiability of the formula. I have tried at least SatELite

Get fractional part of real in QF_UFNRA

爱⌒轻易说出口 提交于 2019-12-13 13:48:52
问题 Using smtlib I would like to make something like modulo using QF_UFNRA. This disables me from using mod, to_int, to_real an such things. In the end I want to get the fractional part of z in the following code: (set-logic QF_UFNRA) (declare-fun z () Real) (declare-fun z1 () Real) (define-fun zval_1 ((x Real)) Real x ) (declare-fun zval (Real) Real) (assert (= z 1.5)); (assert (=> (and (<= 0.0 z) (< z 1.0)) (= (zval z) (zval_1 z)))) (assert (=> (>= z 1.0) (= (zval z) (zval (- z 1.0))))) (assert

Proving inductive facts in Z3

落花浮王杯 提交于 2019-12-13 13:42:12
问题 I am trying to prove an inductive fact in Z3, an SMT solver by Microsoft. I know that Z3 does not provide this functionality in general, as explained in the Z3 guide (section 8: Datatypes), but it looks like this is possible when we constrain the domain over which we want to prove the fact. Consider the following example: (declare-fun p (Int) Bool) (assert (p 0)) (assert (forall ((x Int)) (=> (and (> x 0) (<= x 20)) (= (p (- x 1)) (p x) )))) (assert (not (p 20))) (check-sat) The solver

Microsoft Z3 naming assertions

泪湿孤枕 提交于 2019-12-13 12:37:53
问题 I need to name some assertions im my z3 model so that it is able to generate unsat cores. I can do this manually like this: (assert (! (assertion) :named x)) I just need to do it using the .NET API directly. any help? 回答1: Z3 does not support this directly through the .NET API. Instead, a Boolean constant should be created (the name, e.g., x ), which can then be used to assert conditional constraints, e.g., solver.AssertAndTrack(constraint, x); The constraint is then named x and this constant