Lean / Reader
Lean reader

AdjacentTerminals.lean

154 lines6 declarationsno sorryimports VertexDeletion

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

  1. import VertexDeletion
  2. open SimpleGraph SimpleGraph.Walk
  3. open scoped Sym2
  4. namespace TerminalCycles
  5. universe u
  6. variable {V W : Type u}
  7. abbrev remainder (H : SimpleGraph V) (s t : V) : SimpleGraph (Interior s t) := H.induce {v | v ≠ s ∧ v ≠ t}
  8. /-- The nonterminal vertices only lose their incidences to the two terminals. -/
  9. private theorem remainder_degrees [Finite V] (H : SimpleGraph V) {s t : V} (x y : Interior s t)
  10. (xy : x ≠ y) (onlyS : ∀ v : Interior s t, H.Adj s v.val ↔ v=x)
  11. (onlyT : ∀ v : Interior s t, H.Adj t v.val ↔ v=y)
  12. (deg : ∀ v : Interior s t, 3 ≤ valence H v.val) :
  13. 2 ≤ valence (remainder H s t) x ∧ 2 ≤ valence (remainder H s t) y ∧
  14. ∀ v : Interior s t, v ≠ x → v ≠ y → 3 ≤ valence (remainder H s t) v := by
  15. let U : Set V := {v | v ≠ s ∧ v ≠ t}
  16. have keep (v : Interior s t) (b : V) (safe : ∀ w, H.Adj v.val w → w ≠ b → w ∈ U) :
  17. 2 ≤ valence (remainder H s t) v := by
  18. have sub : H.neighborSet v.val \ {b} ⊆ H.neighborSet v.val ∩ U := fun w hw => ⟨hw.1,safe w hw.1 hw.2⟩
  19. have bound := Set.ncard_le_ncard sub
  20. have diff := Set.ncard_le_ncard_diff_add_ncard (H.neighborSet v.val) {b}
  21. rw [Set.ncard_singleton] at diff
  22. have hv : 3 ≤ (H.neighborSet v.val).ncard := deg v
  23. change 2 ≤ valence (H.induce U) v
  24. rw [induced_valence]
  25. omega
  26. refine ⟨keep x s ?_,keep y t ?_,?_⟩
  27. · intro w e ws
  28. exact ⟨ws,fun wt => xy ((onlyT x).mp (wt ▸ e.symm))⟩
  29. · intro w e wt
  30. exact ⟨fun ws => xy.symm ((onlyS y).mp (ws ▸ e.symm)),wt⟩
  31. · intro v vx vy
  32. have sub : H.neighborSet v.val ⊆ H.neighborSet v.val ∩ U := by
  33. intro w hw
  34. have e : H.Adj v.val w := hw
  35. exact ⟨hw,fun ws => vx ((onlyS v).mp (ws ▸ e.symm)),fun wt => vy ((onlyT v).mp (wt ▸ e.symm))⟩
  36. exact (deg v).trans ((Set.ncard_le_ncard sub).trans_eq (induced_valence H U v).symm)
  37. private theorem path_after_completion (R : SimpleGraph V) (x y : V) (missing : ¬ R.Adj x y)
  38. (yes : hasPowerCycle (completeEdge R x y)) (noR : ¬ hasPowerCycle R) :
  39. ∃ j ≥ 2, ∃ p : R.Walk x y, p.IsPath ∧ p.length+1 = 2^j := by
  40. have del : ¬ hasPowerCycle ((completeEdge R x y).deleteEdges {s(x,y)}) := by rwa [delete_completed R x y missing]
  41. obtain ⟨j,hj,p⟩ := critical_edge_forces_path (completeEdge R x y) x y yes del
  42. rw [delete_completed R x y missing] at p
  43. exact ⟨j,hj,p⟩
  44. /-- Both competitor tests on the graph after removal of adjacent terminals.
  45. The two exceptional neighbors, their nonadjacency, and the degree bounds
  46. are derived from the indicated incidences and original side structure. -/
  47. theorem adjacent_terminal_remainder [Finite V] [Finite W] (H : SimpleGraph V) (G : SimpleGraph W)
  48. (f : H ↪g G) {s t : V} (st : H.Adj s t) (x y : Interior s t) (c : W)
  49. (onlyS : ∀ v : Interior s t, H.Adj s v.val ↔ v=x)
  50. (onlyT : ∀ v : Interior s t, H.Adj t v.val ↔ v=y)
  51. (outside : ∀ v, f v ≠ c) (cs : G.Adj c (f s)) (ct : G.Adj c (f t))
  52. (smaller : Nat.card V < Nat.card W) (deg : ∀ v : Interior s t, 3 ≤ valence H v.val)
  53. (absent : ¬ hasPowerCycle G) (minimal : smaller_graphs_have_cycle G) :
  54. let R := remainder H s t
  55. (∃ j ≥ 2, ∃ p : R.Walk x y, p.IsPath ∧ p.length+1 = 2^j) ∧
  56. ((∀ v, R.Adj v x → R.Adj v y → 4 ≤ valence R v) →
  57. ∃ i ≥ 2, ∃ p : R.Walk x y, p.IsPath ∧ p.length = 2^i) := by
  58. classical
  59. let R := remainder H s t
  60. letI : Nonempty (Interior s t) := ⟨x⟩
  61. have sx := (onlyS x).mpr rfl
  62. have ty := (onlyT y).mpr rfl
  63. have xy : x ≠ y := by
  64. rintro rfl
  65. have h := common_neighbors_unique G (fun eq => st.ne (f.injective eq)) absent
  66. cs.symm ct.symm (f.toHom.map_adj sx) (f.toHom.map_adj ty)
  67. exact outside x.val h.symm
  68. have noH := absent_below f absent
  69. have missing : ¬ R.Adj x y := by
  70. intro edge
  71. have h := common_neighbors_unique H y.property.1.symm noH sx (H.symm edge) st ty.symm
  72. exact x.property.2 h
  73. have noR := absent_below (SimpleGraph.Embedding.induce {v | v ≠ s ∧ v ≠ t}) noH
  74. change ¬ hasPowerCycle R at noR
  75. have sz : Nat.card (Interior s t) < Nat.card W := lt_of_le_of_lt (Nat.card_le_card_of_injective Subtype.val Subtype.val_injective) smaller
  76. obtain ⟨dx,dy,other⟩ := remainder_degrees H x y xy onlyS onlyT deg
  77. have added := minimal _ (completeEdge R x y) sz (completed_minimum R x y xy missing dx dy other)
  78. refine ⟨path_after_completion R x y missing added noR,?_⟩
  79. intro shared
  80. have full (a b : Interior s t) (no : ¬ R.Adj a b) : R.neighborSet a \ {b} = R.neighborSet a := by
  81. ext v
  82. exact ⟨fun hv => hv.1,fun hv => ⟨hv,fun eq => no (eq ▸ hv)⟩⟩
  83. have hub := outer_degree_ge_three R xy noR (from_s := by rwa [full x y missing])
  84. (from_t := by rwa [full y x (fun e => missing e.symm)])
  85. have merged := minimal _ (identify R x y) (lt_of_le_of_lt (identified_size x y) sz)
  86. (identified_minimum_shared R x y hub other shared)
  87. exact identification_forces_dyadic_path R x y xy noR merged
  88. /-- Every remainder path extends through the two attachment edges. It also
  89. closes in two ways, giving the offsets three and four. -/
  90. theorem adjacent_terminal_lift (H : SimpleGraph V) (G : SimpleGraph W) (f : H ↪g G)
  91. {s t : V} (st : H.Adj s t) (x y : Interior s t) (sx : H.Adj s x.val) (ty : H.Adj t y.val)
  92. (c : W) (outside : ∀ v, f v ≠ c) (cs : G.Adj c (f s)) (ct : G.Adj c (f t))
  93. (absent : ¬ hasPowerCycle G) (p : (remainder H s t).Walk x y) (simple : p.IsPath) :
  94. (∃ q : H.Walk s t, q.IsPath ∧ q.length = p.length+2) ∧
  95. (∀ k ≥ 2, p.length+3 ≠ 2^k) ∧ (∀ k ≥ 2, p.length+4 ≠ 2^k) := by
  96. let e : remainder H s t ↪g H := SimpleGraph.Embedding.induce _
  97. let q := p.map e.toHom
  98. have ss : s ∉ q.support := by
  99. change s ∉ (p.map e.toHom).support
  100. rw [Walk.support_map,List.mem_map]
  101. rintro ⟨v,_,eq⟩
  102. exact v.property.1 eq
  103. have tt : t ∉ q.support := by
  104. change t ∉ (p.map e.toHom).support
  105. rw [Walk.support_map,List.mem_map]
  106. rintro ⟨v,_,eq⟩
  107. exact v.property.2 eq
  108. have good : q.IsPath := map_isPath_of_injective e.injective simple
  109. let a := cons sx (q.concat ty.symm)
  110. have simpleA : a.IsPath := open_internal q good st.ne ss tt sx ty.symm
  111. have len : a.length = p.length+2 := by simp [a,q,Nat.add_assoc]
  112. refine ⟨⟨a,simpleA,len⟩,?_,?_⟩
  113. · intro k hk bad
  114. have fresh : s ∉ (q.concat ty.symm).support := by simpa [support_concat,st.ne] using ss
  115. have cycle := close_internal (q.concat ty.symm) (good.concat tt ty.symm) x.property.2 fresh sx st.symm
  116. exact absent_below f absent ⟨k,s,_,hk,cycle,by simpa [q,Nat.add_assoc] using bad⟩
  117. · intro k hk bad
  118. apply forbidden_plus_two f st.ne outside cs ct absent a simpleA k hk
  119. omega
  120. /-- The two simple terminal path lengths for the adjacent case, in H itself. -/
  121. theorem adjacent_terminal_lengths [Finite V] [Finite W] (H : SimpleGraph V) (G : SimpleGraph W)
  122. (f : H ↪g G) {s t : V} (st : H.Adj s t) (x y : Interior s t) (c : W)
  123. (onlyS : ∀ v : Interior s t, H.Adj s v.val ↔ v=x)
  124. (onlyT : ∀ v : Interior s t, H.Adj t v.val ↔ v=y)
  125. (outside : ∀ v, f v ≠ c) (cs : G.Adj c (f s)) (ct : G.Adj c (f t))
  126. (smaller : Nat.card V < Nat.card W) (deg : ∀ v : Interior s t, 3 ≤ valence H v.val)
  127. (absent : ¬ hasPowerCycle G) (minimal : smaller_graphs_have_cycle G) :
  128. (∃ j ≥ 2, ∃ q : H.Walk s t, q.IsPath ∧ q.length = 2^j+1) ∧
  129. ((∀ v, (remainder H s t).Adj v x → (remainder H s t).Adj v y → 4 ≤ valence (remainder H s t) v) →
  130. ∃ i ≥ 2, ∃ q : H.Walk s t, q.IsPath ∧ q.length = 2^i+2) := by
  131. obtain ⟨mersenne,power⟩ := adjacent_terminal_remainder H G f st x y c onlyS onlyT outside cs ct smaller deg absent minimal
  132. have lift := adjacent_terminal_lift H G f st x y ((onlyS x).mpr rfl) ((onlyT y).mpr rfl) c outside cs ct absent
  133. constructor
  134. · obtain ⟨j,hj,p,hp,len⟩ := mersenne
  135. obtain ⟨q,hq,size⟩ := (lift p hp).1
  136. exact ⟨j,hj,q,hq,by omega⟩
  137. · intro shared
  138. obtain ⟨i,hi,p,hp,len⟩ := power shared
  139. obtain ⟨q,hq,size⟩ := (lift p hp).1
  140. exact ⟨i,hi,q,hq,by omega⟩
  141. end TerminalCycles