2

I would like to get access to the quantifier elimination tactic of Z3 in Ocaml, in order to avoiding implementing all the validity and quantifier elimination methods I need.

To do so, I would like to know how to call a Z3 API (for instance, Z3 from Python as a black box) from Ocaml.

Can anyone help?

PS: Would this activity be called multi-paradigm programming? I ask this in order to find more info about similar issues in the future.

Theo Deep
  • 666
  • 4
  • 15

1 Answers1

3

z3 already comes with OCaml bindings:

If the API exposed isn't enough to do what you want, you should really ask them to expose it through the OCaml API. I think going through OCaml-Python-Z3 would be really problematic as you'd have to juggle both layers.

Chris
  • 26,361
  • 5
  • 21
  • 42
alias
  • 28,120
  • 2
  • 23
  • 40
  • My problem with that API is that it does not have a quantifier elimination tactic, does it? – Theo Deep Nov 09 '21 at 19:42
  • 1
    Sure.. Use https://z3prover.github.io/api/html/ml/Z3.Tactic.html. Then, `mk_tactic ctx "qe"` or similar. – alias Nov 09 '21 at 19:54
  • I will see what can I do, but that definitively answers the question! – Theo Deep Nov 09 '21 at 19:57
  • 1
    There are many example calls to `mk_tactic` in https://github.com/Z3Prover/z3/blob/master/examples/ml/ml_example.ml – alias Nov 09 '21 at 19:58
  • Yep, but no one uses "qe" and I never see examples of it for Ocaml. – Theo Deep Nov 09 '21 at 20:01
  • 1
    I've never tried it myself, but I don't see why it wouldn't work. If you put `(help-tactic)` in a file named `t.smt2` and run `z3 t.smt2` it'll print all available tactics. In theory, all the printed tactics should be usable via `mk_tactic`. – alias Nov 09 '21 at 20:41