solidity icon indicating copy to clipboard operation
solidity copied to clipboard

SMTChecker: Use Z3 through the SMT-LIB interface

Open blishko opened this issue 1 year ago • 7 comments

Instead of using Z3 as a library, we use Z3 as an external solver, the same way as we already use Eldarica and cvc5.

After discussion with @ekpyron, we decided that emscripten build of solc will be an exception. The rationale is that switching also the javascript binary of the compiler would require changes in solc-js and would put additional burden on users who would like to use SMTChecker. Fortunately, Z3 exposes an API method Z3_eval_smtlib2_string (from C interface of Z3), which seems to behave exactly as calling the solver on the given SMT-LIB2 script. Thus, we can reuse the same infrastructure we have for processing answers in both cases (calling external process, or calling this API method).

blishko avatar Jul 10 '24 08:07 blishko

Did something change in the model checker engine settings here? I just quickly checked the emscripten binary on remix and was surprised to only get CHC responses - and then also checked the static ubuntu binary, which also only seems to run CHC no matter what I pass in as --model-checker-engine. We could change the behaviour of all this, but what I just saw seemed a bit odd at least :-).

ekpyron avatar Oct 02 '24 12:10 ekpyron

That should not be the case. I will investigate. What exactly have you been trying? What examples?

blishko avatar Oct 02 '24 14:10 blishko

I just checked again: my mistake was mainly that (since that's easier for remix) using the old experimental smtchecker pragma, which seems to override the CLI settings. And also forgot that for some cases if CHC solves it, we won't even query BMC anymore. With some more care in testing all seems to indeed work as expected! Sorry for the false alarm :-).

ekpyron avatar Oct 02 '24 15:10 ekpyron

I should squash everything to a single commit?

blishko avatar Oct 16 '24 21:10 blishko

I should squash everything to a single commit?

That's usually how we do it. But if you want/feel the need to separate things, maybe group everything in 2 or 3 major commits.

matheusaaguiar avatar Oct 16 '24 21:10 matheusaaguiar

The comments here actually look perfectly fine to me.

It's not really about the number. What we don't want is messy history where things are changed and then changed back within the same PR, making it hard to follow. If that's the case then squashing into a single commit is a simple way out. But each commit being one logical, atomic change with a good description is actually superior if we can get it.

So just make sure there are no separate commits for review corrections (they should all be squashed into the original commits they fix) and it's fine. The one commit called "Fixup" sounded like something like that, but it seems that it's actually just normal fix so it's fine.

cameel avatar Oct 17 '24 10:10 cameel

I tried to keep the commits logically compact. I think I can improve some of the commit messages and squash some of the commits together, but I would prefer to keep at least some commits separate, because they address different issues.

blishko avatar Oct 17 '24 13:10 blishko