CheckLockTime for a block-height expiry
ProvedBitcoinHtlc.checkLockTime_iffFor : checkLockTime tx nIn expiry = true iff the transaction's nLockTime is also a block height (below 500,000,000), expiry ≤ nLockTime, and the input's nSequence is not 0xffffffff. BIP65 as GenericTransactionSignatureChecker::CheckLockTime implements it.
import Definitions.Def_BitcoinHtlc import Definitions.Def_BitcoinSer import Definitions.Def_BitcoinSig import Definitions.Def_BitcoinToLocal open BitcoinToLocal BitcoinSig BitcoinVerify open BitcoinScript
theorem BitcoinHtlc.checkLockTime_iff (tx : BitcoinSer.Tx) (nIn : Nat) (expiry : Int) (h0 : 0 ≤ expiry)
(hT : expiry < 500000000) :
BitcoinSig.checkLockTime tx nIn expiry = true ↔
tx.nLockTime < 500000000 ∧ expiry ≤ (tx.nLockTime : Int) ∧ BitcoinToLocal.inputSequence tx nIn ≠ 0xffffffff := 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)
Read-back: BitcoinHtlc.checkLockTime_iff
Statement. Let be any transaction, i.e. a record with a version (a natural number), a list of inputs (each input a record with a previous outpoint, a scriptSig byte string, a natural number nSequence and a witness list), a list of outputs, and a natural number (no upper bound such as is assumed on it here). Let be any natural number (an input index, possibly out of range) and any integer satisfying the two hypotheses and . Then the theorem asserts the equivalence
where the comparison is between integers (the natural number cast to ), and the two functions are as follows. ("input sequence") is the nSequence field of the -th input of (0-based) when , and otherwise the nSequence of a default input, which is . is the transcription of Bitcoin Core's CheckLockTime as a Boolean function of the transaction, the input index and an integer operand : it is false unless either ( and ) or ( and ); otherwise it is false if (as integers); otherwise it is false if the nSequence of the -th input, with the same out-of-range default input (nSequence ), equals ; and otherwise it is true. Nothing else is assumed about or ; in particular when both sides refer to the default sequence value .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.