AFTD Auto-Formalizing Theoretical Domains

op1957_min_degree_forces_matching

theoremverified

A finite graph on at least 2k vertices with minimum degree at least k has a matching of k edges.

Statement

theorem op1957_min_degree_forces_matching
    {V : Type*} [Fintype V] [DecidableEq V]
    (G : SimpleGraph V) [DecidableRel G.Adj] (k : ℕ)
    (hsize : 2*k ≤ Fintype.card V)
    (hdegree : ∀ v, k ≤ (G.neighborFinset v).card) :
    ∃ M : G.Subgraph, M.IsMatching ∧ M.edgeSet.ncard = k
Source
OP-1957: matching bound needed for independence reduction
Verified
29 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 5
Used by 3

The proof, explained

The proof proceeds by contradiction using a counting argument on a maximum matching M. If M had fewer than k edges, then since |V| ≥ 2k there would be at least two unmatched vertices u and v, whose neighbors must all be matched. The set P of matching partners of u's neighbors and the neighborhood Q of v must be disjoint subsets of the matched vertices, because any common vertex would allow an augmenting exchange of one matched edge for two edges. But then the matched vertices must contain at least |P| + |Q| = deg(u) + deg(v) ≥ 2k vertices, contradicting that M has fewer than k edges; finally, a matching of size k is obtained as a submatching of M.

  1. Let M be a maximum matching of G.

    By finite_subset_has_maximum_matching on the universal vertex set, there exists a matching M of G that has maximal cardinality among all matchings.

    lines 7–8

    uses finite_subset_has_maximum_matching

      classical
      obtain ⟨M,hM,hMS,hmax⟩ := finite_subset_has_maximum_matching G Finset.univ
  2. If M has fewer than k edges, the set U of unmatched vertices contains at least two vertices.

    Suppose for contradiction that |M| < k. Let D be the set of vertices covered by M, and let U = V \ D be the set of unmatched vertices. Because M is a matching, |D| = 2|M| by in1076_matching_twice_card. Since D and U partition V, |U| + |D| = |V|. Given |V| ≥ 2k and |M| ≤ k - 1, linear integer arithmetic (via omega) yields |U| = |V| - 2|M| ≥ 2k - 2(k - 1) = 2, so |U| > 1.

    lines 9–20

    uses Set.ncard_eq_toFinset_card', in1076_matching_twice_card, Finset.card_sdiff_add_card_eq_card, Finset.subset_univ

      have hlarge : k ≤ M.edgeSet.ncard := by
        by_contra hn
        let D : Finset V := M.verts.toFinset
        let U : Finset V := Finset.univ \ D
        have hDcard : D.card = 2*M.edgeSet.ncard := by
          dsimp [D]
          rw [← Set.ncard_eq_toFinset_card']
          exact (in1076_matching_twice_card hM).symm
        have hUcard : U.card + D.card = Fintype.card V := by
          have h := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ D)
          simpa [U] using h
        have hUtwo : 1 < U.card := by omega
  3. There exist two distinct unmatched vertices u and v.

    Because |U| > 1, Finset.one_lt_card.mp gives two distinct vertices u, v ∈ U. By definition of U, neither u nor v is covered by M.

    lines 21–23

    uses Finset.one_lt_card.mp

        obtain ⟨u,hu,v,hv,huv⟩ := Finset.one_lt_card.mp hUtwo
        have huM : u ∉ M.verts := by simpa [U,D] using hu
        have hvM : v ∉ M.verts := by simpa [U,D] using hv
  4. All neighbors of any unmatched vertex belong to the matched set D.

    If an unmatched vertex w had a neighbor a ∉ D, then both w and a would be unmatched. But maximum_matching_unmatched_independent implies unmatched vertices form an independent set in any maximum matching, a contradiction.

    lines 24–30

    uses maximum_matching_unmatched_independent, Finset.mem_univ

        have hNsub : ∀ w ∈ U, G.neighborFinset w ⊆ D := by
          intro w hw a ha
          have hwM : w ∉ M.verts := by simpa [U,D] using hw
          by_contra haD
          have haM : a ∉ M.verts := by simpa [D] using haD
          exact maximum_matching_unmatched_independent G Finset.univ M hM hMS hmax
            w (Finset.mem_univ _) hwM a (Finset.mem_univ _) haM (by simpa using ha)
  5. The matching involution f pairs each vertex of D with its match in M and is injective on D.

    Define f : V → V to send each vertex in M to its unique partner in M (via Classical.choose and Classical.choose_spec), and to act as the identity outside M. Then every x ∈ D is matched to f(x) ∈ D. Since vertices in a matching have degree 1, f(f(x)) = x for all x ∈ D. Applying f to both sides of f(x) = f(y) via congrArg thus shows f is injective on D.

    lines 31–49

    uses Classical.choose, Classical.choose_spec, congrArg

        let f : V → V := fun x => if hx : x ∈ M.verts then Classical.choose (hM hx) else x
        have hf : ∀ x ∈ D, M.Adj x (f x) := by
          intro x hx
          have hxM : x ∈ M.verts := by simpa [D] using hx
          simpa [f,hxM] using (Classical.choose_spec (hM hxM)).1
        have hfD : ∀ x ∈ D, f x ∈ D := by
          intro x hx
          have hh := M.edge_vert (hf x hx).symm
          simpa [D] using hh
        have hfinv : ∀ x ∈ D, f (f x) = x := by
          intro x hx
          have hfxD := hfD x hx
          exact (hM (by simpa [D] using hfxD)).unique (hf (f x) hfxD) (hf x hx).symm
        have hfinj : Set.InjOn f (D : Set V) := by
          intro x hx y hy hxy
          calc
            x = f (f x) := (hfinv x hx).symm
            _ = f (f y) := congrArg f hxy
            _ = y := hfinv y hy
  6. The set P = f(N(u)) is a subset of D with |P| = deg(u), and Q = N(v) is also a subset of D.

    Since u is unmatched, all its neighbors lie in D, so their partners P = f(N(u)) also lie in D. Because f is injective on D, Finset.card_image_iff.mpr shows |P| = |N(u)| = deg(u). Similarly, Q = N(v) ⊆ D because v is unmatched.

    lines 50–60

    uses Finset.mem_image.mp, Finset.card_image_iff.mpr

        let P := (G.neighborFinset u).image f
        let Q := G.neighborFinset v
        have hPsub : P ⊆ D := by
          intro a ha
          obtain ⟨b,hb,rfl⟩ := Finset.mem_image.mp ha
          exact hfD b (hNsub u hu hb)
        have hQsub : Q ⊆ D := hNsub v hv
        have hPcard : P.card = (G.neighborFinset u).card := by
          dsimp [P]
          apply Finset.card_image_iff.mpr
          exact hfinj.mono (by intro x hx; exact hNsub u hu hx)
  7. The sets P and Q are disjoint.

    Suppose there were a vertex a ∈ P ∩ Q. Then a is a neighbor of v (since a ∈ Q), and a = f(b) for some neighbor b of u (since a ∈ P), so ab is an edge of M. Exchanging the edge ab for the edges ub and va would yield a matching with one more edge, which contradicts the maximality of M via maximum_matching_forbids_one_edge_two_uncovered_exchange.

    lines 61–68

    uses Finset.disjoint_left.mpr, Finset.mem_image.mp, maximum_matching_forbids_one_edge_two_uncovered_exchange, Finset.mem_univ

        have hdis : Disjoint P Q := by
          apply Finset.disjoint_left.mpr
          intro a ha hq
          obtain ⟨b,hb,hba⟩ := Finset.mem_image.mp ha
          have hbD := hNsub u hu hb
          have hmb : M.Adj b a := by simpa [← hba] using hf b hbD
          exact maximum_matching_forbids_one_edge_two_uncovered_exchange G Finset.univ M hM hMS hmax
            u v b a (Finset.mem_univ _) (Finset.mem_univ _) huM hvM huv hmb (by simpa using hb) (by simpa [Q] using hq)
  8. The maximum matching M has at least k edges.

    Since P and Q are disjoint subsets of D, their union has size |P| + |Q| ≤ |D|. By the minimum degree condition, |P| = deg(u) ≥ k and |Q| = deg(v) ≥ k, so 2k ≤ deg(u) + deg(v) ≤ |D| = 2|M|. This contradicts the assumption |M| < k, so k ≤ |M|.

    lines 69–75

    uses Finset.card_le_card, Finset.union_subset, Finset.card_union_of_disjoint

        have hbound := Finset.card_le_card (Finset.union_subset hPsub hQsub)
        rw [Finset.card_union_of_disjoint hdis,hPcard] at hbound
        have hdu := hdegree u
        have hdv := hdegree v
        dsimp [Q] at hbound
        change (G.neighborFinset u).card + (G.neighborFinset v).card ≤ D.card at hbound
        omega
  9. There exists a matching of G with exactly k edges.

    Since M is a matching with at least k edges, finite_matching_has_submatching_of_each_smaller_size provides a submatching N ⊆ M with exactly k edges.

    lines 76–77

    uses finite_matching_has_submatching_of_each_smaller_size

      obtain ⟨N,hN,_,hNk⟩ := finite_matching_has_submatching_of_each_smaller_size G M hM k hlarge
      exact ⟨N,hN,hNk⟩
finite_subset_has_maximum_matching
Every subset of vertices in a finite graph has a maximum matching.
Set.ncard_eq_toFinset_card'
The set cardinality (ncard) of a set is equal to the card of its conversion to a finset.
in1076_matching_twice_card
The number of vertices in a matching is twice the number of its edges.
Finset.card_sdiff_add_card_eq_card
For finite sets with s ⊆ t, the size of the difference (t \ s) plus the size of s equals the size of t.
Finset.subset_univ
Every finite set of elements of type α is a subset of the universal finset on α.
Finset.one_lt_card.mp
A finite set with cardinality strictly greater than 1 contains at least two distinct elements.
maximum_matching_unmatched_independent
In a graph with a maximum matching, no two unmatched vertices can be adjacent.
Finset.mem_univ
Every element of a finite type belongs to its universal finset.
Classical.choose
Given a proof of existence, chooses a witness satisfying the predicate.
Classical.choose_spec
The witness obtained from Classical.choose satisfies the specified predicate.
congrArg
If two inputs to a function are equal, their images are equal.
Finset.mem_image.mp
An element belongs to the image of a finset under f if and only if it is the image of some element in that finset.
Finset.card_image_iff.mpr
If a function is injective on a finite set, the cardinality of its image is equal to the cardinality of the original set.
Finset.disjoint_left.mpr
Two finite sets are disjoint if no element of the first belongs to the second.
maximum_matching_forbids_one_edge_two_uncovered_exchange
In a maximum matching, there cannot be two distinct unmatched vertices adjacent respectively to the two endpoints of a matched edge.
Finset.card_le_card
If s ⊆ t, then |s| ≤ |t|.
Finset.union_subset
If s ⊆ u and t ⊆ u, then s ∪ t ⊆ u.
Finset.card_union_of_disjoint
The cardinality of the union of two disjoint finite sets is the sum of their cardinalities.
finite_matching_has_submatching_of_each_smaller_size
A matching with at least k edges contains a submatching with exactly k edges.

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 op1957_min_degree_forces_matching    {V : Type*} [Fintype V] [DecidableEq V]    (G : SimpleGraph V) [DecidableRel G.Adj] (k : ℕ)    (hsize : 2*k ≤ Fintype.card V)    (hdegree : ∀ v, k ≤ (G.neighborFinset v).card) :    ∃ M : G.Subgraph, M.IsMatching ∧ M.edgeSet.ncard = k := by  classical  obtain ⟨M,hM,hMS,hmax⟩ := finite_subset_has_maximum_matching G Finset.univ  have hlarge : k ≤ M.edgeSet.ncard := by    by_contra hn    let D : Finset V := M.verts.toFinset    let U : Finset V := Finset.univ \ D    have hDcard : D.card = 2*M.edgeSet.ncard := by      dsimp [D]      rw [← Set.ncard_eq_toFinset_card']      exact (in1076_matching_twice_card hM).symm    have hUcard : U.card + D.card = Fintype.card V := by      have h := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ D)      simpa [U] using h    have hUtwo : 1 < U.card := by omega    obtain ⟨u,hu,v,hv,huv⟩ := Finset.one_lt_card.mp hUtwo    have huM : u ∉ M.verts := by simpa [U,D] using hu    have hvM : v ∉ M.verts := by simpa [U,D] using hv    have hNsub : ∀ w ∈ U, G.neighborFinset w ⊆ D := by      intro w hw a ha      have hwM : w ∉ M.verts := by simpa [U,D] using hw      by_contra haD      have haM : a ∉ M.verts := by simpa [D] using haD      exact maximum_matching_unmatched_independent G Finset.univ M hM hMS hmax        w (Finset.mem_univ _) hwM a (Finset.mem_univ _) haM (by simpa using ha)    let f : V → V := fun x => if hx : x ∈ M.verts then Classical.choose (hM hx) else x    have hf : ∀ x ∈ D, M.Adj x (f x) := by      intro x hx      have hxM : x ∈ M.verts := by simpa [D] using hx      simpa [f,hxM] using (Classical.choose_spec (hM hxM)).1    have hfD : ∀ x ∈ D, f x ∈ D := by      intro x hx      have hh := M.edge_vert (hf x hx).symm      simpa [D] using hh    have hfinv : ∀ x ∈ D, f (f x) = x := by      intro x hx      have hfxD := hfD x hx      exact (hM (by simpa [D] using hfxD)).unique (hf (f x) hfxD) (hf x hx).symm    have hfinj : Set.InjOn f (D : Set V) := by      intro x hx y hy hxy      calc        x = f (f x) := (hfinv x hx).symm        _ = f (f y) := congrArg f hxy        _ = y := hfinv y hy    let P := (G.neighborFinset u).image f    let Q := G.neighborFinset v    have hPsub : P ⊆ D := by      intro a ha      obtain ⟨b,hb,rfl⟩ := Finset.mem_image.mp ha      exact hfD b (hNsub u hu hb)    have hQsub : Q ⊆ D := hNsub v hv    have hPcard : P.card = (G.neighborFinset u).card := by      dsimp [P]      apply Finset.card_image_iff.mpr      exact hfinj.mono (by intro x hx; exact hNsub u hu hx)    have hdis : Disjoint P Q := by      apply Finset.disjoint_left.mpr      intro a ha hq      obtain ⟨b,hb,hba⟩ := Finset.mem_image.mp ha      have hbD := hNsub u hu hb      have hmb : M.Adj b a := by simpa [← hba] using hf b hbD      exact maximum_matching_forbids_one_edge_two_uncovered_exchange G Finset.univ M hM hMS hmax        u v b a (Finset.mem_univ _) (Finset.mem_univ _) huM hvM huv hmb (by simpa using hb) (by simpa [Q] using hq)    have hbound := Finset.card_le_card (Finset.union_subset hPsub hQsub)    rw [Finset.card_union_of_disjoint hdis,hPcard] at hbound    have hdu := hdegree u    have hdv := hdegree v    dsimp [Q] at hbound    change (G.neighborFinset u).card + (G.neighborFinset v).card ≤ D.card at hbound    omega  obtain ⟨N,hN,_,hNk⟩ := finite_matching_has_submatching_of_each_smaller_size G M hM k hlarge  exact ⟨N,hN,hNk⟩
See it in the graphDiscuss this resultChallenge it