A push-only scriptSig parses to its pushes
ProvedBitcoinVerify.parseScript_pushesFor elements each within 520 bytes, parseScript (pushesBytes ps) = some (ps.map push): the canonical pushes (direct, PUSHDATA1, PUSHDATA2) parse back to the pushed elements.
import Definitions.Def_BitcoinVerify import Definitions.Def_BitcoinScript import Definitions.Def_BitcoinSig open BitcoinVerify BitcoinSer BitcoinSig open BitcoinScript hiding Bytes Byte
theorem BitcoinVerify.parseScript_pushes (ps : List Bytes) (hp : ∀ p ∈ ps, p.length ≤ BitcoinScript.MAX_SCRIPT_ELEMENT_SIZE) :
BitcoinSig.parseScript (BitcoinVerify.pushesBytes ps) = some (ps.map Instr.push) := 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.parseScript_pushes
Binders and hypothesis. One universally quantified variable , a finite list of byte strings (each a finite list of 8-bit bytes). One hypothesis hp: every element of satisfies (MAX_SCRIPT_ELEMENT_SIZE). The list may be empty, in which case the hypothesis holds vacuously.
Conclusion.
i.e. the byte-level parser succeeds on the concatenated canonical pushes and returns exactly the instruction list consisting of one push instruction per element of , carrying that element's bytes, in the same order. For this says parseScript [] = some [].
Unfolding pushesBytes. pushesBytes ps concatenates pushBytes p over the elements of in order. pushBytes p is: for , the single byte followed by (for , the lone byte ); for , , one length byte, then ; for , , two little-endian length bytes, then ; otherwise , four little-endian length bytes, then . Under only the first three shapes occur.
Unfolding parseScript. parseScript s runs parseScriptAux with fuel : on the empty string it returns some []; with zero fuel on a non-empty string it returns nothing; otherwise it calls getOp on and, on success with instruction and remainder , recursively parses with one less fuel and prepends ; any failure propagates as nothing. getOp on a non-empty string with first byte : if it is a push — for the push length is itself; for the next byte is the length (nothing if absent); for the next two bytes little-endian (nothing if fewer than two remain); for the next four (nothing if fewer than four) — and then nothing if fewer than that many bytes remain, else the push of those bytes and the rest; if it is the non-push opcode . Each successful getOp consumes at least one byte, so fuel never runs out early.
Logical content. The theorem asserts that the encoder pushBytes and the decoder getOp are inverse along concatenations: parsing re-splits the byte string exactly at the boundaries the encoder wrote, and recovers each element's bytes unchanged as a push instruction, provided every element has at most 520 bytes. It is an equality of optional instruction lists, so it also asserts that the parse does not fail.
What is not said. The theorem does not say anything about elements longer than 520 bytes (the PUSHDATA2/PUSHDATA4 shapes are then outside the statement, even though the hypothesis is not visibly used by the parser); it does not say that the parsed instructions execute successfully or satisfy the interpreter's 520-byte push limit — it is only about parsing; it does not bound the total length (no MAX_SCRIPT_SIZE condition, and parseScript has none); it does not assert the converse (that every byte string parsing to a list of pushes is of the form pushesBytes ps — other encodings of the same pushes exist); and it does not relate to isPushOnly or verifyScript.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.