Skip to content

proof: Stage 3.1 repair correctness + Stage 2.4 verify↔Merkle wiring#53

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

proof: Stage 3.1 repair correctness + Stage 2.4 verify↔Merkle wiring#53
hyperpolymath merged 2 commits into
mainfrom
claude/dazzling-noether-hkgAV

Conversation

@hyperpolymath

@hyperpolymath hyperpolymath commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Repairs, then verify wiring — both machine-checked

Two related capstone pieces, bottom-up. Verified with idris2 0.8.0, --build (--total): 26/26 modules, axiom-free.

Stage 3.1 — pure repair primitive correctness

FSState's verifiable content is its hash map (no separate block data), so installing a hash is the genuine repair — the stub-vacuity precondition is resolved. Factored the pure core out of the IO path (repairBlock = repairBlockPure + range check), then proved (Ochrance.Filesystem.RepairProof):

  • repairBlockSets — repaired index now holds exactly the new hash.
  • repairBlockPreserves — every other index untouched.
  • repairBlockNumBlocks — block count unchanged.
  • repairBlockIdempotent — repairing the same (index, hash) twice = once. (Delivers the ledger's "idempotence as a proof".)

Index test is Nat ==structurally reflexive (eqNatReflTrue / neqNatFalse), wall-free, unlike the primitive Hash ==. Idempotence via decEq (avoids the with-on-(==) asymmetric-reduction trap).

Stage 2.4 — verify↔Merkle wiring

Ochrance.Filesystem.VerifyMerkle: the Merkle root is a faithful fingerprint of the block-hash vector.

  • rootFaithful — equal roots <-> equal leaves. Forward = merkleBindingTree (Stage 1.4, against CollisionResistant h); backward = congruence.
  • rootVerifySound — security reading: a matching committed root ⇒ identical blocks; no collision substitutes different data under the same root.

This is the theorem that licenses root-based verification, carrying Stage 1.4's binding guarantee into the verify use-case — built entirely on the already-secured base, no new walls.

Remaining (documented in docs/PROOFS.adoc, not faked)

  • 3.2 whole-manifest repairPureverifyRefsHelper accepts (distinct-in-range ref-name precondition + isolated Hash-reflexivity hypothesis).
  • Connecting rootFaithful to the live Hash-based verifier needs the hex HashHashBytes conversion (2.3-bounded) + a power-of-two leaf layout — a verify-path change.

Verification note

The repo's Idris2 CI is a static scan, not a full type-check — verified with a real bootstrapped compiler before pushing.

🤖 Generated with Claude Code

claude added 2 commits June 18, 2026 06:13
…ence proved)

FSState's verifiable content is its hash map (no separate block data), so the pure
repairBlockPure — installing a hash at one index — is the genuine repair semantics,
not a no-op. Factored it out of the IO repairBlock (IO↔pure pattern: repairBlock =
repairBlockPure + range check), making the correctness theorems well-founded.

RepairProof (axiom-free, machine-checked):
- repairBlockSets       — the repaired index now holds exactly the new hash;
- repairBlockPreserves  — every other index is untouched;
- repairBlockNumBlocks  — the block count is unchanged;
- repairBlockIdempotent — repairing the same (index, hash) twice = once
                          (the ledger's "idempotence as a proof", delivered).

Index test is Nat == (structural reflexivity eqNatReflTrue / neqNatFalse), so
wall-free — unlike the primitive Hash ==. Idempotence decided via decEq to avoid the
with-on-(==) asymmetric-reduction trap.

NEXT (3.2): whole-manifest repair ⇒ verifyRefsHelper passes — builds on 2.2 + these
lemmas, needs a distinct-in-range ref-name precondition and the isolated
Hash-reflexivity hypothesis (documented).

Verified: idris2 0.8.0, --build (--total), 25/25 modules, axiom-free.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011z2t8zAxfcCNLJzU7YdpBQ
…ingerprint of the blocks)

rootFaithful proves the Merkle root is a faithful fingerprint of the block-hash
vector: equal roots <-> equal leaves. The forward direction (no two distinct
block-sets share a root) is merkleBindingTree against CollisionResistant h
(Stage 1.4); the backward direction is congruence. rootVerifySound is the security
reading — a matching committed root implies identical blocks. This is the theorem
that licenses root-based verification, carrying Stage 1.4's binding guarantee into
the verification use-case.

Ochrance.Filesystem.VerifyMerkle. Builds entirely on the secured base — no new
walls, no postulate/believe_me. Verified: idris2 0.8.0, --build (--total),
26/26 modules, axiom-free.

REMAINING (documented, architectural): connecting this to the live Hash-based
verifyRefsHelper (Stage 2.2) needs the hex Hash<->HashBytes conversion (Stage 2.3,
bounded by unpack/pack + Bits8) and a power-of-two leaf layout — a verify-path
change, not a proof.

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.1 — pure repair primitive correctness (idempotence proved) proof: Stage 3.1 repair correctness + Stage 2.4 verify↔Merkle wiring Jun 18, 2026
@hyperpolymath
hyperpolymath marked this pull request as ready for review June 18, 2026 07:02
@hyperpolymath
hyperpolymath merged commit 04b5da9 into main Jun 18, 2026
19 checks passed
@hyperpolymath
hyperpolymath deleted the claude/dazzling-noether-hkgAV branch June 18, 2026 07:02
hyperpolymath pushed a commit that referenced this pull request Jun 18, 2026
… proof + live Hash bridge)

Rounds out the verify↔Merkle wiring to all three modes (generic→granular):
- inclusionVerifySound — inclusion-proof verification soundness: a generated
  (leaf, proof) reconstructs the tree's true root (merkleCorrect, Stage 1.1, read as
  a per-leaf verification guarantee). The propositional reconstruct = root is the
  wall-free core; the residual root == root Bool step is the documented Bits8 wall.
- hashToBytes — the live bridge decoding an A2ML Hash (hex string) to 32 Merkle
  HashBytes (via the proven Stage 2.3 hex codec); snapshot-root verification composes
  it with rootVerifySound. Conversion correctness is the hex boundary (2.3-bounded),
  surfaced as an explicit partial decode, not asserted.

(Mode 1, rootFaithful/rootVerifySound, landed in the previous commit / PR #53.)

Verified: idris2 0.8.0, --build (--total), 26/26 modules, axiom-free.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011z2t8zAxfcCNLJzU7YdpBQ
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