Compact rounding is order-preserving
ProvedBitcoinPow.round_monoFor all with ,
Decoding after encoding clears a number of low bits that depends only on the position of the top bit; values with the same top bit are rounded on the same grid, and a value with a lower top bit is below the retained top bit of the other. This is the property PermittedDifficultyTransition relies on when it compares re-encoded bounds with a decoded word.
import Definitions.Def_BitcoinPow
theorem BitcoinPow.round_mono (v w : Nat) (hvw : v ≤ w) (hw : w < BitcoinPow.width) :
BitcoinPow.setCompact (BitcoinPow.getCompact v) ≤ BitcoinPow.setCompact (BitcoinPow.getCompact w) := 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 all natural numbers and such that (non-strict) and (strict),
with a non-strict inequality in the conclusion. Here ("getCompact") is the custom map from natural numbers to 32-bit words and ("setCompact") the custom map from 32-bit words to natural numbers, unfolded below; the composite is the "round-trip" of a value through the compact encoding.
The encoding (for ). Let if and otherwise. Let . Let
Let be true exactly when . Put , if is true, else , . Then is the 32-bit word .
The decoding . For a 32-bit word with top byte and low 23 bits ,
Binders and hypotheses. Two universally quantified natural numbers ; two hypotheses, and (the bound on follows from these). The conclusion is monotonicity of between the two given points only; equality is allowed even when . The case is included (and then the claim is reflexive). The case is included, where is the word and . Nothing is asserted when .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.