AFTD Auto-Formalizing Theoretical Domains

perfect_matching_balanced_cut_internal_edge_counts_equal

theoremverified

A perfect matching has equally many internal edges on each side of a balanced partition.

Statement

theorem perfect_matching_balanced_cut_internal_edge_counts_equal
    {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)
    (P : G.Subgraph) (hP : P.IsPerfectMatching)
    (C : Finset V) (hcard : 2*C.card = Fintype.card V) :
    (P.induce (C : Set V)).edgeSet.ncard =
      (P.induce ((C : Set V)ᶜ)).edgeSet.ncard
Source
Balanced-cut structural reduction for OP-1957; https://arxiv.org/abs/2611.22690.
Verified
26 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
Used by 2

The proof, explained

To show that a perfect matching has the same number of internal edges on both sides of a balanced partition C and Cᶜ, we relate the internal edge count of any vertex set to the number of vertices whose partner lies on the same side. The matching defines an involution on V, which provides a bijection between vertices in C matched across the cut and vertices in Cᶜ matched across the cut, showing that the cut contains equal numbers of endpoints on both sides. Because the partition is balanced (|C| = |Cᶜ|), subtracting these equal numbers of cut endpoints proves that both sides contain equally many internally matched vertices, and hence equally many internal edges.

  1. Each vertex v is assigned its unique neighbor f(v) in the perfect matching P.

    Since P is a perfect matching, every vertex v has degree 1 in P and thus possesses a unique neighbor. We define f(v) by choosing this neighbor, which by construction is adjacent to v in P.

    lines 7–12

      set_option maxHeartbeats 4000000 in
        classical
        let f : V → V := fun v => (hP.1 (hP.2 v)).choose
        have hf : ∀ v, P.Adj v (f v) := by
          intro v
          exact (hP.1 (hP.2 v)).choose_spec.1
  2. The partner map f is an involution on V, meaning f(f(v)) = v for every vertex v.

    By definition of f, the partner f(v) is adjacent in P to f(f(v)). By symmetry of adjacency, f(v) is also adjacent to v. Since the neighbor of f(v) in the perfect matching is unique, these two vertices must be identical, so f(f(v)) = v.

    lines 13–15

        have hinv : Function.Involutive f := by
          intro v
          exact (hP.1 (hP.2 (f v))).unique (hf (f v)) (hf v).symm
  3. The number of vertices in C matched outside C equals the number of vertices outside C matched into C.

    We establish a bijection between the crossing vertices {v ∈ C | f(v) ∉ C} and {v ∉ C | f(v) ∈ C} via `Finset.card_bij'`, using f in both directions. If v ∈ C has f(v) ∉ C, then f(v) is outside C and f(f(v)) = v ∈ C; the symmetric claim holds in reverse. Involutivity of f ensures both directions are two-sided inverses on their respective domains.

    lines 16–28

    uses Finset.card_bij', Finset.mem_filter, Finset.mem_compl

        have hcross : (C.filter (fun v => f v ∉ C)).card =
            ((Cᶜ : Finset V).filter (fun v => f v ∈ C)).card := by
          apply Finset.card_bij' (fun v _ => f v) (fun v _ => f v)
          · intro v hv
            simp only [Finset.mem_filter,Finset.mem_compl] at hv ⊢
            exact ⟨hv.2,by rw [hinv]; exact hv.1⟩
          · intro v hv
            simp only [Finset.mem_filter,Finset.mem_compl] at hv ⊢
            exact ⟨hv.2,by rw [hinv]; exact hv.1⟩
          · intro v hv
            exact hinv v
          · intro v hv
            exact hinv v
  4. Twice the number of internal edges in C and in Cᶜ equals the number of vertices matched internally within each set.

    Applying `perfect_matching_internal_edge_card` to C shows that 2 * |E(P[C])| equals the count of vertices in C whose partner also lies in C. Applying the same lemma to the complement Cᶜ yields the corresponding identity for Cᶜ, after rewriting the Finset complement to the Set complement via `hcomp`.

    lines 29–32

    uses perfect_matching_internal_edge_card

        have h1 := perfect_matching_internal_edge_card G P hP f hf C
        have h2 := perfect_matching_internal_edge_card G P hP f hf (Cᶜ : Finset V)
        have hcomp : ((Cᶜ : Finset V) : Set V) = (C : Set V)ᶜ := by ext v; simp
        rw [hcomp] at h2
  5. The vertex sets C and Cᶜ are partitioned into internally matched and cut-crossing vertices, and their sizes sum to |V|.

    Using `Finset.card_filter_add_card_filter_not`, the size of C is split into the number of vertices matched inside C plus those matched outside C. The complement Cᶜ is split analogously into vertices matched inside Cᶜ and vertices matched back into C. Simplifying complements and double negations puts both partition equations in terms of membership in C.

    lines 33–36

    uses Finset.card_filter_add_card_filter_not, Finset.mem_compl, not_not

        have hsplit1 := Finset.card_filter_add_card_filter_not (s:=C) (fun v => f v ∈ C)
        have hsplit2 := Finset.card_filter_add_card_filter_not (s:=(Cᶜ : Finset V)) (fun v => f v ∈ (Cᶜ : Finset V))
        have hcompcard : (Cᶜ : Finset V).card + C.card = Fintype.card V := by simp
        simp only [Finset.mem_compl,not_not] at hsplit2 h2
  6. The induced subgraphs P[C] and P[Cᶜ] have the same number of internal edges.

    Since 2 * |C| = |V| and |C| + |Cᶜ| = |V|, both sides have equal size |C| = |Cᶜ|. Subtracting the equal number of cut-crossing vertices from both sides implies that C and Cᶜ have the same number of internally matched vertices. Dividing by 2 equates the edge counts. The decision procedure `omega` solves this linear arithmetic system to close the goal.

    line 37

        omega
Finset.card_bij'
Two finite sets have the same cardinality if there exist maps between them in both directions that are mutually inverse on the elements of the sets.
Finset.card_filter_add_card_filter_not
The sum of the number of elements of a finite set that satisfy a predicate and the number of elements that do not equals the total cardinality of the set.
Finset.mem_compl
An element belongs to the complement of a finite set if and only if it is not a member of the set.
Finset.mem_filter
An element belongs to a filtered finite set if and only if it belongs to the original set and satisfies the predicate.
not_not
Double negation elimination: the proposition not not P is equivalent to P.
perfect_matching_internal_edge_card
In a graph with a perfect matching, twice the number of internal edges induced by a finite vertex subset equals the number of vertices in that subset whose matched partner is also in that subset.

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 perfect_matching_balanced_cut_internal_edge_counts_equal    {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)    (P : G.Subgraph) (hP : P.IsPerfectMatching)    (C : Finset V) (hcard : 2*C.card = Fintype.card V) :    (P.induce (C : Set V)).edgeSet.ncard =      (P.induce ((C : Set V)ᶜ)).edgeSet.ncard := by  set_option maxHeartbeats 4000000 in    classical    let f : V → V := fun v => (hP.1 (hP.2 v)).choose    have hf : ∀ v, P.Adj v (f v) := by      intro v      exact (hP.1 (hP.2 v)).choose_spec.1    have hinv : Function.Involutive f := by      intro v      exact (hP.1 (hP.2 (f v))).unique (hf (f v)) (hf v).symm    have hcross : (C.filter (fun v => f v ∉ C)).card =        ((Cᶜ : Finset V).filter (fun v => f v ∈ C)).card := by      apply Finset.card_bij' (fun v _ => f v) (fun v _ => f v)      · intro v hv        simp only [Finset.mem_filter,Finset.mem_compl] at hv ⊢        exact ⟨hv.2,by rw [hinv]; exact hv.1⟩      · intro v hv        simp only [Finset.mem_filter,Finset.mem_compl] at hv ⊢        exact ⟨hv.2,by rw [hinv]; exact hv.1⟩      · intro v hv        exact hinv v      · intro v hv        exact hinv v    have h1 := perfect_matching_internal_edge_card G P hP f hf C    have h2 := perfect_matching_internal_edge_card G P hP f hf (Cᶜ : Finset V)    have hcomp : ((Cᶜ : Finset V) : Set V) = (C : Set V)ᶜ := by ext v; simp    rw [hcomp] at h2    have hsplit1 := Finset.card_filter_add_card_filter_not (s:=C) (fun v => f v ∈ C)    have hsplit2 := Finset.card_filter_add_card_filter_not (s:=(Cᶜ : Finset V)) (fun v => f v ∈ (Cᶜ : Finset V))    have hcompcard : (Cᶜ : Finset V).card + C.card = Fintype.card V := by simp    simp only [Finset.mem_compl,not_not] at hsplit2 h2    omega
See it in the graphDiscuss this resultChallenge it