GS.gs
defimported Lean
The Gale-Shapley function: woman j's partner at termination.
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in open List Finset in noncomputable def GS.gs {n : ℕ} [NeZero n] (w m : Preferences n) : Fin n → Fin n
- Defined in
- EconCSLib, `GS.gs`
- Lean proof
- By xbei (from the file's git history), from github.com/gametheoryinlean/EconCSLib at
1a88f809b538(Copyright (c) 2026 EconCSLib contributors. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.30.0.GS.gs← GS.gs (EconCSLib/MarketDesign/Matching/GaleShapley.lean:239): verbatim
- Verified
- 08 Oct 2026
- Axioms
- none listed
- Built on 3
- GS.finalState
finalState: rundaRunwith fueln*n + 1frominitState. - GS.DAStateDA state: per-man proposal cursor + per-woman tentative hold.
- GS.PreferencesList-based preferences:
prefs iis a full permutation ofFin n, ordered from most to least preferred.
- GS.finalState
- Used by 9
- GS.StableMatching.gsStable_greatestThe GS output is the greatest stable matching in the men-preference order: every man weakly prefers his GS partner to his partner in…
- finalState_rank_boundAt termination: if man j proposed to woman i at some round (j was free, i was his nc-th choice at state s, and the rest of the run reaches…
- rsinv_stabilityIf j strictly prefers i over his final partner, i's final partner has rank ≤ j.
- GS.StableMatching.gsStableThe men-proposing Gale–Shapley output, as an element of the lattice of stable matchings.
- gs_injective
gs w mis injective. - galeShapley_isStableGale-Shapley stability: the DA output has no blocking pair. The statement is in the *market* frame (
IsBlocking … (i : M) (j : W)).… - GS.gs_partner_isAchievableThe GS output itself witnesses that
gs.symm jis achievable forj. - gs_bijective
gs w mis a bijection onFin n. - GS.galeShapley_isProposingOptimalMen-optimal stable matching (Gale–Shapley 1962, [MSZ 22.10]): in the men-proposing DA, every man's GS partner is at least as preferred…
Lean source view module on GitHub
set_option autoImplicit true in set_option relaxedAutoImplicit true in open List Finset in /-- The Gale-Shapley function: woman `j`'s partner at termination. -/ noncomputable def GS.gs {n : ℕ} [NeZero n] (w m : Preferences n) : Fin n → Fin n := fun j => (finalState w m).holding j |>.getD default