4

I am using Z3 Python bindings to create an And expression via z3.And(exprs) where exprs is a python list of 48000 equality constraints over boolean variables. This operation takes 2 seconds on a MBP with 2.6GHz processor.

What could I be doing wrong? Is this an issue with z3 Python bindings? Any ideas on how to optimize such constructions?

Incidentally, in my experiments, the constructions of such expressions is taking more time than solving the resulting formulae :)

  • How much time does it usually take, without Python bindings? Did you time the computation time vs construction time? – Flavian Hautbois Oct 15 '14 at 08:29
  • I haven't tried it without Python bindings. However, with the Python bindings, `tmp1[i] = value == z3.is_false(interpretation)` takes ~0.0001s while `n.append(z3.And(tmp1))` takes ~2s. As for the checking time, the initial check takes 8.67s while subsequent checks (with the addition of more constraints (`tmp1` from above) takes 0.3s. – Venkatesh-Prasad Ranganath Oct 15 '14 at 12:54

1 Answers1

2

Using Z3 over Python is generally pretty slow. It includes parameter checks and marshaling (_coerce_expr among others). For scalability you will be better of using one of the other bindings or bypass the Python runtime where possible.

Nikolaj Bjorner
  • 8,229
  • 14
  • 15