Seedelf-Wallet

Lovejoin in every transaction

Kernel-checked proofs of exactly when Lovejoin v2’s mix_logic and one_shot_mint accept, in every transaction: no Blaster, no step limit, every list any length. What they state is in Lovejoin/AnyTx/README.md (Complete mix_logic and one_shot_mint behavior), and what that lets us claim in CLAIMS.md. This page is for changing a proof: read it whole, then Base.lean (the tactics) and one finished region (Carrier.lean). If a statement turns out false, follow the rule in Lovejoin/AnyTx/README.md. The record of how these proofs were built is in the archive: chunk 45. Moving them off the forks is chunk 46’s plan.

Building

The method

  1. The spec is the compiled code, read back. Decode the template and print it as pseudo-code with Lean subterm paths (The tools). Write each region as a Lean function over raw Data, where none is the script’s error. Mirror the compiled order:
    • strict lets stay strict;
    • ifs nest as compiled;
    • Option binds run in evaluation order.
  2. One theorem per region: Ev default <subterm> ρ ((spec …).map toCekValue), which gives both directions. ρ is abstract, with one hypothesis per slot the region reads (List.get?Internal ρ k = some v). A closure it calls is given by its behaviour, e.g. (hv73 : ∀ l, Ap default v73 (.VCon (.ConstDataList l)) (l[1]?.map …)). Loops are by induction on the list. The closure env of a self-applied loop is .VCon list :: .VLam loop ρ :: ρ.
  3. Compose with ev_go [lemmas] [facts] (Base.lean). It applies a lemma where one fits, closes slot goals by cek_rfl or safe_assumption, and rewrites a symbolic condition by the fact the proof cased on: simp only, then rw with each fact (rw also reaches conditions inside instDecidableEqBool, where simp doesn’t look). bsimp (MixPred.lean) reduces a spec’s binds after each split; without it cases can’t reach a term under a bind’s binder. rsimp h (Mix.lean) takes refFields apart.
  4. Proof pattern per region:
    • rcases the data in compiled evaluation order, then all_goals try (ev_go [...] []; done) to close the error branches;
    • simp only [spec, List.getElem?_cons_succ, List.getElem?_cons_zero] once the shape is known;
    • cases h : <condition> for each symbolic Bool, Except or Option, then ev_go [...] [h, …].
  5. The source’s terms are pure Lean about the spec functions, with no CEK step (Readable*.lean): each Aiken function restated over the ledger’s typed TxInfo, and proved equal to the raw function on IsData.toData of the typed value. The ledger’s own guarantees (sorted values, unique references) are hypotheses where they’re used; the crypto stays opaque.

Pitfalls already paid for

Don’t relearn them.

In the CEK regions:

In the launch (Mint*.lean):

In the source’s terms (Readable*.lean):

The tools

In tools/. They print views and paths, and decide nothing a theorem relies on: Lean refuses a wrong path.

# from seedelf-verification/; any scratch path works for the decoded file
aiken uplc decode --hex --cbor Lovejoin/Template/Scripts/mix_logic.hex > /tmp/ml.uplc
python3 -I Lovejoin/Every/tools/pseudo.py /tmp/ml.uplc '[]' 'i_0=POLICY,i_1=NAME,i_2=CTX,i_3=chooseData,i_4=tailList,i_5=headList,i_6=mkCons,i_7=chooseList,i_8=sndPair,i_9=fstPair,i_10=ifThenElse,i_11=policyB,i_12=nameB' > /tmp/pseudo.txt
python3 -I Lovejoin/Every/tools/scope.py /tmp/ml.uplc @<path digits>   # scope (slot → binder) and the free slots of that subterm
python3 -I -c "import sys; sys.path.insert(0,'Lovejoin/Every/tools'); from lpath import lean; print(lean('<digits>'))"

The modules

Module Theorem What it says
Lookup policy_search, name_search quantity_of’s two ordered searches (policyEntry, nameEntry), any map
Carrier nth1_ap, nth2_ap, nth5_ap i_73, i_72, i_74: l[k]?
Carrier carrier_cond, carrier_filter holdsNft for any input Data; carriers for any list
Carrier carrier_datum, reference_datum i_81: referenceDatum P N info: exactly one carrier, its inline datum Constr 0 [I,B,B,I,I,B,B,B]
Collect isBytes_ap, box_pred, collect_loop, boxes_of i_105: boxesOf rd info = collect msh ins (payment credential Script msh, inline well-formed MixDatum)
Shared len_loop i_77: countOf
Shared pairs_loop, pairs_apply i_78 with any predicate given by its behaviour: pairsAll
Shared scalar_ap, scalarMod_ap i_106 scalarOf, i_80 scalarMod
Shared ap_lessThan, ap_lessThanEquals the cased-comparison steps
Owner refs_loop, owner_hash i_115 inputRefs; the transaction hash ownerHash rd info
Owner owner_pred, owner_pred_all each box’s Schnorr check ownerPred ctx box proof; any bad encoding or scalar is an error
Owner owner_branch the Owner branch region (sub (M ++ 10000010)) = ownerResult rd info red boxes
Main len_ap i_107
Main main_owner from the main body’s entry (env29 …) with red = Constr 0 fs: ownerMain P info red (reference datum, then boxes, then Owner), any info : Data
Fold fold_loop, fold_apply, cat_ev, xor_ev i_131 foldOpt with a step given by behaviour; the statements’/branches’ step catStep (f1 and f2 are the same term, catBody'_eq) and the challenges’ xorStep
Value merge_loop, insert_loop, box_value i_200 mergeName, i_193 insertPolicy, i_134 boxValue bl pol nm tq (ADA part, then the token unless the policy is empty or the quantity 0)
Walk atScript_shape, at_script i_133 atScript msh out; an output at the script has four fields
Walk walk_loop, walk_entry i_173 walk (box outs: prefixOut, the strict stmtDatum decode, points recompressed; the rest not at the script), i_135 walkFrom msh val info n
MixPred nth3_ap, pair_cond, par_loop i_130; one branch’s two Σ-protocol equations branchOk A B st br; i_153 = pairsAll (branchOk A B)
MixPred mix_pred the predicate mixPred pre ctx sts box proof: ≥ 2 statements, the Fiat-Shamir hash vs the xor of challenges, the points, every branch (zero32_shape)
Mix rev_loop, apleft_i2b, mix_branch i_165 reverseAux; integerToByteString kept as the builtin’s own result (i2b); the Mix branch region (sub mixAt) = mixResult rd info red boxes (prefix03_shape)
Mix referenceDatum_shape, main_mix from the main body’s entry with red = Constr tr fs, tr ≠ 0: mixMain P info red, any info : Data
Withdraw owner_walk, branches_walk, proofs_walk the redeemer’s shape walks through the fixpoint combinator i_28 (comboX): allOwnerProofs (each Constr 0 [B, B]), allMixProofs (each Constr 0 [List branches], each branch Constr 0 [B, B, B, B])
Withdraw withdraw_root the whole program applied to P, nftName and purposeCtx 2 info red [cred], for any info red cred : Data: unitIf (withdrawResult P info red) (tag 0 Owner, tag 1 Mix, else an error)
Typed withdraw_iff, every_context_iff mix_logic for every typed V3 ScriptContext: () exactly when logicPasses P ctx (a withdrawal by withdrawResult, a certificate by isRegistrationData, nothing else), with #guard_msgs on its axioms
Mint tokens_loop/tokens_apply, qty_loop, seed_loop, out_cond, out_loop, findOut_shape, mnth*_ap one_shot_mint’s loops: the policy search tokensOf, the name search qtyOf, the seed search seedIn, the output search findOut (outCond: script rh, no stake part, no reference script, exactly one of (P, nm))
MintSpec launchResult, launchCheck, launchConds, launchDatumOk, outDatum, lovejoinName_eq the launch’s spec; the found output’s datum decodes by Carrier’s refFields
MintConds, MintCheck conds_region, launch_check the regions after the datum decodes and after the output is found (split so no module passes 16 GB)
MintRoot launch_root the whole one_shot_mint program on purposeCtx 0 info red [B P], any info red : Data: unitIf (launchResult …)
MintTyped launch_iff, mint_every_context_iff one_shot_mint for every typed V3 ScriptContext: () exactly when mintPasses (a mint by launchResult, nothing else), axioms guarded
ReadableBase inputs_data, outputs_data, countOf_eq, AllPairs, pairsAll_map, valid_value_shape, valid_mint_shape, policy_search, name_search typed lists as IsData encodes them; pairs_match_and_all as AllPairs; on a value or mint the ledger accepts, the ordered searches are tokensUnder and valueOf
ReadableOwner referenceDatum_typed, boxesOf_typed, ownerPred_typed, ownerResult_typed read_reference_datum (readReferenceDatum, a RefDatum), collect_well_formed_mix_inputs, each Owner proof as Lovejoin.Classic.schnorrVerifies (prefix01_eq), validate_owner (validateOwner)
ReadableMix boxValue_typed, walk_typed, walkOutputs_eq, branchOk_typed, mixPred_typed, mixResult_typed box_value, output_at_script, walk_outputs (and read whole: take/drop), verify_pre with xor32, validate_mix (validateMix)
ReadableLaunch outCond_typed, findOut_typed, seedIn_typed, launchDatumOk_typed, launchResult_typed output_at_reference_holder, the seed’s list.any, datum_sane and token_sane, one_shot_mint’s mint (launchOk)
Readable withdrawResult_typed, mix_logic_accepts_iff(_valid), one_shot_mint_accepts_iff(_valid) both scripts for every typed V3 context, in the source’s terms: mixLogicAccepts (withdrawOk: the redeemer Owner or Mix, then validateOwner or validateMix; a RegisterCredential; nothing else) and oneShotMintAccepts (launchOk; nothing else), under the ledger’s value rules, axioms guarded. The _valid forms, under the model’s whole validScriptContext, are narrower: its isBalanced ignores deposits, refunds, withdrawals and donations, so they miss every real publish, every non-zero withdrawal, and every transaction with a deposit, a refund or a donation. Cite the others