Appending a block that passes time-too-old never lowers the median
ProvedBitcoinHeader.mtp_monoFor every chain of times and time with ,
The new window is followed by the ten most recent times of : it gains , which lies above the old median, and loses at most the eleventh time of the old window. For a chain shorter than eleven blocks the window grows instead and the median index may move; the inequality holds in both cases.
import Definitions.Def_BitcoinHeader
theorem BitcoinHeader.mtp_mono (times : List Int) (t : Int)
(h : BitcoinHeader.medianTimePast times < t) :
BitcoinHeader.medianTimePast times ≤ BitcoinHeader.medianTimePast (t :: times) := 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 (possibly empty) and every integer , under the hypothesis
the statement asserts the non-strict inequality
where is the list obtained by placing in front of as its new first entry (so ). Here , for any list of integers , is computed by taking the first entries of , sorting them into non-decreasing order , and returning (zero-based, rounding down; the middle element for odd , the upper of the two middle elements for even ), with the fallback value when is empty. Note that the window of consists of together with the first entries of : when , the entry (the eleventh entry of ) belongs to the window of but not to the window of , so the two windows are not nested in general. The hypothesis compares only with the median of 's window, not with the individual entries of . Edge case : then , the hypothesis reads , and the conclusion reads . The conclusion is , not : it allows the two medians to be equal.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.