Z3

Z3 prime numbers

谁都会走 提交于 2020-01-06 04:03:50
问题 I am trying to learn z3, and this is the first program I write. In this exercise, I am trying to determine if x is prime. If x is prime, return SAT, otherwise, return UNSAT alongside with two of its factors. Here is what I have so far http://rise4fun.com/Z3/STlX My problem is I don't think the code is doing anything right now. It returns SAT for whatever I do. i.e if I assert that 7 is prime, it returns SAT, if I assert 7 is not prime, it returns SAT. I am not sure how recursion works in z3,

How to get statistics in Z3 3.2?

拥有回忆 提交于 2020-01-06 04:00:41
问题 With Z3 2.x I used the SMTLib2 command (get-info statistics) to get statistics of a Z3 run. Using Z3 3.2 I get (error "line _ column _: invalid command argument, keyword expected") for the above, and to (get-info :statistics) Z3 replies with unsupported What's the new way of getting statistics (other than the /st command-line option)? And while we're at it: The INI options page lists (set-option :STATISTICS true) as a valid option, but Z3 3.2 again replies with unsupported 回答1: (get-info :all

How to print a Z3 Set object?

橙三吉。 提交于 2020-01-06 02:15:16
问题 I have been unable to print/display a set object returned as part of a Z3 model. Consider the following example (in F#): let ctx:Context = new Context() let ASort = ctx.MkEnumSort("S",[| "A"; "B"; "C"|]) let ASetSort = ctx.MkSetSort(ASort) let xs = ctx.MkConst("xs",ASetSort) let p = mkPredDecl ctx ("p",[|ASetSort|]) let px = ctx.MkApp(p,xs) :?> BoolExpr let s = ctx.MkSolver() s.Assert (ctx.MkAnd(px, ctx.MkNot(ctx.MkEq(xs,ctx.MkEmptySet(ASort))))) assert (s.Check() = Status.SATISFIABLE) let xs

Z3 + boogie installation

柔情痞子 提交于 2020-01-05 12:00:11
问题 I am having some hard time getting the Boogie and Z3 to install on Windows 7 with Z3 version 4.3.2 from codeplex. I've tried to install it like spec# by register.cmd command in prompt, but it doesnt work. Can anyone tell me how to do it ? 回答1: Boogie does not support Z3 version 4.3. You need version 4.1 (see the Installation page on boogie.codeplex.com, which I just updated). By the way, the register.cmd thing was purely a Spec# thing. 来源: https://stackoverflow.com/questions/22474942/z3

Z3 bindings on ocaml

梦想的初衷 提交于 2020-01-05 10:33:28
问题 I am currently using ocaml 4.06.0 and I am trying to use the Z3 sat solver. I am using opam's oasis to compile the files (which is building everything successfully). However, when I run the native code produced I am getting the following error: error while loading shared libraries: libz3.so . I tried reinstalling the z3 package but the error still persists. Can anyone help me solve this please because I have no idea what else to try? 回答1: Here is what I did just now to install z3 under Ubuntu

Z3 maximization API: possible bug?

家住魔仙堡 提交于 2020-01-05 09:15:46
问题 I'm currently playing with the maximization API for Z3 (opt branch), and I've stumbled upon a following bug: Whenever I give it any unbounded problem, it simply returns me OPT and gives zero in the resulting model (e.g. maximize Real('x') with no constraints on the model). Python example: from z3 import * context = main_ctx() x = Real('x') optimize_context = Z3_mk_optimize(context.ctx) Z3_optimize_assert(context.ctx, optimize_context, (x >= 0).ast) Z3_optimize_maximize(context.ctx, optimize

z3 and interpretation of floating point coefficients

六眼飞鱼酱① 提交于 2020-01-05 05:44:12
问题 I was playing with a small multi-objective integer programming problem: In Z3 (using the Python bindings) we can state this very elegantly: from z3 import * x1,x2 = Ints('x1 x2') z1,z2 = Reals('z1 z2') opt = Optimize() opt.set(priority='pareto') opt.add(x1 >= 0, x2 >=0, x1 <= 2, x2 <= 2) opt.add(x1 <= 2*x2) # this version is ok: # opt.add(z1 == x1 - 2*x2, z2 == -x1 + 3*x2) # this truncates coefficients (round down to integer): # opt.add(z1 == 0.5*x1 - 1.0*x2, z2 == -0.5*x1 + 1.5*x2) # this

Generic bitvector type of any length

丶灬走出姿态 提交于 2020-01-04 08:12:46
问题 For the same reasons than described here (user defined uninterpreted function) I want to define my own uninterpreted function bvredxnor() : xnor over the bits of a given bitvector. If I follow the example given here (example of universal quantifiers with C API) I don't know what sort to provide to the argument of my function (a bitvector) I could create a bitvector sort of a given length, but I would like to have it for bitvectors of any length. Looking at bitvector functions available in the

Incorrect model of max value in Z3Py

可紊 提交于 2020-01-04 05:43:30
问题 I want to find a maximal interval in which an expression e is true for all x. A way to write such a formula should be: Exists d : ForAll x in (-d,d) . e and ForAll x not in (-d,d) . !e . To get such a d , the formula f in Z3 (looking at the one above) could be the following: from __future__ import division from z3 import * x = Real('x') delta = Real('d') s = Solver() e = And(1/10000*x**2 > 0, 1/5000*x**3 + -1/5000*x**2 < 0) f = ForAll(x, And(Implies(And(delta > 0, -delta < x, x < delta, x !=

(Z3Py) any limitations in functions declaring?

泄露秘密 提交于 2020-01-03 20:16:49
问题 Is there any limitations in functions declaring? For example, this piece of code returning unsat. from z3 import * def one_op (op, arg1, arg2): if op==1: return arg1*arg2 if op==2: return arg1-arg2 if op==3: return arg1+arg2 return arg1+arg2 # default s=Solver() arg1, arg2, result, unk_op=Ints ('arg1 arg2 result unk_op') s.add (unk_op>=1, unk_op<=3) s.add (arg1==1) s.add (arg2==2) s.add (result==3) s.add (one_op(unk_op, arg1, arg2)==result) print s.check() How Z3Py interpret declared function