IsWitnessProgram characterized
ProvedBitcoinVerify.isWitnessProgram_iffisWitnessProgram s = some (v, program) iff , and is OP_v <program> (a single direct push), i.e. witnessBytes v program.
import Definitions.Def_BitcoinVerify open BitcoinVerify BitcoinSer BitcoinSig open BitcoinScript hiding Bytes Byte
theorem BitcoinVerify.isWitnessProgram_iff (s : Bytes) (v : Nat) (prog : Bytes) :
BitcoinVerify.isWitnessProgram s = some (v, prog) ↔
v ≤ 16 ∧ 2 ≤ prog.length ∧ prog.length ≤ 40 ∧ s = BitcoinVerify.witnessBytes v prog := 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: BitcoinVerify.isWitnessProgram_iff
Binders and hypothesis. Three universally quantified variables: , a byte string; , a natural number; , a byte string. There are no hypotheses.
Conclusion. A biconditional:
Unfolding the left-hand side. isWitnessProgram s returns nothing unless (it returns nothing when or ). Writing for the first byte of (as a natural number), it returns nothing unless or . It then requires that the second byte , as a natural number, satisfy ; if so it returns the pair , otherwise nothing. Here if and (truncated subtraction) otherwise. Consequently the left side holds exactly when: ; and , or with ; ; and is the suffix of after its first two bytes (so ).
Unfolding the right-hand side. witnessBytes v prog is the byte string whose first byte is if and otherwise, followed by pushBytes prog. For , pushBytes prog is the single length byte followed by . So, under the three bounds on the right, must be the -byte string: the version byte (, or through ), the length byte , then .
Logical content. For every , , : the parser recognizes as a witness program with exactly this version and this program if and only if is at most , the program has between and bytes inclusive, and is literally the encoding witnessBytes v prog. Note that the right side uses with no lower bound (so is included) and that the bounds and are both non-strict.
What is not said. Nothing is claimed about except implicitly through the biconditional (for such the left side must be false, since the right side is); nothing is claimed about what isWitnessProgram returns on strings that are not witness programs beyond "not some (v, prog)"; nothing about evaluation, about verifyWitnessProgram, about any flag, or about which versions are "known". The theorem does not say that the version byte of witnessBytes v prog is in range for (it is not, and that is consistent with the statement).
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.