Matching
structureimported Lean
A matching is a partial bijection between M and W. matchM i is the partner of i ∈ M (or none if unmatched). matchW j is the partner of j ∈ W (or none if unmatched).
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in @[ext] structure Matching (M W : Type*)
- Defined in
- EconCSLib, `Matching`
- 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.Matching← Matching (EconCSLib/MarketDesign/Matching/Basic.lean:57): verbatim
- Verified
- 08 Oct 2026
- Axioms
- none listed
- Used by 58
- GS.joinWoman_le_rightGS.joinWoman_le_right
- GS.joinWoman_mem_menIf
iis manj's join-partner thenjis one ofi's two men. - GS.StableMatching.partnerMan
j's partner under a stable matching. - GS.mPartnerThe man partnered to woman
iunder a stable matchingμ. - GS.meetMan_eq_orGS.meetMan_eq_or
- Matching.IsStableA matching is stable if it has no blocking pair. [MSZ 22.5]
- GS.prefM_strictGS.prefM_strict
- GS.stableJoin_matchMGS.stableJoin_matchM
- 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…
- GS.stableMeet_isStableThe meet of two stable matchings is stable.
- GS.stableMeetThe meet
μ ∧ ν: each woman keeps her more-preferred man; each man keeps his less-preferred woman. - GS.stableMeet_matchMGS.stableMeet_matchM
- Matching.IsBlockingA pair
(m, w)is a blocking pair for matchingμif bothmandwstrictly prefer each other to their current partners. [MSZ 22.5] - GS.stableMeet_matchWGS.stableMeet_matchW
- GS.stableMeet_ge_leftGS.stableMeet_ge_left
- GS.meetEquiv_symm_eq_orThe meet woman of man
jis one of his two partners (his worse). - Matching.ofGSCoerce a bijective
f : Fin n → Fin nintoMatching (Fin n) (Fin n). - GS.StableMatching.gsStable_isGreatest
gsStableis the greatest element of the stable-matching lattice. - GS.daStep_NoAchievableRejectionInductive step (KEY LEMMA).
NoAchievableRejectionis preserved by onedaStep. Also threadsHoldInv(for the old-holder index… - Matching.IsIndividuallyRationalA matching is individually rational if every matched agent strictly prefers their partner to being unmatched.
- GS.meetMan_le_leftGS.meetMan_le_left
- GS.stableMeet_ge_rightGS.stableMeet_ge_right
- GS.joinWoman_injectiveThe join woman-assignment is injective.
- GS.matchM_mPartnerGS.matchM_mPartner
- GS.wPartner_stableMeetGS.wPartner_stableMeet
- GS.joinWoman_worse_rightDual of
joinWoman_worse_leftwith the roles ofμ,νswapped. - GS.meetMan_mem_womenGS.meetMan_mem_women
- GS.StableMatching.gsStableThe men-proposing Gale–Shapley output, as an element of the lattice of stable matchings.
- GS.matchW_wPartnerGS.matchW_wPartner
- GS.opposed_preferencesOpposed preferences. Let
μbe a stable matching. If manjis matched to womanwjunder another matchingνand **strictly… - GS.meetManWoman
i's more-preferred man acrossμandν. - GS.stableJoinThe join
μ ∨ ν: each man keeps his more-preferred of the two partners; each woman keeps her less-preferred man. - GS.wPartner_stableJoinGS.wPartner_stableJoin
- GS.joinWoman_le_leftGS.joinWoman_le_left
- GS.stableJoin_isStableThe join of two stable matchings is stable.
- GS.stableJoin_matchWGS.stableJoin_matchW
- GS.wPartnerThe woman partnered to man
junder a stable matchingμ(total, since a stable matching of the balanced market is perfect). - GS.wPartner_eq_iffThe man-of and woman-of partner maps are inverse to each other.
- GS.joinEquivThe join woman-assignment packaged as an equivalence (injective on the finite
Fin n, hence bijective). - GS.meetMan_worse_rightGS.meetMan_worse_right
- GS.meetMan_worse_leftGS.meetMan_worse_left
- GS.meetEquivThe meet man-assignment packaged as an equivalence.
- GS.joinWoman_worse_leftIf
iis the join-partner of herμ-manj, theniweakly prefers herν-man toj(sojis her worse man). - GS.opposed_preferences_womenDual of
opposed_preferences: if womanistrictly prefers manmito hercandidate-manmi', thenmistrictly prefers his… - GS.IsAchievable
IsAchievable w m j wjsays womanwjis achievable for manj: some stable matching pairs them. Recall the codebase convention… - GS.joinWoman_eq_orGS.joinWoman_eq_or
- GS.StableMatching.instPartialOrderMen-preference order:
μ ≤ νiff every man weakly prefers hisν-partner to hisμ-partner (smalleridxOf= more preferred). - GS.StableMatching.matchW_partnerGS.StableMatching.matchW_partner
- galeShapley_isStableGale-Shapley stability: the DA output has no blocking pair. The statement is in the *market* frame (
IsBlocking … (i : M) (j : W)).… - GS.StableMatching.instLatticeConway–Knuth lattice. The stable matchings of a one-to-one market form a lattice under the men-preference order: the join gives every…
- GS.meetMan_le_rightGS.meetMan_le_right
- GS.StableMatchingThe type of stable matchings of a one-to-one market.
- GS.stable_matching_perfectIn the balanced full-preference one-to-one market, every stable matching is perfect: every woman and every man is matched. This is the…
- GS.gs_partner_isAchievableThe GS output itself witnesses that
gs.symm jis achievable forj. - GS.joinWomanMan
j's more-preferred partner across stable matchingsμandν. - GS.prefW_strictGS.prefW_strict
- 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…
- GS.meetMan_injectiveGS.meetMan_injective
Lean source view module on GitHub
set_option autoImplicit true in set_option relaxedAutoImplicit true in /-- A matching is a partial bijection between `M` and `W`. `matchM i` is the partner of `i ∈ M` (or `none` if unmatched). `matchW j` is the partner of `j ∈ W` (or `none` if unmatched). -/ @[ext] structure Matching (M W : Type*) where /-- Partner of each agent on side `M`. -/ matchM : M → Option W /-- Partner of each agent on side `W`. -/ matchW : W → Option M /-- Consistency: `matchM m = some w ↔ matchW w = some m`. -/ consistent : ∀ (m : M) (w : W), matchM m = some w ↔ matchW w = some m