Z3

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

getting new unsat cores

孤街浪徒 提交于 2019-12-13 09:46:07
问题 there I am trying to extract clause from formulas and change one clause's polarity every time, if is solved sat, computing models and put the clause in the set. If it is solved unsat, then find out new unsat cores. But incrementally calling unsat core function, even it's solved unsat, the solver cannot give the new unsat cores. The codes as below: context c; expr x = c.int_const("x"); expr y = c.int_const("y"); solver s(c); expr F = x + y > 10 && x + y < 6 && y < 5 && x > 0; assert(F.is_app()

What is the most efficient way to encode pseudoboolean constraints in z3?

拟墨画扇 提交于 2019-12-13 06:01:43
问题 I think there's two different relevant cases here: Case 1: I have a set of boolean variables and I want another boolean variable which is true if any of these variables are true. I'm currently doing this by making the boolean variables integers which are then set using expressions of the form: (ite (boolean_expr) 1 0) I then set the overall boolean just using a sum and a greater than (> (+ b1 b2 b3...) 0) Case 2 (this may not really be pseudoboolean): I have two sets of boolean variables:

How to prove that the Z3 group satisfies the associative law using Z3-SMT-LIB

血红的双手。 提交于 2019-12-13 05:11:57
问题 I am trying to prove that the Z3 group satisfies the associative law using the following Z3-SMT-LIB code (set-option :mbqi true) (declare-sort S) (declare-fun f (S S) S) (declare-const a S) (declare-const b S) (declare-const c S) (assert (forall ((x S) (y S)) (= (f x y) (f y x)))) (assert (forall ((x S)) (= (f x a) x))) (assert (= (f b b) c)) (assert (= (f b c) a)) (assert (= (f c c) b)) (check-sat) (get-model) (declare-fun x () S) (declare-fun y () S) (declare-fun z () S) (assert (not (=>

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

Z3 java binding error: “The operating system cannot run %1”

混江龙づ霸主 提交于 2019-12-13 04:25:51
问题 When I run Z3's JavaExample.java to test the java bindings, I get the following error: Exception in thread "main" java.lang.UnsatisfiedLinkError:Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\git\z3\build\libz3java.dll: The operating system cannot run %1 at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1854) at java.lang.Runtime.loadLibrary0(Runtime.java

Z3 Java API - get unsat core

不羁岁月 提交于 2019-12-13 03:59:21
问题 I am trying to figure out how to get the unsat core using the Java API for Z3. Our scenario is as follows (code is underneath, which works in rise4fun): We create the SMT2 input programtically The input contains function definitions, datatype declarations, and assertions We parse this using the parseSMTLIB2String API We ensure that the context and the solver have unsat_core -> true Z3 returns UNSAT for the provided input, which is correct The UNSAT core is always empty though. The same input

Creating List in z3 using function

不想你离开。 提交于 2019-12-13 02:49:51
问题 I'm trying to convert this piece of pseudocode to SMT-LIB language, but I got stuck. List function my_fun(int x) { list = nil for(i in 1 to x): if(some_condition_on_i) list.concat(i) return list } what I've done so far is this: (declare-const l1 (List Int)) (define-fun my_fun ((x Int)) (List Int) (forall ((t Int)) (ite (and (some_condition_on_t) (< t x)) (insert t l1) l1 ) ) ) ) which I know it is wrong, and does not work. can you help me to understand how can I do this? 回答1: SMT-LIB models

Why does Z3 return unknown for this nonlinear integer arithmetic example?

时光毁灭记忆、已成空白 提交于 2019-12-13 02:37:47
问题 I have a simple example in nonlinear integer arithmetic, namely a search for Pythagorean triples. Based on what I read in related questions (see below), I'd expect Z3 to find a solution to this problem, but it returns 'unknown'. Here is the example in SMT-LIB v2: (declare-fun x () Int) (declare-fun y () Int) (declare-fun z () Int) (declare-fun xSquared () Int) (declare-fun ySquared () Int) (declare-fun zSquared () Int) (declare-fun xSquaredPlusYSquared () Int) (assert (= xSquared (* x x)))