51582

how to convert z3py expression to smtlib 2 format

Question:

My question is related to: <a href="https://stackoverflow.com/questions/14628279/z3-convert-z3py-expression-to-smt-lib2" rel="nofollow">Z3: convert Z3py expression to SMT-LIB2?</a>

I am trying to convert z3py expression from to smtlib2 format. using following script, but after conversion when I am feeding the result to z3 or any other SMT, I get:

<blockquote>

"Syntax error, unexpected let"

</blockquote>

Is there any way that I can bring it in the smtlib2 format using z3py so that I dont have to write long expression again.

Following is the code which I am using for conversion:

def convertor(f, status="unknown", name="benchmark", logic=""): v = (Ast * 0)() if isinstance(f, Solver): a = f.assertions() if len(a) == 0: f = BoolVal(True) else: f = And(*a) return Z3_benchmark_to_smtlib_string(f.ctx_ref(), name, logic, status, "", 0, v, f.as_ast()) x = Int('x') y = Int('y') s = Solver() s.add(x > 0) s.add( x < 100000) s.add(x==2*y) print convertor(s, logic="QF_LIA")

and this is the output:

(set-info :status unknown) (set-logic QF_LIA) (declare-fun y () Int) (declare-fun x () Int) (let (($x34 (= x (* 2 y)))) (let (($x31 (< x 100000))) (let (($x10 (> x 0))) (let (($x35 (and $x10 $x31 $x34))) (assert $x35))))) (check-sat)

Answer1:

This is also related to another question <a href="https://stackoverflow.com/questions/14775122/z3-convert-z3py-expression-to-smt-lib2-from-solver-object?lq=1" rel="nofollow">here</a>.

Most likely, this problem is because of an outdated version of Z3. There have been numerous bugfixes which haven't made it into the master branch yet and using the unstable branch (or the precompiled nightly binaries <a href="http://z3.codeplex.com/releases/view/101914" rel="nofollow">here</a>) I get a different output, which is accepted by Z3 without errors:

(set-info :status unknown) (set-logic QF_LIA) (declare-fun y () Int) (declare-fun x () Int) (assert (let (($x34 (= x (* 2 y)))) (let (($x31 (< x 100000))) (let (($x10 (> x 0))) (and $x10 $x31 $x34))))) (check-sat)

Recommend

  • where to place my script tag before closing of or after it [duplicate]
  • CSS: Can I select data value greater than?
  • HereMaps - These credentials do not authorize access. Can't get valid response for Public Trans
  • elementRef.style.top = “100px” doesn't work
  • Macro calling a function works in interpreter, fails in compiler (SBCL + CMUCL)
  • How to track database changes dynamically using spring?
  • get difference between 3 lists
  • EF6 MySql: Update-Database -Script generates SQL without semicolon
  • Inheritance and lazy loading in NHibernate
  • php using msaccess
  • Cycle R,G,B vales as HUE?
  • query a json key in postgres json field
  • Spring + Tiles2 - put-attribute from model?
  • Why is this Animatable property being set again?
  • iOS - open another application that exists on the phone?
  • Webdriver 3.14 IE11: session lost when click link/button that opens a window/popup
  • Bazel failed to include a external static library .a
  • Google Apps Script fails to generate image from EmbeddedChartBuilder
  • Jekyll - How do I create pages in the root directory?
  • android : speech recognition what are the technologies available
  • Unable to connect to AWS RDS through PDO
  • Is possible having two COM STA instances of the same component?
  • How to find angle formed by the blades of a wind turbine with respect to a horizontal imaginary axis
  • Checking for valid enum types from protobufs
  • Add checkbox dynamically using angular 2
  • Java Collections.shuffle() weird behaviour [closed]
  • Controller or RestController
  • how to run a different select statement based on condition in Hive SQL
  • How convert html to BBcode in C#
  • Support of :after in IE7
  • Terminal run dalvikvm with am.jar
  • `$http:badreq Bad Request Configuration` - from angular post method, what is wrong here?
  • How to handle div that is created dynamically in a table
  • Make checkout phone field optional for specific countries in WooCommerce
  • ReferenceError: TextEncoder is not defined