There are some API examples in the source distribution that might help you. In particular, examples/api/combination.cpp creates some functions and predicates and makes some assertions: https://github.com/CVC4/CVC4/blob/master/examples/api/combination.cpp In your case, you'll create a predicate type with ExprManager::mkFunctionType(), then you construct an "isblue" predicate with ExprManager::mkVar() giving it that type. It will...

SMT solvers have extra overhead because of theory solvers. In CVC4, you can avoid this by using the following commands: (set-logic QF_UF) (set-info :cvc4-logic QF_SAT) instead of (set-logic QF_UF) Note that this is a CVC4 extension, not part of the SMT-LIB standard. But if you are truly using only Boolean...

In addition to dejvuth's answer: The SMT language is well documented (see smt-lib.org), for this particular issue the FixedSizeBitVectors theory and the QF_BV logic definition are relevant. The latter contains the definition for repeat: ((_ repeat i) (_ BitVec m) (_ BitVec i*m)) - ((_ repeat i) x) means concatenate...

Working With SBV Working with SBV requires that you follow the types and realize the Predicate is just a Symbolic SBool. After that step it is important that you investigate and discover Symbolic is a monad - yay, a monad! Now that you you know you have a monad then...

If all you want is to encode is that an element v is in a finite set {e1, ..., en} (with sort U), you can do this using smtlib2 as follows: (declare-fun v () U) (declare-fun p1 () Bool) ... (assert (= p1 (= v e1))) (assert (= p2 (=...

Here's a trick you might enjoy by parsing the SMT2 string via the Python API with parse_smt2_string ( http://research.microsoft.com/en-us/um/redmond/projects/z3/z3.html#-parse_smt2_string ): from z3 import * s = SolverFor("BV") #s.set(':pp.bv_literals', True) # gives error for some reason mask = BitVec('mask', 64) multiplicand = BitVec('multiplicand', 64) x = BitVec('x', 64) y = BitVec('y',...

If you want to generate something randomly, I suggest a nondeterminism monad, of which MonadRandom is a popular choice. I would suggest two inputs to this procedure: vars, the number of variables, and clauses the number of clauses. Of course you could always generate the number of clauses at random...

It may, but switching solvers or building a specialized tactic will probably have a greater influence.

The int2bv function is essentially handled as uninterpreted (as stated in the documentation), so the semantics are not precise. There have previously been a few questions about those conversion functions, they might be helpful here too: Z3: an exception with int2bv Check overflow with Z3 bv-enable-int2bv-propagation option...

java,smt,integer-programming,sat-solvers

GLPK, open-source package for LP and (mixed) ILP has Java binding. Another open-source solvers are lp_solve (Java API) and SCIP. There are also commercial solvers - CPLEX, GUROBI and Mosek, all with Java interface. Btw. for my homeworks, I found Python and PuLP a bit easier to work with :)...

There are roughly 3 ways to do this. You can use the interpreted predicate (_ divisible 2). (assert ((_ divisible 2) 6)) You can use a define-fun to capture even exactly. (define-fun even ((x Int)) Bool ((_ divisible 2) x)) Note that this may not be in your logic of...

The second call to Z3_parse_smtlib2_string does not know about the declaration in the first call: Z3_ast parsed2 = Z3_parse_smtlib2_string(c1, testing.c_str(), 0,0,0,0,0,0); The bunch of zero's in the end means "do not assume anything else", so it doesn't know that p0 exists. For more details see the Z3_parse_smtlib2_string in the API...

parsing,antlr,grammar,antlr4,smt

Your formula rule seems to be causing the issue here: LEFT_PAREN formula RIGHT_PAREN OR LEFT_PAREN formulaConjunction RIGHT_PAREN. That's saying that only formulas of the form (FORMULA)|(CONJUNCTIVE) will be accepted by the language. Instead, specify precedence rules for each operator, and use a nonterminal for each level of precedence. For example,...

multithreading,x86,x86-64,smt,hyperthreading

The Intel Architecture Software Optimization manual has a brief description of how processor resources are shared between HT threads on a core in chapter 2.3.9. Documented for the Nehalem architecture, getting stale but fairly likely to still be relevant for current ones since the partitioning is logically consistent: Duplicated for...

You already have everything in place, but the constants 1 and 0 are not Boolean values; the corresponding values are true and false, i.e., this should work: (assert (= (not (ite (< t0 10) true false)) true)) ...

exception,z3,smt,java-api,tactic

The command Goal g = ctx.mkGoal(true, true, false); asks for unsat core extraction to be enabled (the second true) for the goal g, but the propagate-ineqs tactic does not support that feature, so it throws an exception....

There is no equivalent to function definitions because they aren't necessary, just like the define-fun macro. The equivalent thing to do in the API is to build an expression for the function and then for every application of the function, just substitute the argument values for the input values, e.g.,...

Even Z3 has multiple solvers, e.g., BMC, PDR (the default?), CLP (prolog-style reasoning), Datalog, and Duality. Choose with fixedpoint.engine=xx. There's also another engine coming soonish which is a port of HSF to Z3. (the original HSF is also available and is very reliable) There are other solvers out there, but...

That is indeed correct. SMTLib uses a many-sorted first-order logic; so in your example A can be any sort, but it has to be a known sort; not a type-parameter. Having said that, SMTLib does allow uninterpreted sorts; that is, you can introduce new sorts with no underlying representation. (Just...

The example given in the answer to the question referred to is slightly out of date. A Solver() will pick a suitable tactic to solve the problem, and it appears that it picks a different one now. We can still get that behavior by using a SimpleSolver() (at a possibly...

arrays,z3,smt,z3py,microsoft-research

Disclaimer: I've hardly ever used Z3py before, but I've used Z3 quite a bit. I have the feeling that you are somewhat new to encoding logical problems as well - could that be? There are several (odd) things going on in your problem. You put constraints on x and y,...

The extract function only takes numerals as arguments, not arbitrary expressions. However, we can shift the expression to one direction and then extract the first or last four bits, e.g. along the lines of ((_ extract 11 8) (bvshl l (bvmul idx four))) (where idx and four are bit-vector expressions...

Assert the equality of the select at each index to be the constant at that index in the table that you gave. (declare-fun FSb () (Array (_ BitVec 8) (_ BitVec 8))) (assert (= (select FSb #x00) #x63)) (assert (= (select FSb #x01) #x7C)) ... (FSB could also be modeled...

See the C API testcases. There are a number of small, easy to read examples for how to use STP's C interface. Here is push-pop.c. /* g++ -I$(HOME)/stp/c_interface push-pop.c -L$(HOME)/lib -lstp -o cc*/ #include <stdio.h> #include "c_interface.h" int main() { VC vc = vc_createValidityChecker(); vc_setFlags('n'); vc_setFlags('d'); vc_setFlags('p'); //vc_setFlags('v'); //vc_setFlags('s'); Type...

It also seemed not to return for me using that, but it seems to work as: z3 -in -smt2 Followed by pasting the query, so I think it may need the -smt2 parameter. I tried it on Windows with 4.3.3 (I thought I had 4.3.2, but it seems I updated...

This is an answer to my own question. If anyone can post an example for a use-case of a user-defined sort with arity > 0, I'll happily accept that as answer. After reading the SMT-LIBv2 standard more carefully I am now thinking that sort declarations with arity > 0 only...