AFTD Auto-Formalizing Theoretical Domains

maximum_matching_size_from_independence

theoremverified

A maximum matching inside S covers enough vertices that |S| is at most twice its edge count plus the independence bound.

Statement

theorem maximum_matching_size_from_independence
    {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)
    (a : ℕ) (hind : ∀ U : Finset V,
      (∀ u ∈ U, ∀ v ∈ U, u ≠ v → ¬ G.Adj u v) → U.card ≤ a) :
    S.card ≤ 2*M.edgeSet.ncard+a
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 partitions S into the vertices D covered by the matching M and the remaining unmatched vertices U = S \ D. Because M is a matching, the number of covered vertices |D| equals twice the number of edges in M. By the maximality of M inside S, no two vertices in U can be adjacent, so U is an independent set and has size at most a. Decomposing |S| into |D| + |U| then yields |S| ≤ 2 * |M.edgeSet| + a.

  1. The vertex set S is partitioned into the set D of vertices matched by M and the set U = S \ D of unmatched vertices, with D ⊆ S.

    Under classical logic, D is defined as the vertices of the subgraph M (as a Finset) and U as the complement S \ D. Since M has all its vertices in S (by hypothesis hMS), every vertex in D belongs to S, establishing D ⊆ S.

    lines 9–13

      set_option maxHeartbeats 4000000 in
        classical
        let D : Finset V := M.verts.toFinset
        let U : Finset V := S \ D
        have hDS : D ⊆ S := by intro v hv; exact hMS (by simpa [D] using hv)
  2. The number of matched vertices |D| is twice the number of edges in M.

    The cardinality of D as a Finset is converted to the set cardinality of M.verts via Set.ncard_eq_toFinset_card'. Since M is a matching, in1076_matching_twice_card proves that the number of matched vertices is exactly twice the number of edges.

    lines 14–17

    uses Set.ncard_eq_toFinset_card', in1076_matching_twice_card

        have hDcard : D.card = 2*M.edgeSet.ncard := by
          dsimp [D]
          rw [← Set.ncard_eq_toFinset_card']
          exact (in1076_matching_twice_card hM).symm
  3. The set of unmatched vertices U is an independent set in G.

    Given any two distinct vertices u, v ∈ U, unpacking the set difference with Finset.mem_sdiff.mp shows that both belong to S but neither belongs to D (i.e., neither is covered by M). Because M is a maximum matching inside S, maximum_matching_unmatched_independent implies that u and v cannot be adjacent, since otherwise adding the edge uv would yield a larger matching in S.

    lines 18–24

    uses Finset.mem_sdiff.mp, maximum_matching_unmatched_independent

        have hUind : ∀ u ∈ U, ∀ v ∈ U, u ≠ v → ¬ G.Adj u v := by
          intro u hu v hv hne
          have hu' := Finset.mem_sdiff.mp hu
          have hv' := Finset.mem_sdiff.mp hv
          apply maximum_matching_unmatched_independent G S M hM hMS hmax u hu'.1 ?_ v hv'.1 ?_
          · simpa [D] using hu'.2
          · simpa [D] using hv'.2
  4. |S| ≤ 2 * |M.edgeSet| + a. automation

    Because U is an independent set, the hypothesis hind guarantees |U| ≤ a. Furthermore, because D ⊆ S, the set S decomposes into the disjoint union of S \ D and D, so |S \ D| + |D| = |S| by Finset.card_sdiff_add_card_eq_card. Combining this partition formula with |D| = 2 * |M.edgeSet| and |S \ D| ≤ a, the linear arithmetic tactic omega closes the inequality.

    lines 25–28

    uses Finset.card_sdiff_add_card_eq_card

        have hU := hind U hUind
        have hcount := Finset.card_sdiff_add_card_eq_card hDS
        dsimp [U] at hU
        omega
Set.ncard_eq_toFinset_card'
For any finite set, its set cardinality (ncard) equals the cardinality of its Finset representation.
in1076_matching_twice_card
The number of vertices in a matching is twice the number of edges.
Finset.mem_sdiff.mp
An element is in the set difference s \ t if and only if it is in s and not in t.
maximum_matching_unmatched_independent
In a maximum matching inside S, any two distinct vertices in S that are not covered by the matching are not adjacent.
Finset.card_sdiff_add_card_eq_card
If s ⊆ t, then |t \ s| + |s| = |t|.

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_size_from_independence    {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)    (a : ℕ) (hind : ∀ U : Finset V,      (∀ u ∈ U, ∀ v ∈ U, u ≠ v → ¬ G.Adj u v) → U.card ≤ a) :    S.card ≤ 2*M.edgeSet.ncard+a := by  set_option maxHeartbeats 4000000 in    classical    let D : Finset V := M.verts.toFinset    let U : Finset V := S \ D    have hDS : D ⊆ S := by intro v hv; exact hMS (by simpa [D] using hv)    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 hUind : ∀ u ∈ U, ∀ v ∈ U, u ≠ v → ¬ G.Adj u v := by      intro u hu v hv hne      have hu' := Finset.mem_sdiff.mp hu      have hv' := Finset.mem_sdiff.mp hv      apply maximum_matching_unmatched_independent G S M hM hMS hmax u hu'.1 ?_ v hv'.1 ?_      · simpa [D] using hu'.2      · simpa [D] using hv'.2    have hU := hind U hUind    have hcount := Finset.card_sdiff_add_card_eq_card hDS    dsimp [U] at hU    omega
See it in the graphDiscuss this resultChallenge it