Open Proof Network

Problems / vizing-conjecture / vizing-conjecture--h5--h1

Sun's theorem, domination number three

vizing-conjecture--h5--h1

proved

Restated as hole sun of critical connected target sets (split by 20261203T143116Z-t1203r2-v-partial.lean).

Hole sun of pairs with no catching certificate (split by 20261203T133009Z-t1203r2-v-partial.lean).

$\displaystyle \gamma(G) = 3 \implies 3\,\gamma(H) \le \gamma(G \,\square\, H)$

For all finite graphs G and H. The statement is that of L. Sun, A result on Vizing's conjecture, Discrete Mathematics 275 (2004) 363-366; Theorem 6.4 of the survey of Bresar, Dorbec, Goddard, Hartnell, Henning, Klavzar and Rall, J. Graph Theory 69 (2012) 46-76.

unverified · history

Lean
theorem vizing_conjecture__h5__h1 : ∀ {α β : Type} [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β] (G : SimpleGraph α) (H : SimpleGraph β),
  G.dominationNumber = (3 : ℕ) → (3 : ℕ) * H.dominationNumber ≤ (G □ H).dominationNumber := by
  sorry
Why does it end in sorry?

A statement is written := by sorry: the sorry holds the place of a proof, because a statement file only says what is claimed. A proof the gate checked is its own file, Proof.lean. How to read a proof page →

How it was proved

Proved by Proof.lean, checked by the kernel. Its attestation, 002923, records the gate’s run.

The proof in Lean (Proof.lean)

Checked by the kernel — these bytes are the ones its attestation names: attestations/002923.json, merge commit 4575f089c129.

Proof.lean — its sha256 is the artifact_hash of the attestation below, so these are the bytes the gate checked. Rendered from targets/vizing-conjecture/nodes/vizing-conjecture--h5--h1/Proof.lean, sha256 a429fb9e0d8e.
import Mathlib
import Defs.AnalysisSpecialFunctionsAdditiveCharacter
import Defs.CombinatoricsSimpleGraphDomination
import Nodes.«vizing-conjecture--h5--h1».Context

open SimpleGraph

/-! Hole `sun` of a merged partial proof, as a node (D-12 #5, D-29).
Statement generated by the gate from the assembly; immutable (D-3). -/

/-! ## Sun's theorem, `γ(G) = 3 → 3 γ(H) ≤ γ(G □ H)`: generic lemmas -/

/-- Three distinct elements of `Fin 3` exhaust it. -/
private theorem Opn.sun_fin3 : ∀ a b c x : Fin 3, a ≠ b → b ≠ c → a ≠ c → x = a ∨ x = b ∨ x = c := by
  decide

/-- Replacing `c` by a colour `i` that is in neither set never shrinks the union, and grows it when
`c` is in the other set. -/
private theorem Opn.sun_swap_term (A B : Finset (Fin 3)) (i c : Fin 3) (hc : c ∈ A) (hiA : i ∉ A)
    (hiB : i ∉ B) :
    (A ∪ B).card ≤ (insert i (A.erase c) ∪ B).card ∧
      (c ∈ B → (A ∪ B).card < (insert i (A.erase c) ∪ B).card) := by
  by_cases hcB : c ∈ B
  · have e : insert i (A.erase c) ∪ B = insert i (A ∪ B) := by
      ext x
      simp only [Finset.mem_union, Finset.mem_insert, Finset.mem_erase]
      constructor
      · rintro ((h | ⟨_, h⟩) | h)
        · exact Or.inl h
        · exact Or.inr (Or.inl h)
        · exact Or.inr (Or.inr h)
      · rintro (h | h | h)
        · exact Or.inl (Or.inl h)
        · by_cases hx : x = c
          · exact Or.inr (hx ▸ hcB)
          · exact Or.inl (Or.inr ⟨hx, h⟩)
        · exact Or.inr h
    have hn : i ∉ A ∪ B := by simp [hiA, hiB]
    rw [e, Finset.card_insert_of_notMem hn]
    exact ⟨Nat.le_succ _, fun _ => Nat.lt_succ_self _⟩
  · have e : insert i (A.erase c) ∪ B = insert i ((A ∪ B).erase c) := by
      ext x
      simp only [Finset.mem_union, Finset.mem_insert, Finset.mem_erase]
      constructor
      · rintro ((h | ⟨h1, h2⟩) | h)
        · exact Or.inl h
        · exact Or.inr ⟨h1, Or.inl h2⟩
        · exact Or.inr ⟨fun hx => hcB (hx ▸ h), Or.inr h⟩
      · rintro (h | ⟨h1, h2 | h2⟩)
        · exact Or.inl (Or.inl h)
        · exact Or.inl (Or.inr ⟨h1, h2⟩)
        · exact Or.inr h2
    have hn : i ∉ (A ∪ B).erase c := by simp [hiA, hiB]
    have hcm : c ∈ A ∪ B := Finset.mem_union_left _ hc
    rw [e, Finset.card_insert_of_notMem hn, Finset.card_erase_of_mem hcm]
    have : 0 < (A ∪ B).card := Finset.card_pos.mpr ⟨c, hcm⟩
    exact ⟨by omega, fun h => absurd h hcB⟩

/-- A double sum over a symmetric kernel that vanishes on the diagonal, split at one index. -/
private theorem Opn.sun_split {β : Type} [Fintype β] [DecidableEq β] (f : β → β → ℕ) (h : β)
    (hs : ∀ u w, f u w = f w u) (hd : f h h = 0) :
    ∑ u, ∑ w, f u w =
      2 * ∑ w, f h w + ∑ u ∈ Finset.univ.erase h, ∑ w ∈ Finset.univ.erase h, f u w := by
  have e0 : ∑ u, ∑ w, f u w = ∑ w, f h w + ∑ u ∈ Finset.univ.erase h, ∑ w, f u w :=
    (Finset.add_sum_erase Finset.univ (fun u => ∑ w, f u w) (Finset.mem_univ h)).symm
  have e1 : ∀ u, ∑ w, f u w = f u h + ∑ w ∈ Finset.univ.erase h, f u w := fun u =>
    (Finset.add_sum_erase Finset.univ (fun w => f u w) (Finset.mem_univ h)).symm
  have e2 : ∑ u ∈ Finset.univ.erase h, f u h = ∑ w, f h w := by
    rw [← Finset.add_sum_erase Finset.univ (fun w => f h w) (Finset.mem_univ h), hd, zero_add]
    exact Finset.sum_congr rfl (fun u _ => hs u h)
  rw [e0, Finset.sum_congr rfl (fun u _ => e1 u), Finset.sum_add_distrib, e2]
  ring

/-- The edge potential `Φ(C) = Σ_{u ~ w} |C u ∪ C w|`: changing `C` at `h` alone changes `Φ` by
twice the change of the terms at `h`. -/
private theorem Opn.sun_update {β : Type} [Fintype β] [DecidableEq β] (H : SimpleGraph β)
    [DecidableRel H.Adj] (C : β → Finset (Fin 3)) (h : β) (X : Finset (Fin 3)) :
    (∑ u, ∑ w, if H.Adj u w then (Function.update C h X u ∪ Function.update C h X w).card else 0) +
        2 * ∑ w, (if H.Adj h w then (C h ∪ C w).card else 0) =
      (∑ u, ∑ w, if H.Adj u w then (C u ∪ C w).card else 0) +
        2 * ∑ w, (if H.Adj h w then (X ∪ C w).card else 0) := by
  set C' := Function.update C h X with hC'
  have sC : ∀ u w, (if H.Adj u w then (C u ∪ C w).card else 0) =
      (if H.Adj w u then (C w ∪ C u).card else 0) := by
    intro u w
    by_cases hadj : H.Adj u w
    · rw [if_pos hadj, if_pos hadj.symm, Finset.union_comm]
    · rw [if_neg hadj, if_neg (fun h' => hadj h'.symm)]
  have sC' : ∀ u w, (if H.Adj u w then (C' u ∪ C' w).card else 0) =
      (if H.Adj w u then (C' w ∪ C' u).card else 0) := by
    intro u w
    by_cases hadj : H.Adj u w
    · rw [if_pos hadj, if_pos hadj.symm, Finset.union_comm]
    · rw [if_neg hadj, if_neg (fun h' => hadj h'.symm)]
  rw [Opn.sun_split (fun u w => if H.Adj u w then (C u ∪ C w).card else 0) h sC
      (by simp),
    Opn.sun_split (fun u w => if H.Adj u w then (C' u ∪ C' w).card else 0) h sC' (by simp)]
  have rest : ∑ u ∈ Finset.univ.erase h, ∑ w ∈ Finset.univ.erase h,
      (if H.Adj u w then (C' u ∪ C' w).card else 0) =
      ∑ u ∈ Finset.univ.erase h, ∑ w ∈ Finset.univ.erase h,
      (if H.Adj u w then (C u ∪ C w).card else 0) := by
    refine Finset.sum_congr rfl (fun u hu => Finset.sum_congr rfl (fun w hw => ?_))
    rw [hC', Function.update_of_ne (Finset.ne_of_mem_erase hu),
      Function.update_of_ne (Finset.ne_of_mem_erase hw)]
  have row : ∑ w, (if H.Adj h w then (C' h ∪ C' w).card else 0) =
      ∑ w, (if H.Adj h w then (X ∪ C w).card else 0) := by
    refine Finset.sum_congr rfl (fun w _ => ?_)
    by_cases hadj : H.Adj h w
    · rw [if_pos hadj, if_pos hadj, hC', Function.update_self,
        Function.update_of_ne (Ne.symm hadj.ne)]
    · rw [if_neg hadj, if_neg hadj]
  rw [rest, row]
  ring


/-- If `vᵢ ~ vⱼ` (neither is `v₂`) and `vᵢ` is the only vertex of type `{i}`, then `{vⱼ, v₂}`
dominates `G`, which no two vertices do. -/
private theorem Opn.sun_two {α : Type} (G : SimpleGraph α) (v : Fin 3 → α) (τ : α → Finset (Fin 3))
    (hmem : ∀ g p, p ∈ τ g → g = v p ∨ G.Adj g (v p)) (hne : ∀ g, (τ g).Nonempty)
    (h3 : ∀ x y : α, ∃ z, z ≠ x ∧ ¬ G.Adj z x ∧ z ≠ y ∧ ¬ G.Adj z y)
    (i j : Fin 3) (hij : i ≠ j) (hi2 : i ≠ 2) (hj2 : j ≠ 2) (hadj : G.Adj (v i) (v j))
    (honly : ∀ y, τ y = {i} → y = v i) : False := by
  obtain ⟨z, hz1, hz2, hz3, hz4⟩ := h3 (v j) (v 2)
  have outj : j ∉ τ z := fun h => by rcases hmem z j h with h' | h'; exacts [hz1 h', hz2 h']
  have out2 : (2 : Fin 3) ∉ τ z := fun h => by rcases hmem z 2 h with h' | h'; exacts [hz3 h', hz4 h']
  have hzi : τ z = {i} := by
    obtain ⟨p, hp⟩ := hne z
    refine Finset.eq_singleton_iff_unique_mem.mpr ⟨?_, fun q hq => ?_⟩
    · rcases Opn.sun_fin3 i j 2 p hij hj2 hi2 with h | h | h
      · exact h ▸ hp
      · exact absurd (h ▸ hp) outj
      · exact absurd (h ▸ hp) out2
    · rcases Opn.sun_fin3 i j 2 q hij hj2 hi2 with h | h | h
      · exact h
      · exact absurd (h ▸ hq) outj
      · exact absurd (h ▸ hq) out2
  have := honly z hzi
  subst this
  exact hz2 hadj

/-- Claim A: at a colouring that no single swap improves, every fibre sees all three colours, or it
is *bad*: its row is an `R`-vertex and a private neighbour `p` of `v k`, and its neighbours use
no colour but `k`. -/
private theorem Opn.sun_claimA {α β : Type} [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
    (G : SimpleGraph α) (H : SimpleGraph β)
    (v : Fin 3 → α) (τ : α → Finset (Fin 3))
    (hmem : ∀ g p, p ∈ τ g → g = v p ∨ G.Adj g (v p))
    (hv : ∀ p, τ (v p) = {p})
    (hne : ∀ g, (τ g).Nonempty)
    (hF1 : ∀ g i j, τ g = {j} → G.Adj g (v i) → i ≠ j → g = v j)
    (hF2 : ∀ g, τ g = {2} → g = v 2)
    (hF3 : ∀ g, G.Adj g (v 2) → 2 ≤ (τ g).card)
    (hF6 : ∀ g p, 2 ≤ (τ g).card → G.Adj g (v p) → p ∈ τ g)
    (h3 : ∀ x y : α, ∃ z, z ≠ x ∧ ¬ G.Adj z x ∧ z ≠ y ∧ ¬ G.Adj z y)
    (row : β → Finset α)
    (hdom : ∀ g h, g ∈ row h ∨ (∃ x ∈ row h, G.Adj g x) ∨ (∃ h', H.Adj h h' ∧ g ∈ row h'))
    (C : β → Finset (Fin 3))
    (hopt : ∀ h, (C h).card = min (row h).card 3 ∧ ∀ x ∈ row h, (C h ∩ τ x).Nonempty)
    (hswap : ∀ h i c, (∀ g, (g = h ∨ H.Adj h g) → i ∉ C g) → c ∈ C h →
      (∀ x ∈ row h, (insert i ((C h).erase c) ∩ τ x).Nonempty) → ∀ g, H.Adj h g → c ∉ C g)
    (h : β) :
    (∀ i, ∃ g, (g = h ∨ H.Adj h g) ∧ i ∈ C g) ∨
      (∃ x p k, row h = {x, p} ∧ x ≠ p ∧ 2 ≤ (τ x).card ∧ τ p = {k} ∧ p ≠ v k ∧
        ∀ g, H.Adj h g → C g ⊆ {k}) := by
  by_cases happy : ∀ i, ∃ g, (g = h ∨ H.Adj h g) ∧ i ∈ C g
  · exact Or.inl happy
  right
  obtain ⟨i, hmiss⟩ : ∃ i, ∀ g, (g = h ∨ H.Adj h g) → i ∉ C g := by
    by_contra hcon
    apply happy
    intro i
    by_contra hi
    exact hcon ⟨i, fun g hg hig => hi ⟨g, hg, hig⟩⟩
  have hiC : i ∉ C h := hmiss h (Or.inl rfl)
  -- a vertex of type `{i}` is in no row of `N[h]`
  have noi : ∀ g y, (g = h ∨ H.Adj h g) → y ∈ row g → τ y ≠ {i} := by
    intro g y hg hy hyi
    obtain ⟨q, hq⟩ := (hopt g).2 y hy
    rw [Finset.mem_inter, hyi, Finset.mem_singleton] at hq
    exact hmiss g hg (hq.2 ▸ hq.1)
  -- so a vertex of type `{i}` is dominated within the fibre
  have U2 : ∀ y, τ y = {i} → ∃ x ∈ row h, G.Adj y x := by
    intro y hy
    rcases hdom y h with h1 | h1 | ⟨h', hh', hy'⟩
    · exact absurd hy (noi h y (Or.inl rfl) h1)
    · exact h1
    · exact absurd hy (noi h' y (Or.inr hh') hy')
  obtain ⟨xi, hxi, hadji⟩ := U2 (v i) (hv i)
  -- a vertex outside the closed neighbourhood of the row sits in a neighbouring row
  have vert : ∀ z, z ∉ row h → (∀ x ∈ row h, ¬ G.Adj z x) → ∃ h', H.Adj h h' ∧ z ∈ row h' := by
    intro z hz hza
    rcases hdom z h with h1 | ⟨x, hx, hzx⟩ | h1
    · exact absurd h1 hz
    · exact absurd hzx (hza x hx)
    · exact h1
  have hcard := (hopt h).1
  have third : ∀ s t : Fin 3, ∃ m, m ≠ s ∧ m ≠ t := by decide
  obtain hge | hlt := le_or_gt 3 (row h).card
  · exfalso
    rw [min_eq_right hge] at hcard
    have : C h = Finset.univ := Finset.eq_univ_of_card _ (by simp [hcard])
    exact hiC (this ▸ Finset.mem_univ i)
  obtain h0 | h1 | h2 : (row h).card = 0 ∨ (row h).card = 1 ∨ (row h).card = 2 := by omega
  · exfalso
    rw [Finset.card_eq_zero] at h0
    rw [h0] at hxi
    exact Finset.notMem_empty _ hxi
  · -- one vertex in the row
    exfalso
    obtain ⟨x, hx⟩ := Finset.card_eq_one.mp h1
    rw [h1] at hcard
    obtain ⟨s, hs⟩ := Finset.card_eq_one.mp (by simpa using hcard)
    have hxx : x ∈ row h := by rw [hx]; exact Finset.mem_singleton_self x
    have hxi' : xi = x := by rw [hx] at hxi; exact Finset.mem_singleton.mp hxi
    rw [hxi'] at hadji
    have hsi : s ≠ i := fun e => hiC (by rw [hs, e]; exact Finset.mem_singleton_self i)
    obtain ⟨q0, hq0⟩ := (hopt h).2 x hxx
    rw [hs, Finset.mem_inter, Finset.mem_singleton] at hq0
    have hsx : s ∈ τ x := by rw [← hq0.1]; exact hq0.2
    by_cases hT : (τ x).card = 1
    · obtain ⟨j, hj⟩ := Finset.card_eq_one.mp hT
      have hjs : j = s := by rw [hj] at hsx; exact (Finset.mem_singleton.mp hsx).symm
      rw [hjs] at hj
      have hij : i ≠ s := fun e => hsi e.symm
      have hxv : x = v s := hF1 x i s hj hadji.symm hij
      have hi2 : i ≠ 2 := by
        intro e
        have := hF3 x (e ▸ hadji.symm)
        rw [hT] at this
        omega
      have hj2 : s ≠ 2 := by
        intro e
        have hx2 : x = v 2 := e ▸ hxv
        have := hF3 (v i) (hx2 ▸ hadji)
        rw [hv i, Finset.card_singleton] at this
        omega
      refine Opn.sun_two G v τ hmem hne h3 i s hij hi2 hj2 (hxv ▸ hadji) (fun y hy => ?_)
      obtain ⟨x', hx', hyx'⟩ := U2 y hy
      rw [hx] at hx'
      rw [Finset.mem_singleton.mp hx', hxv] at hyx'
      exact hF1 y s i hy hyx' (Ne.symm hij)
    · have hT2 : 2 ≤ (τ x).card := by
        have := (hne x).card_pos
        omega
      have hix : i ∈ τ x := hF6 x i hT2 hadji.symm
      -- swapping `s` for `i` is allowed, so the neighbours lack `s`
      have hswap' := hswap h i s hmiss (by rw [hs]; exact Finset.mem_singleton_self s) (by
        intro y hy
        rw [hx, Finset.mem_singleton] at hy
        rw [hy]
        exact ⟨i, Finset.mem_inter.mpr ⟨Finset.mem_insert_self _ _, hix⟩⟩)
      obtain ⟨m, hms, hmi⟩ := third s i
      obtain ⟨z, hz1, hz2, hz3, hz4⟩ := h3 x (v m)
      obtain ⟨h', hh', hz⟩ := vert z (by rw [hx, Finset.mem_singleton]; exact hz1)
        (by intro x' hx'; rw [hx, Finset.mem_singleton] at hx'; rw [hx']; exact hz2)
      obtain ⟨q, hq⟩ := (hopt h').2 z hz
      rw [Finset.mem_inter] at hq
      have hqm : q ≠ m := fun e => by
        rcases hmem z q hq.2 with e' | e'
        · exact hz3 (e ▸ e')
        · exact hz4 (e ▸ e')
      have hqi : q ≠ i := fun e => hmiss h' (Or.inr hh') (e ▸ hq.1)
      have hqs : q ≠ s := fun e => hswap' h' hh' (e ▸ hq.1)
      rcases Opn.sun_fin3 s i m q hsi (Ne.symm hmi) (Ne.symm hms) with e | e | e
      exacts [hqs e, hqi e, hqm e]
  · -- two vertices in the row
    obtain ⟨x, y, hxy, hrow⟩ := Finset.card_eq_two.mp h2
    rw [h2] at hcard
    obtain ⟨s1, s2, hs12, hC⟩ := Finset.card_eq_two.mp (by simpa using hcard)
    have hi1 : i ≠ s1 := fun e => hiC (by rw [hC, e]; simp)
    have hi2' : i ≠ s2 := fun e => hiC (by rw [hC, e]; simp)
    have memrow : ∀ z, z ∈ row h ↔ z = x ∨ z = y := by
      intro z; rw [hrow, Finset.mem_insert, Finset.mem_singleton]
    -- the colours of a singleton type in the row are among `s1, s2`
    have typ_in : ∀ z t, z ∈ row h → τ z = {t} → t = s1 ∨ t = s2 := by
      intro z t hz hzt
      obtain ⟨q, hq⟩ := (hopt h).2 z hz
      rw [Finset.mem_inter, hzt, Finset.mem_singleton, hC, Finset.mem_insert,
        Finset.mem_singleton] at hq
      rcases hq.1 with e | e
      · exact Or.inl (hq.2 ▸ e)
      · exact Or.inr (hq.2 ▸ e)
    -- swapping `t` for `i`, where `{t, u} = C h`, is allowed unless some row vertex has type `{t}`
    have swap_ok : ∀ t u, C h = {t, u} → t ≠ u → (∀ z ∈ row h, τ z ≠ {t}) →
        ∀ g, H.Adj h g → t ∉ C g := by
      intro t u htu htu' hnt
      have hti : t ∈ C h := by rw [htu]; simp
      refine hswap h i t hmiss hti (fun z hz => ?_)
      have hins : insert i ((C h).erase t) = {i, u} := by
        rw [htu, Finset.erase_insert (by simpa using htu')]
      rw [hins]
      obtain ⟨q, hq⟩ := (hopt h).2 z hz
      rw [Finset.mem_inter, htu, Finset.mem_insert, Finset.mem_singleton] at hq
      rcases hq.1 with e | e
      · -- `t ∈ τ z`, and `τ z ≠ {t}` gives another colour, which is `i` or `u`
        obtain ⟨r, hr, hrt⟩ : ∃ r ∈ τ z, r ≠ t := by
          by_contra hcon
          apply hnt z hz
          refine Finset.eq_singleton_iff_unique_mem.mpr ⟨e ▸ hq.2, fun r hr => ?_⟩
          by_contra hrt
          exact hcon ⟨r, hr, hrt⟩
        have hit : i ≠ t := by
          intro eit; apply hiC; rw [htu, eit]; simp
        have hiu : i ≠ u := by
          intro eiu; apply hiC; rw [htu, eiu]; simp
        rcases Opn.sun_fin3 t i u r (Ne.symm hit) hiu htu' with e' | e' | e'
        · exact absurd e' hrt
        · exact ⟨r, Finset.mem_inter.mpr ⟨by rw [e']; simp, hr⟩⟩
        · exact ⟨r, Finset.mem_inter.mpr ⟨by rw [e']; simp, hr⟩⟩
      · exact ⟨q, Finset.mem_inter.mpr ⟨by rw [e]; simp, hq.2⟩⟩
    -- the witness: a vertex outside `N[x] ∪ N[y]` sits in a neighbouring row
    obtain ⟨z, hz1, hz2, hz3, hz4⟩ := h3 x y
    obtain ⟨h', hh', hz⟩ := vert z (by
        rw [memrow]; rintro (e | e); exacts [hz1 e, hz3 e])
      (by intro x' hx'; rw [memrow] at hx'; rcases hx' with e | e <;> rw [e]; exacts [hz2, hz4])
    obtain ⟨q, hq⟩ := (hopt h').2 z hz
    rw [Finset.mem_inter] at hq
    have hqi : q ≠ i := fun e => hmiss h' (Or.inr hh') (e ▸ hq.1)
    -- one blocked colour `k`, the other `t` free
    have one_blocked : ∀ k t, C h = {k, t} → k ≠ t → i ≠ k → i ≠ t →
        (∀ z ∈ row h, τ z ≠ {t}) → (∃ w ∈ row h, τ w = {k}) →
        ∃ x p k, row h = {x, p} ∧ x ≠ p ∧ 2 ≤ (τ x).card ∧ τ p = {k} ∧ p ≠ v k ∧
          ∀ g, H.Adj h g → C g ⊆ {k} := by
      intro k t hkt hkt' hik hit hnt ⟨w, hw, hwk⟩
      have lack_t := swap_ok t k (by rw [hkt, Finset.pair_comm]) (Ne.symm hkt') hnt
      have sub : ∀ g, H.Adj h g → C g ⊆ {k} := by
        intro g hg r hr
        rw [Finset.mem_singleton]
        rcases Opn.sun_fin3 k t i r hkt' (Ne.symm hit) (Ne.symm hik) with e | e | e
        · exact e
        · exact absurd (e ▸ hr) (lack_t g hg)
        · exact absurd (e ▸ hr) (hmiss g (Or.inr hg))
      -- the other row vertex
      obtain ⟨o, ho, hwo, hrow'⟩ : ∃ o ∈ row h, o ≠ w ∧ row h = {o, w} := by
        rw [memrow] at hw
        rcases hw with e | e
        · exact ⟨y, (memrow y).mpr (Or.inr rfl), fun h' => hxy (h'.trans e).symm,
            by rw [e, hrow, Finset.pair_comm]⟩
        · exact ⟨x, (memrow x).mpr (Or.inl rfl), fun h' => hxy (h'.trans e), by rw [e, hrow]⟩
      have memrow' : ∀ z, z ∈ row h ↔ z = o ∨ z = w := by
        intro z; rw [hrow', Finset.mem_insert, Finset.mem_singleton]
      -- `z` sits in a row coloured `k`, so `z ∈ N[v k]`; hence no row vertex is `v k`
      have hqk : q = k := by
        have := sub h' hh' hq.1
        exact Finset.mem_singleton.mp this
      have hzk : z = v k ∨ G.Adj z (v k) := hmem z k (hqk ▸ hq.2)
      have notvk : ∀ u ∈ row h, u ≠ v k := by
        intro u hu e
        rw [memrow] at hu
        rcases hu with e' | e'
        · have hvx : v k = x := e.symm.trans e'
          rcases hzk with e'' | e''
          · exact hz1 (e''.trans hvx)
          · exact hz2 (hvx ▸ e'')
        · have hvy : v k = y := e.symm.trans e'
          rcases hzk with e'' | e''
          · exact hz3 (e''.trans hvy)
          · exact hz4 (hvy ▸ e'')
      have hwv : w ≠ v k := notvk w hw
      -- the other vertex is not of a singleton type
      have ho2 : 2 ≤ (τ o).card := by
        by_contra hlt
        have h1' : (τ o).card = 1 := by
          have := (hne o).card_pos
          omega
        obtain ⟨r, hr⟩ := Finset.card_eq_one.mp h1'
        have hrC : r ∈ C h := by
          rcases typ_in o r ho hr with e | e <;> rw [hC, e] <;> simp
        rw [hkt, Finset.mem_insert, Finset.mem_singleton] at hrC
        rcases hrC with e | e
        · rw [e] at hr
          rw [memrow'] at hxi
          rcases hxi with e1 | e1
          · rw [e1] at hadji
            exact notvk o ho (hF1 o i k hr hadji.symm hik)
          · rw [e1] at hadji
            exact hwv (hF1 w i k hwk hadji.symm hik)
        · exact hnt o ho (e ▸ hr)
      exact ⟨o, w, k, hrow', hwo, ho2, hwk, hwv, sub⟩
    by_cases b1 : ∃ w ∈ row h, τ w = {s1}
    · by_cases b2 : ∃ w ∈ row h, τ w = {s2}
      · -- both blocked: the row is `{q₁, q₂}` of types `{s1}, {s2}`
        exfalso
        obtain ⟨w1, hw1, hw1t⟩ := b1
        obtain ⟨w2, hw2, hw2t⟩ := b2
        have hw12 : w1 ≠ w2 := fun e => hs12 (by
          rw [e, hw2t] at hw1t; exact (Finset.singleton_inj.mp hw1t).symm)
        have hsub : ({w1, w2} : Finset α) ⊆ row h := by
          intro u hu
          rw [Finset.mem_insert, Finset.mem_singleton] at hu
          rcases hu with e | e <;> rw [e]
          exacts [hw1, hw2]
        have heq : ({w1, w2} : Finset α) = row h :=
          Finset.eq_of_subset_of_card_le hsub (by rw [h2, Finset.card_pair hw12])
        have hrow2 : ∀ u, u ∈ row h ↔ u = w1 ∨ u = w2 := by
          intro u; rw [← heq, Finset.mem_insert, Finset.mem_singleton]
        -- `i` is not `2`: `v 2`'s neighbours are not of singleton type
        have hi_2 : i ≠ 2 := by
          intro e
          have hx2 := hF3 xi (e ▸ hadji.symm)
          rcases (hrow2 xi).mp hxi with e' | e' <;> subst e'
          · rw [hw1t] at hx2; simp at hx2
          · rw [hw2t] at hx2; simp at hx2
        -- the generic argument with `{q, v 2}` and `q` of type `{j}`
        have finish : ∀ q c' j, (∀ u, u ∈ row h ↔ u = q ∨ u = c') → τ q = {j} → τ c' = {2} →
            i ≠ j → j ≠ 2 → False := by
          intro q c' j hr hq hc' hij hj2
          have hcv : c' = v 2 := hF2 c' hc'
          have hadj_q : G.Adj (v i) q := by
            rcases (hr xi).mp hxi with e' | e' <;> subst e'
            · exact hadji
            · exfalso
              have := hF3 (v i) (hcv ▸ hadji)
              rw [hv i] at this; simp at this
          have hqv : q = v j := hF1 q i j hq hadj_q.symm hij
          refine Opn.sun_two G v τ hmem hne h3 i j hij hi_2 hj2 (hqv ▸ hadj_q) (fun y' hy' => ?_)
          obtain ⟨x', hx', hyx'⟩ := U2 y' hy'
          rcases (hr x').mp hx' with e' | e' <;> subst e'
          · exact hF1 y' j i hy' (hqv ▸ hyx') (Ne.symm hij)
          · exfalso
            have := hF3 y' (hcv ▸ hyx')
            rw [hy'] at this; simp at this
        rcases Opn.sun_fin3 s1 s2 i 2 hs12 (Ne.symm hi2') (Ne.symm hi1) with e | e | e
        · exact finish w2 w1 s2 (fun u => by rw [hrow2]; tauto) hw2t (by rw [hw1t, ← e]) hi2'
            (fun e2 => hs12 (e.symm.trans e2.symm))
        · exact finish w1 w2 s1 hrow2 hw1t (by rw [hw2t, ← e]) hi1
            (fun e1 => hs12 (e1.trans e.symm.symm))
        · exact absurd e.symm hi_2
      · exact one_blocked s1 s2 hC hs12 hi1 hi2'
          (fun u hu hut => b2 ⟨u, hu, hut⟩) b1
    · by_cases b2 : ∃ w ∈ row h, τ w = {s2}
      · exact one_blocked s2 s1 (by rw [hC, Finset.pair_comm]) (Ne.symm hs12) hi2' hi1
          (fun u hu hut => b1 ⟨u, hu, hut⟩) b2
      · -- nothing blocked: the neighbours carry no colour at all
        exfalso
        have l1 := swap_ok s1 s2 hC hs12 (fun u hu hut => b1 ⟨u, hu, hut⟩)
        have l2 := swap_ok s2 s1 (by rw [hC, Finset.pair_comm]) (Ne.symm hs12)
          (fun u hu hut => b2 ⟨u, hu, hut⟩)
        rcases Opn.sun_fin3 s1 s2 i q hs12 (Ne.symm hi2') (Ne.symm hi1) with e | e | e
        · exact l1 h' hh' (e ▸ hq.1)
        · exact l2 h' hh' (e ▸ hq.1)
        · exact hqi e


/-! ## Repair: bad fibres take the two colours other than `k` -/

private theorem Opn.sun_repair {α β : Type} [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
    (G : SimpleGraph α) (H : SimpleGraph β)
    (v : Fin 3 → α) (τ : α → Finset (Fin 3))
    (hv : ∀ p, τ (v p) = {p})
    (h3 : ∀ x y : α, ∃ z, z ≠ x ∧ ¬ G.Adj z x ∧ z ≠ y ∧ ¬ G.Adj z y)
    (row : β → Finset α)
    (hdom : ∀ g h, g ∈ row h ∨ (∃ x ∈ row h, G.Adj g x) ∨ (∃ h', H.Adj h h' ∧ g ∈ row h'))
    (C : β → Finset (Fin 3))
    (hopt : ∀ h, (C h).card = min (row h).card 3 ∧ ∀ x ∈ row h, (C h ∩ τ x).Nonempty)
    (hA : ∀ h, (∀ i, ∃ g, (g = h ∨ H.Adj h g) ∧ i ∈ C g) ∨
      (∃ x p k, row h = {x, p} ∧ x ≠ p ∧ 2 ≤ (τ x).card ∧ τ p = {k} ∧ p ≠ v k ∧
        ∀ g, H.Adj h g → C g ⊆ {k})) :
    ∃ C' : β → Finset (Fin 3), (∀ h, (C' h).card ≤ (row h).card) ∧
      ∀ h i, ∃ g, (g = h ∨ H.Adj h g) ∧ i ∈ C' g := by
  classical
  have hk : ∀ h, ∃ k : Fin 3, (∀ i, ∃ g, (g = h ∨ H.Adj h g) ∧ i ∈ C g) ∨
      (∃ x p, row h = {x, p} ∧ x ≠ p ∧ 2 ≤ (τ x).card ∧ τ p = {k} ∧ p ≠ v k ∧
        ∀ g, H.Adj h g → C g ⊆ {k}) := by
    intro h
    rcases hA h with hh | ⟨x, p, k, hb⟩
    · exact ⟨0, Or.inl hh⟩
    · exact ⟨k, Or.inr ⟨x, p, hb⟩⟩
  choose k hk using hk
  let happy : β → Prop := fun h => ∀ i, ∃ g, (g = h ∨ H.Adj h g) ∧ i ∈ C g
  have bad : ∀ h, ¬ happy h → ∃ x p, row h = {x, p} ∧ x ≠ p ∧ 2 ≤ (τ x).card ∧ τ p = {k h} ∧
      p ≠ v (k h) ∧ ∀ g, H.Adj h g → C g ⊆ {k h} := by
    intro h hn
    rcases hk h with e | e
    · exact absurd e hn
    · exact e
  -- a neighbour of an unhappy fibre has at most one colour, so it is happy
  have card_bad : ∀ h, ¬ happy h → (C h).card = 2 := by
    intro h hn
    obtain ⟨x, p, hrow, hxp, -⟩ := bad h hn
    rw [(hopt h).1, hrow, Finset.card_pair hxp]
    rfl
  have nb_happy : ∀ h g, ¬ happy h → H.Adj h g → happy g := by
    intro h g hn hadj
    by_contra hg
    obtain ⟨-, -, -, -, -, -, -, sub⟩ := bad h hn
    have := Finset.card_le_card (sub g hadj)
    rw [card_bad g hg, Finset.card_singleton] at this
    omega
  -- `v k` lies in no unhappy row
  have vk_not_bad : ∀ h q, ¬ happy h → v q ∈ row h → False := by
    intro h q hn hq
    obtain ⟨x, p, hrow, -, hx2, hp, hpv, -⟩ := bad h hn
    rw [hrow, Finset.mem_insert, Finset.mem_singleton] at hq
    rcases hq with e' | e'
    · rw [← e', hv q] at hx2
      simp at hx2
    · rw [← e', hv q] at hp
      have : q = k h := Finset.singleton_injective hp
      exact hpv (by rw [← e', this])
  refine ⟨fun h => if happy h then C h else Finset.univ.erase (k h), ?_, ?_⟩
  · intro h
    by_cases hh : happy h
    · simp only [hh, if_true]
      rw [(hopt h).1]
      exact min_le_left _ _
    · simp only [hh, if_false]
      obtain ⟨x, p, hrow, hxp, -⟩ := bad h hh
      rw [hrow, Finset.card_pair hxp, Finset.card_erase_of_mem (Finset.mem_univ _)]
      simp
  · intro h i
    by_cases hh : happy h
    · obtain ⟨g, hg, hig⟩ := hh i
      by_cases hgh : happy g
      · exact ⟨g, hg, by simp only [hgh, if_true]; exact hig⟩
      · -- `g` is an unhappy neighbour of the happy `h`
        have hgne : g ≠ h := fun e => hgh (e ▸ hh)
        have hadj : H.Adj h g := hg.resolve_left hgne
        by_cases hik : i = k g
        · obtain ⟨-, -, -, -, -, -, -, sub⟩ := bad g hgh
          have hCh : C h ⊆ {k g} := sub h hadj.symm
          by_cases hkh : k g ∈ C h
          · exact ⟨h, Or.inl rfl, by simp only [hh, if_true]; rw [hik]; exact hkh⟩
          · -- `C h` is empty, so is `row h`, and `v k` sits in a happy neighbour's row
            have hC0 : C h = ∅ := by
              ext q
              simp only [Finset.notMem_empty, iff_false]
              intro hq
              have := hCh hq
              rw [Finset.mem_singleton] at this
              exact hkh (this ▸ hq)
            have hr0 : row h = ∅ := by
              have := (hopt h).1
              rw [hC0, Finset.card_empty] at this
              have h0 : (row h).card = 0 := by
                rcases Nat.eq_zero_or_pos (row h).card with e | e
                · exact e
                · exfalso
                  have : 0 < min (row h).card 3 := lt_min e (by norm_num)
                  omega
              exact Finset.card_eq_zero.mp h0
            rcases hdom (v (k g)) h with hm | ⟨x, hx, -⟩ | ⟨h', hadj', hm⟩
            · rw [hr0] at hm; exact absurd hm (Finset.notMem_empty _)
            · rw [hr0] at hx; exact absurd hx (Finset.notMem_empty _)
            · obtain ⟨q, hq⟩ := (hopt h').2 _ hm
              rw [Finset.mem_inter, hv] at hq
              have hqk : q = k g := Finset.mem_singleton.mp hq.2
              have hh' : happy h' := by
                by_contra hn'
                exact vk_not_bad h' (k g) hn' hm
              refine ⟨h', Or.inr hadj', ?_⟩
              simp only [hh', if_true]
              rw [hik, ← hqk]
              exact hq.1
        · exact ⟨g, hg, by
            simp only [hgh, if_false]
            exact Finset.mem_erase.mpr ⟨hik, Finset.mem_univ _⟩⟩
    · by_cases hik : i = k h
      · obtain ⟨x, p, hrow, hxp, -, -, -, sub⟩ := bad h hh
        obtain ⟨z, hz1, hz2, hz3, hz4⟩ := h3 x p
        rcases hdom z h with hm | ⟨y, hy, hzy⟩ | ⟨h', hadj', hm⟩
        · rw [hrow, Finset.mem_insert, Finset.mem_singleton] at hm
          rcases hm with e | e
          · exact absurd e hz1
          · exact absurd e hz3
        · rw [hrow, Finset.mem_insert, Finset.mem_singleton] at hy
          rcases hy with e | e
          · exact absurd (e ▸ hzy) hz2
          · exact absurd (e ▸ hzy) hz4
        · obtain ⟨q, hq⟩ := (hopt h').2 _ hm
          have hq1 := (Finset.mem_inter.mp hq).1
          have hqk : q = k h := Finset.mem_singleton.mp (sub h' hadj' hq1)
          have hh' : happy h' := nb_happy h h' hh hadj'
          refine ⟨h', Or.inr hadj', ?_⟩
          simp only [hh', if_true]
          rw [hik, ← hqk]
          exact hq1
      · exact ⟨h, Or.inl rfl, by
          simp only [hh, if_false]
          exact Finset.mem_erase.mpr ⟨hik, Finset.mem_univ _⟩⟩

/-! ## Count: three dominating sets of `H` out of the colouring -/

private theorem Opn.sun_count {β : Type} [Fintype β] [DecidableEq β] (H : SimpleGraph β)
    (C' : β → Finset (Fin 3)) (hcov : ∀ h i, ∃ g, (g = h ∨ H.Adj h g) ∧ i ∈ C' g) :
    3 * H.dominationNumber ≤ ∑ h, (C' h).card := by
  classical
  have hD : ∀ i : Fin 3, H.dominationNumber ≤ (Finset.univ.filter (fun h => i ∈ C' h)).card := by
    intro i
    apply SimpleGraph.dominationNumber_le_of_isDominating
    intro h
    obtain ⟨g, hg, hig⟩ := hcov h i
    rcases hg with e | hadj
    · left
      rw [← e]
      simpa using hig
    · right
      exact ⟨g, by simpa using hig, hadj⟩
  calc 3 * H.dominationNumber = ∑ _i : Fin 3, H.dominationNumber := by simp
    _ ≤ ∑ i : Fin 3, (Finset.univ.filter (fun h => i ∈ C' h)).card := Finset.sum_le_sum (fun i _ => hD i)
    _ = ∑ h, (C' h).card := by
      simp only [Finset.card_filter]
      rw [Finset.sum_comm]
      refine Finset.sum_congr rfl (fun h _ => ?_)
      rw [← Finset.card_filter]
      congr 1
      ext q
      simp


/-! ## The colouring: an option at every fibre, maximizing the edge potential -/

private theorem Opn.sun_choose {α β : Type} [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
    (H : SimpleGraph β) [DecidableRel H.Adj] (τ : α → Finset (Fin 3))
    (hne : ∀ g, (τ g).Nonempty) (row : β → Finset α) :
    ∃ C : β → Finset (Fin 3),
      (∀ h, (C h).card = min (row h).card 3 ∧ ∀ x ∈ row h, (C h ∩ τ x).Nonempty) ∧
      (∀ h i c, (∀ g, (g = h ∨ H.Adj h g) → i ∉ C g) → c ∈ C h →
        (∀ x ∈ row h, (insert i ((C h).erase c) ∩ τ x).Nonempty) → ∀ g, H.Adj h g → c ∉ C g) := by
  classical
  let opt : β → Finset (Fin 3) → Prop := fun h X =>
    X.card = min (row h).card 3 ∧ ∀ x ∈ row h, (X ∩ τ x).Nonempty
  have hex : ∀ h, ∃ X, opt h X := by
    intro h
    choose f hf using hne
    let S0 := (row h).image f
    have hS0 : S0.card ≤ min (row h).card 3 :=
      le_min Finset.card_image_le (by
        have := Finset.card_le_univ S0
        simpa using this)
    obtain ⟨X, hX, hXc⟩ := Finset.exists_superset_card_eq hS0 (by simp)
    refine ⟨X, hXc, fun x hx => ⟨f x, Finset.mem_inter.mpr ⟨hX (Finset.mem_image_of_mem f hx), hf x⟩⟩⟩
  let S : Finset (β → Finset (Fin 3)) :=
    Fintype.piFinset (fun h => Finset.univ.filter (opt h))
  have hS : S.Nonempty := by
    choose X hX using hex
    exact ⟨X, Fintype.mem_piFinset.mpr (fun h => by simpa using hX h)⟩
  let Φ : (β → Finset (Fin 3)) → ℕ := fun C =>
    ∑ u, ∑ w, if H.Adj u w then (C u ∪ C w).card else 0
  obtain ⟨C, hCS, hmax⟩ := Finset.exists_max_image S Φ hS
  have hCopt : ∀ h, opt h (C h) := fun h => by
    have := Fintype.mem_piFinset.mp hCS h
    simpa using this
  refine ⟨C, hCopt, ?_⟩
  intro h i c hi hc hmeet g hadj hcg
  have hiC : i ∉ C h := hi h (Or.inl rfl)
  have hic : i ≠ c := fun e => hiC (e ▸ hc)
  set X := insert i ((C h).erase c) with hXdef
  have hXcard : X.card = (C h).card := by
    rw [hXdef, Finset.card_insert_of_notMem (fun hm => hiC (Finset.mem_of_mem_erase hm)),
      Finset.card_erase_of_mem hc]
    have : 0 < (C h).card := Finset.card_pos.mpr ⟨c, hc⟩
    omega
  have hXopt : opt h X := ⟨by rw [hXcard]; exact (hCopt h).1, hmeet⟩
  have hC2 : Function.update C h X ∈ S := by
    refine Fintype.mem_piFinset.mpr (fun u => ?_)
    by_cases hu : u = h
    · subst hu; simpa using hXopt
    · rw [Function.update_of_ne hu]; simpa using hCopt u
  have hle := hmax _ hC2
  have hupd := Opn.sun_update H C h X
  have hlt : ∑ w, (if H.Adj h w then (C h ∪ C w).card else 0) <
      ∑ w, (if H.Adj h w then (X ∪ C w).card else 0) := by
    apply Finset.sum_lt_sum
    · intro w _
      by_cases hw : H.Adj h w
      · rw [if_pos hw, if_pos hw]
        exact (Opn.sun_swap_term (C h) (C w) i c hc hiC (hi w (Or.inr hw))).1
      · rw [if_neg hw, if_neg hw]
    · refine ⟨g, Finset.mem_univ _, ?_⟩
      rw [if_pos hadj, if_pos hadj]
      exact (Opn.sun_swap_term (C h) (C g) i c hc hiC (hi g (Or.inr hadj))).2 hcg
  simp only [Φ] at hle
  omega


/-! ## The core: from the type function to the bound on `D` -/

private theorem Opn.sun_core {α β : Type} [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
    (G : SimpleGraph α) (H : SimpleGraph β)
    (v : Fin 3 → α) (τ : α → Finset (Fin 3))
    (hmem : ∀ g p, p ∈ τ g → g = v p ∨ G.Adj g (v p))
    (hv : ∀ p, τ (v p) = {p})
    (hne : ∀ g, (τ g).Nonempty)
    (hF1 : ∀ g i j, τ g = {j} → G.Adj g (v i) → i ≠ j → g = v j)
    (hF2 : ∀ g, τ g = {2} → g = v 2)
    (hF3 : ∀ g, G.Adj g (v 2) → 2 ≤ (τ g).card)
    (hF6 : ∀ g p, 2 ≤ (τ g).card → G.Adj g (v p) → p ∈ τ g)
    (h3 : ∀ x y : α, ∃ z, z ≠ x ∧ ¬ G.Adj z x ∧ z ≠ y ∧ ¬ G.Adj z y)
    (D : Finset (α × β)) (hD : (G □ H).IsDominating D) :
    3 * H.dominationNumber ≤ D.card := by
  classical
  let row : β → Finset α := fun h => (D.filter (fun d => d.2 = h)).image Prod.fst
  have hrow : ∀ g h, g ∈ row h ↔ (g, h) ∈ D := by
    intro g h
    simp only [row, Finset.mem_image, Finset.mem_filter]
    constructor
    · rintro ⟨⟨a, b⟩, ⟨hab, hb⟩, ha⟩
      simp only at hb ha
      rw [← ha, ← hb]; exact hab
    · intro hm; exact ⟨(g, h), ⟨hm, rfl⟩, rfl⟩
  have hdom : ∀ g h, g ∈ row h ∨ (∃ x ∈ row h, G.Adj g x) ∨ (∃ h', H.Adj h h' ∧ g ∈ row h') := by
    intro g h
    rcases hD (g, h) with hm | ⟨⟨a, b⟩, hm, hadj⟩
    · exact Or.inl ((hrow g h).mpr (Finset.mem_coe.mp hm))
    · have hm' : (a, b) ∈ D := Finset.mem_coe.mp hm
      rw [SimpleGraph.boxProd_adj] at hadj
      rcases hadj with ⟨hga, hb⟩ | ⟨hhb, hg⟩
      · simp only at hga hb
        exact Or.inr (Or.inl ⟨a, (hrow a h).mpr (hb ▸ hm'), hga⟩)
      · simp only at hhb hg
        exact Or.inr (Or.inr ⟨b, hhb, (hrow g b).mpr (hg ▸ hm')⟩)
  obtain ⟨C, hopt, hswap⟩ := Opn.sun_choose H τ hne row
  have hA := Opn.sun_claimA G H v τ hmem hv hne hF1 hF2 hF3 hF6 h3 row hdom C hopt hswap
  obtain ⟨C', hcard, hcov⟩ := Opn.sun_repair G H v τ hv h3 row hdom C hopt hA
  have hsum : ∑ h, (row h).card ≤ D.card := by
    rw [Finset.card_eq_sum_card_fiberwise (f := Prod.snd) (t := Finset.univ)
      (fun _ _ => Finset.mem_univ _)]
    exact Finset.sum_le_sum (fun h _ => Finset.card_image_le)
  calc 3 * H.dominationNumber ≤ ∑ h, (C' h).card := Opn.sun_count H C' hcov
    _ ≤ ∑ h, (row h).card := Finset.sum_le_sum (fun h _ => hcard h)
    _ ≤ D.card := hsum


/-! ## Reduction (Brešar, Observations 3 and 4) and the concrete types -/

/-- No two vertices dominate a graph of domination number three. -/
private theorem Opn.sun_h3 {α : Type} [Fintype α] [DecidableEq α] (M : SimpleGraph α)
    (hM : M.dominationNumber = 3) :
    ∀ x y : α, ∃ z, z ≠ x ∧ ¬ M.Adj z x ∧ z ≠ y ∧ ¬ M.Adj z y := by
  intro x y
  by_contra hcon
  push Not at hcon
  have hdom : M.IsDominating (({x, y} : Finset α) : Set α) := by
    intro z
    by_cases hzx : z = x
    · left; simp [hzx]
    by_cases hzy : z = y
    · left; simp [hzy]
    by_cases hax : M.Adj z x
    · right; exact ⟨x, by simp, hax⟩
    · right; exact ⟨y, by simp, hcon z hzx hax hzy⟩
  have h1 := SimpleGraph.dominationNumber_le_of_isDominating M _ hdom
  have h2 : ({x, y} : Finset α).card ≤ 2 := Finset.card_le_two
  omega

/-- A dominating set of a graph dominates every graph with more edges. -/
private theorem Opn.sun_dom_mono {α : Type} {G M : SimpleGraph α} (hGM : G ≤ M) (D : Set α)
    (hD : G.IsDominating D) : M.IsDominating D := by
  intro z
  rcases hD z with h | ⟨w, hw, hadj⟩
  · exact Or.inl h
  · exact Or.inr ⟨w, hw, hGM hadj⟩

/-- The last step of the reduction, with the two dominating vertices in either order. -/
private theorem Opn.sun_reduce_end {α : Type} (M M' : SimpleGraph α) (z x e f w : α)
    (hM' : ∀ u w, M'.Adj u w ↔ M.Adj u w ∨ (u = z ∧ w = x) ∨ (u = x ∧ w = z))
    (hE : ∀ t, t = e ∨ M'.Adj t e ∨ t = f ∨ M'.Adj t f)
    (hwe : (w = z ∧ e = x) ∨ (w = x ∧ e = z))
    (h1 : w ≠ e) (h2 : ¬ M.Adj w e) (h3 : w ≠ f) (h4 : ¬ M.Adj w f) :
    ∃ a b c : α, (∀ t, t ≠ c → t = a ∨ M.Adj t a ∨ t = b ∨ M.Adj t b) ∧
      c ≠ a ∧ ¬ M.Adj c a ∧ c ≠ b ∧ ¬ M.Adj c b := by
  refine ⟨e, f, w, fun t ht => ?_, h1, h2, h3, h4⟩
  rcases hE t with h | h | h | h
  · exact Or.inl h
  · rw [hM'] at h
    rcases h with h | h
    · exact Or.inr (Or.inl h)
    · exfalso
      rcases h with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ <;> rcases hwe with ⟨rfl, h'⟩ | ⟨rfl, h'⟩ <;>
        simp_all
  · exact Or.inr (Or.inr (Or.inl h))
  · rw [hM'] at h
    rcases h with h | h
    · exact Or.inr (Or.inr (Or.inr h))
    · rcases h with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ <;> rcases hwe with ⟨rfl, h'⟩ | ⟨rfl, h'⟩ <;>
        simp_all

private theorem Opn.sun_reduce {α : Type} [Fintype α] [DecidableEq α] (G : SimpleGraph α)
    (hG : G.dominationNumber = 3) :
    ∃ M : SimpleGraph α, G ≤ M ∧ M.dominationNumber = 3 ∧ ∃ a b c : α,
      (∀ t, t ≠ c → t = a ∨ M.Adj t a ∨ t = b ∨ M.Adj t b) ∧
      c ≠ a ∧ ¬ M.Adj c a ∧ c ≠ b ∧ ¬ M.Adj c b := by
  classical
  have : Finite (SimpleGraph α) :=
    Finite.of_injective SimpleGraph.Adj (fun G₁ G₂ h => SimpleGraph.ext h)
  obtain ⟨M, hMs, hMmax⟩ := Set.Finite.exists_maximal
    (s := {M : SimpleGraph α | G ≤ M ∧ M.dominationNumber = 3}) (Set.toFinite _) ⟨G, le_rfl, hG⟩
  obtain ⟨hGM, hM3⟩ := hMs
  have h3 := Opn.sun_h3 M hM3
  refine ⟨M, hGM, hM3, ?_⟩
  obtain ⟨D0, hD0⟩ := SimpleGraph.exists_isNDominatingSet_dominationNumber M
  have hD0c : D0.card = 3 := hD0.card_eq.trans hM3
  obtain ⟨x0, -⟩ : D0.Nonempty := Finset.card_pos.mp (by omega)
  obtain ⟨z, hzx, hnzx, -, -⟩ := h3 x0 x0
  -- add the edge `z x0`
  let M' : SimpleGraph α := M ⊔ SimpleGraph.fromRel (fun u w => u = z ∧ w = x0)
  have hM' : ∀ u w, M'.Adj u w ↔ M.Adj u w ∨ (u = z ∧ w = x0) ∨ (u = x0 ∧ w = z) := by
    intro u w
    simp only [M', SimpleGraph.sup_adj, SimpleGraph.fromRel_adj]
    constructor
    · rintro (h | ⟨-, ⟨h1, h2⟩ | ⟨h1, h2⟩⟩)
      · exact Or.inl h
      · exact Or.inr (Or.inl ⟨h1, h2⟩)
      · exact Or.inr (Or.inr ⟨h2, h1⟩)
    · rintro (h | ⟨h1, h2⟩ | ⟨h1, h2⟩)
      · exact Or.inl h
      · exact Or.inr ⟨by rw [h1, h2]; exact hzx, Or.inl ⟨h1, h2⟩⟩
      · exact Or.inr ⟨by rw [h1, h2]; exact Ne.symm hzx, Or.inr ⟨h2, h1⟩⟩
  have hMM' : M ≤ M' := le_sup_left
  have hne3 : M'.dominationNumber ≠ 3 := by
    intro e
    have := hMmax ⟨hGM.trans hMM', e⟩ hMM'
    exact hnzx (this ((hM' z x0).mpr (Or.inr (Or.inl ⟨rfl, rfl⟩))))
  have hle3 : M'.dominationNumber ≤ 3 := by
    have := SimpleGraph.dominationNumber_le_of_isDominating M' D0
      (Opn.sun_dom_mono hMM' _ hD0.isDominating)
    omega
  obtain ⟨E, hE⟩ := SimpleGraph.exists_isNDominatingSet_dominationNumber M'
  have hEc : E.card ≤ 2 := by
    have := hE.card_eq
    omega
  -- `E ⊆ {e1, e2}`
  obtain ⟨e1, e2, hsub⟩ : ∃ e1 e2, E ⊆ {e1, e2} := by
    interval_cases hc : E.card
    · exact ⟨x0, x0, by rw [Finset.card_eq_zero.mp hc]; exact Finset.empty_subset _⟩
    · obtain ⟨e, he⟩ := Finset.card_eq_one.mp hc
      exact ⟨e, e, by rw [he]; intro q hq; simp_all⟩
    · obtain ⟨a, b, -, he⟩ := Finset.card_eq_two.mp hc
      exact ⟨a, b, by rw [he]⟩
  have hE2 : ∀ t, t = e1 ∨ M'.Adj t e1 ∨ t = e2 ∨ M'.Adj t e2 := by
    intro t
    rcases hE.isDominating t with h | ⟨w, hw, hadj⟩
    · have := hsub (Finset.mem_coe.mp h)
      simp only [Finset.mem_insert, Finset.mem_singleton] at this
      rcases this with e | e
      · exact Or.inl e
      · exact Or.inr (Or.inr (Or.inl e))
    · have := hsub (Finset.mem_coe.mp hw)
      simp only [Finset.mem_insert, Finset.mem_singleton] at this
      rcases this with e | e
      · exact Or.inr (Or.inl (e ▸ hadj))
      · exact Or.inr (Or.inr (Or.inr (e ▸ hadj)))
  obtain ⟨w, hw1, hw2, hw3, hw4⟩ := h3 e1 e2
  rcases hE2 w with h | h | h | h
  · exact absurd h hw1
  · rw [hM'] at h
    rcases h with h | h
    · exact absurd h hw2
    · exact Opn.sun_reduce_end M M' z x0 e1 e2 w hM' hE2 h hw1 hw2 hw3 hw4
  · exact absurd h hw3
  · rw [hM'] at h
    rcases h with h | h
    · exact absurd h hw4
    · exact Opn.sun_reduce_end M M' z x0 e2 e1 w hM'
        (fun t => by rcases hE2 t with q | q | q | q <;> tauto) h hw3 hw4 hw1 hw2


/-! ## The types of vertices, from `a b c` -/

private theorem Opn.sun_types {α : Type} [Fintype α] [DecidableEq α] (M : SimpleGraph α)
    (a b c : α) (hcov : ∀ t, t ≠ c → t = a ∨ M.Adj t a ∨ t = b ∨ M.Adj t b)
    (hca : c ≠ a) (hnca : ¬ M.Adj c a) (hcb : c ≠ b) (hncb : ¬ M.Adj c b)
    (h3 : ∀ x y : α, ∃ z, z ≠ x ∧ ¬ M.Adj z x ∧ z ≠ y ∧ ¬ M.Adj z y) :
    ∃ (v : Fin 3 → α) (τ : α → Finset (Fin 3)),
      (∀ g p, p ∈ τ g → g = v p ∨ M.Adj g (v p)) ∧
      (∀ p, τ (v p) = {p}) ∧
      (∀ g, (τ g).Nonempty) ∧
      (∀ g i j, τ g = {j} → M.Adj g (v i) → i ≠ j → g = v j) ∧
      (∀ g, τ g = {2} → g = v 2) ∧
      (∀ g, M.Adj g (v 2) → 2 ≤ (τ g).card) ∧
      (∀ g p, 2 ≤ (τ g).card → M.Adj g (v p) → p ∈ τ g) := by
  classical
  have hab : a ≠ b := by
    intro e
    obtain ⟨z, hz1, hz2, hz3, hz4⟩ := h3 a c
    rcases hcov z hz3 with h | h | h | h
    · exact hz1 h
    · exact hz2 h
    · exact hz1 (h.trans e.symm)
    · exact hz2 (e ▸ h)
  let v : Fin 3 → α := ![a, b, c]
  have v0 : v 0 = a := rfl
  have v1 : v 1 = b := rfl
  have v2 : v 2 = c := rfl
  let τ : α → Finset (Fin 3) := fun g =>
    if g = a then {0} else if g = b then {1} else if g = c then {2}
    else Finset.univ.filter (fun p => M.Adj g (v p))
  have hv : ∀ p, τ (v p) = {p} := by
    intro p
    fin_cases p
    · simp [τ, v0]
    · simp [τ, v1, hab.symm]
    · simp [τ, v2, hca, hcb]
  have hcase : ∀ g, (∃ q, g = v q ∧ τ g = {q}) ∨
      (g ≠ a ∧ g ≠ b ∧ g ≠ c ∧ ∀ p, p ∈ τ g ↔ M.Adj g (v p)) := by
    intro g
    by_cases ha : g = a
    · exact Or.inl ⟨0, by rw [ha, v0], by rw [ha, ← v0, hv]⟩
    by_cases hb : g = b
    · exact Or.inl ⟨1, by rw [hb, v1], by rw [hb, ← v1, hv]⟩
    by_cases hc : g = c
    · exact Or.inl ⟨2, by rw [hc, v2], by rw [hc, ← v2, hv]⟩
    refine Or.inr ⟨ha, hb, hc, fun p => ?_⟩
    simp [τ, ha, hb, hc]
  -- a vertex other than `a b c` sees `a` or `b`
  have hab' : ∀ g, g ≠ a → g ≠ b → g ≠ c → (0 : Fin 3) ∈ τ g ∨ (1 : Fin 3) ∈ τ g := by
    intro g ha hb hc
    rcases hcase g with ⟨q, hq, -⟩ | ⟨-, -, -, hiff⟩
    · exfalso
      fin_cases q
      · exact ha hq
      · exact hb hq
      · exact hc hq
    · rcases hcov g hc with h | h | h | h
      · exact absurd h ha
      · exact Or.inl ((hiff 0).mpr (v0 ▸ h))
      · exact absurd h hb
      · exact Or.inr ((hiff 1).mpr (v1 ▸ h))
  refine ⟨v, τ, ?_, hv, ?_, ?_, ?_, ?_, ?_⟩
  · intro g p hp
    rcases hcase g with ⟨q, hq, hτ⟩ | ⟨-, -, -, hiff⟩
    · rw [hτ, Finset.mem_singleton] at hp
      exact Or.inl (hp ▸ hq)
    · exact Or.inr ((hiff p).mp hp)
  · intro g
    rcases hcase g with ⟨q, -, hτ⟩ | ⟨ha, hb, hc, -⟩
    · rw [hτ]; exact Finset.singleton_nonempty q
    · rcases hab' g ha hb hc with h | h
      · exact ⟨0, h⟩
      · exact ⟨1, h⟩
  · intro g i j hτj hadj hij
    rcases hcase g with ⟨q, hq, hτ⟩ | ⟨-, -, -, hiff⟩
    · rw [hτ] at hτj
      rw [hq, Finset.singleton_injective hτj]
    · have := (hiff i).mpr hadj
      rw [hτj, Finset.mem_singleton] at this
      exact absurd this hij
  · intro g hτ2
    rcases hcase g with ⟨q, hq, hτ⟩ | ⟨ha, hb, hc, -⟩
    · rw [hτ] at hτ2
      rw [hq, Finset.singleton_injective hτ2]
    · rcases hab' g ha hb hc with h | h <;> rw [hτ2] at h <;> simp at h
  · intro g hadj
    rcases hcase g with ⟨q, hq, -⟩ | ⟨ha, hb, hc, hiff⟩
    · exfalso
      rw [v2, hq] at hadj
      rcases (by decide : ∀ q : Fin 3, q = 0 ∨ q = 1 ∨ q = 2) q with e | e | e <;> rw [e] at hadj
      · rw [v0] at hadj; exact hnca hadj.symm
      · rw [v1] at hadj; exact hncb hadj.symm
      · rw [v2] at hadj; exact M.irrefl hadj
    · have h2 : (2 : Fin 3) ∈ τ g := (hiff 2).mpr hadj
      rcases hab' g ha hb hc with h | h
      · calc 2 = ({0, 2} : Finset (Fin 3)).card := by decide
          _ ≤ (τ g).card := Finset.card_le_card (by
              intro q hq; simp only [Finset.mem_insert, Finset.mem_singleton] at hq
              rcases hq with e | e <;> rw [e] <;> assumption)
      · calc 2 = ({1, 2} : Finset (Fin 3)).card := by decide
          _ ≤ (τ g).card := Finset.card_le_card (by
              intro q hq; simp only [Finset.mem_insert, Finset.mem_singleton] at hq
              rcases hq with e | e <;> rw [e] <;> assumption)
  · intro g p hcard hadj
    rcases hcase g with ⟨q, -, hτ⟩ | ⟨-, -, -, hiff⟩
    · rw [hτ, Finset.card_singleton] at hcard; omega
    · exact (hiff p).mpr hadj


theorem vizing_conjecture__h5__h1 : ∀ {α β : Type} [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β] (G : SimpleGraph α) (H : SimpleGraph β),
  G.dominationNumber = (3 : ℕ) → (3 : ℕ) * H.dominationNumber ≤ (G □ H).dominationNumber := by
  intro α β _ _ _ _ G H hG
  classical
  obtain ⟨M, hGM, hM3, a, b, c, hcov, hca, hnca, hcb, hncb⟩ := Opn.sun_reduce G hG
  have h3 := Opn.sun_h3 M hM3
  obtain ⟨v, τ, hmem, hv, hne, hF1, hF2, hF3, hF6⟩ :=
    Opn.sun_types M a b c hcov hca hnca hcb hncb h3
  obtain ⟨D, hD⟩ := SimpleGraph.exists_isNDominatingSet_dominationNumber (G □ H)
  rw [← hD.card_eq]
  have hmono : (G □ H) ≤ (M □ H) := by
    intro x y hxy
    rw [SimpleGraph.boxProd_adj] at hxy ⊢
    rcases hxy with ⟨h1, h2⟩ | ⟨h1, h2⟩
    · exact Or.inl ⟨hGM h1, h2⟩
    · exact Or.inr ⟨h1, h2⟩
  exact Opn.sun_core M H v τ hmem hv hne hF1 hF2 hF3 hF6 h3 D
    (Opn.sun_dom_mono hmono _ hD.isDominating)

What is known

Literature: Known: a proof is published and not formalised · proposed by t1203r2-v, awaiting a steward or curator

References and summary
Literature status

Proposed by t1203r2-v, awaiting a steward or curator: Known: a proof is published and not formalised (record, 2026-12-03T14:31:54Z).

Untrusted contributor text — a literature summary (D-25 v3.35): the contributor’s reading, not a verdict.

Untrusted: summary by t1203r2-v, drafted with Claude Opus 5.5 (claude-opus-5-5) through Claude Code; the 2012 survey read, Crossref for the references. Rendered from targets/vizing-conjecture/nodes/vizing-conjecture--h5--h1/literature/20261203T143154Z-t1203r2-v.yaml.

Every finite graph G with domination number 3 satisfies Vizing's inequality against every graph H. Proved by L. Sun (2004); a new proof was given by B. Bresar (2015). The node's statement is this theorem for finite simple graphs, with no further hypothesis. We know of no formalisation and did not attempt one.

Work on it

No explainer yet. This proof written as a journal would print it, labelled unverified, is the next thing a writer could add, by pull request (D-3, D-36; the guide shows how).

Write the explainer →

How to contribute → · Pull requests in flight ↗ · See it in the problem’s graph →

Record

Statement: the Lean file and its words (1 version)

Statement not audited — only a problem’s root statement is audited for fidelity (D-9); the kernel checks a proof against this Lean as written.

import Mathlib
import Defs.AnalysisSpecialFunctionsAdditiveCharacter
import Defs.CombinatoricsSimpleGraphDomination
import Nodes.«vizing-conjecture--h5--h1».Context

open SimpleGraph

/-! Hole `sun` of a merged partial proof, as a node (D-12 #5, D-29).
Statement generated by the gate from the assembly; immutable (D-3). -/

theorem vizing_conjecture__h5__h1 : ∀ {α β : Type} [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β] (G : SimpleGraph α) (H : SimpleGraph β),
  G.dominationNumber = (3 : ℕ) → (3 : ℕ) * H.dominationNumber ≤ (G □ H).dominationNumber := by
  sorry

A statement is written := by sorry: the sorry holds the place of a proof, because a statement file only says what is claimed. A proof the gate checked is its own file, Proof.lean. How to read a proof page →

In words, unverified — what this statement says; written by t1203r2-v, drafted with claude-opus-5-5+claude-fable-5-1, 2026-12-03; no one has read it against the Lean and signed it.

Draft · drafted, by the model named above

$\displaystyle \gamma(G) = 3 \implies 3\,\gamma(H) \le \gamma(G \,\square\, H)$

For all finite graphs G and H. The statement is that of L. Sun, A result on Vizing's conjecture, Discrete Mathematics 275 (2004) 363-366; Theorem 6.4 of the survey of Bresar, Dorbec, Goddard, Hartnell, Henning, Klavzar and Rall, J. Graph Theory 69 (2012) 46-76.

Rendered from gloss/61038a149b2b….md · Improve these words →

Rendered from targets/vizing-conjecture/nodes/vizing-conjecture--h5--h1/Statement.lean. Origin: compiler-derived.

Attestation: pass, 7 of 7 checks

Checked by the kernel — the gate’s record of the run: attestations/002923.json, merge commit 4575f089c129.

Verdict pass, from attestations/002923.json.

Submitter
fable-1203-vizing
Toolchain
leanprover/lean4:v4.33.1 (hash f54d0bc916bf76a7fae460ce9d078ccd1f74aeb4fd12c4b6546bca28b6aa1c63)
Mathlib
0df444a360eaa60ab8c11dca51a86af692955474
Reviewer
none needed (intermediate)
StepCheckResult
1toolchainpass
2pathspass
4kernel-replaypass
5axiomspass
6hazardspass
7witnesspass
8depspass
Witness

Checked by the kernel — step 7 passed in the run its attestation records: attestations/002923.json, merge commit 4575f089c129.

Witness.lean — checked at step 7 of the run recorded below: pass. Rendered from targets/vizing-conjecture/nodes/vizing-conjecture--h5--h1/Witness.lean, sha256 41a3f1d00536.
import Mathlib
import Defs.AnalysisSpecialFunctionsAdditiveCharacter
import Defs.CombinatoricsSimpleGraphDomination

open SimpleGraph

theorem witness : ∃ (α : Type) (β : Type) (inst : Fintype α) (inst_1 : Fintype β) (inst_2 : DecidableEq α) (inst_3 : DecidableEq β)
  (G : SimpleGraph α) (H : SimpleGraph β), G.dominationNumber = 3 := by
  refine ⟨Fin 3, Fin 1, inferInstance, inferInstance, inferInstance, inferInstance, ⊥, ⊥, le_antisymm ?_ ?_⟩
  · exact SimpleGraph.dominationNumber_le_of_isDominating _ (Finset.univ : Finset (Fin 3))
      (fun v => Or.inl (Finset.mem_coe.mpr (Finset.mem_univ v)))
  · obtain ⟨D, hD, hc⟩ := SimpleGraph.exists_isNDominatingSet_dominationNumber (⊥ : SimpleGraph (Fin 3))
    rw [← hc]
    have hsub : (Finset.univ : Finset (Fin 3)) ⊆ D := by
      intro i _
      rcases hD i with h | ⟨y, _, hadj⟩
      · exact Finset.mem_coe.mp h
      · exact absurd hadj (by simp)
    simpa using Finset.card_le_card hsub

In words, unverified — what this witness says; written by t1203r2-v, drafted with Claude Opus 5.5 (claude-opus-5-5), 2026-12-03; no one has read it against the Lean and signed it.

Draft · drafted, by the model named above

$\displaystyle \exists\, G, H:\ \gamma(G) = 3$

The example given is $G$ the graph with three vertices and no edge, and $H = K_1$. Every vertex of an edgeless graph must be in a dominating set, so $\gamma(G) = 3$.

Rendered from gloss/3b343e793a3c….md · Improve these words →

How to read this page