kino-mc / rsmt2

A generic library to interact with SMT-LIB 2 compliant solvers running in a separate system process, such as Z3 and CVC4.
Apache License 2.0
65 stars 14 forks source link

Support other solvers than z3 #7

Closed AdrienChampion closed 4 years ago

AdrienChampion commented 7 years ago
aep commented 4 years ago

cvc4 doesnt work out of the box at least. probably because interactive mode echoes back?

Error(ParseError("expected `sat` or `unsat`", "(declare-const n Int)"),
AdrienChampion commented 4 years ago

@aep yeah originally rsmt2 supported cvc4, but it was quite tedious to maintain and until now no one really asked for it.

There used to be a way to remove the prompt completely, but I'm not sure that's the case anymore. I will take a look at adding support for cvc4 back. I will most likely only add support for the latest version, which will provide a template for supporting other versions that behave differently.

aep commented 4 years ago

its "--no-interactive", see my PR

aep commented 4 years ago

any idea how i can run the tests against the other solvers to find the problems?

i could search and replace SmtConf::z3 but that's a temporary solution

AdrienChampion commented 4 years ago

Right, the idea is to extend SmtConf to add a cvc4 "driver" that handles the specifics of interacting with cvc4. Just give me a bit of time, I'll work on it this afternoon to add support for the latest cvc4 I have access to. (Hopefully.)

Once that's done, it will provide a guideline for submitting drivers for other solvers, such as yices or other versions of cvc4.

aep commented 4 years ago

the zz compiler self test suite has half a million lines of smt2.

yices2 works as expected with my PR

AdrienChampion commented 4 years ago

Alright, so cvc4 is actually already supported, at least as far as declarations/assertions/get-model are concerned. Also, get-value segfaults on my version (1.4.2).

Yices 2 mostly works out of the box, but differs in how it outputs models. That is, it writes (= <symbol> <value>) where z3 would write (define-fun <symbol> (<args>) <sort> <value>). (Which implies that Yices 2 does not seem to plan to provide values for non-nullary function symbols.) This forces me to change a few things in the API. Nothing big, but I need a bit more time. This should be taken care of tomorrow.

AdrienChampion commented 4 years ago

In any case, thank you for #11 as it makes it very fast for me to add support for Yices 2 :D

AdrienChampion commented 4 years ago

See also https://github.com/SRI-CSL/yices2/issues/162

AdrienChampion commented 4 years ago

Done, I released the new version of rsmt2 as beta for now: https://crates.io/crates/rsmt2/0.11.0-beta.0

I think we can close this issue, feel free to open new ones if you run into problems with this beta version.

Thank you again :)

aep commented 4 years ago

how would i use this with yices2-mt?

aep commented 4 years ago

after fixing those its working

AdrienChampion commented 4 years ago
aep commented 4 years ago

cvc4 needs to --no-interactive as --interactive will echo

you're correct about the yices binary release. no idea why the source build is different. Possibly about to change

still missing --incremental for yices

aep commented 4 years ago

any progress on adding --incremental to yices? i'd like to get rid of the downstream fork

AdrienChampion commented 4 years ago

I'm about to publish rsmt2 0.11.0 which is currently beta. Note that nothing has changed from the user's perspective compared to the beta version from January. (Except the default name for yices' binary.)

I would really appreciate it if you could take the time to give it a try and let me know if you run into any problems before I release 0.11.0. Using rsmt2 = { git = "https://github.com/kino-mc/rsmt2" }.

I think it would be better to have that feedback in a different issue though, if that's ok with you. If you encounter problems for a specific solver, remember to include your operating system and the solver's version :)

Thank you again for your feedback!