MatchingMarket.ofEquivData
defimported Lean
Build a MatchingMarket (Fin n) (Fin n) from list-based preference data. some j ≻ some k iff j appears earlier in the list; none is worst. Side transposition (read carefully). ofEquivData a b puts a on the market's MEN (prefM) and b on the market's WOMEN (prefW). Hence when it is applied as ofEquivData w m with the algorithm's w (women's / choosing preferences) and m (men's / proposing preferences), the market's "men" are the algorithm's *women* and the market's "women" are the algorithm's *men* — the two sides are transposed. Stability is symmetric, so this is harmless, but be aware that a market-M index corresponds to an algorithm woman (and vice versa); the stability proof reasons in the algorithm frame.
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in open List Finset in open GS in variable {n : ℕ} [NeZero n] in noncomputable def MatchingMarket.ofEquivData (wPrefs mPrefs : GS.Preferences n) : MatchingMarket (Fin n) (Fin n)
- Defined in
- EconCSLib, `MatchingMarket.ofEquivData`
- 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.MatchingMarket.ofEquivData← MatchingMarket.ofEquivData (EconCSLib/MarketDesign/Matching/GaleShapley.lean:263): verbatim
- Verified
- 08 Oct 2026
- Axioms
- none listed
- Built on 5
- IsPreferenceA weak preference relation is admissible if it is reflexive, transitive, and total.
- instCoeFunPrefForallForallPropinstCoeFunPrefForallForallProp
- GS.PreferencesList-based preferences:
prefs iis a full permutation ofFin n, ordered from most to least preferred. - MatchingMarketA two-sided matching market.
MandWare the two sides (e.g., men and women, hospitals and residents). Each agent has a preference… - PrefA bundled weak preference relation. Use this interface when several agents may rank the same outcome type differently. Use…
- Used by 54
- 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
- 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
- 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). - 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… - 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 open List Finset in open GS in variable {n : ℕ} [NeZero n] in /-- Build a `MatchingMarket (Fin n) (Fin n)` from list-based preference data. `some j ≻ some k` iff `j` appears earlier in the list; `none` is worst. **Side transposition (read carefully).** `ofEquivData a b` puts `a` on the market's MEN (`prefM`) and `b` on the market's WOMEN (`prefW`). Hence when it is applied as `ofEquivData w m` with the algorithm's `w` (women's / choosing preferences) and `m` (men's / proposing preferences), the market's "men" are the algorithm's *women* and the market's "women" are the algorithm's *men* — the two sides are **transposed**. Stability is symmetric, so this is harmless, but be aware that a market-`M` index corresponds to an algorithm woman (and vice versa); the stability proof reasons in the algorithm frame. -/ noncomputable def MatchingMarket.ofEquivData (wPrefs mPrefs : GS.Preferences n) : MatchingMarket (Fin n) (Fin n) where prefM := fun i => { rel := fun ow1 ow2 => match ow1, ow2 with | none, none => True | none, some _ => False | some _, none => True | some w1, some w2 => (wPrefs.prefs i).idxOf w1 ≤ (wPrefs.prefs i).idxOf w2 prop := { reflexive := by intro ow; cases ow <;> simp transitive := by intro ow1 ow2 ow3 h12 h23 cases ow1 <;> cases ow2 <;> cases ow3 <;> simp_all exact Nat.le_trans h12 h23 total := by intro ow1 ow2; cases ow1 <;> cases ow2 <;> simp exact Nat.le_or_le _ _ } } prefW := fun j => { rel := fun om1 om2 => match om1, om2 with | none, none => True | none, some _ => False | some _, none => True | some m1, some m2 => (mPrefs.prefs j).idxOf m1 ≤ (mPrefs.prefs j).idxOf m2 prop := { reflexive := by intro om; cases om <;> simp transitive := by intro om1 om2 om3 h12 h23 cases om1 <;> cases om2 <;> cases om3 <;> simp_all exact Nat.le_trans h12 h23 total := by intro om1 om2; cases om1 <;> cases om2 <;> simp exact Nat.le_or_le _ _ } }