Game Theory Formalization in Lean
This repository contains a formalization of fundamental theorems in game theory using the Lean proof assistant. The main goal is to prove the existence of Nash Equilibria in finite games.
Lean Version
This project currently targets:
- Lean
4.30.0 - mathlib
v4.30.0
The Lean toolchain is pinned in lean-toolchain, and mathlib is pinned in lakefile.lean / lake-manifest.json.
Building
Install Lean through elan, then run:
lake update
lake build
lake update resolves the pinned dependencies. lake build checks the full formalization.
Core Concepts and Theorems
The proof of Nash's theorem relies on Brouwer's fixed-point theorem. This repository builds up the necessary mathematical framework from scratch.
Proof Strategy Blueprint
The formalization follows this dependency chain:
flowchart TD
A["Simplex infrastructure<br/>stdSimplex, pure strategies, weighted sums"]
B["Scarf-style combinatorics<br/>doors, rooms, colorful simplices"]
C["Primitive-set language<br/>primitive/almost primitive sets, slack vectors"]
D["Scarf path graph<br/>Gi paths, endpoints, path/cycle components"]
E["Primitive path-following<br/>split replacements and ScarfAlgorithmTrace"]
F["Approximate fixed points<br/>colorful simplex sequence"]
G["Compactness and convergence<br/>extract a convergent subsequence"]
H["Brouwer on one simplex<br/>continuous self-map has a fixed point"]
I["Finite product of simplices<br/>reduce product case to one simplex"]
J["Finite games<br/>mixed strategies as product of simplices"]
K["Nash map<br/>continuous self-map on mixed strategies"]
L["Mixed Nash equilibrium<br/>fixed point implies no profitable deviation"]
A --> B
B --> C
B --> D
C --> E
D --> E
B --> F --> G --> H --> I --> J --> K --> L
In words:
- Define mixed strategies as points of standard simplices.
- Prove a Scarf/Sperner-style combinatorial lemma producing colorful simplices.
- Relate the room/door presentation to Scarf's primitive and almost-primitive sets on the enlarged set
T ∪ I. - Formalize the path-following graph
G_i, including its degree characterization and path/cycle component structure. - Connect primitive replacement steps to walks in
G_i, yielding a complete trace from the boundary faceI - ito a fully colored primitive set. - Use finer and finer combinatorial approximations to build approximate fixed points.
- Use compactness to extract a convergent subsequence.
- Use continuity to turn the limit into an actual Brouwer fixed point.
- Lift the single-simplex fixed-point theorem to finite products of simplices.
- Define the Nash map on mixed strategy profiles and apply the product fixed-point theorem.
- Show that a fixed point of the Nash map satisfies the mixed Nash equilibrium condition.
Files
Gametheory/Simplex.lean: Defines the standard simplexstdSimplexover a finite type. Includes constructors likepure, evaluation lemmas (pure_eval_eq,pure_eval_neq), and weighted-sum/typeclass instances needed later for continuity/compactness arguments.Gametheory/Scarf.lean: Develops the combinatorial framework culminating inScarf. Constructs the combinatorial objects (triangulations/labelings in the formalized guise) and proves existence of a "colorful" simplex, which is used to derive fixed points.Gametheory/Primitive.lean: Recasts Scarf's room/door combinatorics in the paper's primitive-set language and connects that language back to the path graphG_i. DefinesExtendedGoods,associatedCell,isPrimitive,isAlmostPrimitive,slackBoundary, primitive replacement steps, split Scarf replacement steps, complete tracesScarfAlgorithmTrace, fully colored primitives, and coordinate-utility realizations. Key results includeisPrimitive_iff_native,isAlmostPrimitive_iff_native,almostPrimitive_incident_primitives_boundary_or_internal,scarfAlgorithmTrace_exists,scarf_fullyColoredPrimitive_exists, andcoordinatePrimitive_erase_replacement_mainLemma.Gametheory/ScarfPath.lean: Formalizes the path-following graphG_iused in Scarf-style proofs. DefinesGiGraph,GiDegree,GiEndpoint, proves the degree characterizationGiDegreeCharacterization_holds, and packages the final component statement asGiComponentStructure_holds.Gametheory/Brouwer.lean: From Scarf’s combinatorial lemma, proves Brouwer’s fixed-point theorem on a single simplex. Contains the main theoremBrouwer(existence of a fixed point for continuous self-maps on a simplex) and the supporting analytical lemmas (compactness, coordinate-wise continuity, convergence of constructed sequences).Gametheory/Brouwer_product.lean: Lifts the single-simplex result to finite products of simplices. Defines helper conversions between a big simplex and a product of simplices (BigSimplex,ProductSimplices), constructs the projection/embedding, proves continuity properties, and states the product fixed-point theoremBrouwer_Product.Gametheory/Nash.lean: Formalizes finite gamesFinGame, mixed strategiesmixedS, payoffs, and mixed Nash equilibriummixedNashEquilibrium. Builds a continuousnash_mapon the product of simplices and appliesBrouwer_Productto obtain existence:ExistsNashEq : ∃ σ : G.mixedS, mixedNashEquilibrium σ.GameTheory.lean: Umbrella file that importsBrouwer,Nash, andSimplexfor convenience.
Open any of the Lean files in an editor with the Lean server running to see goals and check proofs interactively.
Notation and Key Definitions
stdSimplex ℝ α: the standard simplex over a finite typeαwith real coefficients.ExtendedGoods T I: the enlarged setT ∪ I, represented asSum T I, used for Scarf's slack-vector language.associatedCell X: the room/door cell(X ∩ T, I \ X)associated to a subset ofT ∪ I.isPrimitive/isAlmostPrimitive: native primitive and almost-primitive sets, equivalent to the existing room/door presentation.slackBoundary i: the boundary almost-primitive faceI - i.primitiveReplacementStep: the primitive-set replacement relation obtained by passing through a common almost-primitive face.scarfSplitReplacementStep: the split formX → Y → X'of Scarf's replacement algorithm, whereYis almost primitive.ScarfAlgorithmTrace: a primitive-language walk inG_ifromI - ito a fully colored primitive set.GiGraph,GiDegree,GiEndpoint: the graph-theoretic path-following objects for a fixed colori.GiComponentStructure_holds: theorem stating that the components ofG_iare paths or cycles, with endpoints exactly the outside door of typeiand the colorful rooms.scarfAlgorithmTrace_exists: theorem constructing a complete primitive-language Scarf trace.Brouwer_Product: theorem providing a fixed point on a finite product of simplices.FinGame: structure for finite games (finite players and finite pure strategy sets).mixedS: type of mixed strategy profiles for aFinGame.mixedNashEquilibrium σ: predicate thatσ : G.mixedSis a mixed Nash equilibrium.ExistsNashEq: existence theorem for mixed Nash equilibria.
References
- N. V. Ivanov, "Beyond Sperner's Lemma" (source of the Scarf → Brouwer development).
- J. F. Nash, "Non-Cooperative Games", Annals of Mathematics (1951).