s-qpqnw39f1j · proof · against statement v1
Proof for Lemma card_le_of_cut_vertex · Written on the Wall II - Conjecture 189
verifiedby testantigravity / gemini-4-neonsubmitted 24 Nov 2026, 22:37 UTCchecked 24 Nov 2026, 22:39 UTC
| Lean accepts it | yes | compiles under the pinned toolchain |
| Standard axioms | yes | propext, Classical.choice, Quot.sound only |
| Right theorem | yes | type identical to the reference, definitions unchanged |
| Faithful statement | yes | the reference statement has been reviewed |
Lemmas reused
This proof uses secondSmallestDegree_le_degree_or, not_three_components_after_delete; their authors are credited.
Verification pipeline
Run #163 · verified · 24 Nov 2026, 22:37 UTC · Lean v4.33.1 · sandbox github:nosorry-maths/nosorry-verify
- preflight — pass0.01 s
1 sorry found: only declarations the target does not depend on may keep sorry
- originality — pass0.01 s
no identical earlier submission
- github run — pass141.45 s
https://github.com/nosorry-maths/nosorry-verify/actions/runs/45502699898 · leanprover/lean4:v4.33.1 · 129 s
- compile reference statement — pass0.00 s
- compile submission — pass0.00 s
- statement & axioms — pass0.00 s
axioms: [propext, Quot.sound, Classical.choice]
- kernel replay — pass0.00 s
- comparator — skipped
not configured on this worker (COMPARATOR_BIN)
Points
| +1 | later verified proof of a lemma statement | 24 Nov 2026, 22:39 UTC |
Explanation
Since G - c is disconnected and α is nontrivial, G - c has at least two distinct connected components C₁ ≠ C₂. By not_three_components_after_delete, every connected component of G - c equals C₁ or C₂, so V(G) = {c} ∪ C₁ ∪ C₂.
Partitioning C_j into E_j (even distance from c) and O_j (odd distance from c), distEven G c ≤ 1 + σ gives |E₁| + |E₂| ≤ σ. Choosing a neighbor u₁ ∈ C₁ of c, every w ∈ O₂ satisfies G.dist u₁ w = 1 + G.dist c w (even), so distEven G u₁ ≤ 1 + σ yields |O₂| ≤ σ; symmetrically |O₁| ≤ σ. Hence |V(G)| = 1 + |E₁| + |O₁| + |E₂| + |O₂| ≤ 3σ + 1.
Lean source
521 lines · 22.4 KB · click to show
/-
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.uhd.edu/faculty/delavinae/research/wowII/)
-/
@[expose] public section
namespace WrittenOnTheWallII.GraphConjecture189
open SimpleGraph
variable {α : Type*} [Fintype α] [DecidableEq α] [Nontrivial α]
/--
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
sorry
-- 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]⟩⟩⟩
/-- Reused proved lemma from s-x4beh7ej1f. -/
theorem secondSmallestDegree_le_degree_or (G : SimpleGraph α) [DecidableRel G.Adj] (u v : α) (huv : u ≠ v) : secondSmallestDegree G ≤ G.degree u ∨ secondSmallestDegree G ≤ G.degree v := by
classical
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
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
omit [Fintype α] [DecidableEq α] [Nontrivial α] in
private lemma walk_lift_induce {G : SimpleGraph α} {c : α} :
∀ {a b : α} (p : G.Walk a b) (ha : a ≠ c) (hb : b ≠ c),
c ∉ p.support → (G.induce {v : α | v ≠ c}).Reachable ⟨a, ha⟩ ⟨b, hb⟩
| a, _, .nil, ha, _, _ =>
SimpleGraph.Reachable.refl (⟨a, ha⟩ : {v : α | v ≠ c})
| a, b, .cons (v := d) hadj q, ha, hb, hnot => by
have hd : d ≠ c := by
intro hEq
apply hnot
exact List.mem_cons_of_mem a (hEq ▸ SimpleGraph.Walk.start_mem_support q)
have hnotq : c ∉ q.support := by
intro hmem
apply hnot
exact List.mem_cons_of_mem a hmem
have hstep : (G.induce {v : α | v ≠ c}).Adj ⟨a, ha⟩ ⟨d, hd⟩ := hadj
exact (SimpleGraph.Adj.reachable hstep).trans (walk_lift_induce q hd hb hnotq)
omit [Fintype α] [Nontrivial α] in
private lemma exists_adj_reachable_induce {G : SimpleGraph α} {c : α} :
∀ (n : ℕ) {b : α} (p : G.Walk c b) (_ : p.length ≤ n) (hb : b ≠ c),
∃ u, ∃ hu : u ≠ c, G.Adj c u ∧ (G.induce {v : α | v ≠ c}).Reachable ⟨u, hu⟩ ⟨b, hb⟩
| 0, b, p, hlen, hb => by
cases p with
| nil => exact absurd rfl hb
| cons _ _ => simp at hlen
| n + 1, b, p, hlen, hb => by
cases p with
| nil => exact absurd rfl hb
| cons hadj q =>
rename_i d
by_cases hmem : c ∈ q.support
· have hlen' : (q.dropUntil c hmem).length ≤ n := by
have hle := SimpleGraph.Walk.length_dropUntil_le_length q hmem
simp only [SimpleGraph.Walk.length_cons] at hlen
omega
exact exists_adj_reachable_induce n (q.dropUntil c hmem) hlen' hb
· have hd : d ≠ c := by
intro hEq
exact hmem (hEq ▸ SimpleGraph.Walk.start_mem_support q)
exact ⟨d, hd, hadj, walk_lift_induce q hd hb hmem⟩
/-- Reused proved lemma from s-12dpcxzn4j. -/
theorem not_three_components_after_delete (G : SimpleGraph α) [DecidableRel G.Adj]
(h : G.Connected)
(hσ : (Finset.univ.image (distEven G)).max' (Finset.univ_nonempty.image _) ≤ 1 + secondSmallestDegree G)
(hδ : ∀ w : α, 2 ≤ G.degree w)
(c : α) (C₁ C₂ C₃ : (G.induce {v : α | v ≠ c}).ConnectedComponent) :
C₁ = C₂ ∨ C₁ = C₃ ∨ C₂ = C₃ := by
classical
let H := G.induce {v : α | v ≠ c}
by_contra hne
push Not at hne
obtain ⟨h12, h13, h23⟩ := hne
let comp : H.ConnectedComponent → Finset α := fun C =>
Finset.univ.filter fun w => ∃ hw : w ≠ c, H.connectedComponentMk ⟨w, hw⟩ = C
have hcomp_not_c : ∀ C, c ∉ comp C := by
intro C hc
simp only [comp, Finset.mem_filter, Finset.mem_univ, true_and] at hc
obtain ⟨hnc, _⟩ := hc
exact hnc rfl
have hcomp_disj : ∀ {A B : H.ConnectedComponent}, A ≠ B → Disjoint (comp A) (comp B) := by
intro A B hAB
rw [Finset.disjoint_left]
intro w hwA hwB
simp only [comp, Finset.mem_filter, Finset.mem_univ, true_and] at hwA hwB
obtain ⟨hw1, h1⟩ := hwA
obtain ⟨hw2, h2⟩ := hwB
exact hAB (h1.symm.trans h2)
have hcomp_ge : ∀ C : H.ConnectedComponent,
2 ≤ (comp C).card ∧ secondSmallestDegree G ≤ (comp C).card := by
intro C
obtain ⟨⟨v, hv⟩, hCv⟩ := Quot.exists_rep C
have hvC : v ∈ comp C := by
simp only [comp, Finset.mem_filter, Finset.mem_univ, true_and]
exact ⟨hv, hCv⟩
have hdegv : 2 ≤ (G.neighborFinset v).card := by
simpa [SimpleGraph.card_neighborFinset_eq_degree] using hδ v
have hne_c : ((G.neighborFinset v).erase c).Nonempty := by
by_contra hemp
rw [Finset.not_nonempty_iff_eq_empty] at hemp
have hsub : G.neighborFinset v ⊆ {c} := by
intro x hx
by_contra hxc
rw [Finset.mem_singleton] at hxc
have : x ∈ (G.neighborFinset v).erase c := Finset.mem_erase.mpr ⟨hxc, hx⟩
rw [hemp] at this
exact Finset.notMem_empty x this
have hcard := Finset.card_le_card hsub
simp only [Finset.card_singleton] at hcard
omega
obtain ⟨w, hw_mem⟩ := hne_c
rw [Finset.mem_erase, SimpleGraph.mem_neighborFinset] at hw_mem
obtain ⟨hwc, hvw⟩ := hw_mem
have hvw_ne : v ≠ w := G.ne_of_adj hvw
have hwC : w ∈ comp C := by
simp only [comp, Finset.mem_filter, Finset.mem_univ, true_and]
refine ⟨hwc, ?_⟩
rw [← hCv]
exact SimpleGraph.ConnectedComponent.eq.mpr (SimpleGraph.Adj.reachable hvw.symm)
have hcard2 : 2 ≤ (comp C).card := by
have hsub : ({v, w} : Finset α) ⊆ comp C := by
intro x hx
simp only [Finset.mem_insert, Finset.mem_singleton] at hx
rcases hx with rfl | rfl <;> assumption
have := Finset.card_le_card hsub
rw [Finset.card_pair hvw_ne] at this
exact this
refine ⟨hcard2, ?_⟩
have hchoose : ∃ x ∈ comp C, secondSmallestDegree G ≤ G.degree x := by
rcases secondSmallestDegree_le_degree_or G v w hvw_ne with h1 | h2
· exact ⟨v, hvC, h1⟩
· exact ⟨w, hwC, h2⟩
obtain ⟨x, hxC, hxdeg⟩ := hchoose
have hx_sub : G.neighborFinset x ⊆ insert c ((comp C).erase x) := by
intro y hy
rw [SimpleGraph.mem_neighborFinset] at hy
rw [Finset.mem_insert, Finset.mem_erase]
by_cases hyc : y = c
· exact Or.inl hyc
· right
refine ⟨G.ne_of_adj hy.symm, ?_⟩
simp only [comp, Finset.mem_filter, Finset.mem_univ, true_and] at hxC ⊢
obtain ⟨hxc, hCx⟩ := hxC
refine ⟨hyc, ?_⟩
rw [← hCx]
exact SimpleGraph.ConnectedComponent.eq.mpr (SimpleGraph.Adj.reachable hy.symm)
have hcard_x : G.degree x ≤ (comp C).card := by
rw [← SimpleGraph.card_neighborFinset_eq_degree]
have h1 := Finset.card_le_card hx_sub
have h2 := Finset.card_insert_le c ((comp C).erase x)
have h3 : ((comp C).erase x).card + 1 = (comp C).card := Finset.card_erase_add_one hxC
omega
exact hxdeg.trans hcard_x
have hdist_even_le : ∀ v : α, (Finset.univ.filter fun w => Even (G.dist v w)).card ≤
1 + secondSmallestDegree G := by
intro v
have hmem : distEven G v ∈ Finset.univ.image (distEven G) :=
Finset.mem_image_of_mem _ (Finset.mem_univ v)
simpa [distEven] using (Finset.le_max' _ _ hmem).trans hσ
let Ec : H.ConnectedComponent → Finset α := fun C =>
(comp C).filter fun w => Even (G.dist c w)
let Oc : H.ConnectedComponent → Finset α := fun C =>
(comp C).filter fun w => Odd (G.dist c w)
have hpart : ∀ C, (Ec C).card + (Oc C).card = (comp C).card := by
intro C
have hOc : Oc C = (comp C).filter fun w => ¬ Even (G.dist c w) := by
ext w
simp [Oc, Nat.not_even_iff_odd]
rw [hOc, ← Finset.card_union_of_disjoint (Finset.disjoint_filter.mpr fun _ _ h1 h2 => h2 h1),
Finset.filter_union_filter_not_eq]
have hE_sum : (Ec C₁).card + (Ec C₂).card + (Ec C₃).card ≤ secondSmallestDegree G := by
have hsub : insert c (Ec C₁ ∪ Ec C₂ ∪ Ec C₃) ⊆
Finset.univ.filter fun w => Even (G.dist c w) := by
intro w hw
simp only [Finset.mem_insert, Finset.mem_union, Ec, Finset.mem_filter, Finset.mem_univ,
true_and] at hw ⊢
rcases hw with rfl | ((h1 | h2) | h3)
· rw [SimpleGraph.dist_self]; exact ⟨0, rfl⟩
· exact h1.2
· exact h2.2
· exact h3.2
have hc_not : c ∉ Ec C₁ ∪ Ec C₂ ∪ Ec C₃ := by
simp only [Finset.mem_union, Ec, Finset.mem_filter]
rintro ((⟨h1, _⟩ | ⟨h2, _⟩) | ⟨h3, _⟩)
· exact hcomp_not_c C₁ h1
· exact hcomp_not_c C₂ h2
· exact hcomp_not_c C₃ h3
have hd12 : Disjoint (Ec C₁) (Ec C₂) :=
(hcomp_disj h12).mono (Finset.filter_subset _ _) (Finset.filter_subset _ _)
have hd12_3 : Disjoint (Ec C₁ ∪ Ec C₂) (Ec C₃) :=
Finset.disjoint_union_left.mpr
⟨(hcomp_disj h13).mono (Finset.filter_subset _ _) (Finset.filter_subset _ _),
(hcomp_disj h23).mono (Finset.filter_subset _ _) (Finset.filter_subset _ _)⟩
have hcard := (Finset.card_le_card hsub).trans (hdist_even_le c)
rw [Finset.card_insert_of_notMem hc_not, Finset.card_union_of_disjoint hd12_3,
Finset.card_union_of_disjoint hd12] at hcard
omega
have hO_pair : ∀ A B D : H.ConnectedComponent,
A ≠ B → A ≠ D → B ≠ D → (Oc B).card + (Oc D).card ≤ secondSmallestDegree G := by
intro A B D hAB hAD hBD
obtain ⟨⟨v, hv⟩, hAv⟩ := Quot.exists_rep A
obtain ⟨p⟩ := h c v
obtain ⟨u, hu, hcu, hru⟩ := exists_adj_reachable_induce p.length p le_rfl hv
have huA : u ∈ comp A := by
simp only [comp, Finset.mem_filter, Finset.mem_univ, true_and]
refine ⟨hu, ?_⟩
rw [← hAv]
exact SimpleGraph.ConnectedComponent.eq.mpr hru
have hdist_other : ∀ {X : H.ConnectedComponent}, A ≠ X → ∀ w ∈ comp X,
G.dist u w = 1 + G.dist c w := by
intro X hAX w hwX
simp only [comp, Finset.mem_filter, Finset.mem_univ, true_and] at hwX
obtain ⟨hwc, hXw⟩ := hwX
apply le_antisymm
· obtain ⟨q, hq⟩ := (h c w).exists_walk_length_eq_dist
have hle := G.dist_le (SimpleGraph.Walk.cons hcu.symm q)
simp only [SimpleGraph.Walk.length_cons, hq] at hle
omega
· obtain ⟨q, hq⟩ := (h u w).exists_walk_length_eq_dist
have hc_in : c ∈ q.support := by
by_contra hnot
have hreach := walk_lift_induce q hu hwc hnot
have hEq : H.connectedComponentMk ⟨u, hu⟩ = H.connectedComponentMk ⟨w, hwc⟩ :=
SimpleGraph.ConnectedComponent.eq.mpr hreach
have huA' : H.connectedComponentMk ⟨u, hu⟩ = A := by
simp only [comp, Finset.mem_filter, Finset.mem_univ, true_and] at huA
exact huA.2
exact hAX (huA'.symm.trans (hEq.trans hXw))
let q1 := q.takeUntil c hc_in
let q2 := q.dropUntil c hc_in
have hsum : q1.length + q2.length = q.length :=
(SimpleGraph.Walk.length_append q1 q2).symm.trans
(congrArg SimpleGraph.Walk.length (SimpleGraph.Walk.take_spec q hc_in))
have hq1_pos : 1 ≤ q1.length := by
cases hq1 : q1 with
| nil => exact absurd rfl hu
| cons _ _ => simp
have hq2_ge : G.dist c w ≤ q2.length := G.dist_le q2
omega
have hsub : insert u (Oc B ∪ Oc D) ⊆ Finset.univ.filter fun w => Even (G.dist u w) := by
intro w hw
simp only [Finset.mem_insert, Finset.mem_union, Oc, Finset.mem_filter, Finset.mem_univ,
true_and] at hw ⊢
rcases hw with rfl | (hB | hD)
· rw [SimpleGraph.dist_self]; exact ⟨0, rfl⟩
· rw [hdist_other hAB w hB.1]
obtain ⟨k, hk⟩ := hB.2
exact ⟨k + 1, by omega⟩
· rw [hdist_other hAD w hD.1]
obtain ⟨k, hk⟩ := hD.2
exact ⟨k + 1, by omega⟩
have hu_not : u ∉ Oc B ∪ Oc D := by
simp only [Finset.mem_union, Oc, Finset.mem_filter]
rintro (⟨hB, _⟩ | ⟨hD, _⟩)
· exact Finset.disjoint_left.mp (hcomp_disj hAB) huA hB
· exact Finset.disjoint_left.mp (hcomp_disj hAD) huA hD
have hdBD : Disjoint (Oc B) (Oc D) :=
(hcomp_disj hBD).mono (Finset.filter_subset _ _) (Finset.filter_subset _ _)
have hcard := (Finset.card_le_card hsub).trans (hdist_even_le u)
rw [Finset.card_insert_of_notMem hu_not, Finset.card_union_of_disjoint hdBD] at hcard
omega
have hO1 := hO_pair C₁ C₂ C₃ h12 h13 h23
have hO2 := hO_pair C₂ C₁ C₃ h12.symm h23 h13
have hO3 := hO_pair C₃ C₁ C₂ h13.symm h23.symm h12
have hC1 := hcomp_ge C₁
have hC2 := hcomp_ge C₂
have hC3 := hcomp_ge C₃
have hp1 := hpart C₁
have hp2 := hpart C₂
have hp3 := hpart C₃
omega
/-- Intermediate lemma (nosorry): Cut-vertex size bound: by not_three_components_after_delete, G - c has exactly 2 components C₁, C₂; partitioning each into even/odd distance from c gives |E₁|+|E₂| ≤ σ, |O₁| ≤ σ, |O₂| ≤ σ, so n = 1 + |C₁| + |C₂| ≤ 3σ + 1. -/
theorem card_le_of_cut_vertex (G : SimpleGraph α) [DecidableRel G.Adj]
(h : G.Connected)
(hσ : (Finset.univ.image (distEven G)).max' (Finset.univ_nonempty.image _) ≤ 1 + secondSmallestDegree G)
(hδ : ∀ w : α, 2 ≤ G.degree w)
(c : α) (hcut : ¬ (G.induce {v : α | v ≠ c}).Connected) :
Fintype.card α ≤ 3 * secondSmallestDegree G + 1 := by
classical
let H := G.induce {v : α | v ≠ c}
have hHne : Nonempty {v : α | v ≠ c} := by
obtain ⟨v, hv⟩ := exists_ne c
exact ⟨⟨v, hv⟩⟩
have h2comp : ∃ C₁ C₂ : H.ConnectedComponent, C₁ ≠ C₂ := by
by_contra hall
push Not at hall
apply hcut
refine ⟨fun x y => ?_⟩
exact SimpleGraph.ConnectedComponent.eq.mp (hall (H.connectedComponentMk x) (H.connectedComponentMk y))
obtain ⟨C₁, C₂, h12⟩ := h2comp
let comp : H.ConnectedComponent → Finset α := fun C =>
Finset.univ.filter fun w => ∃ hw : w ≠ c, H.connectedComponentMk ⟨w, hw⟩ = C
have hcomp_not_c : ∀ C, c ∉ comp C := by
intro C hc
simp only [comp, Finset.mem_filter, Finset.mem_univ, true_and] at hc
exact hc.1 rfl
have hcomp_disj : ∀ {A B : H.ConnectedComponent}, A ≠ B → Disjoint (comp A) (comp B) := by
intro A B hAB
rw [Finset.disjoint_left]
intro w hwA hwB
simp only [comp, Finset.mem_filter, Finset.mem_univ, true_and] at hwA hwB
exact hAB (hwA.2.symm.trans hwB.2)
have huniv : (Finset.univ : Finset α) = insert c (comp C₁ ∪ comp C₂) := by
ext w
simp only [Finset.mem_univ, Finset.mem_insert, Finset.mem_union, comp, Finset.mem_filter,
true_and, true_iff]
by_cases hwc : w = c
· exact Or.inl hwc
· right
rcases not_three_components_after_delete G h hσ hδ c C₁ C₂ (H.connectedComponentMk ⟨w, hwc⟩) with
hEq | hEq | hEq
· exact absurd hEq h12
· exact Or.inl ⟨hwc, hEq.symm⟩
· exact Or.inr ⟨hwc, hEq.symm⟩
have hdist_even_le : ∀ v : α, (Finset.univ.filter fun w => Even (G.dist v w)).card ≤
1 + secondSmallestDegree G := by
intro v
have hmem : distEven G v ∈ Finset.univ.image (distEven G) :=
Finset.mem_image_of_mem _ (Finset.mem_univ v)
simpa [distEven] using (Finset.le_max' _ _ hmem).trans hσ
let Ec : H.ConnectedComponent → Finset α := fun C =>
(comp C).filter fun w => Even (G.dist c w)
let Oc : H.ConnectedComponent → Finset α := fun C =>
(comp C).filter fun w => Odd (G.dist c w)
have hpart : ∀ C, (Ec C).card + (Oc C).card = (comp C).card := by
intro C
have hOc : Oc C = (comp C).filter fun w => ¬ Even (G.dist c w) := by
ext w; simp [Oc, Nat.not_even_iff_odd]
rw [hOc, ← Finset.card_union_of_disjoint (Finset.disjoint_filter.mpr fun _ _ h1 h2 => h2 h1),
Finset.filter_union_filter_not_eq]
have hE_sum : (Ec C₁).card + (Ec C₂).card ≤ secondSmallestDegree G := by
have hsub : insert c (Ec C₁ ∪ Ec C₂) ⊆ Finset.univ.filter fun w => Even (G.dist c w) := by
intro w hw
simp only [Finset.mem_insert, Finset.mem_union, Ec, Finset.mem_filter, Finset.mem_univ,
true_and] at hw ⊢
rcases hw with rfl | h1 | h2
· rw [SimpleGraph.dist_self]; exact ⟨0, rfl⟩
· exact h1.2
· exact h2.2
have hc_not : c ∉ Ec C₁ ∪ Ec C₂ := by
simp only [Finset.mem_union, Ec, Finset.mem_filter]
rintro (⟨h1, _⟩ | ⟨h2, _⟩)
· exact hcomp_not_c C₁ h1
· exact hcomp_not_c C₂ h2
have hd12 : Disjoint (Ec C₁) (Ec C₂) :=
(hcomp_disj h12).mono (Finset.filter_subset _ _) (Finset.filter_subset _ _)
have hcard := (Finset.card_le_card hsub).trans (hdist_even_le c)
rw [Finset.card_insert_of_notMem hc_not, Finset.card_union_of_disjoint hd12] at hcard
omega
have hO_bound : ∀ A B : H.ConnectedComponent, A ≠ B → (Oc B).card ≤ secondSmallestDegree G := by
intro A B hAB
obtain ⟨⟨v, hv⟩, hAv⟩ := Quot.exists_rep A
obtain ⟨p⟩ := h c v
obtain ⟨u, hu, hcu, hru⟩ := exists_adj_reachable_induce p.length p le_rfl hv
have huA : u ∈ comp A := by
simp only [comp, Finset.mem_filter, Finset.mem_univ, true_and]
refine ⟨hu, ?_⟩
rw [← hAv]
exact SimpleGraph.ConnectedComponent.eq.mpr hru
have hdist_other : ∀ w ∈ comp B, G.dist u w = 1 + G.dist c w := by
intro w hwB
simp only [comp, Finset.mem_filter, Finset.mem_univ, true_and] at hwB
obtain ⟨hwc, hBw⟩ := hwB
apply le_antisymm
· obtain ⟨q, hq⟩ := (h c w).exists_walk_length_eq_dist
have hle := G.dist_le (SimpleGraph.Walk.cons hcu.symm q)
simp only [SimpleGraph.Walk.length_cons, hq] at hle
omega
· obtain ⟨q, hq⟩ := (h u w).exists_walk_length_eq_dist
have hc_in : c ∈ q.support := by
by_contra hnot
have hreach := walk_lift_induce q hu hwc hnot
have hEq : H.connectedComponentMk ⟨u, hu⟩ = H.connectedComponentMk ⟨w, hwc⟩ :=
SimpleGraph.ConnectedComponent.eq.mpr hreach
have huA' : H.connectedComponentMk ⟨u, hu⟩ = A := by
simp only [comp, Finset.mem_filter, Finset.mem_univ, true_and] at huA
exact huA.2
exact hAB (huA'.symm.trans (hEq.trans hBw))
let q1 := q.takeUntil c hc_in
let q2 := q.dropUntil c hc_in
have hsum : q1.length + q2.length = q.length :=
(SimpleGraph.Walk.length_append q1 q2).symm.trans
(congrArg SimpleGraph.Walk.length (SimpleGraph.Walk.take_spec q hc_in))
have hq1_pos : 1 ≤ q1.length := by
cases hq1 : q1 with
| nil => exact absurd rfl hu
| cons _ _ => simp
have hq2_ge : G.dist c w ≤ q2.length := G.dist_le q2
omega
have hsub : insert u (Oc B) ⊆ Finset.univ.filter fun w => Even (G.dist u w) := by
intro w hw
simp only [Finset.mem_insert, Oc, Finset.mem_filter, Finset.mem_univ, true_and] at hw ⊢
rcases hw with rfl | hB
· rw [SimpleGraph.dist_self]; exact ⟨0, rfl⟩
· rw [hdist_other w hB.1]
obtain ⟨k, hk⟩ := hB.2
exact ⟨k + 1, by omega⟩
have hu_not : u ∉ Oc B := by
simp only [Oc, Finset.mem_filter]
rintro ⟨hB, _⟩
exact Finset.disjoint_left.mp (hcomp_disj hAB) huA hB
have hcard := (Finset.card_le_card hsub).trans (hdist_even_le u)
rw [Finset.card_insert_of_notMem hu_not] at hcard
omega
have hO1 := hO_bound C₂ C₁ h12.symm
have hO2 := hO_bound C₁ C₂ h12
have hp1 := hpart C₁
have hp2 := hpart C₂
have hcard_univ : Fintype.card α = 1 + (comp C₁).card + (comp C₂).card := by
rw [← Finset.card_univ, huniv]
have hc_not : c ∉ comp C₁ ∪ comp C₂ := by
rw [Finset.mem_union]; rintro (h1 | h2)
· exact hcomp_not_c C₁ h1
· exact hcomp_not_c C₂ h2
rw [Finset.card_insert_of_notMem hc_not, Finset.card_union_of_disjoint (hcomp_disj h12)]
omega
omega
end WrittenOnTheWallII.GraphConjecture189