AFTD Auto-Formalizing Theoretical Domains

proposal_rank_bound

theoremverifiedformalizationimported Lean

When free man j proposes to woman i in daStep, the resulting hold has rank ≤ j.

Statement

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
open List Finset in
open GS in
variable {n : ℕ} [NeZero n] in
lemma proposal_rank_bound (w m : Preferences n) (s : DAState n) (j i : Fin n)
    (hfj : isFree s j = true) (hpt : propTarget m j (s.nextChoice j) = some i) :
    ∃ h : Fin n, (daStep w m s).holding i = some h ∧
      (w.prefs i).idxOf h ≤ (w.prefs i).idxOf j
Formalizes
EconCSLib, `proposal_rank_bound`
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.
Verified
08 Oct 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 5
  • 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.propTargetThe woman man i proposes to at cursor index k (none if out of bounds).
  • GS.isFreeMan i is free in s iff no woman holds him.
  • GS.DAStateDA state: per-man proposal cursor + per-woman tentative hold.
  • GS.PreferencesList-based preferences: prefs i is a full permutation of Fin n, ordered from most to least preferred.
Used by 2
  • 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.
  • rsinv_stepRSInv is preserved by one daStep.

Lean source view module on GitHub

set_option autoImplicit true inset_option relaxedAutoImplicit true inopen List Finset inopen GS invariable {n : ℕ} [NeZero n] in/-- When free man `j` proposes to woman `i` in `daStep`, the resulting hold has rank ≤ j. -/lemma proposal_rank_bound (w m : Preferences n) (s : DAState n) (j i : Fin n)    (hfj : isFree s j = true) (hpt : propTarget m j (s.nextChoice j) = some i) :    ∃ h : Fin n, (daStep w m s).holding i = some h ∧      (w.prefs i).idxOf h ≤ (w.prefs i).idxOf j := by  -- j is in proposerList i  have hj_in : j ∈ (Finset.univ.filter (fun k : Fin n =>      isFree s k && (propTarget m k (s.nextChoice k) == some i))).val.toList :=    Multiset.mem_toList.mpr (Finset.mem_val.mpr      (Finset.mem_filter.mpr ⟨Finset.mem_univ _, by simp [hfj, hpt]⟩))  set pl := (Finset.univ.filter (fun k : Fin n =>      isFree s k && (propTarget m k (s.nextChoice k) == some i))).val.toList with hpl_def  have hne_pl : pl ≠ [] := List.ne_nil_of_mem hj_in  -- argmin returns some q with rank ≤ j's rank  have hbn : ∃ q : Fin n, pl.argmin (fun k => (w.prefs i).idxOf k) = some q :=    (Option.ne_none_iff_exists.mp (List.argmin_eq_none.not.mpr hne_pl)).imp      (fun _ h => h.symm)  obtain ⟨q, hq⟩ := hbn  have hq_le : (w.prefs i).idxOf q ≤ (w.prefs i).idxOf j :=    List.le_of_mem_argmin hj_in (show q ∈ pl.argmin (fun k => (w.prefs i).idxOf k) from hq)  -- daStep holding i = some h with rank ≤ q ≤ j  simp only [daStep, ← hpl_def]  cases hs : s.holding i with  | none =>      simp only [hs, hq]      exact ⟨q, rfl, hq_le⟩  | some h =>      simp only [hs, hq]      split_ifs with hlt      · exact ⟨q, rfl, hq_le⟩      · exact ⟨h, rfl, Nat.le_trans (Nat.le_of_not_lt hlt) hq_le⟩
See it in the graphDiscuss this resultChallenge it