Repository navigation
Lean KV: ~1.7x faster proof checking, proofs only - #8687
Merged
Merged
Conversation
Restructure the KV proofs into three self-contained modules that Lake checks in parallel, and use cheaper proof steps. Theorem statements in Properties.lean are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
cjen1-msft
approved these changes
Nov 5, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the proof-module restructuring.
No open issues 🎉
What changed in this PR
Restructures CCF's Lean KV proofs to reduce sequential import dependencies, following the consistency-model optimization in #8680.
The PR reports about 1.7x faster proof checking without changing the executable model or public property statements.
Changes:
- Consolidates six proof modules into three independent modules, duplicating shared private helpers to enable parallel checking.
- Simplifies proof implementations while retaining the kernel-checked witnesses and earlier optimizations from #8672.
- Updates proof imports, implementation references, and layout documentation.
Custom instructions used
No additional repository instruction files were loaded.
| File | Description |
|---|---|
lean/kv/README.md |
Documents parallel proof checking and updated invariant locations. |
lean/kv/Kv/Properties.lean |
Updates imports and proof references while preserving public statements. |
lean/kv/Kv/Proofs/Witnesses.lean |
Makes witnesses self-contained and incorporates model-level claims. |
lean/kv/Kv/Proofs/Trace.lean |
Removes the former trace proof module; redistributes its proofs. |
lean/kv/Kv/Proofs/Replay.lean |
Adds self-contained snapshot, map-capture, and attempt-replay proofs. |
lean/kv/Kv/Proofs/Properties.lean |
Removes the intermediate property-proof module. |
lean/kv/Kv/Proofs/Model.lean |
Removes the separate model-proof module; redistributes its claims. |
lean/kv/Kv/Proofs/Invariants.lean |
Removes the shared invariant module in favor of self-contained proofs. |
lean/kv/Kv/Proofs/Execution.lean |
Removes the separate execution bridge module. |
lean/kv/Kv.lean |
Updates root imports to the three-module proof layout. |
Review effort: Balanced
This was referenced Nov 6, 2026
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.
Motivation
Follow-up to #8680, applying the same restructuring to the KV model. KV's proof modules formed a ~6-module import chain (Execution -> Invariants -> Model -> Trace -> Proofs.Properties -> Properties), and each module pays ~1s just to load its imports, so wall-clock checking time was dominated by the critical path rather than the proofs themselves.
Implementation summary
Kv/Proofs/modules with three self-contained modules that do not import each other, so Lake checks them in parallel:Reachable: the state invariants, their preservation by every step, and the claims that depend on them.Replay: replay/segment claims.Witnesses: the non-vacuity witnesses (still mostlydecide +kernelover one accepted trace, as in Lean KV: ~5x faster proof checking, proofs only #8672) plus the model-level claims.privatedeclarations (generated from each module's dependency closure); module docstrings explain this. Some modules keep emptynamespace ... endblocks so thatopenworks for namespaces whose only content there is private.haves), the most expensive cases ofstepEvent_effectsplit into per-constructor lemmas, andomegareplaced by explicitNatlemmas. The Lean KV: ~5x faster proof checking, proofs only #8672 speedups are kept.Properties.lean: only theKv.Proofs.*imports and 13exact Proofs.<name>references change; every statement is byte-identical.Kv.lean: only theKv.Proofs.*imports change.README.md: updated the references to the removedProofs/Execution.leanandProofs/Invariants.lean, and described the parallel layout.Rebuilding all proof modules,
Propertiesand the root, with Mathlib,ccf_common, the model and property helpers cached (median of alternating same-time runs on a 20-core machine):CPU time and size go up because of the duplicated private lemmas; wall-clock time is what CI and local iteration wait on.
Safety and compatibility
No runtime impact: this changes only Lean proof implementations under
lean/kv/Kv/Proofs/, the proof imports/references inKv/Properties.leanandKv.lean, and the KV README. Public safety statements and witnesses are unchanged (witnesses remainlemmas perlean/AGENT.md). Everything remains fully kernel-checked with nosorry,native_decide, new axioms or disabled linters. Locally passing:lake build --wfail --fail-fast,lake exe check-imports,lake build CCF,lake lint,lake exe runLinter --no-build CCF Kv replayer.Main,lake check --inadvisably-no-sandbox(axioms:propext,Quot.sound,Classical.choice),./replayer/check-fixtures.sh, leanfmt, and the Markdown newline/ASCII/prettier checks.