AFTD Auto-Formalizing Theoretical Domains

op309_subcubic_host_mate_six_clique_forces_k4

theoremverified

In a loopless host multigraph of maximum degree three, add a perfect matching between disjoint host edges. Any six classes that are pairwise adjacent by a shared host or the matching form the six edges of an isolated four-host complete component.

Statement

theorem op309_subcubic_host_mate_six_clique_forces_k4
    {U X : Type*} [Fintype U] [DecidableEq U] [Fintype X] [DecidableEq X]
    (a b : X → U) (mate : X → X)
    (hends : ∀ x, a x ≠ b x)
    (hinvolution : ∀ x, mate (mate x) = x)
    (hmate : ∀ x, mate x ≠ x ∧ a x ≠ a (mate x) ∧
      a x ≠ b (mate x) ∧ b x ≠ a (mate x) ∧ b x ≠ b (mate x))
    (hdegree : ∀ u, ((Finset.univ : Finset X).filter
      fun x => a x = u ∨ b x = u).card ≤ 3)
    (f : Fin 6 → X) (hf : Function.Injective f)
    (hclique : ∀ i j, i ≠ j →
      a (f i) = a (f j) ∨ a (f i) = b (f j) ∨
      b (f i) = a (f j) ∨ b (f i) = b (f j) ∨ f j = mate (f i)) :
    ∃ S : Finset U, S.card = 4 ∧
      (∀ i, a (f i) ∈ S ∧ b (f i) ∈ S) ∧
      ∀ u ∈ S, ∀ v ∈ S, u ≠ v →
        ∃! i : Fin 6, (a (f i) = u ∧ b (f i) = v) ∨
          (a (f i) = v ∧ b (f i) = u)
Source
Host-multigraph saturation step in the OP-309 equality-forest port argument; experiments 40887 and 43718.
Verified
28 Nov 2026
Axioms
Classical.choiceQuot.soundpropext

The proof, explained

In any subcubic host graph with disjoint matching edges, six edges forming a clique under host-sharing and matching adjacency must have their neighbors partitioned: at most two other edges can share either endpoint, capping the host-sharing neighbors at four and forcing each edge to have exactly one matching mate and two sharing edges at each endpoint. This saturates the host degree at three for every endpoint and ensures that no edges outside the clique are incident to them. A double-counting handshaking argument on host incidences then shows that the total set of endpoints has size 12 / 3 = 4. Finally, since no two clique edges share both endpoints, the three edges incident to each vertex connect to all three other vertices, spanning a complete graph K4 on four host vertices.

  1. For each host vertex u, the set of incident host edges inc(u) has cardinality at most 3.

    We define the incidence set inc(u) to be the host edges having u as an endpoint (a(x) = u or b(x) = u), and rephrase the maximum host degree bound directly as |inc(u)| ≤ 3.

    lines 19–23

      classical
      let inc : U → Finset X := fun u => (Finset.univ : Finset X).filter (fun x => a x = u ∨ b x = u)
      have mem_inc : ∀ (x : X) (u : U), x ∈ inc u ↔ (a x = u ∨ b x = u) := by
        intro x u; simp [inc]
      have hinc_le : ∀ u, (inc u).card ≤ 3 := fun u => hdegree u
  2. For each clique edge f(i), at most one other clique edge is its matching mate.

    We classify any edge f(j) adjacent to f(i) in the clique graph as either sharing an endpoint (Sh(i), subdivided into Pt(i) for endpoint a(f(i)) and Pb(i) for endpoint b(f(i))) or being mated with f(i) (Mt(i)). Since f is injective, at most one index j can satisfy f(j) = mate(f(i)), so |Mt(i)| ≤ 1.

    lines 24–44

    uses Finset.card_le_one

      let Sh : Fin 6 → Finset (Fin 6) := fun i => Finset.univ.filter fun j =>
        j ≠ i ∧ (a (f i) = a (f j) ∨ a (f i) = b (f j) ∨ b (f i) = a (f j) ∨ b (f i) = b (f j))
      let Mt : Fin 6 → Finset (Fin 6) := fun i => Finset.univ.filter fun j => f j = mate (f i)
      let Pt : Fin 6 → Finset (Fin 6) := fun i => (Finset.univ.erase i).filter fun j =>
        a (f j) = a (f i) ∨ b (f j) = a (f i)
      let Pb : Fin 6 → Finset (Fin 6) := fun i => (Finset.univ.erase i).filter fun j =>
        a (f j) = b (f i) ∨ b (f j) = b (f i)
      have memSh : ∀ i j, j ∈ Sh i ↔ j ≠ i ∧ (a (f i) = a (f j) ∨ a (f i) = b (f j) ∨ b (f i) = a (f j) ∨ b (f i) = b (f j)) := by
        intro i j; simp [Sh]
      have memMt : ∀ i j, j ∈ Mt i ↔ f j = mate (f i) := by
        intro i j; simp [Mt]
      have memPt : ∀ i j, j ∈ Pt i ↔ j ≠ i ∧ (a (f j) = a (f i) ∨ b (f j) = a (f i)) := by
        intro i j; simp [Pt]
      have memPb : ∀ i j, j ∈ Pb i ↔ j ≠ i ∧ (a (f j) = b (f i) ∨ b (f j) = b (f i)) := by
        intro i j; simp [Pb]
      have hMt_le : ∀ i, (Mt i).card ≤ 1 := by
        intro i
        rw [Finset.card_le_one]
        intro j hj k hk
        rw [memMt] at hj hk
        exact hf (hj.trans hk.symm)
  3. For each edge f(i), the other 5 clique edges are partitioned into those sharing a host endpoint (Sh(i)) and its mate (Mt(i)).

    By the clique hypothesis, any distinct f(j) must share a host endpoint or be the mate of f(i), so Sh(i) ∪ Mt(i) covers all 5 other indices. Since matched edges share no endpoints by the matching assumption (hmate), Sh(i) and Mt(i) are disjoint.

    lines 45–68

    uses Finset.mem_union, Finset.mem_erase, Finset.mem_univ, and_true, Finset.disjoint_left

      have hUnion : ∀ i, Sh i ∪ Mt i = Finset.univ.erase i := by
        intro i; ext j
        simp only [Finset.mem_union, memSh, memMt, Finset.mem_erase, Finset.mem_univ, and_true]
        constructor
        · rintro (⟨hji, -⟩ | hj)
          · exact hji
          · refine fun h => ?_
            rw [h] at hj
            exact (hmate (f i)).1 hj.symm
        · intro hji
          rcases hclique i j (fun h => hji h.symm) with hs | hs | hs | hs | hm
          · exact Or.inl ⟨hji, Or.inl hs⟩
          · exact Or.inl ⟨hji, Or.inr (Or.inl hs)⟩
          · exact Or.inl ⟨hji, Or.inr (Or.inr (Or.inl hs))⟩
          · exact Or.inl ⟨hji, Or.inr (Or.inr (Or.inr hs))⟩
          · exact Or.inr hm
      have hDisj : ∀ i, Disjoint (Sh i) (Mt i) := by
        intro i; rw [Finset.disjoint_left]
        intro j hj hj'
        rw [memSh] at hj; rw [memMt] at hj'
        obtain ⟨-, hshare⟩ := hj
        obtain ⟨h1, h2, h3, h4, h5⟩ := hmate (f i)
        rw [hj'] at hshare
        tauto
  4. At each endpoint of f(i), at most 2 other clique edges are incident.

    The clique edges incident to a(f(i)) other than f(i) embed injectively via f into inc(a(f(i))) \ {f(i)}. Because |inc(a(f(i)))| ≤ 3, this set has cardinality at most 3 - 1 = 2, so |Pt(i)| ≤ 2. By symmetric reasoning at b(f(i)), |Pb(i)| ≤ 2 as well.

    lines 69–104

    uses Finset.mem_image, Finset.mem_erase, Finset.card_image_of_injective, Finset.card_erase_of_mem, Finset.card_le_card

      have hPt_le : ∀ i, (Pt i).card ≤ 2 := by
        intro i
        have hsub : (Pt i).image f ⊆ (inc (a (f i))).erase (f i) := by
          intro x hx
          rw [Finset.mem_image] at hx
          obtain ⟨j, hj, rfl⟩ := hx
          rw [memPt] at hj
          obtain ⟨hji, hcond⟩ := hj
          rw [Finset.mem_erase, mem_inc]
          exact ⟨fun h => hji (hf h), hcond⟩
        have hcard1 : ((Pt i).image f).card = (Pt i).card := Finset.card_image_of_injective _ hf
        have hcard2 : ((inc (a (f i))).erase (f i)).card = (inc (a (f i))).card - 1 :=
          Finset.card_erase_of_mem ((mem_inc (f i) (a (f i))).mpr (Or.inl rfl))
        have hle : ((inc (a (f i))).erase (f i)).card ≤ 2 := by
          rw [hcard2]; have := hinc_le (a (f i)); omega
        calc (Pt i).card = ((Pt i).image f).card := hcard1.symm
          _ ≤ ((inc (a (f i))).erase (f i)).card := Finset.card_le_card hsub
          _ ≤ 2 := hle
      have hPb_le : ∀ i, (Pb i).card ≤ 2 := by
        intro i
        have hsub : (Pb i).image f ⊆ (inc (b (f i))).erase (f i) := by
          intro x hx
          rw [Finset.mem_image] at hx
          obtain ⟨j, hj, rfl⟩ := hx
          rw [memPb] at hj
          obtain ⟨hji, hcond⟩ := hj
          rw [Finset.mem_erase, mem_inc]
          exact ⟨fun h => hji (hf h), hcond⟩
        have hcard1 : ((Pb i).image f).card = (Pb i).card := Finset.card_image_of_injective _ hf
        have hcard2 : ((inc (b (f i))).erase (f i)).card = (inc (b (f i))).card - 1 :=
          Finset.card_erase_of_mem ((mem_inc (f i) (b (f i))).mpr (Or.inr rfl))
        have hle : ((inc (b (f i))).erase (f i)).card ≤ 2 := by
          rw [hcard2]; have := hinc_le (b (f i)); omega
        calc (Pb i).card = ((Pb i).image f).card := hcard1.symm
          _ ≤ ((inc (b (f i))).erase (f i)).card := Finset.card_le_card hsub
          _ ≤ 2 := hle
  5. Every clique edge has exactly 4 host-sharing neighbors (2 at each endpoint) and exactly 1 matching mate.

    The 5 other edges partition into Sh(i) and Mt(i), giving |Sh(i)| + |Mt(i)| = 5. Since any edge sharing an endpoint with f(i) is in Pt(i) ∪ Pb(i), we have |Sh(i)| ≤ |Pt(i)| + |Pb(i)| ≤ 2 + 2 = 4. Together with |Mt(i)| ≤ 1, this forces |Sh(i)| = 4 and |Mt(i)| = 1. Consequently, |Pt(i)| + |Pb(i)| ≥ 4, which with |Pt(i)| ≤ 2 and |Pb(i)| ≤ 2 forces |Pt(i)| = 2 and |Pb(i)| = 2.

    lines 105–148

    uses Finset.mem_union, Finset.card_erase_of_mem, Finset.mem_univ, Finset.card_union_of_disjoint, Finset.card_le_card, Finset.card_union_le

      have hSh_sub : ∀ i, Sh i ⊆ Pt i ∪ Pb i := by
        intro i j hj
        rw [memSh] at hj
        obtain ⟨hji, hs⟩ := hj
        rw [Finset.mem_union, memPt, memPb]
        rcases hs with h | h | h | h
        · exact Or.inl ⟨hji, Or.inl h.symm⟩
        · exact Or.inl ⟨hji, Or.inr h.symm⟩
        · exact Or.inr ⟨hji, Or.inl h.symm⟩
        · exact Or.inr ⟨hji, Or.inr h.symm⟩
      have herase_card : ∀ i : Fin 6, (Finset.univ.erase i).card = 5 := by
        intro i
        rw [Finset.card_erase_of_mem (Finset.mem_univ i)]
        simp
      have hsum_eq : ∀ i, (Sh i).card + (Mt i).card = 5 := by
        intro i
        rw [← Finset.card_union_of_disjoint (hDisj i), hUnion i, herase_card i]
      have hSh_card : ∀ i, (Sh i).card = 4 := by
        intro i
        have h1 : (Sh i).card ≤ (Pt i ∪ Pb i).card := Finset.card_le_card (hSh_sub i)
        have h2 : (Pt i ∪ Pb i).card ≤ (Pt i).card + (Pb i).card := Finset.card_union_le _ _
        have h3 : (Pt i).card + (Pb i).card ≤ 4 := by
          have := hPt_le i; have := hPb_le i; omega
        have h4 : (Sh i).card + (Mt i).card = 5 := hsum_eq i
        have h5 : (Mt i).card ≤ 1 := hMt_le i
        omega
      have hMt_card : ∀ i, (Mt i).card = 1 := by
        intro i; have := hsum_eq i; have := hSh_card i; omega
      have hPt_card : ∀ i, (Pt i).card = 2 := by
        intro i
        have h1 : (Sh i).card ≤ (Pt i ∪ Pb i).card := Finset.card_le_card (hSh_sub i)
        have h2 : (Pt i ∪ Pb i).card ≤ (Pt i).card + (Pb i).card := Finset.card_union_le _ _
        have h3 : (Pt i).card ≤ 2 := hPt_le i
        have h4 : (Pb i).card ≤ 2 := hPb_le i
        have := hSh_card i
        omega
      have hPb_card : ∀ i, (Pb i).card = 2 := by
        intro i
        have h1 : (Sh i).card ≤ (Pt i ∪ Pb i).card := Finset.card_le_card (hSh_sub i)
        have h2 : (Pt i ∪ Pb i).card ≤ (Pt i).card + (Pb i).card := Finset.card_union_le _ _
        have h3 : (Pt i).card ≤ 2 := hPt_le i
        have h4 : (Pb i).card ≤ 2 := hPb_le i
        have := hSh_card i
        omega
  6. No other clique edge shares both endpoints with f(i).

    If an index j belonged to both Pt(i) and Pb(i), the intersection Pt(i) ∩ Pb(i) would be non-empty. But inclusion-exclusion gives |Pt(i) ∪ Pb(i)| + |Pt(i) ∩ Pb(i)| = |Pt(i)| + |Pb(i)| = 4, and |Pt(i) ∪ Pb(i)| ≥ |Sh(i)| = 4, which forces |Pt(i) ∩ Pb(i)| = 0, a contradiction.

    lines 149–162

    uses Finset.disjoint_left, Finset.card_le_card, Finset.card_union_le, Finset.card_pos.mpr, Finset.mem_inter, Finset.card_union_add_card_inter

      have hPtPb_disj : ∀ i, Disjoint (Pt i) (Pb i) := by
        intro i
        rw [Finset.disjoint_left]
        intro j hj1 hj2
        have hunion : (Pt i ∪ Pb i).card = 4 := by
          have h1 : (Sh i).card ≤ (Pt i ∪ Pb i).card := Finset.card_le_card (hSh_sub i)
          have h2 : (Pt i ∪ Pb i).card ≤ (Pt i).card + (Pb i).card := Finset.card_union_le _ _
          have := hSh_card i; have := hPt_card i; have := hPb_card i
          omega
        have hinter : 1 ≤ (Pt i ∩ Pb i).card :=
          Finset.card_pos.mpr ⟨j, Finset.mem_inter.mpr ⟨hj1, hj2⟩⟩
        have hcu := Finset.card_union_add_card_inter (Pt i) (Pb i)
        have := hPt_card i; have := hPb_card i
        omega
  7. Each endpoint of each clique edge has host degree exactly 3, and all its incident host edges are among the 6 clique edges.

    At endpoint a(f(i)), we have f(i) and the 2 clique edges in Pt(i), giving 3 distinct incident host edges. Since the maximum host degree is at most 3, the host degree at a(f(i)) is exactly 3, and every incident host edge belongs to the 6 clique edges. Symmetrically, the same holds for endpoint b(f(i)).

    lines 163–250

    uses Finset.mem_image, Finset.card_image_of_injective, Finset.mem_insert, Finset.card_insert_of_notMem, Finset.card_le_card, Finset.mem_erase, Finset.card_erase_of_mem, Finset.eq_of_subset_of_card_le, Finset.mem_univ

      have hfi_top : ∀ i, f i ∈ inc (a (f i)) := fun i => (mem_inc _ _).mpr (Or.inl rfl)
      have hfi_bot : ∀ i, f i ∈ inc (b (f i)) := fun i => (mem_inc _ _).mpr (Or.inr rfl)
      have hnotin_top : ∀ i, f i ∉ (Pt i).image f := by
        intro i hx
        rw [Finset.mem_image] at hx
        obtain ⟨j, hj, hji⟩ := hx
        rw [memPt] at hj
        exact hj.1 (hf hji)
      have hnotin_bot : ∀ i, f i ∉ (Pb i).image f := by
        intro i hx
        rw [Finset.mem_image] at hx
        obtain ⟨j, hj, hji⟩ := hx
        rw [memPb] at hj
        exact hj.1 (hf hji)
      have hincTop_card : ∀ i, (inc (a (f i))).card = 3 := by
        intro i
        have himgcard : ((Pt i).image f).card = 2 := by
          rw [Finset.card_image_of_injective _ hf, hPt_card i]
        have hsub : (Pt i).image f ⊆ inc (a (f i)) := by
          intro x hx; rw [Finset.mem_image] at hx; obtain ⟨j, hj, rfl⟩ := hx
          rw [memPt] at hj; exact (mem_inc _ _).mpr hj.2
        have hins : insert (f i) ((Pt i).image f) ⊆ inc (a (f i)) := by
          intro x hx; rw [Finset.mem_insert] at hx
          rcases hx with rfl | hx
          · exact hfi_top i
          · exact hsub hx
        have hinscard : (insert (f i) ((Pt i).image f)).card = ((Pt i).image f).card + 1 :=
          Finset.card_insert_of_notMem (hnotin_top i)
        have hge : 3 ≤ (inc (a (f i))).card := by
          have := Finset.card_le_card hins
          rw [hinscard, himgcard] at this
          omega
        have := hinc_le (a (f i)); omega
      have hEqTop : ∀ i, (Pt i).image f = (inc (a (f i))).erase (f i) := by
        intro i
        have hsub : (Pt i).image f ⊆ (inc (a (f i))).erase (f i) := by
          intro x hx; rw [Finset.mem_image] at hx; obtain ⟨j, hj, rfl⟩ := hx
          rw [memPt] at hj
          exact Finset.mem_erase.mpr ⟨fun h => hj.1 (hf h), (mem_inc _ _).mpr hj.2⟩
        have hcard : ((inc (a (f i))).erase (f i)).card = 2 := by
          rw [Finset.card_erase_of_mem (hfi_top i), hincTop_card i]
        exact Finset.eq_of_subset_of_card_le hsub
          (by rw [hcard, Finset.card_image_of_injective _ hf, hPt_card i])
      have hincTop_subset : ∀ i, inc (a (f i)) ⊆ Finset.univ.image f := by
        intro i x hx
        by_cases h : x = f i
        · rw [h]; exact Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩
        · have hx' : x ∈ (inc (a (f i))).erase (f i) := Finset.mem_erase.mpr ⟨h, hx⟩
          rw [← hEqTop i] at hx'
          obtain ⟨j, -, hfj⟩ := Finset.mem_image.mp hx'
          exact Finset.mem_image.mpr ⟨j, Finset.mem_univ j, hfj⟩
      have hincBot_card : ∀ i, (inc (b (f i))).card = 3 := by
        intro i
        have himgcard : ((Pb i).image f).card = 2 := by
          rw [Finset.card_image_of_injective _ hf, hPb_card i]
        have hsub : (Pb i).image f ⊆ inc (b (f i)) := by
          intro x hx; rw [Finset.mem_image] at hx; obtain ⟨j, hj, rfl⟩ := hx
          rw [memPb] at hj; exact (mem_inc _ _).mpr hj.2
        have hins : insert (f i) ((Pb i).image f) ⊆ inc (b (f i)) := by
          intro x hx; rw [Finset.mem_insert] at hx
          rcases hx with rfl | hx
          · exact hfi_bot i
          · exact hsub hx
        have hinscard : (insert (f i) ((Pb i).image f)).card = ((Pb i).image f).card + 1 :=
          Finset.card_insert_of_notMem (hnotin_bot i)
        have hge : 3 ≤ (inc (b (f i))).card := by
          have := Finset.card_le_card hins
          rw [hinscard, himgcard] at this
          omega
        have := hinc_le (b (f i)); omega
      have hEqBot : ∀ i, (Pb i).image f = (inc (b (f i))).erase (f i) := by
        intro i
        have hsub : (Pb i).image f ⊆ (inc (b (f i))).erase (f i) := by
          intro x hx; rw [Finset.mem_image] at hx; obtain ⟨j, hj, rfl⟩ := hx
          rw [memPb] at hj
          exact Finset.mem_erase.mpr ⟨fun h => hj.1 (hf h), (mem_inc _ _).mpr hj.2⟩
        have hcard : ((inc (b (f i))).erase (f i)).card = 2 := by
          rw [Finset.card_erase_of_mem (hfi_bot i), hincBot_card i]
        exact Finset.eq_of_subset_of_card_le hsub
          (by rw [hcard, Finset.card_image_of_injective _ hf, hPb_card i])
      have hincBot_subset : ∀ i, inc (b (f i)) ⊆ Finset.univ.image f := by
        intro i x hx
        by_cases h : x = f i
        · rw [h]; exact Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩
        · have hx' : x ∈ (inc (b (f i))).erase (f i) := Finset.mem_erase.mpr ⟨h, hx⟩
          rw [← hEqBot i] at hx'
          obtain ⟨j, -, hfj⟩ := Finset.mem_image.mp hx'
          exact Finset.mem_image.mpr ⟨j, Finset.mem_univ j, hfj⟩
  8. No two distinct clique edges share the same pair of endpoints.

    If distinct edges f(i) and f(j) shared both endpoints (in either orientation), j would belong to both Pt(i) and Pb(i), contradicting the disjointness of Pt(i) and Pb(i).

    lines 251–265

    uses Finset.disjoint_left

      have hpar : ∀ i j, i ≠ j → ¬ ((a (f i) = a (f j) ∧ b (f i) = b (f j)) ∨ (a (f i) = b (f j) ∧ b (f i) = a (f j))) := by
        intro i j hij h
        have hmemPt : j ∈ Pt i := by
          rw [memPt]
          refine ⟨fun hh => hij hh.symm, ?_⟩
          rcases h with ⟨h1, h2⟩ | ⟨h1, h2⟩
          · exact Or.inl h1.symm
          · exact Or.inr h1.symm
        have hmemPb : j ∈ Pb i := by
          rw [memPb]
          refine ⟨fun hh => hij hh.symm, ?_⟩
          rcases h with ⟨h1, h2⟩ | ⟨h1, h2⟩
          · exact Or.inr h2.symm
          · exact Or.inl h2.symm
        exact ((Finset.disjoint_left.mp (hPtPb_disj i)) hmemPt) hmemPb
  9. The total set of endpoints T of the 6 clique edges has cardinality exactly 4.

    Let T be the set of endpoints of the 6 clique edges. Every vertex in T has host degree 3, all provided by the clique edges, so the sum of degrees over T is 3|T|. Double counting incidences across the 6 edges (each of which has 2 distinct endpoints in T) gives 6 × 2 = 12 total incidences. Hence 3|T| = 12, which implies |T| = 4.

    lines 266–330

    uses Finset.mem_union, Finset.mem_image, Finset.mem_univ, true_and, Finset.card_image_of_injective, Finset.card_filter, Finset.sum_comm, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton, Finset.card_pair, Finset.sum_congr, Finset.sum_const

      let T : Finset U := (Finset.univ.image fun i : Fin 6 => a (f i)) ∪ (Finset.univ.image fun i : Fin 6 => b (f i))
      have haT : ∀ i, a (f i) ∈ T := by
        intro i
        show a (f i) ∈ (Finset.univ.image fun i : Fin 6 => a (f i)) ∪ (Finset.univ.image fun i : Fin 6 => b (f i))
        exact Finset.mem_union.mpr (Or.inl (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩))
      have hbT : ∀ i, b (f i) ∈ T := by
        intro i
        show b (f i) ∈ (Finset.univ.image fun i : Fin 6 => a (f i)) ∪ (Finset.univ.image fun i : Fin 6 => b (f i))
        exact Finset.mem_union.mpr (Or.inr (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩))
      have hT_inc_card : ∀ u ∈ T, (inc u).card = 3 := by
        intro u hu
        simp only [T, Finset.mem_union, Finset.mem_image, Finset.mem_univ, true_and] at hu
        rcases hu with ⟨i, hia⟩ | ⟨i, hib⟩
        · rw [← hia]; exact hincTop_card i
        · rw [← hib]; exact hincBot_card i
      have hT_sub : ∀ u ∈ T, inc u ⊆ Finset.univ.image f := by
        intro u hu
        simp only [T, Finset.mem_union, Finset.mem_image, Finset.mem_univ, true_and] at hu
        rcases hu with ⟨i, hia⟩ | ⟨i, hib⟩
        · rw [← hia]; exact hincTop_subset i
        · rw [← hib]; exact hincBot_subset i
      let deg6 : U → Finset (Fin 6) := fun u => (Finset.univ : Finset (Fin 6)).filter (fun i => a (f i) = u ∨ b (f i) = u)
      have mem_deg6 : ∀ (i : Fin 6) (u : U), i ∈ deg6 u ↔ (a (f i) = u ∨ b (f i) = u) := by
        intro i u; simp [deg6]
      have hcard_deg6 : ∀ u, inc u ⊆ Finset.univ.image f → (deg6 u).card = (inc u).card := by
        intro u hsub
        have himg : (deg6 u).image f = inc u := by
          ext x; constructor
          · intro hx; rw [Finset.mem_image] at hx; obtain ⟨i, hi, rfl⟩ := hx
            exact (mem_inc _ _).mpr ((mem_deg6 _ _).mp hi)
          · intro hx
            obtain ⟨i, -, hix⟩ := Finset.mem_image.mp (hsub hx)
            rw [Finset.mem_image]
            exact ⟨i, (mem_deg6 _ _).mpr (by rw [hix]; exact (mem_inc _ _).mp hx), hix⟩
        calc (deg6 u).card = ((deg6 u).image f).card := (Finset.card_image_of_injective _ hf).symm
          _ = (inc u).card := by rw [himg]
      have hdeg6_three : ∀ u ∈ T, (deg6 u).card = 3 := by
        intro u hu
        rw [hcard_deg6 u (hT_sub u hu), hT_inc_card u hu]
      have hsum1 : (∑ u ∈ T, (deg6 u).card) = ∑ i : Fin 6, ∑ u ∈ T, (if (a (f i) = u ∨ b (f i) = u) then (1:Nat) else 0) := by
        simp only [deg6, Finset.card_filter]
        rw [Finset.sum_comm]
      have hinner : ∀ i : Fin 6, (∑ u ∈ T, (if (a (f i) = u ∨ b (f i) = u) then (1:Nat) else 0)) = 2 := by
        intro i
        have hfilter : T.filter (fun u => a (f i) = u ∨ b (f i) = u) = {a (f i), b (f i)} := by
          ext u
          simp only [Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton]
          constructor
          · rintro ⟨-, h | h⟩
            · exact Or.inl h.symm
            · exact Or.inr h.symm
          · rintro (h | h)
            · exact ⟨by rw [h]; exact haT i, Or.inl h.symm⟩
            · exact ⟨by rw [h]; exact hbT i, Or.inr h.symm⟩
        rw [← Finset.card_filter (fun u => a (f i) = u ∨ b (f i) = u) T, hfilter, Finset.card_pair (hends (f i))]
      have hsum2 : (∑ u ∈ T, (deg6 u).card) = 12 := by
        rw [hsum1]
        rw [Finset.sum_congr rfl (fun i (_ : i ∈ (Finset.univ : Finset (Fin 6))) => hinner i)]
        simp
      have hsum3 : (∑ u ∈ T, (deg6 u).card) = T.card * 3 := by
        rw [Finset.sum_congr rfl (fun u (hu : u ∈ T) => hdeg6_three u hu)]
        simp [Finset.sum_const]
      have hTcard : T.card = 4 := by
        have h2 := hsum2; have h3 := hsum3
        omega
  10. For any vertex u in T, the map taking an incident clique edge to its other endpoint is injective.

    The other endpoint oth(u, x) of an edge x incident to u is b(x) if a(x) = u and a(x) otherwise. Since edges are loopless, oth(u, x) ≠ u. If two distinct incident edges had the same other endpoint, they would share both endpoints, violating the absence of parallel edges.

    lines 331–364

      let oth : U → X → U := fun u x => if a x = u then b x else a x
      have oth_ne : ∀ u x, x ∈ inc u → oth u x ≠ u := by
        intro u x hx
        by_cases h : a x = u
        · have hh : oth u x = b x := by simp [oth, h]
          rw [hh]; intro hb; exact (hends x) (h.trans hb.symm)
        · have hh : oth u x = a x := by simp [oth, h]
          rw [hh]; exact h
      have oth_pair : ∀ u x, x ∈ inc u → (a x = u ∧ b x = oth u x) ∨ (b x = u ∧ a x = oth u x) := by
        intro u x hx
        by_cases h : a x = u
        · left; exact ⟨h, by simp [oth, h]⟩
        · right
          have hb : b x = u := by
            rcases (mem_inc x u).mp hx with h' | h'
            · exact absurd h' h
            · exact h'
          refine ⟨hb, ?_⟩
          have hh : oth u x = a x := by simp [oth, h]
          rw [hh]
      have oth_inj : ∀ u i j, i ∈ deg6 u → j ∈ deg6 u → oth u (f i) = oth u (f j) → i = j := by
        intro u i j hi hj heq
        have hfi : f i ∈ inc u := (mem_inc _ _).mpr ((mem_deg6 _ _).mp hi)
        have hfj : f j ∈ inc u := (mem_inc _ _).mpr ((mem_deg6 _ _).mp hj)
        by_contra hij
        apply hpar i j hij
        have pi := oth_pair u (f i) hfi
        have pj := oth_pair u (f j) hfj
        rw [heq] at pi
        rcases pi with ⟨h1, h2⟩ | ⟨h1, h2⟩ <;> rcases pj with ⟨k1, k2⟩ | ⟨k1, k2⟩
        · exact Or.inl ⟨h1.trans k1.symm, h2.trans k2.symm⟩
        · exact Or.inr ⟨h1.trans k1.symm, h2.trans k2.symm⟩
        · exact Or.inr ⟨h2.trans k2.symm, h1.trans k1.symm⟩
        · exact Or.inl ⟨h2.trans k2.symm, h1.trans k1.symm⟩
  11. The neighborhood of each vertex u in T along the clique edges is all of T \ {u}.

    The set O(u) of other endpoints of the 3 clique edges incident to u has cardinality 3 by injectivity of the other-endpoint map. Since O(u) ⊆ T \ {u} and |T \ {u}| = 4 - 1 = 3, the two finite sets of the same size must be equal: O(u) = T \ {u}.

    lines 365–391

    uses Finset.card_image_iff, Finset.mem_image, Finset.mem_erase, Finset.card_erase_of_mem, Finset.eq_of_subset_of_card_le

      let O : U → Finset U := fun u => (deg6 u).image (fun i => oth u (f i))
      have hO_card : ∀ u ∈ T, (O u).card = 3 := by
        intro u hu
        have hinj : Set.InjOn (fun i => oth u (f i)) ↑(deg6 u) := by
          intro i hi j hj heq
          exact oth_inj u i j hi hj heq
        rw [show O u = (deg6 u).image (fun i => oth u (f i)) from rfl,
          Finset.card_image_iff.mpr hinj, hdeg6_three u hu]
      have hO_sub : ∀ u ∈ T, O u ⊆ T.erase u := by
        intro u hu x hx
        rw [show O u = (deg6 u).image (fun i => oth u (f i)) from rfl, Finset.mem_image] at hx
        obtain ⟨i, hi, rfl⟩ := hx
        have hfi : f i ∈ inc u := (mem_inc _ _).mpr ((mem_deg6 _ _).mp hi)
        rw [Finset.mem_erase]
        refine ⟨oth_ne u (f i) hfi, ?_⟩
        rcases (mem_deg6 i u).mp hi with ha | hb
        · have hh : oth u (f i) = b (f i) := by simp [oth, ha]
          rw [hh]; exact hbT i
        · have hna : ¬ a (f i) = u := fun h => (hends (f i)) (h.trans hb.symm)
          have hh : oth u (f i) = a (f i) := by simp [oth, hna]
          rw [hh]; exact haT i
      have hO_eq : ∀ u ∈ T, O u = T.erase u := by
        intro u hu
        have h1 : (O u).card = 3 := hO_card u hu
        have h2 : (T.erase u).card = 3 := by
          rw [Finset.card_erase_of_mem hu, hTcard]
        exact Finset.eq_of_subset_of_card_le (hO_sub u hu) (by rw [h2, h1])
  12. The 4 endpoints form a complete component K4: every pair of distinct vertices in T is joined by a unique clique edge.

    Given distinct vertices u, v ∈ T, v belongs to T \ {u} = O(u), yielding a clique edge connecting u and v. If another clique edge also connected u and v, the two edges would share both endpoints, contradicting the established fact that clique edges cannot be parallel. Thus the connection is unique.

    lines 392–412

    uses Finset.mem_erase, Finset.mem_image

      refine ⟨T, hTcard, fun i => ⟨haT i, hbT i⟩, ?_⟩
      intro u hu v hv huv
      have hvO : v ∈ O u := by
        rw [hO_eq u hu, Finset.mem_erase]
        exact ⟨fun h => huv h.symm, hv⟩
      rw [show O u = (deg6 u).image (fun i => oth u (f i)) from rfl, Finset.mem_image] at hvO
      obtain ⟨i, hi, hith⟩ := hvO
      have hfi : f i ∈ inc u := (mem_inc _ _).mpr ((mem_deg6 i u).mp hi)
      have hpred : (a (f i) = u ∧ b (f i) = v) ∨ (a (f i) = v ∧ b (f i) = u) := by
        rcases oth_pair u (f i) hfi with ⟨h1, h2⟩ | ⟨h1, h2⟩
        · exact Or.inl ⟨h1, h2.trans hith⟩
        · exact Or.inr ⟨h2.trans hith, h1⟩
      refine ⟨i, hpred, ?_⟩
      intro j hj
      by_contra hji
      apply hpar i j (fun h => hji h.symm)
      rcases hpred with ⟨p1, p2⟩ | ⟨p1, p2⟩ <;> rcases hj with ⟨q1, q2⟩ | ⟨q1, q2⟩
      · exact Or.inl ⟨p1.trans q1.symm, p2.trans q2.symm⟩
      · exact Or.inr ⟨p1.trans q2.symm, p2.trans q1.symm⟩
      · exact Or.inr ⟨p1.trans q2.symm, p2.trans q1.symm⟩
      · exact Or.inl ⟨p1.trans q1.symm, p2.trans q2.symm⟩
and_true
Conjunction with True simplifies to the proposition itself.
Finset.card_erase_of_mem
Removing an element from a finite set decreases its cardinality by one.
Finset.card_filter
The cardinality of a filtered subset equals the sum of indicator values over the set.
Finset.card_image_iff
The image of a finite set under a map has the same cardinality as the set if and only if the map is injective on that set.
Finset.card_image_of_injective
An injective function preserves the cardinality of a finite set under forward image.
Finset.card_insert_of_notMem
Inserting an element not already present increases the cardinality of a finite set by one.
Finset.card_le_one
A finite set has cardinality at most one if and only if any two of its elements are equal.
Finset.card_le_card
A subset of a finite set has cardinality less than or equal to that of the set.
Finset.card_pair
A set of two distinct elements has cardinality two.
Finset.card_pos.mpr
A non-empty finite set has strictly positive cardinality.
Finset.card_union_add_card_inter
The sum of the sizes of the union and intersection of two finite sets equals the sum of their individual sizes (principle of inclusion-exclusion).
Finset.card_union_le
The cardinality of the union of two finite sets is at most the sum of their cardinalities.
Finset.card_union_of_disjoint
The cardinality of the union of two disjoint finite sets is the sum of their cardinalities.
Finset.disjoint_left
Two finite sets are disjoint if and only if no element of the first belongs to the second.
Finset.eq_of_subset_of_card_le
If a finite subset has cardinality at least that of the superset, the two sets are equal.
Finset.mem_erase
An element belongs to a set with another element erased if and only if it is in the set and differs from the erased element.
Finset.mem_filter
An element belongs to a filtered set if and only if it belongs to the set and satisfies the filtering condition.
Finset.mem_image
An element is in the image of a set under a function if and only if it is the image of some element in the set.
Finset.mem_insert
An element is in the set obtained by inserting an element if and only if it equals the inserted element or is in the original set.
Finset.mem_inter
An element is in the intersection of two sets if and only if it belongs to both sets.
Finset.mem_singleton
An element belongs to a singleton set if and only if it is equal to that unique member.
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 the universal finite set of that type.
Finset.sum_comm
Double sums over finite sets can be interchanged (finite Fubini theorem).
Finset.sum_congr
Two finite sums are equal if their index sets are equal and their terms agree on all elements.
Finset.sum_const
The sum of a constant term over a finite set equals the cardinality of the set multiplied by the constant.
true_and
Conjunction with True on the left simplifies to the proposition itself.

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

Lean’s trace was cut to the first 400 of 452 tactics.

theorem op309_subcubic_host_mate_six_clique_forces_k4    {U X : Type*} [Fintype U] [DecidableEq U] [Fintype X] [DecidableEq X]    (a b : X → U) (mate : X → X)    (hends : ∀ x, a x ≠ b x)    (hinvolution : ∀ x, mate (mate x) = x)    (hmate : ∀ x, mate x ≠ x ∧ a x ≠ a (mate x) ∧      a x ≠ b (mate x) ∧ b x ≠ a (mate x) ∧ b x ≠ b (mate x))    (hdegree : ∀ u, ((Finset.univ : Finset X).filter      fun x => a x = u ∨ b x = u).card ≤ 3)    (f : Fin 6 → X) (hf : Function.Injective f)    (hclique : ∀ i j, i ≠ j →      a (f i) = a (f j) ∨ a (f i) = b (f j) ∨      b (f i) = a (f j) ∨ b (f i) = b (f j) ∨ f j = mate (f i)) :    ∃ S : Finset U, S.card = 4 ∧      (∀ i, a (f i) ∈ S ∧ b (f i) ∈ S) ∧      ∀ u ∈ S, ∀ v ∈ S, u ≠ v →        ∃! i : Fin 6, (a (f i) = u ∧ b (f i) = v) ∨          (a (f i) = v ∧ b (f i) = u) := by  classical  let inc : U → Finset X := fun u => (Finset.univ : Finset X).filter (fun x => a x = u ∨ b x = u)  have mem_inc : ∀ (x : X) (u : U), x ∈ inc u ↔ (a x = u ∨ b x = u) := by    intro x u; simp [inc]  have hinc_le : ∀ u, (inc u).card ≤ 3 := fun u => hdegree u  let Sh : Fin 6 → Finset (Fin 6) := fun i => Finset.univ.filter fun j =>    j ≠ i ∧ (a (f i) = a (f j) ∨ a (f i) = b (f j) ∨ b (f i) = a (f j) ∨ b (f i) = b (f j))  let Mt : Fin 6 → Finset (Fin 6) := fun i => Finset.univ.filter fun j => f j = mate (f i)  let Pt : Fin 6 → Finset (Fin 6) := fun i => (Finset.univ.erase i).filter fun j =>    a (f j) = a (f i) ∨ b (f j) = a (f i)  let Pb : Fin 6 → Finset (Fin 6) := fun i => (Finset.univ.erase i).filter fun j =>    a (f j) = b (f i) ∨ b (f j) = b (f i)  have memSh : ∀ i j, j ∈ Sh i ↔ j ≠ i ∧ (a (f i) = a (f j) ∨ a (f i) = b (f j) ∨ b (f i) = a (f j) ∨ b (f i) = b (f j)) := by    intro i j; simp [Sh]  have memMt : ∀ i j, j ∈ Mt i ↔ f j = mate (f i) := by    intro i j; simp [Mt]  have memPt : ∀ i j, j ∈ Pt i ↔ j ≠ i ∧ (a (f j) = a (f i) ∨ b (f j) = a (f i)) := by    intro i j; simp [Pt]  have memPb : ∀ i j, j ∈ Pb i ↔ j ≠ i ∧ (a (f j) = b (f i) ∨ b (f j) = b (f i)) := by    intro i j; simp [Pb]  have hMt_le : ∀ i, (Mt i).card ≤ 1 := by    intro i    rw [Finset.card_le_one]    intro j hj k hk    rw [memMt] at hj hk    exact hf (hj.trans hk.symm)  have hUnion : ∀ i, Sh i ∪ Mt i = Finset.univ.erase i := by    intro i; ext j    simp only [Finset.mem_union, memSh, memMt, Finset.mem_erase, Finset.mem_univ, and_true]    constructor    · rintro (⟨hji, -⟩ | hj)      · exact hji      · refine fun h => ?_        rw [h] at hj        exact (hmate (f i)).1 hj.symm    · intro hji      rcases hclique i j (fun h => hji h.symm) with hs | hs | hs | hs | hm      · exact Or.inl ⟨hji, Or.inl hs⟩      · exact Or.inl ⟨hji, Or.inr (Or.inl hs)⟩      · exact Or.inl ⟨hji, Or.inr (Or.inr (Or.inl hs))⟩      · exact Or.inl ⟨hji, Or.inr (Or.inr (Or.inr hs))⟩      · exact Or.inr hm  have hDisj : ∀ i, Disjoint (Sh i) (Mt i) := by    intro i; rw [Finset.disjoint_left]    intro j hj hj'    rw [memSh] at hj; rw [memMt] at hj'    obtain ⟨-, hshare⟩ := hj    obtain ⟨h1, h2, h3, h4, h5⟩ := hmate (f i)    rw [hj'] at hshare    tauto  have hPt_le : ∀ i, (Pt i).card ≤ 2 := by    intro i    have hsub : (Pt i).image f ⊆ (inc (a (f i))).erase (f i) := by      intro x hx      rw [Finset.mem_image] at hx      obtain ⟨j, hj, rfl⟩ := hx      rw [memPt] at hj      obtain ⟨hji, hcond⟩ := hj      rw [Finset.mem_erase, mem_inc]      exact ⟨fun h => hji (hf h), hcond⟩    have hcard1 : ((Pt i).image f).card = (Pt i).card := Finset.card_image_of_injective _ hf    have hcard2 : ((inc (a (f i))).erase (f i)).card = (inc (a (f i))).card - 1 :=      Finset.card_erase_of_mem ((mem_inc (f i) (a (f i))).mpr (Or.inl rfl))    have hle : ((inc (a (f i))).erase (f i)).card ≤ 2 := by      rw [hcard2]; have := hinc_le (a (f i)); omega    calc (Pt i).card = ((Pt i).image f).card := hcard1.symm      _ ≤ ((inc (a (f i))).erase (f i)).card := Finset.card_le_card hsub      _ ≤ 2 := hle  have hPb_le : ∀ i, (Pb i).card ≤ 2 := by    intro i    have hsub : (Pb i).image f ⊆ (inc (b (f i))).erase (f i) := by      intro x hx      rw [Finset.mem_image] at hx      obtain ⟨j, hj, rfl⟩ := hx      rw [memPb] at hj      obtain ⟨hji, hcond⟩ := hj      rw [Finset.mem_erase, mem_inc]      exact ⟨fun h => hji (hf h), hcond⟩    have hcard1 : ((Pb i).image f).card = (Pb i).card := Finset.card_image_of_injective _ hf    have hcard2 : ((inc (b (f i))).erase (f i)).card = (inc (b (f i))).card - 1 :=      Finset.card_erase_of_mem ((mem_inc (f i) (b (f i))).mpr (Or.inr rfl))    have hle : ((inc (b (f i))).erase (f i)).card ≤ 2 := by      rw [hcard2]; have := hinc_le (b (f i)); omega    calc (Pb i).card = ((Pb i).image f).card := hcard1.symm      _ ≤ ((inc (b (f i))).erase (f i)).card := Finset.card_le_card hsub      _ ≤ 2 := hle  have hSh_sub : ∀ i, Sh i ⊆ Pt i ∪ Pb i := by    intro i j hj    rw [memSh] at hj    obtain ⟨hji, hs⟩ := hj    rw [Finset.mem_union, memPt, memPb]    rcases hs with h | h | h | h    · exact Or.inl ⟨hji, Or.inl h.symm⟩    · exact Or.inl ⟨hji, Or.inr h.symm⟩    · exact Or.inr ⟨hji, Or.inl h.symm⟩    · exact Or.inr ⟨hji, Or.inr h.symm⟩  have herase_card : ∀ i : Fin 6, (Finset.univ.erase i).card = 5 := by    intro i    rw [Finset.card_erase_of_mem (Finset.mem_univ i)]    simp  have hsum_eq : ∀ i, (Sh i).card + (Mt i).card = 5 := by    intro i    rw [← Finset.card_union_of_disjoint (hDisj i), hUnion i, herase_card i]  have hSh_card : ∀ i, (Sh i).card = 4 := by    intro i    have h1 : (Sh i).card ≤ (Pt i ∪ Pb i).card := Finset.card_le_card (hSh_sub i)    have h2 : (Pt i ∪ Pb i).card ≤ (Pt i).card + (Pb i).card := Finset.card_union_le _ _    have h3 : (Pt i).card + (Pb i).card ≤ 4 := by      have := hPt_le i; have := hPb_le i; omega    have h4 : (Sh i).card + (Mt i).card = 5 := hsum_eq i    have h5 : (Mt i).card ≤ 1 := hMt_le i    omega  have hMt_card : ∀ i, (Mt i).card = 1 := by    intro i; have := hsum_eq i; have := hSh_card i; omega  have hPt_card : ∀ i, (Pt i).card = 2 := by    intro i    have h1 : (Sh i).card ≤ (Pt i ∪ Pb i).card := Finset.card_le_card (hSh_sub i)    have h2 : (Pt i ∪ Pb i).card ≤ (Pt i).card + (Pb i).card := Finset.card_union_le _ _    have h3 : (Pt i).card ≤ 2 := hPt_le i    have h4 : (Pb i).card ≤ 2 := hPb_le i    have := hSh_card i    omega  have hPb_card : ∀ i, (Pb i).card = 2 := by    intro i    have h1 : (Sh i).card ≤ (Pt i ∪ Pb i).card := Finset.card_le_card (hSh_sub i)    have h2 : (Pt i ∪ Pb i).card ≤ (Pt i).card + (Pb i).card := Finset.card_union_le _ _    have h3 : (Pt i).card ≤ 2 := hPt_le i    have h4 : (Pb i).card ≤ 2 := hPb_le i    have := hSh_card i    omega  have hPtPb_disj : ∀ i, Disjoint (Pt i) (Pb i) := by    intro i    rw [Finset.disjoint_left]    intro j hj1 hj2    have hunion : (Pt i ∪ Pb i).card = 4 := by      have h1 : (Sh i).card ≤ (Pt i ∪ Pb i).card := Finset.card_le_card (hSh_sub i)      have h2 : (Pt i ∪ Pb i).card ≤ (Pt i).card + (Pb i).card := Finset.card_union_le _ _      have := hSh_card i; have := hPt_card i; have := hPb_card i      omega    have hinter : 1 ≤ (Pt i ∩ Pb i).card :=      Finset.card_pos.mpr ⟨j, Finset.mem_inter.mpr ⟨hj1, hj2⟩⟩    have hcu := Finset.card_union_add_card_inter (Pt i) (Pb i)    have := hPt_card i; have := hPb_card i    omega  have hfi_top : ∀ i, f i ∈ inc (a (f i)) := fun i => (mem_inc _ _).mpr (Or.inl rfl)  have hfi_bot : ∀ i, f i ∈ inc (b (f i)) := fun i => (mem_inc _ _).mpr (Or.inr rfl)  have hnotin_top : ∀ i, f i ∉ (Pt i).image f := by    intro i hx    rw [Finset.mem_image] at hx    obtain ⟨j, hj, hji⟩ := hx    rw [memPt] at hj    exact hj.1 (hf hji)  have hnotin_bot : ∀ i, f i ∉ (Pb i).image f := by    intro i hx    rw [Finset.mem_image] at hx    obtain ⟨j, hj, hji⟩ := hx    rw [memPb] at hj    exact hj.1 (hf hji)  have hincTop_card : ∀ i, (inc (a (f i))).card = 3 := by    intro i    have himgcard : ((Pt i).image f).card = 2 := by      rw [Finset.card_image_of_injective _ hf, hPt_card i]    have hsub : (Pt i).image f ⊆ inc (a (f i)) := by      intro x hx; rw [Finset.mem_image] at hx; obtain ⟨j, hj, rfl⟩ := hx      rw [memPt] at hj; exact (mem_inc _ _).mpr hj.2    have hins : insert (f i) ((Pt i).image f) ⊆ inc (a (f i)) := by      intro x hx; rw [Finset.mem_insert] at hx      rcases hx with rfl | hx      · exact hfi_top i      · exact hsub hx    have hinscard : (insert (f i) ((Pt i).image f)).card = ((Pt i).image f).card + 1 :=      Finset.card_insert_of_notMem (hnotin_top i)    have hge : 3 ≤ (inc (a (f i))).card := by      have := Finset.card_le_card hins      rw [hinscard, himgcard] at this      omega    have := hinc_le (a (f i)); omega  have hEqTop : ∀ i, (Pt i).image f = (inc (a (f i))).erase (f i) := by    intro i    have hsub : (Pt i).image f ⊆ (inc (a (f i))).erase (f i) := by      intro x hx; rw [Finset.mem_image] at hx; obtain ⟨j, hj, rfl⟩ := hx      rw [memPt] at hj      exact Finset.mem_erase.mpr ⟨fun h => hj.1 (hf h), (mem_inc _ _).mpr hj.2⟩    have hcard : ((inc (a (f i))).erase (f i)).card = 2 := by      rw [Finset.card_erase_of_mem (hfi_top i), hincTop_card i]    exact Finset.eq_of_subset_of_card_le hsub      (by rw [hcard, Finset.card_image_of_injective _ hf, hPt_card i])  have hincTop_subset : ∀ i, inc (a (f i)) ⊆ Finset.univ.image f := by    intro i x hx    by_cases h : x = f i    · rw [h]; exact Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩    · have hx' : x ∈ (inc (a (f i))).erase (f i) := Finset.mem_erase.mpr ⟨h, hx⟩      rw [← hEqTop i] at hx'      obtain ⟨j, -, hfj⟩ := Finset.mem_image.mp hx'      exact Finset.mem_image.mpr ⟨j, Finset.mem_univ j, hfj⟩  have hincBot_card : ∀ i, (inc (b (f i))).card = 3 := by    intro i    have himgcard : ((Pb i).image f).card = 2 := by      rw [Finset.card_image_of_injective _ hf, hPb_card i]    have hsub : (Pb i).image f ⊆ inc (b (f i)) := by      intro x hx; rw [Finset.mem_image] at hx; obtain ⟨j, hj, rfl⟩ := hx      rw [memPb] at hj; exact (mem_inc _ _).mpr hj.2    have hins : insert (f i) ((Pb i).image f) ⊆ inc (b (f i)) := by      intro x hx; rw [Finset.mem_insert] at hx      rcases hx with rfl | hx      · exact hfi_bot i      · exact hsub hx    have hinscard : (insert (f i) ((Pb i).image f)).card = ((Pb i).image f).card + 1 :=      Finset.card_insert_of_notMem (hnotin_bot i)    have hge : 3 ≤ (inc (b (f i))).card := by      have := Finset.card_le_card hins      rw [hinscard, himgcard] at this      omega    have := hinc_le (b (f i)); omega  have hEqBot : ∀ i, (Pb i).image f = (inc (b (f i))).erase (f i) := by    intro i    have hsub : (Pb i).image f ⊆ (inc (b (f i))).erase (f i) := by      intro x hx; rw [Finset.mem_image] at hx; obtain ⟨j, hj, rfl⟩ := hx      rw [memPb] at hj      exact Finset.mem_erase.mpr ⟨fun h => hj.1 (hf h), (mem_inc _ _).mpr hj.2⟩    have hcard : ((inc (b (f i))).erase (f i)).card = 2 := by      rw [Finset.card_erase_of_mem (hfi_bot i), hincBot_card i]    exact Finset.eq_of_subset_of_card_le hsub      (by rw [hcard, Finset.card_image_of_injective _ hf, hPb_card i])  have hincBot_subset : ∀ i, inc (b (f i)) ⊆ Finset.univ.image f := by    intro i x hx    by_cases h : x = f i    · rw [h]; exact Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩    · have hx' : x ∈ (inc (b (f i))).erase (f i) := Finset.mem_erase.mpr ⟨h, hx⟩      rw [← hEqBot i] at hx'      obtain ⟨j, -, hfj⟩ := Finset.mem_image.mp hx'      exact Finset.mem_image.mpr ⟨j, Finset.mem_univ j, hfj⟩  have hpar : ∀ i j, i ≠ j → ¬ ((a (f i) = a (f j) ∧ b (f i) = b (f j)) ∨ (a (f i) = b (f j) ∧ b (f i) = a (f j))) := by    intro i j hij h    have hmemPt : j ∈ Pt i := by      rw [memPt]      refine ⟨fun hh => hij hh.symm, ?_⟩      rcases h with ⟨h1, h2⟩ | ⟨h1, h2⟩      · exact Or.inl h1.symm      · exact Or.inr h1.symm    have hmemPb : j ∈ Pb i := by      rw [memPb]      refine ⟨fun hh => hij hh.symm, ?_⟩      rcases h with ⟨h1, h2⟩ | ⟨h1, h2⟩      · exact Or.inr h2.symm      · exact Or.inl h2.symm    exact ((Finset.disjoint_left.mp (hPtPb_disj i)) hmemPt) hmemPb  let T : Finset U := (Finset.univ.image fun i : Fin 6 => a (f i)) ∪ (Finset.univ.image fun i : Fin 6 => b (f i))  have haT : ∀ i, a (f i) ∈ T := by    intro i    show a (f i) ∈ (Finset.univ.image fun i : Fin 6 => a (f i)) ∪ (Finset.univ.image fun i : Fin 6 => b (f i))    exact Finset.mem_union.mpr (Or.inl (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩))  have hbT : ∀ i, b (f i) ∈ T := by    intro i    show b (f i) ∈ (Finset.univ.image fun i : Fin 6 => a (f i)) ∪ (Finset.univ.image fun i : Fin 6 => b (f i))    exact Finset.mem_union.mpr (Or.inr (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩))  have hT_inc_card : ∀ u ∈ T, (inc u).card = 3 := by    intro u hu    simp only [T, Finset.mem_union, Finset.mem_image, Finset.mem_univ, true_and] at hu    rcases hu with ⟨i, hia⟩ | ⟨i, hib⟩    · rw [← hia]; exact hincTop_card i    · rw [← hib]; exact hincBot_card i  have hT_sub : ∀ u ∈ T, inc u ⊆ Finset.univ.image f := by    intro u hu    simp only [T, Finset.mem_union, Finset.mem_image, Finset.mem_univ, true_and] at hu    rcases hu with ⟨i, hia⟩ | ⟨i, hib⟩    · rw [← hia]; exact hincTop_subset i    · rw [← hib]; exact hincBot_subset i  let deg6 : U → Finset (Fin 6) := fun u => (Finset.univ : Finset (Fin 6)).filter (fun i => a (f i) = u ∨ b (f i) = u)  have mem_deg6 : ∀ (i : Fin 6) (u : U), i ∈ deg6 u ↔ (a (f i) = u ∨ b (f i) = u) := by    intro i u; simp [deg6]  have hcard_deg6 : ∀ u, inc u ⊆ Finset.univ.image f → (deg6 u).card = (inc u).card := by    intro u hsub    have himg : (deg6 u).image f = inc u := by      ext x; constructor      · intro hx; rw [Finset.mem_image] at hx; obtain ⟨i, hi, rfl⟩ := hx        exact (mem_inc _ _).mpr ((mem_deg6 _ _).mp hi)      · intro hx        obtain ⟨i, -, hix⟩ := Finset.mem_image.mp (hsub hx)        rw [Finset.mem_image]        exact ⟨i, (mem_deg6 _ _).mpr (by rw [hix]; exact (mem_inc _ _).mp hx), hix⟩    calc (deg6 u).card = ((deg6 u).image f).card := (Finset.card_image_of_injective _ hf).symm      _ = (inc u).card := by rw [himg]  have hdeg6_three : ∀ u ∈ T, (deg6 u).card = 3 := by    intro u hu    rw [hcard_deg6 u (hT_sub u hu), hT_inc_card u hu]  have hsum1 : (∑ u ∈ T, (deg6 u).card) = ∑ i : Fin 6, ∑ u ∈ T, (if (a (f i) = u ∨ b (f i) = u) then (1:Nat) else 0) := by    simp only [deg6, Finset.card_filter]    rw [Finset.sum_comm]  have hinner : ∀ i : Fin 6, (∑ u ∈ T, (if (a (f i) = u ∨ b (f i) = u) then (1:Nat) else 0)) = 2 := by    intro i    have hfilter : T.filter (fun u => a (f i) = u ∨ b (f i) = u) = {a (f i), b (f i)} := by      ext u      simp only [Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton]      constructor      · rintro ⟨-, h | h⟩        · exact Or.inl h.symm        · exact Or.inr h.symm      · rintro (h | h)        · exact ⟨by rw [h]; exact haT i, Or.inl h.symm⟩        · exact ⟨by rw [h]; exact hbT i, Or.inr h.symm⟩    rw [← Finset.card_filter (fun u => a (f i) = u ∨ b (f i) = u) T, hfilter, Finset.card_pair (hends (f i))]  have hsum2 : (∑ u ∈ T, (deg6 u).card) = 12 := by    rw [hsum1]    rw [Finset.sum_congr rfl (fun i (_ : i ∈ (Finset.univ : Finset (Fin 6))) => hinner i)]    simp  have hsum3 : (∑ u ∈ T, (deg6 u).card) = T.card * 3 := by    rw [Finset.sum_congr rfl (fun u (hu : u ∈ T) => hdeg6_three u hu)]    simp [Finset.sum_const]  have hTcard : T.card = 4 := by    have h2 := hsum2; have h3 := hsum3    omega  let oth : U → X → U := fun u x => if a x = u then b x else a x  have oth_ne : ∀ u x, x ∈ inc u → oth u x ≠ u := by    intro u x hx    by_cases h : a x = u    · have hh : oth u x = b x := by simp [oth, h]      rw [hh]; intro hb; exact (hends x) (h.trans hb.symm)    · have hh : oth u x = a x := by simp [oth, h]      rw [hh]; exact h  have oth_pair : ∀ u x, x ∈ inc u → (a x = u ∧ b x = oth u x) ∨ (b x = u ∧ a x = oth u x) := by    intro u x hx    by_cases h : a x = u    · left; exact ⟨h, by simp [oth, h]⟩    · right      have hb : b x = u := by        rcases (mem_inc x u).mp hx with h' | h'        · exact absurd h' h        · exact h'      refine ⟨hb, ?_⟩      have hh : oth u x = a x := by simp [oth, h]      rw [hh]  have oth_inj : ∀ u i j, i ∈ deg6 u → j ∈ deg6 u → oth u (f i) = oth u (f j) → i = j := by    intro u i j hi hj heq    have hfi : f i ∈ inc u := (mem_inc _ _).mpr ((mem_deg6 _ _).mp hi)    have hfj : f j ∈ inc u := (mem_inc _ _).mpr ((mem_deg6 _ _).mp hj)    by_contra hij    apply hpar i j hij    have pi := oth_pair u (f i) hfi    have pj := oth_pair u (f j) hfj    rw [heq] at pi    rcases pi with ⟨h1, h2⟩ | ⟨h1, h2⟩ <;> rcases pj with ⟨k1, k2⟩ | ⟨k1, k2⟩    · exact Or.inl ⟨h1.trans k1.symm, h2.trans k2.symm⟩    · exact Or.inr ⟨h1.trans k1.symm, h2.trans k2.symm⟩    · exact Or.inr ⟨h2.trans k2.symm, h1.trans k1.symm⟩    · exact Or.inl ⟨h2.trans k2.symm, h1.trans k1.symm⟩  let O : U → Finset U := fun u => (deg6 u).image (fun i => oth u (f i))  have hO_card : ∀ u ∈ T, (O u).card = 3 := by    intro u hu    have hinj : Set.InjOn (fun i => oth u (f i)) ↑(deg6 u) := by      intro i hi j hj heq      exact oth_inj u i j hi hj heq    rw [show O u = (deg6 u).image (fun i => oth u (f i)) from rfl,      Finset.card_image_iff.mpr hinj, hdeg6_three u hu]  have hO_sub : ∀ u ∈ T, O u ⊆ T.erase u := by    intro u hu x hx    rw [show O u = (deg6 u).image (fun i => oth u (f i)) from rfl, Finset.mem_image] at hx    obtain ⟨i, hi, rfl⟩ := hx    have hfi : f i ∈ inc u := (mem_inc _ _).mpr ((mem_deg6 _ _).mp hi)    rw [Finset.mem_erase]    refine ⟨oth_ne u (f i) hfi, ?_⟩    rcases (mem_deg6 i u).mp hi with ha | hb    · have hh : oth u (f i) = b (f i) := by simp [oth, ha]      rw [hh]; exact hbT i    · have hna : ¬ a (f i) = u := fun h => (hends (f i)) (h.trans hb.symm)      have hh : oth u (f i) = a (f i) := by simp [oth, hna]      rw [hh]; exact haT i  have hO_eq : ∀ u ∈ T, O u = T.erase u := by    intro u hu    have h1 : (O u).card = 3 := hO_card u hu    have h2 : (T.erase u).card = 3 := by      rw [Finset.card_erase_of_mem hu, hTcard]    exact Finset.eq_of_subset_of_card_le (hO_sub u hu) (by rw [h2, h1])  refine ⟨T, hTcard, fun i => ⟨haT i, hbT i⟩, ?_⟩  intro u hu v hv huv  have hvO : v ∈ O u := by    rw [hO_eq u hu, Finset.mem_erase]    exact ⟨fun h => huv h.symm, hv⟩  rw [show O u = (deg6 u).image (fun i => oth u (f i)) from rfl, Finset.mem_image] at hvO  obtain ⟨i, hi, hith⟩ := hvO  have hfi : f i ∈ inc u := (mem_inc _ _).mpr ((mem_deg6 i u).mp hi)  have hpred : (a (f i) = u ∧ b (f i) = v) ∨ (a (f i) = v ∧ b (f i) = u) := by    rcases oth_pair u (f i) hfi with ⟨h1, h2⟩ | ⟨h1, h2⟩    · exact Or.inl ⟨h1, h2.trans hith⟩    · exact Or.inr ⟨h2.trans hith, h1⟩  refine ⟨i, hpred, ?_⟩  intro j hj  by_contra hji  apply hpar i j (fun h => hji h.symm)  rcases hpred with ⟨p1, p2⟩ | ⟨p1, p2⟩ <;> rcases hj with ⟨q1, q2⟩ | ⟨q1, q2⟩  · exact Or.inl ⟨p1.trans q1.symm, p2.trans q2.symm⟩  · exact Or.inr ⟨p1.trans q2.symm, p2.trans q1.symm⟩  · exact Or.inr ⟨p1.trans q2.symm, p2.trans q1.symm⟩  · exact Or.inl ⟨p1.trans q1.symm, p2.trans q2.symm⟩
See it in the graphDiscuss this resultChallenge it