Repository navigation
Add witnessed% to state Lean safety claims with their witnesses - #8760
Open
cjen1-msft wants to merge 4 commits into
Open
cjen1-msft wants to merge 4 commits into
cjen1-msft wants to merge 4 commits into
Conversation
nonvacuous% foo is the statement that the hypotheses of the theorem foo can be satisfied, so a witness lemma no longer repeats the variables and hypotheses of the theorem it witnesses. Use it for the consensus and disaster-recovery witnesses whose statements it reproduces exactly; the proofs under Proofs/ are unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Convert the kv witnesses whose statements are the hypotheses of their theorem, optionally with further conjuncts. The proofs are unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
State each safety claim and its witness once, as
witnessed% forall xs, { pre := p, post := q, witness := w }, and move the
proof glue into Proofs/Claims.lean in each package.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
cjen1-msft
marked this pull request as ready for review
November 13, 2026 18:17
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The new Lean elaborator rewrites 53 safety/witness statements, but lake check has not been run, so human review must confirm elaboration, independent kernel checks, and import checks across all five affected packages.
No open issues 🎉
What changed in this PR
This PR adds witnessed% to CCF’s shared Lean library, allowing safety claims and their existential witnesses to share variables and premises.
It reduces duplicated statements across the formal models without changing runtime behavior.
Changes:
- Add
CCF.Witnessed,.safetyand.witnessprojections, and elaboration checks. - Convert 53 claim/witness pairs across consensus, disaster recovery, consistency, and KV, with proof assembly in new
Proofs/Claims.leanmodules. - Update recovery callers and documentation, including the new
config.Validassumption on converted recovery claims; retain separate witnesses where needed.
Custom instructions used
- CCF repository review guidance supplied with the request.
lean/AGENT.md— supplied excerpt covering witnessed claims and proof organization.
| File | Description |
|---|---|
lean/kv/README.md |
Document combined claims and standalone witnesses. |
lean/kv/Kv/Properties.lean |
Convert 28 KV claims to witnessed statements. |
lean/kv/Kv/Proofs/Claims.lean |
Assemble KV safety proofs and witnesses. |
lean/kv/Kv.lean |
Export the new claims module. |
lean/disaster-recovery/README.md |
Explain witnessed claims and configuration validity assumptions. |
lean/disaster-recovery/DisasterRecovery/Tests/Witnesses.lean |
Adapt witness checks to the new projections. |
lean/disaster-recovery/DisasterRecovery/Tests/Trace.lean |
Supply configuration validity when applying safety projections. |
lean/disaster-recovery/DisasterRecovery/Properties.lean |
Convert six recovery claims to witnessed statements. |
lean/disaster-recovery/DisasterRecovery/Proofs/Claims.lean |
Combine recovery proofs with valid-configuration witnesses. |
lean/disaster-recovery/DisasterRecovery.lean |
Export the new claims module. |
lean/consistency/consistency/Properties.lean |
Convert 16 consistency claims and explicitly bind tuple components. |
lean/consistency/consistency/Proofs/Claims.lean |
Assemble consistency claims from existing proofs and witnesses. |
lean/consensus/Consensus/Properties.lean |
Convert three consensus claims, retaining witness-only conditions. |
lean/consensus/Consensus/Proofs/Claims.lean |
Assemble consensus safety proofs and witnesses. |
lean/common/README.md |
Explain notation, quantifier scope, and projections. |
lean/common/CCF/Witnessed.lean |
Define witnessed propositions, specifications, and elaboration. |
lean/common/CCF/Tests/Witnessed.lean |
Check generated statements and unsupported-input diagnostics. |
lean/common/CCF.lean |
Export witnessed definitions and import their checks. |
lean/AGENT.md |
Update contributor guidance for witnessed safety claims. |
Review effort: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
| exact Proofs.Claims.single_node_committed_log_monotonic | ||
|
|
||
| /-- No two distinct nodes are primary in the same term. | ||
| Witness: a valid trace has a state with two primaries in the same term. -/ |
This branch has not been deployed
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
Each safety theorem in the Lean
Properties.leanfiles is followed by a witness lemma that repeats its variables and hypotheses underexists.The repetition is review overhead, and nothing checks that the two copies stay in step.
Implementation summary
CCF.Witnessedto the common package:witnessed% forall xs, { pre := p, post := q, witness := w }is the propositionWitnessed (forall xs, p -> q) (exists xs, p /\ w), a namedAndwith.safetyand.witnessprojections.The braces are an ordinary
Witnessed.Specstructure instance;witnessis optional.CCF.Tests.Witnessedrecords the produced statements and errors with#guard_msgs.Before:
After:
A conjunct that only the witness satisfies goes in an optional
witness := ...field, for examplewitness := rs ≠ []in kv.Each
Properties.leanproof is a one-lineexact Proofs.Claims.<name>; the glue that assembles the existing safety and witness proofs lives in a newProofs/Claims.leanper package.deadlock_freetheorems,full_gossip_preserves_commit(its witness assumes more than its claim),all_received_is_first_sent, and the kv point-read and publication claims, whose witnesses fix type parameters.CCF.Nonvacuous, and updatelean/AGENT.mdand the package READMEs.Safety and compatibility
No runtime change.
The converted disaster-recovery and consensus safety theorems now assume
config.Validandconfig.Nonemptyrespectively, which their witnesses already required; the unconditional theorems underProofs/are unchanged.Some kv witnesses now quantify over variables of their claim that they previously omitted.
lake checkruns only in CI and has not been run on this change.