z3py

How get a a value from a Lambda expression?

家住魔仙堡 提交于 2019-12-20 02:02:28
问题 I'm experimenting with z3 in python. I have the following model: (set-option :produce-models true) (set-logic QF_AUFBV ) (declare-fun a () (Array (_ BitVec 32) (_ BitVec 8) ) ) (declare-fun another () (Array (_ BitVec 32) (_ BitVec 8) ) ) (assert (and (= false (= (_ bv77 32) (concat (select a (_ bv3 32) ) (concat (select a (_ bv2 32) ) (concat (select a (_ bv1 32) ) (select a (_ bv0 32) ) ) ) ) ) ) (= false (= (_ bv12 32) (concat (select another (_ bv3 32) ) (concat (select another (_ bv2 32)

Cyclic relation in Datalog using SMTLib for z3

帅比萌擦擦* 提交于 2019-12-13 10:36:07
问题 I would like to express this problem in the SMTLib Format and evaluate it using Z3. edge("som1","som3"). edge("som2","som4"). edge("som4","som1"). edge("som3","som4"). path(x,y) :- edge(x,y). % x and y are strings path(x,z) :- edge(x,y), path(y,z). :- path(x,y), path(y,x). %cyclic path. My question is how to write the rule (or query) which detect the existence of a cycle in the relation path (this rule in basic datalog : :- path(x,y), path(y,x) ). 回答1: The tutorial Levent Erkok pointed out

Extending `z3` with one way functions

喜夏-厌秋 提交于 2019-12-13 04:39:44
问题 I'm looking to use a one-way function in a z3 Python program. I'd like z3 to respect the following properties/tactics: if x = y , then f(x) = f(y) f is a computable Python function that I can provide when x is known if f(x) = y , attempt to resolve by matching f(*y) = f(x) implying x = *y from prior assignments (never attempt to guess x that computes to y ) Are there built in features to support this construct or anything else that may help introduce it? 来源: https://stackoverflow.com

Saving the “state” of a Z3 solver in SMT2 format

℡╲_俬逩灬. 提交于 2019-12-12 17:26:03
问题 is it possible, using the Z3 API (e.g. the Python API), to save the current state of a solver, including what the solver has learned (in SAT solving we would say the "learned clauses") in a file in SMT2 format? Because I would like to be able to save the state of the solver in a temporary file in order to resume solving later, in order to have some time to understand what further queries I should make to it. Many thanks in advance... 回答1: SMT2 has no provisions of saving a given solvers state

How can I solve minimizing constraint in Z3?

不想你离开。 提交于 2019-12-12 12:38:01
问题 Could any one can tell me how I can implement minimizing integer problem like the below one by Z3py? How can I define for all statement? Here all variables are int sort. Is there any dedicated solver within Z3 is available to solve such kind of problem? If there any, then how can I set configuration for that solver? Thanks 回答1: Here are some relevant/similar questions and answers: Minimum and maximum value of variable Determine upper/lower bound for variables in an arbitrary propositional

Simplify function interpretation in model

↘锁芯ラ 提交于 2019-12-12 03:36:25
问题 In SMT: check uniqueness and totality of function I gave a function axiomatization and asked Z3 for a model. However because solving something with quantifiers in it is undecidable in general, Z3 times out. Here is a modified version in which the "int" case is modelled as a single value: (declare-datatypes () ((ABC int error none))) (declare-fun f (ABC ABC) ABC) (assert (forall ((x ABC)) (=> (or (= x int) (= x error) (= x none)) (= (f none x) none)))) (assert (forall ((x ABC)) (=> (or (= x

Z3py SMT coding following variables and the formulas

Deadly 提交于 2019-12-12 03:35:36
问题 I am really new to Z3 and SMT solvers. I have the following problem which I don't know how to code in Z3py. In the above diagram N is set of nodes, thus N = {Node1, Node2, Node3, Node4, Node5, Node6, Node7} I is set of Inputs, I = {I 1 , I 2 , I 3 , I 4 } O is set of Outputs, O = {O 1 , O 2 , O 3 } G is a group where for any consecutive 2 outputs (O i , O j ), if O i is first output generated and O j is second output generated then, G k is set of nodes that were scheduled after the generation

How to declare constraints with variable as array index in Z3Py?

江枫思渺然 提交于 2019-12-12 02:08:22
问题 Suppose x,y,z are int variables and A is a matrix, I want to express a constraint like: z == A[x][y] However this leads to an error: TypeError: object cannot be interpreted as an index What would be the correct way to do this? ======================= A specific example: I want to select 2 items with the best combination score, where the score is given by the value of each item and a bonus on the selection pair. For example, for 3 items: a, b, c with related value [1,2,1], and the bonus on

Get the corresponding python variable name of a Z3 model name

徘徊边缘 提交于 2019-12-11 17:23:15
问题 Is there a way to get the corresponding python variable name of a z3 model name? Suppose I have the following code: from z3 import * s = Solver() a = [Real('a_%s' % k) for k in range(10)] for i in range(10): s.add(a[i] > 10) s.check() m = s.model() for d in m: print(d, m[d]) Here the d in m are a_0, a_1, a_2,..., a_9 , and all of their values are 11 . I'm trying to set up some constraints which make the variables don't equal to the previous checking result, like the following: s.add(a[0] != m

(Sub)optimal way to get a legit range info when using a SMT constraint with Z3

拈花ヽ惹草 提交于 2019-12-11 13:34:47
问题 This question is related to my previous question Is it possible to get a legit range info when using a SMT constraint with Z3 So it seems that "efficiently" finding the maximum range info is not proper, given typical 32-bit vectors and so on. But on the other hand, I am thinking whether it is feasible to find certain "sub-maximum" range info, which hopefully becomes more efficient. Another thing is that we may want to have certain "safe" guarantee, say for all elements in the sub-maximum