AFTD Auto-Formalizing Theoretical Domains

op309_cubic_twentyfour_no_leafclean_p3_forest

theoremverified

No cubic graph on 24 vertices has a totally dominating P3 forest whose leaf boundary edges all meet uncovered vertices.

Statement

theorem op309_cubic_twentyfour_no_leafclean_p3_forest
    (G : SimpleGraph (Fin 24)) [DecidableRel G.Adj] (R : Finset G.edgeSet)
    (hregular : ∀ v, G.degree v = 3)
    (hdom : ∀ e : G.edgeSet, ∃ f ∈ R, G.lineGraph.Adj e f)
    (hbound : ∀ v, (R.filter fun e => v ∈ e.1).card ≤ 2)
    (hpaths : ∀ e ∈ R, ¬ ∃ a b : Fin 24, e.1 = s(a,b) ∧
      (R.filter fun f => a ∈ f.1).card = 2 ∧
      (R.filter fun f => b ∈ f.1).card = 2)
    (hneighbors : ∀ e ∈ R, ∃ f ∈ R, G.lineGraph.Adj e f) :
    ¬ (∀ e : G.edgeSet, e ∉ R →
      (∃ v, v ∈ e.1 ∧ (R.filter fun f => v ∈ f.1).card = 1) →
      ∃ u, u ∈ e.1 ∧ ∀ f ∈ R, u ∉ f.1)
Source
Counting obstruction to universal leaf-clean P3 selection in OP-309; experiment 43701.
Verified
28 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3
Used by 1

The proof, explained

A totally dominating P3-forest R in a 3-regular graph on 24 vertices partitions the vertices into centers C of degree 2, leaves L of degree 1, and uncovered vertices U of degree 0, satisfying 2|C| = |R|, |L| = |R|, and 3|R| + 2|U| = 48, with U being an independent set. If R were leaf-clean, every leaf in L would send its remaining 2 edges to U, forcing the number of edges between V and U, which equals 3|U| by 3-regularity, to satisfy 2|L| <= 3|U| <= 2|L| + |C|. Substituting |L| = |R| and |C| = |R|/2 leaves no integer solution for (|R|, |U|), reaching a contradiction.

  1. H is bipartite with parts C and L.

    Define C, L, U as the sets of vertices of degree 2, 1, 0 in H. Since the maximum degree is at most 2 and no adjacent vertices have equal degree, any edge must connect a vertex of degree 2 to a vertex of degree 1. Therefore, H is bipartite with parts C and L.

    lines 12–31

      classical
      let C : Finset V := Finset.univ.filter fun v => H.degree v = 2
      let L : Finset V := Finset.univ.filter fun v => H.degree v = 1
      let U : Finset V := Finset.univ.filter fun v => H.degree v = 0
      have hdis : Disjoint C L := by
        apply Finset.disjoint_left.mpr
        intro v hvC hvL
        have hc := (Finset.mem_filter.mp hvC).2
        have hl := (Finset.mem_filter.mp hvL).2
        omega
      have hbip : H.IsBipartiteWith (C : Set V) (L : Set V) := by
        refine ⟨Finset.disjoint_coe.mpr hdis, ?_⟩
        intro a b hab
        have ha := hab.degree_pos_left
        have hb := hab.degree_pos_right
        have hba := hbound a
        have hbb := hbound b
        have hne := hdifferent a b hab
        simp only [Finset.mem_coe, C, L, Finset.mem_filter, Finset.mem_univ, true_and]
        omega
  2. 2|C| = |E(H)| and |L| = |E(H)|.

    Summing degrees in C and L in a bipartite graph yields the number of edges. Since all vertices in C have degree 2 and all vertices in L have degree 1, this gives 2|C| = |E(H)| and |L| = |E(H)|.

    lines 32–46

      have hsumC : ∑ v ∈ C, H.degree v = 2 * C.card := by
        calc
          _ = ∑ _v ∈ C, 2 := Finset.sum_congr rfl (fun v hv => (Finset.mem_filter.mp hv).2)
          _ = _ := by simp [Nat.mul_comm]
      have hsumL : ∑ v ∈ L, H.degree v = L.card := by
        calc
          _ = ∑ _v ∈ L, 1 := Finset.sum_congr rfl (fun v hv => (Finset.mem_filter.mp hv).2)
          _ = _ := by simp
      have hedgesC : 2 * C.card = H.edgeFinset.card := by
        rw [← hsumC]
        exact H.isBipartiteWith_sum_degrees_eq_card_edges hbip
      have hedgesL : L.card = H.edgeFinset.card := by
        rw [← hsumL]
        exact H.isBipartiteWith_sum_degrees_eq_card_edges' hbip
      exact ⟨hedgesC, hedgesL⟩
  3. Double-counting edges between S and T.

    Expressing the number of neighbors as a sum of indicators and interchanging summation gives equality of edge counts from S to T and from T to S.

    lines 51–69

      have h1 : ∀ v : V, (G.neighborFinset v ∩ TT).card = ∑ w ∈ TT, if G.Adj v w then 1 else 0 := by
        intro v
        have hvv : (G.neighborFinset v ∩ TT) = TT.filter (fun w => G.Adj v w) := by
          ext w; rw [Finset.mem_inter, Finset.mem_filter, SimpleGraph.mem_neighborFinset]; tauto
        rw [hvv, Finset.card_eq_sum_ones, Finset.sum_filter]
      simp_rw [h1]
      rw [Finset.sum_comm]
      apply Finset.sum_congr rfl
      intro w hw
      have h2 : (G.neighborFinset w ∩ S).card = ∑ v ∈ S, if G.Adj w v then 1 else 0 := by
        have hvv : (G.neighborFinset w ∩ S) = S.filter (fun v => G.Adj w v) := by
          ext v; rw [Finset.mem_inter, Finset.mem_filter, SimpleGraph.mem_neighborFinset]; tauto
        rw [hvv, Finset.card_eq_sum_ones, Finset.sum_filter]
      rw [h2]
      apply Finset.sum_congr rfl
      intro v hv
      by_cases h : G.Adj v w
      · rw [if_pos h, if_pos ((SimpleGraph.adj_comm G v w).mp h)]
      · rw [if_neg h, if_neg (fun hh => h ((SimpleGraph.adj_comm G v w).mpr hh))]
  4. H has maximum degree at most 2 and its edges correspond bijectively to R.

    Assume for contradiction that R is leaf-clean. Construct H from R. Since G has no self-loops, the edge set of H is in bijection with R, and vertex degrees in H are bounded by 2.

    lines 83–105

      classical
      intro hclean
      let H := op309_selected_edge_graph G R
      letI : DecidableRel H.Adj := Classical.decRel _
      have hedges : H.edgeFinset = R.image Subtype.val := by
        ext e
        rw [SimpleGraph.mem_edgeFinset]
        change e ∈ (SimpleGraph.fromEdgeSet (↑(R.image Subtype.val) : Set (Sym2 (Fin 24)))).edgeSet ↔ _
        rw [SimpleGraph.edgeSet_fromEdgeSet]
        constructor
        · intro he
          exact he.1
        · intro he
          obtain ⟨f,hf,hfe⟩ := Finset.mem_image.mp he
          refine ⟨he, ?_⟩
          have hnot := G.not_isDiag_of_mem_edgeSet f.2
          simpa [Sym2.mem_diagSet, ← hfe] using hnot
      have hdegree : ∀ v, H.degree v = (R.filter fun e => v ∈ e.1).card := by
        intro v
        rw [← H.card_incidenceFinset_eq_degree v, H.incidenceFinset_eq_filter, hedges,
          Finset.filter_image]
        exact Finset.card_image_iff.mpr (fun _ _ _ _ h => Subtype.ext h)
      have hHbound : ∀ v, H.degree v ≤ 2 := by intro v; rw [hdegree]; exact hbound v
  5. Adjacent vertices in H have different degrees.

    Two vertices of degree 2 cannot be adjacent by the path condition, and two vertices of degree 1 cannot be adjacent because every edge in R is adjacent to another edge in R.

    lines 106–139

      have hdiff : ∀ a b, H.Adj a b → H.degree a ≠ H.degree b := by
        intro a b hab heq
        have hposA := hab.degree_pos_left
        have hposB := hab.degree_pos_right
        have hbA := hHbound a
        have hbB := hHbound b
        have hp : s(a,b) ∈ R.image Subtype.val := by
          exact ((SimpleGraph.fromEdgeSet_adj (↑(R.image Subtype.val) : Set (Sym2 (Fin 24)))).mp hab).1
        obtain ⟨e,he,heval⟩ := Finset.mem_image.mp hp
        by_cases htwo : H.degree a = 2
        · apply hpaths e he
          exact ⟨a,b,heval, by simpa [hdegree] using htwo,
            by rw [← hdegree b, ← heq]; exact htwo⟩
        · have ha : (R.filter fun f => a ∈ f.1).card = 1 := by rw [← hdegree]; omega
          have hb : (R.filter fun f => b ∈ f.1).card = 1 := by rw [← hdegree]; omega
          obtain ⟨f,hf,hef⟩ := hneighbors e he
          obtain ⟨hne,w,hwe,hwf⟩ := SimpleGraph.lineGraph_adj_iff_exists.mp hef
          have hw : w = a ∨ w = b := by rw [heval, Sym2.mem_iff] at hwe; exact hwe
          rcases hw with hwa | hwb
          · subst w
            have hle : (R.filter fun f => a ∈ f.1).card ≤ 1 := by omega
            have he' : e ∈ R.filter (fun f => a ∈ f.1) := by
              simp [he,heval]
            have hf' : f ∈ R.filter (fun f => a ∈ f.1) := by simp [hf,hwf]
            exact hne ((Finset.card_le_one.mp hle) e he' f hf')
          · subst w
            have hle : (R.filter fun f => b ∈ f.1).card ≤ 1 := by omega
            have he' : e ∈ R.filter (fun f => b ∈ f.1) := by
              simp [he,heval]
            have hf' : f ∈ R.filter (fun f => b ∈ f.1) := by simp [hf,hwf]
            exact hne ((Finset.card_le_one.mp hle) e he' f hf')
      have hc : H.edgeFinset.card = R.card := by
        rw [hedges]
        exact Finset.card_image_iff.mpr (fun _ _ _ _ h => Subtype.ext h)
  6. Degree counts and independence of U.

    Applying the first lemma gives 2|C| = |R| and |L| = |R|. The P3-forest count formula gives 3|R| + 2|U| = 48. Total edge domination implies U is an independent set in G.

    lines 140–156

      let d : Fin 24 → ℕ := fun v => (R.filter fun e => v ∈ e.1).card
      let U : Finset (Fin 24) := Finset.univ.filter fun v => d v = 0
      let L : Finset (Fin 24) := Finset.univ.filter fun v => d v = 1
      let C : Finset (Fin 24) := Finset.univ.filter fun v => d v = 2
      have hcounts : 2 * C.card = R.card ∧ L.card = R.card := by
        simpa only [hdegree, hc, C, L, d] using in1280_leafclean_degree_counts H hHbound hdiff
      have hnum : 3 * R.card + 2 * U.card = 48 := by
        simpa [U, d] using op309_p3_forest_selected_edge_count G R hbound hpaths hneighbors
      have hzero : ∀ v, d v = 0 ↔ ∀ e ∈ R, v ∉ e.1 := by
        intro v
        simp only [d, Finset.card_eq_zero, Finset.eq_empty_iff_forall_notMem,
          Finset.mem_filter, not_and]
      have hU : ∀ v, v ∈ U ↔ d v = 0 := by intro v; simp [U]
      have hind : ∀ v w, v ∈ U → w ∈ U → ¬ G.Adj v w := by
        intro v w hv hw
        exact ((op309_total_edge_dom_iff_independent_uncovered_and_no_isolated G R).mp hdom).1 v w
          ((hzero v).mp ((hU v).mp hv)) ((hzero w).mp ((hU w).mp hw))
  7. Neighbors of leaves in G belong to H or U.

    By the leaf-clean assumption, any edge in G incident to a leaf in L either belongs to H or has its other endpoint in U.

    lines 157–197

      have hHA : ∀ v w, H.Adj v w ↔ ∃ e ∈ R, e.1 = s(v,w) := by
        intro v w
        change (SimpleGraph.fromEdgeSet (↑(R.image Subtype.val) : Set (Sym2 (Fin 24)))).Adj v w ↔ _
        rw [SimpleGraph.fromEdgeSet_adj]
        constructor
        · intro h
          obtain ⟨e,he,heq⟩ := Finset.mem_image.mp h.1
          exact ⟨e,he,heq⟩
        · rintro ⟨e,he,heq⟩
          refine ⟨Finset.mem_image.mpr ⟨e,he,heq⟩, ?_⟩
          intro hvw
          have hg : G.Adj v w := (G.mem_edgeSet).mp (heq ▸ e.2)
          exact hg.ne hvw
      have hG : ∀ v w, H.Adj v w → G.Adj v w := by
        intro v w h
        obtain ⟨e,he,heq⟩ := (hHA v w).mp h
        exact (G.mem_edgeSet).mp (heq ▸ e.2)
      have hsel : ∀ v w, H.Adj v w → w ∉ U := by
        intro v w h hw
        obtain ⟨e,he,heq⟩ := (hHA v w).mp h
        have hw' := (hzero w).mp ((hU w).mp hw) e he
        apply hw'
        rw [heq]
        exact Sym2.mem_mk_right v w
      have hcover : ∀ v w, d v = 1 → G.Adj v w → H.Adj v w ∨ w ∈ U := by
        intro v w hv hg
        by_cases hs : H.Adj v w
        · exact Or.inl hs
        · right
          let e : G.edgeSet := ⟨s(v,w), (G.mem_edgeSet).mpr hg⟩
          have he : e ∉ R := by
            intro he
            exact hs ((hHA v w).mpr ⟨e,he,rfl⟩)
          obtain ⟨u,hu,hun⟩ := hclean e he ⟨v, Sym2.mem_mk_left v w, hv⟩
          have hu' : u = v ∨ u = w := by simpa [e, Sym2.mem_iff] using hu
          rcases hu' with hvu | hwu
          · rw [hvu] at hun
            have : d v = 0 := (hzero v).mpr hun
            omega
          · rw [hwu] at hun
            exact (hU w).mpr ((hzero w).mpr hun)
  8. Degree of leaves, centers, and uncovered vertices into U.

    Each leaf in L has 1 neighbor in H and therefore exactly 2 neighbors in U. Vertices in C have at most 1 neighbor in U, and vertices in U have 0 neighbors in U because U is independent.

    lines 198–234

      have hdis : ∀ v, Disjoint (H.neighborFinset v) (G.neighborFinset v ∩ U) := by
        intro v
        apply Finset.disjoint_left.mpr
        intro w hw1 hw2
        exact hsel v w ((SimpleGraph.mem_neighborFinset H v w).mp hw1) (Finset.mem_inter.mp hw2).2
      have hunion : ∀ v, H.neighborFinset v ∪ (G.neighborFinset v ∩ U) ⊆ G.neighborFinset v := by
        intro v w hw
        rcases Finset.mem_union.mp hw with hw | hw
        · exact (SimpleGraph.mem_neighborFinset G v w).mpr (hG v w ((SimpleGraph.mem_neighborFinset H v w).mp hw))
        · exact (Finset.mem_inter.mp hw).1
      have hboundU : ∀ v, d v + (G.neighborFinset v ∩ U).card ≤ 3 := by
        intro v
        have hh := Finset.card_le_card (hunion v)
        rw [Finset.card_union_of_disjoint (hdis v), SimpleGraph.card_neighborFinset_eq_degree,
          hdegree, SimpleGraph.card_neighborFinset_eq_degree, hregular] at hh
        exact hh
      have hleaf : ∀ v, d v = 1 → (G.neighborFinset v ∩ U).card = 2 := by
        intro v hv
        have heq : H.neighborFinset v ∪ (G.neighborFinset v ∩ U) = G.neighborFinset v := by
          apply Finset.Subset.antisymm (hunion v)
          intro w hw
          have hg := (SimpleGraph.mem_neighborFinset G v w).mp hw
          rcases hcover v w hv hg with hs | hu
          · exact Finset.mem_union_left _ ((SimpleGraph.mem_neighborFinset H v w).mpr hs)
          · exact Finset.mem_union_right _ (Finset.mem_inter.mpr ⟨hw,hu⟩)
        have hh := congrArg Finset.card heq
        rw [Finset.card_union_of_disjoint (hdis v), SimpleGraph.card_neighborFinset_eq_degree,
          hdegree, SimpleGraph.card_neighborFinset_eq_degree, hregular] at hh
        change d v + _ = _ at hh
        omega
      have hzeroU : ∀ v, d v = 0 → (G.neighborFinset v ∩ U).card = 0 := by
        intro v hv
        apply Finset.card_eq_zero.mpr
        apply Finset.eq_empty_iff_forall_notMem.mpr
        intro w hw
        exact hind v w ((hU v).mpr hv) (Finset.mem_inter.mp hw).2
          ((SimpleGraph.mem_neighborFinset G v w).mp (Finset.mem_inter.mp hw).1)
  9. Double counting edges to U gives bounds on 3|U|.

    Double-counting edges between V and U gives 3|U|. Summing the pointwise bounds over V gives 2|L| <= 3|U| <= 2|L| + |C|.

    lines 235–272

      let n : Fin 24 → ℕ := fun v => (G.neighborFinset v ∩ U).card
      have hsumn : ∑ v, n v = 3 * U.card := by
        have hh := in1280_leafclean_neighbor_sum_comm
          G Finset.univ U
        change (∑ v ∈ Finset.univ, n v) = _ at hh
        calc
          _ = ∑ v ∈ U, (G.neighborFinset v ∩ Finset.univ).card := hh
          _ = ∑ _v ∈ U, 3 := by
            apply Finset.sum_congr rfl
            intro v hv
            simp [SimpleGraph.card_neighborFinset_eq_degree, hregular]
          _ = _ := by simp [Nat.mul_comm]
      have hlower : ∀ v, (if d v = 1 then 2 else 0) ≤ n v := by
        intro v
        split_ifs with hv
        · simp [n, hleaf v hv]
        · omega
      have hupper : ∀ v, n v ≤ (if d v = 1 then 2 else if d v = 2 then 1 else 0) := by
        intro v
        have hb := hbound v
        have hu := hboundU v
        change d v + n v ≤ 3 at hu
        by_cases h1 : d v = 1
        · simp [h1, n, hleaf v h1]
        · by_cases h2 : d v = 2
          · simp [h1, h2]; omega
          · have h0 : d v = 0 := by change d v ≤ 2 at hb; omega
            simp [h1, h2, n, hzeroU v h0]
      have hsumL : (∑ v : Fin 24, if d v = 1 then 2 else 0) = 2 * L.card := by
        simp [L, ← Finset.sum_filter, Nat.mul_comm]
      have hsumC : (∑ v : Fin 24, if d v = 1 then 2 else if d v = 2 then 1 else 0) =
          2 * L.card + C.card := by
        have eq : ∀ v : Fin 24, (if d v = 1 then 2 else if d v = 2 then 1 else 0) =
            (if d v = 1 then 2 else 0) + (if d v = 2 then 1 else 0) := by
          intro v; split_ifs <;> omega
        simp_rw [eq, Finset.sum_add_distrib]
        rw [hsumL]
        simp [C, ← Finset.sum_filter]
  10. Contradiction by linear arithmetic.

    Combining 2|L| <= 3|U| <= 2|L| + |C| with 2|C| = |R|, |L| = |R|, and 3|R| + 2|U| = 48 yields no integer solutions.

    lines 273–277

      have hlo := Finset.sum_le_sum (fun v (_ : v ∈ Finset.univ) => hlower v)
      have hhi := Finset.sum_le_sum (fun v (_ : v ∈ Finset.univ) => hupper v)
      rw [hsumL, hsumn] at hlo
      rw [hsumn, hsumC] at hhi
      omega

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

set_option maxRecDepth 4096set_option maxHeartbeats 4000000open scoped BigOperatorsprivate theorem in1280_leafclean_degree_counts    {V : Type*} [Fintype V] [DecidableEq V]    (H : SimpleGraph V) [DecidableRel H.Adj]    (hbound : ∀ v, H.degree v ≤ 2)    (hdifferent : ∀ a b, H.Adj a b → H.degree a ≠ H.degree b) :    2 * ((Finset.univ : Finset V).filter fun v => H.degree v = 2).card = H.edgeFinset.card ∧    ((Finset.univ : Finset V).filter fun v => H.degree v = 1).card = H.edgeFinset.card := by  classical  let C : Finset V := Finset.univ.filter fun v => H.degree v = 2  let L : Finset V := Finset.univ.filter fun v => H.degree v = 1  let U : Finset V := Finset.univ.filter fun v => H.degree v = 0  have hdis : Disjoint C L := by    apply Finset.disjoint_left.mpr    intro v hvC hvL    have hc := (Finset.mem_filter.mp hvC).2    have hl := (Finset.mem_filter.mp hvL).2    omega  have hbip : H.IsBipartiteWith (C : Set V) (L : Set V) := by    refine ⟨Finset.disjoint_coe.mpr hdis, ?_⟩    intro a b hab    have ha := hab.degree_pos_left    have hb := hab.degree_pos_right    have hba := hbound a    have hbb := hbound b    have hne := hdifferent a b hab    simp only [Finset.mem_coe, C, L, Finset.mem_filter, Finset.mem_univ, true_and]    omega  have hsumC : ∑ v ∈ C, H.degree v = 2 * C.card := by    calc      _ = ∑ _v ∈ C, 2 := Finset.sum_congr rfl (fun v hv => (Finset.mem_filter.mp hv).2)      _ = _ := by simp [Nat.mul_comm]  have hsumL : ∑ v ∈ L, H.degree v = L.card := by    calc      _ = ∑ _v ∈ L, 1 := Finset.sum_congr rfl (fun v hv => (Finset.mem_filter.mp hv).2)      _ = _ := by simp  have hedgesC : 2 * C.card = H.edgeFinset.card := by    rw [← hsumC]    exact H.isBipartiteWith_sum_degrees_eq_card_edges hbip  have hedgesL : L.card = H.edgeFinset.card := by    rw [← hsumL]    exact H.isBipartiteWith_sum_degrees_eq_card_edges' hbip  exact ⟨hedgesC, hedgesL⟩private lemma in1280_leafclean_neighbor_sum_comm {V : Type*} [Fintype V] [DecidableEq V]    (G : SimpleGraph V) [DecidableRel G.Adj] (S TT : Finset V) :    ∑ v ∈ S, (G.neighborFinset v ∩ TT).card = ∑ w ∈ TT, (G.neighborFinset w ∩ S).card := by  have h1 : ∀ v : V, (G.neighborFinset v ∩ TT).card = ∑ w ∈ TT, if G.Adj v w then 1 else 0 := by    intro v    have hvv : (G.neighborFinset v ∩ TT) = TT.filter (fun w => G.Adj v w) := by      ext w; rw [Finset.mem_inter, Finset.mem_filter, SimpleGraph.mem_neighborFinset]; tauto    rw [hvv, Finset.card_eq_sum_ones, Finset.sum_filter]  simp_rw [h1]  rw [Finset.sum_comm]  apply Finset.sum_congr rfl  intro w hw  have h2 : (G.neighborFinset w ∩ S).card = ∑ v ∈ S, if G.Adj w v then 1 else 0 := by    have hvv : (G.neighborFinset w ∩ S) = S.filter (fun v => G.Adj w v) := by      ext v; rw [Finset.mem_inter, Finset.mem_filter, SimpleGraph.mem_neighborFinset]; tauto    rw [hvv, Finset.card_eq_sum_ones, Finset.sum_filter]  rw [h2]  apply Finset.sum_congr rfl  intro v hv  by_cases h : G.Adj v w  · rw [if_pos h, if_pos ((SimpleGraph.adj_comm G v w).mp h)]  · rw [if_neg h, if_neg (fun hh => h ((SimpleGraph.adj_comm G v w).mpr hh))]theorem op309_cubic_twentyfour_no_leafclean_p3_forest    (G : SimpleGraph (Fin 24)) [DecidableRel G.Adj] (R : Finset G.edgeSet)    (hregular : ∀ v, G.degree v = 3)    (hdom : ∀ e : G.edgeSet, ∃ f ∈ R, G.lineGraph.Adj e f)    (hbound : ∀ v, (R.filter fun e => v ∈ e.1).card ≤ 2)    (hpaths : ∀ e ∈ R, ¬ ∃ a b : Fin 24, e.1 = s(a,b) ∧      (R.filter fun f => a ∈ f.1).card = 2 ∧      (R.filter fun f => b ∈ f.1).card = 2)    (hneighbors : ∀ e ∈ R, ∃ f ∈ R, G.lineGraph.Adj e f) :    ¬ (∀ e : G.edgeSet, e ∉ R →      (∃ v, v ∈ e.1 ∧ (R.filter fun f => v ∈ f.1).card = 1) →      ∃ u, u ∈ e.1 ∧ ∀ f ∈ R, u ∉ f.1) := by  classical  intro hclean  let H := op309_selected_edge_graph G R  letI : DecidableRel H.Adj := Classical.decRel _  have hedges : H.edgeFinset = R.image Subtype.val := by    ext e    rw [SimpleGraph.mem_edgeFinset]    change e ∈ (SimpleGraph.fromEdgeSet (↑(R.image Subtype.val) : Set (Sym2 (Fin 24)))).edgeSet ↔ _    rw [SimpleGraph.edgeSet_fromEdgeSet]    constructor    · intro he      exact he.1    · intro he      obtain ⟨f,hf,hfe⟩ := Finset.mem_image.mp he      refine ⟨he, ?_⟩      have hnot := G.not_isDiag_of_mem_edgeSet f.2      simpa [Sym2.mem_diagSet, ← hfe] using hnot  have hdegree : ∀ v, H.degree v = (R.filter fun e => v ∈ e.1).card := by    intro v    rw [← H.card_incidenceFinset_eq_degree v, H.incidenceFinset_eq_filter, hedges,      Finset.filter_image]    exact Finset.card_image_iff.mpr (fun _ _ _ _ h => Subtype.ext h)  have hHbound : ∀ v, H.degree v ≤ 2 := by intro v; rw [hdegree]; exact hbound v  have hdiff : ∀ a b, H.Adj a b → H.degree a ≠ H.degree b := by    intro a b hab heq    have hposA := hab.degree_pos_left    have hposB := hab.degree_pos_right    have hbA := hHbound a    have hbB := hHbound b    have hp : s(a,b) ∈ R.image Subtype.val := by      exact ((SimpleGraph.fromEdgeSet_adj (↑(R.image Subtype.val) : Set (Sym2 (Fin 24)))).mp hab).1    obtain ⟨e,he,heval⟩ := Finset.mem_image.mp hp    by_cases htwo : H.degree a = 2    · apply hpaths e he      exact ⟨a,b,heval, by simpa [hdegree] using htwo,        by rw [← hdegree b, ← heq]; exact htwo⟩    · have ha : (R.filter fun f => a ∈ f.1).card = 1 := by rw [← hdegree]; omega      have hb : (R.filter fun f => b ∈ f.1).card = 1 := by rw [← hdegree]; omega      obtain ⟨f,hf,hef⟩ := hneighbors e he      obtain ⟨hne,w,hwe,hwf⟩ := SimpleGraph.lineGraph_adj_iff_exists.mp hef      have hw : w = a ∨ w = b := by rw [heval, Sym2.mem_iff] at hwe; exact hwe      rcases hw with hwa | hwb      · subst w        have hle : (R.filter fun f => a ∈ f.1).card ≤ 1 := by omega        have he' : e ∈ R.filter (fun f => a ∈ f.1) := by          simp [he,heval]        have hf' : f ∈ R.filter (fun f => a ∈ f.1) := by simp [hf,hwf]        exact hne ((Finset.card_le_one.mp hle) e he' f hf')      · subst w        have hle : (R.filter fun f => b ∈ f.1).card ≤ 1 := by omega        have he' : e ∈ R.filter (fun f => b ∈ f.1) := by          simp [he,heval]        have hf' : f ∈ R.filter (fun f => b ∈ f.1) := by simp [hf,hwf]        exact hne ((Finset.card_le_one.mp hle) e he' f hf')  have hc : H.edgeFinset.card = R.card := by    rw [hedges]    exact Finset.card_image_iff.mpr (fun _ _ _ _ h => Subtype.ext h)  let d : Fin 24 → ℕ := fun v => (R.filter fun e => v ∈ e.1).card  let U : Finset (Fin 24) := Finset.univ.filter fun v => d v = 0  let L : Finset (Fin 24) := Finset.univ.filter fun v => d v = 1  let C : Finset (Fin 24) := Finset.univ.filter fun v => d v = 2  have hcounts : 2 * C.card = R.card ∧ L.card = R.card := by    simpa only [hdegree, hc, C, L, d] using in1280_leafclean_degree_counts H hHbound hdiff  have hnum : 3 * R.card + 2 * U.card = 48 := by    simpa [U, d] using op309_p3_forest_selected_edge_count G R hbound hpaths hneighbors  have hzero : ∀ v, d v = 0 ↔ ∀ e ∈ R, v ∉ e.1 := by    intro v    simp only [d, Finset.card_eq_zero, Finset.eq_empty_iff_forall_notMem,      Finset.mem_filter, not_and]  have hU : ∀ v, v ∈ U ↔ d v = 0 := by intro v; simp [U]  have hind : ∀ v w, v ∈ U → w ∈ U → ¬ G.Adj v w := by    intro v w hv hw    exact ((op309_total_edge_dom_iff_independent_uncovered_and_no_isolated G R).mp hdom).1 v w      ((hzero v).mp ((hU v).mp hv)) ((hzero w).mp ((hU w).mp hw))  have hHA : ∀ v w, H.Adj v w ↔ ∃ e ∈ R, e.1 = s(v,w) := by    intro v w    change (SimpleGraph.fromEdgeSet (↑(R.image Subtype.val) : Set (Sym2 (Fin 24)))).Adj v w ↔ _    rw [SimpleGraph.fromEdgeSet_adj]    constructor    · intro h      obtain ⟨e,he,heq⟩ := Finset.mem_image.mp h.1      exact ⟨e,he,heq⟩    · rintro ⟨e,he,heq⟩      refine ⟨Finset.mem_image.mpr ⟨e,he,heq⟩, ?_⟩      intro hvw      have hg : G.Adj v w := (G.mem_edgeSet).mp (heq ▸ e.2)      exact hg.ne hvw  have hG : ∀ v w, H.Adj v w → G.Adj v w := by    intro v w h    obtain ⟨e,he,heq⟩ := (hHA v w).mp h    exact (G.mem_edgeSet).mp (heq ▸ e.2)  have hsel : ∀ v w, H.Adj v w → w ∉ U := by    intro v w h hw    obtain ⟨e,he,heq⟩ := (hHA v w).mp h    have hw' := (hzero w).mp ((hU w).mp hw) e he    apply hw'    rw [heq]    exact Sym2.mem_mk_right v w  have hcover : ∀ v w, d v = 1 → G.Adj v w → H.Adj v w ∨ w ∈ U := by    intro v w hv hg    by_cases hs : H.Adj v w    · exact Or.inl hs    · right      let e : G.edgeSet := ⟨s(v,w), (G.mem_edgeSet).mpr hg⟩      have he : e ∉ R := by        intro he        exact hs ((hHA v w).mpr ⟨e,he,rfl⟩)      obtain ⟨u,hu,hun⟩ := hclean e he ⟨v, Sym2.mem_mk_left v w, hv⟩      have hu' : u = v ∨ u = w := by simpa [e, Sym2.mem_iff] using hu      rcases hu' with hvu | hwu      · rw [hvu] at hun        have : d v = 0 := (hzero v).mpr hun        omega      · rw [hwu] at hun        exact (hU w).mpr ((hzero w).mpr hun)  have hdis : ∀ v, Disjoint (H.neighborFinset v) (G.neighborFinset v ∩ U) := by    intro v    apply Finset.disjoint_left.mpr    intro w hw1 hw2    exact hsel v w ((SimpleGraph.mem_neighborFinset H v w).mp hw1) (Finset.mem_inter.mp hw2).2  have hunion : ∀ v, H.neighborFinset v ∪ (G.neighborFinset v ∩ U) ⊆ G.neighborFinset v := by    intro v w hw    rcases Finset.mem_union.mp hw with hw | hw    · exact (SimpleGraph.mem_neighborFinset G v w).mpr (hG v w ((SimpleGraph.mem_neighborFinset H v w).mp hw))    · exact (Finset.mem_inter.mp hw).1  have hboundU : ∀ v, d v + (G.neighborFinset v ∩ U).card ≤ 3 := by    intro v    have hh := Finset.card_le_card (hunion v)    rw [Finset.card_union_of_disjoint (hdis v), SimpleGraph.card_neighborFinset_eq_degree,      hdegree, SimpleGraph.card_neighborFinset_eq_degree, hregular] at hh    exact hh  have hleaf : ∀ v, d v = 1 → (G.neighborFinset v ∩ U).card = 2 := by    intro v hv    have heq : H.neighborFinset v ∪ (G.neighborFinset v ∩ U) = G.neighborFinset v := by      apply Finset.Subset.antisymm (hunion v)      intro w hw      have hg := (SimpleGraph.mem_neighborFinset G v w).mp hw      rcases hcover v w hv hg with hs | hu      · exact Finset.mem_union_left _ ((SimpleGraph.mem_neighborFinset H v w).mpr hs)      · exact Finset.mem_union_right _ (Finset.mem_inter.mpr ⟨hw,hu⟩)    have hh := congrArg Finset.card heq    rw [Finset.card_union_of_disjoint (hdis v), SimpleGraph.card_neighborFinset_eq_degree,      hdegree, SimpleGraph.card_neighborFinset_eq_degree, hregular] at hh    change d v + _ = _ at hh    omega  have hzeroU : ∀ v, d v = 0 → (G.neighborFinset v ∩ U).card = 0 := by    intro v hv    apply Finset.card_eq_zero.mpr    apply Finset.eq_empty_iff_forall_notMem.mpr    intro w hw    exact hind v w ((hU v).mpr hv) (Finset.mem_inter.mp hw).2      ((SimpleGraph.mem_neighborFinset G v w).mp (Finset.mem_inter.mp hw).1)  let n : Fin 24 → ℕ := fun v => (G.neighborFinset v ∩ U).card  have hsumn : ∑ v, n v = 3 * U.card := by    have hh := in1280_leafclean_neighbor_sum_comm      G Finset.univ U    change (∑ v ∈ Finset.univ, n v) = _ at hh    calc      _ = ∑ v ∈ U, (G.neighborFinset v ∩ Finset.univ).card := hh      _ = ∑ _v ∈ U, 3 := by        apply Finset.sum_congr rfl        intro v hv        simp [SimpleGraph.card_neighborFinset_eq_degree, hregular]      _ = _ := by simp [Nat.mul_comm]  have hlower : ∀ v, (if d v = 1 then 2 else 0) ≤ n v := by    intro v    split_ifs with hv    · simp [n, hleaf v hv]    · omega  have hupper : ∀ v, n v ≤ (if d v = 1 then 2 else if d v = 2 then 1 else 0) := by    intro v    have hb := hbound v    have hu := hboundU v    change d v + n v ≤ 3 at hu    by_cases h1 : d v = 1    · simp [h1, n, hleaf v h1]    · by_cases h2 : d v = 2      · simp [h1, h2]; omega      · have h0 : d v = 0 := by change d v ≤ 2 at hb; omega        simp [h1, h2, n, hzeroU v h0]  have hsumL : (∑ v : Fin 24, if d v = 1 then 2 else 0) = 2 * L.card := by    simp [L, ← Finset.sum_filter, Nat.mul_comm]  have hsumC : (∑ v : Fin 24, if d v = 1 then 2 else if d v = 2 then 1 else 0) =      2 * L.card + C.card := by    have eq : ∀ v : Fin 24, (if d v = 1 then 2 else if d v = 2 then 1 else 0) =        (if d v = 1 then 2 else 0) + (if d v = 2 then 1 else 0) := by      intro v; split_ifs <;> omega    simp_rw [eq, Finset.sum_add_distrib]    rw [hsumL]    simp [C, ← Finset.sum_filter]  have hlo := Finset.sum_le_sum (fun v (_ : v ∈ Finset.univ) => hlower v)  have hhi := Finset.sum_le_sum (fun v (_ : v ∈ Finset.univ) => hupper v)  rw [hsumL, hsumn] at hlo  rw [hsumn, hsumC] at hhi  omega
See it in the graphDiscuss this resultChallenge it