AFTD Auto-Formalizing Theoretical Domains

balanced_cut_evenly_distributed_cross_matching

theoremverified

In a 2k-connected balanced cut, r crossing edges can be chosen from 2r available separator vertices into distinct anticomplete outside groups of size at least two, with an odd number of chosen endpoints in at most one group.

Statement

theorem balanced_cut_evenly_distributed_cross_matching
    (k 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 U : Finset (Fin (4*k))) (hcard : C.card = 2*k) (hUC : U ⊆ C)
    (hU : 2*r ≤ U.card) {I : Type*} [DecidableEq I]
    (J : Finset I) (F : I → Finset (Fin (4*k))) (hJ : r+2 ≤ J.card)
    (hCH : ∀ i ∈ J, Disjoint C (F i))
    (hdis : ∀ i ∈ J, ∀ j ∈ J, i ≠ j → Disjoint (F i) (F j))
    (hsize : ∀ i ∈ J, 2 ≤ (F i).card)
    (hanti : ∀ i ∈ J, ∀ u ∈ F i, ∀ v, v ∉ C → v ∉ F i → ¬ G.Adj u v) :
    ∃ f g : Fin r → Fin (4*k), Function.Injective f ∧ Function.Injective g ∧
      (∀ a, f a ∈ U ∧ G.Adj (f a) (g a)) ∧
      (∀ a, ∃ i ∈ J, g a ∈ F i) ∧
      ∃ B : Finset I, B.card ≤ 1 ∧
        ∀ i ∈ J, i ∉ B → Even (((Finset.univ : Finset (Fin r)).image g) ∩ F i).card
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 1

The proof, explained

The proof proceeds by two-step induction on the matching size r. For r = 0, the empty matching trivially satisfies the conditions with B = ∅. For r = 1, a single edge is matched into an arbitrary group F j using the cross-matching lemma, with B = {j} capturing the single odd group while all other groups contain 0 endpoints. For the step r → r + 2, two edges are matched into a chosen group F j, and removing these two vertices from U and F j from the group family allows applying the induction hypothesis to obtain an r-matching; appending these matchings adds exactly 2 endpoints to F j (preserving even parity) and 0 endpoints to all other groups, leaving the exceptional set B unchanged.

  1. The claim is reduced to a two-step induction on r, universally quantified over the separator subset U and the family of outside groups J.

    After enabling classical logic (line 19) and generalizing the hypotheses on U and J (line 20), we perform induction on r using `Nat.twoStepInduction` (line 21). This generates three obligations: the base cases r = 0 and r = 1, and the inductive step from r to r + 2.

    lines 18–21

    uses Nat.twoStepInduction

      set_option maxHeartbeats 4000000 in
        classical
        revert U J
        induction r using Nat.twoStepInduction with
  2. The base case r = 0 holds with the empty matching and empty exceptional set B = ∅. automation

    When r = 0, we provide empty functions `Fin.elim0` for both f and g, and B = ∅ (line 24). Since Fin 0 is empty, injectivity and edge properties hold vacuously via `Fin.elim0` (lines 25-32). For every group i ∈ J, the image of g is empty, so its intersection with F i has cardinality 0, which is even (lines 33-34).

    lines 22–34

    uses Fin.elim0

        | zero =>
          intro U hUC hU J hJ hCH hdis hsize hanti
          refine ⟨Fin.elim0,Fin.elim0,?_,?_,?_,?_,∅,by simp,?_⟩
          · intro x
            exact Fin.elim0 x
          · intro x
            exact Fin.elim0 x
          · intro x
            exact Fin.elim0 x
          · intro x
            exact Fin.elim0 x
          · intro i hi _
            simp
  3. In the base case r = 1, there exists a 1-edge matching into an arbitrary group F j, with exceptional set B = {j}.

    Since |J| ≥ 1 + 2 = 3, there exists an index j ∈ J (line 37). Applying the lemma `balanced_cut_anticomplete_side_has_cross_matching` with size 1 between U and F j produces injective maps f, g : Fin 1 → Fin (4k) such that f(a) ∈ U, g(a) ∈ F j, and f(a) is adjacent to g(a) (lines 38-40). Setting B = {j}, which has cardinality 1, satisfies the vertex and group containment conditions (lines 41-43).

    lines 35–43

    uses Finset.card_pos.mp, balanced_cut_anticomplete_side_has_cross_matching

        | one =>
          intro U hUC hU J hJ hCH hdis hsize hanti
          obtain ⟨j,hj⟩ := Finset.card_pos.mp (by omega : 0 < J.card)
          obtain ⟨f,g,hf,hg,hfg⟩ :=
            balanced_cut_anticomplete_side_has_cross_matching k 1 (by omega) G hsep C (F j) U
              hcard (hCH j hj) hUC (hanti j hj) (by omega) (by have := hsize j hj; omega)
          refine ⟨f,g,hf,hg,(fun a => ⟨(hfg a).1,(hfg a).2.2⟩),?_,{j},by simp,?_⟩
          · intro a
            exact ⟨j,hj,(hfg a).2.1⟩
  4. For r = 1, every group F i with i ≠ j contains an even number (zero) of matching endpoints. automation

    For any i ∈ J with i ∉ {j}, we have i ≠ j (line 45). Because F i and F j are disjoint, and the image of g is contained in F j, no vertex in the image of g can belong to F i (lines 46-51). Hence the intersection is empty (line 52), so its cardinality is 0, which is even (line 53).

    lines 44–53

    uses Finset.disjoint_left.mp, Finset.eq_empty_iff_forall_notMem.mpr, Finset.mem_image.mp, Finset.mem_inter.mp

          · intro i hi hiB
            have hij : i ≠ j := by simpa using hiB
            have hnull : ((Finset.univ : Finset (Fin 1)).image g) ∩ F i = ∅ := by
              apply Finset.eq_empty_iff_forall_notMem.mpr
              intro v hv
              obtain ⟨hvg,hvi⟩ := Finset.mem_inter.mp hv
              obtain ⟨a,_,rfl⟩ := Finset.mem_image.mp hvg
              exact Finset.disjoint_left.mp (hdis i hi j hj hij) hvi (hfg a).2.1
            rw [hnull]
            simp
  5. In the inductive step for r + 2, we choose a group F j, find a 2-edge matching (f0, g0) into F j, and define the reduced sets U' = U \ im(f0) and J' = J \ {j}.

    Since |J| ≥ (r + 2) + 2 ≥ 4, there exists an index j ∈ J (line 56). Applying `balanced_cut_anticomplete_side_has_cross_matching` with size 2 between U and F j yields an injective 2-edge matching f0, g0 : Fin 2 → Fin (4k) (lines 57-59). We set A = im(f0), U' = U \ A, and J' = J \ {j} (lines 60-62).

    lines 54–62

    uses Finset.card_pos.mp, balanced_cut_anticomplete_side_has_cross_matching

        | more r ih _ =>
          intro U hUC hU J hJ hCH hdis hsize hanti
          obtain ⟨j,hj⟩ := Finset.card_pos.mp (by omega : 0 < J.card)
          obtain ⟨f0,g0,hf0,hg0,hfg0⟩ :=
            balanced_cut_anticomplete_side_has_cross_matching k 2 (by omega) G hsep C (F j) U
              hcard (hCH j hj) hUC (hanti j hj) (by omega) (hsize j hj)
          let A : Finset (Fin (4*k)) := (Finset.univ : Finset (Fin 2)).image f0
          let U' : Finset (Fin (4*k)) := U \ A
          let J' : Finset I := J.erase j
  6. The reduced separator subset U' and family of groups J' satisfy all preconditions for the induction hypothesis.

    Injectivity of f0 implies |A| = 2 (`Finset.card_image_of_injective`, lines 63-66). Set arithmetic yields |U'| = |U \ A| ≥ 2(r + 2) - 2 = 2r (lines 68-72) and |J'| = |J| - 1 ≥ r + 2 (lines 73-76). The remaining hypotheses—U' ⊆ C, disjointness of the groups from C and each other, group sizes at least 2, and the anticomplete condition—are inherited directly because J' ⊆ J (lines 67, 77-88).

    lines 63–88

    uses Finset.card_erase_add_one, Finset.card_image_of_injective, Finset.card_le_card, Finset.card_sdiff_add_card_inter, Finset.inter_subset_right, Finset.mem_erase.mp, Finset.sdiff_subset

          have hAcard : A.card = 2 := by
            dsimp [A]
            rw [Finset.card_image_of_injective _ hf0]
            simp
          have hUC' : U' ⊆ C := (Finset.sdiff_subset : U' ⊆ U).trans hUC
          have hU' : 2*r ≤ U'.card := by
            have hh := Finset.card_sdiff_add_card_inter U A
            have hh' : (U ∩ A).card ≤ A.card := Finset.card_le_card Finset.inter_subset_right
            dsimp [U']
            omega
          have hJ' : r+2 ≤ J'.card := by
            have hh := Finset.card_erase_add_one hj
            dsimp [J']
            omega
          have hCH' : ∀ i ∈ J', Disjoint C (F i) := by
            intro i hi
            exact hCH i (Finset.mem_erase.mp hi).2
          have hdis' : ∀ i ∈ J', ∀ l ∈ J', i ≠ l → Disjoint (F i) (F l) := by
            intro i hi l hl hil
            exact hdis i (Finset.mem_erase.mp hi).2 l (Finset.mem_erase.mp hl).2 hil
          have hsize' : ∀ i ∈ J', 2 ≤ (F i).card := by
            intro i hi
            exact hsize i (Finset.mem_erase.mp hi).2
          have hanti' : ∀ i ∈ J', ∀ u ∈ F i, ∀ v, v ∉ C → v ∉ F i → ¬ G.Adj u v := by
            intro i hi
            exact hanti i (Finset.mem_erase.mp hi).2
  7. The induction hypothesis provides an r-edge cross-matching (f, g) into J' with an exceptional set B ⊆ J' of size at most 1.

    Applying the induction hypothesis `ih` to U' and J' yields injective maps f, g : Fin r → Fin (4k) and an exceptional set B ⊆ J' with |B| ≤ 1 such that every edge connects U' to some group F i with i ∈ J', and for every i ∈ J' \ B, the number of endpoints in F i is even.

    lines 89–90

          obtain ⟨f,g,hf,hg,hfg,hgroups,B,hB,hpar⟩ :=
            ih U' hUC' hU' J' hJ' hCH' hdis' hsize' hanti'
  8. The matchings (f, g) and (f0, g0) have disjoint ranges, so their concatenations ff = f ∪ f0 and gg = g ∪ g0 are injective.

    The sets of starting vertices are disjoint because f takes values in U' = U \ A while f0 takes values in A (lines 91-96). The endpoint vertices are disjoint because g lands only in groups indexed by J' (which excludes j), whereas g0 lands in F j (lines 97-104). By `Fin.append_injective_iff.mpr`, the concatenated functions ff, gg : Fin (r + 2) → Fin (4k) are injective (lines 105-108).

    lines 91–108

    uses Fin.append, Fin.append_injective_iff.mpr, Finset.disjoint_left.mp, Finset.mem_erase.mp, Finset.mem_image.mpr, Finset.mem_sdiff.mp, Finset.mem_univ

          have hfd : ∀ a b, f a ≠ f0 b := by
            intro a b he
            have hn := (Finset.mem_sdiff.mp (hfg a).1).2
            apply hn
            dsimp [A]
            exact Finset.mem_image.mpr ⟨b,Finset.mem_univ _,he.symm⟩
          have hgnot : ∀ a, g a ∉ F j := by
            intro a hgj
            obtain ⟨i,hi,hgi⟩ := hgroups a
            have hne : i ≠ j := (Finset.mem_erase.mp hi).1
            exact Finset.disjoint_left.mp (hdis i (Finset.mem_erase.mp hi).2 j hj hne) hgi hgj
          have hgd : ∀ a b, g a ≠ g0 b := by
            intro a b he
            exact hgnot a (he.symm ▸ (hfg0 b).2.1)
          let ff := Fin.append f f0
          let gg := Fin.append g g0
          have hff : Function.Injective ff := Fin.append_injective_iff.mpr ⟨hf,hf0,hfd⟩
          have hgg : Function.Injective gg := Fin.append_injective_iff.mpr ⟨hg,hg0,hgd⟩
  9. Every edge (ff(a), gg(a)) connects U to a group F i for some i ∈ J.

    We split cases on the index a ∈ Fin (r + 2) using `Fin.addCases`. If a corresponds to an index in Fin r, then ff(a) = f(a) ∈ U' ⊆ U, G.Adj(f(a), g(a)) holds, and g(a) ∈ F i for some i ∈ J' ⊆ J (lines 111-113, 118-121). If a corresponds to an index in Fin 2, then ff(a) = f0(a) ∈ U, G.Adj(f0(a), g0(a)) holds, and g0(a) ∈ F j with j ∈ J (lines 114-115, 122-123).

    lines 109–123

    uses Fin.addCases, Finset.mem_erase.mp, Finset.mem_sdiff.mp

          have hboth : ∀ a, ff a ∈ U ∧ G.Adj (ff a) (gg a) := by
            intro a
            refine Fin.addCases ?_ ?_ a
            · intro b
              simpa [ff,gg] using ⟨(Finset.mem_sdiff.mp (hfg b).1).1,(hfg b).2⟩
            · intro b
              simpa [ff,gg] using ⟨(hfg0 b).1,(hfg0 b).2.2⟩
          have hwhere : ∀ a, ∃ i ∈ J, gg a ∈ F i := by
            intro a
            refine Fin.addCases ?_ ?_ a
            · intro b
              obtain ⟨i,hi,hgi⟩ := hgroups b
              exact ⟨i,(Finset.mem_erase.mp hi).2,by simpa [gg] using hgi⟩
            · intro b
              exact ⟨j,hj,by simpa [gg] using (hfg0 b).2.1⟩
  10. The image of gg is the union of the images of g and g0.

    By extensionality, a vertex v belongs to im(gg) if and only if v = gg(a) for some a. Case analysis using `Fin.addCases` shows that this occurs precisely when v ∈ im(g) or v ∈ im(g0), and the reverse inclusion follows via `Fin.castAdd` and `Fin.natAdd`.

    lines 124–139

    uses Fin.addCases, Fin.castAdd, Fin.natAdd, Finset.mem_image, Finset.mem_union, Finset.mem_univ, true_and

          have himage : ((Finset.univ : Finset (Fin (r+2))).image gg) =
              ((Finset.univ : Finset (Fin r)).image g) ∪ ((Finset.univ : Finset (Fin 2)).image g0) := by
            ext v
            simp only [Finset.mem_image,Finset.mem_univ,true_and,Finset.mem_union]
            constructor
            · rintro ⟨a,ha⟩
              cases a using Fin.addCases with
              | left b =>
                left
                exact ⟨b,by simpa [gg] using ha⟩
              | right b =>
                right
                exact ⟨b,by simpa [gg] using ha⟩
            · rintro (⟨b,hb⟩ | ⟨b,hb⟩)
              · exact ⟨Fin.castAdd 2 b,by simpa [gg] using hb⟩
              · exact ⟨Fin.natAdd r b,by simpa [gg] using hb⟩
  11. The exceptional set B still has size at most 1, and for the group F j (if j ∉ B), the number of matching endpoints in F j is 2, which is even.

    We retain the same set B, so |B| ≤ 1 holds (line 140). Rewriting the image of gg as im(g) ∪ im(g0) (line 142), we consider i ∈ J \ B. If i = j, then since g has no endpoints in F j and g0 has all its endpoints in F j, the intersection reduces to im(g0) (lines 145-164). Since g0 is injective on Fin 2, this set has cardinality 2 (`Finset.card_image_of_injective`), which is even (lines 165-166).

    lines 140–166

    uses False.elim, Finset.card_image_of_injective, Finset.disjoint_left.mp, Finset.disjoint_left.mpr, Finset.mem_image.mp, Finset.mem_inter, Finset.mem_union, Or.inr

          refine ⟨ff,gg,hff,hgg,hboth,hwhere,B,hB,?_⟩
          intro i hi hiB
          rw [himage]
          by_cases hij : i = j
          · subst i
            have hzero : Disjoint ((Finset.univ : Finset (Fin r)).image g) (F j) := by
              apply Finset.disjoint_left.mpr
              intro v hvg hvj
              obtain ⟨a,_,rfl⟩ := Finset.mem_image.mp hvg
              exact hgnot a hvj
            have hsub : ((Finset.univ : Finset (Fin 2)).image g0) ⊆ F j := by
              intro v hv
              obtain ⟨a,_,rfl⟩ := Finset.mem_image.mp hv
              exact (hfg0 a).2.1
            have heq : (((Finset.univ : Finset (Fin r)).image g) ∪
                ((Finset.univ : Finset (Fin 2)).image g0)) ∩ F j =
                  ((Finset.univ : Finset (Fin 2)).image g0) := by
              ext v
              simp only [Finset.mem_inter,Finset.mem_union]
              constructor
              · rintro ⟨hv | hv,hvj⟩
                · exact False.elim (Finset.disjoint_left.mp hzero hv hvj)
                · exact hv
              · intro hv
                exact ⟨Or.inr hv,hsub hv⟩
            rw [heq,Finset.card_image_of_injective _ hg0]
            simp
  12. For every group F i with i ≠ j and i ∉ B, the number of matching endpoints is even by the induction hypothesis.

    If i ≠ j, then i ∈ J' (line 167). Since im(g0) ⊆ F j and F i is disjoint from F j, im(g0) is disjoint from F i (lines 168-172). Thus (im(g) ∪ im(g0)) ∩ F i = im(g) ∩ F i (lines 173-184). Because i ∈ J' \ B, the induction hypothesis guarantees that |im(g) ∩ F i| is even (line 185).

    lines 167–185

    uses False.elim, Finset.disjoint_left.mp, Finset.disjoint_left.mpr, Finset.mem_erase.mpr, Finset.mem_image.mp, Finset.mem_inter, Finset.mem_union, Or.inl

          · have hi' : i ∈ J' := Finset.mem_erase.mpr ⟨hij,hi⟩
            have hzero : Disjoint ((Finset.univ : Finset (Fin 2)).image g0) (F i) := by
              apply Finset.disjoint_left.mpr
              intro v hvg hvi
              obtain ⟨a,_,rfl⟩ := Finset.mem_image.mp hvg
              exact Finset.disjoint_left.mp (hdis i hi j hj hij) hvi (hfg0 a).2.1
            have heq : (((Finset.univ : Finset (Fin r)).image g) ∪
                ((Finset.univ : Finset (Fin 2)).image g0)) ∩ F i =
                  ((Finset.univ : Finset (Fin r)).image g) ∩ F i := by
              ext v
              simp only [Finset.mem_inter,Finset.mem_union]
              constructor
              · rintro ⟨hv | hv,hvi⟩
                · exact ⟨hv,hvi⟩
                · exact False.elim (Finset.disjoint_left.mp hzero hv hvi)
              · rintro ⟨hv,hvi⟩
                exact ⟨Or.inl hv,hvi⟩
            rw [heq]
            exact hpar i hi' hiB
False.elim
From a proof of False (a contradiction), any proposition can be deduced.
Fin.addCases
Evaluates a property on Fin (m + n) by splitting cases into the first m coordinates and the remaining n coordinates.
Fin.append
Concatenates two maps defined on Fin m and Fin n into a single map on Fin (m + n).
Fin.append_injective_iff.mpr
Concatenating two injective maps with disjoint ranges produces an injective map on the sum of their domains.
Fin.castAdd
Embeds an index of Fin n into Fin (n + m) as one of the first n elements.
Fin.elim0
The unique function from the empty type Fin 0 to any target type, eliminating impossible or vacuous cases.
Fin.natAdd
Embeds an index of Fin m into Fin (n + m) by shifting it by n.
Finset.card_erase_add_one
Removing an element that belongs to a finite set decreases its cardinality by one.
Finset.card_image_of_injective
The cardinality of the image of a finite set under an injective function equals the cardinality of the original set.
Finset.card_le_card
If s is a subset of t, then |s| ≤ |t|.
Finset.card_pos.mp
A finite set has positive cardinality if and only if it is nonempty.
Finset.card_sdiff_add_card_inter
For finite sets s and t, |s \ t| + |s ∩ t| = |s|.
Finset.disjoint_left.mp
If two sets are disjoint, any element in the first set cannot belong to the second.
Finset.disjoint_left.mpr
If no element of a set s belongs to t, then s and t are disjoint.
Finset.eq_empty_iff_forall_notMem.mpr
If no element belongs to a finite set, then the set is empty.
Finset.inter_subset_right
The intersection s ∩ t is a subset of t.
Finset.mem_erase.mp
If an element belongs to s with a removed, then it belongs to s and is not equal to a.
Finset.mem_erase.mpr
If an element belongs to s and is distinct from a, then it belongs to s with a erased.
Finset.mem_image
An element belongs to the image of a set under a function if and only if it is the image of some element in the set.
Finset.mem_image.mp
If an element belongs to the image of a set under a function, it is the function value of some element in that set.
Finset.mem_image.mpr
If an element is the image of some point in a set, then it belongs to the image of that set.
Finset.mem_inter
An element belongs to the intersection of two sets if and only if it belongs to both.
Finset.mem_inter.mp
If an element belongs to the intersection of two sets, it belongs to both sets.
Finset.mem_sdiff.mp
If an element belongs to s \ t, then it belongs to s and does not belong to t.
Finset.mem_union
An element belongs to the union of two sets if and only if it belongs to at least one of them.
Finset.mem_univ
Every element of a finite type belongs to its universal set Finset.univ.
Finset.sdiff_subset
The set difference s \ t is a subset of s.
Nat.twoStepInduction
Principle of mathematical induction where proving the base cases 0 and 1, and the inductive step from n to n + 2, establishes the result for all natural numbers.
Or.inl
A disjunction holds whenever its left-hand operand holds.
Or.inr
A disjunction holds whenever its right-hand operand holds.
balanced_cut_anticomplete_side_has_cross_matching
In a graph with a 2k-separator condition, any subset U of a balanced cut C of size 2k and any disjoint anticomplete outside set H with |U| ≥ r and |H| ≥ r admit an r-edge matching between U and H.
true_and
The logical conjunction of True and any proposition p is equivalent to p.

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_evenly_distributed_cross_matching    (k 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 U : Finset (Fin (4*k))) (hcard : C.card = 2*k) (hUC : U ⊆ C)    (hU : 2*r ≤ U.card) {I : Type*} [DecidableEq I]    (J : Finset I) (F : I → Finset (Fin (4*k))) (hJ : r+2 ≤ J.card)    (hCH : ∀ i ∈ J, Disjoint C (F i))    (hdis : ∀ i ∈ J, ∀ j ∈ J, i ≠ j → Disjoint (F i) (F j))    (hsize : ∀ i ∈ J, 2 ≤ (F i).card)    (hanti : ∀ i ∈ J, ∀ u ∈ F i, ∀ v, v ∉ C → v ∉ F i → ¬ G.Adj u v) :    ∃ f g : Fin r → Fin (4*k), Function.Injective f ∧ Function.Injective g ∧      (∀ a, f a ∈ U ∧ G.Adj (f a) (g a)) ∧      (∀ a, ∃ i ∈ J, g a ∈ F i) ∧      ∃ B : Finset I, B.card ≤ 1 ∧        ∀ i ∈ J, i ∉ B → Even (((Finset.univ : Finset (Fin r)).image g) ∩ F i).card := by  set_option maxHeartbeats 4000000 in    classical    revert U J    induction r using Nat.twoStepInduction with    | zero =>      intro U hUC hU J hJ hCH hdis hsize hanti      refine ⟨Fin.elim0,Fin.elim0,?_,?_,?_,?_,∅,by simp,?_⟩      · intro x        exact Fin.elim0 x      · intro x        exact Fin.elim0 x      · intro x        exact Fin.elim0 x      · intro x        exact Fin.elim0 x      · intro i hi _        simp    | one =>      intro U hUC hU J hJ hCH hdis hsize hanti      obtain ⟨j,hj⟩ := Finset.card_pos.mp (by omega : 0 < J.card)      obtain ⟨f,g,hf,hg,hfg⟩ :=        balanced_cut_anticomplete_side_has_cross_matching k 1 (by omega) G hsep C (F j) U          hcard (hCH j hj) hUC (hanti j hj) (by omega) (by have := hsize j hj; omega)      refine ⟨f,g,hf,hg,(fun a => ⟨(hfg a).1,(hfg a).2.2⟩),?_,{j},by simp,?_⟩      · intro a        exact ⟨j,hj,(hfg a).2.1⟩      · intro i hi hiB        have hij : i ≠ j := by simpa using hiB        have hnull : ((Finset.univ : Finset (Fin 1)).image g) ∩ F i = ∅ := by          apply Finset.eq_empty_iff_forall_notMem.mpr          intro v hv          obtain ⟨hvg,hvi⟩ := Finset.mem_inter.mp hv          obtain ⟨a,_,rfl⟩ := Finset.mem_image.mp hvg          exact Finset.disjoint_left.mp (hdis i hi j hj hij) hvi (hfg a).2.1        rw [hnull]        simp    | more r ih _ =>      intro U hUC hU J hJ hCH hdis hsize hanti      obtain ⟨j,hj⟩ := Finset.card_pos.mp (by omega : 0 < J.card)      obtain ⟨f0,g0,hf0,hg0,hfg0⟩ :=        balanced_cut_anticomplete_side_has_cross_matching k 2 (by omega) G hsep C (F j) U          hcard (hCH j hj) hUC (hanti j hj) (by omega) (hsize j hj)      let A : Finset (Fin (4*k)) := (Finset.univ : Finset (Fin 2)).image f0      let U' : Finset (Fin (4*k)) := U \ A      let J' : Finset I := J.erase j      have hAcard : A.card = 2 := by        dsimp [A]        rw [Finset.card_image_of_injective _ hf0]        simp      have hUC' : U' ⊆ C := (Finset.sdiff_subset : U' ⊆ U).trans hUC      have hU' : 2*r ≤ U'.card := by        have hh := Finset.card_sdiff_add_card_inter U A        have hh' : (U ∩ A).card ≤ A.card := Finset.card_le_card Finset.inter_subset_right        dsimp [U']        omega      have hJ' : r+2 ≤ J'.card := by        have hh := Finset.card_erase_add_one hj        dsimp [J']        omega      have hCH' : ∀ i ∈ J', Disjoint C (F i) := by        intro i hi        exact hCH i (Finset.mem_erase.mp hi).2      have hdis' : ∀ i ∈ J', ∀ l ∈ J', i ≠ l → Disjoint (F i) (F l) := by        intro i hi l hl hil        exact hdis i (Finset.mem_erase.mp hi).2 l (Finset.mem_erase.mp hl).2 hil      have hsize' : ∀ i ∈ J', 2 ≤ (F i).card := by        intro i hi        exact hsize i (Finset.mem_erase.mp hi).2      have hanti' : ∀ i ∈ J', ∀ u ∈ F i, ∀ v, v ∉ C → v ∉ F i → ¬ G.Adj u v := by        intro i hi        exact hanti i (Finset.mem_erase.mp hi).2      obtain ⟨f,g,hf,hg,hfg,hgroups,B,hB,hpar⟩ :=        ih U' hUC' hU' J' hJ' hCH' hdis' hsize' hanti'      have hfd : ∀ a b, f a ≠ f0 b := by        intro a b he        have hn := (Finset.mem_sdiff.mp (hfg a).1).2        apply hn        dsimp [A]        exact Finset.mem_image.mpr ⟨b,Finset.mem_univ _,he.symm⟩      have hgnot : ∀ a, g a ∉ F j := by        intro a hgj        obtain ⟨i,hi,hgi⟩ := hgroups a        have hne : i ≠ j := (Finset.mem_erase.mp hi).1        exact Finset.disjoint_left.mp (hdis i (Finset.mem_erase.mp hi).2 j hj hne) hgi hgj      have hgd : ∀ a b, g a ≠ g0 b := by        intro a b he        exact hgnot a (he.symm ▸ (hfg0 b).2.1)      let ff := Fin.append f f0      let gg := Fin.append g g0      have hff : Function.Injective ff := Fin.append_injective_iff.mpr ⟨hf,hf0,hfd⟩      have hgg : Function.Injective gg := Fin.append_injective_iff.mpr ⟨hg,hg0,hgd⟩      have hboth : ∀ a, ff a ∈ U ∧ G.Adj (ff a) (gg a) := by        intro a        refine Fin.addCases ?_ ?_ a        · intro b          simpa [ff,gg] using ⟨(Finset.mem_sdiff.mp (hfg b).1).1,(hfg b).2⟩        · intro b          simpa [ff,gg] using ⟨(hfg0 b).1,(hfg0 b).2.2⟩      have hwhere : ∀ a, ∃ i ∈ J, gg a ∈ F i := by        intro a        refine Fin.addCases ?_ ?_ a        · intro b          obtain ⟨i,hi,hgi⟩ := hgroups b          exact ⟨i,(Finset.mem_erase.mp hi).2,by simpa [gg] using hgi⟩        · intro b          exact ⟨j,hj,by simpa [gg] using (hfg0 b).2.1⟩      have himage : ((Finset.univ : Finset (Fin (r+2))).image gg) =          ((Finset.univ : Finset (Fin r)).image g) ∪ ((Finset.univ : Finset (Fin 2)).image g0) := by        ext v        simp only [Finset.mem_image,Finset.mem_univ,true_and,Finset.mem_union]        constructor        · rintro ⟨a,ha⟩          cases a using Fin.addCases with          | left b =>            left            exact ⟨b,by simpa [gg] using ha⟩          | right b =>            right            exact ⟨b,by simpa [gg] using ha⟩        · rintro (⟨b,hb⟩ | ⟨b,hb⟩)          · exact ⟨Fin.castAdd 2 b,by simpa [gg] using hb⟩          · exact ⟨Fin.natAdd r b,by simpa [gg] using hb⟩      refine ⟨ff,gg,hff,hgg,hboth,hwhere,B,hB,?_⟩      intro i hi hiB      rw [himage]      by_cases hij : i = j      · subst i        have hzero : Disjoint ((Finset.univ : Finset (Fin r)).image g) (F j) := by          apply Finset.disjoint_left.mpr          intro v hvg hvj          obtain ⟨a,_,rfl⟩ := Finset.mem_image.mp hvg          exact hgnot a hvj        have hsub : ((Finset.univ : Finset (Fin 2)).image g0) ⊆ F j := by          intro v hv          obtain ⟨a,_,rfl⟩ := Finset.mem_image.mp hv          exact (hfg0 a).2.1        have heq : (((Finset.univ : Finset (Fin r)).image g) ∪            ((Finset.univ : Finset (Fin 2)).image g0)) ∩ F j =              ((Finset.univ : Finset (Fin 2)).image g0) := by          ext v          simp only [Finset.mem_inter,Finset.mem_union]          constructor          · rintro ⟨hv | hv,hvj⟩            · exact False.elim (Finset.disjoint_left.mp hzero hv hvj)            · exact hv          · intro hv            exact ⟨Or.inr hv,hsub hv⟩        rw [heq,Finset.card_image_of_injective _ hg0]        simp      · have hi' : i ∈ J' := Finset.mem_erase.mpr ⟨hij,hi⟩        have hzero : Disjoint ((Finset.univ : Finset (Fin 2)).image g0) (F i) := by          apply Finset.disjoint_left.mpr          intro v hvg hvi          obtain ⟨a,_,rfl⟩ := Finset.mem_image.mp hvg          exact Finset.disjoint_left.mp (hdis i hi j hj hij) hvi (hfg0 a).2.1        have heq : (((Finset.univ : Finset (Fin r)).image g) ∪            ((Finset.univ : Finset (Fin 2)).image g0)) ∩ F i =              ((Finset.univ : Finset (Fin r)).image g) ∩ F i := by          ext v          simp only [Finset.mem_inter,Finset.mem_union]          constructor          · rintro ⟨hv | hv,hvi⟩            · exact ⟨hv,hvi⟩            · exact False.elim (Finset.disjoint_left.mp hzero hv hvi)          · rintro ⟨hv,hvi⟩            exact ⟨Or.inl hv,hvi⟩        rw [heq]        exact hpar i hi' hiB
See it in the graphDiscuss this resultChallenge it