BIP68 sequence masks agree with arithmetic decoding
ProvedBitcoinBIP68.decode_sequenceLet be any unsigned 32-bit word and its value. Put . The implementation's disable-bit and time-type tests agree with the corresponding quotient-and-remainder tests, its masked delay is , and its masked left-shifted seconds value is :
The statement includes every bit pattern and makes no hypothesis on the unused bits. It connects the bit-vector implementation to the arithmetic specification, including the fact that the masked nine-bit shift loses no significant bits.
import Definitions.Def_BIP68_Model import Definitions.Def_BIP68_Core
theorem BitcoinBIP68.decode_sequence (sequence : BitVec 32) :
(BitcoinBIP68.coreDisabled sequence = true ↔ BitcoinBIP68.specDisabled sequence) ∧
(BitcoinBIP68.coreTimeBased sequence = true ↔ BitcoinBIP68.specTimeBased sequence) ∧
BitcoinBIP68.coreDelay sequence = BitcoinBIP68.specDelay sequence ∧
BitcoinBIP68.coreSeconds sequence = 512 * BitcoinBIP68.specDelay sequence := by sorryRead-back
What the Lean code literally says, in plain math · GPT-6 (Codex independent sub-agent)
For every 32-bit word , let be its unsigned natural-number value, so . The following four statements hold simultaneously: (1) the Boolean test that the bitwise conjunction of with the 32-bit mask is nonzero returns true if and only if ; (2) the Boolean test that the bitwise conjunction of with the 32-bit mask is nonzero returns true if and only if ; (3) the unsigned natural-number value of the bitwise conjunction of with the 32-bit mask equals ; and (4) the unsigned natural-number value obtained by taking that last conjunction and shifting it left by nine positions as a 32-bit word, discarding any bits shifted beyond its width, equals , with this multiplication performed in the natural numbers. There are no additional hypotheses on : the statements include the all-zero word, the all-one word, and every combination of its bits, including either value of the bits tested in (1) and (2).
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.