I'm looking at doing some verification work where I've got regular tree grammars as an underlying theory.
Z3 lets you define your own stuff with uninterpreted functions, but that doesn't tend to work well any time your decision procedures are recursive. They used to allow for plugins but that has been depricated, I think.
I'm wondering, does anybody have a recommendation of a decent SMT solver that allows you to write decision procedures for custom theories?
There are several options given that most reasonable SMT solvers are open source you can integrate theory solvers in any detail depending on how much time and energy you have to spend.
- OpenSMT http://verify.inf.usi.ch/opensmt was specifically built to enable pluggable theory integration.
- VeriT, Yices and CVC4 are open source and you could look into theory integration in these solvers.
- Z3 is open source and is available to enable you and others to build on it. There was an API for a DPLL(T) plugin mode, but we removed it when Z3's source became open and also due to a basic limitation: it didn't support model construction well. The internal APIs used for plugging in theories are in principle isomorphic to the external APIs. An older paper describing various ways to integrate theories is https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/nbjorner-aplas11.pdf. I would say a first prototype is much easier achieved using an outer loop around the solver. You get a propositional model from the solver and then check if it satisfies your background theory. You can also try the internal APIs. For some theories, this is fairly easy. See for example UTVPI https://github.com/Z3Prover/z3/blob/master/src/smt/theory_utvpi_def.h as a sample. For the theory of strings, it is fairly involved (because the theory requires substantial special case reasoning). The module z3str3 was integrated earlier this year https://github.com/Z3Prover/z3/blob/master/src/smt/theory_str.cpp, and development is still ongoing. It is about 10KLOC. Bui Phi Dep uses the older version of Z3 for an external theory integration https://github.com/diepbp/FAT. It is also a substantial amount of code, again as strings and transducer theories require quite a bit of setup. For contributors who are willing to be responsive to user bug reports and requests we (Z3) very much welcome additional contributions to the main branch of Z3 with theories and algorithms that are not covered. There is quite a bit of wiggle room in the string and tree acceptor/transducer space.
Again, I would say that for a first version you should get pretty far with an external integration where you let the SMT solver deal with propositional SAT and uninterpreted functions (and arithmetic if you need this). You can then ask the solver for a model and add theory axioms back until the propositional model you get back from the solver aligns with your theory (or you get UNSAT). Not all assignments in the propositional model are going to be relevant. You can minimize the number of assignments you consider by applying dual propagation (http://www.cs.utexas.edu/users/hunt/FMCAD/FMCAD14/proceedings/29_niemetz.pdf).
来源:https://stackoverflow.com/questions/46508907/smt-solver-with-custom-theories