AFTD Auto-Formalizing Theoretical Domains

balanced_cut_extend_internal_matching

theoremverified

The separator cross-matching extends a balanced-side matching of k−r edges to a k-matching, leaving exactly r vertices on that side uncovered.

Statement

theorem balanced_cut_extend_internal_matching
    (k r : ℕ) (hr : 1 ≤ r)
    (G : SimpleGraph (Fin (4*k))) [DecidableRel G.Adj]
    (hsep : ∀ S P Q : Finset (Fin (4*k)), P.Nonempty → Q.Nonempty →
      Disjoint S P → Disjoint S Q → Disjoint P Q → S ∪ P ∪ Q = Finset.univ →
      (∀ u ∈ P, ∀ v ∈ Q, ¬ G.Adj u v) → 2*k ≤ S.card)
    (C H : Finset (Fin (4*k))) (hcard : C.card = 2*k)
    (hCH : Disjoint C H)
    (hanti : ∀ u ∈ H, ∀ v, v ∉ C → v ∉ H → ¬ G.Adj u v)
    (hrH : r ≤ H.card)
    (M : G.Subgraph) (hM : M.IsMatching) (hMC : M.verts ⊆ (C : Set (Fin (4*k))))
    (hm : M.edgeSet.ncard+r = k) :
    ∃ T : G.Subgraph, T.IsMatching ∧ T.edgeSet.ncard = k ∧ M ≤ T ∧
      T.verts ⊆ (C ∪ H : Finset (Fin (4*k))) ∧
      ((C : Set (Fin (4*k))) \ T.verts).ncard = r
Source
Balanced-cut matching construction for OP-1957; https://arxiv.org/abs/2611.22690.
Verified
26 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 4
Used by 1

The proof, explained

The proof extends a matching M of k - r edges inside C to a matching T of k edges by finding r disjoint cross-edges into H. Since |C| = 2k and M covers 2k - 2r vertices, there are 2r unmatched vertices U in C. The balanced separator hypothesis yields a matching N of r independent edges between U and H, which is vertex-disjoint from M. Taking T = M ⊔ N gives a matching of k edges contained in C ∪ H that covers r additional vertices of C, leaving exactly 2r - r = r vertices in C uncovered.

  1. The vertices D covered by M satisfy D ⊆ C and |D| + 2r = 2k, and the unmatched vertices U = C \ D satisfy |U| = 2r ≥ r with U ⊆ C.

    Let D be the set of vertices covered by M, and U = C \ D the unmatched vertices in C. Since M is a matching, each edge has two endpoints, so |D| = 2|E(M)|. From |E(M)| + r = k and |C| = 2k, multiplying by 2 yields |D| + 2r = 2k. Since D ⊆ C, the size of U = C \ D is |C| - |D| = 2r. As r ≥ 1, we have r ≤ |U|.

    lines 16–34

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

      classical
      let D : Finset (Fin (4*k)) := M.verts.toFinset
      let U : Finset (Fin (4*k)) := C \ D
      have hDC : D ⊆ C := by
        intro v hv
        exact hMC (by simpa [D] using hv)
      have hDcard : D.card + 2*r = 2*k := by
        have hh := in1076_matching_twice_card hM
        have hD : D.card = M.verts.ncard := by
          dsimp [D]
          exact (Set.ncard_eq_toFinset_card' M.verts).symm
        rw [hD] at *
        omega
      have hUcard : U.card = 2*r := by
        have hh := Finset.card_sdiff_add_card_eq_card hDC
        dsimp [U]
        omega
      have hUC : U ⊆ C := Finset.sdiff_subset
      have hrU : r ≤ U.card := by omega
  2. There exists a matching subgraph N of r edges between U and H, with vertices given by the ranges of injective maps f : Fin r → U and g : Fin r → H.

    Applying balanced_cut_anticomplete_side_has_cross_matching gives injective functions f : Fin r → U and g : Fin r → H such that each pair (f(i), g(i)) is an edge of G. Since C and H are disjoint and U ⊆ C, no f(i) equals any g(j). Thus, by indexed_disjoint_cross_edges_form_matching, these r edges form a matching N with r edges and vertex set range(f) ∪ range(g).

    lines 35–44

    uses balanced_cut_anticomplete_side_has_cross_matching, Finset.disjoint_left.mp, indexed_disjoint_cross_edges_form_matching

      obtain ⟨f,g,hf,hg,hfg⟩ :=
        balanced_cut_anticomplete_side_has_cross_matching k r hr G hsep C H U
          hcard hCH hUC hanti hrU hrH
      have hfgdis : ∀ i j, f i ≠ g j := by
        intro i j he
        have hc := hUC (hfg i).1
        have hh := (hfg j).2.1
        exact Finset.disjoint_left.mp hCH hc (he.symm ▸ hh)
      obtain ⟨N,hN,hNcard,hNverts⟩ :=
        indexed_disjoint_cross_edges_form_matching G r f g hf hg hfgdis (fun i => (hfg i).2.2)
  3. The matchings M and N have disjoint vertex sets, so their union M ⊔ N is a matching with k edges.

    Vertices of N in C belong to U = C \ D, so they are disjoint from the vertices D of M. Vertices of N in H are disjoint from C ⊇ M.verts because C and H are disjoint. Hence M and N are vertex-disjoint. By extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard, their union M ⊔ N is a matching with |E(M)| + |E(N)| = (k - r) + r = k edges.

    lines 45–58

    uses Set.disjoint_left.mpr, Finset.mem_sdiff.mp, Finset.disjoint_left.mp, extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard

      have hMN : Disjoint M.verts N.verts := by
        apply Set.disjoint_left.mpr
        intro v hvM hvN
        rw [hNverts] at hvN
        rcases hvN with ⟨i,hi⟩ | ⟨i,hi⟩
        · have hu := (hfg i).1
          have hn : f i ∉ D := (Finset.mem_sdiff.mp hu).2
          apply hn
          simpa [D,hi] using hvM
        · have hc := hMC hvM
          have hh := (hfg i).2.1
          exact Finset.disjoint_left.mp hCH hc (hi ▸ hh)
      have hT := extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard M N hM hN hMN
      have hTk : (M ⊔ N).edgeSet.ncard = k := by rw [hT.2,hNcard]; omega
  4. The set A = range(f) of endpoints of N in C has cardinality r, is a subset of C, and is disjoint from the vertices D of M.

    Define A as the image of the injection f. Since f is injective on a domain of size r, |A| = r. Because f maps into U ⊆ C, we have A ⊆ C. Since U = C \ D, every element of A is outside D, so D and A are disjoint.

    lines 59–71

    uses Finset.card_image_of_injective, Finset.mem_image.mp, Finset.disjoint_left.mpr, Finset.mem_sdiff.mp

      let A : Finset (Fin (4*k)) := Finset.univ.image f
      have hAcard : A.card = r := by
        rw [Finset.card_image_of_injective _ hf]
        simp
      have hAC : A ⊆ C := by
        intro v hv
        obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hv
        exact hUC (hfg i).1
      have hDA : Disjoint D A := by
        apply Finset.disjoint_left.mpr
        intro v hvD hvA
        obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hvA
        exact (Finset.mem_sdiff.mp (hfg i).1).2 hvD
  5. The vertex set of M ⊔ N is contained in C ∪ H.

    Every vertex of M lies in C. Every vertex of N is either in range(f) ⊆ U ⊆ C or in range(g) ⊆ H. In all cases, every vertex of M ⊔ N belongs to C ∪ H.

    lines 72–80

    uses Finset.mem_union_left, Finset.mem_union_right

      have hTsub : (M ⊔ N).verts ⊆ (C ∪ H : Finset (Fin (4*k))) := by
        intro v hv
        change v ∈ M.verts ∪ N.verts at hv
        rcases hv with hv | hv
        · exact Finset.mem_union_left H (hMC hv)
        · rw [hNverts] at hv
          rcases hv with ⟨i,rfl⟩ | ⟨i,rfl⟩
          · exact Finset.mem_union_left H (hUC (hfg i).1)
          · exact Finset.mem_union_right C (hfg i).2.1
  6. Exactly r vertices in C are not covered by M ⊔ N.

    A vertex in C is not covered by M ⊔ N if and only if it belongs to neither D (the vertices of M) nor A (the vertices of N in C), so the uncovered vertices are C \ (D ∪ A). Since D and A are disjoint subsets of C, |D ∪ A| = |D| + |A| = (2k - 2r) + r = 2k - r. Subtracting from |C| = 2k gives |C \ (D ∪ A)| = r, which translates directly to the set difference (C \ (M ⊔ N).verts) having cardinality r.

    lines 81–121

    uses Finset.mem_filter, Finset.mem_sdiff, Finset.mem_union, Or.inl, Finset.mem_image.mp, Finset.mem_image.mpr, Finset.mem_univ, Finset.disjoint_left.mp, Finset.union_subset, Finset.card_sdiff_add_card_eq_card, Finset.card_union_of_disjoint, Set.ncard_coe_finset

      have hfilter : C.filter (fun v => v ∉ (M ⊔ N).verts) = C \ (D ∪ A) := by
        ext v
        simp only [Finset.mem_filter,Finset.mem_sdiff,Finset.mem_union]
        constructor
        · rintro ⟨hvC,hvT⟩
          refine ⟨hvC,?_⟩
          rintro (hvD | hvA)
          · apply hvT
            change v ∈ M.verts ∪ N.verts
            exact Or.inl (by simpa [D] using hvD)
          · obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hvA
            apply hvT
            change f i ∈ M.verts ∪ N.verts
            right
            rw [hNverts]
            exact Or.inl ⟨i,rfl⟩
        · rintro ⟨hvC,hvnot⟩
          refine ⟨hvC,?_⟩
          intro hvT
          change v ∈ M.verts ∪ N.verts at hvT
          rcases hvT with hvM | hvN
          · exact hvnot (Or.inl (by simpa [D] using hvM))
          · rw [hNverts] at hvN
            rcases hvN with ⟨i,hi⟩ | ⟨i,hi⟩
            · apply hvnot
              right
              exact Finset.mem_image.mpr ⟨i,Finset.mem_univ _,hi⟩
            · exact Finset.disjoint_left.mp hCH hvC (hi ▸ (hfg i).2.1)
      have hremain : (C.filter (fun v => v ∉ (M ⊔ N).verts)).card = r := by
        rw [hfilter]
        have hsub : D ∪ A ⊆ C := Finset.union_subset hDC hAC
        have hh := Finset.card_sdiff_add_card_eq_card hsub
        rw [Finset.card_union_of_disjoint hDA,hAcard] at hh
        omega
      have hremain' : ((C : Set (Fin (4*k))) \ (M ⊔ N).verts).ncard = r := by
        have heq : (C : Set (Fin (4*k))) \ (M ⊔ N).verts =
            (C.filter (fun v => v ∉ (M ⊔ N).verts) : Finset (Fin (4*k))) := by
          ext v
          simp
        rw [heq,Set.ncard_coe_finset]
        exact hremain
  7. The subgraph T = M ⊔ N witnesses all required conditions of the theorem.

    The subgraph M ⊔ N is a matching of size k, contains M by le_sup_left, has all its vertices within C ∪ H, and leaves exactly r vertices in C uncovered, completing the existential goal.

    line 122

    uses le_sup_left

      refine ⟨M ⊔ N,hT.1,hTk,le_sup_left,hTsub,hremain'⟩
in1076_matching_twice_card
In any graph matching, the number of vertices spanned is twice the number of edges.
Set.ncard_eq_toFinset_card'
The cardinality of a finite set as a Set equals its cardinality as a Finset.
Finset.card_sdiff_add_card_eq_card
For finite sets s ⊆ t, the size of the difference plus the size of s equals the size of t: |t \ s| + |s| = |t|.
Finset.sdiff_subset
The set difference s \ t is always a subset of s.
balanced_cut_anticomplete_side_has_cross_matching
Under the balanced separator condition, there exist r independent edges between a subset U ⊆ C of size at least r and H of size at least r.
Finset.disjoint_left.mp
If two finite sets are disjoint, any element in the first set does not belong to the second set.
indexed_disjoint_cross_edges_form_matching
A family of r edges given by injections f, g with disjoint ranges forms a matching subgraph of size r whose vertex set is the union of the ranges of f and g.
Set.disjoint_left.mpr
If no element of s belongs to t, then s and t are disjoint sets.
Finset.mem_sdiff.mp
If an element belongs to s \ t, then it belongs to s and does not belong 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.
Finset.card_image_of_injective
An injective function preserves the cardinality of a finite set under image.
Finset.mem_image.mp
An element belongs to the image f(s) if and only if it is the image of some element in s.
Finset.disjoint_left.mpr
If no element of s belongs to t, then the finite sets s and t are disjoint.
Finset.mem_union_left
An element of s belongs to s ∪ t.
Finset.mem_union_right
An element of t belongs to s ∪ t.
Finset.mem_filter
An element belongs to a filtered finite set if and only if it is in the original set and satisfies the predicate.
Finset.mem_sdiff
An element belongs to s \ t if and only if it is in s and not in t.
Finset.mem_union
An element belongs to s ∪ t if and only if it is in s or in t.
Or.inl
Deduces the disjunction A ∨ B from A.
Finset.mem_image.mpr
If an element is the image of an element in s, it belongs to the image f(s).
Finset.mem_univ
Every element of a finite type belongs to its universal set Finset.univ.
Finset.union_subset
If s ⊆ u and t ⊆ u, then s ∪ t ⊆ u.
Finset.card_union_of_disjoint
If two finite sets are disjoint, the cardinality of their union is the sum of their cardinalities.
Set.ncard_coe_finset
The Set cardinality of a Finset coerced to a Set equals its Finset cardinality.
le_sup_left
In a join-semilattice, a ≤ a ⊔ b.

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 balanced_cut_extend_internal_matching    (k r : ℕ) (hr : 1 ≤ r)    (G : SimpleGraph (Fin (4*k))) [DecidableRel G.Adj]    (hsep : ∀ S P Q : Finset (Fin (4*k)), P.Nonempty → Q.Nonempty →      Disjoint S P → Disjoint S Q → Disjoint P Q → S ∪ P ∪ Q = Finset.univ →      (∀ u ∈ P, ∀ v ∈ Q, ¬ G.Adj u v) → 2*k ≤ S.card)    (C H : Finset (Fin (4*k))) (hcard : C.card = 2*k)    (hCH : Disjoint C H)    (hanti : ∀ u ∈ H, ∀ v, v ∉ C → v ∉ H → ¬ G.Adj u v)    (hrH : r ≤ H.card)    (M : G.Subgraph) (hM : M.IsMatching) (hMC : M.verts ⊆ (C : Set (Fin (4*k))))    (hm : M.edgeSet.ncard+r = k) :    ∃ T : G.Subgraph, T.IsMatching ∧ T.edgeSet.ncard = k ∧ M ≤ T ∧      T.verts ⊆ (C ∪ H : Finset (Fin (4*k))) ∧      ((C : Set (Fin (4*k))) \ T.verts).ncard = r := by  classical  let D : Finset (Fin (4*k)) := M.verts.toFinset  let U : Finset (Fin (4*k)) := C \ D  have hDC : D ⊆ C := by    intro v hv    exact hMC (by simpa [D] using hv)  have hDcard : D.card + 2*r = 2*k := by    have hh := in1076_matching_twice_card hM    have hD : D.card = M.verts.ncard := by      dsimp [D]      exact (Set.ncard_eq_toFinset_card' M.verts).symm    rw [hD] at *    omega  have hUcard : U.card = 2*r := by    have hh := Finset.card_sdiff_add_card_eq_card hDC    dsimp [U]    omega  have hUC : U ⊆ C := Finset.sdiff_subset  have hrU : r ≤ U.card := by omega  obtain ⟨f,g,hf,hg,hfg⟩ :=    balanced_cut_anticomplete_side_has_cross_matching k r hr G hsep C H U      hcard hCH hUC hanti hrU hrH  have hfgdis : ∀ i j, f i ≠ g j := by    intro i j he    have hc := hUC (hfg i).1    have hh := (hfg j).2.1    exact Finset.disjoint_left.mp hCH hc (he.symm ▸ hh)  obtain ⟨N,hN,hNcard,hNverts⟩ :=    indexed_disjoint_cross_edges_form_matching G r f g hf hg hfgdis (fun i => (hfg i).2.2)  have hMN : Disjoint M.verts N.verts := by    apply Set.disjoint_left.mpr    intro v hvM hvN    rw [hNverts] at hvN    rcases hvN with ⟨i,hi⟩ | ⟨i,hi⟩    · have hu := (hfg i).1      have hn : f i ∉ D := (Finset.mem_sdiff.mp hu).2      apply hn      simpa [D,hi] using hvM    · have hc := hMC hvM      have hh := (hfg i).2.1      exact Finset.disjoint_left.mp hCH hc (hi ▸ hh)  have hT := extendible_graph_matchable_deletion_inherits_extendibility_sup_ncard M N hM hN hMN  have hTk : (M ⊔ N).edgeSet.ncard = k := by rw [hT.2,hNcard]; omega  let A : Finset (Fin (4*k)) := Finset.univ.image f  have hAcard : A.card = r := by    rw [Finset.card_image_of_injective _ hf]    simp  have hAC : A ⊆ C := by    intro v hv    obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hv    exact hUC (hfg i).1  have hDA : Disjoint D A := by    apply Finset.disjoint_left.mpr    intro v hvD hvA    obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hvA    exact (Finset.mem_sdiff.mp (hfg i).1).2 hvD  have hTsub : (M ⊔ N).verts ⊆ (C ∪ H : Finset (Fin (4*k))) := by    intro v hv    change v ∈ M.verts ∪ N.verts at hv    rcases hv with hv | hv    · exact Finset.mem_union_left H (hMC hv)    · rw [hNverts] at hv      rcases hv with ⟨i,rfl⟩ | ⟨i,rfl⟩      · exact Finset.mem_union_left H (hUC (hfg i).1)      · exact Finset.mem_union_right C (hfg i).2.1  have hfilter : C.filter (fun v => v ∉ (M ⊔ N).verts) = C \ (D ∪ A) := by    ext v    simp only [Finset.mem_filter,Finset.mem_sdiff,Finset.mem_union]    constructor    · rintro ⟨hvC,hvT⟩      refine ⟨hvC,?_⟩      rintro (hvD | hvA)      · apply hvT        change v ∈ M.verts ∪ N.verts        exact Or.inl (by simpa [D] using hvD)      · obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hvA        apply hvT        change f i ∈ M.verts ∪ N.verts        right        rw [hNverts]        exact Or.inl ⟨i,rfl⟩    · rintro ⟨hvC,hvnot⟩      refine ⟨hvC,?_⟩      intro hvT      change v ∈ M.verts ∪ N.verts at hvT      rcases hvT with hvM | hvN      · exact hvnot (Or.inl (by simpa [D] using hvM))      · rw [hNverts] at hvN        rcases hvN with ⟨i,hi⟩ | ⟨i,hi⟩        · apply hvnot          right          exact Finset.mem_image.mpr ⟨i,Finset.mem_univ _,hi⟩        · exact Finset.disjoint_left.mp hCH hvC (hi ▸ (hfg i).2.1)  have hremain : (C.filter (fun v => v ∉ (M ⊔ N).verts)).card = r := by    rw [hfilter]    have hsub : D ∪ A ⊆ C := Finset.union_subset hDC hAC    have hh := Finset.card_sdiff_add_card_eq_card hsub    rw [Finset.card_union_of_disjoint hDA,hAcard] at hh    omega  have hremain' : ((C : Set (Fin (4*k))) \ (M ⊔ N).verts).ncard = r := by    have heq : (C : Set (Fin (4*k))) \ (M ⊔ N).verts =        (C.filter (fun v => v ∉ (M ⊔ N).verts) : Finset (Fin (4*k))) := by      ext v      simp    rw [heq,Set.ncard_coe_finset]    exact hremain  refine ⟨M ⊔ N,hT.1,hTk,le_sup_left,hTsub,hremain'⟩
See it in the graphDiscuss this resultChallenge it