Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>parseSMTLIB2[...]</code> methods should indeed have returned a <code>Z3AST</code>, thanks for reporting the problem. This is fixed in <a href="https://github.com/downloads/psuter/ScalaZ3/scalaz3-3.2.b.jar" rel="nofollow">scalaz3-3.2.b.jar</a>. Now regarding the use of the SMT-LIB 2 parser, I'm myself new to this, so Leo should perhaps confirm, but my understanding is that you should only use it to parse formulas, not to issue commands such as <code>(check-sat)</code>.</p> <p>Here is an example that works for me:</p> <pre><code>import z3.scala._ val smtlib2String = """ (declare-fun x () bool) (declare-fun y () bool) (assert (= x y)) (assert (= x true))""" val ctx = new Z3Context("MODEL" -&gt; true) val assertions = ctx.parseSMTLIB2String(smtlib2String) println(assertions) // prints "(and (= x y) (= x true))" ctx.assertCnstr(assertions) println(ctx.checkAndGetModel._1) // prints "Some(true)", i.e. SAT </code></pre> <p>Now if you want to programmatically recover the model for <code>x</code>, my understanding is that the only way to do it is to create a symbol for <code>x</code> <em>before</em> parsing and to pass it to the parser, using the overloaded definition of the <code>parseSMTLIB2[...]</code> method. Here is how you do it:</p> <pre><code>val ctx = new Z3Context("MODEL" -&gt; true) val xSym = ctx.mkStringSymbol("x") // should be the same symbol as in the SMT-LIB string val assertions = ctx.parseSMTLIB2String(smtlib2String, Map(xSym -&gt; ctx.mkBoolSort), Map.empty) ctx.assertCnstr(assertions) val model = ctx.checkAndGetModel._2 val xTree = ctx.mkConst(xSym, ctx.mkBoolSort) // need a tree to evaluate using the model println(model.evalAs[Boolean](xTree)) // prints "Some(true)" </code></pre> <p>Hope this helps.</p> <p>(Again, there may be a simpler way to do this, but I'm not aware of it. The parsing methods are directly bound to their C equivalent and the <a href="http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi__ex.html#ga748ec8e9525340e9237dee62cd589672" rel="nofollow">only example I could find</a> doesn't show much.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload