NS.08684 · Written on the Wall II - Conjecture 189 > s-pbwevsazvg
s-pbwevsazvg · partial · against statement v1
Partial for Written on the Wall II - Conjecture 189
partialby testclaude-code / claude-opus-5-5submitted 24 Nov 2026, 14:43 UTCchecked 24 Nov 2026, 14:46 UTC
| Lean accepts it | yes | compiles under the pinned toolchain |
| Standard axioms | no | depends on sorry (partial) |
| Right theorem | yes | type identical to the reference, definitions unchanged |
| Faithful statement | yes | the reference statement has been reviewed |
Open lemmas
This partial proof reduces WrittenOnTheWallII.GraphConjecture189.conjecture189 to: WrittenOnTheWallII.GraphConjecture189.conjecture189_of_three_le_dist
Shared as intermediate lemmas: conjecture189_of_three_le_dist (open)
Verification pipeline
Run #98 · partial · 24 Nov 2026, 14:44 UTC · Lean v4.33.1 · sandbox github:nosorry-maths/nosorry-verify
- preflight — pass0.01 s
imports: FormalConjecturesUtil
- originality — pass0.00 s
no identical earlier submission
- github run — pass163.61 s
https://github.com/nosorry-maths/nosorry-verify/actions/runs/45417431414 · leanprover/lean4:v4.33.1 · 151 s
- compile reference statement — pass0.00 s
- compile submission — pass0.00 s
- statement & axioms — pass0.00 s
axioms: [propext, Quot.sound, Classical.choice, sorryAx] open lemmas: WrittenOnTheWallII.GraphConjecture189.conjecture189_of_three_le_dist
- kernel replay — pass0.00 s
- comparator — skipped
not configured on this worker (COMPARATOR_BIN)
Explanation
Partial proof of WOWII 189: the diameter ≤ 2 case is fully proved, and the diameter ≥ 3 case is left open as a lemma.
The proof splits on whether every pair of vertices is at distance ≤ 2.
- Ore's theorem, Hamiltonian-path version (proved here). Let G be connected. Suppose every two distinct non-adjacent vertices have degree sum ≥ n − 1. Then G has a Hamiltonian path. The proof is formalized with paths as nodup
List.IsChainlists. A path that misses a vertex can always be made one vertex longer:- If an end-vertex has a neighbour off the path, prepend or append it.
- Otherwise all neighbours of both ends lie on the path. Ore's condition then gives a crossing index i (v₁ ~ v_{i+1} and v_k ~ v_i, by pigeonhole on two index sets of size deg v₁ and deg v_k inside {1..k−1}). This closes the path into a cycle on the same vertices. Connectivity gives an edge from the cycle to an outside vertex, so rotating the cycle and appending that vertex gives a longer path.
- Diameter ≤ 2 (proved here). Every vertex is at distance 0, 1 or 2. So distEven(v) = n − deg(v), and the hypothesis gives deg(v) ≥ n − 1 − σ for every v. Since σ is the second smallest degree, at most one vertex has degree < σ. Hence any two distinct vertices satisfy deg u + deg v ≥ n − 1, which is Ore's condition.
- Diameter ≥ 3 (open lemma
conjecture189_of_three_le_dist). Exhaustive search over all graphs on ≤ 8 vertices, plus ~10k random and structured graphs on 9–14 vertices, found no counterexample. In this case Ore's condition never holds, and the graphs are mostly non-bipartite, so a different argument is needed.
Lean source
/-
Copyright 2025 The Formal Conjectures Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-/
module
public import FormalConjecturesUtil
/-!
# Written on the Wall II - Conjecture 189
**Verbatim statement (WOWII #189, status O):**
> If G is a simple connected graph with n > 1 such that maximum { dist_even(v) : dist_even(v) is the number of vertices at even distance from v } ≤ 1 + σ(G), then G has a Hamiltonian path.
**Source:** http://cms.uhd.edu/faculty/delavinae/research/wowII/all.html#conj189
*Reference:*
[E. DeLaVina, Written on the Wall II, Conjectures of Graffiti.pc](http://cms.dt.uh.edu/faculty/delavinae/research/wowII/)
-/
@[expose] public section
namespace WrittenOnTheWallII.GraphConjecture189
open SimpleGraph
variable {α : Type*} [Fintype α] [DecidableEq α] [Nontrivial α]
set_option linter.unusedSectionVars false
theorem exists_walk_of_isChain (G : SimpleGraph α) :
∀ (l : List α) (a : α), (a :: l).IsChain G.Adj →
∃ b : α, ∃ p : G.Walk a b, p.support = a :: l
| [], a, _ => ⟨a, Walk.nil, rfl⟩
| (c :: l), a, h => by
rw [List.isChain_cons_cons] at h
obtain ⟨b, p, hp⟩ := exists_walk_of_isChain G l c h.2
exact ⟨b, Walk.cons h.1 p, by simp [hp]⟩
/-- A connected graph has an edge leaving any nonempty proper set given as a list. -/
theorem exists_adj_out (G : SimpleGraph α) (h : G.Connected) (l : List α) (hne : l ≠ [])
(hlt : l.length < Fintype.card α) (hnd : l.Nodup) :
∃ y ∈ l, ∃ x, x ∉ l ∧ G.Adj y x := by
obtain ⟨a, ha⟩ := List.exists_mem_of_ne_nil l hne
have : ∃ x, x ∉ l := by
by_contra hcon
push Not at hcon
have h1 : l.toFinset = Finset.univ := Finset.eq_univ_iff_forall.mpr (by simpa using hcon)
have h2 := List.toFinset_card_of_nodup hnd
rw [h1, Finset.card_univ] at h2
omega
obtain ⟨x, hx⟩ := this
obtain ⟨p⟩ := h.preconnected a x
obtain ⟨d, -, hd1, hd2⟩ := p.exists_boundary_dart {v | v ∈ l} ha hx
exact ⟨d.fst, hd1, d.snd, hd2, d.adj⟩
/-- Rotating a cyclic chain at a vertex `y` and appending an outside neighbour `x` of `y`. -/
theorem extend_cycle (G : SimpleGraph α) (cyc : List α) (hc : cyc.IsChain G.Adj) (hnd : cyc.Nodup)
(hclose : ∀ a ∈ cyc.head?, ∀ z ∈ cyc.getLast?, G.Adj z a)
(y : α) (hy : y ∈ cyc) (x : α) (hx : x ∉ cyc) (hyx : G.Adj y x) :
∃ l' : List α, l' ≠ [] ∧ l'.IsChain G.Adj ∧ l'.Nodup ∧ l'.length = cyc.length + 1 := by
obtain ⟨j, hj, rfl⟩ := List.getElem_of_mem hy
set p := cyc.take (j + 1) with hp
set q := cyc.drop (j + 1) with hq
have hpq : p ++ q = cyc := List.take_append_drop _ _
have hplast : p.getLast? = some (cyc[j]'hj) := by
rw [hp, List.getLast?_take]; simp [hj]
have hpchain : p.IsChain G.Adj := hc.take _
have hqchain : q.IsChain G.Adj := hc.drop _
refine ⟨q ++ (p ++ [x]), by simp, ?_, ?_, ?_⟩
· have hpx : (p ++ [x]).IsChain G.Adj := by
apply hpchain.append (List.isChain_singleton x)
intro u hu v hv
rw [hplast] at hu
simp only [Option.mem_def, Option.some.injEq] at hu
simp only [List.head?_cons, Option.mem_def, Option.some.injEq] at hv
subst hu; subst hv; exact hyx
apply hqchain.append hpx
intro u hu v hv
-- u is the last element of q (= last of cyc), v the head of p (= head of cyc)
have hu' : u ∈ cyc.getLast? := by
rw [← hpq, List.getLast?_append]
simp only [Option.mem_def] at hu ⊢
rw [hu]; rfl
have hv' : v ∈ cyc.head? := by
rw [← hpq]
have hpne : p ≠ [] := by
rw [hp]; exact List.ne_nil_of_length_pos (by simp; omega)
rw [List.head?_append_of_ne_nil _ hpne]
rw [List.head?_append_of_ne_nil _ hpne] at hv
exact hv
exact hclose v hv' u hu'
· have hperm : (q ++ (p ++ [x])).Perm (cyc ++ [x]) := by
rw [← hpq, ← List.append_assoc]
exact List.perm_append_comm.append_right _
rw [hperm.nodup_iff, List.nodup_append]
refine ⟨hnd, List.nodup_singleton x, ?_⟩
intro a ha b hb
simp only [List.mem_singleton] at hb
subst hb
exact fun hab => hx (hab ▸ ha)
· rw [← hpq]
simp only [List.length_append, List.length_singleton]
omega
/-- Ore's crossing step: a path whose end-vertices have all their neighbours on the path and
large degree sum can be closed into a cycle on the same vertex set. -/
theorem cycle_of_path (G : SimpleGraph α) [DecidableRel G.Adj] (l : List α)
(hc : l.IsChain G.Adj) (hnd : l.Nodup) (hlen : 2 ≤ l.length)
(hA : ∀ x, G.Adj (l[0]'(by omega)) x → x ∈ l)
(hZ : ∀ x, G.Adj (l[l.length - 1]'(by omega)) x → x ∈ l)
(hsum : l.length ≤ G.degree (l[0]'(by omega)) + G.degree (l[l.length - 1]'(by omega))) :
∃ cyc : List α, cyc.Perm l ∧ cyc.IsChain G.Adj ∧
∀ a ∈ cyc.head?, ∀ z ∈ cyc.getLast?, G.Adj z a := by
set k := l.length with hk
set a := l[0]'(by omega) with ha
set z := l[k - 1]'(by omega) with hz
let f : ℕ → α := fun i => l.getD (i + 1) a
let g : ℕ → α := fun i => l.getD i a
set A := (Finset.range (k - 1)).filter (fun i => G.Adj a (f i)) with hAdef
set B := (Finset.range (k - 1)).filter (fun i => G.Adj z (g i)) with hBdef
have hdegA : G.degree a ≤ A.card := by
rw [← G.card_neighborFinset_eq_degree]
refine le_trans (Finset.card_le_card (t := A.image f) ?_) Finset.card_image_le
intro x hx
rw [SimpleGraph.mem_neighborFinset] at hx
obtain ⟨j, hj, rfl⟩ := List.getElem_of_mem (hA x hx)
have hj0 : j ≠ 0 := by
rintro rfl
exact G.ne_of_adj hx (by simp [ha])
refine Finset.mem_image.mpr ⟨j - 1, ?_, ?_⟩
· simp only [hAdef, Finset.mem_filter, Finset.mem_range]
refine ⟨by omega, ?_⟩
simp only [f, List.getD_eq_getElem?_getD]
rw [show j - 1 + 1 = j by omega, List.getElem?_eq_getElem hj]
simpa using hx
· simp only [f, List.getD_eq_getElem?_getD]
rw [show j - 1 + 1 = j by omega, List.getElem?_eq_getElem hj]
simp
have hdegB : G.degree z ≤ B.card := by
rw [← G.card_neighborFinset_eq_degree]
refine le_trans (Finset.card_le_card (t := B.image g) ?_) Finset.card_image_le
intro x hx
rw [SimpleGraph.mem_neighborFinset] at hx
obtain ⟨j, hj, rfl⟩ := List.getElem_of_mem (hZ x hx)
have hjk : j ≠ k - 1 := by
rintro rfl
exact G.ne_of_adj hx (by simp [hz])
refine Finset.mem_image.mpr ⟨j, ?_, ?_⟩
· simp only [hBdef, Finset.mem_filter, Finset.mem_range]
refine ⟨by omega, ?_⟩
simp only [g, List.getD_eq_getElem?_getD]
rw [List.getElem?_eq_getElem hj]
simpa using hx
· simp only [g, List.getD_eq_getElem?_getD]
rw [List.getElem?_eq_getElem hj]
simp
-- pigeonhole: A and B intersect
obtain ⟨i, hiA, hiB⟩ : ∃ i, i ∈ A ∧ i ∈ B := by
by_contra hcon
push Not at hcon
have hdisj : Disjoint A B := Finset.disjoint_left.mpr hcon
have h1 : (A ∪ B).card ≤ k - 1 := by
have : A ∪ B ⊆ Finset.range (k - 1) := by
intro x hx
rcases Finset.mem_union.mp hx with hx | hx
· exact (Finset.mem_filter.mp hx).1
· exact (Finset.mem_filter.mp hx).1
simpa using Finset.card_le_card this
rw [Finset.card_union_of_disjoint hdisj] at h1
omega
simp only [hAdef, hBdef, Finset.mem_filter, Finset.mem_range] at hiA hiB
obtain ⟨hik, hai⟩ := hiA
obtain ⟨-, hzi⟩ := hiB
have hi1 : i + 1 < k := by omega
have hfi : f i = l[i + 1] := by
simp only [f, List.getD_eq_getElem?_getD, List.getElem?_eq_getElem hi1, Option.getD_some]
have hgi : g i = l[i] := by
simp only [g, List.getD_eq_getElem?_getD, List.getElem?_eq_getElem (by omega : i < k),
Option.getD_some]
rw [hfi] at hai
rw [hgi] at hzi
refine ⟨l.take (i + 1) ++ (l.drop (i + 1)).reverse, ?_, ?_, ?_⟩
· calc (l.take (i + 1) ++ (l.drop (i + 1)).reverse).Perm (l.take (i + 1) ++ l.drop (i + 1)) :=
(List.reverse_perm _).append_left _
_ = l := List.take_append_drop _ _
· apply (hc.take (i + 1)).append
· exact List.isChain_reverse.mpr ((hc.drop (i + 1)).imp fun _ _ h => h.symm)
· intro u hu v hv
rw [List.getLast?_take] at hu
simp only [show ¬ (i + 1 = 0) by omega, if_false, Nat.add_sub_cancel,
List.getElem?_eq_getElem (by omega : i < k), Option.some_or, Option.mem_def,
Option.some.injEq] at hu
rw [List.head?_reverse, List.getLast?_drop] at hv
simp only [show ¬ (k ≤ i + 1) by omega, if_false, ← hk, Option.mem_def] at hv
rw [List.getLast?_eq_getElem?, ← hk, List.getElem?_eq_getElem (by omega : k - 1 < k)] at hv
simp only [Option.some.injEq] at hv
subst hu; subst hv
exact hzi.symm
· intro u hu v hv
rw [List.head?_append, List.head?_take] at hu
simp only [show ¬ (i + 1 = 0) by omega, if_false, List.head?_eq_getElem?,
List.getElem?_eq_getElem (by omega : 0 < k), Option.some_or, Option.mem_def,
Option.some.injEq] at hu
rw [List.getLast?_append, List.getLast?_reverse, List.head?_drop,
List.getElem?_eq_getElem hi1] at hv
simp only [Option.some_or, Option.mem_def, Option.some.injEq] at hv
subst hu; subst hv
exact hai.symm
/-- Under Ore's condition, every path that misses a vertex can be made one vertex longer. -/
theorem ore_step (G : SimpleGraph α) [DecidableRel G.Adj] (h : G.Connected)
(hore : ∀ u v : α, u ≠ v → ¬ G.Adj u v → Fintype.card α - 1 ≤ G.degree u + G.degree v)
(l : List α) (hne : l ≠ []) (hc : l.IsChain G.Adj) (hnd : l.Nodup)
(hlt : l.length < Fintype.card α) :
∃ l' : List α, l' ≠ [] ∧ l'.IsChain G.Adj ∧ l'.Nodup ∧ l'.length = l.length + 1 := by
have hpos : 0 < l.length := List.length_pos_of_ne_nil hne
by_cases h1 : ∃ x, x ∉ l ∧ G.Adj (l[0]'hpos) x
· obtain ⟨x, hx, hadj⟩ := h1
obtain ⟨b, t, rfl⟩ := List.exists_cons_of_ne_nil hne
refine ⟨x :: b :: t, by simp, List.isChain_cons_cons.mpr ⟨hadj.symm, hc⟩,
List.nodup_cons.mpr ⟨hx, hnd⟩, by simp⟩
by_cases h2 : ∃ x, x ∉ l ∧ G.Adj (l[l.length - 1]'(by omega)) x
· obtain ⟨x, hx, hadj⟩ := h2
refine ⟨l ++ [x], by simp, ?_, ?_, by simp⟩
· apply hc.append (List.isChain_singleton x)
intro u hu v hv
rw [List.getLast?_eq_getElem?, List.getElem?_eq_getElem (by omega : l.length - 1 < l.length),
Option.mem_def, Option.some.injEq] at hu
simp only [List.head?_cons, Option.mem_def, Option.some.injEq] at hv
subst hu; subst hv; exact hadj
· rw [List.nodup_append]
refine ⟨hnd, List.nodup_singleton x, ?_⟩
intro a ha b hb
simp only [List.mem_singleton] at hb
subst hb
exact fun hab => hx (hab ▸ ha)
push Not at h1 h2
have hA : ∀ x, G.Adj (l[0]'hpos) x → x ∈ l := fun x hx => by
by_contra hn; exact h1 x hn hx
have hZ : ∀ x, G.Adj (l[l.length - 1]'(by omega)) x → x ∈ l := fun x hx => by
by_contra hn; exact h2 x hn hx
obtain ⟨y, hy, x, hx, hyx⟩ := exists_adj_out G h l hne hlt hnd
have hlen : 2 ≤ l.length := by
by_contra hcon
have h1' : l.length = 1 := by omega
obtain ⟨j, hj, rfl⟩ := List.getElem_of_mem hy
have : j = 0 := by omega
subst this
exact hx (hA x hyx)
obtain ⟨cyc, hperm, hcc, hclose⟩ : ∃ cyc : List α, cyc.Perm l ∧ cyc.IsChain G.Adj ∧
∀ a ∈ cyc.head?, ∀ z ∈ cyc.getLast?, G.Adj z a := by
by_cases hadj : G.Adj (l[0]'hpos) (l[l.length - 1]'(by omega))
· refine ⟨l, List.Perm.refl l, hc, ?_⟩
intro a ha z hz
rw [List.head?_eq_getElem?, List.getElem?_eq_getElem hpos, Option.mem_def,
Option.some.injEq] at ha
rw [List.getLast?_eq_getElem?, List.getElem?_eq_getElem (by omega : l.length - 1 < l.length),
Option.mem_def, Option.some.injEq] at hz
subst ha; subst hz; exact hadj.symm
· have hne' : l[0]'hpos ≠ l[l.length - 1]'(by omega) := by
intro heq
have := (List.Nodup.getElem_inj_iff hnd).mp heq
omega
have := hore _ _ hne' hadj
exact cycle_of_path G l hc hnd hlen hA hZ (by omega)
obtain ⟨l', hne', hc', hnd', hlen'⟩ :=
extend_cycle G cyc hcc (hperm.nodup_iff.mpr hnd) hclose y (hperm.mem_iff.mpr hy) x
(fun hm => hx (hperm.mem_iff.mp hm)) hyx
exact ⟨l', hne', hc', hnd', by rw [hlen', hperm.length_eq]⟩
/-- Ore's theorem, Hamiltonian-path version: if any two distinct non-adjacent vertices have
degree sum at least `n - 1`, then the connected graph `G` has a Hamiltonian path. -/
theorem ore_hamiltonian_path (G : SimpleGraph α) [DecidableRel G.Adj] (h : G.Connected)
(hore : ∀ u v : α, u ≠ v → ¬ G.Adj u v → Fintype.card α - 1 ≤ G.degree u + G.degree v) :
∃ a b : α, ∃ p : G.Walk a b, p.IsHamiltonian := by
have hall : ∀ k, 1 ≤ k → k ≤ Fintype.card α →
∃ l : List α, l ≠ [] ∧ l.IsChain G.Adj ∧ l.Nodup ∧ l.length = k := by
intro k
induction k with
| zero => intro h0; omega
| succ k ih =>
intro _ hk
rcases Nat.eq_zero_or_pos k with rfl | hpos
· obtain ⟨v⟩ := (inferInstance : Nonempty α)
exact ⟨[v], by simp, List.isChain_singleton v, List.nodup_singleton v, rfl⟩
· obtain ⟨l, hne, hc, hnd, hl⟩ := ih hpos (by omega)
obtain ⟨l', hne', hc', hnd', hl'⟩ := ore_step G h hore l hne hc hnd (by omega)
exact ⟨l', hne', hc', hnd', by omega⟩
obtain ⟨l, hne, hc, hnd, hl⟩ := hall (Fintype.card α) Fintype.card_pos le_rfl
obtain ⟨a, t, rfl⟩ := List.exists_cons_of_ne_nil hne
obtain ⟨b, p, hp⟩ := exists_walk_of_isChain G t a hc
refine ⟨a, b, p, ?_⟩
have hpath : p.IsPath := (Walk.isPath_def p).mpr (hp ▸ hnd)
apply hpath.isHamiltonian_of_mem
intro w
rw [hp]
have huniv : (a :: t).toFinset = Finset.univ :=
Finset.eq_univ_of_card _ (by rw [List.toFinset_card_of_nodup hnd, hl])
have : w ∈ (a :: t).toFinset := huniv ▸ Finset.mem_univ w
exact List.mem_toFinset.mp this
/-- In a connected graph of diameter at most two, the vertices at even distance from `v`
are exactly the non-neighbours of `v` (including `v`). -/
theorem distEven_eq_card_sub_degree (G : SimpleGraph α) [DecidableRel G.Adj] (h : G.Connected)
(hd : ∀ u w : α, G.dist u w ≤ 2) (v : α) :
distEven G v = Fintype.card α - G.degree v := by
classical
have key : (Finset.univ.filter fun w => Even (G.dist v w)) =
Finset.univ \ G.neighborFinset v := by
ext w
simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_sdiff,
SimpleGraph.mem_neighborFinset]
constructor
· intro he hadj
rw [SimpleGraph.dist_eq_one_iff_adj.mpr hadj] at he
exact Nat.not_even_one he
· intro hn
have h2 := hd v w
rcases Nat.lt_or_ge (G.dist v w) 2 with hlt | hge
· interval_cases hdist : G.dist v w
· exact ⟨0, rfl⟩
· exact absurd (SimpleGraph.dist_eq_one_iff_adj.mp hdist) hn
· have : G.dist v w = 2 := le_antisymm h2 hge
rw [this]; exact ⟨1, rfl⟩
unfold distEven
convert congrArg Finset.card key using 1
rw [Finset.card_sdiff_of_subset (Finset.subset_univ _), Finset.card_univ,
SimpleGraph.card_neighborFinset_eq_degree]
/-- Under the hypothesis of Conjecture 189, a graph of diameter at most two satisfies
Ore's condition for Hamiltonian paths. -/
theorem ore_of_hσ_of_dist_le_two (G : SimpleGraph α) [DecidableRel G.Adj] (h : G.Connected)
(hd : ∀ u w : α, G.dist u w ≤ 2)
(hσ : (Finset.univ.image (distEven G)).max' (Finset.univ_nonempty.image _) ≤ 1 + secondSmallestDegree G) :
∀ u v : α, u ≠ v → ¬ G.Adj u v → Fintype.card α - 1 ≤ G.degree u + G.degree v := by
classical
-- every vertex has degree at least `n - 1 - σ`
have hlow : ∀ u : α, Fintype.card α ≤ 1 + secondSmallestDegree G + G.degree u := by
intro u
have hmem : distEven G u ∈ Finset.univ.image (distEven G) :=
Finset.mem_image_of_mem _ (Finset.mem_univ u)
have h1 := (Finset.le_max' _ _ hmem).trans hσ
rw [distEven_eq_card_sub_degree G h hd u] at h1
omega
-- at most one vertex has degree below `σ`
have hsig : ∀ u v : α, u ≠ v → secondSmallestDegree G ≤ G.degree u ∨
secondSmallestDegree G ≤ G.degree v := by
intro u v huv
by_contra hcon
push Not at hcon
obtain ⟨hu, hv⟩ := hcon
have hsorted : (degreeSequence G).Pairwise (· ≤ ·) := Multiset.pairwise_sort _ _
have hperm : (degreeSequence G : Multiset ℕ) = Finset.univ.val.map fun w => G.degree w :=
Multiset.sort_eq _ _
have hlen : 2 ≤ (degreeSequence G).length := by
have := congrArg Multiset.card hperm
simp only [Multiset.coe_card, Multiset.card_map, Finset.card_val] at this
rw [this, Finset.card_univ]
exact Fintype.one_lt_card_iff_nontrivial.mpr inferInstance
obtain ⟨a, b, t, hl⟩ : ∃ a b t, degreeSequence G = a :: b :: t := by
match hds : degreeSequence G, hlen with
| a :: b :: t, _ => exact ⟨a, b, t, rfl⟩
have hb : secondSmallestDegree G = b := by
simp [secondSmallestDegree, hl]
rw [hb] at hu hv
rw [hl] at hsorted
have hbt : ∀ x ∈ t, b ≤ x := by
intro x hx
exact (List.pairwise_cons.mp (List.pairwise_cons.mp hsorted).2).1 x hx
-- count the degrees below `b`
have hcount : ((Finset.univ.val.map fun w => G.degree w).filter (· < b)).card ≤ 1 := by
rw [← hperm, hl]
simp only [Multiset.filter_coe, Multiset.coe_card]
have : (b :: t).filter (fun x => decide (x < b)) = [] := by
rw [List.filter_eq_nil_iff]
intro x hx
simp only [decide_eq_true_eq, not_lt]
rcases List.mem_cons.mp hx with rfl | hx
· exact le_rfl
· exact hbt x hx
rw [List.filter_cons]
split_ifs <;> simp [this]
have hge : 2 ≤ ((Finset.univ.val.map fun w => G.degree w).filter (· < b)).card := by
rw [Multiset.filter_map, Multiset.card_map]
have hsub : ({u, v} : Finset α) ⊆ Finset.univ.filter (fun w => G.degree w < b) := by
intro x hx
simp only [Finset.mem_insert, Finset.mem_singleton] at hx
rcases hx with rfl | rfl <;> simp [hu, hv]
have := Finset.card_le_card hsub
rw [Finset.card_pair huv] at this
exact this
omega
intro u v huv _
have hu := hlow u
have hv := hlow v
rcases hsig u v huv with h1 | h1 <;> omega
/-- The remaining case of Conjecture 189: diameter at least three. -/
theorem conjecture189_of_three_le_dist (G : SimpleGraph α) [DecidableRel G.Adj] (h : G.Connected)
(hσ : (Finset.univ.image (distEven G)).max' (Finset.univ_nonempty.image _) ≤ 1 + secondSmallestDegree G)
(hd : ∃ u w : α, 3 ≤ G.dist u w) :
∃ a b : α, ∃ p : G.Walk a b, p.IsHamiltonian := by
sorry
/--
WOWII [Conjecture 189](http://cms.uhd.edu/faculty/delavinae/research/wowII/all.html#conj189)
(status O):
For a simple connected graph `G`, if `max_v distEven(v) ≤ 1 + σ(G)`,
then `G` has a Hamiltonian path.
Here `distEven(v)` is the number of vertices at even distance from `v`, and
`σ(G)` is the **second-smallest degree** of `G`'s degree sequence (per
WOWII defEntry 65).
-/
@[category research open, AMS 5]
theorem conjecture189 (G : SimpleGraph α) [DecidableRel G.Adj] (h : G.Connected)
(hσ : (Finset.univ.image (distEven G)).max' (by simp) ≤ 1 + secondSmallestDegree G) :
∃ a b : α, ∃ p : G.Walk a b, p.IsHamiltonian := by
by_cases hd : ∀ u w : α, G.dist u w ≤ 2
· exact ore_hamiltonian_path G h (ore_of_hσ_of_dist_le_two G h hd hσ)
· push Not at hd
obtain ⟨u, w, huw⟩ := hd
exact conjecture189_of_three_le_dist G h hσ ⟨u, w, huw⟩
-- Sanity checks
/-- The second-smallest degree is nonneg. -/
@[category test, AMS 5]
example (G : SimpleGraph (Fin 3)) [DecidableRel G.Adj] :
0 ≤ secondSmallestDegree G := Nat.zero_le _
/-- `distEven G v` is positive for any vertex `v`. -/
@[category test, AMS 5]
example (G : SimpleGraph (Fin 3)) (v : Fin 3) : 0 < distEven G v := by
unfold distEven
apply Finset.card_pos.mpr
exact ⟨v, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ⟨0, by simp [SimpleGraph.dist_self]⟩⟩⟩
end WrittenOnTheWallII.GraphConjecture189