Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Rural hospitals theorem

Proved
RuralHospitals.rural_hospitals_theorem

by Lucas · Oct 11, 2026 · Mathlib 0df444a (Lean v4.33.1)

rural-hospitalsstable-matching

Consider a many-to-one matching market with a finite set DDD of doctors and a finite set HHH of hospitals, where hospital hhh has qhq_hqh​ positions and all preferences are strict. For a matching μ\muμ, write μ(h)⊆D\mu(h)\subseteq Dμ(h)⊆D for the set of doctors assigned to hhh. Let μ\muμ and ν\nuν be any two stable matchings. Then

  1. a doctor is matched under μ\muμ if and only if she is matched under ν\nuν;
  2. every hospital fills the same number of positions: ∣μ(h)∣=∣ν(h)∣|\mu(h)|=|\nu(h)|∣μ(h)∣=∣ν(h)∣ for all h∈Hh\in Hh∈H;
  3. every hospital with an empty position under μ\muμ receives the same doctors under ν\nuν:
∣μ(h)∣<qh  ⟹  ν(h)=μ(h).|\mu(h)|<q_h \implies \nu(h)=\mu(h).∣μ(h)∣<qh​⟹ν(h)=μ(h).

This is the rural hospitals theorem (Roth 1984, 1986): as long as the mechanism produces stable matchings, changing it cannot give under-subscribed ("rural") hospitals more doctors or different doctors.

Formalization Note Uses the model RuralHospitals.Market (definition RuralHospitals_Market): finite types D (doctors) and H (hospitals); strict preferences given by injective rank functions on Option H / Option D (smaller rank = preferred, none = unmatched / empty position); responsive hospital preferences; capacities capacity : H → ℕ. An assignment is a map μ : D → Option H, and assigned μ h is the finite set of doctors placed at h.

Preamble
import Mathlib
import Definitions.Def_RuralHospitals_Market
Formal statement
namespace RuralHospitals

theorem rural_hospitals_theorem {D H : Type*} [Fintype D] [Fintype H] [DecidableEq H]
    (M : Market D H) (μ ν : Assignment D H) (hμ : M.IsStable μ) (hν : M.IsStable ν) :
    (∀ d, (μ d).isSome = (ν d).isSome) ∧
      (∀ h, (assigned μ h).card = (assigned ν h).card) ∧
      ∀ h, (assigned μ h).card < M.capacity h → assigned ν h = assigned μ h := by sorry

end RuralHospitals
Source
Wikipedia, "Rural hospitals theorem", revision oldid=1064508418 (https://en.wikipedia.org/w/index.php?title=Rural_hospitals_theorem&oldid=1064508418), introduction (the theorem and its two parts). Primary references: Roth, J. Political Economy 92 (1984) 991–1016, doi:10.1086/261272; Roth, Econometrica 54 (1986) 425–427, doi:10.2307/1913160.
Human review
  • Endorsed by Shuze Chen · Oct 11, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Lucas · Oct 11, 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, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me