Repository navigation
verify: Keep each Lean proof with the goal of its statement - #58
Merged
Merged
Conversation
… and certify with the pinned toolchain.
…ut its function's identity.
…across regenerations.
…ment, never by position.
…for the Lean proof identity test.
…or the Lean proof identity test.
…r the Lean proof identity test.
…for the Lean proof identity test.
…r the Lean proof identity test.
…or the Lean proof identity test.
…r the Lean proof identity test.
…bb93f for the Lean proof identity test.
…ect the Lean proof identity test migrates.
…ect the Lean proof identity test migrates.
…ect the Lean proof identity test migrates.
…ect the Lean proof identity test migrates.
…ect the Lean proof identity test migrates.
…ect the Lean proof identity test migrates.
…ect the Lean proof identity test migrates.
…ect the Lean proof identity test migrates.
…ect the Lean proof identity test migrates.
…ity test migrates.
… in the architecture.
…n the tooling reference.
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.
A Lean project named each goal by its position:
cppverify_one_fn_…_obligation_3_goal, the third obligation ofone, its proof inProofs/Goal_<md5 of that name>.lean, and each spec body by the position of its module in the file (cppSpecBody_m2_…). So a proof stayed with a number, not with what it proves:mainType mismatch: h has type r = BitVec.ofInt 32 1 but is expected to have type cppBvSle (BitVec.ofInt 32 0) rcppSpecBody_m2_→m3_), and every proof that unfolds one stops buildingsorrystubsStale/with a note naming the new goal, and the goal gets a stubStale/, and come back when a goal has their statement againDesign
The research for this item (Frama-C WP's per-goal scripts, Vermilion's proof blocks keyed by the hash of their statement, Dafny's and Verus's caches) is in the plan's notes. This takes the identity from Vermilion and the file-per-goal layout from Frama-C, and adds what neither has: proofs follow a renamed function, and a proof is never lost.
cppverify_<function>_<h6>_<kind>_<h8>:h6hashes the function's identity (so overloads differ),h8begins the SHA-256 hash of the obligation's statement. That hash,obligationStatementHash, covers the goal and the logical declarations it reaches, as the per-obligation semantic hash does, without the function's identity, so a renamed function's goals keep their hashes. Identical goals of one function get_2,_3in source order. Spec bodies arecppSpecBody_<hash of the function identity>_….CppVerify/Proofs/<function>/<goal>.lean, starting with a header that records the goal, the stable obligation id, the full hash, the spec-body prefix, and the source. A proof written over its stub (withcp, say) gets the header on the next run.Stale/too; else a proof of the same statement whose goal is gone, from the function with proofs of the most of this function's goals, so two functions renamed at once each take back their own; else the 0.1 file of its 0.1 name; else a stub. A move rewrites the goal's name and the spec-body names throughout the proof text.Stale/, with a note saying why: its statement changed (naming the goal of the changed obligation), its function has no obligation with that statement any more, or its function is gone. A stub cpp-verify wrote and nobody edited is removed.--lean-prune-staledeletesStale/on request.Stale/. Together with verify: Pin Lean 4.35.0, move projects 0.1 pinned, and certify with the pinned toolchain #56's pin migration, a 0.1 project certifies again without edits.The header's source path is escaped as Lean comments need:
Generated.leanalready did that, but the first header did not, and a path containing/-opened a nested comment, so the proof file did not parse. The test runs from a directory named-srcto keep that covered.Tests
suite/lean_identity.testwalks one project through every case. It checks the exact warnings and files at each step, and certifies after the renames, after the return, and after the migration:Truegoals included (the same statement in both functions), and the stubs of the removed function are deleted;lean_project,lean_fallback,lean_fallback_partial,lean_fallback_fast,lean_certify,lean_dependencies,lean_semantics), and their proof inputs for the new spec-body names. The fidelity gate's Lean identity check now compares each project goal's (stable id, kind, source) with the scratch and archive export, and checks each proof file's header against its path and name.main, the new test fails from its second check on: the goal names, paths, headers, moves, and messages are all new.Mutants of
Verifier.cpp,LeanBackend.cpp, andObligationSerialization.cpp, each rebuilt and run against the Lean tests: 27 of 28 killed.no move to another goal; a renamed function's goals not moved together, or the last candidate preferred; a kept proof never restored by its name; kept proofs never read;
the functions the solver settles examined; their modules, or their termination modules, not recorded; the goals left to the solver unknown, not recorded, imported, or certified;
stubs taken for proofs, or moved like proofs; 0.1 stubs reported as moved, or kept; 0.1 proofs not migrated;
a proof written over its stub given no header; goal or spec-body names not rewritten in a moved proof; the source in a header unescaped;
an untaken proof deleted, or kept without its note; emptied directories left;
--lean-prune-staleignored;spec bodies named by position; the statement hash including the function's identity.
The survivor keeps a proof at its goal's path whatever its full hash: the path already carries the hash's first eight digits, so the two differ only on a 32-bit collision within one function and kind. Four of the killed mutants survived a first run and showed gaps in the test, which now has a step for each: a reverted change, a re-export after proofs are copied in, and a function with nothing but stubs.
Docs
Stale/, and the 0.1 migration in the--lean-projectrow; what a fallback run examines; the--lean-prune-stalerow and its error.Checked
Builds on #56 (the Lean 4.35.0 pin), whose 13 commits come first here until it merges. Checked on a local merge of
main14a7383 with #54, #55, and #56; rebased ontomaind7bb472 and the rebased #56, the tree is the same, file for file.lean_identity.testand the fidelity gate included, plusbackend_options.cpp. VerifyTests: 62 passed, 1 skipped (EncodingParityTest, which needs archives).main, the table's first row: after reordering two postconditions, certification fails with the type mismatch shown above.-W;docs_coverage.testanddocs_examples.testpass, and the book's outputs are from this build. clang-format: clean.