Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Only the eleven most recent times determine the median

Proved
BitcoinHeader.mtp_take

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

bitcoinbitcoin-mainnetblock-headerconsensusformal-verificationmedian-time-past

For every chain of times, MTP(times)=MTP(first eleven of times)\mathrm{MTP}(\text{times}) = \mathrm{MTP}(\text{first eleven of times})MTP(times)=MTP(first eleven of times): block times older than the eleventh ancestor have no influence on the median time past.

Preamble
import Definitions.Def_BitcoinHeader
Formal statement
theorem BitcoinHeader.mtp_take (times : List Int) :
    BitcoinHeader.medianTimePast times = BitcoinHeader.medianTimePast (times.take BitcoinHeader.nMedianTimeSpan) := by sorry
Source
Bitcoin Core a773e1e33b349dc819b5a0edc1c7a4839dc73b48: CBlockIndex::GetMedianTimePast and nMedianTimeSpan, MAX_FUTURE_BLOCK_TIME, src/chain.h: https://github.com/bitcoin/bitcoin/blob/a773e1e33b349dc819b5a0edc1c7a4839dc73b48/src/chain.h; ContextualCheckBlockHeader, src/validation.cpp (lines 4091-4128): https://github.com/bitcoin/bitcoin/blob/a773e1e33b349dc819b5a0edc1c7a4839dc73b48/src/validation.cpp; DeploymentActiveAfter (buried), src/deploymentstatus.h; BIP34Height, BIP66Height, BIP65Height in CMainParams, src/kernel/chainparams.cpp
Read-back

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

For every finite list of integers T=[t0,t1,…,tm−1]T = [t_0, t_1, \dots, t_{m-1}]T=[t0​,t1​,…,tm−1​] (including the empty list; there are no hypotheses), the statement asserts the equality of two integers:

medianTimePast(T)  =  medianTimePast(take11(T)),\mathrm{medianTimePast}(T) \;=\; \mathrm{medianTimePast}\bigl(\mathrm{take}_{11}(T)\bigr),medianTimePast(T)=medianTimePast(take11​(T)),

where take11(T)\mathrm{take}_{11}(T)take11​(T) denotes the list of the first min⁡(11,m)\min(11, m)min(11,m) entries of TTT in their given order (111111 being the constant nMedianTimeSpan; when m≤11m \le 11m≤11 this is TTT itself), and medianTimePast\mathrm{medianTimePast}medianTimePast is the function that, given a list LLL, first restricts to its first min⁡(11,∣L∣)\min(11,|L|)min(11,∣L∣) entries, sorts those into non-decreasing order w0≤⋯≤wn−1w_0 \le \dots \le w_{n-1}w0​≤⋯≤wn−1​ with n=min⁡(11,∣L∣)n = \min(11,|L|)n=min(11,∣L∣), and returns w⌊n/2⌋w_{\lfloor n/2\rfloor}w⌊n/2⌋​ (zero-based, natural-number division rounding down — the middle element for odd nnn, the upper-middle element for even nnn), or returns 000 when n=0n = 0n=0, i.e. when LLL is empty. Thus the claim is that first truncating TTT to its first eleven entries and then applying medianTimePast\mathrm{medianTimePast}medianTimePast gives the same integer as applying medianTimePast\mathrm{medianTimePast}medianTimePast to TTT directly. For T=[]T = []T=[] both sides are the fallback value 000. For m≤11m \le 11m≤11 both sides are literally the same expression applied to the same list. The only substantive content is for m>11m > 11m>11, where the right-hand side's argument has exactly 111111 entries and the left-hand side's argument has more.

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

    Confirmed by the moderator at approval.

  • Endorsed by pitimespi · Oct 26, 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