p-token — Anza's Pinocchio rewrite of the SPL Token program (SIMD-0266), live on mainnet at the same program id TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA with a byte-compatible instruction set — modeled in pure Lean 4 as Poc/PToken.lean: the full core instruction semantics plus p-token's three additions, with the safety claims as kernel-checked theorems. Pinocchio stays exactly as it is; this gives its token semantics a machine-checked specification.
State is a list of Mint records (supply, decimals, mint/freeze authorities as options — none once renounced, initialized flag, lamports + rent-exempt reserve) and Account records (mint, owner, amount, delegate with remaining allowance, close authority, frozen flag, lamports), plus a wallet lamport ledger that the lamport-moving instructions pay into. Keys are Nat ids, this repo's convention.
transfer — owner-or-delegate authorization, same mint, neither side frozen, sufficient funds. The debit lands before the credit is computed, so a self-transfer nets to zero, as on-chain. A delegate's allowance decreases by exactly the amount and is cleared at zero — SPL's rule, modeled in afterSpend. transferChecked / mintToChecked additionally require the instruction's decimals to equal the mint's.
mintTo — mint-authority-signed only, unfrozen destination; supply rises by exactly the amount. burn — owner-or-delegate, unfrozen; amount and supply drop together. approve / revoke — owner-signed delegate management. setAuthority — mint kinds (mintTokens, freezeAccount) signed by the current authority of that kind; account kinds (accountOwner — the new owner is a key, never none — and closeAccount). Setting a mint authority to none renounces it irreversibly. freezeAccount / thawAccount — the mint's freeze authority only. closeAccount — zero balance, owner- or close-authority-signed; the account is removed and its lamports are paid to the destination wallet.
batch (discriminator 255) — one instruction carrying a list of sub-instructions, executed in order, all-or-nothing: any failure returns none and the caller's state is untouched. There is deliberately no batch constructor inside the sub-instruction type, so a batch cannot contain a batch — matching the program, which forbids nested batches.
withdrawExcessLamports — an account (or mint) holding lamports above its rent-exempt reserve withdraws the excess: the token-account form is owner-signed and pays the owner's wallet; the mint form is mint-authority-signed and pays the authority's wallet. The reserve stays behind, exactly.
unwrapLamports — native (wrapped-SOL) mints only, owner-signed: the token amount, the mint supply, and the account's lamports each drop by the unwrapped amount, the owner's wallet gains the same amount, and the rent-exempt reserve must remain.
| Instruction | p-token | SPL Token |
|---|---|---|
| transfer | 76 CU | 4,645 CU |
| transferChecked | 105 CU | 6,200 CU |
| mintTo | 119 CU | 4,538 CU |
Reference points from Anza's p-token materials (solana.com/upgrades/p-token, SIMD-0266) — cited, not measured by this model, which has no compute meter. The point of this PoC is the other half of the story: the cheaper program's semantics, pinned down as theorems.
transfer_mints · transfer_sumMintPROVED — a transfer never touches the mint table, and it preserves the sum of all account balances of every mint (debit and credit are the same amount of the same mint; a self-transfer nets to zero). (a)
mintTo_supplyPROVED — a successful mintTo increases supply by exactly the amount. Together with the per-instruction preservation lemmas approve_mints · revoke_mints · freeze_mints · thaw_mints · close_mints (mint table untouched) and setMintAuthority_supply (authority change only), mintTo is the only balance instruction that changes supply. (b)
burn_supplyPROVED — a successful burn decreases supply by exactly the amount (and supply-after + amount = supply-before when amount ≤ supply). (c)
transfer_unauthorized · transfer_delegate_overspend · transfer_delegate_allowance · transfer_delegate_cleared · transfer_amountsPROVED — a signer who is neither owner nor delegate can never transfer; a delegate can never overspend its allowance; a successful delegate transfer decreases the allowance by exactly the amount, and clears the delegate when the allowance is spent exactly; a successful transfer lands the exact debit and credit. (d)
transfer_frozen_src · transfer_frozen_dst · mintTo_frozen · burn_frozen · freeze_unauthorized · freeze_facts · thaw_factsPROVED — frozen accounts cannot send, receive, be minted to, or burn; freezing by anyone but the mint's freeze authority always fails; successful freeze/thaw set the flag. (e)
transferChecked_decimals · mintToChecked_decimalsPROVED — the checked variants always fail on a decimals mismatch. (f)
close_nonzero · close_unauthorized · close_factsPROVED — closing a nonzero-balance account always fails; closing signed by anyone but the owner and the close authority always fails; a successful close pays the account's lamports to the destination wallet, exactly. (g)
batch_nil · batch_cons_success · batch_fail_first · batch_fail_restPROVED — the empty batch is the identity; a batch whose head succeeds is sequential composition; if the first sub-instruction fails — or the tail batch fails from the intermediate state, at any depth — the whole batch returns none: atomicity. (h)
mintTo_no_authority · mintTo_unauthorized · renounce_mintToPROVED — with the mint authority gone (or a wrong signer), mintTo always fails; and after setMintAuthority renounces the mint authority to none, mintTo fails on the resulting state for every signer, destination, and amount — renunciation is forever. (i)
withdrawExcessAccount_facts · unwrapLamports_facts · unwrapLamports_not_nativePROVED — a successful excess withdrawal leaves exactly the rent-exempt reserve and credits exactly the excess; a successful unwrap drops amount, supply, and account lamports by exactly the amount and credits the owner's wallet with exactly the amount; unwrapping a non-native token always fails.
approve_delegate · revoke_delegatePROVED — a successful approve sets exactly the given delegate and allowance; a successful revoke clears it.
Helper lemmasPROVED — findMint_id · findAccount_id · findMint_updateMint · findAccount_updateAccount · findMint_updateMint_of · findAccount_updateAccount_of · findAccount_updateAccount_ne · walletOf_creditWallet · sumMint_updateAccount — the list-ledger workhorses the instruction theorems rest on.
Anza's deployed Rust/Pinocchio binary · sBPF refinementNOT MODELED — the theorems specify the semantics; they do not yet say anything about the compiled program. The lean-svm certified-compiler bridge is the path from here to there.
Token-2022 extensions · multisig signer sets · signature cryptographyNOT MODELED — core instruction set only; authorization is the single-key abstraction (one signer key, equality-checked), as in the other PoCs.
The binary's scenario: mint 1 (decimals 6) and a native mint 2 (decimals 9); accounts for Alice, Bob, Carol, and Alice's wrapped-SOL account. Minting, plain and checked transfers, a delegate allowance spent down to its exact clearing, freeze/thaw gating, a burn, a two-instruction batch and an atomically-aborting one, a self-transfer, the excess-lamports withdrawal, an unwrap, authority renunciation, and a lamport-paying close — with the failure case of every rule exercised. Every check evaluates the model.
A small, self-contained token program (solana-os-lean-programs/PToken.lean) with the model's core rules: InitMint, InitAccount, MintTo (authority only), Transfer (owner only, same mint, no overdraft), Burn. It is not SPL Token and not at the SPL program id; it is our own program, compiled by lean-svm, with a top-level theorem over its exact ELF (PToken.Deployed.bytecode_ok, written, not yet kernel-checked; see LAUNCH.md). Devnet only until launch.