AFTD Auto-Formalizing Theoretical Domains

maximum_matching_forbids_two_edge_three_edge_exchange

theoremverified

A maximum matching forbids replacing two matching edges by two edges from distinct uncovered vertices and an edge joining the two remaining endpoints.

Statement

theorem maximum_matching_forbids_two_edge_three_edge_exchange
    {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 : ∀ T : G.Subgraph, T.IsMatching → T.verts ⊆ (S : Set V) → T.edgeSet.ncard ≤ M.edgeSet.ncard)
    (u v a b c d : V) (huS : u ∈ S) (hvS : v ∈ S)
    (hu : u ∉ M.verts) (hv : v ∉ M.verts) (huv : u ≠ v)
    (hab : M.Adj a b) (hcd : M.Adj c d)
    (hac : a ≠ c) (had : a ≠ d) (hbc : b ≠ c) (hbd : b ≠ d)
    (hua : G.Adj u a) (hvc : G.Adj v c) (hbdEdge : G.Adj b d) : False
Source
Maximum-matching exchange for OP-1957; https://arxiv.org/abs/1011.3384.
Verified
28 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 4
Used by 1

The proof, explained

The theorem proves that a maximum matching M supported on a vertex set S cannot admit an alternating path of length 5 of the form u - a - b - d - c - v, where ab and cd belong to M and u, v are distinct uncovered vertices in S. Deleting the two matching edges ab and cd produces a residual matching D of size |M| - 2 whose vertices are disjoint from {a, b, c, d}. Adding the three edges ua, vc, and bd yields a new matching D ⊔ E supported on S with |M| + 1 edges, which directly contradicts the maximality of M.

  1. The endpoints a, b, c, d belong to the matching M, with a ≠ b and c ≠ d.

    Because ab and cd are edges of the matching subgraph M, all four endpoints a, b, c, d belong to M.verts. Since G is a simple graph, adjacent vertices cannot be equal, so a ≠ b and c ≠ d.

    lines 11–18

      set_option maxHeartbeats 4000000 in
        classical
        have haM : a ∈ M.verts := M.edge_vert hab
        have hbM : b ∈ M.verts := M.edge_vert hab.symm
        have hcM : c ∈ M.verts := M.edge_vert hcd
        have hdM : d ∈ M.verts := M.edge_vert hcd.symm
        have habne : a ≠ b := G.ne_of_adj (M.adj_sub hab)
        have hcdne : c ≠ d := G.ne_of_adj (M.adj_sub hcd)
  2. The set T = {s(a, b), s(c, d)} consists of two distinct edges of M, so T ⊆ M.edgeSet.

    The pairs s(a, b) and s(c, d) belong to M.edgeSet by definition of subgraph adjacency. If they were equal as unordered pairs, then either a = c or a = d by Sym2.eq_iff.mp, contradicting the hypotheses hac and had. Thus the two edges are distinct, and both belong to M.edgeSet.

    lines 19–30

    uses SimpleGraph.Subgraph.mem_edgeSet.mpr, Sym2.eq_iff.mp, Set.mem_insert_iff, Set.mem_singleton_iff

        let T : Set (Sym2 V) := {s(a,b),s(c,d)}
        have he1 : s(a,b) ∈ M.edgeSet := SimpleGraph.Subgraph.mem_edgeSet.mpr hab
        have he2 : s(c,d) ∈ M.edgeSet := SimpleGraph.Subgraph.mem_edgeSet.mpr hcd
        have hene : s(a,b) ≠ s(c,d) := by
          intro he
          rcases Sym2.eq_iff.mp he with ⟨h,_⟩ | ⟨h,_⟩
          · exact hac h
          · exact had h
        have hTM : T ⊆ M.edgeSet := by
          intro e he
          simp only [T,Set.mem_insert_iff,Set.mem_singleton_iff] at he
          rcases he with rfl | rfl <;> assumption
  3. Deleting T from M yields a matching D disjoint from {a, b, c, d} with |D.edgeSet| + 2 = |M.edgeSet|.

    By residual_matching_num_single_edge_exchange_iff_critical_del, deleting the edges T from M leaves a matching D with edge set M.edgeSet \ T. Every vertex of D is incident to an edge of D ⊆ M, so D.verts ⊆ M.verts. If an endpoint p of an edge pq ∈ T were in D.verts, it would be matched to some z in D; by uniqueness of matching edges in M, z = q, implying pq ∈ D.edgeSet = M.edgeSet \ T, a contradiction. Thus none of a, b, c, d belong to D.verts. Since T contains two distinct edges of the finite set M.edgeSet, |D.edgeSet| + 2 = |M.edgeSet| by Set.ncard_sdiff_add_ncard_of_subset and Set.ncard_pair.

    lines 31–55

    uses residual_matching_num_single_edge_exchange_iff_critical_del, SimpleGraph.Subgraph.mem_edgeSet.mp, SimpleGraph.Subgraph.mem_edgeSet.mpr, Sym2.eq_swap, Set.ncard_pair, Set.ncard_sdiff_add_ncard_of_subset, Set.toFinite

        obtain ⟨D,hD,hDedge⟩ := residual_matching_num_single_edge_exchange_iff_critical_del hM T
        have hDsub : D.verts ⊆ M.verts := by
          intro x hx
          obtain ⟨y,hxy,_⟩ := hD hx
          have hh : s(x,y) ∈ D.edgeSet := SimpleGraph.Subgraph.mem_edgeSet.mpr hxy
          rw [hDedge] at hh
          exact M.edge_vert (SimpleGraph.Subgraph.mem_edgeSet.mp hh.1)
        have hnotD : ∀ p q, M.Adj p q → s(p,q) ∈ T → p ∉ D.verts := by
          intro p q hpq hpT hpD
          obtain ⟨z,hpz,_⟩ := hD hpD
          have hh : s(p,z) ∈ D.edgeSet := SimpleGraph.Subgraph.mem_edgeSet.mpr hpz
          rw [hDedge] at hh
          have hpzM : M.Adj p z := SimpleGraph.Subgraph.mem_edgeSet.mp hh.1
          have hz : z=q := (hM (M.edge_vert hpq)).unique hpzM hpq
          subst z
          exact hh.2 hpT
        have haD : a ∉ D.verts := hnotD a b hab (by simp [T])
        have hbD : b ∉ D.verts := hnotD b a hab.symm (by simp [T,Sym2.eq_swap])
        have hcD : c ∉ D.verts := hnotD c d hcd (by simp [T])
        have hdD : d ∉ D.verts := hnotD d c hcd.symm (by simp [T,Sym2.eq_swap])
        have hTcard : T.ncard = 2 := by simpa [T] using (Set.ncard_pair hene)
        have hcard : D.edgeSet.ncard + 2 = M.edgeSet.ncard := by
          have hh := Set.ncard_sdiff_add_ncard_of_subset hTM (Set.toFinite M.edgeSet)
          rw [← hDedge,hTcard] at hh
          exact hh
  4. The three edges ua, vc, bd form a matching E of size 3 with vertices {u, v, b, a, c, d}.

    We define two maps from Fin 3 to V by f = (u, v, b) and g = (a, c, d). Both maps are injective and their ranges are disjoint because u and v do not belong to M.verts while a, b, c, d do, and the hypotheses ensure no collisions among a, b, c, d. Furthermore, each pair (f(i), g(i)) is an edge of G (ua, vc, and bd). By indexed_disjoint_cross_edges_form_matching, these edges form a matching E of cardinality 3 whose vertex set is {u, v, b, a, c, d}.

    lines 56–70

    uses indexed_disjoint_cross_edges_form_matching

        let f : Fin 3 → V := ![u,v,b]
        let g : Fin 3 → V := ![a,c,d]
        have hf : Function.Injective f := by
          intro i j hij
          fin_cases i <;> fin_cases j <;> simp_all [f]
        have hg : Function.Injective g := by
          intro i j hij
          fin_cases i <;> fin_cases j <;> simp_all [g]
        have hfg : ∀ i j, f i ≠ g j := by
          intro i j heq
          fin_cases i <;> fin_cases j <;> simp_all [f,g]
        have hadj : ∀ i, G.Adj (f i) (g i) := by
          intro i
          fin_cases i <;> simp_all [f,g]
        obtain ⟨E,hE,hEcard,hEverts⟩ := indexed_disjoint_cross_edges_form_matching G 3 f g hf hg hfg hadj
  5. The vertex sets of D and E are disjoint.

    Any common vertex x would have to be in E.verts = {u, v, b, a, c, d}. But x ∈ D.verts ⊆ M.verts rules out u and v (which are not in M.verts), and none of a, b, c, d belong to D.verts as established earlier. Hence by Set.disjoint_left.mpr, D.verts and E.verts are disjoint.

    lines 71–78

    uses Set.disjoint_left.mpr

        have hDE : Disjoint D.verts E.verts := by
          apply Set.disjoint_left.mpr
          intro x hxD hxE
          rw [hEverts] at hxE
          rcases hxE with ⟨i,hi⟩ | ⟨i,hi⟩
          · have hxM := hDsub hxD
            fin_cases i <;> simp_all [f]
          · fin_cases i <;> simp_all [g]
  6. The union D ⊔ E is a matching on S with |M.edgeSet| + 1 edges, contradicting the maximality of M.

    By extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard, the union of the vertex-disjoint matchings D and E is a matching with |D.edgeSet| + 3 edges. Its vertices all lie in S because D.verts ⊆ M.verts ⊆ S, u, v ∈ S, and a, b, c, d ∈ M.verts ⊆ S. Maximality of M then implies |D.edgeSet| + 3 ≤ |M.edgeSet|. Combined with |D.edgeSet| + 2 = |M.edgeSet|, this yields |M.edgeSet| + 1 ≤ |M.edgeSet|, an impossibility that omega refutes.

    lines 79–95

    uses extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard

        have hsup := extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard D E hD hE hDE
        have hsub : (D ⊔ E).verts ⊆ (S : Set V) := by
          intro x hx
          change x ∈ D.verts ∪ E.verts at hx
          rcases hx with hxD | hxE
          · exact hMS (hDsub hxD)
          · rw [hEverts] at hxE
            have haS := hMS haM
            have hbS := hMS hbM
            have hcS := hMS hcM
            have hdS := hMS hdM
            rcases hxE with ⟨i,hi⟩ | ⟨i,hi⟩
            · fin_cases i <;> simp_all [f]
            · fin_cases i <;> simp_all [g]
        have hh := hmax (D ⊔ E) hsup.1 hsub
        rw [hsup.2,hEcard] at hh
        omega
SimpleGraph.Subgraph.mem_edgeSet.mpr
An adjacency between two vertices in a subgraph implies that the unordered pair of those vertices belongs to the subgraph's edge set.
Sym2.eq_iff.mp
Two unordered pairs s(a, b) and s(c, d) are equal only if either (a = c and b = d) or (a = d and b = c).
Set.mem_insert_iff
An element x belongs to {a} ∪ s if and only if x = a or x ∈ s.
Set.mem_singleton_iff
An element x belongs to the singleton set {b} if and only if x = b.
residual_matching_num_single_edge_exchange_iff_critical_del
For any matching N and any edge set T, deleting T leaves a matching N' with edge set N.edgeSet \ T.
SimpleGraph.Subgraph.mem_edgeSet.mp
If an unordered pair of vertices belongs to a subgraph's edge set, then those two vertices are adjacent in the subgraph.
Sym2.eq_swap
The unordered pair s(a, b) equals s(b, a).
Set.ncard_pair
If a ≠ b, the unordered pair set {a, b} has cardinality 2.
Set.ncard_sdiff_add_ncard_of_subset
If s ⊆ t and t is finite, then |t \ s| + |s| = |t|.
Set.toFinite
A set whose subtype is finite is a finite set.
indexed_disjoint_cross_edges_form_matching
If f, g : Fin r → V are injective with disjoint ranges and f(i) is adjacent to g(i) for all i, then the r edges between f(i) and g(i) form a matching of size r with vertices range(f) ∪ range(g).
Set.disjoint_left.mpr
Two sets s and t are disjoint if no element of s belongs to t.
extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard
The union of two vertex-disjoint matchings is a matching whose edge count is the sum of their 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_forbids_two_edge_three_edge_exchange    {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 : ∀ T : G.Subgraph, T.IsMatching → T.verts ⊆ (S : Set V) → T.edgeSet.ncard ≤ M.edgeSet.ncard)    (u v a b c d : V) (huS : u ∈ S) (hvS : v ∈ S)    (hu : u ∉ M.verts) (hv : v ∉ M.verts) (huv : u ≠ v)    (hab : M.Adj a b) (hcd : M.Adj c d)    (hac : a ≠ c) (had : a ≠ d) (hbc : b ≠ c) (hbd : b ≠ d)    (hua : G.Adj u a) (hvc : G.Adj v c) (hbdEdge : G.Adj b d) : False := by  set_option maxHeartbeats 4000000 in    classical    have haM : a ∈ M.verts := M.edge_vert hab    have hbM : b ∈ M.verts := M.edge_vert hab.symm    have hcM : c ∈ M.verts := M.edge_vert hcd    have hdM : d ∈ M.verts := M.edge_vert hcd.symm    have habne : a ≠ b := G.ne_of_adj (M.adj_sub hab)    have hcdne : c ≠ d := G.ne_of_adj (M.adj_sub hcd)    let T : Set (Sym2 V) := {s(a,b),s(c,d)}    have he1 : s(a,b) ∈ M.edgeSet := SimpleGraph.Subgraph.mem_edgeSet.mpr hab    have he2 : s(c,d) ∈ M.edgeSet := SimpleGraph.Subgraph.mem_edgeSet.mpr hcd    have hene : s(a,b) ≠ s(c,d) := by      intro he      rcases Sym2.eq_iff.mp he with ⟨h,_⟩ | ⟨h,_⟩      · exact hac h      · exact had h    have hTM : T ⊆ M.edgeSet := by      intro e he      simp only [T,Set.mem_insert_iff,Set.mem_singleton_iff] at he      rcases he with rfl | rfl <;> assumption    obtain ⟨D,hD,hDedge⟩ := residual_matching_num_single_edge_exchange_iff_critical_del hM T    have hDsub : D.verts ⊆ M.verts := by      intro x hx      obtain ⟨y,hxy,_⟩ := hD hx      have hh : s(x,y) ∈ D.edgeSet := SimpleGraph.Subgraph.mem_edgeSet.mpr hxy      rw [hDedge] at hh      exact M.edge_vert (SimpleGraph.Subgraph.mem_edgeSet.mp hh.1)    have hnotD : ∀ p q, M.Adj p q → s(p,q) ∈ T → p ∉ D.verts := by      intro p q hpq hpT hpD      obtain ⟨z,hpz,_⟩ := hD hpD      have hh : s(p,z) ∈ D.edgeSet := SimpleGraph.Subgraph.mem_edgeSet.mpr hpz      rw [hDedge] at hh      have hpzM : M.Adj p z := SimpleGraph.Subgraph.mem_edgeSet.mp hh.1      have hz : z=q := (hM (M.edge_vert hpq)).unique hpzM hpq      subst z      exact hh.2 hpT    have haD : a ∉ D.verts := hnotD a b hab (by simp [T])    have hbD : b ∉ D.verts := hnotD b a hab.symm (by simp [T,Sym2.eq_swap])    have hcD : c ∉ D.verts := hnotD c d hcd (by simp [T])    have hdD : d ∉ D.verts := hnotD d c hcd.symm (by simp [T,Sym2.eq_swap])    have hTcard : T.ncard = 2 := by simpa [T] using (Set.ncard_pair hene)    have hcard : D.edgeSet.ncard + 2 = M.edgeSet.ncard := by      have hh := Set.ncard_sdiff_add_ncard_of_subset hTM (Set.toFinite M.edgeSet)      rw [← hDedge,hTcard] at hh      exact hh    let f : Fin 3 → V := ![u,v,b]    let g : Fin 3 → V := ![a,c,d]    have hf : Function.Injective f := by      intro i j hij      fin_cases i <;> fin_cases j <;> simp_all [f]    have hg : Function.Injective g := by      intro i j hij      fin_cases i <;> fin_cases j <;> simp_all [g]    have hfg : ∀ i j, f i ≠ g j := by      intro i j heq      fin_cases i <;> fin_cases j <;> simp_all [f,g]    have hadj : ∀ i, G.Adj (f i) (g i) := by      intro i      fin_cases i <;> simp_all [f,g]    obtain ⟨E,hE,hEcard,hEverts⟩ := indexed_disjoint_cross_edges_form_matching G 3 f g hf hg hfg hadj    have hDE : Disjoint D.verts E.verts := by      apply Set.disjoint_left.mpr      intro x hxD hxE      rw [hEverts] at hxE      rcases hxE with ⟨i,hi⟩ | ⟨i,hi⟩      · have hxM := hDsub hxD        fin_cases i <;> simp_all [f]      · fin_cases i <;> simp_all [g]    have hsup := extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard D E hD hE hDE    have hsub : (D ⊔ E).verts ⊆ (S : Set V) := by      intro x hx      change x ∈ D.verts ∪ E.verts at hx      rcases hx with hxD | hxE      · exact hMS (hDsub hxD)      · rw [hEverts] at hxE        have haS := hMS haM        have hbS := hMS hbM        have hcS := hMS hcM        have hdS := hMS hdM        rcases hxE with ⟨i,hi⟩ | ⟨i,hi⟩        · fin_cases i <;> simp_all [f]        · fin_cases i <;> simp_all [g]    have hh := hmax (D ⊔ E) hsup.1 hsub    rw [hsup.2,hEcard] at hh    omega
See it in the graphDiscuss this resultChallenge it