A pre-signed HTLC-timeout transaction confirms only above the expiry height
ProvedBitcoinHtlcLocks.presigned_timeout_heightFor , a transaction with nLockTime = expiry and an in-range input whose nSequence is not final: isFinalTx tx height blockTime = true implies expiry < height. BOLT #3's HTLC-timeout transaction, which spends an offered HTLC with the 2-of-2 signatures, is built exactly so.
import Definitions.Def_BitcoinHtlcLocks import Definitions.Def_BitcoinSer open BitcoinHtlcLocks BitcoinVerify BitcoinHtlc open BitcoinScript hiding Bytes Byte
theorem BitcoinHtlcLocks.presigned_timeout_height (tx : BitcoinSer.Tx) (expiry height : Nat) (blockTime : Int)
(hexp : 0 < expiry ∧ expiry < BitcoinBlockV2.LOCKTIME_THRESHOLD) (htx : tx.nLockTime = expiry)
(i : Nat) (hi : i < tx.vin.length)
(hseq : (tx.vin.getD i ⟨⟨[], 0⟩, [], 0, []⟩).nSequence ≠ BitcoinBlockV2.SEQUENCE_FINAL)
(hfinal : BitcoinBlockV2.isFinalTx tx height blockTime = true) : expiry < height := 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: BitcoinHtlcLocks.presigned_timeout_height
Declaration shape. This is a theorem with a universally quantified transaction, two natural numbers (an expiry and a height), an integer block time, an input index, and five hypotheses; the conclusion is a single strict inequality between natural numbers (one direction only, not a bi-implication).
Objects involved. A transaction is a record with four fields: a version number , a finite list of inputs , a finite list of outputs , and a lock time (a natural number, not bounded by the statement to 32 bits). An input is a record with a previous outpoint (a byte string together with a natural-number index), a byte string scriptSig, a sequence number , and a witness stack (a list of byte strings). Two constants:
The finality predicate. For a transaction , a height and a block time , the Boolean is defined by three cases, tried in order:
- if , the value is true;
- otherwise, let cast to an integer, and let the comparison target be (cast to ) when (as natural numbers) and otherwise; if target (as integers), the value is true;
- otherwise the value is true exactly when every input of has (vacuously true for an empty input list), and false otherwise.
The block time is consulted only when the lock time is at or above .
The indexed-input access. "The -th input of with default" is the zero-based -th element of when , and otherwise the default input with outpoint (empty byte string, ), empty scriptSig, and empty witness. In this theorem the hypothesis is present, so the default is never selected.
Statement. For every transaction , every , every (height), every (blockTime), assuming
- (hexp) and (both as natural numbers);
- (htx) ;
- for every with (hi) ;
- (hseq) the -th input of (with the default described above) has ;
- (hfinal) ;
it follows that
a strict inequality between natural numbers.
Edge cases made explicit.
- By (htx) and (hexp), is non-zero and strictly below the threshold, so case 1 of does not apply and in case 2 the comparison target is the height ; the block time is an unconstrained binder not used by the conclusion.
- (hi) forces to be non-empty, and (hseq) singles out one input whose sequence number is not .
- Only one direction is asserted: from finality to . The converse is not part of this statement.
- No hypothesis constrains (it may be , in which case the hypotheses would have to be jointly unsatisfiable for the conclusion to hold), , , or the sequence numbers of inputs other than the -th.
- The hypothesis (hexp) is stated on the natural number ; the comparison inside is on integer casts of natural numbers.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.