Acceptance by the contextual header check, characterized
ProvedBitcoinHeader.contextualCheck_iffFor every header , previous height , chain of previous times, required nBits and local time , the contextual check accepts exactly when
where outdated is the disjunction of the three version-floor conditions. These are the bad-diffbits, time-too-old, time-too-new and bad-version rejections of ContextualCheckBlockHeader.
import Definitions.Def_BitcoinHeader
theorem BitcoinHeader.contextualCheck_iff (h : BitcoinHeader.Header) (prevHeight : Nat) (prevTimes : List Int)
(required : BitVec 32) (now : Int) :
BitcoinHeader.contextualCheck h prevHeight prevTimes required now = true ↔
h.bits = required ∧
BitcoinHeader.medianTimePast prevTimes < h.time ∧
h.time ≤ now + BitcoinHeader.MAX_FUTURE_BLOCK_TIME ∧
¬ ((h.version < 2 ∧ BitcoinHeader.BIP34Height ≤ prevHeight + 1) ∨
(h.version < 3 ∧ BitcoinHeader.BIP66Height ≤ prevHeight + 1) ∨
(h.version < 4 ∧ BitcoinHeader.BIP65Height ≤ prevHeight + 1)) := 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 Header — a record with an arbitrary integer field , an arbitrary integer field , and a 32-bit bit-vector field — every natural number (named prevHeight), every finite list of integers (named prevTimes, possibly empty), every 32-bit bit-vector (named required; a free parameter, not computed from anything), and every integer (named now; a free integer parameter), the statement asserts a logical equivalence ("if and only if") between the Boolean-valued function evaluating to the Boolean true and the conjunction of the following four propositions:
- (equality of 32-bit bit-vectors);
- (strict integer inequality), where is obtained by taking the first entries of , sorting them 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), or returning the fallback value when is empty — so for this conjunct is simply ;
- (non-strict integer inequality; is the constant
MAX_FUTURE_BLOCK_TIME); - the negation
with , , the constants BIP34Height, BIP66Height, BIP65Height, integer comparisons on , and natural-number addition .
Unfolding, is by definition the Boolean "and" of: the Boolean deciding ; the Boolean deciding ; the Boolean deciding ; and the Boolean negation of , where is the Boolean "or" of ( and ), ( and ), ( and ). So the statement says the Boolean computation returns true exactly when the four propositions, with each Boolean test replaced by the relation it decides, all hold; by the "only if" direction it returns false exactly when at least one fails. There are no hypotheses; the equivalence is asserted for all values of the five parameters, including , any (so conjunct 3 can be made true or false by choice of independently of ), and any (so conjunct 1 depends only on whether happens to equal ). Nothing relates to .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.