GetCompact never produces a negative or overflowing word
ProvedBitcoinPow.getCompact_validFor every , the word has its negative flag clear and its overflow flag clear. The mantissa it assembles is below after the bit-23 normalization, so the sign bit is never set, and its size byte is at most with a mantissa below in that extreme case, so none of the overflow thresholds is met.
import Definitions.Def_BitcoinPow
theorem BitcoinPow.getCompact_valid (v : Nat) (hv : v < BitcoinPow.width) :
BitcoinPow.compactNegative (BitcoinPow.getCompact v) = false ∧
BitcoinPow.compactOverflow (BitcoinPow.getCompact v) = false := 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 natural number with , writing for the 32-bit word produced by the custom encoding "getCompact" (unfolded below), with top byte and low 23 bits , both of the following Boolean values are false:
- the "compact negative" flag of ,
i.e. it is not the case that ( and ); and
- the "compact overflow" flag of ,
i.e. either , or ( and ( or ) and ( or )).
The encoding . Let if and otherwise. Let ( for ; under the hypothesis). Let
(so that ). Let be true exactly when . Put , if is true, else , . Then as a 32-bit word; so and (when , which holds here), and bit 23 of is bit 23 of .
Binders and hypotheses. One universally quantified natural number , one hypothesis (strict). The conclusion is a conjunction of two equalities between Boolean values and the constant false. Nothing is asserted for . For , is the word , for which and both flags are false by their first conjunct.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.