AFTD Auto-Formalizing Theoretical Domains

four_groups_with_double_edge_have_five_matching

theoremverified

Four disjoint vertex groups each containing an edge, one containing two disjoint edges, contain a five-edge matching.

Statement

theorem four_groups_with_double_edge_have_five_matching
    {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)
    (R : Finset V) (F : Fin 4 → Finset V)
    (hsub : ∀ i, F i ⊆ R)
    (hdis : ∀ i j, i ≠ j → Disjoint (F i) (F j))
    (hedge : ∀ i, ∃ a ∈ F i, ∃ b ∈ F i, G.Adj a b)
    (z : Fin 4) (a b c d : V)
    (ha : a ∈ F z) (hb : b ∈ F z) (hc : c ∈ F z) (hd : d ∈ F z)
    (hab : G.Adj a b) (hcd : G.Adj c d)
    (hac : a ≠ c) (had : a ≠ d) (hbc : b ≠ c) (hbd : b ≠ d) :
    ∃ M : G.Subgraph, M.IsMatching ∧ M.verts ⊆ (R : Set V) ∧ M.edgeSet.ncard=5
Source
Balanced-cut k=7 reduction for OP-1957; https://arxiv.org/abs/2611.22690.
Verified
28 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
Used by 1

The proof, explained

We construct a five-edge matching by taking one edge from each of the four disjoint vertex groups F i (choosing {a, b} in group z) and adding the second edge {c, d} from group z. Because the four groups are pairwise disjoint and the two edges in group z share no vertices, all 10 endpoints are distinct. Applying the helper theorem indexed_disjoint_cross_edges_form_matching to these five pairs of endpoints produces a matching of size 5 whose vertices all lie within R.

  1. Define functions f and g on Fin 4 selecting one edge in each of the four groups, choosing the specific edge (a, b) in group z.

    Using the axiom of choice on the hypothesis that every group contains an edge, we obtain edges (a' i, b' i) in each group F i. We define f i and g i to be a and b when i = z, and a' i and b' i otherwise.

    lines 12–16

      set_option maxHeartbeats 4000000 in
        classical
        choose a' ha' b' hb' hab' using hedge
        let f : Fin 4 → V := fun i => if i=z then a else a' i
        let g : Fin 4 → V := fun i => if i=z then b else b' i
  2. For every i, f i and g i belong to F i, and f i is adjacent to g i in G.

    We verify each property by splitting into cases on whether i = z. When i = z, the properties hold by the hypotheses that a, b ∈ F z and G.Adj a b. When i ≠ z, they hold by the properties of the chosen witnesses a' i and b' i.

    lines 17–31

        have hfi : ∀ i, f i ∈ F i := by
          intro i
          by_cases hi : i=z
          · subst i; simpa [f] using ha
          · simpa [f,hi] using ha' i
        have hgi : ∀ i, g i ∈ F i := by
          intro i
          by_cases hi : i=z
          · subst i; simpa [g] using hb
          · simpa [g,hi] using hb' i
        have hfg : ∀ i, G.Adj (f i) (g i) := by
          intro i
          by_cases hi : i=z
          · subst i; simpa [f,g] using hab
          · simpa [f,g,hi] using hab' i
  3. The four edges (f i, g i) are pairwise vertex-disjoint: f and g are injective, and f i ≠ g j for all i, j.

    If f i = f j or g i = g j for i ≠ j, the disjointness of F i and F j yields a contradiction via Finset.disjoint_left.mp. For cross-disjointness f i ≠ g j, if i = j the vertices cannot be equal because they are adjacent in a simple graph (via G.ne_of_adj); if i ≠ j, they belong to disjoint groups F i and F j, so equality is again ruled out by Finset.disjoint_left.mp.

    lines 32–45

    uses Finset.disjoint_left.mp, G.ne_of_adj

        have hf : Function.Injective f := by
          intro i j he
          by_contra hij
          exact Finset.disjoint_left.mp (hdis i j hij) (hfi i) (he.symm ▸ hfi j)
        have hg : Function.Injective g := by
          intro i j he
          by_contra hij
          exact Finset.disjoint_left.mp (hdis i j hij) (hgi i) (he.symm ▸ hgi j)
        have hcross : ∀ i j, f i ≠ g j := by
          intro i j he
          by_cases hij : i=j
          · subst j
            exact G.ne_of_adj (hfg i) he
          · exact Finset.disjoint_left.mp (hdis i j hij) (hfi i) (he.symm ▸ hgi j)
  4. None of the endpoints of the four edges equal c or d: for all i, f i ≠ c, f i ≠ d, g i ≠ c, and g i ≠ d.

    We split into cases on whether i = z. For i = z, f z = a and g z = b are distinct from c and d by the distinctness hypotheses (hac, had, hbc, hbd). For i ≠ z, any vertex in F i is distinct from c, d ∈ F z because F i and F z are disjoint by Finset.disjoint_left.mp.

    lines 46–59

    uses Finset.disjoint_left.mp

        have hforbid : ∀ i, f i ≠ c ∧ f i ≠ d ∧ g i ≠ c ∧ g i ≠ d := by
          intro i
          by_cases hi : i=z
          · subst i
            simpa [f,g] using ⟨hac,had,hbc,hbd⟩
          · have hn : ∀ x ∈ F i, x ≠ c ∧ x ≠ d := by
              intro x hx
              constructor
              · intro he
                exact Finset.disjoint_left.mp (hdis i z hi) hx (he.symm ▸ hc)
              · intro he
                exact Finset.disjoint_left.mp (hdis i z hi) hx (he.symm ▸ hd)
            exact ⟨(hn (f i) (hfi i)).1,(hn (f i) (hfi i)).2,
              (hn (g i) (hgi i)).1,(hn (g i) (hgi i)).2⟩
  5. Extend f and g to Fin 5 by appending c and d respectively, and verify that the extensions ff and gg remain injective.

    We define ff = Fin.snoc f c and gg = Fin.snoc g d. Appending an element not in the range of an injective function preserves injectivity by Fin.snoc_injective_of_injective; the forbidden values established in the previous step ensure c ∉ range f and d ∉ range g.

    lines 60–69

    uses Fin.snoc_injective_of_injective

        let ff : Fin 5 → V := Fin.snoc f c
        let gg : Fin 5 → V := Fin.snoc g d
        have hff : Function.Injective ff := by
          apply Fin.snoc_injective_of_injective hf
          rintro ⟨i,hi⟩
          exact (hforbid i).1 hi
        have hgg : Function.Injective gg := by
          apply Fin.snoc_injective_of_injective hg
          rintro ⟨i,hi⟩
          exact (hforbid i).2.2.2 hi
  6. The five edges (ff i, gg i) are mutually vertex-disjoint (ff i ≠ gg j for all i, j) and each pair is adjacent in G.

    We check each index pair using Fin.lastCases. For indices from Fin 4, Fin.snoc_castSucc reduces the check to the four-edge disjointness and adjacency already shown. When one index is the last element (index 4), Fin.snoc_last evaluates to c or d, and disjointness follows from the previous step's forbidden-value properties. When both indices are 4, ff 4 = c and gg 4 = d are adjacent by hypothesis hcd, which also implies c ≠ d via G.ne_of_adj.

    lines 70–93

    uses Fin.lastCases, Fin.snoc_castSucc, Fin.snoc_last, G.ne_of_adj

        have hcross5 : ∀ i j, ff i ≠ gg j := by
          intro i j
          induction i using Fin.lastCases with
          | cast i =>
            induction j using Fin.lastCases with
            | cast j => simpa [ff,gg] using hcross i j
            | last =>
              simp only [ff,gg,Fin.snoc_castSucc,Fin.snoc_last]
              exact (hforbid i).2.1
          | last =>
            induction j using Fin.lastCases with
            | cast j =>
              simp only [ff,gg,Fin.snoc_castSucc,Fin.snoc_last]
              exact (hforbid j).2.2.1.symm
            | last =>
              change c ≠ d
              exact G.ne_of_adj hcd
        have hadj5 : ∀ i, G.Adj (ff i) (gg i) := by
          intro i
          induction i using Fin.lastCases with
          | cast i => simpa [ff,gg] using hfg i
          | last =>
            change G.Adj c d
            exact hcd
  7. There exists a matching subgraph M of G with 5 edges whose vertices are the range of ff and gg.

    Applying indexed_disjoint_cross_edges_form_matching to the injective, cross-disjoint, pointwise adjacent sequences ff and gg yields a 5-edge matching subgraph M whose vertex set is range ff ∪ range gg.

    line 94

    uses indexed_disjoint_cross_edges_form_matching

        obtain ⟨M,hM,hMcard,hMverts⟩ := indexed_disjoint_cross_edges_form_matching G 5 ff gg hff hgg hcross5 hadj5
  8. The vertices of M are contained in R, completing the proof.

    Every vertex of M is of the form ff i or gg i. By Fin.lastCases, for i < 4 these vertices belong to F i ⊆ R, while for i = 4 they are c or d, which belong to F z ⊆ R. Thus all vertices of M lie in R.

    lines 95–104

    uses Fin.lastCases

        refine ⟨M,hM,?_,hMcard⟩
        intro v hv
        rw [hMverts] at hv
        rcases hv with ⟨i,hi⟩ | ⟨i,hi⟩
        · induction i using Fin.lastCases with
          | cast i => exact hi ▸ hsub i (by simpa [ff] using hfi i)
          | last => exact hi ▸ hsub z hc
        · induction i using Fin.lastCases with
          | cast i => exact hi ▸ hsub i (by simpa [gg] using hgi i)
          | last => exact hi ▸ hsub z hd
Finset.disjoint_left.mp
If two finite sets are disjoint, an element belonging to the first cannot belong to the second.
G.ne_of_adj
In a simple graph, adjacent vertices are distinct.
Fin.snoc_injective_of_injective
Extending an injective function on Fin n by appending a value not in its range yields an injective function on Fin (n + 1).
Fin.lastCases
An element of Fin (n + 1) is either the last element or an embedded element from Fin n.
Fin.snoc_castSucc
Evaluating Fin.snoc p x at an embedded element i from Fin n yields p i.
Fin.snoc_last
Evaluating Fin.snoc p x at the last element yields x.
indexed_disjoint_cross_edges_form_matching
Two injective, mutually disjoint sequences of r vertices that are pairwise adjacent form a matching subgraph of size r spanning their union.

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 four_groups_with_double_edge_have_five_matching    {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)    (R : Finset V) (F : Fin 4 → Finset V)    (hsub : ∀ i, F i ⊆ R)    (hdis : ∀ i j, i ≠ j → Disjoint (F i) (F j))    (hedge : ∀ i, ∃ a ∈ F i, ∃ b ∈ F i, G.Adj a b)    (z : Fin 4) (a b c d : V)    (ha : a ∈ F z) (hb : b ∈ F z) (hc : c ∈ F z) (hd : d ∈ F z)    (hab : G.Adj a b) (hcd : G.Adj c d)    (hac : a ≠ c) (had : a ≠ d) (hbc : b ≠ c) (hbd : b ≠ d) :    ∃ M : G.Subgraph, M.IsMatching ∧ M.verts ⊆ (R : Set V) ∧ M.edgeSet.ncard=5 := by  set_option maxHeartbeats 4000000 in    classical    choose a' ha' b' hb' hab' using hedge    let f : Fin 4 → V := fun i => if i=z then a else a' i    let g : Fin 4 → V := fun i => if i=z then b else b' i    have hfi : ∀ i, f i ∈ F i := by      intro i      by_cases hi : i=z      · subst i; simpa [f] using ha      · simpa [f,hi] using ha' i    have hgi : ∀ i, g i ∈ F i := by      intro i      by_cases hi : i=z      · subst i; simpa [g] using hb      · simpa [g,hi] using hb' i    have hfg : ∀ i, G.Adj (f i) (g i) := by      intro i      by_cases hi : i=z      · subst i; simpa [f,g] using hab      · simpa [f,g,hi] using hab' i    have hf : Function.Injective f := by      intro i j he      by_contra hij      exact Finset.disjoint_left.mp (hdis i j hij) (hfi i) (he.symm ▸ hfi j)    have hg : Function.Injective g := by      intro i j he      by_contra hij      exact Finset.disjoint_left.mp (hdis i j hij) (hgi i) (he.symm ▸ hgi j)    have hcross : ∀ i j, f i ≠ g j := by      intro i j he      by_cases hij : i=j      · subst j        exact G.ne_of_adj (hfg i) he      · exact Finset.disjoint_left.mp (hdis i j hij) (hfi i) (he.symm ▸ hgi j)    have hforbid : ∀ i, f i ≠ c ∧ f i ≠ d ∧ g i ≠ c ∧ g i ≠ d := by      intro i      by_cases hi : i=z      · subst i        simpa [f,g] using ⟨hac,had,hbc,hbd⟩      · have hn : ∀ x ∈ F i, x ≠ c ∧ x ≠ d := by          intro x hx          constructor          · intro he            exact Finset.disjoint_left.mp (hdis i z hi) hx (he.symm ▸ hc)          · intro he            exact Finset.disjoint_left.mp (hdis i z hi) hx (he.symm ▸ hd)        exact ⟨(hn (f i) (hfi i)).1,(hn (f i) (hfi i)).2,          (hn (g i) (hgi i)).1,(hn (g i) (hgi i)).2⟩    let ff : Fin 5 → V := Fin.snoc f c    let gg : Fin 5 → V := Fin.snoc g d    have hff : Function.Injective ff := by      apply Fin.snoc_injective_of_injective hf      rintro ⟨i,hi⟩      exact (hforbid i).1 hi    have hgg : Function.Injective gg := by      apply Fin.snoc_injective_of_injective hg      rintro ⟨i,hi⟩      exact (hforbid i).2.2.2 hi    have hcross5 : ∀ i j, ff i ≠ gg j := by      intro i j      induction i using Fin.lastCases with      | cast i =>        induction j using Fin.lastCases with        | cast j => simpa [ff,gg] using hcross i j        | last =>          simp only [ff,gg,Fin.snoc_castSucc,Fin.snoc_last]          exact (hforbid i).2.1      | last =>        induction j using Fin.lastCases with        | cast j =>          simp only [ff,gg,Fin.snoc_castSucc,Fin.snoc_last]          exact (hforbid j).2.2.1.symm        | last =>          change c ≠ d          exact G.ne_of_adj hcd    have hadj5 : ∀ i, G.Adj (ff i) (gg i) := by      intro i      induction i using Fin.lastCases with      | cast i => simpa [ff,gg] using hfg i      | last =>        change G.Adj c d        exact hcd    obtain ⟨M,hM,hMcard,hMverts⟩ := indexed_disjoint_cross_edges_form_matching G 5 ff gg hff hgg hcross5 hadj5    refine ⟨M,hM,?_,hMcard⟩    intro v hv    rw [hMverts] at hv    rcases hv with ⟨i,hi⟩ | ⟨i,hi⟩    · induction i using Fin.lastCases with      | cast i => exact hi ▸ hsub i (by simpa [ff] using hfi i)      | last => exact hi ▸ hsub z hc    · induction i using Fin.lastCases with      | cast i => exact hi ▸ hsub i (by simpa [gg] using hgi i)      | last => exact hi ▸ hsub z hd
See it in the graphDiscuss this resultChallenge it