Skip to content
Proofs

Proven in Lean.

The Unlink Planner is a Lean 4 program. These theorems hold for every plan it returns, for every input. Lean's kernel checked them when this build was made. They are about the planner only.
Lean
4.36.0
toolchain, core library only
Theorems
24
9 headline · 15 lemmas
sorry
0
non-standard axioms: 0
Lean ≡ TypeScript
0 / 100,000
mismatches · 61,332 plans, 38,668 refusals

build src-7e4b77a49909 · planner source sha256 7e4b77a49909116c… · generated 2026-12-02 · ChaCha20 RFC 8439 test vector passes

Try the planner

This runs the TypeScript port in your browser with the relayer's live fee. The checks are the same predicates the theorems talk about.

Burners
3
Speed
Seed
000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f

Relayer fee (default): 0.35% + 0.006 SOL per withdrawal. Denominations 0.1, 0.5, 1, 5, 10 SOL.

burner 1
0.10.51
burner 2
1
burner 3
10.1
now+12h 00m+1d 0h
6 withdrawals · burners receive 3.65105 SOLrelayer fees 0.04895 SOLleft shielded 0 SOL
  • plan_total_exact
  • standard_chunks
  • no_amount_echo
  • delays_respect_min
  • gaps_respect_min
  • within_window
  • burners_in_range
  • dust_bounded
goals closed · 8/8 checks hold, as the Lean theorems guarantee

The nine theorems

Each takes the hypothesis planUnlink i = .ok p: whenever the planner returns a plan, the property holds. The planner refuses rather than return a plan that would break one.

plan_total_exact

planner/LeanPool/Proofs.lean:118 · axioms propext, Classical.choice, Quot.sound

Every lamport is accounted for: what burners receive, plus fees, plus what stays shielded, equals your amount.

Specification
/-- Nothing is created or lost: what the burners receive + what stays shielded + fees = the balance. -/
def TotalExact (i : Input) (p : Plan) : Prop :=
  sumReceived p.steps + p.leftShielded + p.totalFees = i.amount
Theorem
/-- What the burners receive + what stays shielded + fees = exactly the shielded balance. -/
theorem plan_total_exact {i : Input} {p : Plan} (h : planUnlink i = .ok p) :
    TotalExact i p :=
  checkTotal_sound (checkAll_parts (planUnlink_checked h)).1

standard_chunks

planner/LeanPool/Proofs.lean:123 · axioms propext, Classical.choice, Quot.sound

Every withdrawal is one of the standard sizes, with exactly the relayer's fee.

Specification
/-- Every withdrawal is one of the standard denominations, charged the published fee. -/
def StandardChunks (i : Input) (p : Plan) : Prop :=
  ∀ s ∈ p.steps, s.amount ∈ i.denoms ∧ s.fee = feeOf i s.amount
Theorem
/-- Every withdrawal is a standard denomination, charged the published fee. -/
theorem standard_chunks {i : Input} {p : Plan} (h : planUnlink i = .ok p) :
    StandardChunks i p :=
  checkStandard_sound (checkAll_parts (planUnlink_checked h)).2.1

no_amount_echo

planner/LeanPool/Proofs.lean:128 · axioms propext, Classical.choice, Quot.sound

No withdrawal and no burner's running balance echoes your amount or anything you asked to avoid, unless it is a standard size.

Specification
/-- No withdrawal, and no running balance of any burner, lands within ±2 % of the deposit
    or of a recent deposit — unless that value is itself standard. -/
def NoAmountEcho (i : Input) (p : Plan) : Prop :=
  (∀ s ∈ p.steps, Standard i s.received ∨ ¬ Echo i s.received) ∧
  (∀ b, b < i.burners → ∀ v ∈ burnerPrefixes p.steps b, Standard i v ∨ ¬ Echo i v)
Theorem
/-- No withdrawal and no burner balance echoes the deposit or a recent deposit (±2 %). -/
theorem no_amount_echo {i : Input} {p : Plan} (h : planUnlink i = .ok p) :
    NoAmountEcho i p :=
  checkEcho_sound (checkAll_parts (planUnlink_checked h)).2.2.1

delays_respect_min

planner/LeanPool/Proofs.lean:133 · axioms propext, Quot.sound

Nothing leaves before your minimum delay.

Specification
/-- No withdrawal happens earlier than `minDelay` after the plan starts. -/
def DelaysRespectMin (i : Input) (p : Plan) : Prop :=
  ∀ s ∈ p.steps, i.minDelay ≤ s.delay
Theorem
/-- No withdrawal is scheduled before `minDelay`. -/
theorem delays_respect_min {i : Input} {p : Plan} (h : planUnlink i = .ok p) :
    DelaysRespectMin i p :=
  checkDelays_sound (checkAll_parts (planUnlink_checked h)).2.2.2.1

gaps_respect_min

planner/LeanPool/Proofs.lean:138 · axioms propext, Quot.sound

Withdrawals are at least your minimum gap apart.

Specification
/-- Withdrawals are in time order and at least `minGap` apart. -/
def GapsRespectMin (i : Input) (p : Plan) : Prop :=
  gapsOk i.minGap p.steps
Theorem
/-- Withdrawals are in time order and at least `minGap` apart. -/
theorem gaps_respect_min {i : Input} {p : Plan} (h : planUnlink i = .ok p) :
    GapsRespectMin i p :=
  checkGaps_sound (checkAll_parts (planUnlink_checked h)).2.2.2.2.1

within_window

planner/LeanPool/Proofs.lean:143 · axioms propext, Quot.sound

Every withdrawal lands inside the window you picked.

Specification
/-- The whole schedule fits in the chosen speed window. -/
def WithinWindow (i : Input) (p : Plan) : Prop :=
  ∀ s ∈ p.steps, s.delay ≤ i.speed.window
Theorem
/-- The schedule fits in the speed window (6 h / 24 h / 72 h). -/
theorem within_window {i : Input} {p : Plan} (h : planUnlink i = .ok p) :
    WithinWindow i p :=
  checkWindow_sound (checkAll_parts (planUnlink_checked h)).2.2.2.2.2.1

burners_in_range

planner/LeanPool/Proofs.lean:148 · axioms propext, Classical.choice, Quot.sound

Every withdrawal goes to a burner you have, and each burner gets one when the balance allows.

Specification
/-- Every withdrawal goes to a burner that exists; if the balance allows, every burner gets one. -/
def BurnersInRange (i : Input) (p : Plan) : Prop :=
  (∀ s ∈ p.steps, s.burner < i.burners) ∧
  (Enough i → ∀ b, b < i.burners → ∃ s ∈ p.steps, s.burner = b)
Theorem
/-- Every burner index exists, and every burner gets a withdrawal when the balance allows. -/
theorem burners_in_range {i : Input} {p : Plan} (h : planUnlink i = .ok p) :
    BurnersInRange i p :=
  checkBurners_sound (checkAll_parts (planUnlink_checked h)).2.2.2.2.2.2.1

dust_bounded

planner/LeanPool/Proofs.lean:153 · axioms propext, Quot.sound

What stays shielded is smaller than the smallest denomination.

Specification
/-- What stays in the pool is less than the smallest denomination. -/
def DustBounded (i : Input) (p : Plan) : Prop :=
  p.leftShielded < minDenom i.denoms
Theorem
/-- What stays shielded is less than the smallest denomination. -/
theorem dust_bounded {i : Input} {p : Plan} (h : planUnlink i = .ok p) :
    DustBounded i p :=
  checkDust_sound (checkAll_parts (planUnlink_checked h)).2.2.2.2.2.2.2

deterministic

planner/LeanPool/Proofs.lean:158 · axioms propext, Quot.sound

Same input, same seed: the same plan, on any machine.

Theorem
/-- Same input and seed, same result: the planner reads no clock and no OS randomness. -/
theorem deterministic (i j : Input) (h : i = j) : planUnlink i = planUnlink j :=
  h ▸ rfl

Supporting lemmas

How the nine are proven: the planner checks its own candidate with Boolean checks, and these lemmas show each check implies its specification.

LemmaLine
checkTotal_sound
propext, Classical.choice, Quot.sound
14
checkStandard_sound
propext, Classical.choice, Quot.sound
17
echoB_false
propext, Quot.sound
23
standardB_sound
propext, Classical.choice, Quot.sound
30
okValue_sound
propext, Classical.choice, Quot.sound
38
checkEcho_sound
propext, Classical.choice, Quot.sound
45
checkDelays_sound
propext, Quot.sound
49
gapsB_sound
propext
55
checkGaps_sound
propext
62
checkWindow_sound
propext, Quot.sound
66
checkBurners_sound
propext, Classical.choice, Quot.sound
72
checkDust_sound
propext
82
tryAttempts_checked
propext, Quot.sound
87
planUnlink_checked
propext, Quot.sound
101
checkAll_parts
propext
108

What is not proven

  • Anything about Privacy Cash: its program, circuits, trusted setup or relayer. Those are covered by Privacy Cash's own audits.
  • That the browser or CLI runs the planner correctly. The TypeScript port is checked against Lean by differential testing, not proven.
  • That the random seed is good randomness. It comes from your device's crypto.getRandomValues.
  • That a plan makes you anonymous. It removes amount and timing echoes; the crowd in the pool does the rest.

Check it yourself

shell
cd leanpool/planner && lake build && lake exe proofs
cd .. && bun run difftest   # 100,000 random plans, Lean vs TypeScript

Axioms used: propext, Classical.choice and Quot.sound, the three standard axioms of Lean's logic. LEAN POOL adds none.