Calculated lock thresholds fit their signed destinations
ProvedBitcoinBIP68.calculated_boundsLet version and flags be arbitrary unsigned 32-bit words. Let a context and finite input list satisfy the admissible-domain conditions: , every input height at most , and nonnegative supplied ancestor clocks at most . Assume additionally that every actually enforced, non-disabled height sum fits , and every actually enforced, non-disabled time sum fits . These are bounds before subtraction of one, selected according to bit 22.
If calculation returns thresholds , then
Disabled inputs and disabled enforcement require no delay-sum bounds. Empty lists and zero delays are included. The result supplies range guarantees for the mathematical-integer model on the explicitly stated domain; it is not a theorem that the entire C++ caller always establishes that domain.
import Definitions.Def_BIP68_Model import Definitions.Def_BIP68_Core
theorem BitcoinBIP68.calculated_bounds (version flags : BitVec 32)
(ctx : BitcoinBIP68.Context) (inputs : List BitcoinBIP68.Input)
(hctx : BitcoinBIP68.admissible ctx inputs)
(hsafe : BitcoinBIP68.noOverflow version flags ctx inputs) :
let result := BitcoinBIP68.calculate version flags ctx inputs
(-1 ≤ result.minHeight ∧ result.minHeight ≤ (BitcoinBIP68.int32Max : Int)) ∧
(-1 ≤ result.minTime ∧ result.minTime ≤ (BitcoinBIP68.int64Max : Int)) := by sorryRead-back
What the Lean code literally says, in plain math · GPT-6 (Codex independent sub-agent)
For every pair of 32-bit words representing unsigned integers , every context consisting of a natural-number height and a function , and every finite ordered list of inputs, each consisting of a 32-bit sequence word with unsigned value and a natural-number coin height , assume that , that for every natural number , and that for every input in the list. Set to mean and odd. For each input, set to mean (bit 31 is set), set to mean (bit 22 is set), and put . Also assume that, for every input, if holds and does not hold, then when holds, and when does not hold; these sums and inequalities are over natural numbers. Define the calculated result as follows: start with integer accumulators and an empty auxiliary list; if holds, process the input list from left to right, leaving unchanged and prepending to the auxiliary list whenever bit 31 of the sequence word is set; otherwise, if bit 22 is set, replace by and leave unchanged; otherwise replace by and leave unchanged; in either of these latter two cases prepend to the auxiliary list. The additions and final subtraction by in these accumulator updates are integer operations; the value is equivalently obtained by masking the sequence word to its lowest 16 bits and shifting that 32-bit word left by nine bits. If does not hold, leave and set the auxiliary list to the reverse of the input coin-height list. The assertion is that the resulting two integer accumulators satisfy . The list may be empty or contain repetitions, coin heights and delays may be zero, and makes the time lookup use when ; a zero sum before the integer subtraction produces . The extra sum-bound assumptions impose no conditions when is false or for inputs whose bit 31 is set, but the context and coin-height assumptions still apply. An empty input list, or an enabled calculation in which every input has bit 31 set, leaves both integer accumulators equal to ; no monotonicity of is assumed.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.