IsPayToScriptHash characterized
ProvedBitcoinVerify.isPayToScriptHash_iffA byte string satisfies IsPayToScriptHash iff it is OP_HASH160 <h> OP_EQUAL for some 20-byte .
import Definitions.Def_BitcoinVerify open BitcoinVerify BitcoinSer BitcoinSig open BitcoinScript hiding Bytes Byte
theorem BitcoinVerify.isPayToScriptHash_iff (s : Bytes) :
BitcoinVerify.isPayToScriptHash s = true ↔ ∃ h : Bytes, h.length = 20 ∧ s = BitcoinVerify.p2shBytes h := 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.isPayToScriptHash_iff
Binders and hypothesis. There is one universally quantified variable: , a byte string (a finite list of 8-bit bytes). There are no hypotheses.
Conclusion. The statement is a biconditional:
Unfolding the left-hand side. isPayToScriptHash s is a Boolean computed as the conjunction of four decidable tests: ; the byte at index of equals ; the byte at index equals ; the byte at index equals . Indices are read with a default of when out of range, but because the length test forces , all three indices are in range whenever the whole conjunction is true. The 20 bytes at indices are unconstrained. So the left side says exactly: is a 23-byte string of the form .
Unfolding the right-hand side. p2shBytes h is the byte string , where pushBytes is the canonical push encoding: for it is the single length byte followed by . With this is the 23-byte string . So the right side says exactly: there is a 20-byte string with .
Logical content. The theorem asserts that the two syntactic characterizations coincide for every byte string : the index-wise test with a fixed length is equivalent to the existence of a 20-byte middle segment. Both directions are claimed. The existential is a plain existence, not uniqueness, though with fixed the only candidate is .
What is not said. The theorem says nothing about the behaviour of verifyScript or of any evaluation on such an ; it does not say that a P2SH script is or is not a witness program; it does not say anything about p2shBytes h for (such strings exist and may or may not satisfy isPayToScriptHash — the theorem only asserts that if isPayToScriptHash s holds then some 20-byte works, and conversely); it does not mention hashes, so the middle 20 bytes are not required to be the hash160 of anything; and it does not relate isPayToScriptHash to any flag in a context.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.