proof(merkle): Stage 1.2 — root-fold law (root of buildMerkleTree = foldRoot over leaves)#49
Merged
Merged
Conversation
…oldRoot over leaves) Prove the Merkle root is a deterministic, representation-independent fold over the leaf vector: rootHashWith h (buildMerkleTree hs) = foldRoot h hs, generic over the combiner h (XOR and BLAKE3 alike). - foldRoot: the leaf-only spec of the root (singleton -> element; a 2^(S k) vector splits at 2^k and combines its two sub-folds with h, the same split buildMerkleTree uses). - rootFoldSplit: the inductive step on the already-split halves, so the rootHashWith-of-Node reduction is clean and decoupled from the `with` abstraction (mirrors buildGetLeafSplit; the IH is a higher-order argument). - rootFoldLaw: the theorem; base Refl, step via rootFoldSplit applied to the IH. Pairs with buildGetLeaf to fully characterise buildMerkleTree (leaves + root) and hands the Stage-4 binding argument a leaf-only handle on the root. Machine-checked, axiom-free, total (clean --total build, 19/19). PROOFS.adoc marks Stage 1.2 DONE and adds rootFoldLaw/foldRoot to the proven surface. https://claude.ai/code/session_011z2t8zAxfcCNLJzU7YdpBQ
hyperpolymath
marked this pull request as ready for review
June 18, 2026 00:11
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.
Summary
Stage 1.2 of the proof campaign (see
docs/PROOFS.adoc). Proves the Merkle root is a deterministic, representation-independent fold over the leaf vector:What landed (
ochrance-core/Ochrance/Filesystem/MerkleBuild.idr)foldRoot— the leaf-only spec of the root (singleton → element; a2^(S k)vector splits at2^kand combines its two sub-folds withh, the same splitbuildMerkleTreeuses).rootFoldSplit— the inductive step stated on the already-split halves, so therootHashWith-of-Nodereduction is clean and decoupled from thewithabstraction (mirrors Stage 1.1'sbuildGetLeafSplit; the IH is a higher-order argument). This was the one wrinkle: a naiverewriteunderwithfails becausebuildMerkleTree's internalcaseis left as a stucklet— the split-lemma sidesteps it.rootFoldLaw— the theorem; baseRefl, step viarootFoldSplitapplied to the IH.Why it matters
Pairs with
buildGetLeaf(Stage 1.1) to fully characterisebuildMerkleTree— both its leaves (getLeafHash) and its root (rootHashWith) are pinned to the leaf vector. Hands the Stage-4 binding argument a leaf-only handle on the root ("the root is a function of the leaves").Verification
idris2 --build ochrance.ipkgunder--total, 19/19, exit 0. Nobelieve_me/assert_*/postulate/holes.docs/PROOFS.adocupdated: Stage 1.2 marked DONE;rootFoldLaw/foldRootadded to the proven surface.Next: Stage 1.3 (the IO↔pure bridge — the estate-wide spine).
🤖 Generated with Claude Code
https://claude.ai/code/session_011z2t8zAxfcCNLJzU7YdpBQ
Generated by Claude Code