Documentation

CslibFrontier.Algorithms.Lean.Matroid.Intersection

Matroid intersection: min–max theorem and augmenting paths #

For matroids M₁ M₂ : Matroid α and a finite candidate ground set E : Finset α, this module proves Edmonds' matroid intersection theorem: the maximum cardinality of a common independent subset of E equals the minimum over U ⊆ E of M₁.eRk U + M₂.eRk (E \ U). The proof is algorithmic and follows [Sch17], Section 10.5. It defines the exchange digraph H(M₁, M₂, I) of a common independent set I, shows that augmenting I along a shortest source-to-sink walk gives a common independent set with one more element (Theorem 10.6), and shows that if no such walk exists then the set of vertices unreachable from the sources certifies that I is maximum (Theorem 10.7). Iterating the two cases gives the min–max equality (Theorem 10.9).

The matroids need not have ground set E: elements of E outside Mᵢ.E behave as loops of Mᵢ (they lie in no independent set), and eRk only depends on the part of a set inside the ground set. Taking E to be the common finite ground set recovers [Sch17], Theorem 10.9 verbatim (iSup_encard_eq_iInf_eRk_add_eRk).

Main definitions #

Main results #

References #

Common independent sets and weak duality #

def Cslib.Algorithms.Lean.Matroid.IsCommonIndep {α : Type u_1} (M₁ M₂ : Matroid α) (I : Finset α) :

I : Finset α is a common independent set of M₁ and M₂.

theorem Cslib.Algorithms.Lean.Matroid.IsCommonIndep.indep_left {α : Type u_1} {M₁ M₂ : Matroid α} {I : Finset α} (h : IsCommonIndep M₁ M₂ I) :
M₁.Indep ↑I
theorem Cslib.Algorithms.Lean.Matroid.IsCommonIndep.indep_right {α : Type u_1} {M₁ M₂ : Matroid α} {I : Finset α} (h : IsCommonIndep M₁ M₂ I) :
M₂.Indep ↑I
@[simp]
theorem Cslib.Algorithms.Lean.Matroid.isCommonIndep_empty {α : Type u_1} (M₁ M₂ : Matroid α) :
IsCommonIndep M₁ M₂ ∅

The empty set is a common independent set of any two matroids.

def Cslib.Algorithms.Lean.Matroid.IsMaxCommonIndep {α : Type u_1} (M₁ M₂ : Matroid α) (E I : Finset α) :

I is a maximum-cardinality common independent subset of E : Finset α.

theorem Cslib.Algorithms.Lean.Matroid.encard_le_eRk_add_eRk {α : Type u_1} {M₁ M₂ : Matroid α} {X I : Set α} (hIX : I ⊆ X) (h₁ : M₁.Indep I) (h₂ : M₂.Indep I) (U : Set α) :
I.encard ≤ M₁.eRk U + M₂.eRk (X \ U)

Weak duality for matroid intersection (Set form): a set I ⊆ X independent in both M₁ and M₂ has I.encard ≤ M₁.eRk U + M₂.eRk (X \ U) for every U. No finiteness is needed.

theorem Cslib.Algorithms.Lean.Matroid.IsCommonIndep.card_le_eRk_add_eRk {α : Type u_1} [DecidableEq α] {M₁ M₂ : Matroid α} {E I : Finset α} (hI : IsCommonIndep M₁ M₂ I) (hIE : I ⊆ E) (U : Finset α) :
↑I.card ≤ M₁.eRk ↑U + M₂.eRk ↑(E \ U)

Weak duality for matroid intersection (ℕ∞ rank): for any common independent subset I ⊆ E and any U : Finset α, (I.card : ℕ∞) ≤ M₁.eRk ↑U + M₂.eRk ↑(E \ U).

theorem Cslib.Algorithms.Lean.Matroid.IsCommonIndep.card_le_rk_add_rk {α : Type u_1} [DecidableEq α] {M₁ M₂ : Matroid α} {E I : Finset α} (hI : IsCommonIndep M₁ M₂ I) (hIE : I ⊆ E) (U : Finset α) :
I.card ≤ (M₁.eRk ↑U).toNat + (M₂.eRk ↑(E \ U)).toNat

Weak duality for matroid intersection (ℕ rank): for any common independent subset I ⊆ E and any U : Finset α, I.card ≤ (M₁.eRk ↑U).toNat + (M₂.eRk ↑(E \ U)).toNat.

theorem Cslib.Algorithms.Lean.Matroid.isMaxCommonIndep_of_card_eq_eRk_add_eRk {α : Type u_1} [DecidableEq α] {M₁ M₂ : Matroid α} {E I U : Finset α} (hIE : I ⊆ E) (hI : IsCommonIndep M₁ M₂ I) (heq : ↑I.card = M₁.eRk ↑U + M₂.eRk ↑(E \ U)) :
IsMaxCommonIndep M₁ M₂ E I

A common independent subset I ⊆ E attaining M₁.eRk ↑U + M₂.eRk ↑(E \ U) for some U is maximum among all common independent subsets of E.

Chordless exchange sequences and the unreachable-set certificate #

theorem Cslib.Algorithms.Lean.Matroid.indep_exchange_chain {α : Type u_1} [DecidableEq α] {M : Matroid α} {I : Finset α} {y₀ : α} {k : ℕ} (hB_indep : M.Indep ↑(insert y₀ I)) {x y : Fin k → α} (hx_mem : ∀ (i : Fin k), x i ∈ I) (hx_inj : Function.Injective x) (hy_not : ∀ (i : Fin k), y i ∉ insert y₀ I) (hy_inj : Function.Injective y) (hy_dep : ∀ (i : Fin k), ¬M.Indep ↑(insert (y i) I)) (hdiag : ∀ (i : Fin k), M.Indep ↑(insert (y i) (I.erase (x i)))) (hno_chord : ∀ (i j : Fin k), i < j → ¬M.Indep ↑(insert (y j) (I.erase (x i)))) :

Chordless exchange sequences preserve independence. Let insert y₀ I be independent in M, and let x, y : Fin k → α be injective families with x i ∈ I and y i ∉ insert y₀ I such that

  • ¬ M.Indep ↑(insert (y i) I): each y i spans a fundamental circuit of I;
  • M.Indep ↑(insert (y i) (I.erase (x i))): y i can replace x i; and
  • for all i < j, ¬ M.Indep ↑(insert (y j) (I.erase (x i))): there are no forward chords.

Then (insert y₀ I \ {x i}) ∪ {y i} is independent in M.

This is the matroid step of [Sch17], Theorem 10.6. In the source, it is Lemma 10.2 applied to the unique perfect matching {x i, y i} in the exchange graph H(M, I) (the triangular no-chord condition gives uniqueness), followed by a rank argument that adds y₀. Here the statement is proved directly, by downward induction on i, showing that every x i lies in the closure of the new set.

theorem Cslib.Algorithms.Lean.Matroid.card_eq_eRk_add_eRk_of_closed {α : Type u_1} [DecidableEq α] {M₁ M₂ : Matroid α} {E I R : Finset α} (hIE : I ⊆ E) (hI : IsCommonIndep M₁ M₂ I) (hX1 : ∀ y ∈ E \ I, M₁.Indep ↑(insert y I) → y ∈ R) (hX2 : ∀ y ∈ R \ I, ¬M₂.Indep ↑(insert y I)) (hcl1 : ∀ x ∈ R ∩ I, ∀ y ∈ E \ I, M₁.Indep ↑(insert y (I.erase x)) → y ∈ R) (hcl2 : ∀ y ∈ R \ I, ∀ x ∈ I, M₂.Indep ↑(insert y (I.erase x)) → x ∈ R) :
↑I.card = M₁.eRk ↑(E \ R) + M₂.eRk ↑R

The unreachable-set certificate ([Sch17], proof of Theorem 10.7): let I ⊆ E be a common independent set of M₁ and M₂. Let R contain the source set X₁(I), avoid the sink set X₂(I), and be closed under the exchange arcs: M₁-arcs from x ∈ R ∩ I to y ∈ E \ I, and M₂-arcs from y ∈ R \ I to x ∈ I. Then I.card = M₁.eRk ↑(E \ R) + M₂.eRk ↑R, so I and the separator U := E \ R attain equality in weak duality. In the source, U is the set of vertices not reachable from X₁(I), and the two summands are (27) r₁(U) = |I ∩ U| and its M₂ counterpart r₂(E \ U) = |I \ U|.

The exchange digraph, shortest augmenting walks, and Edmonds' theorem #

def Cslib.Algorithms.Lean.Matroid.IsExchSource {α : Type u_1} [DecidableEq α] (M₁ : Matroid α) (E I : Finset α) (y : α) :

y lies in the source set X₁(I) of the exchange digraph ([Sch17], (24)): y ∈ E \ I and insert y I is independent in M₁.

def Cslib.Algorithms.Lean.Matroid.IsExchSink {α : Type u_1} [DecidableEq α] (M₂ : Matroid α) (E I : Finset α) (y : α) :

y lies in the sink set X₂(I) of the exchange digraph ([Sch17], (24)): y ∈ E \ I and insert y I is independent in M₂.

def Cslib.Algorithms.Lean.Matroid.IsExchArc {α : Type u_1} [DecidableEq α] (M₁ M₂ : Matroid α) (E I : Finset α) (u v : α) :

u → v is an arc of the exchange digraph H(M₁, M₂, I) on E ([Sch17], (23)):

  • from u ∈ I to v ∈ E \ I when insert v (I.erase u) is independent in M₁;
  • from u ∈ E \ I to v ∈ I when insert u (I.erase v) is independent in M₂.
def Cslib.Algorithms.Lean.Matroid.IsExchWalk {α : Type u_1} [DecidableEq α] (M₁ M₂ : Matroid α) (E I : Finset α) (p : List α) :

p is a directed walk in the exchange digraph H(M₁, M₂, I) on E.

def Cslib.Algorithms.Lean.Matroid.IsExchAugWalk {α : Type u_1} [DecidableEq α] (M₁ M₂ : Matroid α) (E I : Finset α) (p : List α) :

p is a nonempty walk in H(M₁, M₂, I) from the source set X₁(I) to the sink set X₂(I). A single vertex of X₁(I) ∩ X₂(I) is such a walk (of length 0 in the source's arc count).

def Cslib.Algorithms.Lean.Matroid.IsShortestExchAugWalk {α : Type u_1} [DecidableEq α] (M₁ M₂ : Matroid α) (E I : Finset α) (p : List α) :

p is an X₁(I)-to-X₂(I) walk in H(M₁, M₂, I) with the minimum number of vertices.

theorem Cslib.Algorithms.Lean.Matroid.exists_isShortestExchAugWalk {α : Type u_1} [DecidableEq α] {M₁ M₂ : Matroid α} {E I : Finset α} (hex : ∃ (p : List α), IsExchAugWalk M₁ M₂ E I p) :
∃ (p : List α), IsShortestExchAugWalk M₁ M₂ E I p

If some X₁(I)-to-X₂(I) walk exists, then a shortest one exists.

theorem Cslib.Algorithms.Lean.Matroid.IsShortestExchAugWalk.nodup {α : Type u_1} [DecidableEq α] {M₁ M₂ : Matroid α} {E I : Finset α} {p : List α} (hshort : IsShortestExchAugWalk M₁ M₂ E I p) :

A shortest augmenting walk visits no vertex twice: a repeated vertex would give a source after the first position or a shortcut arc.

theorem Cslib.Algorithms.Lean.Matroid.IsShortestExchAugWalk.augment {α : Type u_1} [DecidableEq α] {M₁ M₂ : Matroid α} {E I : Finset α} {p : List α} (hshort : IsShortestExchAugWalk M₁ M₂ E I p) (hIE : I ⊆ E) :

Augmenting along a shortest walk ([Sch17], Theorem 10.6): if I ⊆ E and p is a shortest X₁(I)-to-X₂(I) walk in the exchange digraph H(M₁, M₂, I), then I ∆ p is a common independent subset of E with one more element than I. The walk alternates between E \ I and I, so I ∆ p is the source's (I \ {z₁, …, zₘ}) ∪ {y₀, …, yₘ}. Minimality makes the walk chordless in both directions, and indep_exchange_chain applies once to M₁ (reading the walk forwards) and once to M₂ (reading it backwards). The independence of I itself is not needed: it follows from y₀ ∈ X₁(I) and yₘ ∈ X₂(I).

theorem Cslib.Algorithms.Lean.Matroid.exists_separator_of_not_exists_exchAugWalk {α : Type u_1} [DecidableEq α] {M₁ M₂ : Matroid α} {E I : Finset α} (hIE : I ⊆ E) (hI : IsCommonIndep M₁ M₂ I) (hno : ¬∃ (p : List α), IsExchAugWalk M₁ M₂ E I p) :
∃ U ⊆ E, ↑I.card = M₁.eRk ↑U + M₂.eRk ↑(E \ U)

No augmenting walk certifies optimality ([Sch17], Theorem 10.7): if I ⊆ E is a common independent set and the exchange digraph H(M₁, M₂, I) has no X₁(I)-to-X₂(I) walk, then the set U ⊆ E of vertices not reachable from X₁(I) satisfies (I.card : ℕ∞) = M₁.eRk ↑U + M₂.eRk ↑(E \ U).

theorem Cslib.Algorithms.Lean.Matroid.exists_commonIndep_card_eq_eRk_add_eRk {α : Type u_1} [DecidableEq α] (M₁ M₂ : Matroid α) (E : Finset α) :
∃ (I : Finset α), ∃ U ⊆ E, IsMaxCommonIndep M₁ M₂ E I ∧ ↑I.card = M₁.eRk ↑U + M₂.eRk ↑(E \ U)

Edmonds' matroid intersection theorem (ℕ∞ rank form; [Edm70]; [Sch17], Theorem 10.9; [Sch03], Chapter 41): for matroids M₁ M₂ : Matroid α and a finite candidate ground set E : Finset α, some maximum common independent subset I ⊆ E and some U ⊆ E satisfy (I.card : ℕ∞) = M₁.eRk ↑U + M₂.eRk ↑(E \ U). Together with weak duality (IsCommonIndep.card_le_eRk_add_eRk), the maximum equals the minimum; see iSup_card_eq_iInf_eRk_add_eRk. The proof is the augmenting-path algorithm: start from ∅, augment along shortest exchange walks (IsShortestExchAugWalk.augment) until none exists, then read off U (exists_separator_of_not_exists_exchAugWalk).

theorem Cslib.Algorithms.Lean.Matroid.exists_commonIndep_card_eq_rk_add_rk {α : Type u_1} [DecidableEq α] (M₁ M₂ : Matroid α) (E : Finset α) :
∃ (I : Finset α), ∃ U ⊆ E, IsMaxCommonIndep M₁ M₂ E I ∧ I.card = (M₁.eRk ↑U).toNat + (M₂.eRk ↑(E \ U)).toNat

Edmonds' matroid intersection theorem (ℕ rank form): some maximum common independent subset I ⊆ E and some U ⊆ E satisfy I.card = (M₁.eRk ↑U).toNat + (M₂.eRk ↑(E \ U)).toNat. The ranks are finite because E is.

theorem Cslib.Algorithms.Lean.Matroid.iSup_card_eq_iInf_eRk_add_eRk {α : Type u_1} [DecidableEq α] (M₁ M₂ : Matroid α) (E : Finset α) :
⨆ (I : Finset α), ⨆ (_ : I ⊆ E ∧ IsCommonIndep M₁ M₂ I), ↑I.card = ⨅ (U : Finset α), ⨅ (_ : U ⊆ E), M₁.eRk ↑U + M₂.eRk ↑(E \ U)

Edmonds' matroid intersection theorem (min–max form; [Edm70]; [Sch17], Theorem 10.9): for matroids M₁ M₂ : Matroid α and a finite candidate ground set E : Finset α, the maximum cardinality of a common independent subset of E equals the minimum over U ⊆ E of M₁.eRk ↑U + M₂.eRk ↑(E \ U).

theorem Cslib.Algorithms.Lean.Matroid.iSup_encard_eq_iInf_eRk_add_eRk {α : Type u_1} (M₁ M₂ : Matroid α) {X : Set α} (hX : X.Finite) :
⨆ (I : Set α), ⨆ (_ : I ⊆ X ∧ M₁.Indep I ∧ M₂.Indep I), I.encard = ⨅ (U : Set α), ⨅ (_ : U ⊆ X), M₁.eRk U + M₂.eRk (X \ U)

Edmonds' matroid intersection theorem (Set min–max form; [Edm70]; [Sch17], Theorem 10.9): for matroids M₁ M₂ : Matroid α and a finite set X : Set α, the supremum of I.encard over sets I ⊆ X independent in both matroids equals the infimum over U ⊆ X of M₁.eRk U + M₂.eRk (X \ U). Taking X to be the common finite ground set of M₁ and M₂ gives the source statement. The proof uses finiteness of X; infinite ground sets are not treated.