Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Union bound over windows

Proved
BitcoinBackboneProb.typicalOn_failure_le_of_window

by pitimespi · Oct 30, 2026 · Mathlib 0df444a (Lean v4.33.1)

backbonebitcoinformal-verificationhoeffdinghonest-majoritymathlibnakamoto-consensusprobabilitytypical-execution

If every window of length at least λ≥1\lambda \ge 1λ≥1 fails with probability at most β\betaβ, then P(¬P(\negP(¬TypicalOn ω lam L)≤L2β) \le L^2 \beta)≤L2β.

Preamble
import Definitions.Def_BitcoinBackboneProb
open BitcoinBackboneProb BitcoinBackbone
open MeasureTheory ProbabilityTheory
Formal statement
theorem BitcoinBackboneProb.typicalOn_failure_le_of_window (n t : ℕ) (p : unitInterval)
    (lam L : ℕ) (hlam : 1 ≤ lam) (β : ℝ)
    (hβ : ∀ a k : ℕ, lam ≤ k → (P n t p).real
      {ω | ∑ i ∈ Finset.Ioo a (a + k), Y ω i ≤ ∑ i ∈ Finset.Icc a (a + k), Z ω i} ≤ β) :
    (P n t p).real {ω | ¬ TypicalOn ω lam L} ≤ (L : ℝ) ^ 2 * β := by sorry
Source
J. Garay, A. Kiayias, N. Leonardos, The Bitcoin Backbone Protocol: Analysis and Applications, EUROCRYPT 2015 (full version ePrint 2014/765): https://eprint.iacr.org/2014/765, Definition 9 (typical execution), Theorem 10, the honest-majority assumption; W. Hoeffding (1963) for the concentration bound; the backbone mission BitcoinBackbone (Execution, Typical, chain growth, common prefix, chain quality)
Read-back

What the Lean code literally says, in plain math · claude-fable-5-1 (independent sub-agent, blind: Lean code + auditor instructions only)

Read-back: BitcoinBackboneProb.typicalOn_failure_le_of_window

Statement. Let n,t∈Nn, t \in \mathbb Nn,t∈N, p∈[0,1]p \in [0,1]p∈[0,1], λ,L∈N\lambda, L \in \mathbb Nλ,L∈N and β∈R\beta \in \mathbb Rβ∈R. Assume

  • λ≥1\lambda \ge 1λ≥1;
  • for all a,k∈Na, k \in \mathbb Na,k∈N with λ≤k\lambda \le kλ≤k:
Pn,t,p({ω:∑i∈(a, a+k)Yi(ω)  ≤  ∑i∈[a, a+k]Zi(ω)})  ≤  βP_{n,t,p}\Big(\Big\{\omega : \sum_{i \in (a,\,a+k)} Y_i(\omega) \;\le\; \sum_{i \in [a,\,a+k]} Z_i(\omega)\Big\}\Big) \;\le\; \betaPn,t,p​({ω:i∈(a,a+k)∑​Yi​(ω)≤i∈[a,a+k]∑​Zi​(ω)})≤β

(here (a,a+k)={a+1,…,a+k−1}(a, a+k) = \{a+1,\dots,a+k-1\}(a,a+k)={a+1,…,a+k−1} has k−1k-1k−1 elements and [a,a+k]={a,…,a+k}[a,a+k] = \{a,\dots,a+k\}[a,a+k]={a,…,a+k} has k+1k+1k+1 elements; the event is the non-strict reverse of the window inequality; the hypothesis is required for every start aaa, with no upper bound on aaa or kkk).

Then

Pn,t,p({ω:not TypOn(ω,λ,L)})  ≤  L2 β,P_{n,t,p}\big(\{\omega : \text{not } \mathrm{TypOn}(\omega, \lambda, L)\}\big) \;\le\; L^2\, \beta ,Pn,t,p​({ω:not TypOn(ω,λ,L)})≤L2β,

with LLL cast to R\mathbb RR. No condition on the margin is assumed. The hypothesis implies β≥0\beta \ge 0β≥0 (it bounds a probability). For L=0L = 0L=0 the right side is 000 (and no window exists since λ≥1\lambda \ge 1λ≥1).

Probabilistic round model (unfolded)

  • Parameters. n,t∈Nn, t \in \mathbb Nn,t∈N are arbitrary natural numbers (either may be 000): nnn is the number of honest parties, ttt the number of adversarial queries per round. ppp is an element of the closed unit interval [0,1][0,1][0,1] (so p=0p = 0p=0 and p=1p = 1p=1 are allowed); wherever it appears in arithmetic it is the real number ppp. All casts of n,tn, tn,t and other naturals into formulas are casts into R\mathbb RR (so (λ−3)(\lambda - 3)(λ−3), (k−1)(k-1)(k−1) etc. below are real subtractions and may be negative), except where a natural-number subtraction is explicitly flagged.
  • Bernoulli law berp\mathrm{ber}_pberp​. The two-point Bernoulli measure on {true,false}\{\mathrm{true}, \mathrm{false}\}{true,false} built by Mathlib's bernoulliMeasure true false p: mass ppp on true\mathrm{true}true and mass 1−p1-p1−p on false\mathrm{false}false. It is a probability measure.
  • Round outcomes Rn,t\mathcal R_{n,t}Rn,t​. A round outcome is a pair ρ=(ρ1,ρ2)\rho = (\rho_1, \rho_2)ρ=(ρ1​,ρ2​) with ρ1:{0,…,n−1}→{true,false}\rho_1 : \{0,\dots,n-1\} \to \{\mathrm{true},\mathrm{false}\}ρ1​:{0,…,n−1}→{true,false} (which honest parties succeeded) and ρ2:{0,…,t−1}→{true,false}\rho_2 : \{0,\dots,t-1\} \to \{\mathrm{true},\mathrm{false}\}ρ2​:{0,…,t−1}→{true,false} (which adversarial queries succeeded). If n=0n = 0n=0 (resp. t=0t = 0t=0) the corresponding component is the unique empty function.
  • Round law μn,t,p\mu_{n,t,p}μn,t,p​. The product measure
μn,t,p=(⨂i=0n−1berp)⊗(⨂j=0t−1berp)\mu_{n,t,p} = \Big(\bigotimes_{i=0}^{n-1} \mathrm{ber}_p\Big) \otimes \Big(\bigotimes_{j=0}^{t-1} \mathrm{ber}_p\Big)μn,t,p​=(i=0⨂n−1​berp​)⊗(j=0⨂t−1​berp​)

on Rn,t\mathcal R_{n,t}Rn,t​ (product σ\sigmaσ-algebra): all n+tn + tn+t coordinates are independent, each true\mathrm{true}true with probability ppp. It is a probability measure.

  • Traces Ωn,t\Omega_{n,t}Ωn,t​. A trace is an infinite sequence ω=(ω0,ω1,ω2,… )\omega = (\omega_0, \omega_1, \omega_2, \dots)ω=(ω0​,ω1​,ω2​,…) of round outcomes, indexed by all r∈Nr \in \mathbb Nr∈N starting at r=0r = 0r=0; Ωn,t=Rn,tN\Omega_{n,t} = \mathcal R_{n,t}^{\mathbb N}Ωn,t​=Rn,tN​ with the product σ\sigmaσ-algebra.
  • Trace law Pn,t,pP_{n,t,p}Pn,t,p​. The infinite product probability measure Pn,t,p=⨂r∈Nμn,t,pP_{n,t,p} = \bigotimes_{r \in \mathbb N} \mu_{n,t,p}Pn,t,p​=⨂r∈N​μn,t,p​ on Ωn,t\Omega_{n,t}Ωn,t​ (Mathlib's Measure.infinitePi): the coordinates ωr\omega_rωr​ are i.i.d. with law μn,t,p\mu_{n,t,p}μn,t,p​. It is a probability measure. For any set A⊆Ωn,tA \subseteq \Omega_{n,t}A⊆Ωn,t​ (measurable or not; non-measurable sets get their outer measure), Pn,t,p(A)P_{n,t,p}(A)Pn,t,p​(A) below denotes the real number obtained by converting the (extended-nonnegative) measure of AAA to R\mathbb RR; it lies in [0,1][0,1][0,1].
  • Counts in one round. For ρ∈Rn,t\rho \in \mathcal R_{n,t}ρ∈Rn,t​:
#H(ρ)=#{ i<n:ρ1(i)=true }∈{0,…,n},#A(ρ)=#{ j<t:ρ2(j)=true }∈{0,…,t}.\#_H(\rho) = \#\{\, i < n : \rho_1(i) = \mathrm{true} \,\} \in \{0,\dots,n\}, \qquad \#_A(\rho) = \#\{\, j < t : \rho_2(j) = \mathrm{true} \,\} \in \{0,\dots,t\}.#H​(ρ)=#{i<n:ρ1​(i)=true}∈{0,…,n},#A​(ρ)=#{j<t:ρ2​(j)=true}∈{0,…,t}.
  • Round indicators. x(ρ)=1x(\rho) = 1x(ρ)=1 if #H(ρ)>0\#_H(\rho) > 0#H​(ρ)>0 and 000 otherwise; y(ρ)=1y(\rho) = 1y(ρ)=1 if #H(ρ)=1\#_H(\rho) = 1#H​(ρ)=1 and 000 otherwise (both natural numbers); w(ρ)=#A(ρ)−y(ρ)w(\rho) = \#_A(\rho) - y(\rho)w(ρ)=#A​(ρ)−y(ρ) computed in R\mathbb RR.
  • Trace variables. For ω∈Ωn,t\omega \in \Omega_{n,t}ω∈Ωn,t​ and r∈Nr \in \mathbb Nr∈N (including r=0r = 0r=0): Xr(ω)=x(ωr)X_r(\omega) = x(\omega_r)Xr​(ω)=x(ωr​), Yr(ω)=y(ωr)Y_r(\omega) = y(\omega_r)Yr​(ω)=y(ωr​), Zr(ω)=#A(ωr)Z_r(\omega) = \#_A(\omega_r)Zr​(ω)=#A​(ωr​) (natural numbers), Wr(ω)=w(ωr)∈RW_r(\omega) = w(\omega_r) \in \mathbb RWr​(ω)=w(ωr​)∈R. So Xr,Yr∈{0,1}X_r, Y_r \in \{0,1\}Xr​,Yr​∈{0,1} and Zr∈{0,…,t}Z_r \in \{0,\dots,t\}Zr​∈{0,…,t}.
  • Margin.
m(n,t,p)=n p (1−p) n −˙ 1−t p∈R,m(n,t,p) = n\,p\,(1-p)^{\,n \,\dot-\, 1} - t\,p \in \mathbb R,m(n,t,p)=np(1−p)n−˙​1−tp∈R,

where n−˙1n \dot- 1n−˙​1 is natural-number subtraction (truncated at 000): for n=0n = 0n=0 the exponent is 000 and m=−tpm = -t pm=−tp; for n=1n = 1n=1, m=p−tpm = p - tpm=p−tp; the convention 00=10^0 = 100=1 applies, so for n=1n = 1n=1, p=1p = 1p=1 the factor (1−p)0(1-p)^0(1−p)0 equals 111.

  • Rate.
κ(n,t,p)=m(n,t,p)22 (t+1)2 ≥0\kappa(n,t,p) = \frac{m(n,t,p)^2}{2\,(t+1)^2} \ \ge 0κ(n,t,p)=2(t+1)2m(n,t,p)2​ ≥0

(the denominator is at least 222, never zero).

Window conventions

For natural numbers a,ba, ba,b: [a,b]={a,a+1,…,b}[a,b] = \{a, a+1, \dots, b\}[a,b]={a,a+1,…,b} (closed window; empty if a>ba > ba>b, a single point if a=ba = ba=b) and (a,b)={a+1,…,b−1}(a,b) = \{a+1, \dots, b-1\}(a,b)={a+1,…,b−1} (open window; empty whenever b≤a+1b \le a + 1b≤a+1). A sum over an empty index set is 000. Sums of the natural-number variables Yi,ZiY_i, Z_iYi​,Zi​ are computed in N\mathbb NN and compared there.

Typicality on a horizon (unfolded)

For a trace ω\omegaω and λ,L∈N\lambda, L \in \mathbb Nλ,L∈N, TypOn(ω,λ,L)\mathrm{TypOn}(\omega, \lambda, L)TypOn(ω,λ,L) holds iff for all a,b∈Na, b \in \mathbb Na,b∈N with a+λ≤ba + \lambda \le ba+λ≤b and b≤Lb \le Lb≤L:

∑i∈[a,b]Zi(ω)  <  ∑i∈(a,b)Yi(ω)\sum_{i \in [a,b]} Z_i(\omega) \;<\; \sum_{i \in (a,b)} Y_i(\omega)i∈[a,b]∑​Zi​(ω)<i∈(a,b)∑​Yi​(ω)

(strict inequality; adversarial blocks counted over the closed window including both endpoints, uniquely successful rounds over the open window excluding both endpoints; a=0a = 0a=0, i.e. round 000 of the trace, is included).

Edge cases: if L<λL < \lambdaL<λ there is no admissible window and TypOn\mathrm{TypOn}TypOn holds vacuously (for every ω\omegaω). Any admissible window with b≤a+1b \le a+1b≤a+1 has an empty open window, so its right side is 000 and the strict inequality fails; hence for λ=0\lambda = 0λ=0, TypOn(ω,0,L)\mathrm{TypOn}(\omega,0,L)TypOn(ω,0,L) is false for every ω\omegaω and every LLL, and for λ=1\lambda = 1λ=1 it is false for every ω\omegaω as soon as L≥1L \ge 1L≥1.

Human review
  • Endorsed by Shuze Chen · Oct 30, 2026

    Confirmed by the moderator at approval.

  • Endorsed by pitimespi · Oct 30, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me