Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Stable matchings exist (Gale-Shapley)

Proved
AGT.stable_matching_exists

by Shuze Chen · Sep 13, 2026 · Mathlib 0df444a (Lean v4.33.1)

game-theorymarket-designmechanism-designstable-matching

Every marriage market has a stable matching — Gale–Shapley, rendered from Theorem 10.10 of Algorithmic Game Theory. For finite sets of men and women with strict preferences over the opposite side and ∣M∣=∣W∣|M| = |W|∣M∣=∣W∣ (the hypothesis Nonempty(M≃W)\mathrm{Nonempty}(M \simeq W)Nonempty(M≃W), which the book arranges by dummy partners), some bijection μ:M≃W\mu : M \simeq Wμ:M≃W admits no blocking pair: no man and woman both prefer each other to their assigned partners.

A note on the rendering. The book's Theorem 10.10 states that the male-propose Deferred Acceptance Algorithm terminates in a stable matching; the algorithm is the book's proof device, and this milestone asserts its existence content. A solver may formalize deferred acceptance and its termination, or reach existence by any other route — the fixed-point formulation the book sketches as Theorem 10.14 (via Tarski), for instance.

Preamble
import Definitions.Def_agt_matching
Formal statement
namespace AGT

/-- A stable matching always exists (Gale–Shapley; Theorem 10.10 of
*Algorithmic Game Theory* — the book obtains it as the terminal state of
the male-propose Deferred Acceptance Algorithm).  The hypothesis
`Nonempty (M ≃ W)` is the book's standing convention `|M| = |W|`, arranged
there by dummy partners; with no bijection at all there are no matchings
to speak of. -/
theorem stable_matching_exists {M W : Type*} [Fintype M] [Fintype W]
    (PM : M → W → W → Prop) (PW : W → M → M → Prop)
    (hM : IsPrefProfile PM) (hW : IsPrefProfile PW)
    (hcard : Nonempty (M ≃ W)) :
    ∃ μ : M ≃ W, IsStableMatching PM PW μ := by
  sorry

end AGT
Source
N. Nisan, T. Roughgarden, E. Tardos, V. V. Vazirani (eds.), Algorithmic Game Theory, Cambridge University Press 2007, https://doi.org/10.1017/CBO9780511800481, Section 10.4, Theorem 10.10, pp. 256-257
Read-back

What the Lean code literally says, in plain math · claude-fable-5

Read-back: stable_matching_exists

Setting and hypotheses. Let MMM and WWW be two finite types (both carry Fintype instances; either or both may be empty). The data are:

  • PMP^MPM, assigning to each m∈Mm \in Mm∈M a binary relation PmMP^M_mPmM​ on WWW (write PmM(w,w′)P^M_m(w, w')PmM​(w,w′) when the relation holds of the ordered pair (w,w′)(w, w')(w,w′));
  • PWP^WPW, assigning to each w∈Ww \in Ww∈W a binary relation PwWP^W_wPwW​ on MMM;
  • hypothesis hMh_MhM​: for every m∈Mm \in Mm∈M, the relation PmMP^M_mPmM​ is a strict total order on WWW — that is, trichotomous (∀w w′\forall w\, w'∀ww′, PmM(w,w′)P^M_m(w,w')PmM​(w,w′) or w=w′w = w'w=w′ or PmM(w′,w)P^M_m(w',w)PmM​(w′,w)), irreflexive, and transitive;
  • hypothesis hWh_WhW​: symmetrically, for every w∈Ww \in Ww∈W, PwWP^W_wPwW​ is a strict total order on MMM;
  • hypothesis hcardh_{\mathrm{card}}hcard​: the type of bijections M≃WM \simeq WM≃W is nonempty — i.e. there merely exists some bijection between MMM and WWW (a Lean Equiv is a function with a two-sided inverse; the hypothesis provides no particular one). Since MMM and WWW are finite, this is equivalent to ∣M∣=∣W∣|M| = |W|∣M∣=∣W∣.

Conclusion. There exists a bijection μ:M→W\mu : M \to Wμ:M→W such that no pair blocks it, i.e.

∀m∈M, ∀w∈W:¬(PmM(w, μ(m)) ∧ PwW(m, μ−1(w))),\forall m \in M,\ \forall w \in W:\quad \neg\Big( P^M_m\big(w,\ \mu(m)\big) \ \wedge\ P^W_w\big(m,\ \mu^{-1}(w)\big) \Big),∀m∈M, ∀w∈W:¬(PmM​(w, μ(m)) ∧ PwW​(m, μ−1(w))),

where μ−1\mu^{-1}μ−1 is the inverse of μ\muμ. In words: there is no man–woman pair (m,w)(m,w)(m,w) such that mmm's relation holds of (www, mmm's partner μ(m)\mu(m)μ(m)) and www's relation holds of (mmm, www's partner μ−1(w)\mu^{-1}(w)μ−1(w)). This unfolds the custom predicate IsStableMatching (which is exactly the "no blocking pair" condition above, and nothing more: no individual-rationality clause, no unmatched agents — μ\muμ matches everyone).

Edge cases. If MMM and WWW are both empty, hcardh_{\mathrm{card}}hcard​ holds (the empty bijection exists), the stability condition is vacuous, and the conclusion holds trivially. If exactly one of M,WM, WM,W is empty, hcardh_{\mathrm{card}}hcard​ is false and the theorem is vacuously true for that instance. The theorem asserts mere existence (∃\exists∃, not ∃!\exists!∃!): nothing is claimed about uniqueness or about any particular construction.

Human review
  • Endorsed by Community (Bot) · Sep 13, 2026

  • Endorsed by Shuze Chen · Sep 13, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, licensed under Apache 2.0.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTermsJoin SlackJoin Zulip© 2026 Prove2Me