Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The interpreter's loop is runSeq followed by the balance check

Proved
BitcoinMiniscript.run_eq_runSeq

by pitimespi · Oct 29, 2026 · Mathlib 0df444a (Lean v4.33.1)

bitcoinbitcoin-mainnetcompiler-correctnessformal-verificationminiscriptpolicyscripttype-system

run f o s sc is runSeq f o s sc followed by the test that the condition stack is empty.

Preamble
import Definitions.Def_BitcoinMiniscript
import Definitions.Def_BitcoinScript
open BitcoinMiniscript BitcoinToLocal BitcoinHtlc BitcoinScript BitcoinSig BitcoinVerify
Formal statement
theorem BitcoinMiniscript.run_eq_runSeq (f : BitcoinScript.Flags) (o : BitcoinScript.Oracle)
    (s : BitcoinScript.State) (sc : BitcoinScript.Script) :
    BitcoinScript.run f o s sc =
      match BitcoinMiniscript.runSeq f o s sc with
      | none => none
      | some s' => if s'.vfExec.isEmpty then some s' else none := by sorry
Source
Miniscript reference (P. Wuille, A. Poelstra, S. Kanjalkar): translation table, type system and correctness/malleability properties, https://bitcoin.sipa.be/miniscript/; Bitcoin Core a773e1e33b349dc819b5a0edc1c7a4839dc73b48: src/script/miniscript.h, src/script/miniscript.cpp (https://github.com/bitcoin/bitcoin/blob/a773e1e33b349dc819b5a0edc1c7a4839dc73b48/src/script/miniscript.h); EvalScript (src/script/interpreter.cpp)
Read-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: BitcoinMiniscript.run_eq_runSeq

Statement. For any flags fff, any oracle ooo (arbitrary functions, see below), any interpreter state sss (any stacks, condition stack and counter) and any script sc\mathit{sc}sc:

runf,o(s,sc)={noneif runSeqf,o(s,sc)=none,some(s′)if runSeqf,o(s,sc)=some(s′) and the condition stack of s′ is empty,noneif runSeqf,o(s,sc)=some(s′) and the condition stack of s′ is nonempty.\mathrm{run}_{f,o}(s, \mathit{sc}) = \begin{cases} \text{none} & \text{if } \mathrm{runSeq}_{f,o}(s, \mathit{sc}) = \text{none},\\ \text{some}(s') & \text{if } \mathrm{runSeq}_{f,o}(s, \mathit{sc}) = \text{some}(s') \text{ and the condition stack of } s' \text{ is empty},\\ \text{none} & \text{if } \mathrm{runSeq}_{f,o}(s, \mathit{sc}) = \text{some}(s') \text{ and the condition stack of } s' \text{ is nonempty.}\end{cases}runf,o​(s,sc)=⎩⎨⎧​nonesome(s′)none​if runSeqf,o​(s,sc)=none,if runSeqf,o​(s,sc)=some(s′) and the condition stack of s′ is empty,if runSeqf,o​(s,sc)=some(s′) and the condition stack of s′ is nonempty.​

Definitions used in the statement, unfolded

Basic data (from the script-interpreter preamble)

Byte strings, stacks, witnesses. A byte string is a finite list of 8-bit bytes (values 0x00\mathtt{0x00}0x00–0xff\mathtt{0xff}0xff); [ ][\,][] is the empty byte string and ∣b∣|b|∣b∣ the length of bbb. Stacks, witnesses and outputs are finite lists of byte strings written top element first. For such lists, x::lx :: lx::l is the list with xxx placed on top of lll, l1+ ⁣ ⁣+l2l_1 \mathbin{+\!\!+} l_2l1​++l2​ is concatenation (in w+ ⁣ ⁣+restw \mathbin{+\!\!+} \mathit{rest}w++rest all elements of www lie above all elements of rest\mathit{rest}rest, the first element of www being the top of the stack), and ∣l∣|l|∣l∣ is the number of elements.

Constants.

MAX_SCRIPT_ELEMENT_SIZE=520,MAX_OPS_PER_SCRIPT=201,MAX_PUBKEYS_PER_MULTISIG=20,MAX_STACK_SIZE=1000.\mathrm{MAX\_SCRIPT\_ELEMENT\_SIZE}=520,\quad \mathrm{MAX\_OPS\_PER\_SCRIPT}=201,\quad \mathrm{MAX\_PUBKEYS\_PER\_MULTISIG}=20,\quad \mathrm{MAX\_STACK\_SIZE}=1000.MAX_SCRIPT_ELEMENT_SIZE=520,MAX_OPS_PER_SCRIPT=201,MAX_PUBKEYS_PER_MULTISIG=20,MAX_STACK_SIZE=1000.

castToBool\mathrm{castToBool}castToBool. For a byte string: castToBool([ ])=false\mathrm{castToBool}([\,])=\text{false}castToBool([])=false; castToBool([b0])=(b0≠0x00∧b0≠0x80)\mathrm{castToBool}([b_0]) = (b_0\neq \mathtt{0x00} \wedge b_0 \neq \mathtt{0x80})castToBool([b0​])=(b0​=0x00∧b0​=0x80); for a string with at least two bytes, castToBool(b0::r)=(b0≠0)∨castToBool(r)\mathrm{castToBool}(b_0 :: r) = (b_0 \neq 0) \vee \mathrm{castToBool}(r)castToBool(b0​::r)=(b0​=0)∨castToBool(r). So it is true exactly when some byte other than the last is nonzero, or the last byte is neither 0x00\mathtt{0x00}0x00 nor 0x80\mathtt{0x80}0x80; the empty string, all-zero strings, and strings of zero bytes followed by a final 0x80\mathtt{0x80}0x80 are false.

boolBytes\mathrm{boolBytes}boolBytes. boolBytes(true)=[0x01]\mathrm{boolBytes}(\text{true}) = [\mathtt{0x01}]boolBytes(true)=[0x01], boolBytes(false)=[ ]\mathrm{boolBytes}(\text{false}) = [\,]boolBytes(false)=[].

serialize\mathrm{serialize}serialize (script-number encoding of an integer nnn). serialize(0)=[ ]\mathrm{serialize}(0) = [\,]serialize(0)=[]. For n≠0n\neq 0n=0, let mag\mathit{mag}mag be the little-endian base-256 digits of ∣n∣|n|∣n∣ with no most-significant zero bytes. If the last (most significant) byte of mag\mathit{mag}mag has bit 0x80\mathtt{0x80}0x80 set, the result is mag\mathit{mag}mag followed by one extra byte, 0x80\mathtt{0x80}0x80 if n<0n<0n<0 and 0x00\mathtt{0x00}0x00 if n>0n>0n>0; otherwise the result is mag\mathit{mag}mag with bit 0x80\mathtt{0x80}0x80 of its last byte set if n<0n<0n<0, and mag\mathit{mag}mag itself if n>0n>0n>0. Examples: serialize(1)=[0x01]\mathrm{serialize}(1)=[\mathtt{0x01}]serialize(1)=[0x01], serialize(−1)=[0x81]\mathrm{serialize}(-1)=[\mathtt{0x81}]serialize(−1)=[0x81], serialize(32)=[0x20]\mathrm{serialize}(32)=[\mathtt{0x20}]serialize(32)=[0x20], serialize(128)=[0x80,0x00]\mathrm{serialize}(128)=[\mathtt{0x80},\mathtt{0x00}]serialize(128)=[0x80,0x00], serialize(231−1)=[0xff,0xff,0xff,0x7f]\mathrm{serialize}(2^{31}-1)=[\mathtt{0xff},\mathtt{0xff},\mathtt{0xff},\mathtt{0x7f}]serialize(231−1)=[0xff,0xff,0xff,0x7f].

Flags fff. A record of three independent booleans f.cltvf.\mathrm{cltv}f.cltv, f.csvf.\mathrm{csv}f.csv, f.nulldummyf.\mathrm{nulldummy}f.nulldummy; every combination is allowed.

Oracle ooo. A record of completely arbitrary functions, with no property assumed of any of them (they are not required to be the real hash functions or a real signature check, need not produce outputs of any particular length, and need not be injective or collision resistant):

  • o.ripemd160, o.sha1, o.sha256, o.hash160, o.hash256o.\mathrm{ripemd160},\ o.\mathrm{sha1},\ o.\mathrm{sha256},\ o.\mathrm{hash160},\ o.\mathrm{hash256}o.ripemd160, o.sha1, o.sha256, o.hash160, o.hash256: byte strings →\to→ byte strings;
  • o.checkSig(sig,pubkey)∈{none,some(true),some(false)}o.\mathrm{checkSig}(\mathit{sig}, \mathit{pubkey}) \in \{\text{none}, \text{some}(\text{true}), \text{some}(\text{false})\}o.checkSig(sig,pubkey)∈{none,some(true),some(false)}, an arbitrary function of a signature and a public key ("none" means the script fails);
  • o.checkLockTime, o.checkSequenceo.\mathrm{checkLockTime},\ o.\mathrm{checkSequence}o.checkLockTime, o.checkSequence: integers →\to→ booleans.

multisigLoopo(sigs,keys)\mathrm{multisigLoop}_o(\mathit{sigs}, \mathit{keys})multisigLoopo​(sigs,keys) (both lists top-first), with result none, some(true) or some(false):

  • if sigs=[ ]\mathit{sigs} = [\,]sigs=[]: some(true);
  • if sigs\mathit{sigs}sigs is nonempty and keys=[ ]\mathit{keys} = [\,]keys=[]: some(false);
  • if sigs=s::S\mathit{sigs} = s :: Ssigs=s::S and keys=k::K\mathit{keys} = k :: Kkeys=k::K: compute o.checkSig(s,k)o.\mathrm{checkSig}(s, k)o.checkSig(s,k). If none, the result is none. If some(true): the result is some(false) when ∣K∣<∣S∣|K| < |S|∣K∣<∣S∣, and otherwise multisigLoopo(S,K)\mathrm{multisigLoop}_o(S, K)multisigLoopo​(S,K). If some(false): the result is some(false) when ∣K∣<∣S∣+1|K| < |S| + 1∣K∣<∣S∣+1, and otherwise multisigLoopo(s::S,K)\mathrm{multisigLoop}_o(s :: S, K)multisigLoopo​(s::S,K).

The script interpreter (from the script-interpreter preamble)

Instructions and scripts. An instruction is either push(d)\mathrm{push}(d)push(d) for a byte string ddd, or op(c)\mathrm{op}(c)op(c) for an opcode byte ccc. A script is a finite list of instructions. Opcode bytes used below: OP_1NEGATE =0x4f=\mathtt{0x4f}=0x4f, OP_RESERVED =0x50=\mathtt{0x50}=0x50, OP_1…OP_16 =0x51=\mathtt{0x51}=0x51…0x60\mathtt{0x60}0x60, OP_NOP =0x61=\mathtt{0x61}=0x61, OP_IF =0x63=\mathtt{0x63}=0x63, OP_NOTIF =0x64=\mathtt{0x64}=0x64, OP_ELSE =0x67=\mathtt{0x67}=0x67, OP_ENDIF =0x68=\mathtt{0x68}=0x68, OP_VERIFY =0x69=\mathtt{0x69}=0x69, OP_RETURN =0x6a=\mathtt{0x6a}=0x6a, OP_TOALTSTACK =0x6b=\mathtt{0x6b}=0x6b, OP_FROMALTSTACK =0x6c=\mathtt{0x6c}=0x6c, OP_IFDUP =0x73=\mathtt{0x73}=0x73, OP_DUP =0x76=\mathtt{0x76}=0x76, OP_SWAP =0x7c=\mathtt{0x7c}=0x7c, OP_SIZE =0x82=\mathtt{0x82}=0x82, OP_EQUAL =0x87=\mathtt{0x87}=0x87, OP_EQUALVERIFY =0x88=\mathtt{0x88}=0x88, OP_0NOTEQUAL =0x92=\mathtt{0x92}=0x92, OP_BOOLAND =0x9a=\mathtt{0x9a}=0x9a, OP_BOOLOR =0x9b=\mathtt{0x9b}=0x9b, OP_RIPEMD160 =0xa6=\mathtt{0xa6}=0xa6, OP_SHA1 =0xa7=\mathtt{0xa7}=0xa7, OP_SHA256 =0xa8=\mathtt{0xa8}=0xa8, OP_HASH160 =0xa9=\mathtt{0xa9}=0xa9, OP_HASH256 =0xaa=\mathtt{0xaa}=0xaa, OP_CODESEPARATOR =0xab=\mathtt{0xab}=0xab, OP_CHECKSIG =0xac=\mathtt{0xac}=0xac, OP_CHECKSIGVERIFY =0xad=\mathtt{0xad}=0xad, OP_CHECKMULTISIG =0xae=\mathtt{0xae}=0xae, OP_CHECKMULTISIGVERIFY =0xaf=\mathtt{0xaf}=0xaf, OP_NOP1 =0xb0=\mathtt{0xb0}=0xb0, OP_CHECKLOCKTIMEVERIFY =0xb1=\mathtt{0xb1}=0xb1, OP_CHECKSEQUENCEVERIFY =0xb2=\mathtt{0xb2}=0xb2, OP_NOP4…OP_NOP10 =0xb3=\mathtt{0xb3}=0xb3…0xb9\mathtt{0xb9}0xb9 (plus the other standard stack/arithmetic opcodes named below).

opsIn(sc)\mathrm{opsIn}(\mathit{sc})opsIn(sc) is the number of instructions op(c)\mathrm{op}(c)op(c) in the script sc\mathit{sc}sc with c>0x60c > \mathtt{0x60}c>0x60 (pushes and opcodes ≤0x60\le \mathtt{0x60}≤0x60 are not counted).

States. A state is a quadruple (stack,alt,vf,k)(\mathit{stack}, \mathit{alt}, \mathit{vf}, k)(stack,alt,vf,k): the main stack and the alt stack (lists of byte strings, top first), the condition stack vf\mathit{vf}vf (a list of booleans, innermost first) and the operation counter k∈Nk\in\mathbb{N}k∈N. initial(st)=(st,[ ],[ ],0)\mathrm{initial}(\mathit{st}) = (\mathit{st}, [\,], [\,], 0)initial(st)=(st,[],[],0). allTrue(vf)\mathrm{allTrue}(\mathit{vf})allTrue(vf) means every entry of vf\mathit{vf}vf is true (so it is true for vf=[ ]\mathit{vf} = [\,]vf=[], and false exactly when vf\mathit{vf}vf contains at least one false). The state is executing when allTrue(vf)\mathrm{allTrue}(\mathit{vf})allTrue(vf).

Decoding numbers. "Decode vvv with limit LLL" fails if ∣v∣>L|v| > L∣v∣>L; otherwise it gives the sign–magnitude little-endian value of vvv: if the last byte has bit 0x80\mathtt{0x80}0x80 set, minus the little-endian value of vvv with that bit cleared, else the little-endian value of vvv ([ ][\,][] decodes to 000). No minimal-encoding requirement is applied anywhere.

stepf,o(s,i)\mathrm{step}_{f,o}(s, i)stepf,o​(s,i) — one instruction; result is a new state or failure.

  • i=push(d)i = \mathrm{push}(d)i=push(d): fail if ∣d∣>520|d| > 520∣d∣>520. If executing, put ddd on top of the main stack; otherwise leave the state unchanged. Then fail if ∣stack∣+∣alt∣>1000|\mathit{stack}| + |\mathit{alt}| > 1000∣stack∣+∣alt∣>1000.
  • i=op(c)i = \mathrm{op}(c)i=op(c): (1) if c>0x60c > \mathtt{0x60}c>0x60 and k+1>201k + 1 > 201k+1>201, fail; if c>0x60c > \mathtt{0x60}c>0x60, increase kkk by one (this happens also in non-executed branches). (2) If ccc is one of the fifteen disabled opcodes (OP_CAT, OP_SUBSTR, OP_LEFT, OP_RIGHT, OP_INVERT, OP_AND, OP_OR, OP_XOR, OP_2MUL, OP_2DIV, OP_MUL, OP_DIV, OP_MOD, OP_LSHIFT, OP_RSHIFT), fail, executing or not. (3) If executing, or 0x63≤c≤0x68\mathtt{0x63} \le c \le \mathtt{0x68}0x63≤c≤0x68, apply execOp\mathrm{execOp}execOp (below, with the flag "executing" passed in); fail if it fails, and otherwise fail if the resulting ∣stack∣+∣alt∣>1000|\mathit{stack}| + |\mathit{alt}| > 1000∣stack∣+∣alt∣>1000. (4) Otherwise the state is unchanged apart from kkk, and it fails if ∣stack∣+∣alt∣>1000|\mathit{stack}| + |\mathit{alt}| > 1000∣stack∣+∣alt∣>1000.

execOpf,o(fExec,c,s)\mathrm{execOp}_{f,o}(\mathit{fExec}, c, s)execOpf,o​(fExec,c,s). "Top" is the first stack element, "second" the next; whenever a required element is missing the result is failure.

  • OP_1NEGATE or OP_1…OP_16: push serialize(c−0x50)\mathrm{serialize}(c - \mathtt{0x50})serialize(c−0x50), i.e. of −1,1,…,16-1, 1, \dots, 16−1,1,…,16.
  • OP_NOP, OP_NOP1, OP_NOP4…OP_NOP10, OP_CODESEPARATOR: no change.
  • OP_CHECKLOCKTIMEVERIFY: if f.cltvf.\mathrm{cltv}f.cltv is false, no change. Otherwise decode the top with limit 555 (not removing it); fail if that fails, if the value n<0n<0n<0, or if o.checkLockTime(n)o.\mathrm{checkLockTime}(n)o.checkLockTime(n) is false; else no change.
  • OP_CHECKSEQUENCEVERIFY: if f.csvf.\mathrm{csv}f.csv is false, no change. Otherwise decode the top with limit 555 (not removing it); fail if that fails or n<0n < 0n<0; if bit 2312^{31}231 of nnn is set, no change; otherwise fail if o.checkSequence(n)o.\mathrm{checkSequence}(n)o.checkSequence(n) is false, else no change.
  • OP_IF / OP_NOTIF: if fExec\mathit{fExec}fExec, remove the top ttt and put castToBool(t)\mathrm{castToBool}(t)castToBool(t) (negated for OP_NOTIF) in front of vf\mathit{vf}vf; if not fExec\mathit{fExec}fExec, put false in front of vf\mathit{vf}vf and leave the stack alone.
  • OP_ELSE: fail if vf\mathit{vf}vf is empty, else negate its first entry. OP_ENDIF: fail if vf\mathit{vf}vf is empty, else remove its first entry.
  • OP_VERIFY: remove the top; fail if castToBool\mathrm{castToBool}castToBool of it is false. OP_RETURN: fail.
  • OP_TOALTSTACK: move the top of the main stack onto the alt stack. OP_FROMALTSTACK: move the top of the alt stack onto the main stack.
  • OP_2DROP, OP_2DUP, OP_3DUP, OP_2OVER, OP_2ROT, OP_2SWAP, OP_DROP, OP_NIP, OP_OVER, OP_ROT, OP_TUCK: the standard rearrangements of the top two to six elements. OP_DUP: duplicate the top. OP_SWAP: exchange top and second. OP_IFDUP: duplicate the top if castToBool\mathrm{castToBool}castToBool of it is true, else no change. OP_DEPTH: push serialize(∣stack∣)\mathrm{serialize}(|\mathit{stack}|)serialize(∣stack∣). OP_PICK/OP_ROLL: remove the top, decode it (limit 444) as nnn, require a nonempty remainder with 0≤n<0 \le n <0≤n< its length, and copy (PICK) or move (ROLL) its element of index nnn (0 = top) to the top.
  • OP_SIZE: push serialize(∣t∣)\mathrm{serialize}(|t|)serialize(∣t∣) for the top ttt, which stays.
  • OP_EQUAL / OP_EQUALVERIFY: remove the top aaa and second bbb; OP_EQUAL pushes boolBytes(a=b)\mathrm{boolBytes}(a=b)boolBytes(a=b); OP_EQUALVERIFY fails unless a=ba=ba=b.
  • OP_1ADD, OP_1SUB, OP_NEGATE, OP_ABS, OP_NOT, OP_0NOTEQUAL: remove the top, decode it with limit 444 as nnn (fail if longer), push serialize\mathrm{serialize}serialize of n+1n+1n+1, n−1n-1n−1, −n-n−n, ∣n∣|n|∣n∣, (111 if n=0n=0n=0 else 000), (111 if n≠0n\neq 0n=0 else 000) respectively.
  • OP_ADD, OP_SUB, OP_BOOLAND, OP_BOOLOR, OP_NUMEQUAL, OP_NUMEQUALVERIFY, OP_NUMNOTEQUAL, OP_LESSTHAN, OP_GREATERTHAN, OP_LESSTHANOREQUAL, OP_GREATERTHANOREQUAL, OP_MIN, OP_MAX: remove the top aaa and second bbb, decode n1n_1n1​ from bbb and n2n_2n2​ from aaa with limit 444 (fail if either is longer), and push serialize\mathrm{serialize}serialize of the result: n1+n2n_1+n_2n1​+n2​, n1−n2n_1-n_2n1​−n2​, (111 if n1≠0n_1\neq0n1​=0 and n2≠0n_2\neq 0n2​=0 else 000), (111 if n1≠0n_1\neq 0n1​=0 or n2≠0n_2\neq0n2​=0 else 000), and 1/01/01/0 for =,=,≠,<,>,≤,≥=,=,\neq,<,>,\le,\ge=,=,=,<,>,≤,≥, then min⁡\minmin, max⁡\maxmax; OP_NUMEQUALVERIFY pushes nothing and fails unless n1=n2n_1 = n_2n1​=n2​.
  • OP_WITHIN: remove three elements aaa (top), bbb, ddd, decode each with limit 444, push boolBytes(b≤d<a)\mathrm{boolBytes}(b \le d < a)boolBytes(b≤d<a) of the decoded values.
  • OP_RIPEMD160, OP_SHA1, OP_SHA256, OP_HASH160, OP_HASH256: replace the top ttt by o.ripemd160(t)o.\mathrm{ripemd160}(t)o.ripemd160(t), o.sha1(t)o.\mathrm{sha1}(t)o.sha1(t), o.sha256(t)o.\mathrm{sha256}(t)o.sha256(t), o.hash160(t)o.\mathrm{hash160}(t)o.hash160(t), o.hash256(t)o.\mathrm{hash256}(t)o.hash256(t) respectively.
  • OP_CHECKSIG / OP_CHECKSIGVERIFY: with pubkey\mathit{pubkey}pubkey the top and sig\mathit{sig}sig the second, let r=o.checkSig(sig,pubkey)r = o.\mathrm{checkSig}(\mathit{sig}, \mathit{pubkey})r=o.checkSig(sig,pubkey); fail if rrr is none; OP_CHECKSIG replaces both by boolBytes(r)\mathrm{boolBytes}(r)boolBytes(r); OP_CHECKSIGVERIFY removes both and fails unless rrr is true.
  • OP_CHECKMULTISIG / OP_CHECKMULTISIGVERIFY: remove the top and decode it (limit 444) as nKn_KnK​; fail if nK<0n_K<0nK​<0 or nK>20n_K>20nK​>20; let k′=k+nKk' = k + n_Kk′=k+nK​ and fail if k′>201k' > 201k′>201; the next nKn_KnK​ elements (top-first) are the keys (fail if fewer); the following element is decoded (limit 444) as nSn_SnS​, failing if absent, if nS<0n_S<0nS​<0 or nS>nKn_S>n_KnS​>nK​; the next nSn_SnS​ elements (top-first) are the signatures (fail if fewer); let r=multisigLoopo(sigs,keys)r = \mathrm{multisigLoop}_o(\mathit{sigs}, \mathit{keys})r=multisigLoopo​(sigs,keys) and fail if none; one more element, the dummy, must be present and is removed; fail if f.nulldummyf.\mathrm{nulldummy}f.nulldummy is true and the dummy is not [ ][\,][]; the counter becomes k′k'k′; OP_CHECKMULTISIG pushes boolBytes(r)\mathrm{boolBytes}(r)boolBytes(r) onto what remains, the VERIFY form pushes nothing and fails unless rrr is true.
  • Every other byte (including OP_RESERVED, 0x65\mathtt{0x65}0x65, 0x66\mathtt{0x66}0x66 and any byte ≤0x4e\le \mathtt{0x4e}≤0x4e used as an opcode): fail.

runf,o(s,sc)\mathrm{run}_{f,o}(s, \mathit{sc})runf,o​(s,sc): run(s,[ ])\mathrm{run}(s, [\,])run(s,[]) is sss if its condition stack is empty and failure otherwise; run(s,i::sc′)\mathrm{run}(s, i :: \mathit{sc}')run(s,i::sc′) fails if step(s,i)\mathrm{step}(s,i)step(s,i) fails and is run(step(s,i),sc′)\mathrm{run}(\mathrm{step}(s,i), \mathit{sc}')run(step(s,i),sc′) otherwise.

evalScriptf,o(st,sc)\mathrm{evalScript}_{f,o}(\mathit{st}, \mathit{sc})evalScriptf,o​(st,sc): if run(initial(st),sc)\mathrm{run}(\mathrm{initial}(\mathit{st}), \mathit{sc})run(initial(st),sc) succeeds with final state s′s's′, the result is "some" of the main stack of s′s's′; otherwise it is failure (none). Nothing about the alt stack, the operation counter, or the truth of the top element is checked; the initial stack st\mathit{st}st is not checked against any size limit.

runSeqf,o(s,sc)\mathrm{runSeq}_{f,o}(s, \mathit{sc})runSeqf,o​(s,sc) (defined in the Miniscript file): exactly like run\mathrm{run}run but without the final check: runSeq(s,[ ])=some(s)\mathrm{runSeq}(s, [\,]) = \text{some}(s)runSeq(s,[])=some(s) (whatever its condition stack), and runSeq(s,i::sc′)\mathrm{runSeq}(s, i :: \mathit{sc}')runSeq(s,i::sc′) fails if step(s,i)\mathrm{step}(s,i)step(s,i) fails and is runSeq(step(s,i),sc′)\mathrm{runSeq}(\mathrm{step}(s,i), \mathit{sc}')runSeq(step(s,i),sc′) otherwise.

Human review
  • Endorsed by Shuze Chen · Oct 30, 2026

    Confirmed by the moderator at approval.

  • Endorsed by pitimespi · Oct 30, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me