proof: Stage 3.2 (repair⇒verify) + live-verifier Merkle redesign soundness#55
Merged
Conversation
…Verify) End-to-end guarantee tying Stage 2.2 (verifier soundness) to Stage 3.1 (pure repair): after repairing every ref of a manifest, the verifier accepts it — verifyRefsHelper (repairRefsPure s refs) refs = Right () New module Ochrance.Filesystem.RepairVerify: - repairRefsPure — pure whole-manifest repair; folds the 3.1 primitive repairBlockPure (installs each ref's hash at its parsed index). - verifyRefsComplete (Lemma A) — completeness, the exact converse of 2.2's verifyRefsSound: All (RefMatches fs) refs ⇒ verifier accepts. - repairRefsConsistent (Lemma B) — repair establishes the match witness for every ref; head hash installed (repairBlockSets) and protected from later repairs (repairRefsPurePreserves, the no-clobber lemma where distinctness is consumed). - repairThenVerify — Stage 3.2, Lemma B ∘ Lemma A. Two boundaries named, never faked (house style of CollisionResistant/HexByteRoundtrip): - GoodRefs — ref names parse to DISTINCT in-range indices (without distinctness a later repair clobbers an earlier ref, so the theorem would be false); - hashRefl : (h == h) = True — reflexivity of the primitive Hash/String ==, the same wall as merkleCorrect's residual step (Nat reflexivity stays structural). Also exports neqNatFalse from RepairProof (needed by the no-clobber lemma). Verified: idris2 0.8.0, --build (--total), 27/27 modules, no warnings, axiom-free. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011z2t8zAxfcCNLJzU7YdpBQ
…ess at the Hash level Part B of the auto-run (Part A = Stage 3.2). Proves the SOUNDNESS that a redesigned root-comparing verifier rests on: two block-hash vectors that decode and build trees with equal Merkle roots are equal — carrying rootVerifySound (HashBytes level) up to the live A2ML Hash level across the decoder bridge. In Ochrance.Filesystem.VerifyMerkle: - decAll — structural per-element decode (reduces definitionally, unlike Functor map). - DecodeInjective dec — named hypothesis: the decoder is injective (true for well-formed hashes; bottoms out in the hex/String wall, Stage 2.3). The live-verification counterpart of CollisionResistant. - mapDecodeInjective — lifts injectivity over a vector. - merkleRootVerifyHashSound — the main theorem; rootVerifySound ∘ mapDecodeInjective. Stated for an arbitrary decoder dec (as rootVerifySound is stated for an arbitrary Combiner h), instantiated at hashToBytes by a future verifier. Two named boundaries: CollisionResistant h (1.4) and DecodeInjective dec (2.3). Remaining is plumbing only, not a proof: pad an arbitrary-length block list to a power-of-two leaf Vect and switch the runtime verify path over. Verified: idris2 0.8.0, --build (--total), 27/27 modules, no warnings, axiom-free. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011z2t8zAxfcCNLJzU7YdpBQ
hyperpolymath
marked this pull request as ready for review
June 18, 2026 10:52
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.
This is the full auto-run: Part A (Stage 3.2, clean proof) and Part B (the architectural live-verifier redesign — its soundness, proven). Verified with idris2 0.8.0,
--build(--total): 27/27 modules, no warnings, axiom-free. (Repo CI is a static scan, not a full type-check — proved with a real bootstrapped compiler before pushing.)Part A — Stage 3.2: whole-manifest repair ⇒ verify
Ties 2.2 (verifier soundness) to 3.1 (pure repair): after repairing every ref, the verifier accepts.
New module
Ochrance.Filesystem.RepairVerify:repairRefsPure— pure whole-manifest repair; folds 3.1'srepairBlockPure.verifyRefsComplete(Lemma A) — completeness, exact converse ofverifyRefsSound.repairRefsConsistent(Lemma B) — repair installs each ref's hash (repairBlockSets) and protects it from later repairs (repairRefsPurePreserves, the no-clobber lemma where distinctness is consumed).repairThenVerify= Lemma B ∘ Lemma A.Named boundaries:
GoodRefs(distinct in-range names — else a later repair clobbers an earlier ref, so the theorem would be false) andhashRefl(primitiveHash==reflexivity, same wall asmerkleCorrect's residual step).Part B — live-verifier Merkle redesign (soundness)
Proves the theorem a redesigned root-comparing
verifyRefsHelperrests on: two block-hash vectors that decode and build trees with equal Merkle roots are equal — carryingrootVerifySoundup to the live A2MLHashlevel across the decoder bridge.Added to
Ochrance.Filesystem.VerifyMerkle:decAll(structural decode),DecodeInjective(named hypothesis — the live counterpart ofCollisionResistant),mapDecodeInjective, and the theorem. Stated for an arbitrary decoderdec(asrootVerifySoundis for an arbitraryCombiner), instantiated athashToBytes.What's left is plumbing, not a proof: padding an arbitrary-length block list to a power-of-two leaf
Vectand switching the runtime verify path over.Campaign status after this PR
Proven bottom-up, each layer machine-checked: 1.1/1.4 Merkle (correct + binding) · 2.1 validator · 2.2 verifier · 2.3 hex · 2.4 verify↔Merkle (3 modes + live root soundness) · 3.1 repair · 3.2 repair⇒verify. Remaining: the layout plumbing above, and Stage 4 (discharge
CollisionResistantagainst the real combiner).🤖 Generated with Claude Code