A W-bit Merkle counter is correct for up to 2^(W-1) leaves
ProvedBsv.Merkle.rootW_eqbitcoindata-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, as in the imported definitions. If and the list has at most leaves, then no fault occurs and
For the bound 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_eq {α : Type} (H : α → α → α) [DecidableEq α] [Inhabited α]
(W : Nat) (hW : 0 < W) (l : List α) (hl : l.length ≤ 2 ^ (W - 1)) :
rootW H W l = .ok (root H l) := by sorry
end Bsv.MerkleSource
Gregory J. Ward, Bryan W. Daugherty, Shawn M. Ryan, BSV Lean proofs (Apache-2.0), theorem rootW_eq. https://github.com/codenlighten/bsv-lean-proofs