Skip to content

proof: Stage 3.2 (repair⇒verify) + live-verifier Merkle redesign soundness#55

Merged
hyperpolymath merged 2 commits into
mainfrom
claude/dazzling-noether-hkgAV
Jun 18, 2026
Merged

proof: Stage 3.2 (repair⇒verify) + live-verifier Merkle redesign soundness#55
hyperpolymath merged 2 commits into
mainfrom
claude/dazzling-noether-hkgAV

Conversation

@hyperpolymath

@hyperpolymath hyperpolymath commented Jun 18, 2026

Copy link
Copy Markdown
Owner

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.

repairThenVerify : (s : FSState) -> (refs : List Ref) ->
  GoodRefs (numBlocks s) refs -> (hashRefl : (h : Hash) -> (h == h) = True) ->
  verifyRefsHelper (repairRefsPure s refs) refs = Right ()

New module Ochrance.Filesystem.RepairVerify:

  • repairRefsPure — pure whole-manifest repair; folds 3.1's repairBlockPure.
  • verifyRefsComplete (Lemma A) — completeness, exact converse of verifyRefsSound.
  • 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) and hashRefl (primitive Hash == reflexivity, same wall as merkleCorrect's residual step).


Part B — live-verifier Merkle redesign (soundness)

Proves the theorem a redesigned root-comparing verifyRefsHelper rests on: two block-hash vectors that decode and build trees with equal Merkle roots are equal — carrying rootVerifySound up to the live A2ML Hash level across the decoder bridge.

merkleRootVerifyHashSound :
  (h : Combiner) -> CollisionResistant h ->
  (dec : Hash -> Maybe HashBytes) -> DecodeInjective dec -> {n : Nat} ->
  (xs, ys : Vect (power 2 n) Hash) -> (xb, yb : Vect (power 2 n) HashBytes) ->
  decAll dec xs = map Just xb -> decAll dec ys = map Just yb ->
  rootHashWith h (buildMerkleTree {n} xb) = rootHashWith h (buildMerkleTree {n} yb) ->
  xs = ys

Added to Ochrance.Filesystem.VerifyMerkle: decAll (structural decode), DecodeInjective (named hypothesis — the live counterpart of CollisionResistant), mapDecodeInjective, and the theorem. Stated for an arbitrary decoder dec (as rootVerifySound is for an arbitrary Combiner), instantiated at hashToBytes.

What's left is plumbing, not a proof: padding an arbitrary-length block list to a power-of-two leaf Vect and 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 CollisionResistant against the real combiner).

🤖 Generated with Claude Code

claude added 2 commits June 18, 2026 10:37
…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 hyperpolymath changed the title proof: Stage 3.2 — whole-manifest repair ⇒ verify (repairThenVerify) proof: Stage 3.2 (repair⇒verify) + live-verifier Merkle redesign soundness Jun 18, 2026
@hyperpolymath
hyperpolymath marked this pull request as ready for review June 18, 2026 10:52
@hyperpolymath
hyperpolymath merged commit 1f1597e into main Jun 18, 2026
19 checks passed
@hyperpolymath
hyperpolymath deleted the claude/dazzling-noether-hkgAV branch June 18, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants