The compact overflow flag is exactly the 256-bit bound
ProvedBitcoinPow.overflow_iffFor every 32-bit word with size and mantissa ,
where for and otherwise. The flag computed by SetCompact from the three threshold tests on and is therefore not an approximation: it is set precisely when the encoded value does not fit in 256 bits. Both directions are asserted, for all words.
import Definitions.Def_BitcoinPow
theorem BitcoinPow.overflow_iff (c : BitVec 32) :
BitcoinPow.compactOverflow c = true ↔ BitcoinPow.width ≤ BitcoinPow.specTarget c := 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)
Statement. For every 32-bit word (an integer with ), writing for its top byte () and for its low 23 bits (), the following two conditions are equivalent (a genuine "if and only if"):
- The Boolean value
is true (this is the custom "compact overflow" flag of ; all comparisons are strict);
- the natural number
(the custom "spec target" of , computed on unbounded natural numbers with no reduction modulo ) satisfies the non-strict inequality
Binders and hypotheses. The only variable is , universally quantified over all words; there are no further hypotheses. Bit 23 of (the bit of value ) plays no role on either side.
Edge cases visible in the statement. When the left side is false and , so the right side is also false. When the left side is false and , so the right side is false. The equivalence is asserted in both directions: overflow-flag true implies , and implies overflow-flag true. The threshold is exactly with , so a value of equal to would fall on the "overflow" side (though is a multiple of with times a power of 256, so the auditor may check which values are attainable).
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.