GS.Preferences
structureimported Lean
List-based preferences: prefs i is a full permutation of Fin n, ordered from most to least preferred.
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in open List Finset in structure GS.Preferences (n : ℕ)
- Defined in
- EconCSLib, `GS.Preferences`
- 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.Preferences← GS.Preferences (EconCSLib/MarketDesign/Matching/GaleShapley.lean:104): verbatim
- Verified
- 08 Oct 2026
- Axioms
- none listed
- Used by 106
- holding_injective_runOver
daRun, holding remains injective. - proposal_rank_boundWhen free man
jproposes to womaniindaStep, the resulting hold has rank ≤ j. - holdinv_step
HoldInvis preserved by one DA step. Proof structure: case-analyze on the pair(s.holding p, bestNew p)that drivesdaStep's… - GS.propTarget_lt
propTargetreturnssomewhenk < n. - GS.daStepOne step of standard men-proposing DA. All free men propose; women pick the best of {held, new proposers} by rank; free men advance their…
- GS.joinWoman_le_rightGS.joinWoman_le_right
- nc_le_n_run
nextChoice i ≤ noverdaRun. - GS.daRunRun DA for at most
fuelsteps, stopping early if no free men remain. - GS.joinWoman_mem_menIf
iis manj's join-partner thenjis one ofi's two men. - GS.finalState_NoAchievableRejectionThe invariant holds at
finalState. - GS.StableMatching.partnerMan
j's partner under a stable matching. - GS.daRun_NoAchievableRejection
NoAchievableRejectionis preserved bydaRun(threadingHoldInvand holding-injectivity, both also preserved bydaStep). - GS.daStep_holdingOne step of DA: woman
p's new holding, expanded once. This is the workhorse rewrite for any proof that needs to case-split on what… - GS.mPartnerThe man partnered to woman
iunder a stable matchingμ. - GS.meetMan_eq_orGS.meetMan_eq_or
- nc_sum_increase
∑ nextChoicestrictly increases when free men exist. - jinv_step
JInvis preserved by onedaStep. - pl_free_propsHelper: membership in the proposerList implies freedom and proposal target.
- GS.gsThe Gale-Shapley function: woman
j's partner at termination. - GS.daStep_nc_heldGS.daStep_nc_held
- holdinv_runholdinv_run
- 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.
- rsinv_runRSInv over daRun.
- holding_rank_mono_runRank-mono over any
daRun. - GS.stableMeetThe meet
μ ∧ ν: each woman keeps her more-preferred man; each man keeps his less-preferred woman. - final_holding_injective
finalStateholding is injective. - GS.stableMeet_matchMGS.stableMeet_matchM
- GS.stableMeet_matchWGS.stableMeet_matchW
- GS.stableMeet_ge_leftGS.stableMeet_ge_left
- not_free_of_nc_ge
nextChoice i ≥ n+ injectivity +JInv→ maniis not free. - rsinv_finalStateRSInv at finalState.
- GS.meetEquiv_symm_eq_orThe meet woman of man
jis one of his two partners (his worse). - GS.daStep_nc_freeGS.daStep_nc_free
- GS.NoAchievableRejectionRun-state invariant for proposer optimality.
NoAchievableRejection w m ssays: at states, for every achievable pair(j, wj), if man… - 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.initState_NoAchievableRejectionThe invariant holds vacuously at
initState: no man has proposed yet. - nc_sum_le_nn
∑ nextChoice ≤ n * nis preserved overdaRun. - finalState_no_free_menAt termination, every man is held (no free man remains). Proof: if a free man remained,
nc_sum_growswould given*n + 1 ≤ n*n,… - 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…
- GS.meetMan_le_leftGS.meetMan_le_left
- GS.stableMeet_ge_rightGS.stableMeet_ge_right
- GS.joinWoman_injectiveThe join woman-assignment is injective.
- GS.propTargetThe woman man
iproposes to at cursor indexk(none if out of bounds). - GS.matchM_mPartnerGS.matchM_mPartner
- initState_injective
initStatehas trivially injective holding (allnone). - GS.wPartner_stableMeetGS.wPartner_stableMeet
- rsinv_stabilityIf j strictly prefers i over his final partner, i's final partner has rank ≤ j.
- 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.
- final_all_women_holdAt termination, every woman holds some man.
- GS.matchW_wPartnerGS.matchW_wPartner
- GS.opposed_preferencesOpposed preferences. Let
μbe a stable matching. If manjis matched to womanwjunder another matchingνand **strictly… - holdinv_finalStateholdinv_finalState
- GS.meetManWoman
i's more-preferred man acrossμandν. - nc_sum_growsAfter
fuelrounds ending with free men,∑ nextChoicegrew by ≥fuel. - 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.
- final_all_men_heldAt termination, every man is held by some woman.
- GS.stableJoin_matchWGS.stableJoin_matchW
- jinv_initjinv_init
- jinv_run
JInvoverdaRun. - holdinv_initholdinv_init
- GS.wPartnerThe woman partnered to man
junder a stable matchingμ(total, since a stable matching of the balanced market is perfect). - daStep_nc_le_n
nextChoice i ≤ nfordaStep. - 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_injective
gs w mis injective. - GS.finalState
finalState: rundaRunwith fueln*n + 1frominitState. - JInvJInv (Proposed → Held): once man
ihas proposed to womanpin some prior step,pis currently held by *someone* (possiblyi,… - daStep_held_of_free_propFree man
iproposing to womanpmakes her held indaStep. - GS.meetMan_worse_rightGS.meetMan_worse_right
- GS.meetMan_worse_leftGS.meetMan_worse_left
- proposal_rank_bound_runOver a daRun, if man j proposed to woman i at the first step, woman i's final partner has rank ≤ j's rank in w.prefs i.
- 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
- RSInvRSInv (the deferred-acceptance rank invariant — the engine of the stability proof): for every man
jand every womanithatjhas… - MatchingMarket.ofEquivDataBuild a
MatchingMarket (Fin n) (Fin n)from list-based preference data.some j ≻ some kiffjappears earlier in the list;noneis… - holding_rank_mono_stepAfter one
daStep, womanj's held man's rank can only decrease (she only upgrades). - galeShapley_isStableGale-Shapley stability: the DA output has no blocking pair. The statement is in the *market* frame (
IsBlocking … (i : M) (j : W)).… - rsinv_initrsinv_init
- HoldInvHoldInv (Held → Proposed): if woman
pcurrently holds manj, thenjmust already have proposed top— i.e.,pis in the… - 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…
- holding_injective_stepIn
daStep,holdingremains injective. - GS.gs_partner_isAchievableThe GS output itself witnesses that
gs.symm jis achievable forj. - held_preserved_runOnce held, always held over
daRun. - rsinv_stepRSInv is preserved by one daStep.
- gs_bijective
gs w mis a bijection onFin n. - 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
- holding_injective_runOver
Lean source view module on GitHub
set_option autoImplicit true in set_option relaxedAutoImplicit true in open List Finset in /-- List-based preferences: `prefs i` is a full permutation of `Fin n`, ordered from most to least preferred. -/ structure GS.Preferences (n : ℕ) where prefs : Fin n → List (Fin n) valid : ∀ i, (prefs i).Nodup ∧ (prefs i).length = n