AFTD Auto-Formalizing Theoretical Domains

maximum_matching_unmatched_independent

theoremverified

The vertices left uncovered by a maximum matching inside a vertex set form an independent set.

Statement

theorem maximum_matching_unmatched_independent
    {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)
    (S : Finset V) (M : G.Subgraph) (hM : M.IsMatching)
    (hMS : M.verts ⊆ (S : Set V))
    (hmax : ∀ N : G.Subgraph, N.IsMatching → N.verts ⊆ (S : Set V) → N.edgeSet.ncard ≤ M.edgeSet.ncard) :
    ∀ u ∈ S, u ∉ M.verts → ∀ v ∈ S, v ∉ M.verts → ¬ G.Adj u v
Source
Balanced-cut matching symmetry for OP-1957; https://arxiv.org/abs/2611.22690.
Verified
26 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 2
Used by 4

The proof, explained

The proof proceeds by contradiction. If two vertices $u, v \in S$ not covered by $M$ were adjacent, the edge $\{u, v\}$ would form a 1-edge matching disjoint from $M$. Adding this edge to $M$ yields a matching with vertices in $S$ and strictly more edges than $M$, contradicting the maximality of $M$.

  1. Assume for contradiction that there are two adjacent vertices in $S$ left unmatched by $M$.

    We introduce two vertices $u, v \in S$ not covered by $M$ (hypotheses `huM` and `hvM`), and assume for contradiction that they are connected by an edge in $G$ (`huv`).

    lines 7–9

      set_option maxHeartbeats 4000000 in
        classical
        intro u hu huM v hv hvM huv
  2. The edge $\{u, v\}$ forms a 1-edge matching $E$ with vertex set $\{u, v\}$.

    We define functions $f, g : \mathrm{Fin}\ 1 \to V$ sending the unique index to $u$ and $v$ respectively. Since $\mathrm{Fin}\ 1$ has only one element, both maps are injective by `Subsingleton.elim`. Since $u$ and $v$ are adjacent, they are distinct by `G.ne_of_adj`. Applying `indexed_disjoint_cross_edges_form_matching` with $r = 1$ gives a matching $E$ with 1 edge whose vertices are $\{u, v\}$.

    lines 10–15

    uses Subsingleton.elim, G.ne_of_adj, indexed_disjoint_cross_edges_form_matching

        let f : Fin 1 → V := fun _ => u
        let g : Fin 1 → V := fun _ => v
        have hf : Function.Injective f := by intro a b h; exact Subsingleton.elim a b
        have hg : Function.Injective g := by intro a b h; exact Subsingleton.elim a b
        have hfg : ∀ a b, f a ≠ g b := by intro a b; exact G.ne_of_adj huv
        obtain ⟨E,hE,hEcard,hEverts⟩ := indexed_disjoint_cross_edges_form_matching G 1 f g hf hg hfg (by intro a; exact huv)
  3. The vertex sets of $M$ and $E$ are disjoint.

    By `Set.disjoint_left.mpr`, it suffices to show no vertex in $M$ belongs to $E$. The vertices of $E$ are $\{u, v\}$, but neither $u$ nor $v$ belongs to $M$ by hypothesis, yielding a contradiction in either case.

    lines 16–22

    uses Set.disjoint_left.mpr

        have hdis : Disjoint M.verts E.verts := by
          apply Set.disjoint_left.mpr
          intro x hxM hxE
          rw [hEverts] at hxE
          rcases hxE with ⟨i,hi⟩ | ⟨i,hi⟩
          · exact huM (by simpa [f,hi] using hxM)
          · exact hvM (by simpa [g,hi] using hxM)
  4. The union $M \sqcup E$ is a matching with $|M| + 1$ edges.

    Since $M$ and $E$ are both matchings and have disjoint vertex sets, `extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard` proves that their union $M \sqcup E$ is also a matching with edge count $|M| + |E| = |M| + 1$.

    line 23

    uses extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard

        have hsup := extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard M E hM hE hdis
  5. The vertices of $M \sqcup E$ are contained in $S$.

    Every vertex of $M \sqcup E$ is either in $M$ or in $E$. Vertices of $M$ are in $S$ by assumption `hMS`, and the vertices of $E$ are $u$ and $v$, which both belong to $S$.

    lines 24–32

        have hsub : (M ⊔ E).verts ⊆ (S : Set V) := by
          intro x hx
          change x ∈ M.verts ∪ E.verts at hx
          rcases hx with hxM | hxE
          · exact hMS hxM
          · rw [hEverts] at hxE
            rcases hxE with ⟨i,hi⟩ | ⟨i,hi⟩
            · simpa [f,hi] using hu
            · simpa [g,hi] using hv
  6. A contradiction arises from the maximality of $M$. automation

    Applying the maximality hypothesis `hmax` to $M \sqcup E$ gives $|M \sqcup E| \le |M|$. Substituting the cardinalities gives $|M| + 1 \le |M|$, which `omega` refutes by integer arithmetic.

    lines 33–35

        have hbound := hmax (M ⊔ E) hsup.1 hsub
        rw [hsup.2,hEcard] at hbound
        omega
Subsingleton.elim
Two elements of a subsingleton type (such as `Fin 1`) are always equal.
G.ne_of_adj
Adjacent vertices in a simple graph are not equal.
indexed_disjoint_cross_edges_form_matching
A family of edges indexed by an injection from `Fin r` with disjoint endpoints forms a matching with $r$ edges whose vertex set is the union of the endpoints.
Set.disjoint_left.mpr
Two sets are disjoint if no element of the first set is in the second set.
extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard
The union of two vertex-disjoint matchings is a matching, and its edge count is the sum of the two edge counts.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

theorem maximum_matching_unmatched_independent    {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)    (S : Finset V) (M : G.Subgraph) (hM : M.IsMatching)    (hMS : M.verts ⊆ (S : Set V))    (hmax : ∀ N : G.Subgraph, N.IsMatching → N.verts ⊆ (S : Set V) → N.edgeSet.ncard ≤ M.edgeSet.ncard) :    ∀ u ∈ S, u ∉ M.verts → ∀ v ∈ S, v ∉ M.verts → ¬ G.Adj u v := by  set_option maxHeartbeats 4000000 in    classical    intro u hu huM v hv hvM huv    let f : Fin 1 → V := fun _ => u    let g : Fin 1 → V := fun _ => v    have hf : Function.Injective f := by intro a b h; exact Subsingleton.elim a b    have hg : Function.Injective g := by intro a b h; exact Subsingleton.elim a b    have hfg : ∀ a b, f a ≠ g b := by intro a b; exact G.ne_of_adj huv    obtain ⟨E,hE,hEcard,hEverts⟩ := indexed_disjoint_cross_edges_form_matching G 1 f g hf hg hfg (by intro a; exact huv)    have hdis : Disjoint M.verts E.verts := by      apply Set.disjoint_left.mpr      intro x hxM hxE      rw [hEverts] at hxE      rcases hxE with ⟨i,hi⟩ | ⟨i,hi⟩      · exact huM (by simpa [f,hi] using hxM)      · exact hvM (by simpa [g,hi] using hxM)    have hsup := extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard M E hM hE hdis    have hsub : (M ⊔ E).verts ⊆ (S : Set V) := by      intro x hx      change x ∈ M.verts ∪ E.verts at hx      rcases hx with hxM | hxE      · exact hMS hxM      · rw [hEverts] at hxE        rcases hxE with ⟨i,hi⟩ | ⟨i,hi⟩        · simpa [f,hi] using hu        · simpa [g,hi] using hv    have hbound := hmax (M ⊔ E) hsup.1 hsub    rw [hsup.2,hEcard] at hbound    omega
See it in the graphDiscuss this resultChallenge it