[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"v0E0hHtScB":3},"# Game Theory Formalization in Lean\n\nThis 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.\n\n## Lean Version\n\nThis project currently targets:\n\n-   Lean `4.30.0`\n-   mathlib `v4.30.0`\n\nThe Lean toolchain is pinned in `lean-toolchain`, and mathlib is pinned in `lakefile.lean` / `lake-manifest.json`.\n\n## Building\n\nInstall Lean through `elan`, then run:\n\n```bash\nlake update\nlake build\n```\n\n`lake update` resolves the pinned dependencies. `lake build` checks the full formalization.\n\n## Core Concepts and Theorems\n\nThe proof of Nash's theorem relies on Brouwer's fixed-point theorem. This repository builds up the necessary mathematical framework from scratch.\n\n## Proof Strategy Blueprint\n\nThe formalization follows this dependency chain:\n\n```mermaid\nflowchart TD\n    A[\"Simplex infrastructure\u003Cbr/>stdSimplex, pure strategies, weighted sums\"]\n    B[\"Scarf-style combinatorics\u003Cbr/>doors, rooms, colorful simplices\"]\n    C[\"Primitive-set language\u003Cbr/>primitive/almost primitive sets, slack vectors\"]\n    D[\"Scarf path graph\u003Cbr/>Gi paths, endpoints, path/cycle components\"]\n    E[\"Primitive path-following\u003Cbr/>split replacements and ScarfAlgorithmTrace\"]\n    F[\"Approximate fixed points\u003Cbr/>colorful simplex sequence\"]\n    G[\"Compactness and convergence\u003Cbr/>extract a convergent subsequence\"]\n    H[\"Brouwer on one simplex\u003Cbr/>continuous self-map has a fixed point\"]\n    I[\"Finite product of simplices\u003Cbr/>reduce product case to one simplex\"]\n    J[\"Finite games\u003Cbr/>mixed strategies as product of simplices\"]\n    K[\"Nash map\u003Cbr/>continuous self-map on mixed strategies\"]\n    L[\"Mixed Nash equilibrium\u003Cbr/>fixed point implies no profitable deviation\"]\n\n    A --> B\n    B --> C\n    B --> D\n    C --> E\n    D --> E\n    B --> F --> G --> H --> I --> J --> K --> L\n```\n\nIn words:\n\n1.  Define mixed strategies as points of standard simplices.\n2.  Prove a Scarf/Sperner-style combinatorial lemma producing colorful simplices.\n3.  Relate the room/door presentation to Scarf's primitive and almost-primitive sets on the enlarged set `T ∪ I`.\n4.  Formalize the path-following graph `G_i`, including its degree characterization and path/cycle component structure.\n5.  Connect primitive replacement steps to walks in `G_i`, yielding a complete trace from the boundary face `I - i` to a fully colored primitive set.\n6.  Use finer and finer combinatorial approximations to build approximate fixed points.\n7.  Use compactness to extract a convergent subsequence.\n8.  Use continuity to turn the limit into an actual Brouwer fixed point.\n9.  Lift the single-simplex fixed-point theorem to finite products of simplices.\n10. Define the Nash map on mixed strategy profiles and apply the product fixed-point theorem.\n11. Show that a fixed point of the Nash map satisfies the mixed Nash equilibrium condition.\n\n### Files\n\n-   `Gametheory/Simplex.lean`: Defines the standard simplex `stdSimplex` over a finite type. Includes constructors like `pure`, evaluation lemmas (`pure_eval_eq`, `pure_eval_neq`), and weighted-sum/typeclass instances needed later for continuity/compactness arguments.\n-   `Gametheory/Scarf.lean`: Develops the combinatorial framework culminating in `Scarf`. Constructs the combinatorial objects (triangulations/labelings in the formalized guise) and proves existence of a \"colorful\" simplex, which is used to derive fixed points.\n-   `Gametheory/Primitive.lean`: Recasts Scarf's room/door combinatorics in the paper's primitive-set language and connects that language back to the path graph `G_i`. Defines `ExtendedGoods`, `associatedCell`, `isPrimitive`, `isAlmostPrimitive`, `slackBoundary`, primitive replacement steps, split Scarf replacement steps, complete traces `ScarfAlgorithmTrace`, fully colored primitives, and coordinate-utility realizations. Key results include `isPrimitive_iff_native`, `isAlmostPrimitive_iff_native`, `almostPrimitive_incident_primitives_boundary_or_internal`, `scarfAlgorithmTrace_exists`, `scarf_fullyColoredPrimitive_exists`, and `coordinatePrimitive_erase_replacement_mainLemma`.\n-   `Gametheory/ScarfPath.lean`: Formalizes the path-following graph `G_i` used in Scarf-style proofs. Defines `GiGraph`, `GiDegree`, `GiEndpoint`, proves the degree characterization `GiDegreeCharacterization_holds`, and packages the final component statement as `GiComponentStructure_holds`.\n-   `Gametheory/Brouwer.lean`: From Scarf’s combinatorial lemma, proves Brouwer’s fixed-point theorem on a single simplex. Contains the main theorem `Brouwer` (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).\n-   `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 theorem `Brouwer_Product`.\n-   `Gametheory/Nash.lean`: Formalizes finite games `FinGame`, mixed strategies `mixedS`, payoffs, and mixed Nash equilibrium `mixedNashEquilibrium`. Builds a continuous `nash_map` on the product of simplices and applies `Brouwer_Product` to obtain existence: `ExistsNashEq : ∃ σ : G.mixedS, mixedNashEquilibrium σ`.\n-   `GameTheory.lean`: Umbrella file that imports `Brouwer`, `Nash`, and `Simplex` for convenience.\n\nOpen any of the Lean files in an editor with the Lean server running to see goals and check proofs interactively.\n\n## Notation and Key Definitions\n\n-   `stdSimplex ℝ α`: the standard simplex over a finite type `α` with real coefficients.\n-   `ExtendedGoods T I`: the enlarged set `T ∪ I`, represented as `Sum T I`, used for Scarf's slack-vector language.\n-   `associatedCell X`: the room/door cell `(X ∩ T, I \\ X)` associated to a subset of `T ∪ I`.\n-   `isPrimitive` / `isAlmostPrimitive`: native primitive and almost-primitive sets, equivalent to the existing room/door presentation.\n-   `slackBoundary i`: the boundary almost-primitive face `I - i`.\n-   `primitiveReplacementStep`: the primitive-set replacement relation obtained by passing through a common almost-primitive face.\n-   `scarfSplitReplacementStep`: the split form `X → Y → X'` of Scarf's replacement algorithm, where `Y` is almost primitive.\n-   `ScarfAlgorithmTrace`: a primitive-language walk in `G_i` from `I - i` to a fully colored primitive set.\n-   `GiGraph`, `GiDegree`, `GiEndpoint`: the graph-theoretic path-following objects for a fixed color `i`.\n-   `GiComponentStructure_holds`: theorem stating that the components of `G_i` are paths or cycles, with endpoints exactly the outside door of type `i` and the colorful rooms.\n-   `scarfAlgorithmTrace_exists`: theorem constructing a complete primitive-language Scarf trace.\n-   `Brouwer_Product`: theorem providing a fixed point on a finite product of simplices.\n-   `FinGame`: structure for finite games (finite players and finite pure strategy sets).\n-   `mixedS`: type of mixed strategy profiles for a `FinGame`.\n-   `mixedNashEquilibrium σ`: predicate that `σ : G.mixedS` is a mixed Nash equilibrium.\n-   `ExistsNashEq`: existence theorem for mixed Nash equilibria.\n\n## References\n\n-   N. V. Ivanov, \"Beyond Sperner's Lemma\" (source of the Scarf → Brouwer development).\n-   J. F. Nash, \"Non-Cooperative Games\", Annals of Mathematics (1951).\n",1780241991691]