I have a program that can dynamically generate expressions in SMT-LIB format and I am trying to connect these expressions to CVC4 to test satisfiability and get the models. I am wondering if there is a convenient way to parse these strings through the CVC4 C++ API or if it would be best to just store the generated SMT-LIB code in a file and redirect input to the cvc4 executable.
Asked
Active
Viewed 259 times
0
-
"Convenient". Probably not by a reasonable person's definition. This can be done at the SMT-LIB _command_ level in an ok fashion (see SMT-LIB 2.6 section 3.9 for command). (FWIW just term parsing is harder than it sounds as terms can generates implicit commands.) The [interactive shell](https://github.com/CVC4/CVC4/blob/master/src/main/interactive_shell.cpp#L172) is doing this and is not supposed to use private APIs. (These might have creeped in.) I'd start trying to understand that code if this feature is really important. Maybe something better has been added recently? – Tim Jun 05 '20 at 16:53
-
@Tim So if I understand you correctly, you can parse the smt-lib commands individually using the parser api with a string input and then invoke the commands on an smt-engine with command.invoke() method. This is much more inconvenient than in z3, but it's good to know that it can be done. – Orson Baines Jun 05 '20 at 23:26
-
"commands individually". What is available is a sequence of commands. The parser tries to handle a stream of text. That can contain multiple commands. Also a command in text can also turn into multiple Command objects as syntactic sugar gets removed, e.g. [ :named ](https://github.com/CVC4/CVC4/blob/master/src/parser/smt2/Smt2.g#L2244). – Tim Jun 09 '20 at 17:10
1 Answers
0
A cursory look at their API doesn't reveal anything obvious, so I don't think they support this mode of operation. In general, loading such statements "on the fly" is tricky, since an expression by itself doesn't make much sense: You'd have to be in a context that has all the relevant sorts defined, along with all the definitions that your expressions rely on, including the selection of the proper logic. That is, for instance, why the corresponding function in z3 has extra arguments: https://z3prover.github.io/api/html/classz3_1_1context.html#af2b9bef14b4f338c7bdd79a1bb155a0f
Having said that, your best bet might be to ask directly at https://github.com/CVC4/CVC4/issues to see if they've something similar.

alias
- 28,120
- 2
- 23
- 40