Repository navigation
D7: every solver query as a standalone SMT-LIB script (--dump-smt2) - #110
Merged
Merged
Conversation
…S runner can meet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The only view of a solver query was
--dump-ir=4: Z3 terms without declarations, options, or a check, which no solver reads. A solver bug, a version differential (D1), or a query that takes too long could not be handed to anyone without cpp-verify and the source. This is plan item D7, stacked on #107 (D6).--dump-smt2=DIRwrites every query cpp-verify sends to Z3 or cvc5 as a script thatz3 FILEorcvc5 FILEruns on its own.What a file is
On the
clamp.cppof chapter 17:z3 clamp-14e9c9/postcondition-5-23.z3-d86b7e26.smt2printssatand the modelx_0 = -2,__result_1 = -1.Design, from the references
/proverLog,--solver-log):@PROC@and, with@TIME@, by time;; Invalid).--log smt):set-optionlines, but the solver's command-line flags are not, soz3 FILEdoes not reproduce every query.-wp-out):<propid>_<prover>.smt2;This PR takes from each:
Z3Encoder::check, and every cvc5 run throughrunCVC5. A file is a query, not a session.set-optioncommands in the file, which Verus and Frama-C leave out:smttactic, ends with(check-sat-using smt);cvc5Optionsnow builds both the command line and the commands).<function>-<h6>/<query>.<solver>-<h8>.smt2:<h6>hashes the function's identity, so overloads stay apart;<query>iswholeor the obligation's stable id askind-line-col;<h8>hashes the script, so two checks of one obligation (refinement rounds) are two files and a repeated check is one.--jobs.; cpp-verify: sat,unsat,unknown (timeout), or for cvc5no answer (...). The script is written before the check, so a check that hangs or crashes leaves its query; the verdict is appended after it. Asatcheck also gets(get-model).Two printer problems the replays found
Z3's benchmark printer (
to_smt2) leaves symbols unquoted. Our quantifier idsq@24:11are not SMT-LIB symbols (the colon starts a keyword), so 1,373 of the first 7,239 dumped scripts did not parse. The dump uses the solver's own printer,Z3_solver_to_string, which quotes them (|q@24:11|). It also prints recursive definitions (define-funs-rec).That printer also writes the model converter that preprocessing left on a solver that has checked before:
model-addof symbols such ask!0that it never declares. 829 scripts did not parse because of it. The dump now prints a solver that holds only the checked solver's assertions.Replaying every query of the suite
Every file of
clang/test/Verify/suitewas run with--jobs=4 --timeout=5000 --dump-smt2, on Z3 and on cvc5, and every script was replayed withreplay_smt2.py. That helper runs Z3 4.13.4's own shell, or cvc5 1.1.2. It compares each answer with the one cpp-verify recorded where that wassatorunsat, and only parses the others.satorunsat. One replay differs:unknownwhere cpp-verify gotsat.unknown; none contradicts the answer cpp-verify got:smttactic.The last group is a property of Z3, not of the files. Z3's search on a quantified query depends on the order in which its terms were created, and a replay creates them in another order.
The vacuity query of
constructors.cpp'sCopy4issatin cpp-verify. Its assertions, re-added to a freshsmt-tactic solver in the same Z3 context, are alsosat, and so is the dumped text parsed back into that context. In a fresh context (Z3's API in another program, or thez3shell) they areunknown(incomplete quantifiers). The documentation says so: replaying gives the answer cpp-verify got for most queries, and a quantified one can end differently.The dumps already paid off while writing #106 and the H5 case study:
cvc5_memory_limit.cppshowed that cvc5 1.4.2 solves it in less than 5 MB;satin 24 ms, but that thesmttactic, chosen for its loop frame's quantifier, gives up on after 20 s.Testing
The vendored Z3 now builds its shell too (
Z3_BUILD_EXECUTABLE=ON, installed into the build'scppverify-z3/install/bin, not into release archives). lit has az3-shellfeature and%cppverify-z3; a system Z3 build usesz3onPATH.suite/smt2_dumps.test(new) checks:(get-model), verdict;(check-sat-using smt)for a quantified query;model-add;It passes five runs out of five. On the base it fails at its first line (
--dump-smt2is unknown).Each mutant below, applied alone and rebuilt, is caught by
smt2_dumps.test, or for Q13 byfailure_notes_cvc5.test(17 of 17):(get-model)aftersat(check-sat)On a release build of the top of this stack (#111, which contains this branch), the whole Verify suite of 503 tests passes but one,
docs_examples.test, whose failure was a docs example on #111's new page, fixed there.Docs: tooling (the option, the layout, a file, a replay, and what replaying may give), chapter 15's flag list, chapter 16 (how to report a solver problem), release notes, README, ARCHITECTURE, and DESIGN.
Stacked on #107.