Z3

Declare symbols that remain valid outside their scope

只谈情不闲聊 提交于 2019-12-10 22:25:35
问题 Z3 2.x had the feature (well, probably rather the bug) that symbol declarations were not popped away, e.g. the following code is accepted by Z3 2.x: (push) (declare-fun x () Int) ; Assumptions made in this scope will be popped correctly (pop) (assert (= x x)) Z3 3.x no longer accepts this code ("unknown constant"). Is there a way to restore the old behaviour? Or another way how one could declare symbols inside scopes such that the declaration (and only the declaration, not the assumptions) is

What is the theory behind Z3 Optimize maximum and minimum functionality?

半城伤御伤魂 提交于 2019-12-10 21:06:31
问题 I am writing to inquire the theory/algorithm behind the Z3 Optimize function, especially for its maximum and minimum function. This seems pretty magic to me. Is it somehow a binary search or so? How can it efficiently figure out the max/min value here..? I tried to search for the source code of the related functions (e.g., the execute_min_max function), but without a deep understanding about the terms there, it does not make too much sense to me... Basically what does lex stand for here? It

What is the unit of memory usage in Z3 statistics?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 20:27:55
问题 What is the unit in which memory usage is measured in z3 statistics? Is it MB or KB? And what does the memory exactly means? Is it the maximum memory usage or the aggregate sum of all allocations during the execution? 回答1: It's an approximation of the maximum heap size during execution and it is added to the statistics object through the following function in cmd_context.cpp: void cmd_context::display_statistics(...) { statistics st; ... unsigned long long mem = memory::get_max_used_memory();

Why operators '/' and 'div' in Z3 give different results?

只谈情不闲聊 提交于 2019-12-10 19:39:06
问题 I was trying to represent a real number with two integer numbers as using them as the numerator and the denominator of the real number. I wrote the following program: (declare-const a Int) (declare-const b Int) (declare-const f Real) (assert (= f (/ a b))) (assert (= f 0.5)) (assert (> b 2)) (assert (> b a)) (check-sat) (get-model) The program returned SAT result as follows: sat (model (define-fun f () Real (/ 1.0 2.0)) (define-fun b () Int 4) (define-fun a () Int 2) ) However, if I write '

Why is Z3 slow for tiny search space?

纵饮孤独 提交于 2019-12-10 19:34:42
问题 I'm trying to make a Z3 program (in Python) that generates boolean circuits that do certain tasks (e.g. adding two n-bit numbers) but the performance is terrible to the point where a brute-force search of the entire solution space would be faster. This is my first time using Z3 so I could be doing something that impacts my performance, but my code seems fine. The following is copied from my code here: from z3 import * BITLEN = 1 # Number of bits in input STEPS = 1 # How many steps to take (e

Z3 : strange behavior with non linear arithmetic

孤者浪人 提交于 2019-12-10 19:24:19
问题 I am just starting to use Z3 (v4.4.0), and I wanted to try one of the tutorial examples : (declare-const a Int) (assert (> (* a a) 3)) (check-sat) (get-model) (echo "Z3 will fail in the next example...") (declare-const b Real) (declare-const c Real) (assert (= (+ (* b b b) (* b c)) 3.0)) (check-sat) As said, the second example fails with "unknown", and by increasing the verbose level (to 3) I think I understand why : some problem with the simplifying process, then the tactic fails. In order

Z3 to show that if a^3=x*y*z then 3a <= x+y+z

我与影子孤独终老i 提交于 2019-12-10 19:19:10
问题 I'm a total newbie with Z3 (started today). So far liking it a lot. Great tool. Unfortunately the syntax confuses me a bit. I want to prove that if: a^3 = x y z = m ( with a, x, y, z, m (0..1) ) then: 3a <= (x+y+z) I do so by trying to find a model satisfying that: 3a > (x+y+z) Here is the Z3 code: (declare-const a Real) (declare-const x Real) (declare-const y Real) (declare-const z Real) (declare-const m Real) (assert (> a 0)) (assert (< a 1)) (assert (> x 0)) (assert (< x 1)) (assert (> y 0

Installation of Z3 on a posix system without python?

两盒软妹~` 提交于 2019-12-10 17:55:30
问题 Is it possible to get Z3 running on a system providing posix API without having python installed? I have seen the new version 4.3 uses python already in the build-process (scripts/mk_make.py). Whats about older versions like 4.1? Is it imaginable to get it to run on posix without python? 回答1: Is Python not available in your system? Python was always used to automatically generate some parts of the Z3 code base. In the first source code release, we have included the automatically generated

Z3 set default value of array to zero

走远了吗. 提交于 2019-12-10 17:47:55
问题 I am trying to solve models for array expressions, where default values for array is equal to 0. For example, I am trying to solve this example, but I get unknown results all the time (declare-const arr (Array Int Int)) (declare-const arr2 (Array Int Int)) (declare-const a Int) (declare-const b Int) (assert (forall ((x Int)) (= (select arr x) 0))) (assert (> a 0)) (assert (<= a 10)) (assert (= arr2 (store arr a 1337))) (assert (> b 0)) (assert (<= b 10)) (assert (= (select arr2 b) 0)) (check

Encoding “at-most-k / at-least-k booleans are true” constraints in Z3

不羁的心 提交于 2019-12-10 17:24:01
问题 What's a good way to encode "at least k / at most k of these boolean variables must be true" constraints in Z3, for arbitrary k and number of boolean variables? I'm thinking of casting "at least k " as a pseudo-boolean problem by introducing new PB variables (using this encoding), relating them to my boolean variables through a biconditional (e.g. x == true iff y == 1 ), and asserting that their sum is greater than or equal to k . Is this a reasonable approach, or is there a simpler / more