Without witnesses the weight is four times the size
ProvedBitcoinSer.weight_no_witnessFor every transaction with no witness: the two serializations coincide, and .
import Definitions.Def_BitcoinSer
theorem BitcoinSer.weight_no_witness (tx : Tx) (h : tx.hasWitness = false) :
BitcoinSer.serTx true tx = BitcoinSer.serTx false tx ∧
BitcoinSer.txWeight tx = BitcoinSer.WITNESS_SCALE_FACTOR * (BitcoinSer.serTx false tx).length := 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: BitcoinSer.weight_no_witness
Binders and hypothesis. A transaction record and the hypothesis
i.e. the Boolean "some input has a non-empty witness list" evaluates to false — every input of has an empty witness list (vacuously so if has no inputs). No well-formedness is assumed; field values may be arbitrary.
Conclusion. A conjunction of two equalities:
where .
Unfolding the first conjunct. computes if , else ; the output is the 4-byte version, then only when , then the CompactSize-prefixed inputs, the CompactSize-prefixed outputs, then (only when ) one CompactSize-prefixed witness stack per input, then the 4-byte lock time. Under the hypothesis, for both and , so the marker bytes and the witness section are absent in both and the two byte strings coincide. The first conjunct says exactly this: with no non-empty witness, the "allow witness" mode produces the legacy encoding.
Unfolding the second conjunct. (the subtraction is on natural numbers and is ). Using the first conjunct, the second summand equals , giving with . The conclusion writes the right side as , i.e. , with the constant on the left of the product.
Edge cases covered: with no inputs (then is false automatically and the hypothesis holds); whose inputs all have witness ; arbitrary out-of-range version/lock time (truncated identically on both sides).
What is not said. Nothing when is true: no formula for the weight of a witness-bearing transaction, and no claim that the two serializations differ. Nothing about , , or any bound on the weight. Nothing about (the definition makes in this case, but the theorem does not mention it). No lengths are computed: the theorem relates the weight to the serialized length but does not say what that length is. It is a two-part equality under the single Boolean hypothesis.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.