Lean / Reader
Lean reader

VertexDeletion.lean

162 lines6 declarationsno sorryimports PairPaths

Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports PairPaths, which it does not have: you can read it there, but it will not check. Build the project itself to check it.

  1. import PairPaths
  2. open SimpleGraph SimpleGraph.Walk
  3. namespace TerminalCycles
  4. variable {V : Type*}
  5. /-- The remaining neighbors after passing to an induced graph. -/
  6. theorem induced_valence (G : SimpleGraph V) (U : Set V) (v : U) :
  7. valence (G.induce U) v = (G.neighborSet v.val ∩ U).ncard := by
  8. apply Nat.card_congr
  9. exact {
  10. toFun := fun a => ⟨a.val.val,a.property,a.val.property⟩
  11. invFun := fun a => ⟨⟨a.val,a.property.2⟩,a.property.1⟩
  12. left_inv := fun _ => rfl
  13. right_inv := fun _ => rfl }
  14. /-- If every other neighbor of a common vertex can lose one incidence,
  15. there is a dyadic path between the nonadjacent endpoints avoiding that vertex. -/
  16. theorem dyadic_path_avoiding_common [Finite V] (G : SimpleGraph V) {s t z : V}
  17. (ne : s ≠ t) (missing : ¬ G.Adj s t) (zs : G.Adj z s) (zt : G.Adj z t)
  18. (deg : ∀ v, 3 ≤ valence G v) (absent : ¬ hasPowerCycle G) (minimal : smaller_graphs_have_cycle G)
  19. (spare : ∀ w, G.Adj z w → w ≠ s → w ≠ t → 4 ≤ valence G w) :
  20. ∃ k ≥ 2, ∃ p : G.Walk s t, p.IsPath ∧ p.length = 2^k ∧ z ∉ p.support := by
  21. classical
  22. let U : Set V := {v | v ≠ z}
  23. let H := G.induce U
  24. let a : U := ⟨s,zs.ne.symm⟩
  25. let b : U := ⟨t,zt.ne.symm⟩
  26. let f : H ↪g G := SimpleGraph.Embedding.induce U
  27. have different : a ≠ b := fun he => ne (congrArg Subtype.val he)
  28. have disj : ∀ v, H.Adj v a → H.Adj v b → False := by
  29. intro v vs vt
  30. exact v.property (common_neighbors_unique G ne absent vs.symm vt.symm zs.symm zt.symm)
  31. have diff (v : U) : valence H v = (G.neighborSet v.val \ {z}).ncard := induced_valence G U v
  32. have loss (v : U) : valence G v.val ≤ valence H v + 1 := by
  33. rw [diff]; simpa only [Set.ncard_singleton] using Set.ncard_le_ncard_diff_add_ncard (G.neighborSet v.val) {z}
  34. have ds := deg s
  35. have dt := deg t
  36. have da := loss a
  37. have db := loss b
  38. change valence G s ≤ valence H a + 1 at da
  39. change valence G t ≤ valence H b + 1 at db
  40. have rest (v : U) (va : v ≠ a) (vb : v ≠ b) : 3 ≤ valence H v := by
  41. by_cases hit : G.Adj z v.val
  42. · have h := spare v.val hit (fun eq => va (Subtype.ext eq)) (fun eq => vb (Subtype.ext eq))
  43. have := loss v
  44. omega
  45. · have all : G.neighborSet v.val \ {z} = G.neighborSet v.val := by
  46. ext y
  47. constructor
  48. · exact fun h => h.1
  49. · intro adj
  50. exact ⟨adj,fun eq => hit ((eq ▸ (show G.Adj v.val y from adj)).symm)⟩
  51. rw [diff,all]
  52. exact deg v.val
  53. have size : Nat.card U ≤ Nat.card V := Nat.card_le_card_of_injective Subtype.val Subtype.val_injective
  54. have merged := minimal _ (identify H a b) (lt_of_lt_of_le (identified_strict_size a b different) size)
  55. (identified_minimum H a b missing disj (by omega) (by omega) rest)
  56. obtain ⟨k,hk,p,simple,len⟩ := identification_forces_dyadic_path H a b different (absent_below f absent) merged
  57. refine ⟨k,hk,p.map f.toHom,map_isPath_of_injective f.injective simple,(length_map _ _).trans len,?_⟩
  58. rw [Walk.support_map,List.mem_map]
  59. rintro ⟨v,_,eq⟩
  60. exact v.property eq
  61. /-- An exceptional nonedge must have a cubic common neighbor whose third
  62. neighbor is also cubic. -/
  63. theorem exceptional_nonedge_cubic_edge [Finite V] (G : SimpleGraph V) {s t : V}
  64. (ne : s ≠ t) (missing : ¬ G.Adj s t) (deg : ∀ v, 3 ≤ valence G v)
  65. (absent : ¬ hasPowerCycle G) (minimal : smaller_graphs_have_cycle G)
  66. (fail : ¬ ∃ k ≥ 2, ∃ p : G.Walk s t, p.IsPath ∧ p.length = 2^k) :
  67. ∃ z w, G.Adj z s ∧ G.Adj z t ∧ valence G z = 3 ∧ G.Adj z w ∧
  68. w ≠ s ∧ w ≠ t ∧ valence G w = 3 := by
  69. have shared : ∃ z, G.Adj z s ∧ G.Adj z t ∧ valence G z = 3 := by
  70. by_contra no
  71. apply fail (dyadic_path_unless_cubic_common G ne deg absent minimal ?_)
  72. intro v vs vt
  73. have bound := deg v
  74. have neq : valence G v ≠ 3 := fun h => no ⟨v,vs,vt,h⟩
  75. omega
  76. obtain ⟨z,zs,zt,three⟩ := shared
  77. by_contra no
  78. have spare (w : V) (zw : G.Adj z w) (ws : w ≠ s) (wt : w ≠ t) : 4 ≤ valence G w := by
  79. have bound := deg w
  80. have neq : valence G w ≠ 3 := fun h => no ⟨z,w,zs,zt,three,zw,ws,wt,h⟩
  81. omega
  82. obtain ⟨k,hk,p,simple,len,_⟩ := dyadic_path_avoiding_common G ne missing zs zt deg absent minimal spare
  83. exact fail ⟨k,hk,p,simple,len⟩
  84. noncomputable def exceptionalNonedges [Fintype V] (G : SimpleGraph V) : Finset (Finset V) := by
  85. classical
  86. exact (exceptionalPairs G).filter (fun P => ∀ s ∈ P, ∀ t ∈ P, ¬ G.Adj s t)
  87. /-- The nonadjacent exceptional pairs can be charged to oriented edges of
  88. the subgraph on cubic vertices, with at most one pair per orientation. -/
  89. theorem exceptional_nonedge_bound [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj]
  90. (deg : ∀ v, 3 ≤ valence G v) (absent : ¬ hasPowerCycle G) (minimal : smaller_graphs_have_cycle G) :
  91. let C := Finset.univ.filter (fun v => valence G v = 3)
  92. (exceptionalNonedges G).card ≤ ∑ v ∈ C, ((G.neighborFinset v).filter (fun w => valence G w = 3)).card := by
  93. classical
  94. let C := Finset.univ.filter (fun v => valence G v = 3)
  95. let out := fun v : V => (G.neighborFinset v).filter (fun w => valence G w = 3)
  96. let wedge := fun v : V => (out v).image (fun w => (G.neighborFinset v).erase w)
  97. have sub : exceptionalNonedges G ⊆ C.biUnion wedge := by
  98. intro P hP
  99. simp only [exceptionalNonedges,Finset.mem_filter] at hP
  100. obtain ⟨pair,noEdges⟩ := hP
  101. simp only [exceptionalPairs,Finset.mem_filter] at pair
  102. obtain ⟨size,s,t,rfl,ne,fail⟩ := pair
  103. have no := noEdges s (by simp) t (by simp)
  104. obtain ⟨z,w,zs,zt,cz,zw,ws,wt,cw⟩ := exceptional_nonedge_cubic_edge G ne no deg absent minimal fail
  105. have win := (G.mem_neighborFinset _ _).mpr zw
  106. apply Finset.mem_biUnion.mpr
  107. refine ⟨z,by simp [C,cz],Finset.mem_image.mpr ⟨w,Finset.mem_filter.mpr ⟨win,cw⟩,?_⟩⟩
  108. symm
  109. apply Finset.eq_of_subset_of_card_le
  110. · intro u hu
  111. rcases Finset.mem_insert.mp hu with rfl|hu
  112. · exact Finset.mem_erase.mpr ⟨ws.symm,(G.mem_neighborFinset _ _).mpr zs⟩
  113. · obtain rfl := Finset.mem_singleton.mp hu
  114. exact Finset.mem_erase.mpr ⟨wt.symm,(G.mem_neighborFinset _ _).mpr zt⟩
  115. · have hsize := (Finset.mem_powersetCard.mp size).2
  116. rw [Finset.card_erase_of_mem win,G.card_neighborFinset_eq_degree,← valence_eq_degree,cz]
  117. omega
  118. calc
  119. (exceptionalNonedges G).card ≤ (C.biUnion wedge).card := Finset.card_le_card sub
  120. _ ≤ ∑ v ∈ C, (wedge v).card := Finset.card_biUnion_le
  121. _ ≤ ∑ v ∈ C, (out v).card := Finset.sum_le_sum (fun _ _ => Finset.card_image_le)
  122. /-- Every pair separated by a vertex of degree at least four has a dyadic
  123. path through that vertex. Its two pieces have lengths summing to the same power. -/
  124. theorem separated_pair_dyadic_path [Finite V] (G : SimpleGraph V) (c : V)
  125. (a b : {v : V // v ≠ c})
  126. (apart : ¬ (G.induce {v | v ≠ c}).Reachable a b) (four : 4 ≤ valence G c)
  127. (deg : ∀ v, 3 ≤ valence G v) (absent : ¬ hasPowerCycle G) (minimal : smaller_graphs_have_cycle G) :
  128. ∃ k ≥ 2, ∃ p : G.Walk a.val b.val, p.IsPath ∧ p.length = 2^k ∧
  129. ∃ (l : G.Walk a.val c) (r : G.Walk c b.val), l.IsPath ∧ r.IsPath ∧ l.append r = p := by
  130. classical
  131. let U : Set V := {v | v ≠ c}
  132. have diff : a.val ≠ b.val := by
  133. intro eq
  134. obtain rfl : a=b := Subtype.ext eq
  135. exact apart ⟨nil⟩
  136. have share (v : V) (va : G.Adj v a.val) (vb : G.Adj v b.val) : 4 ≤ valence G v := by
  137. by_cases keep : v=c
  138. · simpa [keep] using four
  139. · let u : U := ⟨v,keep⟩
  140. have au : (G.induce U).Adj a u := va.symm
  141. have ub : (G.induce U).Adj u b := vb
  142. exact (apart ⟨cons au (cons ub nil)⟩).elim
  143. obtain ⟨k,hk,p,hp,len⟩ := dyadic_path_unless_cubic_common G diff deg absent minimal share
  144. have onpath : c ∈ p.support := by
  145. by_contra out
  146. have keep (v : V) (hv : v ∈ p.support) : v ∈ U := fun eq => out (eq ▸ hv)
  147. exact apart ⟨p.induce U keep⟩
  148. exact ⟨k,hk,p,hp,len,p.takeUntil c onpath,p.dropUntil c onpath,hp.takeUntil onpath,hp.dropUntil onpath,take_spec p onpath⟩
  149. end TerminalCycles