Re-encoding a target rounds it down
ProvedBitcoinPow.getCompact_leFor every ,
GetCompact keeps only the top three bytes of (fewer when the mantissa's bit 23 forces a further byte shift), so decoding the result gives with some low bits cleared, never more than . The case is included and gives .
import Definitions.Def_BitcoinPow
theorem BitcoinPow.getCompact_le (v : Nat) (hv : v < BitcoinPow.width) :
BitcoinPow.setCompact (BitcoinPow.getCompact v) ≤ v := 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 ,
where ("getCompact") maps a natural number to a 32-bit word and ("setCompact") maps a 32-bit word back to a natural number, both custom functions unfolded below. The inequality is non-strict.
The encoding . Let if and otherwise (the number of binary digits of ). Let (the number of bytes of ; for , and under the hypothesis ). Let
(Since , in fact and the reductions modulo and do not change the value.) Let be true exactly when bit 23 of is set, i.e. . Put and if is true, and , otherwise. Then is the 32-bit word , where OR is bitwise-or of natural numbers. For this is the word .
The decoding . For a 32-bit word with top byte and low 23 bits ,
Note that reads only bits 0–22 and 24–31 of ; bit 23 is ignored.
Binders and hypotheses. One universally quantified natural number and one hypothesis (strict). The claim is the single inequality ; equality is permitted and nothing is said about how far below the value may fall. For the claim reads . Nothing is asserted for .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.