GS.daStep
defimported Lean
One step of standard men-proposing DA. All free men propose; women pick the best of {held, new proposers} by rank; free men advance their cursor by 1.
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in open List Finset in noncomputable def GS.daStep {n : ℕ} (w m : Preferences n) (s : DAState n) : DAState n
- Defined in
- EconCSLib, `GS.daStep`
- 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.daStep← GS.daStep (EconCSLib/MarketDesign/Matching/GaleShapley.lean:166): verbatim
- Verified
- 08 Oct 2026
- Axioms
- none listed
- Built on 4
- GS.propTargetThe woman man
iproposes to at cursor indexk(none if out of bounds). - GS.isFreeMan
iis free insiff no woman holds him. - GS.DAStateDA state: per-man proposal cursor + per-woman tentative hold.
- GS.PreferencesList-based preferences:
prefs iis a full permutation ofFin n, ordered from most to least preferred.
- GS.propTargetThe woman man
- Used by 25
- 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… - nc_le_n_run
nextChoice i ≤ noverdaRun. - GS.daRunRun DA for at most
fuelsteps, stopping early if no free men remain. - 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… - nc_sum_increase
∑ nextChoicestrictly increases when free men exist. - jinv_step
JInvis preserved by onedaStep. - GS.daStep_nc_heldGS.daStep_nc_held
- holdinv_runholdinv_run
- rsinv_runRSInv over daRun.
- holding_rank_mono_runRank-mono over any
daRun. - GS.daStep_nc_freeGS.daStep_nc_free
- GS.daStep_NoAchievableRejectionInductive step (KEY LEMMA).
NoAchievableRejectionis preserved by onedaStep. Also threadsHoldInv(for the old-holder index… - nc_sum_le_nn
∑ nextChoice ≤ n * nis preserved overdaRun. - 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…
- nc_sum_growsAfter
fuelrounds ending with free men,∑ nextChoicegrew by ≥fuel. - jinv_run
JInvoverdaRun. - daStep_nc_le_n
nextChoice i ≤ nfordaStep. - daStep_held_of_free_propFree man
iproposing to womanpmakes her held indaStep. - 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.
- holding_rank_mono_stepAfter one
daStep, womanj's held man's rank can only decrease (she only upgrades). - holding_injective_stepIn
daStep,holdingremains injective. - rsinv_stepRSInv is preserved by one daStep.
- holding_injective_runOver
Lean source view module on GitHub
set_option autoImplicit true in set_option relaxedAutoImplicit true in open List Finset in /-- One step of standard men-proposing DA. All free men propose; women pick the best of {held, new proposers} by rank; free men advance their cursor by 1. -/ noncomputable def GS.daStep {n : ℕ} (w m : Preferences n) (s : DAState n) : DAState n := let newNextChoice : Fin n → ℕ := fun i => if isFree s i then s.nextChoice i + 1 else s.nextChoice i let proposerList : Fin n → List (Fin n) := fun j => (Finset.univ.filter (fun i => isFree s i && (propTarget m i (s.nextChoice i) == some j))).val.toList let bestNew : Fin n → Option (Fin n) := fun j => (proposerList j).argmin (fun i => (w.prefs j).idxOf i) let newHolding : Fin n → Option (Fin n) := fun j => match s.holding j, bestNew j with | none, none => none | some h, none => some h | none, some p => some p | some h, some p => if (w.prefs j).idxOf p < (w.prefs j).idxOf h then some p else some h { nextChoice := newNextChoice, holding := newHolding }