AFTD Auto-Formalizing Theoretical Domains

GS.StableMatching.instLattice

instanceimported Lean

Conway–Knuth lattice. The stable matchings of a one-to-one market form a lattice under the men-preference order: the join gives every man his more- preferred of two partners, the meet his less-preferred, and both are stable.

Statement

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
open GS in
variable {n : ℕ} (w m : Preferences n) in
variable {w m} in
variable (μ ν : Matching (Fin n) (Fin n))
  (hμ : Matching.IsStable (MatchingMarket.ofEquivData w m) μ)
  (hν : Matching.IsStable (MatchingMarket.ofEquivData w m) ν) in
noncomputable instance GS.StableMatching.instLattice : Lattice (StableMatching w m)
Defined in
EconCSLib, `GS.StableMatching.instLattice`
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
none listed
Built on 27
Used by 3

Lean source view module on GitHub

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
open GS in
variable {n : ℕ} (w m : Preferences n) in
variable {w m} in
variable (μ ν : Matching (Fin n) (Fin n))
  (hμ : Matching.IsStable (MatchingMarket.ofEquivData w m) μ)
  (hν : Matching.IsStable (MatchingMarket.ofEquivData w m) ν) in
/-- **Conway–Knuth lattice.** The stable matchings of a one-to-one market form a lattice under the men-preference order: the join gives every man his more- preferred of two partners, the meet his less-preferred, and both are stable. -/
noncomputable instance GS.StableMatching.instLattice : Lattice (StableMatching w m) :=
  { (inferInstance : PartialOrder (StableMatching w m)) with
    sup := fun μ ν => ⟨stableJoin μ.1 ν.1 μ.2 ν.2, stableJoin_isStable μ.1 ν.1 μ.2 ν.2⟩
    inf := fun μ ν => ⟨stableMeet μ.1 ν.1 μ.2 ν.2, stableMeet_isStable μ.1 ν.1 μ.2 ν.2⟩
    le_sup_left := fun μ ν j => joinWoman_le_left μ.1 ν.1 μ.2 ν.2 j
    le_sup_right := fun μ ν j => joinWoman_le_right μ.1 ν.1 μ.2 ν.2 j
    sup_le := fun μ ν bound h1 h2 j => by
      show (m.prefs j).idxOf (bound.partner j) ≤ (m.prefs j).idxOf (joinWoman μ.1 ν.1 μ.2 ν.2 j)
      rcases joinWoman_eq_or μ.1 ν.1 μ.2 ν.2 j with he | he
      · rw [he]; exact h1 j
      · rw [he]; exact h2 j
    inf_le_left := fun μ ν j => stableMeet_ge_left μ.1 ν.1 μ.2 ν.2 j
    inf_le_right := fun μ ν j => stableMeet_ge_right μ.1 ν.1 μ.2 ν.2 j
    le_inf := fun bound μ ν h1 h2 j => by
      show (m.prefs j).idxOf ((meetEquiv μ.1 ν.1 μ.2 ν.2).symm j)
        ≤ (m.prefs j).idxOf (bound.partner j)
      rcases meetEquiv_symm_eq_or μ.1 ν.1 μ.2 ν.2 j with he | he
      · rw [he]; exact h1 j
      · rw [he]; exact h2 j }
See it in the graphDiscuss this resultChallenge it