NS.08741 · Written on the Wall II - Conjecture 84 > s-cr3t9jae65
s-cr3t9jae65 · proof · against statement v1
Proof for Written on the Wall II - Conjecture 84
| 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 two_mul_radius_le_largestInducedTreeSize_of_cutVertex; their authors are credited.
Verification pipeline
Run #85 · verified · 24 Nov 2026, 11:03 UTC · Lean v4.33.1 · sandbox docker:nosorry-verifier:fc
- preflight — pass0.07 s
imports: FormalConjecturesUtil
- originality — pass0.04 s
no identical earlier submission
- compile reference statement — pass0.00 s
from cache
- compile submission — pass35.26 s
- statement & axioms — pass50.63 s
axioms: [propext, Quot.sound, Classical.choice]
- kernel replay — pass13.36 s
- comparator — skipped
not configured on this worker (COMPARATOR_BIN)
Points
| +100 | first verified proof of an open problem | 24 Nov 2026, 11:05 UTC |
Explanation
Complete sorry-free formalization of Written on the Wall II Conjecture 84 (wotw-graphconjecture84), proved via Jonas J. Gebendorfer (28 October 2026), Induced trees in graphs with a cut vertex: A proof of Written on the Wall II, Conjecture 84:
For any finite simple connected graph
Gwith positive minimum degree (0 < G.minDegree),2 * (G.radius.toNat : ℝ) / (G.minDegree : ℝ) ≤ (largestInducedTreeSize G : ℝ).
Proof overview:
- Case
G.minDegree ≥ 2: Any shortest path from an arbitrary vertexu₀to a vertex at maximum distance (≥ rad(G)) induces a tree on at leastrad(G) + 1vertices, hence(rad(G) + 1) * δ(G) ≥ 2 * (rad(G) + 1) ≥ 2 * rad(G). - Case
G.minDegree = 1and|V(G)| = 2:G ≃ K₂, sorad(G) = 1andlargestInducedTreeSize G = 2. - Case
G.minDegree = 1and|V(G)| ≥ 3: Every vertex adjacent to a degree-1 vertex is a cut vertex, reducing the conjecture to Gebendorfer's Theorem 1 (2 * rad(G) ≤ largestInducedTreeSize Gfor graphs with a cut vertex).- proved via core-pendant decomposition (
core_pendant_decomposition), radius-drop uniqueness lemma (radius_drop_unique_farthest), Chung's Theorem 2 (2 * rad(H) - 1 ≤ largestInducedTreeSize Hproved in full inchung_aux), constant pendant length along the 2-connected coreK, and attaching allL-pendants to a maximum induced subtree ofG[K].
- proved via core-pendant decomposition (
Verified locally with lake env lean W84Full.lean (0 errors, 0 warnings, axioms [propext, Classical.choice, Quot.sound]), alongside standalone verified intermediate lemmas:
lemma-wotw-graphconjecture84-chung-two-mul-radius-sub-one-le-largesti(s-r2r4mp1yf5, verified)lemma-wotw-graphconjecture84-two-mul-radius-le-largestinducedtreesize(s-5bvxzc9qrt, verified)
Declared prior work
Jonas J. Gebendorfer (Oct 2026), Induced trees in graphs with a cut vertex: A proof of Written on the Wall II, Conjecture 84
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 84
**Verbatim statement (WOWII #84, status O):**
> If G is a simple connected graph, then tree(G) ≥ 2 rad(G) / δ(G)
**Source:** http://cms.uhd.edu/faculty/delavinae/research/wowII/all.html#conj84
Here `δ(G)` is the **minimum degree** of `G` (lowercase delta in the WOWII
HTML, rendered as `<font face="Symbol">d</font>`), not the average distance.
*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.GraphConjecture84
open SimpleGraph
variable {α : Type*} [Fintype α] [DecidableEq α] [Nontrivial α]
section CutVertexHelpers
omit [Fintype α] [DecidableEq α] [Nontrivial α]
private lemma dist_getVert_le {β : Type*} {H : SimpleGraph β} (hH : H.Connected)
{a b : β} (q : H.Walk a b) :
∀ {i j : ℕ}, i ≤ j → j ≤ q.length → H.dist (q.getVert i) (q.getVert j) ≤ j - i := by
intro i j hij hj
obtain ⟨d, hd⟩ := Nat.exists_eq_add_of_le hij
subst hd
induction d with
| zero => simp
| succ d ih =>
have h1 : i + d < q.length := by omega
have ihd := ih (by omega) (by omega)
have hadj : H.Adj (q.getVert (i + d)) (q.getVert (i + d + 1)) :=
q.adj_getVert_succ h1
have htri : H.dist (q.getVert i) (q.getVert (i + d + 1)) ≤
H.dist (q.getVert i) (q.getVert (i + d)) +
H.dist (q.getVert (i + d)) (q.getVert (i + d + 1)) :=
hH.dist_triangle
have h1d : H.dist (q.getVert (i + d)) (q.getVert (i + d + 1)) = 1 :=
dist_eq_one_iff_adj.mpr hadj
rw [← Nat.add_assoc] at *
omega
private lemma geodesic_dist_getVert {β : Type*} {H : SimpleGraph β} (hH : H.Connected)
{a b : β} (q : H.Walk a b) (hq : q.length = H.dist a b) :
∀ {i j : ℕ}, i ≤ j → j ≤ q.length →
H.dist (q.getVert i) (q.getVert j) = j - i := by
intro i j hij hj
have h1 : H.dist a (q.getVert i) ≤ i := by
simpa [q.getVert_zero] using dist_getVert_le hH q (Nat.zero_le i) (hij.trans hj)
have h2 : H.dist (q.getVert i) (q.getVert j) ≤ j - i :=
dist_getVert_le hH q hij hj
have h3 : H.dist (q.getVert j) b ≤ q.length - j := by
simpa [q.getVert_length] using dist_getVert_le hH q hj (le_refl q.length)
have ht1 : H.dist a b ≤ H.dist a (q.getVert i) + H.dist (q.getVert i) b :=
hH.dist_triangle
have ht2 : H.dist (q.getVert i) b ≤ H.dist (q.getVert i) (q.getVert j) + H.dist (q.getVert j) b :=
hH.dist_triangle
omega
private lemma mem_support_iff_exists_getVert {β : Type*} {H : SimpleGraph β}
{a b z : β} (q : H.Walk a b) :
z ∈ q.support ↔ ∃ i ≤ q.length, q.getVert i = z := by
induction q with
| nil =>
simp only [Walk.support_nil, Walk.length_nil, List.mem_singleton, Nat.le_zero,
exists_eq_left, Walk.getVert_zero, eq_comm]
| @cons u v w huv q ih =>
simp only [Walk.support_cons, List.mem_cons, Walk.length_cons, ih]
constructor
· rintro (rfl | ⟨i, hi, rfl⟩)
· exact ⟨0, Nat.zero_le _, rfl⟩
· exact ⟨i + 1, Nat.succ_le_succ hi, by simp⟩
· rintro ⟨i, hi, rfl⟩
cases i with
| zero => exact Or.inl rfl
| succ i => exact Or.inr ⟨i, Nat.le_of_succ_le_succ hi, by simp⟩
private lemma walk_induce_tree_card_image {β : Type*} [Fintype β] [DecidableEq β]
{H : SimpleGraph β} {V' : Set β} (T' : Finset V')
(hT' : ((H.induce V').induce (T' : Set V')).IsTree) :
(H.induce ((T'.image Subtype.val : Finset β) : Set β)).IsTree := by
let S : Set β := (T'.image Subtype.val : Finset β)
have mem_iff (v : β) : v ∈ S ↔ ∃ u : V', u ∈ T' ∧ u.1 = v := by
simp [S]
let e : ((H.induce V').induce (T' : Set V')) ≃g H.induce S :=
{ toFun := fun x => ⟨x.1.1, (mem_iff x.1.1).mpr ⟨x.1, x.2, rfl⟩⟩
invFun := fun y =>
⟨((mem_iff y.1).mp y.2).choose, ((mem_iff y.1).mp y.2).choose_spec.1⟩
left_inv := fun x => by
apply Subtype.ext
apply Subtype.ext
exact ((mem_iff x.1.1).mp ((mem_iff x.1.1).mpr ⟨x.1, x.2, rfl⟩)).choose_spec.2
right_inv := fun y => by
apply Subtype.ext
exact ((mem_iff y.1).mp y.2).choose_spec.2
map_rel_iff' := fun {a b} => Iff.rfl }
exact (e.isTree_iff).mp hT'
private lemma card_largestInducedTreeSize_induce_le {β : Type*} [Fintype β] [DecidableEq β]
(H : SimpleGraph β) (V' : Set β) [Fintype V'] [DecidableEq V'] :
largestInducedTreeSize (H.induce V') ≤ largestInducedTreeSize H := by
classical
by_cases hne : ({n : ℕ | ∃ s : Finset V', s.card = n ∧
((H.induce V').induce (s : Set V')).IsTree}).Nonempty
· unfold largestInducedTreeSize
apply csSup_le hne
rintro n ⟨T', rfl, hT'⟩
have hT : (H.induce ((T'.image Subtype.val : Finset β) : Set β)).IsTree :=
walk_induce_tree_card_image T' hT'
have hcard : (T'.image Subtype.val).card = T'.card :=
Finset.card_image_of_injective T' Subtype.val_injective
rw [← hcard]
exact card_le_largestInducedTreeSize hT
· have h0 : largestInducedTreeSize (H.induce V') = 0 := by
unfold largestInducedTreeSize
rw [show {n : ℕ | ∃ s : Finset V', s.card = n ∧
((H.induce V').induce (s : Set V')).IsTree} = ∅ from
Set.not_nonempty_iff_eq_empty.mp hne]
simp
rw [h0]
exact Nat.zero_le _
private def walkInduce {β : Type*} {H : SimpleGraph β} {V' : Set β} :
∀ {a b : β} (q : H.Walk a b), (∀ z ∈ q.support, z ∈ V') →
(ha : a ∈ V') → (hb : b ∈ V') →
(H.induce V').Walk ⟨a, ha⟩ ⟨b, hb⟩
| _, _, .nil, _, ha, hb => .nil
| a, b, .cons (v := v1) hadj rest, hq, ha, hb =>
have hv1 : v1 ∈ V' := hq v1 (by simp [Walk.start_mem_support])
let u' : V' := ⟨a, ha⟩
let v' : V' := ⟨v1, hv1⟩
let w' : V' := ⟨b, hb⟩
let hadj' : (H.induce V').Adj u' v' := hadj
Walk.cons hadj' (walkInduce rest (fun z hz => hq z (List.mem_cons_of_mem _ hz)) hv1 hb)
private lemma walkInduce_length {β : Type*} {H : SimpleGraph β} {V' : Set β} :
∀ {a b : β} (q : H.Walk a b) (hq : ∀ z ∈ q.support, z ∈ V')
(ha : a ∈ V') (hb : b ∈ V'),
(walkInduce q hq ha hb).length = q.length
| _, _, .nil, _, _, _ => rfl
| _, _, .cons _ rest, hq, ha, hb => by
simp only [walkInduce, Walk.length_cons]
exact congrArg (· + 1) (walkInduce_length rest _ _ _)
private lemma walk_tail_exists {β : Type*} {H : SimpleGraph β}
{v x : β} (q : H.Walk v x) (hq : 1 ≤ q.length) :
∃ (v1 : β) (q' : H.Walk v1 x), v1 = q.getVert 1 ∧ q'.length = q.length - 1 ∧
∀ b ∈ q'.support, ∃ j, 1 ≤ j ∧ j ≤ q.length ∧ b = q.getVert j := by
cases q with
| nil => simp at hq
| @cons _ v1 _ hadj rest =>
refine ⟨v1, rest, by simp, by simp, fun b hb => ?_⟩
rw [mem_support_iff_exists_getVert] at hb
obtain ⟨j, hj, rfl⟩ := hb
exact ⟨j + 1, by omega, by simp only [Walk.length_cons]; omega, rfl⟩
private lemma insertChain_exists {β : Type*} [DecidableEq β] {H : SimpleGraph β}
(S₀ : Finset β) (hS₀ : (H.induce (S₀ : Set β)).IsTree)
{v w : β} (p : H.Walk v w) (hp : p.length = H.dist v w) (hH : H.Connected)
(a₀ : β) (ha₀_mem : a₀ ∈ S₀) (ha₀_adj : H.Adj (p.getVert 1) a₀)
(hdisj : ∀ i, 1 ≤ i → i ≤ p.length → p.getVert i ∉ S₀)
(huniq0 : ∀ i b, 1 ≤ i → i ≤ p.length → b ∈ S₀ → H.Adj (p.getVert i) b → i = 1 ∧ b = a₀) :
∀ k ≤ p.length, ∃ S : Finset β,
(H.induce (S : Set β)).IsTree ∧
S.card = S₀.card + k ∧
S = S₀ ∪ (Finset.Icc 1 k).image (fun i => p.getVert i) := by
intro k hk
induction k with
| zero =>
refine ⟨S₀, hS₀, by simp, by simp⟩
| succ k ih =>
obtain ⟨S, hSTree, hScard, rfl⟩ := ih (Nat.le_of_succ_le hk)
set z := p.getVert (k + 1)
have hz_notin : z ∉ S₀ ∪ (Finset.Icc 1 k).image (fun i => p.getVert i) := by
simp only [Finset.mem_union, Finset.mem_image, Finset.mem_Icc, not_or, not_exists, not_and]
refine ⟨hdisj (k + 1) (Nat.succ_pos k) hk, ?_⟩
rintro i ⟨hi1, hik⟩ heq
have hd1 : H.dist v (p.getVert i) = i := by
simpa [p.getVert_zero] using geodesic_dist_getVert hH p hp (Nat.zero_le i) (hik.trans (Nat.le_of_succ_le hk))
have hd2 : H.dist v z = k + 1 := by
simpa [p.getVert_zero] using geodesic_dist_getVert hH p hp (Nat.zero_le (k + 1)) hk
rw [heq, hd2] at hd1
omega
have hk_or : k = 0 ∨ 1 ≤ k := by omega
rcases hk_or with rfl | hk1
· have hz_tree : (H.induce ((insert z (S₀ ∪ (Finset.Icc 1 0).image (fun i => p.getVert i)) : Finset β) : Set β)).IsTree := by
apply IsTree.induce_insert_of_unique_adj hSTree hz_notin
(Finset.mem_union_left _ ha₀_mem) ha₀_adj
intro b hb hzb
simp only [Finset.Icc_eq_empty_of_lt (by omega : 1 > 0), Finset.image_empty,
Finset.union_empty] at hb
exact (huniq0 1 b (le_refl 1) hk hb hzb).2
refine ⟨insert z (S₀ ∪ (Finset.Icc 1 0).image (fun i => p.getVert i)), hz_tree, ?_, ?_⟩
· rw [Finset.card_insert_of_notMem hz_notin, hScard]
· ext u
simp only [Finset.mem_insert, Finset.mem_union, Finset.mem_image, Finset.mem_Icc,
Finset.Icc_eq_empty_of_lt (by omega : 1 > 0), Finset.image_empty, Finset.union_empty]
constructor
· rintro (rfl | hu)
· exact Or.inr ⟨1, ⟨le_refl 1, le_refl 1⟩, rfl⟩
· exact Or.inl hu
· rintro (hu | ⟨i, ⟨hi1, hik⟩, rfl⟩)
· exact Or.inr hu
· have : i = 1 := by omega
subst this
exact Or.inl rfl
· have hak_mem : p.getVert k ∈ S₀ ∪ (Finset.Icc 1 k).image (fun i => p.getVert i) :=
Finset.mem_union_right _ (Finset.mem_image_of_mem _ (Finset.mem_Icc.mpr ⟨hk1, le_refl k⟩))
have hak_adj : H.Adj z (p.getVert k) := (p.adj_getVert_succ hk).symm
have hz_tree : (H.induce ((insert z (S₀ ∪ (Finset.Icc 1 k).image (fun i => p.getVert i)) : Finset β) : Set β)).IsTree := by
apply IsTree.induce_insert_of_unique_adj hSTree hz_notin hak_mem hak_adj
intro b hb hzb
simp only [Finset.mem_union, Finset.mem_image, Finset.mem_Icc] at hb
rcases hb with hbS₀ | ⟨i, ⟨hi1, hik⟩, rfl⟩
· have h1 := (huniq0 (k + 1) b (by omega) hk hbS₀ hzb).1
omega
· have hd1 : H.dist v (p.getVert i) = i := by
simpa [p.getVert_zero] using geodesic_dist_getVert hH p hp (Nat.zero_le i) (hik.trans (Nat.le_of_succ_le hk))
have hd2 : H.dist v z = k + 1 := by
simpa [p.getVert_zero] using geodesic_dist_getVert hH p hp (Nat.zero_le (k + 1)) hk
have htri : H.dist v z ≤ H.dist v (p.getVert i) + H.dist (p.getVert i) z :=
hH.dist_triangle
have h1d : H.dist (p.getVert i) z = 1 := dist_eq_one_iff_adj.mpr hzb.symm
have hik_eq : i = k := by omega
subst hik_eq
rfl
refine ⟨insert z (S₀ ∪ (Finset.Icc 1 k).image (fun i => p.getVert i)), hz_tree, ?_, ?_⟩
· rw [Finset.card_insert_of_notMem hz_notin, hScard]; omega
· ext u
simp only [Finset.mem_insert, Finset.mem_union, Finset.mem_image, Finset.mem_Icc]
constructor
· rintro (rfl | hu | ⟨i, ⟨hi1, hik⟩, rfl⟩)
· exact Or.inr ⟨k + 1, ⟨by omega, le_refl _⟩, rfl⟩
· exact Or.inl hu
· exact Or.inr ⟨i, ⟨hi1, by omega⟩, rfl⟩
· rintro (hu | ⟨i, ⟨hi1, hik⟩, rfl⟩)
· exact Or.inr (Or.inl hu)
· by_cases hi_eq : i = k + 1
· subst hi_eq; exact Or.inl rfl
· exact Or.inr (Or.inr ⟨i, ⟨hi1, by omega⟩, rfl⟩)
-- Lemma 1 (Gebendorfer 2026): Radius-drop lemma with centre characterization
private lemma radius_drop_unique_farthest {β : Type*} [Fintype β] [DecidableEq β] [Nonempty β]
(H : SimpleGraph β) [DecidableRel H.Adj] (hH : H.Connected)
(x : β) (hx_ne : Nonempty ({x}ᶜ : Set β))
(hH' : (H.induce ({x}ᶜ : Set β)).Connected)
(hlt : (H.induce ({x}ᶜ : Set β)).radius.toNat < H.radius.toNat) :
∃ v : β, v ≠ x ∧ H.dist v x = H.radius.toNat ∧
(∀ z : β, z ≠ x → H.dist v z ≤ H.radius.toNat - 1) ∧
computable_eccent H v = H.radius.toNat := by
set V' : Set β := {x}ᶜ
set H' : SimpleGraph V' := H.induce V'
set r := H.radius.toNat
have hr1 : 1 ≤ r := by omega
have hrad_eq : r = computable_radius H := by
change H.radius.toNat = computable_radius H
rw [radius_eq_computable H hH]; rfl
have hrad'_eq : H'.radius.toNat = computable_radius H' := by
rw [radius_eq_computable H' hH']; rfl
have hecc_ge (u : β) : r ≤ computable_eccent H u := by
have hle := H.radius_le_eccent (u := u)
rw [radius_eq_computable H hH, eccent_eq_computable H hH u] at hle
have hle' : computable_radius H ≤ computable_eccent H u := by exact_mod_cast hle
omega
obtain ⟨c', _, hc'_min⟩ :=
Finset.exists_min_image (Finset.univ : Finset V') (fun u => computable_eccent H' u)
Finset.univ_nonempty
have hc'_ecc : computable_eccent H' c' ≤ r - 1 := by
have hcr : computable_radius H' = computable_eccent H' c' := by
apply le_antisymm
· exact Finset.inf'_le _ (Finset.mem_univ c')
· exact Finset.le_inf' _ _ fun u hu => hc'_min u hu
omega
let v : β := c'.1
have hv_ne_x : v ≠ x := c'.2
have hdist_v_ne : ∀ z : β, z ≠ x → H.dist v z ≤ r - 1 := by
intro z hz
have hH'_dist : H'.dist c' ⟨z, hz⟩ ≤ computable_eccent H' c' := by
rw [dist_eq_computable]
exact Finset.le_sup (f := fun u => computable_dist H' c' u) (Finset.mem_univ _)
obtain ⟨w', hw'⟩ := hH'.exists_walk_length_eq_dist c' ⟨z, hz⟩
have h_le : H.dist v z ≤ (w'.map (Embedding.induce V').toHom).length := dist_le _
rw [Walk.length_map, hw'] at h_le
omega
have hdist_vx_le : H.dist v x ≤ r := by
obtain ⟨qvx, hqvx⟩ := hH.exists_walk_length_eq_dist v x
have hlen_pos : 1 ≤ qvx.length := by
rw [hqvx]
exact Nat.pos_of_ne_zero fun h0 =>
hv_ne_x ((hH.dist_eq_zero_iff).mp h0)
let u := qvx.getVert (qvx.length - 1)
have hadj : H.Adj u x := by
simpa [u, Nat.sub_add_cancel hlen_pos, qvx.getVert_length] using
qvx.adj_getVert_succ (by omega : qvx.length - 1 < qvx.length)
have hvu := hdist_v_ne u hadj.ne
have hux : H.dist u x = 1 := dist_eq_one_iff_adj.mpr hadj
have htri : H.dist v x ≤ H.dist v u + H.dist u x := hH.dist_triangle
omega
have hdist_vx : H.dist v x = r := by
have hv_ecc : r ≤ computable_eccent H v := hecc_ge v
obtain ⟨zmax, _, hzmax⟩ :=
Finset.exists_max_image (Finset.univ : Finset β) (fun z => computable_dist H v z)
Finset.univ_nonempty
have h_sup_le : computable_eccent H v ≤ computable_dist H v zmax := by
unfold computable_eccent
exact Finset.sup_le fun z _ => hzmax z (Finset.mem_univ z)
rw [← dist_eq_computable] at h_sup_le
by_cases hzx : zmax = x
· subst hzx; omega
· have := hdist_v_ne zmax hzx; omega
have hv_ecc_eq : computable_eccent H v = r := by
apply le_antisymm _ (hecc_ge v)
unfold computable_eccent
apply Finset.sup_le
intro z _
rw [← dist_eq_computable]
by_cases hzx : z = x
· subst hzx; omega
· have := hdist_v_ne z hzx; omega
exact ⟨v, hv_ne_x, hdist_vx, hdist_v_ne, hv_ecc_eq⟩
-- Tree bound (Part 0): every finite tree satisfies 2 * rad(T) ≤ |V(T)|
private lemma walk_isPath_length_eq_dist_of_isTree {β : Type*} {H : SimpleGraph β}
(hT : H.IsTree) {a b : β} (q : H.Walk a b) (hq : q.IsPath) :
q.length = H.dist a b := by
obtain ⟨s, hs, hsl⟩ := hT.connected.exists_path_of_dist a b
have heq := (hT.existsUnique_path a b).unique hq hs
rw [heq, hsl]
private lemma tree_two_mul_radius_le_card {β : Type*} [Fintype β] [DecidableEq β]
(H : SimpleGraph β) [DecidableRel H.Adj] (hT : H.IsTree) :
2 * H.radius.toNat ≤ Fintype.card β := by
classical
have : Nonempty β := hT.connected.nonempty
obtain ⟨⟨a, b⟩, _, hab_max⟩ :=
Finset.exists_max_image (Finset.univ : Finset (β × β))
(fun p => H.dist p.1 p.2) Finset.univ_nonempty
set D := H.dist a b
obtain ⟨p, hp⟩ := hT.connected.exists_walk_length_eq_dist a b
have hp_path : p.IsPath := p.isPath_of_length_eq_dist hp
have hp_len : p.length = D := hp
have hp_card : D + 1 ≤ Fintype.card β := by
have hnodup := hp_path.support_nodup
have hle : p.support.toFinset.card ≤ Fintype.card β := Finset.card_le_univ _
rw [List.toFinset_card_of_nodup hnodup, Walk.length_support, hp_len] at hle
exact hle
let m := p.getVert (D / 2)
have hm_ecc : computable_eccent H m ≤ (D + 1) / 2 := by
unfold computable_eccent
apply Finset.sup_le
intro z _
rw [← dist_eq_computable]
obtain ⟨i, _, hi_min⟩ :=
Finset.exists_min_image (Finset.univ : Finset (Fin (D + 1)))
(fun j => H.dist z (p.getVert j)) Finset.univ_nonempty
let u := p.getVert i
set h := H.dist z u
obtain ⟨w, hw⟩ := hT.connected.exists_walk_length_eq_dist z u
have hw_path : w.IsPath := w.isPath_of_length_eq_dist hw
have hw_disj : ∀ x ∈ w.support, x ∈ p.support → x = u := by
intro x hxw hxp
rw [mem_support_iff_exists_getVert] at hxp hxw
obtain ⟨j, hj, rfl⟩ := hxp
obtain ⟨k, hk, hkx⟩ := hxw
have h_le_h : H.dist z (p.getVert j) ≤ k := by
simpa [← hkx, w.getVert_zero] using dist_getVert_le hT.connected w (Nat.zero_le k) hk
have h_ge_h : h ≤ H.dist z (p.getVert j) :=
hi_min ⟨j, by omega⟩ (Finset.mem_univ _)
have hk_eq : k = w.length := by omega
subst hk_eq
rw [← hkx, w.getVert_length]
have hu_supp : u ∈ p.support := (mem_support_iff_exists_getVert p).mpr ⟨i.1, by omega, rfl⟩
let p1 := p.takeUntil u hu_supp
let p2 := p.dropUntil u hu_supp
have hp1_len : p1.length = i.1 := by
have hp1_geod : p1.length = H.dist a u := by
have hsub : p1.IsSubwalk p := ⟨.nil, p2, by simp [p1, p2, p.take_spec]⟩
exact length_eq_dist_of_subwalk hp hsub
have hda : H.dist a u = i.1 := by
simpa [u, p.getVert_zero] using geodesic_dist_getVert hT.connected p hp (Nat.zero_le _) (by omega)
omega
have hi_le : i.1 ≤ D := Nat.lt_succ_iff.mp i.isLt
have hp2_len : p2.length = D - i.1 := by
have hp2_geod : p2.length = H.dist u b := by
have hsub : p2.IsSubwalk p := ⟨p1, .nil, by simp [p1, p2, p.take_spec]⟩
exact length_eq_dist_of_subwalk hp hsub
have hdb : H.dist u b = D - i.1 := by
simpa [u, ← hp_len, p.getVert_length] using
geodesic_dist_getVert hT.connected p hp hi_le (by omega)
omega
-- Any internal vertex of p1 or p2 is in p.support, so w.append p2 and w.append p1.reverse are paths
have hp1_sub : ∀ x ∈ p1.support, x ∈ p.support := fun x hx =>
Walk.support_takeUntil_subset_support p hu_supp hx
have hp2_sub : ∀ x ∈ p2.support, x ∈ p.support := fun x hx =>
Walk.support_dropUntil_subset_support p hu_supp hx
have hw_p1_path : (w.append p1.reverse).IsPath := by
rw [Walk.isPath_def, Walk.support_append, List.nodup_append]
refine ⟨hw_path.support_nodup, ?_, ?_⟩
· have hp1p : p1.IsPath := hp_path.takeUntil hu_supp
exact List.Nodup.tail hp1p.reverse.support_nodup
· intro x hxw y hy heq
subst heq
have hy_p1 : x ∈ p1.support := by
have hy_rev : x ∈ p1.reverse.support := List.tail_subset _ hy
rwa [Walk.support_reverse, List.mem_reverse] at hy_rev
have hxu : x = u := hw_disj x hxw (hp1_sub x hy_p1)
subst hxu
have hp1r : p1.reverse.IsPath := (hp_path.takeUntil hu_supp).reverse
have hnod := hp1r.support_nodup
rw [← Walk.cons_tail_support] at hnod
exact (List.nodup_cons.mp hnod).1 hy
have hw_p2_path : (w.append p2).IsPath := by
rw [Walk.isPath_def, Walk.support_append, List.nodup_append]
refine ⟨hw_path.support_nodup, ?_, ?_⟩
· have hp2p : p2.IsPath := hp_path.dropUntil hu_supp
exact List.Nodup.tail hp2p.support_nodup
· intro x hxw y hy heq
subst heq
have hxu : x = u := hw_disj x hxw (hp2_sub x (List.tail_subset _ hy))
subst hxu
have hp2p : p2.IsPath := hp_path.dropUntil hu_supp
have hnod := hp2p.support_nodup
rw [← Walk.cons_tail_support] at hnod
exact (List.nodup_cons.mp hnod).1 hy
have hza : H.dist z a = h + i.1 := by
rw [← walk_isPath_length_eq_dist_of_isTree hT (w.append p1.reverse) hw_p1_path]
simp [Walk.length_append, hw, hp1_len, h]
have hzb : H.dist z b = h + (D - i.1) := by
rw [← walk_isPath_length_eq_dist_of_isTree hT (w.append p2) hw_p2_path]
simp [Walk.length_append, hw, hp2_len, h]
have hza_le : H.dist z a ≤ D := hab_max (z, a) (Finset.mem_univ _)
have hzb_le : H.dist z b ≤ D := hab_max (z, b) (Finset.mem_univ _)
have hmu : H.dist m u = if i.1 ≤ D / 2 then D / 2 - i.1 else i.1 - D / 2 := by
split_ifs with hiD
· rw [H.dist_comm]
exact geodesic_dist_getVert hT.connected p hp hiD (by omega)
· exact geodesic_dist_getVert hT.connected p hp (by omega) (by omega)
have htri : H.dist m z ≤ H.dist m u + H.dist u z := hT.connected.dist_triangle
rw [H.dist_comm (u := u) (v := z)] at htri
split_ifs at hmu <;> omega
have hrad_le : H.radius.toNat ≤ computable_eccent H m := by
have hle := H.radius_le_eccent (u := m)
rw [radius_eq_computable H hT.connected, eccent_eq_computable H hT.connected m] at hle
have hle' : computable_radius H ≤ computable_eccent H m := by exact_mod_cast hle
have hr_eq : H.radius.toNat = computable_radius H := by
rw [radius_eq_computable H hT.connected]; rfl
omega
omega
private def walk_comp_lift {β : Type*} {G : SimpleGraph β} {c : β}
{C1 : (G.induce ({c}ᶜ : Set β)).ConnectedComponent} {VH : Set β}
(hC1_sub : ∀ u : β, (hu : u ≠ c) →
(G.induce ({c}ᶜ : Set β)).connectedComponentMk ⟨u, hu⟩ = C1 → u ∈ VH) :
∀ {a b : ({c}ᶜ : Set β)}
(ha : (G.induce ({c}ᶜ : Set β)).connectedComponentMk a = C1)
(hb : (G.induce ({c}ᶜ : Set β)).connectedComponentMk b = C1),
(G.induce ({c}ᶜ : Set β)).Walk a b →
(G.induce VH).Walk ⟨a.1, hC1_sub a.1 a.2 ha⟩ ⟨b.1, hC1_sub b.1 b.2 hb⟩
| _, _, ha, hb, .nil => .nil
| a, b, ha, hb, .cons (v := v1) hadj rest =>
have hv1 : (G.induce ({c}ᶜ : Set β)).connectedComponentMk v1 = C1 := by
rw [← ha]
exact (ConnectedComponent.eq.mpr hadj.reachable).symm
let u' : VH := ⟨a.1, hC1_sub a.1 a.2 ha⟩
let v' : VH := ⟨v1.1, hC1_sub v1.1 v1.2 hv1⟩
let _w' : VH := ⟨b.1, hC1_sub b.1 b.2 hb⟩
Walk.cons (u := u') (v := v') (w := _w') hadj
(walk_comp_lift hC1_sub hv1 hb rest)
private lemma geodesic_positive_tail_same_comp {β : Type*} {G : SimpleGraph β}
(hG : G.Connected) (c : β) {z : ({c}ᶜ : Set β)} (q : G.Walk c z.1)
(hq : q.length = G.dist c z.1) :
∀ k, 1 ≤ k → k ≤ q.length →
∃ hk : q.getVert k ≠ c,
(G.induce ({c}ᶜ : Set β)).connectedComponentMk ⟨q.getVert k, hk⟩ =
(G.induce ({c}ᶜ : Set β)).connectedComponentMk z := by
intro k hk1 hk2
have hk_ne : q.getVert k ≠ c := by
have hd : G.dist c (q.getVert k) = k := by
simpa [q.getVert_zero] using geodesic_dist_getVert hG q hq (Nat.zero_le k) hk2
intro heq
rw [heq, G.dist_self] at hd
omega
refine ⟨hk_ne, ?_⟩
obtain ⟨d, hd⟩ := Nat.exists_eq_add_of_le hk2
induction d generalizing k with
| zero =>
have hkeq : k = q.length := by omega
subst hkeq
have hv : q.getVert q.length = z.1 := q.getVert_length
congr 1
exact Subtype.ext hv
| succ d ih =>
have hstep_ne : q.getVert (k + 1) ≠ c := by
have hd1 : G.dist c (q.getVert (k + 1)) = k + 1 := by
simpa [q.getVert_zero] using
geodesic_dist_getVert hG q hq (Nat.zero_le (k + 1)) (by omega)
intro heq
rw [heq, G.dist_self] at hd1
omega
have hadj : (G.induce ({c}ᶜ : Set β)).Adj ⟨q.getVert k, hk_ne⟩ ⟨q.getVert (k + 1), hstep_ne⟩ :=
q.adj_getVert_succ (by omega)
have h_eq1 : (G.induce ({c}ᶜ : Set β)).connectedComponentMk ⟨q.getVert k, hk_ne⟩ =
(G.induce ({c}ᶜ : Set β)).connectedComponentMk ⟨q.getVert (k + 1), hstep_ne⟩ :=
ConnectedComponent.eq.mpr hadj.reachable
rw [h_eq1]
exact ih (k + 1) (by omega) (by omega) hstep_ne (by omega)
-- Part 1: Every cut vertex in a minimal counterexample splits G into two components,
-- where the shallower one is a geodesic pendant path of length e2 ≤ e1 - 2.
private lemma cutVertex_pendant_structure {β : Type u} [Fintype β] [DecidableEq β] [Nonempty β]
(G : SimpleGraph β) [DecidableRel G.Adj] (hG : G.Connected)
(hlt : largestInducedTreeSize G < 2 * G.radius.toNat)
(ih : ∀ {γ : Type u} [Fintype γ] [DecidableEq γ] [Nonempty γ]
(H : SimpleGraph γ) [DecidableRel H.Adj],
Fintype.card γ < Fintype.card β → H.Connected →
∀ v : γ, ¬ (H.induce ({v}ᶜ : Set γ)).Connected →
2 * H.radius.toNat ≤ largestInducedTreeSize H)
(c : β) (hc_cut : ¬ (G.induce ({c}ᶜ : Set β)).Connected) :
∃ (C1 C2 : (G.induce ({c}ᶜ : Set β)).ConnectedComponent)
(z2 : β) (hz2 : z2 ≠ c) (p2 : G.Walk c z2),
C1 ≠ C2 ∧
(∀ C : (G.induce ({c}ᶜ : Set β)).ConnectedComponent, C = C1 ∨ C = C2) ∧
p2.length = G.dist c z2 ∧
1 ≤ p2.length ∧
p2.length + 2 ≤ computable_eccent G c ∧
(G.induce ({c}ᶜ : Set β)).connectedComponentMk ⟨z2, hz2⟩ = C2 ∧
(∀ u : β, (hu : u ≠ c) →
((G.induce ({c}ᶜ : Set β)).connectedComponentMk ⟨u, hu⟩ = C2 ↔
u ∈ p2.support)) := by
classical
set r := G.radius.toNat
have hr1 : 1 ≤ r := by
have h1 := one_le_largestInducedTreeSize G
omega
have hrad_eq : r = computable_radius G := by
change G.radius.toNat = computable_radius G
rw [radius_eq_computable G hG]; rfl
have hecc_ge (u : β) : r ≤ computable_eccent G u := by
have hle := G.radius_le_eccent (u := u)
rw [radius_eq_computable G hG, eccent_eq_computable G hG u] at hle
have hle' : computable_radius G ≤ computable_eccent G u := by exact_mod_cast hle
omega
have hcard2 : 2 ≤ Fintype.card β := by
by_contra hlt2
have h1 : Fintype.card β = 1 := by
have := Fintype.card_pos (α := β); omega
have hsub : Subsingleton β := Fintype.card_le_one_iff_subsingleton.mp (by omega)
have he0 : computable_eccent G c = 0 := by
apply Nat.eq_zero_of_le_zero
unfold computable_eccent
apply Finset.sup_le
intro z _
rw [← dist_eq_computable, Subsingleton.elim z c, G.dist_self]
have := hecc_ge c
omega
have hnt : Nontrivial β := Fintype.one_lt_card_iff_nontrivial.mp (by omega)
obtain ⟨w0, hw0⟩ := @exists_ne _ hnt c
let Vc : Set β := {c}ᶜ
let Gc : SimpleGraph Vc := G.induce Vc
have hVc_ne : Nonempty Vc := ⟨⟨w0, hw0⟩⟩
have h_not_pre : ¬ Gc.Preconnected := fun hp => hc_cut ⟨hp⟩
rw [Preconnected] at h_not_pre
push Not at h_not_pre
obtain ⟨ca, cb, h_not_reach⟩ := h_not_pre
have h_comp_ne : Gc.connectedComponentMk ca ≠ Gc.connectedComponentMk cb := by
intro heq
exact h_not_reach (ConnectedComponent.eq.mp heq)
let depth (C : Gc.ConnectedComponent) : ℕ :=
Finset.univ.sup (fun u : Vc => if Gc.connectedComponentMk u = C then G.dist c u.1 else 0)
have h_le_depth (u : β) (hu : u ≠ c) : G.dist c u ≤ depth (Gc.connectedComponentMk ⟨u, hu⟩) := by
unfold depth
exact Finset.le_sup_of_le (Finset.mem_univ (⟨u, hu⟩ : Vc)) (by simp)
have hdepth_pos (C : Gc.ConnectedComponent) : 1 ≤ depth C := by
obtain ⟨u, rfl⟩ := C.exists_rep
have hle := h_le_depth u.1 u.2
have hpos : 1 ≤ G.dist c u.1 :=
Nat.pos_of_ne_zero fun h0 => u.2 ((hG.dist_eq_zero_iff).mp h0).symm
exact Nat.le_trans hpos hle
have hdepth_attained (C : Gc.ConnectedComponent) :
∃ z : Vc, Gc.connectedComponentMk z = C ∧ G.dist c z.1 = depth C := by
obtain ⟨z, _, hz_max⟩ :=
Finset.exists_max_image (Finset.univ : Finset Vc)
(fun u => if Gc.connectedComponentMk u = C then G.dist c u.1 else 0)
Finset.univ_nonempty
have h_sup : depth C ≤ if Gc.connectedComponentMk z = C then G.dist c z.1 else 0 := by
unfold depth
exact Finset.sup_le fun u _ => hz_max u (Finset.mem_univ u)
have hpos := hdepth_pos C
split_ifs at h_sup with hzc
· refine ⟨z, hzc, le_antisymm ?_ h_sup⟩
unfold depth
exact Finset.le_sup_of_le (Finset.mem_univ z) (by simp [hzc])
· omega
obtain ⟨C1, _, hC1_max⟩ :=
Finset.exists_max_image (Finset.univ : Finset Gc.ConnectedComponent) depth Finset.univ_nonempty
have h_erase_ne : (Finset.univ.erase C1 : Finset Gc.ConnectedComponent).Nonempty := by
by_cases ha : Gc.connectedComponentMk ca = C1
· exact ⟨Gc.connectedComponentMk cb, Finset.mem_erase.mpr ⟨by rw [← ha]; exact h_comp_ne.symm, Finset.mem_univ _⟩⟩
· exact ⟨Gc.connectedComponentMk ca, Finset.mem_erase.mpr ⟨ha, Finset.mem_univ _⟩⟩
obtain ⟨C2, hC2_mem, hC2_max⟩ :=
Finset.exists_max_image (Finset.univ.erase C1) depth h_erase_ne
have hC12_ne : C1 ≠ C2 := (Finset.mem_erase.mp hC2_mem).1.symm
set e1 := depth C1
set e2 := depth C2
have he1_pos : 1 ≤ e1 := hdepth_pos C1
have he2_pos : 1 ≤ e2 := hdepth_pos C2
obtain ⟨z1, hz1_comp, hz1_dist⟩ := hdepth_attained C1
obtain ⟨z2, hz2_comp, hz2_dist⟩ := hdepth_attained C2
have he1_ecc : e1 = computable_eccent G c := by
apply le_antisymm
· dsimp only [e1]
rw [← hz1_dist, dist_eq_computable]
exact Finset.le_sup (f := fun z => computable_dist G c z) (Finset.mem_univ _)
· unfold computable_eccent
apply Finset.sup_le
intro z _
rw [← dist_eq_computable]
by_cases hzc : z = c
· subst hzc; simp
· have hle1 : G.dist c z ≤ depth (Gc.connectedComponentMk ⟨z, hzc⟩) := h_le_depth z hzc
have hle2 : depth (Gc.connectedComponentMk ⟨z, hzc⟩) ≤ e1 :=
hC1_max _ (Finset.mem_univ _)
omega
obtain ⟨p1, hp1⟩ := hG.exists_walk_length_eq_dist c z1.1
obtain ⟨p2, hp2⟩ := hG.exists_walk_length_eq_dist c z2.1
have hp1_comp : ∀ i, 1 ≤ i → i ≤ p1.length →
∃ hi : p1.getVert i ≠ c, Gc.connectedComponentMk ⟨p1.getVert i, hi⟩ = C1 := by
intro i hi1 hi2
obtain ⟨hi, hcomp⟩ := geodesic_positive_tail_same_comp hG c p1 hp1 i hi1 hi2
exact ⟨hi, hcomp.trans hz1_comp⟩
have hp2_comp : ∀ j, 1 ≤ j → j ≤ p2.length →
∃ hj : p2.getVert j ≠ c, Gc.connectedComponentMk ⟨p2.getVert j, hj⟩ = C2 := by
intro j hj1 hj2
obtain ⟨hj, hcomp⟩ := geodesic_positive_tail_same_comp hG c p2 hp2 j hj1 hj2
exact ⟨hj, hcomp.trans hz2_comp⟩
-- Apply insertChain_exists to combine p1 and p2 into an induced tree of size e1 + e2 + 1
have he2_le_e1 : e2 + 2 ≤ e1 := by
let S₀ := p1.support.toFinset
have hS₀_tree : (G.induce (S₀ : Set β)).IsTree :=
Walk.induce_support_isTree_of_length_eq_dist p1 hp1
have hS₀_card : S₀.card = e1 + 1 := by
have hnod := (p1.isPath_of_length_eq_dist hp1).support_nodup
rw [List.toFinset_card_of_nodup hnod, Walk.length_support, hp1, hz1_dist]
have hc_mem : c ∈ S₀ := by simp [S₀, Walk.start_mem_support]
have hc_adj : G.Adj (p2.getVert 1) c := by
simpa [p2.getVert_zero] using (p2.adj_getVert_succ (by omega : 0 < p2.length)).symm
have hS₀_mem (b : β) : b ∈ S₀ → ∃ i ≤ p1.length, b = p1.getVert i := by
intro hb
simp only [S₀, List.mem_toFinset] at hb
rw [mem_support_iff_exists_getVert] at hb
obtain ⟨i, hi, rfl⟩ := hb
exact ⟨i, hi, rfl⟩
have hdisj : ∀ j, 1 ≤ j → j ≤ p2.length → p2.getVert j ∉ S₀ := by
intro j hj1 hj2 hmem
obtain ⟨i, hi, heq⟩ := hS₀_mem _ hmem
obtain ⟨hj_ne, hj_comp⟩ := hp2_comp j hj1 hj2
rcases Nat.eq_zero_or_pos i with rfl | hi1
· rw [p1.getVert_zero] at heq; exact hj_ne heq
· obtain ⟨hi_ne, hi_comp⟩ := hp1_comp i hi1 hi
have heq' : (⟨p2.getVert j, hj_ne⟩ : Vc) = ⟨p1.getVert i, hi_ne⟩ := Subtype.ext heq
have hce : C2 = C1 := by rw [← hj_comp, ← hi_comp, heq']
exact hC12_ne hce.symm
have huniq : ∀ j b, 1 ≤ j → j ≤ p2.length → b ∈ S₀ →
G.Adj (p2.getVert j) b → j = 1 ∧ b = c := by
intro j b hj1 hj2 hb hadjb
obtain ⟨i, hi, rfl⟩ := hS₀_mem b hb
obtain ⟨hj_ne, hj_comp⟩ := hp2_comp j hj1 hj2
rcases Nat.eq_zero_or_pos i with rfl | hi1
· rw [p1.getVert_zero] at hadjb ⊢
have hdj : G.dist c (p2.getVert j) = j := by
simpa [p2.getVert_zero] using geodesic_dist_getVert hG p2 hp2 (Nat.zero_le j) hj2
have h1d : G.dist (p2.getVert j) c = 1 := dist_eq_one_iff_adj.mpr hadjb
rw [G.dist_comm] at h1d
exact ⟨by omega, rfl⟩
· obtain ⟨hi_ne, hi_comp⟩ := hp1_comp i hi1 hi
have hadj_vc : Gc.Adj ⟨p2.getVert j, hj_ne⟩ ⟨p1.getVert i, hi_ne⟩ := hadjb
have hce : C2 = C1 := by
rw [← hj_comp, ← hi_comp]
exact ConnectedComponent.eq.mpr hadj_vc.reachable
exact absurd hce.symm hC12_ne
obtain ⟨S, hSTree, hScard, _⟩ :=
insertChain_exists S₀ hS₀_tree p2 hp2 hG c hc_mem hc_adj hdisj huniq p2.length (le_refl _)
have hbound := card_le_largestInducedTreeSize hSTree
have hecc := hecc_ge c
omega
-- Construct H = G[A ∪ p2.support] and show H.radius.toNat = r, forcing V(H) = V(G)
let A : Set β := {u : β | u = c ∨ ∃ hu : u ≠ c, Gc.connectedComponentMk ⟨u, hu⟩ = C1}
let VH : Set β := {u : β | u ∈ A ∨ u ∈ p2.support}
let H : SimpleGraph VH := G.induce VH
have hcA : c ∈ A := Or.inl rfl
have hcVH : c ∈ VH := Or.inl hcA
have hVH_ne : Nonempty VH := ⟨⟨c, hcVH⟩⟩
have hz1A : z1.1 ∈ A := Or.inr ⟨z1.2, hz1_comp⟩
have hC1_sub_VH : ∀ u : β, (hu : u ≠ c) → Gc.connectedComponentMk ⟨u, hu⟩ = C1 → u ∈ VH :=
fun u hu hcomp => Or.inl (Or.inr ⟨hu, hcomp⟩)
have hp2_sub_VH : ∀ u ∈ p2.support, u ∈ VH := fun u hu => Or.inr hu
have hp1_sub_VH : ∀ u ∈ p1.support, u ∈ VH := by
intro u hu
rw [mem_support_iff_exists_getVert] at hu
obtain ⟨i, hi, rfl⟩ := hu
rcases Nat.eq_zero_or_pos i with rfl | hi1
· simpa [p1.getVert_zero] using hcVH
· obtain ⟨hi_ne, hi_comp⟩ := hp1_comp i hi1 hi
exact hC1_sub_VH _ hi_ne hi_comp
-- Connect every vertex of VH to ⟨c, hcVH⟩ in H
have hH_reach_c : ∀ x : VH, H.Reachable ⟨c, hcVH⟩ x := by
intro ⟨x, hx⟩
rcases hx with (rfl | ⟨hxc, hxC1⟩) | hxp2
· exact Reachable.refl _
· have hreach_z1 : Gc.Reachable ⟨x, hxc⟩ z1 :=
ConnectedComponent.eq.mp (hxC1.trans hz1_comp.symm)
obtain ⟨wx⟩ := hreach_z1
have h1 : H.Reachable ⟨x, Or.inl (Or.inr ⟨hxc, hxC1⟩)⟩ ⟨z1.1, Or.inl hz1A⟩ :=
⟨walk_comp_lift hC1_sub_VH hxC1 hz1_comp wx⟩
have h2 : H.Reachable ⟨c, hcVH⟩ ⟨z1.1, Or.inl hz1A⟩ :=
⟨walkInduce p1 hp1_sub_VH hcVH (Or.inl hz1A)⟩
exact h2.trans h1.symm
· rw [mem_support_iff_exists_getVert] at hxp2
obtain ⟨j, hj, rfl⟩ := hxp2
have hsub : ∀ z ∈ (p2.takeUntil (p2.getVert j)
((mem_support_iff_exists_getVert p2).mpr ⟨j, hj, rfl⟩)).support, z ∈ VH :=
fun z hz => hp2_sub_VH z (Walk.support_takeUntil_subset_support p2 _ hz)
exact ⟨walkInduce _ hsub hcVH (Or.inr ((mem_support_iff_exists_getVert p2).mpr ⟨j, hj, rfl⟩))⟩
have hH_conn : H.Connected := ⟨fun a b => (hH_reach_c a).symm.trans (hH_reach_c b)⟩
-- ⟨c, hcVH⟩ is a cut vertex of H
have hc_cut_H : ¬ (H.induce ({(⟨c, hcVH⟩ : VH)}ᶜ : Set VH)).Connected := by
intro hH_c
have hreach_z : (H.induce ({(⟨c, hcVH⟩ : VH)}ᶜ : Set VH)).Reachable
⟨⟨z1.1, Or.inl hz1A⟩, fun h => z1.2 (congrArg Subtype.val h)⟩
⟨⟨z2.1, hp2_sub_VH z2.1 p2.end_mem_support⟩, fun h => z2.2 (congrArg Subtype.val h)⟩ :=
hH_c.preconnected _ _
obtain ⟨w⟩ := hreach_z
let f : (H.induce ({(⟨c, hcVH⟩ : VH)}ᶜ : Set VH)) →g Gc :=
{ toFun := fun u => ⟨u.1.1, fun h => u.2 (Subtype.ext h)⟩
map_rel' := fun hadj => hadj }
have hGc_reach : Gc.Reachable z1 z2 := ⟨w.map f⟩
have hce : C1 = C2 := by rw [← hz1_comp, ← hz2_comp]; exact ConnectedComponent.eq.mpr hGc_reach
exact hC12_ne hce
-- Helper: any walk in G starting in A and ending outside A visits c;
-- any geodesic between vertices of A stays inside A.
have hA_exit : ∀ {u v : β} (w : G.Walk u v), u ∈ A → v ∉ A →
∃ k < w.length, w.getVert k = c := by
intro u v w hu hv
-- Find minimal k ≤ w.length with w.getVert k ∉ A
have hex : ∃ k ≤ w.length, w.getVert k ∉ A := ⟨w.length, le_refl _, by simpa [w.getVert_length] using hv⟩
let k := Nat.find hex
have hk_spec : k ≤ w.length ∧ w.getVert k ∉ A := Nat.find_spec hex
have hk_pos : 1 ≤ k := by
by_contra h0
have hk0 : k = 0 := by omega
apply hk_spec.2
simpa [hk0, w.getVert_zero] using hu
have hk_prev : w.getVert (k - 1) ∈ A := by
by_contra hnot
exact Nat.find_min hex (by omega : k - 1 < k) ⟨by omega, hnot⟩
have hadj : G.Adj (w.getVert (k - 1)) (w.getVert k) := by
simpa [Nat.sub_add_cancel hk_pos] using w.adj_getVert_succ (by omega : k - 1 < w.length)
have hprev_eq_c : w.getVert (k - 1) = c := by
rcases hk_prev with h | ⟨hprev_ne, hprev_C1⟩
· exact h
· exfalso
have hk_ne : w.getVert k ≠ c := fun hc => hk_spec.2 (hc ▸ hcA)
have hcomp_eq : Gc.connectedComponentMk ⟨w.getVert k, hk_ne⟩ = C1 := by
rw [← hprev_C1]
have hadj_gc : Gc.Adj ⟨w.getVert (k - 1), hprev_ne⟩ ⟨w.getVert k, hk_ne⟩ := hadj
exact ConnectedComponent.eq.mpr hadj_gc.reachable.symm
exact hk_spec.2 (Or.inr ⟨hk_ne, hcomp_eq⟩)
exact ⟨k - 1, by omega, hprev_eq_c⟩
have hA_geod_stays : ∀ {u v : β} (w : G.Walk u v), w.length = G.dist u v →
u ∈ A → v ∈ A → ∀ z ∈ w.support, z ∈ A := by
intro u v w hw hu hv z hz
by_contra hzA
rw [mem_support_iff_exists_getVert] at hz
obtain ⟨m, hm, rfl⟩ := hz
have hm_supp : w.getVert m ∈ w.support := (mem_support_iff_exists_getVert w).mpr ⟨m, hm, rfl⟩
let w1 := w.takeUntil (w.getVert m) hm_supp
let w2 := w.dropUntil (w.getVert m) hm_supp
obtain ⟨k1, hk1_lt, hk1_c⟩ := hA_exit w1 hu hzA
obtain ⟨k2, hk2_lt, hk2_c⟩ := hA_exit w2.reverse hv hzA
have hw1_sub : w1.IsSubwalk w := ⟨.nil, w2, by simp [w1, w2, w.take_spec]⟩
have hw2_sub : w2.IsSubwalk w := ⟨w1, .nil, by simp [w1, w2, w.take_spec]⟩
have hw1_geod : w1.length = G.dist u (w.getVert m) := length_eq_dist_of_subwalk hw hw1_sub
have hw2_geod : w2.length = G.dist (w.getVert m) v := length_eq_dist_of_subwalk hw hw2_sub
have hw2r_geod : w2.reverse.length = G.dist v (w.getVert m) := by
rw [Walk.length_reverse, G.dist_comm]
exact hw2_geod
have hm_dist1 : G.dist u (w.getVert m) = m := by
simpa [w.getVert_zero] using geodesic_dist_getVert hG w hw (Nat.zero_le m) hm
have hm_dist2 : G.dist (w.getVert m) v = w.length - m := by
simpa [w.getVert_length] using geodesic_dist_getVert hG w hw hm (le_refl _)
have hw1_len : w1.length = m := by rw [hw1_geod, hm_dist1]
have hw2_len : w2.length = w.length - m := by rw [hw2_geod, hm_dist2]
have hdc1 : G.dist u c = k1 := by
simpa [hk1_c, w1.getVert_zero] using geodesic_dist_getVert hG w1 hw1_geod (Nat.zero_le k1) (by omega)
have hdc2 : G.dist v c = k2 := by
simpa [hk2_c, w2.reverse.getVert_zero] using geodesic_dist_getVert hG w2.reverse hw2r_geod (Nat.zero_le k2) (by omega)
have htri : G.dist u v ≤ G.dist u c + G.dist c v := hG.dist_triangle
rw [G.dist_comm (u := c) (v := v)] at htri
rw [Walk.length_reverse] at hk2_lt
omega
have hdist_H_A : ∀ {u v : β} (hu : u ∈ A) (hv : v ∈ A),
H.dist ⟨u, Or.inl hu⟩ ⟨v, Or.inl hv⟩ = G.dist u v := by
intro u v hu hv
apply le_antisymm
· obtain ⟨w, hw⟩ := hG.exists_walk_length_eq_dist u v
have hsub : ∀ z ∈ w.support, z ∈ VH := fun z hz => Or.inl (hA_geod_stays w hw hu hv z hz)
have h_le : H.dist ⟨u, Or.inl hu⟩ ⟨v, Or.inl hv⟩ ≤ (walkInduce w hsub (Or.inl hu) (Or.inl hv)).length :=
dist_le _
rw [walkInduce_length, hw] at h_le
exact h_le
· obtain ⟨w', hw'⟩ := hH_conn.exists_walk_length_eq_dist ⟨u, Or.inl hu⟩ ⟨v, Or.inl hv⟩
have h_le : G.dist u v ≤ (w'.map (Embedding.induce VH).toHom).length := dist_le _
rw [Walk.length_map, hw'] at h_le
exact h_le
-- Any walk in H from u ∈ A to y ∈ p2.support \ {c} hits c (and same in G from A to any w ∉ A)
have hdist_G_cross : ∀ {u w : β}, u ∈ A → w ∉ A →
G.dist u w = G.dist u c + G.dist c w := by
intro u w hu hwA
apply le_antisymm (hG.dist_triangle (v := c))
obtain ⟨q, hq⟩ := hG.exists_walk_length_eq_dist u w
obtain ⟨k, hk_lt, hk_c⟩ := hA_exit q hu hwA
have hduc : G.dist u c = k := by
simpa [hk_c, q.getVert_zero] using geodesic_dist_getVert hG q hq (Nat.zero_le k) (by omega)
have hdcw : G.dist c w = q.length - k := by
simpa [hk_c, q.getVert_length] using geodesic_dist_getVert hG q hq (Nat.le_of_lt hk_lt) (le_refl q.length)
rw [← hq, hduc, hdcw]
omega
have hdist_H_cross : ∀ {u y : β} (hu : u ∈ A) (hy : y ∈ VH) (hyA : y ∉ A),
H.dist ⟨u, Or.inl hu⟩ ⟨y, hy⟩ = G.dist u c + G.dist c y := by
intro u y hu hy hyA
have hH_le : H.dist ⟨u, Or.inl hu⟩ ⟨y, hy⟩ ≤ G.dist u c + G.dist c y := by
have htri : H.dist ⟨u, Or.inl hu⟩ ⟨y, hy⟩ ≤
H.dist ⟨u, Or.inl hu⟩ ⟨c, hcVH⟩ + H.dist ⟨c, hcVH⟩ ⟨y, hy⟩ :=
hH_conn.dist_triangle
rw [hdist_H_A hu hcA] at htri
have hcy : H.dist ⟨c, hcVH⟩ ⟨y, hy⟩ = G.dist c y := by
apply le_antisymm
· rcases hy with hyA' | hyp2
· exact absurd hyA' hyA
· obtain ⟨j, hj, rfl⟩ := (mem_support_iff_exists_getVert p2).mp hyp2
have hj_supp : p2.getVert j ∈ p2.support :=
(mem_support_iff_exists_getVert p2).mpr ⟨j, hj, rfl⟩
have hsub : ∀ z ∈ (p2.takeUntil (p2.getVert j) hj_supp).support, z ∈ VH :=
fun z hz => hp2_sub_VH z (Walk.support_takeUntil_subset_support p2 _ hz)
have h_le := dist_le (walkInduce (p2.takeUntil (p2.getVert j) hj_supp) hsub hcVH (Or.inr hj_supp))
have hj_dist : G.dist c (p2.getVert j) = j := by
simpa [p2.getVert_zero] using geodesic_dist_getVert hG p2 hp2 (Nat.zero_le j) hj
have htake_len : (p2.takeUntil (p2.getVert j) hj_supp).length = j := by
have hsubw : (p2.takeUntil (p2.getVert j) hj_supp).IsSubwalk p2 :=
⟨.nil, p2.dropUntil (p2.getVert j) hj_supp, by simp [p2.take_spec hj_supp]⟩
rw [length_eq_dist_of_subwalk hp2 hsubw, hj_dist]
rw [walkInduce_length, htake_len] at h_le
exact h_le.trans_eq hj_dist.symm
· obtain ⟨w', hw'⟩ := hH_conn.exists_walk_length_eq_dist ⟨c, hcVH⟩ ⟨y, hy⟩
have h_le : G.dist c y ≤ (w'.map (Embedding.induce VH).toHom).length := dist_le _
rw [Walk.length_map, hw'] at h_le
exact h_le
omega
have hG_le : G.dist u c + G.dist c y ≤ H.dist ⟨u, Or.inl hu⟩ ⟨y, hy⟩ := by
rw [← hdist_G_cross hu hyA]
obtain ⟨w', hw'⟩ := hH_conn.exists_walk_length_eq_dist ⟨u, Or.inl hu⟩ ⟨y, hy⟩
have h_le : G.dist u y ≤ (w'.map (Embedding.induce VH).toHom).length := dist_le _
rw [Walk.length_map, hw'] at h_le
exact h_le
omega
-- Compute ecc_H(u) = ecc_G(u) for u ∈ A, and show vertices outside A have strictly larger ecc in H and G
have hecc_H_A : ∀ {u : β} (hu : u ∈ A), computable_eccent H ⟨u, Or.inl hu⟩ = computable_eccent G u := by
intro u hu
apply le_antisymm
· unfold computable_eccent
apply Finset.sup_le
intro ⟨w, hw⟩ _
rw [← dist_eq_computable]
by_cases hwA : w ∈ A
· rw [hdist_H_A hu hwA, dist_eq_computable]
exact Finset.le_sup (f := fun z => computable_dist G u z) (Finset.mem_univ w)
· rw [hdist_H_cross hu hw hwA]
have hz2A : z2.1 ∉ A := by
rintro (h | ⟨hne, hcomp⟩)
· exact z2.2 h
· have : (⟨z2.1, hne⟩ : Vc) = z2 := Subtype.ext rfl
rw [this, hz2_comp] at hcomp
exact hC12_ne hcomp.symm
have hcw_le : G.dist c w ≤ e2 := by
by_cases hwc : w = c
· subst hwc; exact absurd hcA hwA
· have hcomp_w : Gc.connectedComponentMk ⟨w, hwc⟩ ≠ C1 := fun hc => hwA (Or.inr ⟨hwc, hc⟩)
have hle1 : G.dist c w ≤ depth (Gc.connectedComponentMk ⟨w, hwc⟩) := h_le_depth w hwc
have hle2 : depth (Gc.connectedComponentMk ⟨w, hwc⟩) ≤ e2 :=
hC2_max _ (Finset.mem_erase.mpr ⟨hcomp_w, Finset.mem_univ _⟩)
omega
have hguz2 : G.dist u z2.1 = G.dist u c + e2 := by
rw [hdist_G_cross hu hz2A, hz2_dist]
have hle_sup : G.dist u z2.1 ≤ Finset.univ.sup (fun z => computable_dist G u z) := by
rw [dist_eq_computable]
exact Finset.le_sup (f := fun z => computable_dist G u z) (Finset.mem_univ z2.1)
omega
· unfold computable_eccent
apply Finset.sup_le
intro w _
rw [← dist_eq_computable]
by_cases hwA : w ∈ A
· rw [← hdist_H_A hu hwA, dist_eq_computable]
exact Finset.le_sup (f := fun z : VH => computable_dist H ⟨u, Or.inl hu⟩ z)
(Finset.mem_univ (⟨w, Or.inl hwA⟩ : VH))
· have hz2VH : z2.1 ∈ VH := hp2_sub_VH z2.1 p2.end_mem_support
have hz2A : z2.1 ∉ A := by
rintro (h | ⟨hne, hcomp⟩)
· exact z2.2 h
· have : (⟨z2.1, hne⟩ : Vc) = z2 := Subtype.ext rfl
rw [this, hz2_comp] at hcomp
exact hC12_ne hcomp.symm
have hcw_le : G.dist c w ≤ e2 := by
by_cases hwc : w = c
· subst hwc; exact absurd hcA hwA
· have hcomp_w : Gc.connectedComponentMk ⟨w, hwc⟩ ≠ C1 := fun hc => hwA (Or.inr ⟨hwc, hc⟩)
have hle1 : G.dist c w ≤ depth (Gc.connectedComponentMk ⟨w, hwc⟩) := h_le_depth w hwc
have hle2 : depth (Gc.connectedComponentMk ⟨w, hwc⟩) ≤ e2 :=
hC2_max _ (Finset.mem_erase.mpr ⟨hcomp_w, Finset.mem_univ _⟩)
omega
rw [hdist_G_cross hu hwA]
have hHz2 : H.dist (⟨u, Or.inl hu⟩ : VH) (⟨z2.1, hz2VH⟩ : VH) = G.dist u c + e2 := by
rw [hdist_H_cross hu hz2VH hz2A, hz2_dist]
have hle_sup : H.dist (⟨u, Or.inl hu⟩ : VH) (⟨z2.1, hz2VH⟩ : VH) ≤
Finset.univ.sup (fun z : VH => computable_dist H ⟨u, Or.inl hu⟩ z) := by
rw [dist_eq_computable]
exact Finset.le_sup (f := fun z : VH => computable_dist H ⟨u, Or.inl hu⟩ z)
(Finset.mem_univ (⟨z2.1, hz2VH⟩ : VH))
omega
have hrH_eq : H.radius.toNat = r := by
have hradH : H.radius.toNat = computable_radius H := by
rw [radius_eq_computable H hH_conn]; rfl
rw [hradH, hrad_eq]
apply le_antisymm
· obtain ⟨v, _, hv_min⟩ :=
Finset.exists_min_image (Finset.univ : Finset β) (fun u => computable_eccent G u)
Finset.univ_nonempty
have hv_rad : computable_radius G = computable_eccent G v :=
le_antisymm (Finset.inf'_le _ (Finset.mem_univ v)) (Finset.le_inf' _ _ fun u hu => hv_min u hu)
have hvA : v ∈ A := by
by_contra hvnot
have hvz1 : G.dist v z1.1 = G.dist v c + e1 := by
rw [G.dist_comm, hdist_G_cross hz1A hvnot, G.dist_comm (u := z1.1) (v := c), hz1_dist, G.dist_comm (u := c) (v := v)]
dsimp only [e1]; omega
have hvc_pos : 1 ≤ G.dist v c :=
Nat.pos_of_ne_zero fun h0 => hvnot (((hG.dist_eq_zero_iff).mp h0) ▸ hcA)
have h_ecc_v : e1 + 1 ≤ computable_eccent G v := by
have hle : G.dist v z1.1 ≤ computable_eccent G v := by
rw [dist_eq_computable]
exact Finset.le_sup (f := fun z => computable_dist G v z) (Finset.mem_univ z1.1)
omega
have h_rad_le_c : computable_radius G ≤ e1 := by
rw [he1_ecc]
exact Finset.inf'_le _ (Finset.mem_univ c)
omega
have hH_le : computable_radius H ≤ computable_eccent H (⟨v, Or.inl hvA⟩ : VH) :=
Finset.inf'_le _ (Finset.mem_univ (⟨v, Or.inl hvA⟩ : VH))
rw [hecc_H_A hvA, ← hv_rad] at hH_le
exact hH_le
· obtain ⟨v', _, hv'_min⟩ :=
Finset.exists_min_image (Finset.univ : Finset VH) (fun u => computable_eccent H u)
Finset.univ_nonempty
have hv'_rad : computable_radius H = computable_eccent H v' :=
le_antisymm (Finset.inf'_le _ (Finset.mem_univ v')) (Finset.le_inf' _ _ fun u hu => hv'_min u hu)
have hv'A : v'.1 ∈ A := by
by_contra hvnot
have h_cross : H.dist (⟨z1.1, Or.inl hz1A⟩ : VH) v' = G.dist z1.1 c + G.dist c v'.1 :=
hdist_H_cross hz1A v'.2 hvnot
have hvc_pos : 1 ≤ G.dist c v'.1 :=
Nat.pos_of_ne_zero fun h0 => hvnot (((hG.dist_eq_zero_iff).mp h0).symm ▸ hcA)
have h_ecc_v' : e1 + 1 ≤ computable_eccent H v' := by
have hle : H.dist v' (⟨z1.1, Or.inl hz1A⟩ : VH) ≤ computable_eccent H v' := by
rw [dist_eq_computable]
exact Finset.le_sup (f := fun z => computable_dist H v' z) (Finset.mem_univ (⟨z1.1, Or.inl hz1A⟩ : VH))
rw [H.dist_comm, h_cross, G.dist_comm (u := z1.1) (v := c), hz1_dist] at hle
dsimp only [e1] at *
omega
have h_radH_le_c : computable_radius H ≤ e1 := by
rw [he1_ecc, ← hecc_H_A hcA]
exact Finset.inf'_le _ (Finset.mem_univ (⟨c, hcVH⟩ : VH))
omega
have hG_le : computable_radius G ≤ computable_eccent G v'.1 :=
Finset.inf'_le _ (Finset.mem_univ v'.1)
have hv'_eq : (⟨v'.1, Or.inl hv'A⟩ : VH) = v' := Subtype.ext rfl
rw [← hecc_H_A hv'A, hv'_eq, ← hv'_rad] at hG_le
exact hG_le
-- By minimality of G, Fintype.card VH = Fintype.card β, so ∀ u, u ∈ VH
have hVH_all : ∀ u : β, u ∈ VH := by
by_contra hnot
push Not at hnot
obtain ⟨u_out, hu_out⟩ := hnot
have hcard_lt : Fintype.card VH < Fintype.card β := by
have hsub : (Finset.univ.filter (fun z : β => z ∈ VH)) ⊂ Finset.univ := by
rw [Finset.ssubset_iff_of_subset (Finset.subset_univ _)]
exact ⟨u_out, Finset.mem_univ u_out, by simp [hu_out]⟩
rw [Fintype.card_subtype]
exact Finset.card_lt_card hsub
have ihH := ih H hcard_lt hH_conn (⟨c, hcVH⟩ : VH) hc_cut_H
have hmono := card_largestInducedTreeSize_induce_le G VH
have hcontra : 2 * r ≤ largestInducedTreeSize G := by
rw [← hrH_eq]
exact le_trans ihH hmono
omega
-- Conclude!
refine ⟨C1, C2, z2.1, z2.2, p2, hC12_ne, ?_, hp2, ?_, ?_, ?_, ?_⟩
· intro C
obtain ⟨u, rfl⟩ := C.exists_rep
rcases hVH_all u.1 with (hu | ⟨huc, huC1⟩) | hup2
· exact absurd hu u.2
· left
exact (congrArg Gc.connectedComponentMk (Subtype.ext rfl)).trans huC1
· right
rw [mem_support_iff_exists_getVert] at hup2
obtain ⟨j, hj, hj_eq⟩ := hup2
rcases Nat.eq_zero_or_pos j with rfl | hj1
· rw [p2.getVert_zero] at hj_eq
exact absurd hj_eq.symm u.2
· obtain ⟨hj_ne, hj_comp⟩ := hp2_comp j hj1 hj
exact (congrArg Gc.connectedComponentMk (Subtype.ext hj_eq.symm)).trans hj_comp
· omega
· omega
· exact hz2_comp
· intro u hu
constructor
· intro hcomp
rcases hVH_all u with (rfl | ⟨huc, huC1⟩) | hup2
· exact absurd rfl hu
· have h1 : Gc.connectedComponentMk ⟨u, hu⟩ = C1 :=
(congrArg Gc.connectedComponentMk (Subtype.ext rfl)).trans huC1
rw [h1] at hcomp
exact absurd hcomp hC12_ne
· exact hup2
· intro hup2
rw [mem_support_iff_exists_getVert] at hup2
obtain ⟨j, hj, hj_eq⟩ := hup2
rcases Nat.eq_zero_or_pos j with rfl | hj1
· rw [p2.getVert_zero] at hj_eq
exact absurd hj_eq.symm hu
· obtain ⟨hj_ne, hj_comp⟩ := hp2_comp j hj1 hj
exact (congrArg Gc.connectedComponentMk (Subtype.ext hj_eq.symm)).trans hj_comp
-- Stage 2: 2-connected core K and pendant path decomposition
private def IsTwoConnected {β : Type*} [DecidableEq β] (G : SimpleGraph β) (S : Finset β) : Prop :=
3 ≤ S.card ∧ ∀ x ∈ S, (G.induce ((S.erase x : Finset β) : Set β)).Connected
private lemma isTwoConnected_connected {β : Type*} [DecidableEq β]
{G : SimpleGraph β} {S : Finset β} (hS : IsTwoConnected G S) :
(G.induce (S : Set β)).Connected := by
have hS3 := hS.1
have hS_ne : S.Nonempty := Finset.card_pos.mp (by omega)
obtain ⟨x, hx⟩ := hS_ne
have hSx_card : 2 ≤ (S.erase x).card := by rw [Finset.card_erase_of_mem hx]; omega
obtain ⟨y, hy⟩ := Finset.card_pos.mp (by omega : 0 < (S.erase x).card)
have hyS : y ∈ S := Finset.mem_of_mem_erase hy
have hyx : y ≠ x := (Finset.mem_erase.mp hy).1
have hSxy_card : 1 ≤ ((S.erase x).erase y).card := by
rw [Finset.card_erase_of_mem hy]; omega
obtain ⟨z, hz⟩ := Finset.card_pos.mp hSxy_card
have hzx_mem : z ∈ S.erase x := Finset.mem_of_mem_erase hz
have hzS : z ∈ S := Finset.mem_of_mem_erase hzx_mem
have hzy : z ≠ y := (Finset.mem_erase.mp hz).1
have hzy_mem : z ∈ S.erase y := Finset.mem_erase.mpr ⟨hzy, hzS⟩
have hxy_mem : x ∈ S.erase y := Finset.mem_erase.mpr ⟨hyx.symm, hx⟩
have hconn_x := hS.2 x hx
have hconn_y := hS.2 y hyS
let f_x : G.induce ((S.erase x : Finset β) : Set β) →g G.induce (S : Set β) :=
{ toFun := fun u => ⟨u.1, Finset.mem_of_mem_erase u.2⟩
map_rel' := fun h => h }
let f_y : G.induce ((S.erase y : Finset β) : Set β) →g G.induce (S : Set β) :=
{ toFun := fun u => ⟨u.1, Finset.mem_of_mem_erase u.2⟩
map_rel' := fun h => h }
have hreach_z : ∀ u : (S : Set β), (G.induce (S : Set β)).Reachable ⟨z, hzS⟩ u := by
intro ⟨u, hu⟩
by_cases hux : u = x
· subst hux
exact (hconn_y.preconnected ⟨z, hzy_mem⟩ ⟨u, hxy_mem⟩).map f_y
· exact (hconn_x.preconnected ⟨z, hzx_mem⟩ ⟨u, Finset.mem_erase.mpr ⟨hux, hu⟩⟩).map f_x
have : Nonempty (S : Set β) := ⟨⟨z, hzS⟩⟩
exact ⟨fun a b => (hreach_z a).symm.trans (hreach_z b)⟩
private lemma isTwoConnected_two_neighbors {β : Type*} [DecidableEq β]
{G : SimpleGraph β} {S : Finset β} (hS : IsTwoConnected G S) {c : β} (hc : c ∈ S) :
∃ a b : S, a.1 ≠ c ∧ b.1 ≠ c ∧ a ≠ b ∧ G.Adj c a.1 ∧ G.Adj c b.1 := by
have hS3 := hS.1
have hSc_card : 2 ≤ (S.erase c).card := by rw [Finset.card_erase_of_mem hc]; omega
-- If there were at most 1 neighbor of c in S, erasing it (or any other vertex) isolates c.
by_contra hnot
push Not at hnot
have hex_a0 : ∃ a0 ∈ S.erase c, ∀ u ∈ S.erase c, G.Adj c u → u = a0 := by
by_cases hex1 : ∃ u ∈ S.erase c, G.Adj c u
· obtain ⟨a0, ha0_mem, ha0_adj⟩ := hex1
refine ⟨a0, ha0_mem, fun u hu_mem hu_adj => ?_⟩
by_contra hne
exact hnot ⟨a0, Finset.mem_of_mem_erase ha0_mem⟩ ⟨u, Finset.mem_of_mem_erase hu_mem⟩
(Finset.mem_erase.mp ha0_mem).1 (Finset.mem_erase.mp hu_mem).1
(fun h => hne (congrArg Subtype.val h).symm) ha0_adj hu_adj
· obtain ⟨a0, ha0_mem⟩ := Finset.card_pos.mp (by omega : 0 < (S.erase c).card)
exact ⟨a0, ha0_mem, fun u hu_mem hu_adj => absurd ⟨u, hu_mem, hu_adj⟩ hex1⟩
obtain ⟨a0, ha0_mem, ha0_uniq⟩ := hex_a0
have ha0S : a0 ∈ S := Finset.mem_of_mem_erase ha0_mem
have ha0c : a0 ≠ c := (Finset.mem_erase.mp ha0_mem).1
have hconn := hS.2 a0 ha0S
obtain ⟨b, hb⟩ := Finset.card_pos.mp (by rw [Finset.card_erase_of_mem ha0_mem]; omega : 0 < ((S.erase c).erase a0).card)
have hbc : b ≠ c := (Finset.mem_erase.mp (Finset.mem_of_mem_erase hb)).1
have hba0 : b ≠ a0 := (Finset.mem_erase.mp hb).1
have hbS : b ∈ S := Finset.mem_of_mem_erase (Finset.mem_of_mem_erase hb)
have hc_mem : c ∈ S.erase a0 := Finset.mem_erase.mpr ⟨ha0c.symm, hc⟩
have hb_mem : b ∈ S.erase a0 := Finset.mem_erase.mpr ⟨hba0, hbS⟩
obtain ⟨w⟩ := hconn.preconnected ⟨c, hc_mem⟩ ⟨b, hb_mem⟩
cases w with
| nil => exact absurd rfl hbc
| @cons _ u _ hadj _ =>
have huc : u.1 ≠ c := fun heq => hadj.ne (Subtype.ext heq.symm)
have hua0 : u.1 = a0 := ha0_uniq u.1 (Finset.mem_erase.mpr ⟨huc, Finset.mem_of_mem_erase u.2⟩) hadj
exact (Finset.mem_erase.mp u.2).1 hua0
private lemma cycle_erase_connected {β : Type*} [DecidableEq β]
{G : SimpleGraph β} {v : β} (c : G.Walk v v) (hc : c.IsCycle)
(x : β) (hx : x ∈ c.support) :
(G.induce ((c.support.toFinset.erase x : Finset β) : Set β)).Connected := by
let r := c.rotate x hx
have hr_len : 3 ≤ r.length := by rw [Walk.length_rotate]; exact hc.three_le_length
have hr_nodup : r.support.tail.Nodup :=
(Walk.support_rotate c x hx).nodup_iff.mpr hc.support_nodup
cases h_r : r with
| nil => simp [h_r] at hr_len
| @cons _ y1 _ _ rest =>
have hrest_len : 2 ≤ rest.length := by
have := congrArg Walk.length h_r
simp only [Walk.length_cons] at this
omega
have hrest_nodup : rest.support.Nodup := by
have hsup := congrArg (List.tail ∘ Walk.support) h_r
simp only [Function.comp_apply, Walk.support_cons, List.tail_cons] at hsup
rwa [hsup] at hr_nodup
have hrest_not_nil : ¬ rest.Nil := fun h => by rw [h.length_eq_zero] at hrest_len; omega
let q := rest.dropLast
have hq_supp : q.support = rest.support.dropLast := Walk.support_dropLast hrest_not_nil
have hrest_eq_app : rest.support = rest.support.dropLast ++ [x] := by
have := List.dropLast_concat_getLast (Walk.support_ne_nil rest)
rw [Walk.getLast_support] at this
exact this.symm
have hx_notin_q : x ∉ q.support := by
intro hmem
rw [hq_supp] at hmem
have hnd := hrest_nodup
rw [hrest_eq_app, List.nodup_append] at hnd
exact hnd.2.2 x hmem x (List.mem_singleton.mpr rfl) rfl
have hq_sub : ∀ z ∈ q.support, z ∈ ((c.support.toFinset.erase x : Finset β) : Set β) := by
intro z hz
have hz_ne : z ≠ x := fun heq => hx_notin_q (heq ▸ hz)
have hz_rest : z ∈ rest.support := by
rw [hq_supp] at hz
exact List.dropLast_subset _ hz
have hz_r : z ∈ r.support := by rw [h_r, Walk.support_cons]; exact List.mem_cons_of_mem _ hz_rest
have hz_c : z ∈ c.support := (Walk.mem_support_rotate_iff c x hx).mp hz_r
exact Finset.mem_coe.mpr (Finset.mem_erase.mpr ⟨hz_ne, List.mem_toFinset.mpr hz_c⟩)
have hy1_mem : y1 ∈ ((c.support.toFinset.erase x : Finset β) : Set β) :=
hq_sub y1 q.start_mem_support
have hall_in_q : ∀ z ∈ ((c.support.toFinset.erase x : Finset β) : Set β), z ∈ q.support := by
intro z hz
have hz_ne : z ≠ x := (Finset.mem_erase.mp (Finset.mem_coe.mp hz)).1
have hz_c : z ∈ c.support := List.mem_toFinset.mp (Finset.mem_of_mem_erase (Finset.mem_coe.mp hz))
have hz_ctail : z ∈ c.support.tail := by
cases h_c : c with
| nil => simp [h_c] at hc
| cons hadjc crest =>
rw [Walk.support_cons, List.tail_cons]
have hmem : z ∈ v :: crest.support := by simpa [h_c, Walk.support_cons] using hz_c
rcases List.mem_cons.mp hmem with rfl | hzc
· exact Walk.end_mem_support crest
· exact hzc
have hz_rtail : z ∈ r.support.tail := (Walk.support_rotate c x hx).mem_iff.mpr hz_ctail
have hz_rest : z ∈ rest.support := by
have hsup := congrArg (List.tail ∘ Walk.support) h_r
simp only [Function.comp_apply, Walk.support_cons, List.tail_cons] at hsup
rwa [← hsup]
rw [hrest_eq_app, List.mem_append, List.mem_singleton] at hz_rest
rcases hz_rest with hz_dl | rfl
· rwa [hq_supp]
· exact absurd rfl hz_ne
have hreach : ∀ u : ((c.support.toFinset.erase x : Finset β) : Set β),
(G.induce ((c.support.toFinset.erase x : Finset β) : Set β)).Reachable
⟨y1, hy1_mem⟩ u := by
intro ⟨z, hz⟩
have hzq := hall_in_q z hz
let qz := q.takeUntil z hzq
have hsub : ∀ w ∈ qz.support, w ∈ ((c.support.toFinset.erase x : Finset β) : Set β) :=
fun w hw => hq_sub w (Walk.support_takeUntil_subset_support q hzq hw)
exact ⟨walkInduce qz hsub hy1_mem hz⟩
have : Nonempty ((c.support.toFinset.erase x : Finset β) : Set β) := ⟨⟨y1, hy1_mem⟩⟩
exact ⟨fun a b => (hreach a).symm.trans (hreach b)⟩
private lemma exists_isTwoConnected_of_not_isTree {β : Type*} [Fintype β] [DecidableEq β]
{G : SimpleGraph β} (hG : G.Connected) (hnT : ¬ G.IsTree) :
∃ S : Finset β, IsTwoConnected G S := by
have hnA : ¬ G.IsAcyclic := fun ha => hnT ⟨hG, ha⟩
unfold IsAcyclic at hnA
push Not at hnA
obtain ⟨v, c, hc⟩ := hnA
refine ⟨c.support.toFinset, ?_, fun x hx => cycle_erase_connected c hc x (List.mem_toFinset.mp hx)⟩
have hnod : c.support.tail.Nodup := hc.support_nodup
have hlen : c.support.tail.length = c.length := by
simp only [List.length_tail, Walk.length_support, Nat.add_sub_cancel]
have hcard : c.length ≤ c.support.tail.toFinset.card := by
rw [List.toFinset_card_of_nodup hnod]
omega
have hsub : c.support.tail.toFinset ⊆ c.support.toFinset := by
intro z hz
exact List.mem_toFinset.mpr (List.tail_subset _ (List.mem_toFinset.mp hz))
have hle := Finset.card_le_card hsub
have hc3 := hc.three_le_length
omega
private lemma walk_end_mem_tail_support_of_ne {β : Type*} {G : SimpleGraph β}
{a b : β} (w : G.Walk a b) (hne : a ≠ b) : b ∈ w.support.tail := by
cases w with
| nil => exact absurd rfl hne
| cons _ r => simp [Walk.end_mem_support r]
-- Helper: connecting two distinct vertices in a component of G - K via a walk in G - K enlarges a 2-connected set
private lemma attach_path_isTwoConnected {β : Type*} [DecidableEq β]
{G : SimpleGraph β} {K : Finset β} (hK : IsTwoConnected G K)
{a b : K} (hab : a ≠ b)
{ua ub : ((K : Set β)ᶜ : Set β)} (hadj_a : G.Adj a.1 ua.1) (hadj_b : G.Adj b.1 ub.1)
(q : (G.induce ((K : Set β)ᶜ : Set β)).Walk ua ub) (hq : q.IsPath) :
IsTwoConnected G (K ∪ q.support.toFinset.image Subtype.val) := by
set Q : Finset β := q.support.toFinset.image Subtype.val
have hdisj : Disjoint K Q := by
rw [Finset.disjoint_left]
intro x hxK hxQ
simp only [Q, Finset.mem_image, List.mem_toFinset] at hxQ
obtain ⟨u, _, rfl⟩ := hxQ
exact u.2 hxK
have hKconn := isTwoConnected_connected hK
refine ⟨by have := Finset.card_union_of_disjoint hdisj; have := hK.1; omega, ?_⟩
intro x hx
by_cases hxK : x ∈ K
· -- x ∈ K: K.erase x is connected, and every vertex of Q connects to ua (adjacent to a) and ub (adjacent to b).
-- At least one of a, b is in K.erase x!
have hKex_conn := hK.2 x hxK
have hQ_sub : ∀ z ∈ q.support, z.1 ∈ (((K ∪ Q).erase x : Finset β) : Set β) := by
intro z hz
refine Finset.mem_coe.mpr (Finset.mem_erase.mpr ⟨fun heq => ?_, Finset.mem_union_right _ ?_⟩)
· exact z.2 (heq ▸ hxK)
· exact Finset.mem_image_of_mem _ (List.mem_toFinset.mpr hz)
have hua_mem : ua.1 ∈ (((K ∪ Q).erase x : Finset β) : Set β) := hQ_sub ua q.start_mem_support
have hub_mem : ub.1 ∈ (((K ∪ Q).erase x : Finset β) : Set β) := hQ_sub ub q.end_mem_support
-- Pick basepoint in K.erase x: either a or b
have hab_or : a.1 ≠ x ∨ b.1 ≠ x := by
by_cases ha : a.1 = x
· right; intro hb; exact hab (Subtype.ext (ha.trans hb.symm))
· left; exact ha
have hbase : ∃ k0 : β, ∃ hk0 : k0 ∈ (((K ∪ Q).erase x : Finset β) : Set β),
(∀ y, (hy : y ∈ K.erase x) → (G.induce (((K ∪ Q).erase x : Finset β) : Set β)).Reachable
⟨k0, hk0⟩ ⟨y, Finset.mem_coe.mpr (Finset.mem_erase.mpr ⟨(Finset.mem_erase.mp hy).1, Finset.mem_union_left _ (Finset.mem_of_mem_erase hy)⟩)⟩) ∧
(G.induce (((K ∪ Q).erase x : Finset β) : Set β)).Reachable ⟨k0, hk0⟩ ⟨ua.1, hua_mem⟩ := by
rcases hab_or with ha_ne | hb_ne
· have ha_ex : a.1 ∈ K.erase x := Finset.mem_erase.mpr ⟨ha_ne, a.2⟩
have ha_mem : a.1 ∈ (((K ∪ Q).erase x : Finset β) : Set β) :=
Finset.mem_coe.mpr (Finset.mem_erase.mpr ⟨ha_ne, Finset.mem_union_left _ a.2⟩)
let f : G.induce ((K.erase x : Finset β) : Set β) →g
G.induce (((K ∪ Q).erase x : Finset β) : Set β) :=
{ toFun := fun u => ⟨u.1, Finset.mem_coe.mpr (Finset.mem_erase.mpr
⟨(Finset.mem_erase.mp u.2).1, Finset.mem_union_left _ (Finset.mem_of_mem_erase u.2)⟩)⟩
map_rel' := fun h => h }
have hadj_a' : (G.induce (((K ∪ Q).erase x : Finset β) : Set β)).Adj ⟨a.1, ha_mem⟩ ⟨ua.1, hua_mem⟩ := hadj_a
refine ⟨a.1, ha_mem, fun y hy => (hKex_conn.preconnected ⟨a.1, ha_ex⟩ ⟨y, hy⟩).map f, Adj.reachable hadj_a'⟩
· have hb_ex : b.1 ∈ K.erase x := Finset.mem_erase.mpr ⟨hb_ne, b.2⟩
have hb_mem : b.1 ∈ (((K ∪ Q).erase x : Finset β) : Set β) :=
Finset.mem_coe.mpr (Finset.mem_erase.mpr ⟨hb_ne, Finset.mem_union_left _ b.2⟩)
let f : G.induce ((K.erase x : Finset β) : Set β) →g
G.induce (((K ∪ Q).erase x : Finset β) : Set β) :=
{ toFun := fun u => ⟨u.1, Finset.mem_coe.mpr (Finset.mem_erase.mpr
⟨(Finset.mem_erase.mp u.2).1, Finset.mem_union_left _ (Finset.mem_of_mem_erase u.2)⟩)⟩
map_rel' := fun h => h }
have hq_reach : (G.induce (((K ∪ Q).erase x : Finset β) : Set β)).Reachable
⟨ub.1, hub_mem⟩ ⟨ua.1, hua_mem⟩ := by
let qG := q.map (Embedding.induce ((K : Set β)ᶜ : Set β)).toHom
have hqG_sub : ∀ z ∈ qG.support, z ∈ (((K ∪ Q).erase x : Finset β) : Set β) := by
intro z hz
simp only [qG, Walk.support_map, List.mem_map] at hz
obtain ⟨z', hz', rfl⟩ := hz
exact hQ_sub z' hz'
exact Reachable.symm ⟨walkInduce qG hqG_sub hua_mem hub_mem⟩
have hadj_b' : (G.induce (((K ∪ Q).erase x : Finset β) : Set β)).Adj ⟨b.1, hb_mem⟩ ⟨ub.1, hub_mem⟩ := hadj_b
refine ⟨b.1, hb_mem, fun y hy => (hKex_conn.preconnected ⟨b.1, hb_ex⟩ ⟨y, hy⟩).map f,
(Adj.reachable hadj_b').trans hq_reach⟩
obtain ⟨k0, hk0, hreach_K, hreach_ua⟩ := hbase
have hreach_all : ∀ u : (((K ∪ Q).erase x : Finset β) : Set β),
(G.induce (((K ∪ Q).erase x : Finset β) : Set β)).Reachable ⟨k0, hk0⟩ u := by
intro ⟨u, hu⟩
have hu' : u ∈ (K ∪ Q).erase x := Finset.mem_coe.mp hu
have hu_ne : u ≠ x := (Finset.mem_erase.mp hu').1
rcases Finset.mem_union.mp (Finset.mem_of_mem_erase hu') with huK | huQ
· exact hreach_K u (Finset.mem_erase.mpr ⟨hu_ne, huK⟩)
· simp only [Q, Finset.mem_image, List.mem_toFinset] at huQ
obtain ⟨u', hu'q, rfl⟩ := huQ
let qG := q.map (Embedding.induce ((K : Set β)ᶜ : Set β)).toHom
have hu'G : u'.1 ∈ qG.support := by
simp only [qG, Walk.support_map, List.mem_map]
exact ⟨u', hu'q, rfl⟩
have hsub : ∀ z ∈ (qG.takeUntil u'.1 hu'G).support,
z ∈ (((K ∪ Q).erase x : Finset β) : Set β) := by
intro z hz
have hzG := Walk.support_takeUntil_subset_support qG hu'G hz
simp only [qG, Walk.support_map, List.mem_map] at hzG
obtain ⟨z', hz', rfl⟩ := hzG
exact hQ_sub z' hz'
have hua_u : (G.induce (((K ∪ Q).erase x : Finset β) : Set β)).Reachable
⟨ua.1, hua_mem⟩ ⟨u'.1, hu⟩ :=
⟨walkInduce (qG.takeUntil u'.1 hu'G) hsub hua_mem hu⟩
exact hreach_ua.trans hua_u
have : Nonempty (((K ∪ Q).erase x : Finset β) : Set β) := ⟨⟨k0, hk0⟩⟩
exact ⟨fun u v => (hreach_all u).symm.trans (hreach_all v)⟩
· -- x ∈ Q \ K
have hxQ : x ∈ Q := (Finset.mem_union.mp hx).resolve_left hxK
simp only [Q, Finset.mem_image, List.mem_toFinset] at hxQ
obtain ⟨x', hx'q, rfl⟩ := hxQ
let qG := q.map (Embedding.induce ((K : Set β)ᶜ : Set β)).toHom
have hqG_nodup : qG.support.Nodup := by
simp only [qG, Walk.support_map]
exact hq.support_nodup.map Subtype.val_injective
have hxG : x'.1 ∈ qG.support := by
simp only [qG, Walk.support_map, List.mem_map]
exact ⟨x', hx'q, rfl⟩
have ha_mem : a.1 ∈ (((K ∪ Q).erase x'.1 : Finset β) : Set β) :=
Finset.mem_coe.mpr (Finset.mem_erase.mpr ⟨fun h => x'.2 (h ▸ a.2), Finset.mem_union_left _ a.2⟩)
have hb_mem : b.1 ∈ (((K ∪ Q).erase x'.1 : Finset β) : Set β) :=
Finset.mem_coe.mpr (Finset.mem_erase.mpr ⟨fun h => x'.2 (h ▸ b.2), Finset.mem_union_left _ b.2⟩)
let fK : G.induce (K : Set β) →g G.induce (((K ∪ Q).erase x'.1 : Finset β) : Set β) :=
{ toFun := fun u => ⟨u.1, Finset.mem_coe.mpr (Finset.mem_erase.mpr
⟨fun h => x'.2 (h ▸ u.2), Finset.mem_union_left _ u.2⟩)⟩
map_rel' := fun h => h }
have hreach_a : ∀ u : (((K ∪ Q).erase x'.1 : Finset β) : Set β),
(G.induce (((K ∪ Q).erase x'.1 : Finset β) : Set β)).Reachable ⟨a.1, ha_mem⟩ u := by
intro ⟨u, hu⟩
have hu' := Finset.mem_coe.mp hu
have hu_ne : u ≠ x'.1 := (Finset.mem_erase.mp hu').1
rcases Finset.mem_union.mp (Finset.mem_of_mem_erase hu') with huK | huQ
· exact (hKconn.preconnected a ⟨u, huK⟩).map fK
· simp only [Q, Finset.mem_image, List.mem_toFinset] at huQ
obtain ⟨u', hu'q, rfl⟩ := huQ
have hu'G : u'.1 ∈ qG.support := by
simp only [qG, Walk.support_map, List.mem_map]
exact ⟨u', hu'q, rfl⟩
have h_app : qG.support = (qG.takeUntil x'.1 hxG).support ++ (qG.dropUntil x'.1 hxG).support.tail := by
have := congrArg Walk.support (qG.take_spec hxG)
rw [Walk.support_append] at this
exact this.symm
have hu_split : u'.1 ∈ (qG.takeUntil x'.1 hxG).support ∨ u'.1 ∈ (qG.dropUntil x'.1 hxG).support := by
have hu_in := h_app ▸ hu'G
rw [List.mem_append] at hu_in
rcases hu_in with h1 | h2
· exact Or.inl h1
· exact Or.inr (List.tail_subset _ h2)
have hqG_elem_mem : ∀ z ∈ qG.support, z ≠ x'.1 → z ∈ (((K ∪ Q).erase x'.1 : Finset β) : Set β) := by
intro z hz hzx
refine Finset.mem_coe.mpr (Finset.mem_erase.mpr ⟨hzx, Finset.mem_union_right _ ?_⟩)
simp only [qG, Walk.support_map, List.mem_map] at hz
obtain ⟨z', hz', rfl⟩ := hz
exact Finset.mem_image_of_mem _ (List.mem_toFinset.mpr hz')
have hqG_path : qG.IsPath := by rw [Walk.isPath_def]; exact hqG_nodup
rcases hu_split with hu_left | hu_right
· let p1 := qG.takeUntil x'.1 hxG
let p1' := p1.takeUntil u'.1 hu_left
have hx_not_p1' : x'.1 ∉ p1'.support := by
have hp1_nod : p1.support.Nodup := (hqG_path.takeUntil hxG).support_nodup
intro hx_in
have h_spec := congrArg Walk.support (p1.take_spec hu_left)
rw [Walk.support_append] at h_spec
have hx_tail : x'.1 ∈ (p1.dropUntil u'.1 hu_left).support.tail :=
walk_end_mem_tail_support_of_ne (p1.dropUntil u'.1 hu_left) hu_ne
have hnd := hp1_nod
rw [← h_spec, List.nodup_append] at hnd
exact hnd.2.2 x'.1 hx_in x'.1 hx_tail rfl
have hp1'_sub : ∀ z ∈ p1'.support, z ∈ (((K ∪ Q).erase x'.1 : Finset β) : Set β) := by
intro z hz
have hzp1 : z ∈ p1.support := Walk.support_takeUntil_subset_support p1 hu_left hz
have hzq : z ∈ qG.support := Walk.support_takeUntil_subset_support qG hxG hzp1
exact hqG_elem_mem z hzq (fun heq => hx_not_p1' (heq ▸ hz))
have hua_mem' : ua.1 ∈ (((K ∪ Q).erase x'.1 : Finset β) : Set β) :=
hp1'_sub ua.1 p1'.start_mem_support
have hadj_a' : (G.induce (((K ∪ Q).erase x'.1 : Finset β) : Set β)).Adj
⟨a.1, ha_mem⟩ ⟨ua.1, hua_mem'⟩ := hadj_a
have ha_ua : (G.induce (((K ∪ Q).erase x'.1 : Finset β) : Set β)).Reachable
⟨a.1, ha_mem⟩ ⟨ua.1, hua_mem'⟩ := Adj.reachable hadj_a'
have hua_u : (G.induce (((K ∪ Q).erase x'.1 : Finset β) : Set β)).Reachable
⟨ua.1, hua_mem'⟩ ⟨u'.1, hu⟩ := ⟨walkInduce p1' hp1'_sub hua_mem' hu⟩
exact ha_ua.trans hua_u
· let p2 := qG.dropUntil x'.1 hxG
let p2' := p2.dropUntil u'.1 hu_right
have hx_not_p2' : x'.1 ∉ p2'.support := by
have hp2_nod : p2.support.Nodup := (hqG_path.dropUntil hxG).support_nodup
intro hx_in
have h_spec := congrArg Walk.support (p2.take_spec hu_right)
rw [Walk.support_append] at h_spec
have hx_take : x'.1 ∈ (p2.takeUntil u'.1 hu_right).support :=
Walk.start_mem_support (p2.takeUntil u'.1 hu_right)
rcases List.mem_cons.mp (by rw [← Walk.cons_tail_support] at hx_in; exact hx_in) with heq | hx_tail
· exact hu_ne heq.symm
· have hnd := hp2_nod
rw [← h_spec, List.nodup_append] at hnd
exact hnd.2.2 x'.1 hx_take x'.1 hx_tail rfl
have hp2'_sub : ∀ z ∈ p2'.support, z ∈ (((K ∪ Q).erase x'.1 : Finset β) : Set β) := by
intro z hz
have hzp2 : z ∈ p2.support := Walk.support_dropUntil_subset_support p2 hu_right hz
have hzq : z ∈ qG.support := Walk.support_dropUntil_subset_support qG hxG hzp2
exact hqG_elem_mem z hzq (fun heq => hx_not_p2' (heq ▸ hz))
have hub_mem' : ub.1 ∈ (((K ∪ Q).erase x'.1 : Finset β) : Set β) :=
hp2'_sub ub.1 p2'.end_mem_support
have ha_b : (G.induce (((K ∪ Q).erase x'.1 : Finset β) : Set β)).Reachable
⟨a.1, ha_mem⟩ ⟨b.1, hb_mem⟩ := (hKconn.preconnected a b).map fK
have hadj_b' : (G.induce (((K ∪ Q).erase x'.1 : Finset β) : Set β)).Adj
⟨b.1, hb_mem⟩ ⟨ub.1, hub_mem'⟩ := hadj_b
have hb_ub : (G.induce (((K ∪ Q).erase x'.1 : Finset β) : Set β)).Reachable
⟨b.1, hb_mem⟩ ⟨ub.1, hub_mem'⟩ := Adj.reachable hadj_b'
have hu_ub : (G.induce (((K ∪ Q).erase x'.1 : Finset β) : Set β)).Reachable
⟨u'.1, hu⟩ ⟨ub.1, hub_mem'⟩ := ⟨walkInduce p2' hp2'_sub hu hub_mem'⟩
exact (ha_b.trans hb_ub).trans hu_ub.symm
have : Nonempty (((K ∪ Q).erase x'.1 : Finset β) : Set β) := ⟨⟨a.1, ha_mem⟩⟩
exact ⟨fun u v => (hreach_a u).symm.trans (hreach_a v)⟩
private lemma walk_reach_induce_prefix {β : Type*} {G : SimpleGraph β} {V : Set β}
{a b : β} (w : G.Walk a b) (m : ℕ) (hm : m ≤ w.length)
(hV : ∀ j ≤ m, w.getVert j ∈ V) :
(G.induce V).Reachable ⟨w.getVert 0, hV 0 (Nat.zero_le _)⟩ ⟨w.getVert m, hV m (le_refl _)⟩ := by
induction m with
| zero => exact Reachable.refl _
| succ m ih =>
have hV' : ∀ j ≤ m, w.getVert j ∈ V := fun j hj => hV j (by omega)
have ih' := ih (by omega) hV'
have hadj : (G.induce V).Adj ⟨w.getVert m, hV m (by omega)⟩ ⟨w.getVert (m + 1), hV (m + 1) (le_refl _)⟩ :=
w.adj_getVert_succ (by omega)
exact ih'.trans (Adj.reachable hadj)
private lemma core_pendant_decomposition {β : Type u} [Fintype β] [DecidableEq β] [Nonempty β]
(G : SimpleGraph β) [DecidableRel G.Adj] (hG : G.Connected)
(hlt : largestInducedTreeSize G < 2 * G.radius.toNat)
(ih : ∀ {γ : Type u} [Fintype γ] [DecidableEq γ] [Nonempty γ]
(H : SimpleGraph γ) [DecidableRel H.Adj],
Fintype.card γ < Fintype.card β → H.Connected →
∀ v : γ, ¬ (H.induce ({v}ᶜ : Set γ)).Connected →
2 * H.radius.toNat ≤ largestInducedTreeSize H)
(v0 : β) (hv0 : ¬ (G.induce ({v0}ᶜ : Set β)).Connected) :
∃ (K : Finset β) (_hK : IsTwoConnected G K)
(t : K → ℕ) (endpt : K → β) (P : ∀ y : K, G.Walk y.1 (endpt y)),
(∀ y : K, (P y).length = t y ∧ (P y).length = G.dist y.1 (endpt y)) ∧
(∃ y0 : K, 1 ≤ t y0) ∧
(∀ y : K, ∀ m, 1 ≤ m → m ≤ t y → (P y).getVert m ∉ K) ∧
(∀ y1 y2 : K, ∀ m1 m2, 1 ≤ m1 → m1 ≤ t y1 → 1 ≤ m2 → m2 ≤ t y2 →
(P y1).getVert m1 = (P y2).getVert m2 → y1 = y2 ∧ m1 = m2) ∧
(∀ u : β, u ∈ K ∨ ∃ y : K, ∃ m, 1 ≤ m ∧ m ≤ t y ∧ u = (P y).getVert m) ∧
(∀ y : K, ∀ m, 1 ≤ m → m ≤ t y → ∀ z : β, G.Adj ((P y).getVert m) z → z ∈ (P y).support) ∧
(∀ u y : K, ∀ m ≤ t y, G.dist u.1 ((P y).getVert m) = (G.induce (K : Set β)).dist u y + m) ∧
(∀ u : K, computable_eccent G u.1 = Finset.univ.sup (fun y : K => (G.induce (K : Set β)).dist u y + t y)) ∧
(∀ y : K, 1 ≤ t y → t y + 2 ≤ computable_eccent G y.1) := by
classical
have hnT : ¬ G.IsTree := fun hT => by
have hcard := tree_two_mul_radius_le_card G hT
have huniv : (G.induce ((Finset.univ : Finset β) : Set β)).IsTree := by
have e : (G.induce ((Finset.univ : Finset β) : Set β)) ≃g G :=
{ toFun := fun x => x.1
invFun := fun x => ⟨x, Finset.mem_coe.mpr (Finset.mem_univ x)⟩
left_inv := fun _ => Subtype.ext rfl
right_inv := fun _ => rfl
map_rel_iff' := Iff.rfl }
exact e.isTree_iff.mpr hT
have hle := card_le_largestInducedTreeSize huniv
rw [Finset.card_univ] at hle
omega
have h2c_ne : (Finset.univ.filter (fun S : Finset β => IsTwoConnected G S)).Nonempty := by
obtain ⟨S, hS⟩ := exists_isTwoConnected_of_not_isTree hG hnT
exact ⟨S, Finset.mem_filter.mpr ⟨Finset.mem_univ S, hS⟩⟩
obtain ⟨K, hK_mem, hK_max⟩ :=
Finset.exists_max_image _ Finset.card h2c_ne
have hK : IsTwoConnected G K := (Finset.mem_filter.mp hK_mem).2
have hK_conn : (G.induce (K : Set β)).Connected := isTwoConnected_connected hK
have hK_ne : K.Nonempty := Finset.card_pos.mp (by have := hK.1; omega : 0 < K.card)
have hK_ssub : K ≠ Finset.univ := by
intro heq
apply hv0
let e : G.induce ({v0}ᶜ : Set β) ≃g G.induce ((K.erase v0 : Finset β) : Set β) :=
{ toFun := fun ⟨x, hx⟩ => ⟨x, Finset.mem_coe.mpr (Finset.mem_erase.mpr ⟨hx, by rw [heq]; exact Finset.mem_univ _⟩)⟩
invFun := fun ⟨x, hx⟩ => ⟨x, (Finset.mem_erase.mp (Finset.mem_coe.mp hx)).1⟩
left_inv := fun _ => Subtype.ext rfl
right_inv := fun _ => Subtype.ext rfl
map_rel_iff' := Iff.rfl }
have hKc := hK.2 v0 (by rw [heq]; exact Finset.mem_univ _)
obtain ⟨w_ex⟩ := hKc.nonempty
have : Nonempty ({v0}ᶜ : Set β) := ⟨e.symm w_ex⟩
exact ⟨fun a b => (hKc.preconnected (e a) (e b)).map e.symm.toHom⟩
have hex_out : ∃ u0 : β, u0 ∉ K := by
by_contra h
push Not at h
exact hK_ssub (Finset.eq_univ_iff_forall.mpr h)
let VKc : Set β := (K : Set β)ᶜ
let GKc : SimpleGraph VKc := G.induce VKc
have : Nonempty VKc := ⟨⟨hex_out.choose, hex_out.choose_spec⟩⟩
-- Unique attachment: two vertices in the same component of G - K cannot attach to distinct vertices of K
have h_uniq_att : ∀ {u1 u2 : VKc}, GKc.Reachable u1 u2 →
∀ {a1 a2 : K}, G.Adj a1.1 u1.1 → G.Adj a2.1 u2.1 → a1 = a2 := by
intro u1 u2 hreach a1 a2 hadj1 hadj2
by_contra hne
obtain ⟨q, hqp, _⟩ := hreach.exists_path_of_dist
have hK' := attach_path_isTwoConnected hK hne hadj1 hadj2 q hqp
have hle := hK_max _ (Finset.mem_filter.mpr ⟨Finset.mem_univ _, hK'⟩)
have h_card : K.card < (K ∪ q.support.toFinset.image Subtype.val).card := by
apply Finset.card_lt_card
rw [Finset.ssubset_iff_of_subset Finset.subset_union_left]
exact ⟨u1.1, Finset.mem_union_right _ (Finset.mem_image_of_mem _ (List.mem_toFinset.mpr q.start_mem_support)), u1.2⟩
omega
-- Every component of G - K has an attachment in K
have h_has_att : ∀ u : VKc, ∃ (c : K) (u_att : VKc), GKc.Reachable u u_att ∧ G.Adj c.1 u_att.1 := by
intro u
obtain ⟨k0, hk0⟩ := hK_ne
obtain ⟨w⟩ := hG.preconnected u.1 k0
have hex : ∃ m ≤ w.length, w.getVert m ∈ K :=
⟨w.length, le_refl _, by simpa [w.getVert_length] using hk0⟩
set m := Nat.find hex
have hm_spec : m ≤ w.length ∧ w.getVert m ∈ K := Nat.find_spec hex
have hm_pos : 1 ≤ m := by
by_contra h0
have hm0 : m = 0 := by omega
rw [hm0, w.getVert_zero] at hm_spec
exact u.2 hm_spec.2
have hprev_out : w.getVert (m - 1) ∉ K :=
fun h => Nat.find_min hex (m := m - 1) (by omega) ⟨by omega, h⟩
have hadj : G.Adj (w.getVert m) (w.getVert (m - 1)) := by
simpa [Nat.sub_add_cancel hm_pos] using (w.adj_getVert_succ (by omega : m - 1 < w.length)).symm
have hpre_out : ∀ j ≤ m - 1, w.getVert j ∈ VKc := by
intro j hj hjK
exact Nat.find_min hex (m := j) (by omega) ⟨by omega, hjK⟩
have hreach := walk_reach_induce_prefix w (m - 1) (by omega) hpre_out
have hu0 : (⟨w.getVert 0, hpre_out 0 (Nat.zero_le _)⟩ : VKc) = u := by
apply Subtype.ext
exact w.getVert_zero
rw [hu0] at hreach
exact ⟨⟨w.getVert m, hm_spec.2⟩, ⟨w.getVert (m - 1), hpre_out (m - 1) (le_refl _)⟩, hreach, hadj⟩
-- For any c ∈ K and u0 ∈ VKc with G.Adj c.1 u0.1, c.1 is a cut vertex and its pendant path equals the GKc-component of u0.
have h_att_pendant : ∀ (c : K) (u0 : VKc), G.Adj c.1 u0.1 →
∃ (z2 : β) (p2 : G.Walk c.1 z2),
p2.length = G.dist c.1 z2 ∧ 1 ≤ p2.length ∧
p2.length + 2 ≤ computable_eccent G c.1 ∧
(∀ b ∈ p2.support, b ≠ c.1 → b ∉ K) ∧
(∀ b ∈ p2.support, (hb : b ≠ c.1) → ∃ hbK : b ∉ K, GKc.Reachable u0 ⟨b, hbK⟩) ∧
(∀ w : β, (hw : w ∉ K) → GKc.Reachable u0 ⟨w, hw⟩ → w ∈ p2.support) ∧
(∀ b ∈ p2.support, b ≠ c.1 → ∀ z : β, G.Adj b z → z ∈ p2.support) ∧
(∀ v_out : VKc, G.Adj c.1 v_out.1 → v_out.1 ∈ p2.support) := by
intro c u0 hadj_cu0
have hc_cut : ¬ (G.induce ({c.1}ᶜ : Set β)).Connected := by
intro hc_conn
obtain ⟨a, _, ha_ne, _, _, _, _⟩ := isTwoConnected_two_neighbors hK c.2
have hreach_c : (G.induce ({c.1}ᶜ : Set β)).Reachable
⟨u0.1, fun h => u0.2 (h ▸ c.2)⟩ ⟨a.1, ha_ne⟩ :=
hc_conn.preconnected _ _
obtain ⟨wc⟩ := hreach_c
let wcG := wc.map (Embedding.induce ({c.1}ᶜ : Set β)).toHom
have hex : ∃ m ≤ wcG.length, wcG.getVert m ∈ K :=
⟨wcG.length, le_refl _, by rw [wcG.getVert_length]; exact a.2⟩
set m := Nat.find hex
have hm_spec : m ≤ wcG.length ∧ wcG.getVert m ∈ K := Nat.find_spec hex
have hm_pos : 1 ≤ m := by
by_contra h0
have hm0 : m = 0 := by omega
rw [hm0, Walk.getVert_zero] at hm_spec
exact u0.2 hm_spec.2
have hpre_out : ∀ j ≤ m - 1, wcG.getVert j ∈ VKc := fun j hj hjK =>
Nat.find_min hex (m := j) (by omega) ⟨by omega, hjK⟩
have hreach_u := walk_reach_induce_prefix wcG (m - 1) (by omega) hpre_out
have h0_eq : (⟨wcG.getVert 0, hpre_out 0 (Nat.zero_le _)⟩ : VKc) = u0 := by
apply Subtype.ext; exact wcG.getVert_zero
rw [h0_eq] at hreach_u
have hadj_m : G.Adj (wcG.getVert m) (wcG.getVert (m - 1)) := by
simpa [Nat.sub_add_cancel hm_pos] using (wcG.adj_getVert_succ (by omega : m - 1 < wcG.length)).symm
have hm_ne_c : wcG.getVert m ≠ c.1 := by
have hmem : wcG.getVert m ∈ wcG.support := (mem_support_iff_exists_getVert wcG).mpr ⟨m, hm_spec.1, rfl⟩
simp only [wcG, Walk.support_map, List.mem_map] at hmem
obtain ⟨x', _, hx'eq⟩ := hmem
rw [← hx'eq]
exact x'.2
have hc_eq := h_uniq_att hreach_u (a1 := c) (a2 := ⟨wcG.getVert m, hm_spec.2⟩) hadj_cu0 hadj_m
exact hm_ne_c (congrArg Subtype.val hc_eq).symm
obtain ⟨C1, C2, z2, hz2, p2, hC12, hcomps, hp2_len, hp2_1, hp2_e1, hz2_comp, hC2_iff⟩ :=
cutVertex_pendant_structure G hG hlt ih c.1 hc_cut
let Gc := G.induce ({c.1}ᶜ : Set β)
-- All vertices of K.erase c.1 lie in C1
have hK_in_C1 : ∀ k : K, (hk : k.1 ≠ c.1) → Gc.connectedComponentMk ⟨k.1, hk⟩ = C1 := by
have hKc_conn := hK.2 c.1 c.2
obtain ⟨a, b, ha_ne, hb_ne, hab_ne, hadj_a, hadj_b⟩ := isTwoConnected_two_neighbors hK c.2
let fK : G.induce ((K.erase c.1 : Finset β) : Set β) →g Gc :=
{ toFun := fun u => ⟨u.1, (Finset.mem_erase.mp (Finset.mem_coe.mp u.2)).1⟩
map_rel' := fun h => h }
have h_same (k : K) (hk : k.1 ≠ c.1) :
Gc.connectedComponentMk ⟨k.1, hk⟩ = Gc.connectedComponentMk ⟨a.1, ha_ne⟩ := by
have hk_mem : k.1 ∈ K.erase c.1 := Finset.mem_erase.mpr ⟨hk, k.2⟩
have ha_mem : a.1 ∈ K.erase c.1 := Finset.mem_erase.mpr ⟨ha_ne, a.2⟩
exact ConnectedComponent.eq.mpr ((hKc_conn.preconnected ⟨k.1, hk_mem⟩ ⟨a.1, ha_mem⟩).map fK)
have h_not_C2 : Gc.connectedComponentMk ⟨a.1, ha_ne⟩ ≠ C2 := by
intro h_C2
have ha_p2 : a.1 ∈ p2.support := (hC2_iff a.1 ha_ne).mp h_C2
have hb_C2 : Gc.connectedComponentMk ⟨b.1, hb_ne⟩ = C2 := (h_same b hb_ne).trans h_C2
have hb_p2 : b.1 ∈ p2.support := (hC2_iff b.1 hb_ne).mp hb_C2
obtain ⟨ia, hia, hia_eq⟩ := (mem_support_iff_exists_getVert p2).mp ha_p2
obtain ⟨ib, hib, hib_eq⟩ := (mem_support_iff_exists_getVert p2).mp hb_p2
have hda : G.dist c.1 a.1 = ia := by
simpa [hia_eq, p2.getVert_zero] using geodesic_dist_getVert hG p2 hp2_len (Nat.zero_le ia) hia
have hdb : G.dist c.1 b.1 = ib := by
simpa [hib_eq, p2.getVert_zero] using geodesic_dist_getVert hG p2 hp2_len (Nat.zero_le ib) hib
have hd1a : G.dist c.1 a.1 = 1 := dist_eq_one_iff_adj.mpr hadj_a
have hd1b : G.dist c.1 b.1 = 1 := dist_eq_one_iff_adj.mpr hadj_b
have hia1 : ia = 1 := by omega
have hib1 : ib = 1 := by omega
have haeq : a.1 = b.1 := by rw [← hia_eq, ← hib_eq, hia1, hib1]
exact hab_ne (Subtype.ext haeq)
have h_is_C1 : Gc.connectedComponentMk ⟨a.1, ha_ne⟩ = C1 := by
rcases hcomps (Gc.connectedComponentMk ⟨a.1, ha_ne⟩) with h | h
· exact h
· exact absurd h h_not_C2
intro k hk
exact (h_same k hk).trans h_is_C1
-- u0 is in C2 (cannot be in C1 since u0 only attaches to c)
have hu0_ne_c : u0.1 ≠ c.1 := fun h => u0.2 (h ▸ c.2)
have hu0_C2 : Gc.connectedComponentMk ⟨u0.1, hu0_ne_c⟩ = C2 := by
have h_not_C1 : Gc.connectedComponentMk ⟨u0.1, hu0_ne_c⟩ ≠ C1 := by
intro h_C1
obtain ⟨a, _, ha_ne, _, _, _, _⟩ := isTwoConnected_two_neighbors hK c.2
have ha_C1 := hK_in_C1 a ha_ne
have hreach_a : Gc.Reachable ⟨u0.1, hu0_ne_c⟩ ⟨a.1, ha_ne⟩ :=
ConnectedComponent.eq.mp (h_C1.trans ha_C1.symm)
obtain ⟨wc⟩ := hreach_a
let wcG := wc.map (Embedding.induce ({c.1}ᶜ : Set β)).toHom
have hex : ∃ m ≤ wcG.length, wcG.getVert m ∈ K :=
⟨wcG.length, le_refl _, by rw [wcG.getVert_length]; exact a.2⟩
set m := Nat.find hex
have hm_spec : m ≤ wcG.length ∧ wcG.getVert m ∈ K := Nat.find_spec hex
have hm_pos : 1 ≤ m := by
by_contra h0; have hm0 : m = 0 := by omega
rw [hm0, Walk.getVert_zero] at hm_spec
exact u0.2 hm_spec.2
have hpre_out : ∀ j ≤ m - 1, wcG.getVert j ∈ VKc := fun j hj hjK =>
Nat.find_min hex (m := j) (by omega) ⟨by omega, hjK⟩
have hreach_u := walk_reach_induce_prefix wcG (m - 1) (by omega) hpre_out
have h0_eq : (⟨wcG.getVert 0, hpre_out 0 (Nat.zero_le _)⟩ : VKc) = u0 := by
apply Subtype.ext; exact wcG.getVert_zero
rw [h0_eq] at hreach_u
have hadj_m : G.Adj (wcG.getVert m) (wcG.getVert (m - 1)) := by
simpa [Nat.sub_add_cancel hm_pos] using (wcG.adj_getVert_succ (by omega : m - 1 < wcG.length)).symm
have hm_ne_c : wcG.getVert m ≠ c.1 := by
have hmem : wcG.getVert m ∈ wcG.support := (mem_support_iff_exists_getVert wcG).mpr ⟨m, hm_spec.1, rfl⟩
simp only [wcG, Walk.support_map, List.mem_map] at hmem
obtain ⟨x', _, hx'eq⟩ := hmem
rw [← hx'eq]
exact x'.2
exact hm_ne_c (congrArg Subtype.val (h_uniq_att hreach_u (a1 := c) (a2 := ⟨wcG.getVert m, hm_spec.2⟩) hadj_cu0 hadj_m)).symm
rcases hcomps (Gc.connectedComponentMk ⟨u0.1, hu0_ne_c⟩) with h | h
· exact absurd h h_not_C1
· exact h
have hu0_p2 : u0.1 ∈ p2.support := (hC2_iff u0.1 hu0_ne_c).mp hu0_C2
have hu0_eq_p2_1 : u0.1 = p2.getVert 1 := by
obtain ⟨j, hj, hj_eq⟩ := (mem_support_iff_exists_getVert p2).mp hu0_p2
have hdj : G.dist c.1 u0.1 = j := by
simpa [hj_eq, p2.getVert_zero] using geodesic_dist_getVert hG p2 hp2_len (Nat.zero_le j) hj
have hd1 : G.dist c.1 u0.1 = 1 := dist_eq_one_iff_adj.mpr hadj_cu0
have hj1 : j = 1 := by omega
rw [← hj_eq, hj1]
have hp2_not_K : ∀ b ∈ p2.support, b ≠ c.1 → b ∉ K := by
intro b hb hbc hbK
have hb_C1 := hK_in_C1 ⟨b, hbK⟩ hbc
have hb_C2 := (hC2_iff b hbc).mpr hb
exact hC12 (hb_C1.symm.trans hb_C2)
-- Any v_out : VKc adjacent to c.1 is in C2 (same argument as for u0)
have hvout_p2 : ∀ v_out : VKc, G.Adj c.1 v_out.1 → v_out.1 ∈ p2.support := by
intro v_out hvout_adj
have hv_ne_c : v_out.1 ≠ c.1 := fun h => v_out.2 (h ▸ c.2)
have h_not_C1 : Gc.connectedComponentMk ⟨v_out.1, hv_ne_c⟩ ≠ C1 := by
intro h_C1
obtain ⟨a, _, ha_ne, _, _, _, _⟩ := isTwoConnected_two_neighbors hK c.2
have ha_C1 := hK_in_C1 a ha_ne
have hreach_a : Gc.Reachable ⟨v_out.1, hv_ne_c⟩ ⟨a.1, ha_ne⟩ :=
ConnectedComponent.eq.mp (h_C1.trans ha_C1.symm)
obtain ⟨wc⟩ := hreach_a
let wcG := wc.map (Embedding.induce ({c.1}ᶜ : Set β)).toHom
have hex : ∃ m ≤ wcG.length, wcG.getVert m ∈ K :=
⟨wcG.length, le_refl _, by rw [wcG.getVert_length]; exact a.2⟩
set m := Nat.find hex
have hm_spec : m ≤ wcG.length ∧ wcG.getVert m ∈ K := Nat.find_spec hex
have hm_pos : 1 ≤ m := by
by_contra h0; have hm0 : m = 0 := by omega
rw [hm0, Walk.getVert_zero] at hm_spec
exact v_out.2 hm_spec.2
have hpre_out : ∀ j ≤ m - 1, wcG.getVert j ∈ VKc := fun j hj hjK =>
Nat.find_min hex (m := j) (by omega) ⟨by omega, hjK⟩
have hreach_u := walk_reach_induce_prefix wcG (m - 1) (by omega) hpre_out
have h0_eq : (⟨wcG.getVert 0, hpre_out 0 (Nat.zero_le _)⟩ : VKc) = v_out := by
apply Subtype.ext; exact wcG.getVert_zero
rw [h0_eq] at hreach_u
have hadj_m : G.Adj (wcG.getVert m) (wcG.getVert (m - 1)) := by
simpa [Nat.sub_add_cancel hm_pos] using (wcG.adj_getVert_succ (by omega : m - 1 < wcG.length)).symm
have hm_ne_c : wcG.getVert m ≠ c.1 := by
have hmem : wcG.getVert m ∈ wcG.support := (mem_support_iff_exists_getVert wcG).mpr ⟨m, hm_spec.1, rfl⟩
simp only [wcG, Walk.support_map, List.mem_map] at hmem
obtain ⟨x', _, hx'eq⟩ := hmem
rw [← hx'eq]
exact x'.2
exact hm_ne_c (congrArg Subtype.val (h_uniq_att hreach_u (a1 := c) (a2 := ⟨wcG.getVert m, hm_spec.2⟩) hvout_adj hadj_m)).symm
rcases hcomps (Gc.connectedComponentMk ⟨v_out.1, hv_ne_c⟩) with h | h
· exact absurd h h_not_C1
· exact (hC2_iff v_out.1 hv_ne_c).mp h
refine ⟨z2, p2, hp2_len, hp2_1, hp2_e1, hp2_not_K, ?_, ?_, ?_, hvout_p2⟩
· intro b hb hbc
refine ⟨hp2_not_K b hb hbc, ?_⟩
obtain ⟨j, hj, rfl⟩ := (mem_support_iff_exists_getVert p2).mp hb
have hj1 : 1 ≤ j := by
rcases Nat.eq_zero_or_pos j with rfl | hpos
· exact absurd p2.getVert_zero hbc
· exact hpos
obtain ⟨d, hd⟩ := Nat.exists_eq_add_of_le hj1
subst hd
have h_ind : ∀ m ≤ d, ∃ hmK : p2.getVert (1 + m) ∉ K,
GKc.Reachable u0 ⟨p2.getVert (1 + m), hmK⟩ := by
intro m hm
induction m with
| zero =>
have h1 : p2.getVert (1 + 0) = u0.1 := hu0_eq_p2_1.symm
have hmK : p2.getVert (1 + 0) ∉ K := h1 ▸ u0.2
refine ⟨hmK, ?_⟩
have heq : (⟨p2.getVert (1 + 0), hmK⟩ : VKc) = u0 := Subtype.ext h1
rw [heq]
| succ m ihm =>
obtain ⟨hmK, hmR⟩ := ihm (by omega)
have hne_c : p2.getVert (1 + (m + 1)) ≠ c.1 := by
have hd' : G.dist c.1 (p2.getVert (1 + (m + 1))) = 1 + (m + 1) := by
simpa [p2.getVert_zero] using
geodesic_dist_getVert hG p2 hp2_len (Nat.zero_le _) (by omega)
intro heq; rw [heq, G.dist_self] at hd'; omega
have hmK' : p2.getVert (1 + (m + 1)) ∉ K :=
hp2_not_K _ ((mem_support_iff_exists_getVert p2).mpr ⟨1 + (m + 1), by omega, rfl⟩) hne_c
have hadj0 : G.Adj (p2.getVert (1 + m)) (p2.getVert (1 + (m + 1))) := by
simpa [Nat.add_assoc] using p2.adj_getVert_succ (by omega : 1 + m < p2.length)
have hadj_g : GKc.Adj ⟨p2.getVert (1 + m), hmK⟩ ⟨p2.getVert (1 + (m + 1)), hmK'⟩ := hadj0
exact ⟨hmK', hmR.trans (Adj.reachable hadj_g)⟩
exact (h_ind d (le_refl d)).2
· intro w hw hreach
let fK : GKc →g Gc := { toFun := fun u => ⟨u.1, fun h => u.2 (h ▸ c.2)⟩, map_rel' := fun h => h }
have hGc_reach : Gc.Reachable ⟨u0.1, hu0_ne_c⟩ ⟨w, fun h => hw (h ▸ c.2)⟩ := hreach.map fK
have hw_C2 : Gc.connectedComponentMk ⟨w, fun h => hw (h ▸ c.2)⟩ = C2 := by
rw [← hu0_C2]; exact (ConnectedComponent.eq.mpr hGc_reach).symm
exact (hC2_iff w (fun h => hw (h ▸ c.2))).mp hw_C2
· intro b hb hbc z hadjbz
by_cases hzc : z = c.1
· subst hzc; exact p2.start_mem_support
· have hadj_gc : Gc.Adj ⟨b, hbc⟩ ⟨z, hzc⟩ := hadjbz
have hz_C2 : Gc.connectedComponentMk ⟨z, hzc⟩ = C2 := by
rw [← (hC2_iff b hbc).mpr hb]
exact (ConnectedComponent.eq.mpr hadj_gc.reachable).symm
exact (hC2_iff z hzc).mp hz_C2
-- Construct (t, endpt, P) for each y : K
have h_y : ∀ y : K, ∃ (ty : ℕ) (ey : β) (Py : G.Walk y.1 ey),
Py.length = ty ∧ Py.length = G.dist y.1 ey ∧
(∀ m, 1 ≤ m → m ≤ ty → Py.getVert m ∉ K) ∧
(∀ w : VKc, (∃ u' : VKc, GKc.Reachable w u' ∧ G.Adj y.1 u'.1) → w.1 ∈ Py.support) ∧
(1 ≤ ty → ∃ u0 : VKc, G.Adj y.1 u0.1 ∧
(∀ b ∈ Py.support, (hb : b ≠ y.1) → ∃ hbK : b ∉ K, GKc.Reachable u0 ⟨b, hbK⟩)) ∧
(∀ m, 1 ≤ m → m ≤ ty → ∀ z : β, G.Adj (Py.getVert m) z → z ∈ Py.support) ∧
(1 ≤ ty → ty + 2 ≤ computable_eccent G y.1) := by
intro y
by_cases hy_att : ∃ u0 : VKc, G.Adj y.1 u0.1
· obtain ⟨u0, hu0_adj⟩ := hy_att
obtain ⟨z2, p2, hp2_len, hp2_1, hp2_e1, hp2_notK, hp2_reach, hp2_in, hp2_adj, hp2_vout⟩ :=
h_att_pendant y u0 hu0_adj
refine ⟨p2.length, z2, p2, rfl, hp2_len, ?_, ?_, ?_, ?_, fun _ => hp2_e1⟩
· intro m hm1 hm2
have hne : p2.getVert m ≠ y.1 := by
have hd : G.dist y.1 (p2.getVert m) = m := by
simpa [p2.getVert_zero] using geodesic_dist_getVert hG p2 hp2_len (Nat.zero_le m) hm2
intro heq; rw [heq, G.dist_self] at hd; omega
exact hp2_notK _ ((mem_support_iff_exists_getVert p2).mpr ⟨m, hm2, rfl⟩) hne
· intro w ⟨u', hwu', hu'_adj⟩
have hu'_p2 : u'.1 ∈ p2.support := hp2_vout u' hu'_adj
have hu'_ne : u'.1 ≠ y.1 := fun h => u'.2 (h ▸ y.2)
obtain ⟨hu'K, hu0_u'⟩ := hp2_reach u'.1 hu'_p2 hu'_ne
have h_eq : (⟨u'.1, hu'K⟩ : VKc) = u' := Subtype.ext rfl
rw [h_eq] at hu0_u'
exact hp2_in w.1 w.2 (hu0_u'.trans hwu'.symm)
· intro _
refine ⟨u0, hu0_adj, hp2_reach⟩
· intro m hm1 hm2 z hadjz
have hne : p2.getVert m ≠ y.1 := by
have hd : G.dist y.1 (p2.getVert m) = m := by
simpa [p2.getVert_zero] using geodesic_dist_getVert hG p2 hp2_len (Nat.zero_le m) hm2
intro heq; rw [heq, G.dist_self] at hd; omega
exact hp2_adj _ ((mem_support_iff_exists_getVert p2).mpr ⟨m, hm2, rfl⟩) hne z hadjz
· refine ⟨0, y.1, Walk.nil, rfl, by simp, fun m hm1 hm2 => by omega, ?_, ?_, fun m hm1 hm2 => by omega, fun h1 => by omega⟩
· intro w ⟨u', _, hu'_adj⟩
exact absurd ⟨u', hu'_adj⟩ hy_att
· intro h1; omega
choose t endpt P hP using h_y
have hB_exit : ∀ (y' : K) {a b : β} (q : G.Walk a b),
a ∈ (P y').support → a ≠ y'.1 → (b ∈ (P y').support → b = y'.1) →
∃ j, 1 ≤ j ∧ j ≤ q.length ∧ q.getVert j = y'.1 := by
intro y' a b q ha_supp ha_ne hb_not
let B : Set β := {v | v ∈ (P y').support ∧ v ≠ y'.1}
have haB : a ∈ B := ⟨ha_supp, ha_ne⟩
have hbB : b ∉ B := fun hb => hb.2 (hb_not hb.1)
have hex : ∃ j ≤ q.length, q.getVert j ∉ B := ⟨q.length, le_refl _, by simpa [q.getVert_length] using hbB⟩
set j := Nat.find hex
have hj_spec : j ≤ q.length ∧ q.getVert j ∉ B := Nat.find_spec hex
have hj_pos : 1 ≤ j := by
by_contra h0; have hj0 : j = 0 := by omega
apply hj_spec.2
rw [hj0, q.getVert_zero]
exact haB
have hj_prev : q.getVert (j - 1) ∈ B := by
by_contra hnot; exact Nat.find_min hex (m := j - 1) (by omega) ⟨by omega, hnot⟩
have hadjq : G.Adj (q.getVert (j - 1)) (q.getVert j) := by
simpa [Nat.sub_add_cancel hj_pos] using q.adj_getVert_succ (by omega : j - 1 < q.length)
obtain ⟨m0, hm0, hm0_eq⟩ := (mem_support_iff_exists_getVert (P y')).mp hj_prev.1
have hm01 : 1 ≤ m0 := by
rcases Nat.eq_zero_or_pos m0 with rfl | hp
· rw [(P y').getVert_zero] at hm0_eq; exact absurd hm0_eq.symm hj_prev.2
· exact hp
have hnext_supp : q.getVert j ∈ (P y').support := by
rw [← hm0_eq] at hadjq
exact (hP y').2.2.2.2.2.1 m0 hm01 (by have := (hP y').1; omega) _ hadjq
have hnext_eq : q.getVert j = y'.1 := by
by_contra hne; exact hj_spec.2 ⟨hnext_supp, hne⟩
exact ⟨j, hj_pos, hj_spec.1, hnext_eq⟩
have hdist_K : ∀ u y : K, G.dist u.1 y.1 = (G.induce (K : Set β)).dist u y := by
intro u y
apply le_antisymm
· obtain ⟨w, hw⟩ := hK_conn.exists_walk_length_eq_dist u y
have h_le : G.dist u.1 y.1 ≤ (w.map (Embedding.induce (K : Set β)).toHom).length := dist_le _
rw [Walk.length_map, hw] at h_le
exact h_le
· obtain ⟨w, hw⟩ := hG.exists_walk_length_eq_dist u.1 y.1
have hw_in_K : ∀ z ∈ w.support, z ∈ (K : Set β) := by
intro z hz
by_contra hzK
obtain ⟨y', u_att, hreach, hadj⟩ := h_has_att ⟨z, hzK⟩
have hz_supp := (hP y').2.2.2.1 ⟨z, hzK⟩ ⟨u_att, hreach, hadj⟩
rw [mem_support_iff_exists_getVert] at hz
obtain ⟨k, hk, rfl⟩ := hz
have hk_supp : w.getVert k ∈ w.support := (mem_support_iff_exists_getVert w).mpr ⟨k, hk, rfl⟩
let w1 := w.takeUntil (w.getVert k) hk_supp
let w2 := w.dropUntil (w.getVert k) hk_supp
have hw1_sub : w1.IsSubwalk w := ⟨.nil, w2, by simp [w1, w2, w.take_spec]⟩
have hw2_sub : w2.IsSubwalk w := ⟨w1, .nil, by simp [w1, w2, w.take_spec]⟩
have hw1_geod : w1.length = G.dist u.1 (w.getVert k) := length_eq_dist_of_subwalk hw hw1_sub
have hw2_geod : w2.length = G.dist (w.getVert k) y.1 := length_eq_dist_of_subwalk hw hw2_sub
have hz_ne_y' : w.getVert k ≠ y'.1 := fun h => hzK (h ▸ y'.2)
have hu_out : u.1 ∈ (P y').support → u.1 = y'.1 := by
intro hu_supp
obtain ⟨m, hm, hm_eq⟩ := (mem_support_iff_exists_getVert (P y')).mp hu_supp
rcases Nat.eq_zero_or_pos m with rfl | hm1
· rw [(P y').getVert_zero] at hm_eq; exact hm_eq.symm
· exact absurd (hm_eq.symm ▸ u.2) ((hP y').2.2.1 m hm1 (by have := (hP y').1; omega))
have hy_out : y.1 ∈ (P y').support → y.1 = y'.1 := by
intro hy_supp
obtain ⟨m, hm, hm_eq⟩ := (mem_support_iff_exists_getVert (P y')).mp hy_supp
rcases Nat.eq_zero_or_pos m with rfl | hm1
· rw [(P y').getVert_zero] at hm_eq; exact hm_eq.symm
· exact absurd (hm_eq.symm ▸ y.2) ((hP y').2.2.1 m hm1 (by have := (hP y').1; omega))
obtain ⟨j1, hj1_pos, hj1_le, hj1_eq⟩ := hB_exit y' w1.reverse hz_supp hz_ne_y' hu_out
obtain ⟨j2, hj2_pos, hj2_le, hj2_eq⟩ := hB_exit y' w2 hz_supp hz_ne_y' hy_out
have hw1r_geod : w1.reverse.length = G.dist (w.getVert k) u.1 := by
rw [Walk.length_reverse, G.dist_comm]; exact hw1_geod
have hd1 : G.dist (w.getVert k) y'.1 = j1 := by
simpa [hj1_eq, w1.reverse.getVert_zero] using
geodesic_dist_getVert hG w1.reverse hw1r_geod (Nat.zero_le j1) hj1_le
have hd2 : G.dist y'.1 u.1 = w1.reverse.length - j1 := by
have h2 := geodesic_dist_getVert hG w1.reverse hw1r_geod hj1_le (le_refl w1.reverse.length)
rw [hj1_eq, w1.reverse.getVert_length] at h2
exact h2
have hd3 : G.dist (w.getVert k) y'.1 = j2 := by
simpa [hj2_eq, w2.getVert_zero] using
geodesic_dist_getVert hG w2 hw2_geod (Nat.zero_le j2) hj2_le
have hd4 : G.dist y'.1 y.1 = w2.length - j2 := by
have h4 := geodesic_dist_getVert hG w2 hw2_geod hj2_le (le_refl w2.length)
rw [hj2_eq, w2.getVert_length] at h4
exact h4
have htri : G.dist u.1 y.1 ≤ G.dist u.1 y'.1 + G.dist y'.1 y.1 := hG.dist_triangle
rw [G.dist_comm (u := u.1) (v := y'.1)] at htri
rw [Walk.length_reverse] at hd2 hj1_le
have hsum : w1.length + w2.length = w.length := by
rw [← Walk.length_append]
exact congrArg Walk.length (w.take_spec hk_supp)
omega
rw [← hw, ← walkInduce_length w hw_in_K u.2 y.2]
exact dist_le (walkInduce w hw_in_K u.2 y.2)
have hdist_Kp : ∀ u y : K, ∀ m ≤ t y,
G.dist u.1 ((P y).getVert m) = (G.induce (K : Set β)).dist u y + m := by
intro u y m hm
rcases Nat.eq_zero_or_pos m with rfl | hm1
· rw [(P y).getVert_zero, Nat.add_zero, hdist_K]
· have hm_len : m ≤ (P y).length := by have := (hP y).1; omega
have hdm : G.dist y.1 ((P y).getVert m) = m := by
simpa [(P y).getVert_zero] using geodesic_dist_getVert hG (P y) (hP y).2.1 (Nat.zero_le m) hm_len
apply le_antisymm
· have htri : G.dist u.1 ((P y).getVert m) ≤ G.dist u.1 y.1 + G.dist y.1 ((P y).getVert m) :=
hG.dist_triangle
rw [hdist_K, hdm] at htri
exact htri
· obtain ⟨q, hq⟩ := hG.exists_walk_length_eq_dist u.1 ((P y).getVert m)
have hm_supp : (P y).getVert m ∈ (P y).support :=
(mem_support_iff_exists_getVert (P y)).mpr ⟨m, hm_len, rfl⟩
have hm_ne : (P y).getVert m ≠ y.1 := fun heq =>
(hP y).2.2.1 m hm1 hm (heq.symm ▸ y.2)
have hu_out : u.1 ∈ (P y).support → u.1 = y.1 := by
intro hu_supp
obtain ⟨m', hm', hm'_eq⟩ := (mem_support_iff_exists_getVert (P y)).mp hu_supp
rcases Nat.eq_zero_or_pos m' with rfl | hm'1
· rw [(P y).getVert_zero] at hm'_eq; exact hm'_eq.symm
· exact absurd (hm'_eq.symm ▸ u.2) ((hP y).2.2.1 m' hm'1 (by have := (hP y).1; omega))
obtain ⟨j, hj_pos, hj_le, hj_eq⟩ := hB_exit y q.reverse hm_supp hm_ne hu_out
have hqr_geod : q.reverse.length = G.dist ((P y).getVert m) u.1 := by
rw [Walk.length_reverse, G.dist_comm]; exact hq
have hd1 : G.dist ((P y).getVert m) y.1 = j := by
simpa [hj_eq, q.reverse.getVert_zero] using
geodesic_dist_getVert hG q.reverse hqr_geod (Nat.zero_le j) hj_le
have hd2 : G.dist y.1 u.1 = q.reverse.length - j := by
have h2 := geodesic_dist_getVert hG q.reverse hqr_geod hj_le (le_refl q.reverse.length)
rw [hj_eq, q.reverse.getVert_length] at h2
exact h2
rw [G.dist_comm (u := (P y).getVert m) (v := y.1), hdm] at hd1
rw [G.dist_comm (u := y.1) (v := u.1), hdist_K, Walk.length_reverse, hq] at hd2
rw [Walk.length_reverse] at hj_le
omega
refine ⟨K, hK, t, endpt, P, ?_, ?_, ?_, ?_, ?_, ?_, hdist_Kp, ?_, ?_⟩
· intro y; exact ⟨(hP y).1, (hP y).2.1⟩
· obtain ⟨u0, hu0⟩ := hex_out
obtain ⟨y0, u_att, hreach, hadj⟩ := h_has_att ⟨u0, hu0⟩
have hu0_supp : u0 ∈ (P y0).support := ((hP y0).2.2.2.1 ⟨u0, hu0⟩ ⟨u_att, hreach, hadj⟩)
obtain ⟨m, hm, hm_eq⟩ := (mem_support_iff_exists_getVert (P y0)).mp hu0_supp
have hm1 : 1 ≤ m := by
rcases Nat.eq_zero_or_pos m with rfl | hpos
· rw [(P y0).getVert_zero] at hm_eq; rw [← hm_eq] at hu0; exact absurd y0.2 hu0
· exact hpos
exact ⟨y0, by have := (hP y0).1; omega⟩
· intro y m hm1 hm2; exact (hP y).2.2.1 m hm1 hm2
· intro y1 y2 m1 m2 hm1 hm1' hm2 hm2' heq
have h1_notK : (P y1).getVert m1 ∉ K := (hP y1).2.2.1 m1 hm1 hm1'
have h2_notK : (P y2).getVert m2 ∉ K := (hP y2).2.2.1 m2 hm2 hm2'
have h1_pos : 1 ≤ t y1 := by omega
have h2_pos : 1 ≤ t y2 := by omega
obtain ⟨u1, hu1_adj, hu1_r⟩ := (hP y1).2.2.2.2.1 h1_pos
obtain ⟨u2, hu2_adj, hu2_r⟩ := (hP y2).2.2.2.2.1 h2_pos
have hne1 : (P y1).getVert m1 ≠ y1.1 := fun h => h1_notK (h.symm ▸ y1.2)
have hne2 : (P y2).getVert m2 ≠ y2.1 := fun h => h2_notK (h.symm ▸ y2.2)
obtain ⟨h1K, hR1⟩ := hu1_r _ ((mem_support_iff_exists_getVert (P y1)).mpr ⟨m1, by have := (hP y1).1; omega, rfl⟩) hne1
obtain ⟨h2K, hR2⟩ := hu2_r _ ((mem_support_iff_exists_getVert (P y2)).mpr ⟨m2, by have := (hP y2).1; omega, rfl⟩) hne2
have h_sub_eq : (⟨(P y1).getVert m1, h1K⟩ : VKc) = ⟨(P y2).getVert m2, h2K⟩ := Subtype.ext heq
have hR12 : GKc.Reachable u1 u2 := hR1.trans (h_sub_eq ▸ hR2.symm)
have hy_eq : y1 = y2 := h_uniq_att hR12 hu1_adj hu2_adj
subst hy_eq
have hd1 : G.dist y1.1 ((P y1).getVert m1) = m1 := by
simpa [(P y1).getVert_zero] using geodesic_dist_getVert hG (P y1) (hP y1).2.1 (Nat.zero_le _) (by have := (hP y1).1; omega)
have hd2 : G.dist y1.1 ((P y1).getVert m2) = m2 := by
simpa [(P y1).getVert_zero] using geodesic_dist_getVert hG (P y1) (hP y1).2.1 (Nat.zero_le _) (by have := (hP y1).1; omega)
rw [heq, hd2] at hd1
exact ⟨rfl, hd1.symm⟩
· intro u
by_cases huK : u ∈ K
· exact Or.inl huK
· right
obtain ⟨y, u_att, hreach, hadj⟩ := h_has_att ⟨u, huK⟩
have hu_supp := (hP y).2.2.2.1 ⟨u, huK⟩ ⟨u_att, hreach, hadj⟩
obtain ⟨m, hm, hm_eq⟩ := (mem_support_iff_exists_getVert (P y)).mp hu_supp
have hm1 : 1 ≤ m := by
rcases Nat.eq_zero_or_pos m with rfl | hpos
· rw [(P y).getVert_zero] at hm_eq; dsimp only at hm_eq; rw [← hm_eq] at huK; exact absurd y.2 huK
· exact hpos
exact ⟨y, m, hm1, by have := (hP y).1; omega, hm_eq.symm⟩
· intro y m hm1 hm2 z hadjz
exact (hP y).2.2.2.2.2.1 m hm1 hm2 z hadjz
· intro u
apply le_antisymm
· unfold computable_eccent
apply Finset.sup_le
intro z _
rw [← dist_eq_computable]
by_cases hzK : z ∈ K
· have h_le : G.dist u.1 z ≤ (G.induce (K : Set β)).dist u ⟨z, hzK⟩ + t ⟨z, hzK⟩ := by
rw [hdist_K u ⟨z, hzK⟩]; omega
exact le_trans h_le (Finset.le_sup (f := fun y : K => (G.induce (K : Set β)).dist u y + t y) (Finset.mem_univ _))
· obtain ⟨y, u_att, hreach, hadj⟩ := h_has_att ⟨z, hzK⟩
have hz_supp := (hP y).2.2.2.1 ⟨z, hzK⟩ ⟨u_att, hreach, hadj⟩
obtain ⟨m, hm, rfl⟩ := (mem_support_iff_exists_getVert (P y)).mp hz_supp
have hm' : m ≤ t y := by have := (hP y).1; omega
rw [hdist_Kp u y m hm']
exact le_trans (by omega : (G.induce (K : Set β)).dist u y + m ≤ (G.induce (K : Set β)).dist u y + t y)
(Finset.le_sup (f := fun y' : K => (G.induce (K : Set β)).dist u y' + t y') (Finset.mem_univ y))
· apply Finset.sup_le
intro y _
have hy_dist := hdist_Kp u y (t y) (le_refl _)
rw [← hy_dist, dist_eq_computable]
exact Finset.le_sup (f := fun z => computable_dist G u.1 z) (Finset.mem_univ ((P y).getVert (t y)))
· intro y hy
exact (hP y).2.2.2.2.2.2 hy
-- Stage 3: Chung's bound, pendant attachment, Parts 3-5, and Theorem 1
private lemma chung_aux :
∀ (n : ℕ) {β : Type*} [Fintype β] [DecidableEq β] [Nonempty β]
(H : SimpleGraph β) [DecidableRel H.Adj],
Fintype.card β = n → H.Connected →
2 * H.radius.toNat - 1 ≤ largestInducedTreeSize H := by
intro n
induction n using Nat.strong_induction_on with
| h n ih =>
intro β _ _ _ H _ hcard hH
set r := H.radius.toNat
by_cases hr : r ≤ 1
· have h1 := one_le_largestInducedTreeSize H
omega
have hr2 : 2 ≤ r := by omega
have hrad_eq : r = computable_radius H := by
change H.radius.toNat = computable_radius H
rw [radius_eq_computable H hH]
rfl
have hecc_ge (u : β) : r ≤ computable_eccent H u := by
have hle := H.radius_le_eccent (u := u)
rw [radius_eq_computable H hH, eccent_eq_computable H hH u] at hle
have hle' : computable_radius H ≤ computable_eccent H u := by exact_mod_cast hle
omega
let u0 : β := Classical.arbitrary β
obtain ⟨x, _, hx_max⟩ :=
Finset.exists_max_image (Finset.univ : Finset β) (fun z => H.dist u0 z) Finset.univ_nonempty
have hx_dist2 : 2 ≤ H.dist u0 x := by
have h_ecc : 2 ≤ computable_eccent H u0 := le_trans hr2 (hecc_ge u0)
have h_le : computable_eccent H u0 ≤ H.dist u0 x := by
unfold computable_eccent
apply Finset.sup_le
intro z _
rw [← dist_eq_computable]
exact hx_max z (Finset.mem_univ z)
omega
have h_u0_ne_x : u0 ≠ x := by
intro h_eq
subst h_eq
simp at hx_dist2
let V' : Set β := {x}ᶜ
let H' : SimpleGraph V' := H.induce V'
have hH'_nonempty : Nonempty V' := ⟨⟨u0, h_u0_ne_x⟩⟩
have hH'_reach (y : β) (hy : y ≠ x) :
H'.Reachable ⟨u0, h_u0_ne_x⟩ ⟨y, hy⟩ := by
obtain ⟨q0, hq0⟩ := hH.exists_walk_length_eq_dist u0 y
have hx_notin : x ∉ q0.support := by
intro hxmem
rw [mem_support_iff_exists_getVert] at hxmem
obtain ⟨i, hi, rfl⟩ := hxmem
have hi_lt : i < q0.length := by
rcases Nat.eq_or_lt_of_le hi with rfl | hi_lt
· rw [q0.getVert_length] at hy; exact absurd rfl hy
· exact hi_lt
have hdi : H.dist u0 (q0.getVert i) = i := by
simpa [q0.getVert_zero] using geodesic_dist_getVert hH q0 hq0 (Nat.zero_le i) hi
have hymax := hx_max y (Finset.mem_univ y)
omega
have hsupp : ∀ z ∈ q0.support, z ∈ V' := by
intro z hz heq
apply hx_notin
rwa [← heq]
exact ⟨walkInduce q0 hsupp h_u0_ne_x hy⟩
have hH' : H'.Connected := by
refine ⟨fun a b => ?_⟩
exact (hH'_reach a.1 a.2).symm.trans (hH'_reach b.1 b.2)
have hV'_card : Fintype.card V' < n := by
rw [← hcard]
have hcardV' : Fintype.card V' = (Finset.univ.erase x).card := by
rw [Fintype.card_subtype]
congr 1
ext z
simp [V', and_comm]
rw [hcardV', Finset.card_erase_of_mem (Finset.mem_univ x)]
exact Nat.sub_lt Fintype.card_pos Nat.zero_lt_one
by_cases hrad' : r ≤ H'.radius.toNat
· have ih' := ih (Fintype.card V') hV'_card H' rfl hH'
have hmono := card_largestInducedTreeSize_induce_le H V'
calc 2 * r - 1 ≤ 2 * H'.radius.toNat - 1 := by omega
_ ≤ largestInducedTreeSize H' := ih'
_ ≤ largestInducedTreeSize H := hmono
have hrad'_lt : H'.radius.toNat ≤ r - 1 := by omega
have hrad'_eq : H'.radius.toNat = computable_radius H' := by
rw [radius_eq_computable H' hH']
rfl
obtain ⟨c', _, hc'_min⟩ :=
Finset.exists_min_image (Finset.univ : Finset V') (fun u => computable_eccent H' u)
Finset.univ_nonempty
have hc'_ecc : computable_eccent H' c' ≤ r - 1 := by
have hcr : computable_radius H' = computable_eccent H' c' := by
apply le_antisymm
· exact Finset.inf'_le _ (Finset.mem_univ c')
· exact Finset.le_inf' _ _ fun u hu => hc'_min u hu
omega
let v : β := c'.1
have hv_ne_x : v ≠ x := c'.2
have hdist_v_ne : ∀ z : β, z ≠ x → H.dist v z ≤ r - 1 := by
intro z hz
have hH'_dist : H'.dist c' ⟨z, hz⟩ ≤ computable_eccent H' c' := by
rw [dist_eq_computable]
exact Finset.le_sup (f := fun u => computable_dist H' c' u) (Finset.mem_univ _)
obtain ⟨w', hw'⟩ := hH'.exists_walk_length_eq_dist c' ⟨z, hz⟩
have h_le : H.dist v z ≤ (w'.map (Embedding.induce V').toHom).length := dist_le _
rw [Walk.length_map, hw'] at h_le
omega
have hdist_vx_le : H.dist v x ≤ r := by
obtain ⟨qvx, hqvx⟩ := hH.exists_walk_length_eq_dist v x
have hlen_pos : 1 ≤ qvx.length := by
rw [hqvx]
exact Nat.pos_of_ne_zero fun h0 =>
hv_ne_x ((hH.dist_eq_zero_iff).mp h0)
let u := qvx.getVert (qvx.length - 1)
have hadj : H.Adj u x := by
simpa [u, Nat.sub_add_cancel hlen_pos, qvx.getVert_length] using
qvx.adj_getVert_succ (by omega : qvx.length - 1 < qvx.length)
have hvu := hdist_v_ne u hadj.ne
have hux : H.dist u x = 1 := dist_eq_one_iff_adj.mpr hadj
have htri : H.dist v x ≤ H.dist v u + H.dist u x := hH.dist_triangle
omega
have hdist_vx : H.dist v x = r := by
have hv_ecc : r ≤ computable_eccent H v := hecc_ge v
obtain ⟨zmax, _, hzmax⟩ :=
Finset.exists_max_image (Finset.univ : Finset β) (fun z => computable_dist H v z)
Finset.univ_nonempty
have h_sup_le : computable_eccent H v ≤ computable_dist H v zmax := by
unfold computable_eccent
exact Finset.sup_le fun z _ => hzmax z (Finset.mem_univ z)
rw [← dist_eq_computable] at h_sup_le
by_cases hzx : zmax = x
· subst hzx; omega
· have := hdist_v_ne zmax hzx; omega
obtain ⟨q, hq⟩ := hH.exists_walk_length_eq_dist v x
have hq_len : q.length = r := by omega
let q2 := q.getVert 2
have hq2_x : H.dist q2 x = r - 2 := by
simpa [q2, ← hq_len, q.getVert_length] using
geodesic_dist_getVert hH q hq (by omega : 2 ≤ r) (by omega : r ≤ q.length)
have hq2_v : H.dist v q2 = 2 := by
simpa [q2, q.getVert_zero] using
geodesic_dist_getVert hH q hq (Nat.zero_le 2) (by omega : 2 ≤ q.length)
obtain ⟨w, _, hw_max⟩ :=
Finset.exists_max_image (Finset.univ : Finset β) (fun z => computable_dist H q2 z)
Finset.univ_nonempty
have hq2_w : r ≤ H.dist q2 w := by
have h_ecc := hecc_ge q2
have h_sup : computable_eccent H q2 ≤ computable_dist H q2 w := by
unfold computable_eccent
exact Finset.sup_le fun z _ => hw_max z (Finset.mem_univ z)
rw [← dist_eq_computable] at h_sup
omega
have hw_ne_x : w ≠ x := by
intro heq; subst heq; omega
set l := H.dist v w
have hl_le : l ≤ r - 1 := hdist_v_ne w hw_ne_x
have hl_ge : r - 2 ≤ l := by
have htri : H.dist q2 w ≤ H.dist q2 v + H.dist v w := hH.dist_triangle
rw [H.dist_comm (u := q2) (v := v)] at htri
have h2v : H.dist v q2 = 2 := hq2_v
omega
by_cases hl0 : l = 0
· have hr_eq2 : r = 2 := by omega
have hqtree : (H.induce (q.support.toFinset : Set β)).IsTree :=
Walk.induce_support_isTree_of_length_eq_dist q hq
have hqnodup : q.support.Nodup := (q.isPath_of_length_eq_dist hq).support_nodup
have hqcard : q.support.toFinset.card = r + 1 := by
rw [List.toFinset_card_of_nodup hqnodup, Walk.length_support, hq_len]
have hbound := card_le_largestInducedTreeSize hqtree
omega
have hl1 : 1 ≤ l := by omega
obtain ⟨p, hp⟩ := hH.exists_walk_length_eq_dist v w
have hp_len : p.length = l := hp
have hq2_p_ge : ∀ i, 1 ≤ i → i ≤ l → i + 1 ≤ H.dist q2 (p.getVert i) := by
intro i hi1 hil
have hpiw : H.dist (p.getVert i) w = l - i := by
simpa [← hp_len, p.getVert_length] using
geodesic_dist_getVert hH p hp hil (by omega : l ≤ p.length)
have htri : H.dist q2 w ≤ H.dist q2 (p.getVert i) + H.dist (p.getVert i) w :=
hH.dist_triangle
omega
have hq2_q : ∀ j ≤ r, H.dist q2 (q.getVert j) = if j ≤ 2 then 2 - j else j - 2 := by
intro j hj
split_ifs with hj2
· rw [H.dist_comm]
exact geodesic_dist_getVert hH q hq hj2 (by omega : 2 ≤ q.length)
· exact geodesic_dist_getVert hH q hq (by omega : 2 ≤ j) (by omega : j ≤ q.length)
have hp_ne_q : ∀ i, 1 ≤ i → i ≤ l → ∀ j ≤ r, p.getVert i ≠ q.getVert j := by
intro i hi1 hil j hj heq
have hdv_p : H.dist v (p.getVert i) = i := by
simpa [p.getVert_zero] using
geodesic_dist_getVert hH p hp (Nat.zero_le i) (by omega)
have hdv_q : H.dist v (q.getVert j) = j := by
simpa [q.getVert_zero] using
geodesic_dist_getVert hH q hq (Nat.zero_le j) (by omega)
rw [heq, hdv_q] at hdv_p
have h2p := hq2_p_ge i hi1 hil
rw [heq, hq2_q j hj] at h2p
split_ifs at h2p <;> omega
have hp_adj_q : ∀ i, 1 ≤ i → i ≤ l → ∀ j ≤ r,
H.Adj (p.getVert i) (q.getVert j) → i = 1 ∧ (j = 0 ∨ j = 1) := by
intro i hi1 hil j hj hadj
have hdv_p : H.dist v (p.getVert i) = i := by
simpa [p.getVert_zero] using
geodesic_dist_getVert hH p hp (Nat.zero_le i) (by omega)
have hdv_q : H.dist v (q.getVert j) = j := by
simpa [q.getVert_zero] using
geodesic_dist_getVert hH q hq (Nat.zero_le j) (by omega)
have hd1 : H.dist (p.getVert i) (q.getVert j) = 1 := dist_eq_one_iff_adj.mpr hadj
have htri1 : H.dist v (p.getVert i) ≤ H.dist v (q.getVert j) + H.dist (q.getVert j) (p.getVert i) :=
hH.dist_triangle
have htri2 : H.dist v (q.getVert j) ≤ H.dist v (p.getVert i) + H.dist (p.getVert i) (q.getVert j) :=
hH.dist_triangle
rw [H.dist_comm (u := q.getVert j) (v := p.getVert i), hd1, hdv_p, hdv_q] at htri1
rw [hd1, hdv_p, hdv_q] at htri2
have h2p := hq2_p_ge i hi1 hil
have htri3 : H.dist q2 (p.getVert i) ≤ H.dist q2 (q.getVert j) + H.dist (q.getVert j) (p.getVert i) :=
hH.dist_triangle
rw [H.dist_comm (u := q.getVert j) (v := p.getVert i), hd1, hq2_q j hj] at htri3
split_ifs at htri3 <;> omega
by_cases hadj11 : H.Adj (p.getVert 1) (q.getVert 1)
· have hl_eq : l = r - 1 := by
have hpiw : H.dist (p.getVert 1) w = l - 1 := by
simpa [← hp_len, p.getVert_length] using
geodesic_dist_getVert hH p hp hl1 (by omega : l ≤ p.length)
have htri_w : H.dist q2 w ≤ H.dist q2 (p.getVert 1) + H.dist (p.getVert 1) w :=
hH.dist_triangle
have htri_q1 : H.dist q2 (p.getVert 1) ≤ H.dist q2 (q.getVert 1) + H.dist (q.getVert 1) (p.getVert 1) :=
hH.dist_triangle
have h1d : H.dist (q.getVert 1) (p.getVert 1) = 1 := dist_eq_one_iff_adj.mpr hadj11.symm
have h21 : H.dist q2 (q.getVert 1) = 1 := by
simpa using hq2_q 1 (by omega)
omega
obtain ⟨v1, q', hv1_eq, hq'_len, hq'_mem⟩ := walk_tail_exists q (by omega : 1 ≤ q.length)
have hq'_geod : q'.length = H.dist v1 x := by
have hd1x : H.dist (q.getVert 1) x = r - 1 := by
simpa [← hq_len, q.getVert_length] using
geodesic_dist_getVert hH q hq (by omega : 1 ≤ r) (by omega : r ≤ q.length)
rw [← hv1_eq] at hd1x
omega
let S₀ := q'.support.toFinset
have hS₀_tree : (H.induce (S₀ : Set β)).IsTree :=
Walk.induce_support_isTree_of_length_eq_dist q' hq'_geod
have hS₀_card : S₀.card = r := by
have hnodup := (q'.isPath_of_length_eq_dist hq'_geod).support_nodup
rw [List.toFinset_card_of_nodup hnodup, Walk.length_support, hq'_len, hq_len]
omega
have hv1_mem : v1 ∈ S₀ := by
simp [S₀, Walk.start_mem_support]
have hS₀_mem_iff (b : β) : b ∈ S₀ → ∃ j, 1 ≤ j ∧ j ≤ r ∧ b = q.getVert j := by
intro hb
simp only [S₀, List.mem_toFinset] at hb
obtain ⟨j, hj1, hjr, rfl⟩ := hq'_mem b hb
exact ⟨j, hj1, by omega, rfl⟩
have hdisj : ∀ i, 1 ≤ i → i ≤ p.length → p.getVert i ∉ S₀ := by
intro i hi1 hil hb
obtain ⟨j, _, hjr, heq⟩ := hS₀_mem_iff _ hb
exact hp_ne_q i hi1 (by omega) j hjr heq
have huniq0 : ∀ i b, 1 ≤ i → i ≤ p.length → b ∈ S₀ →
H.Adj (p.getVert i) b → i = 1 ∧ b = v1 := by
intro i b hi1 hil hb hadjb
obtain ⟨j, hj1, hjr, rfl⟩ := hS₀_mem_iff b hb
obtain ⟨hi_eq, hj_or⟩ := hp_adj_q i hi1 (by omega) j hjr hadjb
rcases hj_or with rfl | rfl
· omega
· exact ⟨hi_eq, hv1_eq.symm⟩
obtain ⟨S, hSTree, hScard, _⟩ := insertChain_exists S₀ hS₀_tree p hp hH v1
hv1_mem (by rw [hv1_eq]; exact hadj11) hdisj huniq0 l (by omega)
have hbound := card_le_largestInducedTreeSize hSTree
omega
· let S₀ := q.support.toFinset
have hS₀_tree : (H.induce (S₀ : Set β)).IsTree :=
Walk.induce_support_isTree_of_length_eq_dist q hq
have hS₀_card : S₀.card = r + 1 := by
have hnodup := (q.isPath_of_length_eq_dist hq).support_nodup
rw [List.toFinset_card_of_nodup hnodup, Walk.length_support, hq_len]
have hv_mem : v ∈ S₀ := by
simp [S₀, Walk.start_mem_support]
have hv_adj : H.Adj (p.getVert 1) v := by
simpa [p.getVert_zero] using (p.adj_getVert_succ (by omega : 0 < p.length)).symm
have hS₀_mem_iff (b : β) : b ∈ S₀ → ∃ j ≤ r, b = q.getVert j := by
intro hb
simp only [S₀, List.mem_toFinset] at hb
rw [mem_support_iff_exists_getVert] at hb
obtain ⟨j, hj, rfl⟩ := hb
exact ⟨j, by omega, rfl⟩
have hdisj : ∀ i, 1 ≤ i → i ≤ p.length → p.getVert i ∉ S₀ := by
intro i hi1 hil hb
obtain ⟨j, hjr, heq⟩ := hS₀_mem_iff _ hb
exact hp_ne_q i hi1 (by omega) j hjr heq
have huniq0 : ∀ i b, 1 ≤ i → i ≤ p.length → b ∈ S₀ →
H.Adj (p.getVert i) b → i = 1 ∧ b = v := by
intro i b hi1 hil hb hadjb
obtain ⟨j, hjr, rfl⟩ := hS₀_mem_iff b hb
obtain ⟨hi_eq, hj_or⟩ := hp_adj_q i hi1 (by omega) j hjr hadjb
rcases hj_or with rfl | rfl
· exact ⟨hi_eq, q.getVert_zero⟩
· subst hi_eq
exact absurd hadjb hadj11
obtain ⟨S, hSTree, hScard, _⟩ := insertChain_exists S₀ hS₀_tree p hp hH v hv_mem
hv_adj hdisj huniq0 l (by omega)
have hbound := card_le_largestInducedTreeSize hSTree
omega
private lemma attach_pendants {β : Type u} [Fintype β] [DecidableEq β]
(G : SimpleGraph β) (hG : G.Connected) (K : Finset β)
(t : K → ℕ) (endpt : K → β) (P : ∀ y : K, G.Walk y.1 (endpt y))
(hP_len : ∀ y : K, (P y).length = t y ∧ (P y).length = G.dist y.1 (endpt y))
(hP_out : ∀ y : K, ∀ m, 1 ≤ m → m ≤ t y → (P y).getVert m ∉ K)
(hP_inj : ∀ y1 y2 : K, ∀ m1 m2, 1 ≤ m1 → m1 ≤ t y1 → 1 ≤ m2 → m2 ≤ t y2 →
(P y1).getVert m1 = (P y2).getVert m2 → y1 = y2 ∧ m1 = m2)
(hP_adj : ∀ y : K, ∀ m, 1 ≤ m → m ≤ t y → ∀ z : β, G.Adj ((P y).getVert m) z → z ∈ (P y).support)
(L : ℕ) (hL1 : 1 ≤ L) (htL : ∀ y : K, t y = L)
(T₀ : Finset K) (hT₀ : ((G.induce (K : Set β)).induce (T₀ : Set K)).IsTree) :
∃ S : Finset β, (G.induce (S : Set β)).IsTree ∧ S.card = T₀.card * (L + 1) := by
classical
have h_ind : ∀ U : Finset K, U ⊆ T₀ → ∃ S : Finset β,
(G.induce (S : Set β)).IsTree ∧
S.card = T₀.card + U.card * L ∧
∀ u : β, u ∈ S ↔ ((∃ y ∈ T₀, u = y.1) ∨ ∃ y ∈ U, ∃ m, 1 ≤ m ∧ m ≤ t y ∧ u = (P y).getVert m) := by
intro U
induction U using Finset.induction_on with
| empty =>
intro _
refine ⟨T₀.image Subtype.val, walk_induce_tree_card_image T₀ hT₀, ?_, ?_⟩
· rw [Finset.card_image_of_injective T₀ Subtype.val_injective, Finset.card_empty, Nat.zero_mul, Nat.add_zero]
· intro u
simp only [Finset.mem_image, Finset.notMem_empty, false_and, exists_false, or_false]
exact ⟨fun ⟨y, hy, heq⟩ => ⟨y, hy, heq.symm⟩, fun ⟨y, hy, heq⟩ => ⟨y, hy, heq.symm⟩⟩
| @insert a U haU ihU =>
intro hUsub
obtain ⟨S_U, hSU_tree, hSU_card, hSU_mem⟩ :=
ihU (Finset.Subset.trans (Finset.subset_insert a U) hUsub)
have haT₀ : a ∈ T₀ := hUsub (Finset.mem_insert_self a U)
have ha_len : (P a).length = L := (hP_len a).1.trans (htL a)
have ha_mem : a.1 ∈ S_U := (hSU_mem a.1).mpr (Or.inl ⟨a, haT₀, rfl⟩)
have ha_adj : G.Adj ((P a).getVert 1) a.1 := by
have hadj := ((P a).adj_getVert_succ (by rw [ha_len]; exact hL1 : 0 < (P a).length)).symm
simpa [(P a).getVert_zero] using hadj
have hdisj : ∀ m, 1 ≤ m → m ≤ (P a).length → (P a).getVert m ∉ S_U := by
intro m hm1 hm2 hmem
have hm_ty : m ≤ t a := by have := (hP_len a).1; omega
rcases (hSU_mem _).mp hmem with ⟨y, _, heq⟩ | ⟨y, hyU, m', hm'1, hm'2, heq⟩
· exact hP_out a m hm1 hm_ty (heq ▸ y.2)
· exact haU ((hP_inj a y m m' hm1 hm_ty hm'1 hm'2 heq).1 ▸ hyU)
have huniq : ∀ m b, 1 ≤ m → m ≤ (P a).length → b ∈ S_U →
G.Adj ((P a).getVert m) b → m = 1 ∧ b = a.1 := by
intro m b hm1 hm2 hb hadj
have hm_ty : m ≤ t a := by have := (hP_len a).1; omega
have hb_supp : b ∈ (P a).support := hP_adj a m hm1 hm_ty b hadj
obtain ⟨j, hj, rfl⟩ := (mem_support_iff_exists_getVert (P a)).mp hb_supp
rcases Nat.eq_zero_or_pos j with rfl | hj1
· rw [(P a).getVert_zero] at hadj ⊢
have hdm : G.dist a.1 ((P a).getVert m) = m := by
simpa [(P a).getVert_zero] using geodesic_dist_getVert hG (P a) (hP_len a).2 (Nat.zero_le m) hm2
have hd1 : G.dist a.1 ((P a).getVert m) = 1 := dist_eq_one_iff_adj.mpr hadj.symm
exact ⟨by omega, rfl⟩
· exfalso
have hj_ty : j ≤ t a := by have := (hP_len a).1; omega
rcases (hSU_mem _).mp hb with ⟨y, _, heq⟩ | ⟨y, hyU, m', hm'1, hm'2, heq⟩
· exact hP_out a j hj1 hj_ty (heq ▸ y.2)
· exact haU ((hP_inj a y j m' hj1 hj_ty hm'1 hm'2 heq).1 ▸ hyU)
obtain ⟨S, hSTree, hScard, hSeq⟩ :=
insertChain_exists S_U hSU_tree (P a) (hP_len a).2 hG a.1 ha_mem ha_adj hdisj huniq (P a).length (le_refl _)
refine ⟨S, hSTree, ?_, ?_⟩
· rw [hScard, hSU_card, Finset.card_insert_of_notMem haU, ha_len]; ring
· intro u
rw [hSeq, Finset.mem_union, hSU_mem u, Finset.mem_image]
constructor
· rintro ((hK_u | ⟨y, hyU, m, hm1, hm2, rfl⟩) | ⟨m, hmIcc, rfl⟩)
· exact Or.inl hK_u
· exact Or.inr ⟨y, Finset.mem_insert_of_mem hyU, m, hm1, hm2, rfl⟩
· rw [Finset.mem_Icc] at hmIcc
exact Or.inr ⟨a, Finset.mem_insert_self a U, m, hmIcc.1, by have := (hP_len a).1; omega, rfl⟩
· rintro (hK_u | ⟨y, hyIU, m, hm1, hm2, rfl⟩)
· exact Or.inl (Or.inl hK_u)
· rcases Finset.mem_insert.mp hyIU with rfl | hyU
· exact Or.inr ⟨m, Finset.mem_Icc.mpr ⟨hm1, by have := (hP_len y).1; omega⟩, rfl⟩
· exact Or.inl (Or.inr ⟨y, hyU, m, hm1, hm2, rfl⟩)
obtain ⟨S, hSTree, hScard, _⟩ := h_ind T₀ (Finset.Subset.refl T₀)
refine ⟨S, hSTree, ?_⟩
rw [hScard]
ring
private lemma cutVertex_aux :
∀ (n : ℕ) {β : Type u} [Fintype β] [DecidableEq β] [Nonempty β]
(G : SimpleGraph β) [DecidableRel G.Adj],
Fintype.card β = n → G.Connected →
∀ v0 : β, ¬ (G.induce ({v0}ᶜ : Set β)).Connected →
2 * G.radius.toNat ≤ largestInducedTreeSize G := by
intro n
induction n using Nat.strong_induction_on with
| h n ih =>
intro β _ _ _ G _ hcard hG v0 hv0
classical
by_contra hnot
have hlt : largestInducedTreeSize G < 2 * G.radius.toNat := by omega
set r := G.radius.toNat
have hr1 : 1 ≤ r := by
have h1 := one_le_largestInducedTreeSize G
omega
have hrad_eq : r = computable_radius G := by
change G.radius.toNat = computable_radius G
rw [radius_eq_computable G hG]; rfl
have hecc_ge (u : β) : r ≤ computable_eccent G u := by
have hle := G.radius_le_eccent (u := u)
rw [radius_eq_computable G hG, eccent_eq_computable G hG u] at hle
have hle' : computable_radius G ≤ computable_eccent G u := by exact_mod_cast hle
omega
have ih' : ∀ {γ : Type u} [Fintype γ] [DecidableEq γ] [Nonempty γ]
(H : SimpleGraph γ) [DecidableRel H.Adj],
Fintype.card γ < Fintype.card β → H.Connected →
∀ v : γ, ¬ (H.induce ({v}ᶜ : Set γ)).Connected →
2 * H.radius.toNat ≤ largestInducedTreeSize H :=
fun {γ} _ _ _ H _ hlt_c hH v hv => ih (Fintype.card γ) (hcard ▸ hlt_c) H rfl hH v hv
obtain ⟨K, hK, t, endpt, P, hP_len, hy0_pos, hP_out, hP_inj, h_cov, hP_adj, hdist_Kp, hecc_K, ht_ecc⟩ :=
core_pendant_decomposition G hG hlt ih' v0 hv0
let GK := G.induce (K : Set β)
have hK_conn : GK.Connected := isTwoConnected_connected hK
have hK_ne : Nonempty K := hK_conn.nonempty
have : Nonempty (K : Set β) := hK_ne
have hdist_KK : ∀ u y : K, G.dist u.1 y.1 = GK.dist u y := fun u y => by
simpa [(P y).getVert_zero] using hdist_Kp u y 0 (Nat.zero_le (t y))
have hendpt_def : ∀ y : K, endpt y = (P y).getVert (t y) := fun y => by
rw [← (hP_len y).1, (P y).getVert_length]
-- Helper: any walk leaving P y from (P y).getVert m (1 ≤ m ≤ t y) to outside P y \ {y.1} hits y.1
have h_exit_P : ∀ (y : K) {a b : β} (q : G.Walk a b),
(∃ m, 1 ≤ m ∧ m ≤ t y ∧ a = (P y).getVert m) →
(∀ j, 1 ≤ j → j ≤ t y → b ≠ (P y).getVert j) →
∃ k, 1 ≤ k ∧ k ≤ q.length ∧ q.getVert k = y.1 := by
intro y a b q ⟨m, hm1, hm2, ha_eq⟩ hb_out
let B : Set β := {v | ∃ j, 1 ≤ j ∧ j ≤ t y ∧ v = (P y).getVert j}
have haB : a ∈ B := ⟨m, hm1, hm2, ha_eq⟩
have hbB : b ∉ B := fun ⟨j, hj1, hj2, hbj⟩ => hb_out j hj1 hj2 hbj
have hex : ∃ k ≤ q.length, q.getVert k ∉ B :=
⟨q.length, le_refl _, by simpa [q.getVert_length] using hbB⟩
set k := Nat.find hex
have hk_spec : k ≤ q.length ∧ q.getVert k ∉ B := Nat.find_spec hex
have hk_pos : 1 ≤ k := by
by_contra h0; have hk0 : k = 0 := by omega
apply hk_spec.2; rw [hk0, q.getVert_zero]; exact haB
obtain ⟨j0, hj01, hj02, hj0_eq⟩ : q.getVert (k - 1) ∈ B := by
by_contra hnot
exact Nat.find_min hex (m := k - 1) (by omega) ⟨by omega, hnot⟩
have hadj : G.Adj (q.getVert (k - 1)) (q.getVert k) := by
simpa [Nat.sub_add_cancel hk_pos] using q.adj_getVert_succ (by omega : k - 1 < q.length)
rw [hj0_eq] at hadj
have hnext_supp : q.getVert k ∈ (P y).support := hP_adj y j0 hj01 hj02 _ hadj
obtain ⟨j1, hj1, hj1_eq⟩ := (mem_support_iff_exists_getVert (P y)).mp hnext_supp
rcases Nat.eq_zero_or_pos j1 with rfl | hj1_pos
· rw [(P y).getVert_zero] at hj1_eq
exact ⟨k, hk_pos, hk_spec.1, hj1_eq.symm⟩
· exfalso
exact hk_spec.2 ⟨j1, hj1_pos, by have := (hP_len y).1; omega, hj1_eq.symm⟩
-- Helper: centres of G must lie in K
have hcentre_in_K : ∀ z : β, computable_eccent G z ≤ r → z ∈ K := by
intro z hz_ecc
by_contra hzK
rcases h_cov z with h | ⟨y, m, hm1, hm2, rfl⟩
· exact hzK h
· have hy_pos : 1 ≤ t y := by omega
have hy_ecc := ht_ecc y hy_pos
rw [hecc_K y] at hy_ecc
obtain ⟨y', _, hy'_max⟩ :=
Finset.exists_max_image (Finset.univ : Finset K) (fun w => GK.dist y w + t w) Finset.univ_nonempty
have hy_sup : Finset.univ.sup (fun w : K => GK.dist y w + t w) ≤ GK.dist y y' + t y' :=
Finset.sup_le fun w _ => hy'_max w (Finset.mem_univ w)
have h_y_ge : t y + 2 ≤ GK.dist y y' + t y' := by
dsimp only [GK] at hy_sup ⊢
omega
have hy'_ne : y' ≠ y := by
intro heq; subst heq
rw [SimpleGraph.dist_self] at h_y_ge
omega
have hend_out : ∀ j, 1 ≤ j → j ≤ t y → endpt y' ≠ (P y).getVert j := by
intro j hj1 hj2 heq
rw [hendpt_def y'] at heq
rcases Nat.eq_zero_or_pos (t y') with ht0 | ht1
· rw [ht0, (P y').getVert_zero] at heq
exact hP_out y j hj1 hj2 (heq ▸ y'.2)
· exact hy'_ne (hP_inj y' y (t y') j ht1 (le_refl _) hj1 hj2 heq).1
obtain ⟨q, hq⟩ := hG.exists_walk_length_eq_dist ((P y).getVert m) (endpt y')
obtain ⟨k, hk1, hk2, hk_eq⟩ := h_exit_P y q ⟨m, hm1, hm2, rfl⟩ hend_out
have hm_len : m ≤ (P y).length := by have := (hP_len y).1; omega
have hdm : G.dist y.1 ((P y).getVert m) = m := by
simpa [(P y).getVert_zero] using geodesic_dist_getVert hG (P y) (hP_len y).2 (Nat.zero_le m) hm_len
have hd_prev : G.dist ((P y).getVert m) y.1 = k := by
simpa [hk_eq, q.getVert_zero] using geodesic_dist_getVert hG q hq (Nat.zero_le k) hk2
have hd_next : G.dist y.1 (endpt y') = q.length - k := by
simpa [hk_eq, q.getVert_length] using geodesic_dist_getVert hG q hq hk2 (le_refl _)
have hy'end : G.dist y.1 (endpt y') = GK.dist y y' + t y' := by
rw [hendpt_def y']; exact hdist_Kp y y' (t y') (le_refl _)
have h_dist_le : G.dist ((P y).getVert m) (endpt y') ≤ computable_eccent G ((P y).getVert m) := by
rw [dist_eq_computable]
exact Finset.le_sup (f := fun w => computable_dist G ((P y).getVert m) w) (Finset.mem_univ _)
have h_ecc_y := hecc_ge y.1
rw [hecc_K y] at h_ecc_y
have h_sup_le : Finset.univ.sup (fun w : K => (G.induce (K : Set β)).dist y w + t w) ≤ GK.dist y y' + t y' := by
dsimp only [GK]; exact hy_sup
rw [G.dist_comm (u := (P y).getVert m) (v := y.1), hdm] at hd_prev
omega
-- Part 3: Every core vertex has positive pendant length (1 ≤ t y)
have ht_pos : ∀ y : K, 1 ≤ t y := by
have h_no_zero_adj : ∀ a b : K, GK.Adj a b → t a = 0 → 1 ≤ t b → False := by
intro a b hadj_ab hta htb
have hab_ne : a.1 ≠ b.1 := fun heq => hadj_ab.ne (Subtype.ext heq)
let Va : Set β := {a.1}ᶜ
let Ga : SimpleGraph Va := G.induce Va
have hVa_ne : Nonempty Va := ⟨⟨b.1, hab_ne.symm⟩⟩
have hGa_conn : Ga.Connected := by
have hKa_conn := hK.2 a.1 a.2
let fKa : G.induce ((K.erase a.1 : Finset β) : Set β) →g Ga :=
{ toFun := fun u => ⟨u.1, (Finset.mem_erase.mp (Finset.mem_coe.mp u.2)).1⟩
map_rel' := fun h => h }
have h_reach_b : ∀ x : Va, Ga.Reachable ⟨b.1, hab_ne.symm⟩ x := by
intro ⟨x, hx⟩
by_cases hxK : x ∈ K
· have hx_mem : x ∈ K.erase a.1 := Finset.mem_erase.mpr ⟨hx, hxK⟩
have hb_mem : b.1 ∈ K.erase a.1 := Finset.mem_erase.mpr ⟨hab_ne.symm, b.2⟩
exact (hKa_conn.preconnected ⟨b.1, hb_mem⟩ ⟨x, hx_mem⟩).map fKa
· rcases h_cov x with h | ⟨y, m, hm1, hm2, rfl⟩
· exact absurd h hxK
· have hy_ne_a : y ≠ a := by intro heq; subst heq; omega
have hpy_sub : ∀ j ≤ m, (P y).getVert j ∈ Va := by
intro j hj
rcases Nat.eq_zero_or_pos j with rfl | hj1
· rw [(P y).getVert_zero]; exact fun heq => hy_ne_a (Subtype.ext heq)
· exact fun heq => hP_out y j hj1 (by omega) (heq ▸ a.2)
have hreach_yx := walk_reach_induce_prefix (P y) m (by have := (hP_len y).1; omega) hpy_sub
have hy_eq : (⟨(P y).getVert 0, hpy_sub 0 (Nat.zero_le _)⟩ : Va) =
⟨y.1, fun heq => hy_ne_a (Subtype.ext heq)⟩ :=
Subtype.ext (P y).getVert_zero
rw [hy_eq] at hreach_yx
have hy_mem : y.1 ∈ K.erase a.1 :=
Finset.mem_erase.mpr ⟨fun heq => hy_ne_a (Subtype.ext heq), y.2⟩
have hb_mem : b.1 ∈ K.erase a.1 := Finset.mem_erase.mpr ⟨hab_ne.symm, b.2⟩
have hby : Ga.Reachable ⟨b.1, hab_ne.symm⟩ ⟨y.1, fun heq => hy_ne_a (Subtype.ext heq)⟩ :=
(hKa_conn.preconnected ⟨b.1, hb_mem⟩ ⟨y.1, hy_mem⟩).map fKa
exact hby.trans hreach_yx
exact ⟨fun u v => (h_reach_b u).symm.trans (h_reach_b v)⟩
have hb_cut : ¬ (Ga.induce ({(⟨b.1, hab_ne.symm⟩ : Va)}ᶜ : Set Va)).Connected := by
intro hbc
have hKc_card : 1 ≤ ((K.erase a.1).erase b.1).card := by
rw [Finset.card_erase_of_mem (Finset.mem_erase.mpr ⟨hab_ne.symm, b.2⟩),
Finset.card_erase_of_mem a.2]
have := hK.1; omega
obtain ⟨c, hc⟩ := Finset.card_pos.mp hKc_card
have hcb : c ≠ b.1 := (Finset.mem_erase.mp hc).1
have hca : c ≠ a.1 := (Finset.mem_erase.mp (Finset.mem_of_mem_erase hc)).1
have hcK : c ∈ K := Finset.mem_of_mem_erase (Finset.mem_of_mem_erase hc)
have hend_out : endpt b ∉ K := by
rw [hendpt_def b]; exact hP_out b (t b) htb (le_refl _)
have hend_a : endpt b ≠ a.1 := fun h => hend_out (h ▸ a.2)
have hend_b : endpt b ≠ b.1 := fun h => hend_out (h ▸ b.2)
have hreach := hbc.preconnected
⟨⟨endpt b, hend_a⟩, fun h => hend_b (congrArg Subtype.val h)⟩
⟨⟨c, hca⟩, fun h => hcb (congrArg Subtype.val h)⟩
obtain ⟨w⟩ := hreach
let f : (Ga.induce ({(⟨b.1, hab_ne.symm⟩ : Va)}ᶜ : Set Va)) →g G :=
{ toFun := fun u => u.1.1, map_rel' := fun h => h }
let wG := w.map f
have hc_out : ∀ j, 1 ≤ j → j ≤ t b → c ≠ (P b).getVert j := fun j hj1 hj2 heq =>
hP_out b j hj1 hj2 (heq ▸ hcK)
obtain ⟨k, _, hk2, hk_eq⟩ :=
h_exit_P b wG ⟨t b, htb, le_refl _, hendpt_def b⟩ hc_out
have hmem : wG.getVert k ∈ wG.support := (mem_support_iff_exists_getVert wG).mpr ⟨k, hk2, rfl⟩
simp only [wG, Walk.support_map, List.mem_map] at hmem
obtain ⟨u', _, hu'eq⟩ := hmem
exact u'.2 (Subtype.ext (hu'eq.trans hk_eq))
have hVa_lt : Fintype.card Va < Fintype.card β := by
have hcardVa : Fintype.card Va = (Finset.univ.erase a.1).card := by
rw [Fintype.card_subtype]; congr 1; ext z; simp [Va, and_comm]
rw [hcardVa, Finset.card_erase_of_mem (Finset.mem_univ a.1)]
exact Nat.sub_lt Fintype.card_pos Nat.zero_lt_one
have h_rad_lt : Ga.radius.toNat < r := by
have ihGa := ih' Ga hVa_lt hGa_conn ⟨b.1, hab_ne.symm⟩ hb_cut
have hmono := card_largestInducedTreeSize_induce_le G Va
have hle : 2 * Ga.radius.toNat ≤ largestInducedTreeSize G := le_trans ihGa hmono
have hlt' : largestInducedTreeSize G < 2 * r := hlt
omega
obtain ⟨v, _, hv_dist_a, hv_dist_ne, hv_ecc⟩ :=
radius_drop_unique_farthest G hG a.1 hVa_ne hGa_conn h_rad_lt
have hvK := hcentre_in_K v (le_of_eq hv_ecc)
let va : K := ⟨v, hvK⟩
have hend_out : endpt b ∉ K := by
rw [hendpt_def b]; exact hP_out b (t b) htb (le_refl _)
have hend_ne_a : endpt b ≠ a.1 := fun h => hend_out (h ▸ a.2)
have h1 := hv_dist_ne (endpt b) hend_ne_a
have h2 : G.dist v (endpt b) = GK.dist va b + t b := by
rw [hendpt_def b]; exact hdist_Kp va b (t b) (le_refl _)
have h3 : GK.dist va a = r := by
rw [← hdist_KK va a]; exact hv_dist_a
have htri : GK.dist va a ≤ GK.dist va b + GK.dist b a := hK_conn.dist_triangle
have hba1 : GK.dist b a = 1 := dist_eq_one_iff_adj.mpr hadj_ab.symm
omega
obtain ⟨y0, hy0⟩ := hy0_pos
intro y
obtain ⟨w⟩ := hK_conn.preconnected y0 y
induction w with
| nil => exact hy0
| @cons u v _ hadj _ ihw =>
apply ihw
by_contra h0
have hv0 : t v = 0 := by omega
exact h_no_zero_adj v u hadj.symm hv0 ‹1 ≤ t u›
-- Part 4: All pendant paths have the same length L ≥ 1
have ht_adj_le : ∀ a b : K, GK.Adj a b → t b ≤ t a := by
intro a b hadj_ab
have hta : 1 ≤ t a := ht_pos a
have htb : 1 ≤ t b := ht_pos b
have hab_ne : a ≠ b := hadj_ab.ne
let za := endpt a
have hza_out : za ∉ K := by
dsimp only [za]; rw [hendpt_def a]; exact hP_out a (t a) hta (le_refl _)
let Vz : Set β := {za}ᶜ
let Gz : SimpleGraph Vz := G.induce Vz
have hVz_ne : Nonempty Vz := ⟨⟨a.1, fun h => hza_out (h ▸ a.2)⟩⟩
have hGz_conn : Gz.Connected := by
let fK : GK →g Gz :=
{ toFun := fun u => ⟨u.1, fun h => hza_out (h ▸ u.2)⟩
map_rel' := fun h => h }
have hreach_a : ∀ x : Vz, Gz.Reachable ⟨a.1, fun h => hza_out (h ▸ a.2)⟩ x := by
intro ⟨x, hx⟩
by_cases hxK : x ∈ K
· exact (hK_conn.preconnected a ⟨x, hxK⟩).map fK
· rcases h_cov x with h | ⟨y, m, hm1, hm2, rfl⟩
· exact absurd h hxK
· by_cases hya : y = a
· subst hya
have hm_lt : m < t y := by
by_contra hge
have hmeq : m = t y := by omega
exact hx (Set.mem_singleton_iff.mpr (by rw [hmeq, ← hendpt_def y]))
have hsub : ∀ j ≤ m, (P y).getVert j ∈ Vz := by
intro j hj heq
simp only [Set.mem_singleton_iff] at heq
dsimp only [za] at heq
have hd1 : G.dist y.1 ((P y).getVert j) = j := by
simpa [(P y).getVert_zero] using
geodesic_dist_getVert hG (P y) (hP_len y).2 (Nat.zero_le j) (by have := (hP_len y).1; omega)
have hd2 : G.dist y.1 (endpt y) = t y := by
have h1 := (hP_len y).1
have h2 := (hP_len y).2
omega
rw [heq, hd2] at hd1
omega
have hry := walk_reach_induce_prefix (P y) m (by have := (hP_len y).1; omega) hsub
have h0_eq : (⟨(P y).getVert 0, hsub 0 (Nat.zero_le _)⟩ : Vz) =
⟨y.1, fun h => hza_out (h ▸ y.2)⟩ := Subtype.ext (P y).getVert_zero
rw [h0_eq] at hry
exact hry
· have hsub : ∀ j ≤ m, (P y).getVert j ∈ Vz := by
intro j hj heq
simp only [Set.mem_singleton_iff] at heq
dsimp only [za] at heq
rcases Nat.eq_zero_or_pos j with rfl | hj1
· rw [(P y).getVert_zero] at heq
dsimp only [za] at hza_out
exact hza_out (heq ▸ y.2)
· rw [hendpt_def a] at heq
exact hya (hP_inj y a j (t a) hj1 (by omega) hta (le_refl _) heq).1
have hry := walk_reach_induce_prefix (P y) m (by have := (hP_len y).1; omega) hsub
have h0_eq : (⟨(P y).getVert 0, hsub 0 (Nat.zero_le _)⟩ : Vz) =
⟨y.1, fun h => hza_out (h ▸ y.2)⟩ := Subtype.ext (P y).getVert_zero
rw [h0_eq] at hry
exact ((hK_conn.preconnected a y).map fK).trans hry
exact ⟨fun u v => (hreach_a u).symm.trans (hreach_a v)⟩
have hc_cut_Gz : ¬ (Gz.induce ({(⟨b.1, fun h => hza_out (h ▸ b.2)⟩ : Vz)}ᶜ : Set Vz)).Connected := by
intro hbc
have hzb_out : endpt b ∉ K := by
rw [hendpt_def b]; exact hP_out b (t b) htb (le_refl _)
have hzb_za : endpt b ≠ za := by
intro heq
dsimp only [za] at heq
rw [hendpt_def b, hendpt_def a] at heq
exact hab_ne (hP_inj b a (t b) (t a) htb (le_refl _) hta (le_refl _) heq).1.symm
have hzb_b : endpt b ≠ b.1 := fun h => hzb_out (h ▸ b.2)
have hreach := hbc.preconnected
⟨⟨endpt b, hzb_za⟩, fun h => hzb_b (congrArg Subtype.val h)⟩
⟨⟨a.1, fun h => hza_out (h ▸ a.2)⟩,
fun h => by simp only [Set.mem_singleton_iff, Subtype.mk.injEq] at h; exact hab_ne (Subtype.ext h)⟩
obtain ⟨w⟩ := hreach
let f : (Gz.induce ({(⟨b.1, fun h => hza_out (h ▸ b.2)⟩ : Vz)}ᶜ : Set Vz)) →g G :=
{ toFun := fun u => u.1.1, map_rel' := fun h => h }
let wG := w.map f
have ha_out : ∀ j, 1 ≤ j → j ≤ t b → a.1 ≠ (P b).getVert j := fun j hj1 hj2 heq =>
hP_out b j hj1 hj2 (heq ▸ a.2)
obtain ⟨k, _, hk2, hk_eq⟩ := h_exit_P b wG ⟨t b, htb, le_refl _, hendpt_def b⟩ ha_out
have hmem : wG.getVert k ∈ wG.support := (mem_support_iff_exists_getVert wG).mpr ⟨k, hk2, rfl⟩
simp only [wG, Walk.support_map, List.mem_map] at hmem
obtain ⟨u', _, hu'eq⟩ := hmem
exact u'.2 (Subtype.ext (hu'eq.trans hk_eq))
have hVz_lt : Fintype.card Vz < Fintype.card β := by
have hcardVz : Fintype.card Vz = (Finset.univ.erase za).card := by
rw [Fintype.card_subtype]; congr 1; ext z; simp [Vz, and_comm]
rw [hcardVz, Finset.card_erase_of_mem (Finset.mem_univ za)]
exact Nat.sub_lt Fintype.card_pos Nat.zero_lt_one
have h_rad_lt : Gz.radius.toNat < r := by
have ihGz := ih' Gz hVz_lt hGz_conn ⟨b.1, fun h => hza_out (h ▸ b.2)⟩ hc_cut_Gz
have hmono := card_largestInducedTreeSize_induce_le G Vz
have hle : 2 * Gz.radius.toNat ≤ largestInducedTreeSize G := le_trans ihGz hmono
have hlt' : largestInducedTreeSize G < 2 * r := hlt
omega
obtain ⟨v, _, hv_dist_za, hv_dist_ne, hv_ecc⟩ :=
radius_drop_unique_farthest G hG za hVz_ne hGz_conn h_rad_lt
have hvK := hcentre_in_K v (le_of_eq hv_ecc)
let va : K := ⟨v, hvK⟩
have hzb_out : endpt b ∉ K := by
rw [hendpt_def b]; exact hP_out b (t b) htb (le_refl _)
have hzb_za : endpt b ≠ za := by
intro heq
dsimp only [za] at heq
rw [hendpt_def b, hendpt_def a] at heq
exact hab_ne (hP_inj b a (t b) (t a) htb (le_refl _) hta (le_refl _) heq).1.symm
have h1 := hv_dist_ne (endpt b) hzb_za
have h2 : G.dist v (endpt b) = GK.dist va b + t b := by
rw [hendpt_def b]; exact hdist_Kp va b (t b) (le_refl _)
have h3 : G.dist v za = GK.dist va a + t a := by
dsimp only [za]; rw [hendpt_def a]; exact hdist_Kp va a (t a) (le_refl _)
have htri : GK.dist va a ≤ GK.dist va b + GK.dist b a := hK_conn.dist_triangle
have hba1 : GK.dist b a = 1 := dist_eq_one_iff_adj.mpr hadj_ab.symm
omega
obtain ⟨a0⟩ := hK_ne
set L := t a0
have hL1 : 1 ≤ L := ht_pos a0
have htL : ∀ y : K, t y = L := by
have h_const : ∀ {u v : K}, GK.Adj u v → t u = t v := fun {u v} huv =>
le_antisymm (ht_adj_le v u huv.symm) (ht_adj_le u v huv)
have h_reach : ∀ {u v : K}, GK.Reachable u v → t u = t v := by
intro u v ⟨w⟩
induction w with
| nil => rfl
| cons hadj _ ihw => exact (h_const hadj).trans ihw
intro y
exact (h_reach (hK_conn.preconnected a0 y)).symm
-- Part 5: Construct the induced tree of order ≥ 2 * r
set s := GK.radius.toNat
have hr_eq_sL : r = s + L := by
have hs_eq : s = computable_radius GK := by
change GK.radius.toNat = computable_radius GK
rw [radius_eq_computable GK hK_conn]; rfl
have hecc_GK : ∀ u : K, computable_eccent G u.1 = computable_eccent GK u + L := by
intro u
rw [hecc_K u]
apply le_antisymm
· apply Finset.sup_le
intro y _
rw [htL y]
have hle : GK.dist u y ≤ computable_eccent GK u := by
rw [dist_eq_computable]
exact Finset.le_sup (f := fun z => computable_dist GK u z) (Finset.mem_univ y)
dsimp only [GK] at hle ⊢
omega
· obtain ⟨y, _, hy_max⟩ :=
Finset.exists_max_image (Finset.univ : Finset K) (fun w => computable_dist GK u w)
Finset.univ_nonempty
have h_sup : computable_eccent GK u ≤ computable_dist GK u y := by
unfold computable_eccent
exact Finset.sup_le fun w _ => hy_max w (Finset.mem_univ w)
rw [← dist_eq_computable] at h_sup
have h_le2 := Finset.le_sup (f := fun w : K => (G.induce (K : Set β)).dist u w + t w) (Finset.mem_univ y)
rw [htL y] at h_le2
dsimp only [GK] at h_sup ⊢
omega
obtain ⟨u_c, _, hu_c_min⟩ :=
Finset.exists_min_image (Finset.univ : Finset K) (fun u => computable_eccent GK u)
Finset.univ_nonempty
have hs_att : computable_radius GK = computable_eccent GK u_c :=
le_antisymm (Finset.inf'_le _ (Finset.mem_univ u_c)) (Finset.le_inf' _ _ fun u hu => hu_c_min u hu)
obtain ⟨v_c, _, hv_c_min⟩ :=
Finset.exists_min_image (Finset.univ : Finset β) (fun v => computable_eccent G v)
Finset.univ_nonempty
have hr_att : computable_radius G = computable_eccent G v_c :=
le_antisymm (Finset.inf'_le _ (Finset.mem_univ v_c)) (Finset.le_inf' _ _ fun v hv => hv_c_min v hv)
have hv_cK : v_c ∈ K := hcentre_in_K v_c (by omega)
have h1 : computable_radius G ≤ computable_eccent G u_c.1 := Finset.inf'_le _ (Finset.mem_univ u_c.1)
have h2 : computable_radius GK ≤ computable_eccent GK ⟨v_c, hv_cK⟩ := Finset.inf'_le _ (Finset.mem_univ _)
rw [hecc_GK u_c, ← hs_att] at h1
have h3 := hecc_GK ⟨v_c, hv_cK⟩
dsimp only at h3
omega
have hs1 : 1 ≤ s := by
by_contra h0
have hs0 : s = 0 := by omega
have hs_eq : s = computable_radius GK := by
change GK.radius.toNat = computable_radius GK
rw [radius_eq_computable GK hK_conn]; rfl
obtain ⟨u_c, _, hu_c_min⟩ :=
Finset.exists_min_image (Finset.univ : Finset K) (fun u => computable_eccent GK u)
Finset.univ_nonempty
have hs_att : computable_radius GK = computable_eccent GK u_c :=
le_antisymm (Finset.inf'_le _ (Finset.mem_univ u_c)) (Finset.le_inf' _ _ fun u hu => hu_c_min u hu)
obtain ⟨a1, _, ha1_ne, _, _, hadj1, _⟩ := isTwoConnected_two_neighbors hK u_c.2
have ha1K : (⟨a1.1, a1.2⟩ : K) ≠ u_c := fun h => ha1_ne (congrArg Subtype.val h)
have hle : GK.dist u_c ⟨a1.1, a1.2⟩ ≤ computable_eccent GK u_c := by
rw [dist_eq_computable]
exact Finset.le_sup (f := fun z => computable_dist GK u_c z) (Finset.mem_univ _)
have hpos : 1 ≤ GK.dist u_c ⟨a1.1, a1.2⟩ :=
Nat.pos_of_ne_zero fun hz => ha1K ((hK_conn.dist_eq_zero_iff).mp hz).symm
omega
by_cases hs_eq1 : s = 1
· obtain ⟨a1, _, ha1_ne, _, _, hadj1, _⟩ := isTwoConnected_two_neighbors hK a0.2
let b0 : K := ⟨a1.1, a1.2⟩
have hadj_ab : GK.Adj a0 b0 := hadj1
let w : GK.Walk a0 b0 := Walk.cons hadj_ab .nil
have hw_geod : w.length = GK.dist a0 b0 := by
rw [Walk.length_cons, Walk.length_nil, dist_eq_one_iff_adj.mpr hadj_ab]
have hT₀ : (GK.induce (w.support.toFinset : Set K)).IsTree :=
Walk.induce_support_isTree_of_length_eq_dist w hw_geod
have hT₀_card : w.support.toFinset.card = 2 := by
have hnod := (w.isPath_of_length_eq_dist hw_geod).support_nodup
rw [List.toFinset_card_of_nodup hnod, Walk.length_support, Walk.length_cons, Walk.length_nil]
obtain ⟨S, hSTree, hScard⟩ :=
attach_pendants G hG K t endpt P hP_len hP_out hP_inj hP_adj L hL1 htL w.support.toFinset hT₀
have hbound := card_le_largestInducedTreeSize hSTree
rw [hT₀_card] at hScard
have hlt' : largestInducedTreeSize G < 2 * r := hlt
omega
· have hs2 : 2 ≤ s := by omega
have hchung := chung_aux (Fintype.card K) GK rfl hK_conn
let TF : Finset (Finset K) := Finset.univ.filter (fun T : Finset K => (GK.induce (T : Set K)).IsTree)
have hnil_eq : (Walk.nil : GK.Walk a0 a0).support.toFinset = ({a0} : Finset K) := by simp
have hnil_tree : (GK.induce (({a0} : Finset K) : Set K)).IsTree := by
rw [← hnil_eq]
exact Walk.induce_support_isTree_of_length_eq_dist Walk.nil (by simp)
have htree_ne : TF.Nonempty :=
⟨({a0} : Finset K), Finset.mem_filter.mpr ⟨Finset.mem_univ _, hnil_tree⟩⟩
obtain ⟨T₀, hT₀_mem, hT₀_max⟩ := Finset.exists_max_image TF Finset.card htree_ne
have hT₀ : (GK.induce (T₀ : Set K)).IsTree := (Finset.mem_filter.mp hT₀_mem).2
have hT₀_card : largestInducedTreeSize GK ≤ T₀.card := by
unfold largestInducedTreeSize
by_cases hne : ({n : ℕ | ∃ s : Finset K, s.card = n ∧ (GK.induce (s : Set K)).IsTree}).Nonempty
· apply csSup_le hne
rintro m ⟨T, rfl, hT⟩
exact hT₀_max T (Finset.mem_filter.mpr ⟨Finset.mem_univ T, hT⟩)
· exfalso
exact hne ⟨1, {a0}, rfl, hnil_tree⟩
obtain ⟨S, hSTree, hScard⟩ :=
attach_pendants G hG K t endpt P hP_len hP_out hP_inj hP_adj L hL1 htL T₀ hT₀
have hbound := card_le_largestInducedTreeSize hSTree
have hcalc : 2 * (s + L) ≤ T₀.card * (L + 1) := by
have hs_def : s = GK.radius.toNat := rfl
have h1 : 2 * s ≤ T₀.card + 1 := by omega
have h2 : 2 * s * (L + 1) ≤ (T₀.card + 1) * (L + 1) := Nat.mul_le_mul_right (L + 1) h1
have h3 : 4 * L ≤ 2 * s * L := Nat.mul_le_mul_right L (by omega : 4 ≤ 2 * s)
nlinarith
have hlt' : largestInducedTreeSize G < 2 * r := hlt
omega
end CutVertexHelpers
/-- Intermediate lemma (nosorry): Left open by partial proof s-zg5h4dgpr5. -/
theorem two_mul_radius_le_largestInducedTreeSize_of_cutVertex (G : SimpleGraph α) [DecidableRel G.Adj] (h : G.Connected)
(v : α) (_hv : ¬ (G.induce ({v}ᶜ : Set α)).Connected) :
2 * G.radius.toNat ≤ largestInducedTreeSize G :=
cutVertex_aux (Fintype.card α) G rfl h v _hv
private lemma radius_toNat_add_one_le_largestInducedTreeSize
(G : SimpleGraph α) [DecidableRel G.Adj] (h : G.Connected) :
G.radius.toNat + 1 ≤ largestInducedTreeSize G := by
let u0 : α := Classical.choice inferInstance
have hrad_le_ecc : G.radius.toNat ≤ computable_eccent G u0 := by
have hle : G.radius ≤ G.eccent u0 := G.radius_le_eccent
rw [radius_eq_computable G h, eccent_eq_computable G h u0] at hle
have hle' : computable_radius G ≤ computable_eccent G u0 := by exact_mod_cast hle
have hrad_eq : G.radius.toNat = computable_radius G := by
rw [radius_eq_computable G h]
rfl
omega
obtain ⟨v, -, hv⟩ := Finset.exists_mem_eq_sup Finset.univ Finset.univ_nonempty
(fun v => computable_dist G u0 v)
have hecc_eq : computable_eccent G u0 = G.dist u0 v := by
have hv' : computable_eccent G u0 = computable_dist G u0 v := hv
rw [hv', ← dist_eq_computable]
obtain ⟨p, hp_path, hp_len⟩ := h.exists_path_of_dist u0 v
have hT : (G.induce (p.support.toFinset : Set α)).IsTree :=
Walk.induce_support_isTree_of_length_eq_dist p hp_len
have hcard_le : p.support.toFinset.card ≤ largestInducedTreeSize G :=
card_le_largestInducedTreeSize hT
have hcard_eq : p.support.toFinset.card = p.length + 1 := by
rw [List.toFinset_card_of_nodup hp_path.support_nodup, p.length_support]
omega
private lemma two_mul_radius_le_largestInducedTreeSize_of_card_eq_two
(G : SimpleGraph α) [DecidableRel G.Adj] (h : G.Connected) (hcard : Fintype.card α = 2) :
2 * G.radius.toNat ≤ largestInducedTreeSize G := by
obtain ⟨u, v, huv⟩ := exists_pair_ne α
have huniv : (Finset.univ : Finset α) = {u, v} := by
refine (Finset.eq_of_subset_of_card_le (Finset.subset_univ {u, v}) ?_).symm
rw [Finset.card_univ, hcard, Finset.card_pair huv]
have hadj : G.Adj u v := by
obtain ⟨p⟩ := h u v
cases p with
| nil => exact (huv rfl).elim
| @cons _ z _ huz _ =>
have hz_mem : z ∈ ({u, v} : Finset α) := huniv ▸ Finset.mem_univ z
rcases Finset.mem_insert.mp hz_mem with rfl | hz
· exact (huz.ne rfl).elim
· rw [Finset.mem_singleton.mp hz] at huz
exact huz
have hdist_le : ∀ x y : α, G.dist x y ≤ 1 := by
intro x y
by_cases hxy : x = y
· subst hxy
simp
· have hx_mem : x ∈ ({u, v} : Finset α) := huniv ▸ Finset.mem_univ x
have hy_mem : y ∈ ({u, v} : Finset α) := huniv ▸ Finset.mem_univ y
have hadj_xy : G.Adj x y := by
rcases Finset.mem_insert.mp hx_mem with rfl | hx <;>
rcases Finset.mem_insert.mp hy_mem with rfl | hy
· exact (hxy rfl).elim
· rw [Finset.mem_singleton.mp hy]; exact hadj
· rw [Finset.mem_singleton.mp hx]; exact hadj.symm
· rw [Finset.mem_singleton.mp hx, Finset.mem_singleton.mp hy] at hxy
exact (hxy rfl).elim
exact (G.dist_le (Walk.cons hadj_xy Walk.nil)).trans (by simp)
have hecc_le : computable_eccent G u ≤ 1 := by
apply Finset.sup_le
intro w _
rw [← dist_eq_computable]
exact hdist_le u w
have hrad_le : G.radius.toNat ≤ 1 := by
have hle : G.radius ≤ G.eccent u := G.radius_le_eccent
rw [radius_eq_computable G h, eccent_eq_computable G h u] at hle
have hle' : computable_radius G ≤ computable_eccent G u := by exact_mod_cast hle
have hrad_eq : G.radius.toNat = computable_radius G := by
rw [radius_eq_computable G h]
rfl
omega
have hdist_uv : (Walk.cons hadj (Walk.nil : G.Walk v v)).length = G.dist u v := by
have hpos : 0 < G.dist u v := (h u v).pos_dist_of_ne huv
have h1 := hdist_le u v
change 1 = G.dist u v
omega
have hT : (G.induce ((Walk.cons hadj (Walk.nil : G.Walk v v)).support.toFinset : Set α)).IsTree :=
Walk.induce_support_isTree_of_length_eq_dist _ hdist_uv
have hcard_le : (Walk.cons hadj (Walk.nil : G.Walk v v)).support.toFinset.card ≤
largestInducedTreeSize G := card_le_largestInducedTreeSize hT
have hsupp_eq : (Walk.cons hadj (Walk.nil : G.Walk v v)).support.toFinset = {u, v} := by
ext x
simp [Walk.support_cons, Walk.support_nil]
have hcard2 : (Walk.cons hadj (Walk.nil : G.Walk v v)).support.toFinset.card = 2 := by
rw [hsupp_eq, Finset.card_pair huv]
omega
omit [DecidableEq α] in
private lemma exists_cutVertex_of_minDegree_eq_one
(G : SimpleGraph α) [DecidableRel G.Adj] (hcard : 3 ≤ Fintype.card α)
(hδ : G.minDegree = 1) :
∃ v : α, ¬ (G.induce ({v}ᶜ : Set α)).Connected := by
classical
obtain ⟨u, hu⟩ := G.exists_minimal_degree_vertex
rw [hδ] at hu
obtain ⟨v, huv, huniq⟩ := degree_eq_one_iff_existsUnique_adj.mp hu.symm
have hwex : ∃ w : α, w ≠ u ∧ w ≠ v := by
by_contra! hall
have hsub : (Finset.univ : Finset α) ⊆ {u, v} := by
intro x _
by_cases hxu : x = u
· simp [hxu]
· simp [hall x hxu]
have hle := Finset.card_le_card hsub
rw [Finset.card_univ] at hle
have h2 : ({u, v} : Finset α).card ≤ 2 := Finset.card_le_two
omega
obtain ⟨w, hwu, hvw⟩ := hwex
refine ⟨v, fun hc => ?_⟩
obtain ⟨q⟩ := hc ⟨u, by simp [huv.ne]⟩ ⟨w, by simp [hvw]⟩
cases q with
| nil => exact hwu rfl
| @cons _ z _ hadj _ =>
have hzv : z.1 = v := huniq z.1 hadj
exact z.2 (by simp [hzv])
/--
WOWII [Conjecture 84](http://cms.uhd.edu/faculty/delavinae/research/wowII/all.html#conj84)
(status O):
For a simple connected graph `G` with positive minimum degree,
`tree(G) ≥ 2 · rad(G) / δ(G)`,
where `tree(G)` is the number of vertices in a largest induced subtree,
`rad(G)` is the radius, and `δ(G) = G.minDegree` is the minimum degree.
The hypothesis `0 < G.minDegree` follows from connectedness on a nontrivial
vertex set, but is stated explicitly so the theorem reads as a real-valued
inequality without `x / 0` corner cases.
-/
@[category research open, AMS 5]
theorem conjecture84 (G : SimpleGraph α) [DecidableRel G.Adj]
(h : G.Connected) (hδ : 0 < G.minDegree) :
2 * (G.radius.toNat : ℝ) / (G.minDegree : ℝ) ≤ (largestInducedTreeSize G : ℝ) := by
by_cases hδ1 : G.minDegree = 1
· rw [hδ1]
norm_num
norm_cast
have h2 : 2 ≤ Fintype.card α := Fintype.one_lt_card
rcases Nat.eq_or_lt_of_le h2 with hcard2 | hcard3
· exact two_mul_radius_le_largestInducedTreeSize_of_card_eq_two G h hcard2.symm
· obtain ⟨v, hv⟩ := exists_cutVertex_of_minDegree_eq_one G hcard3 hδ1
exact two_mul_radius_le_largestInducedTreeSize_of_cutVertex G h v hv
· have hδ2 : 2 ≤ G.minDegree := by omega
have htree : G.radius.toNat + 1 ≤ largestInducedTreeSize G :=
radius_toNat_add_one_le_largestInducedTreeSize G h
have hδ_pos : (0 : ℝ) < (G.minDegree : ℝ) := by exact_mod_cast hδ
rw [div_le_iff₀ hδ_pos]
have hδ2_real : (2 : ℝ) ≤ (G.minDegree : ℝ) := by exact_mod_cast hδ2
have htree_real : (G.radius.toNat : ℝ) + 1 ≤ (largestInducedTreeSize G : ℝ) := by
exact_mod_cast htree
have hrad_nonneg : (0 : ℝ) ≤ (G.radius.toNat : ℝ) := Nat.cast_nonneg _
nlinarith
-- Sanity checks
/-- The `largestInducedTreeSize` is nonneg. -/
@[category test, AMS 5]
example (G : SimpleGraph (Fin 3)) : 0 ≤ largestInducedTreeSize G := Nat.zero_le _
/-- The largest induced tree size is nonneg. -/
@[category test, AMS 5]
example (G : SimpleGraph (Fin 3)) : 0 ≤ (largestInducedTreeSize G : ℝ) :=
Nat.cast_nonneg _
end WrittenOnTheWallII.GraphConjecture84