The median time past lies within any bounds of the window
ProvedBitcoinHeader.mtp_boundsFor every non-empty chain and integers such that every time in the window satisfies , also . In particular the median is between the oldest and the newest time of the window.
import Definitions.Def_BitcoinHeader
theorem BitcoinHeader.mtp_bounds (times : List Int) (h : times ≠ []) (lo hi : Int)
(hb : ∀ t ∈ BitcoinHeader.timeWindow times, lo ≤ t ∧ t ≤ hi) :
lo ≤ BitcoinHeader.medianTimePast times ∧ BitcoinHeader.medianTimePast times ≤ hi := by sorryRead-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 , under the hypothesis that is not the empty list (so ), and for every pair of integers (named lo) and (named hi), under the further hypothesis
the statement asserts
(both inequalities non-strict). Here with is the list of the first at-most-eleven entries of (all of when ), and the second hypothesis ranges over members of that window only: it requires every one of to lie in the closed interval , and says nothing about the entries when , which may lie outside . The quantity is obtained by sorting that same window into non-decreasing order and returning (zero-based position, natural-number division rounding down; the middle element when is odd, the upper of the two middle elements when is even); the definition's fallback value for an empty window does not arise because forces . Since the window is non-empty, the second hypothesis forces ; if the hypothesis is unsatisfiable and the statement holds vacuously for such . The conclusion is that the computed value lies in the closed interval . No claim is made for .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.