Z3

ord() Function or ASCII Character Code of String with Z3 Solver

让人想犯罪 __ 提交于 2021-01-29 21:32:37
问题 How can I convert a z3.String to a sequence of ASCII values? For example, here is some code that I thought would check whether the ASCII values of all the characters in the string add up to 100: import z3 def add_ascii_values(password): return sum(ord(character) for character in password) password = z3.String("password") solver = z3.Solver() ascii_sum = add_ascii_values(password) solver.add(ascii_sum == 100) print(solver.check()) print(solver.model()) Unfortunately, I get this error:

Floor and Ceiling Function implementation in Z3

余生长醉 提交于 2021-01-29 16:20:33
问题 I have tried to implement Floor and Ceiling Function as defined in the following link https://math.stackexchange.com/questions/3619044/floor-or-ceiling-function-encoding-in-first-order-logic/3619320#3619320 But Z3 query returning counterexample. Floor Function _X=Real('_X') _Y=Int('_Y') _W=Int('_W') _n=Int('_n') _Floor=Function('_Floor',RealSort(),IntSort()) .. _s.add(_X>=0) _s.add(_Y>=0) _s.add(Implies(_Floor(_X)==_Y,And(Or(_Y==_X,_Y<_X),ForAll(_W,Implies(And(_W>=0,_W<_X),And(_W ==_Y,_W<_Y))

How to use Z3 with C++

时光怂恿深爱的人放手 提交于 2021-01-29 03:13:37
问题 I want to use Z3 with C++, and I followed the installation guide - Building Z3 on Windows using Visual Studio Command Prompt. I built it successfully, then I also added the build path to the system path. However, I still got an error when I was trying to run the example.cpp file. The error says [Error] z3++.h: No such file or directory . Can anyone tell me is there any other configuration I need to do after building Z3 using Visual Studio Command Prompt successfully in order to run Z3 with c+

How to use Z3 with C++

蹲街弑〆低调 提交于 2021-01-29 03:05:36
问题 I want to use Z3 with C++, and I followed the installation guide - Building Z3 on Windows using Visual Studio Command Prompt. I built it successfully, then I also added the build path to the system path. However, I still got an error when I was trying to run the example.cpp file. The error says [Error] z3++.h: No such file or directory . Can anyone tell me is there any other configuration I need to do after building Z3 using Visual Studio Command Prompt successfully in order to run Z3 with c+

Python and Z3: integers and floating, how to manage them in the correct way?

醉酒当歌 提交于 2021-01-28 19:15:42
问题 need help with Z3 and Python...it looks I'm too dumb for this. My code: from z3 import * num1 = Int('num1') num2 = Int('num2') num3 = Int('num3') s = Solver() s.add( 2 * num1 - num2 + 0.5 * num3 == 5412.0) s.add( 2 * num1 + 3 * num2 + 4 * num3 == 28312.0) The result is the following: [num3 = 1, num1 = 5568, num2 = 5724] Which is not completely correct: the first expression actually returns 5412.5, not 5412.0. I guess it has to do with the mixed usage of "Int" with some "point numbers" (0.5).

Checking sat using check() with assumptions rises AttributeError: 'bool' object has no attribute 'as_ast'

强颜欢笑 提交于 2021-01-28 18:26:47
问题 Why this works: >>> from z3 import * >>> s = Solver() >>> s.add([True]) >>> s.check() sat but this doesn't: >>> from z3 import * >>> s = Solver() >>> s.check([True]) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "$HOME/.local/lib/python3.6/site-packages/z3/z3.py", line 6656, in check _assumptions[i] = assumptions[i].as_ast() AttributeError: 'bool' object has no attribute 'as_ast' >>> Am I missing something? I understood that it was the same operation but without

Finding BitVec weight efficently (aka access to bits of a bitvector) in z3

十年热恋 提交于 2021-01-28 12:35:50
问题 I'm currently computing the weight of bitvectors using the python api for z3. After searching through the python API for more straight forward method, I'm implementing the weight function for a bitvector st1 in the following manner: Sum([( (st1 & (2**(i)))/(2**(i)) ) for i in range(bits)]) My question is relatively straight-forward, is there an easier/more efficient way? I have problems which contain 1500+ of these weight constraints and would like to make sure I'm doing things as efficiently

Finding BitVec weight efficently (aka access to bits of a bitvector) in z3

谁说胖子不能爱 提交于 2021-01-28 12:31:59
问题 I'm currently computing the weight of bitvectors using the python api for z3. After searching through the python API for more straight forward method, I'm implementing the weight function for a bitvector st1 in the following manner: Sum([( (st1 & (2**(i)))/(2**(i)) ) for i in range(bits)]) My question is relatively straight-forward, is there an easier/more efficient way? I have problems which contain 1500+ of these weight constraints and would like to make sure I'm doing things as efficiently

Can I replay a proof in Z3?

社会主义新天地 提交于 2021-01-28 01:39:12
问题 Is it possible to have Z3 serialise a proof for some assertion, and replay the proof on later invocations instead of running a proof-search again? I know Z3 can output counter-examples for unsat , but can it provide proofs for models that are sat ? 回答1: Terminology note: Z3 (and SAT/SMT solvers in general) output models for sat , and proofs for unsat . Proof generation is actually an SMT-Lib feature. See page 56 of http://smtlib.cs.uiowa.edu/papers/smt-lib-reference-v2.6-r2017-07-18.pdf And

Why do already popped scopes affect the check-sat time in subsequent scopes?

不想你离开。 提交于 2021-01-28 00:09:58
问题 General problem I've noticed several times that push-pop scopes that have already been popped appear to affect the time that a check-sat in a subsequent scope needs. That is, assume a program with multiple (potentially arbitrarily nested) push-pop scopes, each of which contain a check-sat command. Furthermore, assume that the second check-sat takes 10s, whereas the first one takes only 0.1s. ... (push) (assert (not P)) (check-sat) ; Could be sat, unsat or unknown (pop) ... (push) (assert (not