This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Lean 4 (v4.29.0, Mathlib v4.29.0) formalization of the Goldfish Ethereum consensus protocol (IACR ePrint 2022/1171). The specification target is exactly the paper's 21 numbered statements (Theorem 1–7, Lemma 1–9, Proposition 1–5); Algorithms 1–6 and prose are intentionally out of scope. README.md is the authoritative design document — it records the four barriers, the decision taken for each, and the full dependency graph (Mermaid) between statements. Consult it before adding or restructuring proofs.
lake exe cache get # fetch prebuilt Mathlib oleans — run before the first build
lake build # build the whole Goldfish library
lake build Goldfish.FastConfirmation.Lemma5 # build a single module (fastest check while editing)There is no test suite, linter, or CI config; lake build succeeding is the correctness check.
- Never
sorry. Every statement is either fully proved or declared as anaxiomunder the policy below. Module docstrings assert "Nosorry" — keep that true. - Axioms are allowed in exactly two places:
Goldfish/Axioms.lean— probabilistic good events (Lemma 1, Lemma 4, Proposition 1 conclusions, which hold w.o.p. via VRF lottery + Chernoff). Deterministic dependents take the good event as a hypothesis (HonestMajorityPerSlot,HonestLeaderEveryWindow, …) rather than invoking probability.Goldfish/EbbAndFlow/External.lean— results imported from ref [61] (Neu–Tas–Tse accountability gadgets, ePrint 2021/628), each with a source comment. Formalizing [61] is out of scope.- Do not introduce axioms anywhere else.
Goldfish/Probabilistic/is the separate track that replaces the good-event axioms with real measure-theoretic proofs (theLotterymodel, Chernoff/Hoeffding bounds — paper App. G). It must never block or be depended on by the deterministic proofs.autoImplicitis off project-wide (lakefile.toml); bind all variables explicitly.
The protocol is not implemented operationally. Goldfish/Protocol.lean defines an abstract interface:
Execution— observable data of a run:Δ, awake/honest/eligible counts,votesFor,leader,forkChoice,outvotes,fastConfirms, plus slot↔round arithmetic (slotStart/voteRoundfor the 3∆ regime,fastSlotStart/fastVoteRound/fastConfirmRoundfor 4∆).Spec— the protocol's defining behaviour bundled as hypotheses over anExecution. All theorems are derived fromSpec; an executable model could later discharge its fields without changing any theorem statement.
Three proof layers, built in order (each maps to a paper appendix; per-statement files are named TheoremN.lean / LemmaN.lean / PropositionN.lean):
Goldfish/SynchronousSecurity/— Thm 1–3, Lem 2–3 under(1/2, 3∆)-compliance (App. B). Self-contained.Goldfish/FastConfirmation/— Thm 4–6, Lem 5 under(1/2, 4∆)-compliance (App. C). Has its ownSpec4ΔandLedger4Deltafor the 4∆ timing regime.Goldfish/EbbAndFlow/— Thm 7, Lem 6–9, Prop 2–5 under(1/3, 3∆)-compliance with the accountability-gadget overlay (Gadget,GadgetSpec) (App. D). Lemmas 7/8/9 are cyclically dependent and must be proved as one simultaneous induction (Healing.lean).
Supporting modules: Basic.lean (block-tree prefix order, (γ,τ)-compliance, negligibility), Ledger.lean (confirmed-ledger layer, Def. 1 safety/liveness). Umbrella files (Goldfish.lean, Goldfish/EbbAndFlow.lean, …) just re-export; add new modules to the matching umbrella import list.
- One numbered statement per file; the module docstring names the paper statement it formalizes and states its dependency shape.
- Before adding a dependency between statements, check the README dependency graph — an edge
A → Bmeans A's proof depends on B. Update the Mermaid graph if the structure changes. - Branches follow
feat/,docs/,refactor/prefixes; work merges tomainvia PR (repo: NyxFoundation/goldfish-fv).