A W-bit Merkle root computation succeeds exactly up to 2^(W-1) leaves
ProvedBsv.Merkle.rootW_ok_iffbitcoindata-structuresformal-verificationmerkle-tree
Let be an arbitrary binary operation on a type with decidable equality and a default element, , and rootW the array-and-counter Merkle computation with a -bit counter. For every list of leaves , the computation returns a value, rather than a fault, if and only if
The bound is therefore exact. For it is leaves.
Formalization Note The statement is about the Lean model of the computation, not about a particular program.
Preamble
import Definitions.Def_bsv_merkle_width
Formal statement
namespace Bsv.Merkle
theorem rootW_ok_iff {α : Type} (H : α → α → α) [DecidableEq α] [Inhabited α]
(W : Nat) (hW : 0 < W) (l : List α) :
(∃ r, rootW H W l = .ok r) ↔ l.length ≤ 2 ^ (W - 1) := by sorry
end Bsv.MerkleSource
Gregory J. Ward, Bryan W. Daugherty, Shawn M. Ryan, BSV Lean proofs (Apache-2.0), theorem rootW_ok_iff. https://github.com/codenlighten/bsv-lean-proofs