Lean / lkruer/erdos-96-97-proof / Erdos9697Complete.lean
Lean reader

Erdos9697Complete.lean

4,744 lines399 declarationsno sorryimports Mathlib
  1. import Mathlib
  2. /-!
  3. # Unit distances in convex polygons: complete formalisation
  4. Single-file formalisation of 96-97.tex by Liam Kruer, Jensen Kohlmeyer, and
  5. Liam Price. All construction lemmas, quantitative results, corollaries, and
  6. the disproofs of Erdos problems 96, 97, and the general fixed-k conjecture
  7. are included below. The only import is Mathlib.
  8. Main entry points in namespace Proof:
  9. * main_theorem and main_quantitative (explicit absolute constant C = 7)
  10. * finite_construction_plane and threshold_configuration_plane
  11. * convex_unit_distances_omega and eventual_minimum_degree
  12. * bounded_size_minimum_degree and explicit_erdos_97_counterexample
  13. * erdos_96_false, erdos_97_false, and erdos_97_general_false
  14. The final section checks the transitive axiom dependencies of 33 results,
  15. permitting only propext, Classical.choice, and Quot.sound.
  16. Checked with Lean v4.33.1 and the Mathlib version used by this project.
  17. -/
  18. set_option maxHeartbeats 1600000
  19. set_option maxRecDepth 4000
  20. /- The following compatibility definitions reproduce the relevant geometry
  21. interfaces of FormalConjecturesForMathlib.Geometry.Metric and Geometry.2d.
  22. Those sources are Copyright 2025 The Formal Conjectures Authors and licensed
  23. under the Apache License, Version 2.0:
  24. https://www.apache.org/licenses/LICENSE-2.0
  25. They are included here so this file requires no Formal Conjectures imports. -/
  26. scoped[EuclideanGeometry] notation "ℝ²" => EuclideanSpace ℝ (Fin 2)
  27. noncomputable def unitDistNum {X : Type*} [MetricSpace X] (s : Finset X) : ℕ := by
  28. classical
  29. exact (s.sym2.filter fun p => dist p.out.1 p.out.2 = 1).card
  30. namespace EuclideanGeometry
  31. open scoped EuclideanGeometry
  32. def ConvexIndep (S : Set ℝ²) : Prop :=
  33. ∀ a ∈ S, a ∉ convexHull ℝ (S \ {a})
  34. end EuclideanGeometry
  35. /-! ## Source: Definitions.lean -/
  36. section Combined_Definitions
  37. /-!
  38. Definitions used by the Formal Conjectures statements of Erdős problems 96 and 97.
  39. The definitions below reproduce the relevant definitions from those problem files;
  40. no conjecture declaration or unproved theorem is imported.
  41. -/
  42. open EuclideanGeometry
  43. open scoped EuclideanGeometry
  44. namespace Erdos96
  45. noncomputable def convexUnitDistanceCounts (n : ℕ) : Set ℕ :=
  46. {unitDistNum points | (points : Finset ℝ²) (_ : points.card = n) (_ : ConvexIndep points)}
  47. noncomputable def maxConvexUnitDistances (n : ℕ) : ℕ :=
  48. sSup (convexUnitDistanceCounts n)
  49. end Erdos96
  50. namespace Erdos97
  51. def HasNEquidistantPointsAt (n : ℕ) (A : Finset ℝ²) (p : ℝ²) : Prop :=
  52. ∃ r : ℝ, r > 0 ∧ (A.filter fun q ↦ dist p q = r).card ≥ n
  53. def HasNEquidistantPointsOn (n : ℕ) (A B : Finset ℝ²) : Prop :=
  54. ∀ p ∈ B, HasNEquidistantPointsAt n A p
  55. def HasNEquidistantProperty (n : ℕ) (A : Finset ℝ²) : Prop :=
  56. HasNEquidistantPointsOn n A A
  57. def HasNUnitDistancePointsAt (n : ℕ) (A : Finset ℝ²) (p : ℝ²) : Prop :=
  58. (A.filter fun q ↦ dist p q = 1).card ≥ n
  59. def HasNUnitDistancePointsOn (n : ℕ) (A B : Finset ℝ²) : Prop :=
  60. ∀ p ∈ B, HasNUnitDistancePointsAt n A p
  61. def HasNUnitDistanceProperty (n : ℕ) (A : Finset ℝ²) : Prop :=
  62. HasNUnitDistancePointsOn n A A
  63. end Erdos97
  64. end Combined_Definitions
  65. /-! ## Source: Erdos96.lean -/
  66. section Combined_Erdos96
  67. /-!
  68. # Superlinearly many unit distances in convex position
  69. Authors: Liam Kruer <kruerl@purdue.edu>
  70. Jensen Kohlmeyer <jenwin@purdue.edu>
  71. OpenAI Codex provided substantial assistance with the mathematical exploration,
  72. construction, proofs, formalization, verification, and manuscript preparation.
  73. The authors are responsible for the content.
  74. Proof of the original counterexample and the negation of Erdős problem 96.
  75. The conjectures' definitions above do not import unproved statements.
  76. -/
  77. open _root_.Erdos96
  78. /- ## Angle -/
  79. section OriginalAngle
  80. /- Calculus of the angle subtended by a unit chord at the origin. -/
  81. namespace Proof
  82. noncomputable def chordCos (r s : ℝ) : ℝ := (r ^ 2 + s ^ 2 - 1) / (2 * r * s)
  83. noncomputable def chordCosLeft (r s : ℝ) : ℝ := (r ^ 2 - s ^ 2 + 1) / (2 * r ^ 2 * s)
  84. noncomputable def chordCosMixed (r s : ℝ) : ℝ := -(r ^ 2 + s ^ 2 + 1) / (2 * r ^ 2 * s ^ 2)
  85. noncomputable def chordAngle (r s : ℝ) : ℝ := Real.arccos (chordCos r s)
  86. theorem chordCos_comm (r s : ℝ) : chordCos r s = chordCos s r := by
  87. unfold chordCos
  88. congr 1 <;> ring
  89. theorem hasDerivAt_chordCos_left {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0) :
  90. HasDerivAt (fun x => chordCos x s) (chordCosLeft r s) r := by
  91. have hnum := (((hasDerivAt_id r).pow 2).add_const (s ^ 2)).sub_const 1
  92. have hden := ((hasDerivAt_id r).const_mul 2).mul_const s
  93. convert! hnum.div hden (mul_ne_zero (mul_ne_zero two_ne_zero hr) hs) using 1
  94. dsimp only [id_eq, Pi.pow_apply]
  95. unfold chordCosLeft
  96. field_simp [hr, hs]
  97. ring
  98. theorem hasDerivAt_chordCos_right {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0) :
  99. HasDerivAt (chordCos r) (chordCosLeft s r) s := by
  100. simpa only [chordCos_comm] using hasDerivAt_chordCos_left hs hr
  101. theorem hasDerivAt_chordCosLeft_right {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0) :
  102. HasDerivAt (chordCosLeft r) (chordCosMixed r s) s := by
  103. have hnum := (((hasDerivAt_id s).pow 2).const_sub (r ^ 2)).add_const 1
  104. have hden := (hasDerivAt_id s).const_mul (2 * r ^ 2)
  105. convert! hnum.div hden (mul_ne_zero (mul_ne_zero two_ne_zero (pow_ne_zero 2 hr)) hs) using 1
  106. dsimp only [id_eq, Pi.pow_apply]
  107. unfold chordCosMixed
  108. field_simp [hr, hs]
  109. ring
  110. theorem chordCos_mixed_identity {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0) :
  111. -(chordCosMixed r s * (1 - chordCos r s ^ 2) +
  112. chordCos r s * chordCosLeft r s * chordCosLeft s r) = 1 / (r ^ 2 * s ^ 2) := by
  113. unfold chordCosMixed chordCos chordCosLeft
  114. field_simp [hr, hs]
  115. ring
  116. noncomputable def chordAngleLeft (r s : ℝ) : ℝ :=
  117. -chordCosLeft r s / Real.sqrt (1 - chordCos r s ^ 2)
  118. theorem chord_discriminant_pos {r s : ℝ}
  119. (hl : -1 < chordCos r s) (hu : chordCos r s < 1) :
  120. 0 < 1 - chordCos r s ^ 2 := by
  121. nlinarith
  122. theorem hasDerivAt_chordAngle_left {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0)
  123. (hl : -1 < chordCos r s) (hu : chordCos r s < 1) :
  124. HasDerivAt (fun x => chordAngle x s) (chordAngleLeft r s) r := by
  125. convert! (Real.hasDerivAt_arccos (ne_of_gt hl) (ne_of_lt hu)).comp r
  126. (hasDerivAt_chordCos_left hr hs) using 1
  127. unfold chordAngleLeft
  128. ring
  129. theorem hasDerivAt_chordAngleLeft_right {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0)
  130. (hl : -1 < chordCos r s) (hu : chordCos r s < 1) :
  131. HasDerivAt (chordAngleLeft r)
  132. (1 / (r ^ 2 * s ^ 2 * Real.sqrt (1 - chordCos r s ^ 2) ^ 3)) s := by
  133. have hq := chord_discriminant_pos hl hu
  134. have hsqrt : Real.sqrt (1 - chordCos r s ^ 2) ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr hq)
  135. have hsquare := Real.sq_sqrt hq.le
  136. have hnum := (hasDerivAt_chordCosLeft_right hr hs).neg
  137. have hden := (((hasDerivAt_chordCos_right hr hs).pow 2).const_sub 1).sqrt (ne_of_gt hq)
  138. convert! hnum.div hden hsqrt using 1
  139. have hid := chordCos_mixed_identity hr hs
  140. dsimp only [id_eq, Pi.pow_apply, Pi.neg_apply, Nat.cast_ofNat, Nat.reduceSub, pow_one, one_mul, mul_one]
  141. field_simp [hr, hs, hsqrt] at hid ⊢
  142. rw [hsquare]
  143. linear_combination -hid
  144. theorem chordAngle_mixed_positive {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0)
  145. (hl : -1 < chordCos r s) (hu : chordCos r s < 1) :
  146. 0 < deriv (chordAngleLeft r) s := by
  147. rw [(hasDerivAt_chordAngleLeft_right hr hs hl hu).deriv]
  148. have := Real.sqrt_pos.mpr (chord_discriminant_pos hl hu)
  149. positivity
  150. end Proof
  151. end OriginalAngle
  152. /- ## GenericAngles -/
  153. section OriginalGenericAngles
  154. /- Local separation of finite linear combinations of edge angles. -/
  155. namespace Proof
  156. open Set Filter
  157. open scoped Topology
  158. def ChordFeasible (r s : ℝ) : Prop :=
  159. r ≠ 0 ∧ s ≠ 0 ∧ -1 < chordCos r s ∧ chordCos r s < 1
  160. theorem chordAngle_rectangle_strict {a b c d : ℝ} (hab : a < b) (hcd : c < d)
  161. (hf : ∀ x ∈ Icc a b, ∀ y ∈ Icc c d, ChordFeasible x y) :
  162. 0 < chordAngle b d - chordAngle a d - chordAngle b c + chordAngle a c := by
  163. have hm : ∀ x ∈ Icc a b, chordAngleLeft x c < chordAngleLeft x d := by
  164. intro x hx
  165. have hmono : StrictMonoOn (chordAngleLeft x) (Icc c d) := by
  166. apply strictMonoOn_of_deriv_pos (convex_Icc c d)
  167. · intro y hy
  168. obtain ⟨hr, hs, hl, hu⟩ := hf x hx y hy
  169. exact (hasDerivAt_chordAngleLeft_right hr hs hl hu).continuousAt.continuousWithinAt
  170. · intro y hy
  171. obtain ⟨hr, hs, hl, hu⟩ := hf x hx y (interior_subset hy)
  172. exact chordAngle_mixed_positive hr hs hl hu
  173. exact hmono ⟨le_rfl, hcd.le⟩ ⟨hcd.le, le_rfl⟩ hcd
  174. have hder : ∀ x ∈ Icc a b,
  175. HasDerivAt (fun t => chordAngle t d - chordAngle t c)
  176. (chordAngleLeft x d - chordAngleLeft x c) x := by
  177. intro x hx
  178. obtain ⟨hrd, hsd, hld, hud⟩ := hf x hx d ⟨hcd.le, le_rfl⟩
  179. obtain ⟨hrc, hsc, hlc, huc⟩ := hf x hx c ⟨le_rfl, hcd.le⟩
  180. exact (hasDerivAt_chordAngle_left hrd hsd hld hud).sub
  181. (hasDerivAt_chordAngle_left hrc hsc hlc huc)
  182. have hmono : StrictMonoOn (fun t => chordAngle t d - chordAngle t c) (Icc a b) := by
  183. apply strictMonoOn_of_deriv_pos (convex_Icc a b)
  184. · intro x hx
  185. exact (hder x hx).continuousAt.continuousWithinAt
  186. · intro x hx
  187. rw [(hder x (interior_subset hx)).deriv]
  188. exact sub_pos.mpr (hm x (interior_subset hx))
  189. have hh := hmono ⟨le_rfl, hab.le⟩ ⟨hab.le, le_rfl⟩ hab
  190. linarith
  191. noncomputable def matrixSum {L P : Type*} [Fintype L] [Fintype P]
  192. (f : L → P → ℝ → ℝ → ℝ) (r : L → ℝ) (s : P → ℝ) : ℝ :=
  193. ∑ i, ∑ j, f i j (r i) (s j)
  194. theorem matrix_rectangle {L P : Type*} [Fintype L] [Fintype P]
  195. [DecidableEq L] [DecidableEq P] (f : L → P → ℝ → ℝ → ℝ)
  196. (r : L → ℝ) (s : P → ℝ) (i : L) (j : P) (x y : ℝ) :
  197. matrixSum f (Function.update r i x) (Function.update s j y) -
  198. matrixSum f r (Function.update s j y) -
  199. matrixSum f (Function.update r i x) s + matrixSum f r s =
  200. f i j x y - f i j (r i) y - f i j x (s j) + f i j (r i) (s j) := by
  201. let g := fun a b => f a b (Function.update r i x a) (Function.update s j y b) -
  202. f a b (r a) (Function.update s j y b) -
  203. f a b (Function.update r i x a) (s b) + f a b (r a) (s b)
  204. have he : matrixSum f (Function.update r i x) (Function.update s j y) -
  205. matrixSum f r (Function.update s j y) -
  206. matrixSum f (Function.update r i x) s + matrixSum f r s = ∑ a, ∑ b, g a b := by
  207. simp only [matrixSum, g, Finset.sum_add_distrib, Finset.sum_sub_distrib]
  208. rw [he, Finset.sum_eq_single i]
  209. · rw [Finset.sum_eq_single j]
  210. · simp [g]
  211. · intro b _ hbj
  212. simp [g, Function.update_of_ne hbj]
  213. · simp
  214. · intro a _ hai
  215. apply Finset.sum_eq_zero
  216. intro b _
  217. simp [g, Function.update_of_ne hai]
  218. · simp
  219. theorem finite_avoidance {X K Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [T1Space Y] [Zero Y]
  220. (f : K → X → Y) (U : Set X) (hU : IsOpen U) (hne : U.Nonempty)
  221. (hc : ∀ k, ContinuousOn (f k) U)
  222. (hnc : ∀ k, ∀ V : Set X, V ⊆ U → IsOpen V → V.Nonempty → ∃ x ∈ V, f k x ≠ 0)
  223. (s : Finset K) : ∃ x ∈ U, ∀ k ∈ s, f k x ≠ 0 := by
  224. classical
  225. suffices ∃ V : Set X, V ⊆ U ∧ IsOpen V ∧ V.Nonempty ∧
  226. ∀ x ∈ V, ∀ k ∈ s, f k x ≠ 0 by
  227. obtain ⟨V, hVU, hVo, ⟨x, hx⟩, hv⟩ := this
  228. exact ⟨x, hVU hx, hv x hx⟩
  229. induction s using Finset.induction_on with
  230. | empty => exact ⟨U, subset_rfl, hU, hne, by simp⟩
  231. | @insert k s hks ih =>
  232. obtain ⟨V, hVU, hVo, hVne, hV⟩ := ih
  233. obtain ⟨x, hx, hkx⟩ := hnc k V hVU hVo hVne
  234. refine ⟨V ∩ (f k) ⁻¹' ({0}ᶜ), inter_subset_left.trans hVU,
  235. (hc k |>.mono hVU).isOpen_inter_preimage hVo isClosed_singleton.isOpen_compl,
  236. ⟨x, hx, hkx⟩, ?_⟩
  237. intro y hy j hj
  238. rcases Finset.mem_insert.mp hj with rfl | hj
  239. · exact hy.2
  240. · exact hV y hy.1 j hj
  241. theorem coordinate_rectangle {L P : Type*} [DecidableEq L] [DecidableEq P]
  242. {U : Set ((L → ℝ) × (P → ℝ))} (hU : IsOpen U) {z : (L → ℝ) × (P → ℝ)}
  243. (hz : z ∈ U) (i : L) (j : P) :
  244. ∃ b d : ℝ, z.1 i < b ∧ z.2 j < d ∧
  245. ∀ x ∈ Icc (z.1 i) b, ∀ y ∈ Icc (z.2 j) d,
  246. (Function.update z.1 i x, Function.update z.2 j y) ∈ U := by
  247. let F := fun xy : ℝ × ℝ => (Function.update z.1 i xy.1, Function.update z.2 j xy.2)
  248. have hF : Continuous F := by unfold F; fun_prop
  249. have hmem : (z.1 i, z.2 j) ∈ F ⁻¹' U := by simpa [F] using hz
  250. obtain ⟨A, hA, B, hB, hAB⟩ := mem_nhds_prod_iff.mp ((hU.preimage hF).mem_nhds hmem)
  251. obtain ⟨a, b, hab, hAsub⟩ := mem_nhds_iff_exists_Ioo_subset.mp hA
  252. obtain ⟨c, d, hcd, hBsub⟩ := mem_nhds_iff_exists_Ioo_subset.mp hB
  253. refine ⟨(z.1 i + b) / 2, (z.2 j + d) / 2, by linarith [hab.2], by linarith [hcd.2], ?_⟩
  254. intro x hx y hy
  255. change (x, y) ∈ F ⁻¹' U
  256. apply hAB
  257. constructor
  258. · apply hAsub
  259. constructor <;> linarith [hab.1, hab.2, hx.1, hx.2]
  260. · apply hBsub
  261. constructor <;> linarith [hcd.1, hcd.2, hy.1, hy.2]
  262. theorem angle_sum_not_constant {L P : Type*} [Fintype L] [Fintype P]
  263. [DecidableEq L] [DecidableEq P] (c : L → P → ℝ) (i : L) (j : P) (hc : c i j ≠ 0)
  264. (U : Set ((L → ℝ) × (P → ℝ))) (hU : IsOpen U) (hne : U.Nonempty)
  265. (hf : ∀ z ∈ U, ChordFeasible (z.1 i) (z.2 j)) (k : ℝ) :
  266. ∃ z ∈ U, matrixSum (fun a b x y => c a b * chordAngle x y) z.1 z.2 ≠ k := by
  267. by_contra hnone
  268. push Not at hnone
  269. obtain ⟨z, hz⟩ := hne
  270. obtain ⟨b, d, hb, hd, hrect⟩ := coordinate_rectangle hU hz i j
  271. have hfeas : ∀ x ∈ Icc (z.1 i) b, ∀ y ∈ Icc (z.2 j) d, ChordFeasible x y := by
  272. intro x hx y hy
  273. simpa using hf _ (hrect x hx y hy)
  274. have hpositive := chordAngle_rectangle_strict hb hd hfeas
  275. have h00 := hnone z hz
  276. have h11 := hnone _ (hrect b ⟨hb.le, le_rfl⟩ d ⟨hd.le, le_rfl⟩)
  277. have h01 := hnone _ (hrect (z.1 i) ⟨le_rfl, hb.le⟩ d ⟨hd.le, le_rfl⟩)
  278. have h10 := hnone _ (hrect b ⟨hb.le, le_rfl⟩ (z.2 j) ⟨le_rfl, hd.le⟩)
  279. simp only [Function.update_eq_self] at h01 h10
  280. have hid := matrix_rectangle (fun a b x y => c a b * chordAngle x y) z.1 z.2 i j b d
  281. rw [h00, h11, h01, h10] at hid
  282. have hzero : c i j * (chordAngle b d - chordAngle (z.1 i) d -
  283. chordAngle b (z.2 j) + chordAngle (z.1 i) (z.2 j)) = 0 := by linear_combination -hid
  284. exact (mul_ne_zero hc (ne_of_gt hpositive)) hzero
  285. theorem weighted_angles_continuousAt {L P : Type*} [Fintype L] [Fintype P]
  286. (c : L → P → ℝ) (z : (L → ℝ) × (P → ℝ))
  287. (hr : ∀ i, z.1 i ≠ 0) (hs : ∀ j, z.2 j ≠ 0) :
  288. ContinuousAt (fun u => matrixSum (fun i j x y => c i j * chordAngle x y) u.1 u.2) z := by
  289. unfold matrixSum chordAngle chordCos
  290. fun_prop (disch := aesop)
  291. theorem finite_angle_avoidance {L P K : Type*} [Fintype L] [Fintype P]
  292. [DecidableEq L] [DecidableEq P]
  293. (c : K → L → P → ℝ) (offset : K → ℝ) (U : Set ((L → ℝ) × (P → ℝ)))
  294. (hU : IsOpen U) (hne : U.Nonempty)
  295. (hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0))
  296. (hc : ∀ k, ∃ i j, c k i j ≠ 0)
  297. (hfeas : ∀ k i j, c k i j ≠ 0 → ∀ z ∈ U, ChordFeasible (z.1 i) (z.2 j))
  298. (s : Finset K) : ∃ z ∈ U, ∀ k ∈ s,
  299. matrixSum (fun i j x y => c k i j * chordAngle x y) z.1 z.2 ≠ offset k := by
  300. let f := fun (k : K) (z : (L → ℝ) × (P → ℝ)) =>
  301. matrixSum (fun i j x y => c k i j * chordAngle x y) z.1 z.2 - offset k
  302. have hcont : ∀ k, ContinuousOn (f k) U := by
  303. intro k z hz
  304. exact ((weighted_angles_continuousAt (c k) z (hnz z hz).1 (hnz z hz).2).sub
  305. continuousAt_const).continuousWithinAt
  306. have hnc : ∀ k, ∀ V : Set ((L → ℝ) × (P → ℝ)),
  307. V ⊆ U → IsOpen V → V.Nonempty → ∃ z ∈ V, f k z ≠ 0 := by
  308. intro k V hVU hVo hVne
  309. obtain ⟨i, j, hij⟩ := hc k
  310. obtain ⟨z, hz, hh⟩ := angle_sum_not_constant (c k) i j hij V hVo hVne
  311. (fun z hz => hfeas k i j hij z (hVU hz)) (offset k)
  312. exact ⟨z, hz, sub_ne_zero.mpr hh⟩
  313. obtain ⟨z, hz, hh⟩ := finite_avoidance f U hU hne hcont hnc s
  314. exact ⟨z, hz, fun k hk => sub_ne_zero.mp (hh k hk)⟩
  315. end Proof
  316. end OriginalGenericAngles
  317. /- ## SeedAlgebra -/
  318. section OriginalSeedAlgebra
  319. /- Polynomial identities for the two classes of incidence seeds. -/
  320. namespace Proof
  321. noncomputable section
  322. def lineC (x t : ℝ) : ℝ := x ^ 2 + t / 2
  323. def pointD (x t : ℝ) : ℝ := -x ^ 2 + t / 2
  324. def lineSeed (ε x t : ℝ) : ℂ := ⟨ε * x, -1 / 2 + ε ^ 2 * lineC x t⟩
  325. def pointSeed (ε x t : ℝ) : ℂ := ⟨-ε * x, 1 / 2 + ε ^ 2 * pointD x t⟩
  326. def support (a b : ℂ) : ℝ := a.re * (b.re - a.re) + a.im * (b.im - a.im)
  327. theorem line_support_identity (ε x t y u : ℝ) :
  328. support (lineSeed ε x t) (lineSeed ε y u) =
  329. ε ^ 2 * (-(y - x) ^ 2 / 2 - (u - t) / 4) +
  330. ε ^ 4 * lineC x t * (lineC y u - lineC x t) := by
  331. simp only [support, lineSeed, lineC]
  332. ring
  333. theorem point_support_identity (ε x t y u : ℝ) :
  334. support (pointSeed ε x t) (pointSeed ε y u) =
  335. ε ^ 2 * (-(y - x) ^ 2 / 2 + (u - t) / 4) +
  336. ε ^ 4 * pointD x t * (pointD y u - pointD x t) := by
  337. simp only [support, pointSeed, pointD]
  338. ring
  339. theorem line_normSq (ε x t : ℝ) :
  340. Complex.normSq (lineSeed ε x t) =
  341. 1 / 4 - ε ^ 2 * t / 2 + ε ^ 4 * (lineC x t) ^ 2 := by
  342. simp only [Complex.normSq_apply, lineSeed, lineC]
  343. ring
  344. theorem point_normSq (ε x t : ℝ) :
  345. Complex.normSq (pointSeed ε x t) =
  346. 1 / 4 + ε ^ 2 * t / 2 + ε ^ 4 * (pointD x t) ^ 2 := by
  347. simp only [Complex.normSq_apply, pointSeed, pointD]
  348. ring
  349. theorem incidence_distance_identity (ε x t y u : ℝ)
  350. (h : u - t = (y - x) ^ 2) :
  351. Complex.normSq (pointSeed ε y u - lineSeed ε x t) =
  352. 1 + ε ^ 4 * (pointD y u - lineC x t) ^ 2 := by
  353. simp only [Complex.normSq_apply, Complex.sub_re, Complex.sub_im,
  354. pointSeed, lineSeed, pointD, lineC]
  355. linear_combination ε ^ 2 * h
  356. theorem signed_digit_margin {x t : ℝ}
  357. (h : |t| < (50 / 27 : ℝ) * x ^ 2) :
  358. -x ^ 2 / 2 - t / 4 < -x ^ 2 / 27 ∧
  359. -x ^ 2 / 2 + t / 4 < -x ^ 2 / 27 := by
  360. rcases abs_lt.mp h with ⟨hl, hu⟩
  361. constructor <;> linarith
  362. end
  363. end Proof
  364. end OriginalSeedAlgebra
  365. /- ## RadialGeometry -/
  366. section OriginalRadialGeometry
  367. /- Strict radial support, rotations, and their convexity consequences. -/
  368. namespace Proof
  369. open scoped InnerProductSpace
  370. theorem support_eq_inner (a b : ℂ) : support a b = ⟪a, b - a⟫_ℝ := by
  371. simp only [support, Complex.inner, Complex.mul_re, Complex.sub_re,
  372. Complex.sub_im, Complex.conj_re, Complex.conj_im]
  373. ring
  374. theorem support_eq_normSq (a b : ℂ) :
  375. 2 * support a b = Complex.normSq b - Complex.normSq a - Complex.normSq (b - a) := by
  376. simp only [support, Complex.normSq_apply, Complex.sub_re, Complex.sub_im]
  377. ring
  378. theorem support_negative_of_equal_norm {a b : ℂ} (hne : a ≠ b)
  379. (hnorm : ‖a‖ = ‖b‖) : support a b < 0 := by
  380. have heq : Complex.normSq a = Complex.normSq b := by
  381. simpa only [Complex.normSq_eq_norm_sq] using congrArg (fun r : ℝ => r ^ 2) hnorm
  382. have hp : 0 < Complex.normSq (b - a) := Complex.normSq_pos.mpr (sub_ne_zero.mpr hne.symm)
  383. have := support_eq_normSq a b
  384. linarith
  385. theorem convexIndependent_of_support {ι : Type*} (p : ι → ℂ)
  386. (h : ∀ i j, i ≠ j → support (p i) (p j) < 0) : ConvexIndependent ℝ p := by
  387. intro s i hi
  388. by_contra hnot
  389. have hs : p '' s ⊆ {z : ℂ | ⟪p i, z⟫_ℝ < ⟪p i, p i⟫_ℝ} := by
  390. rintro z ⟨j, hj, rfl⟩
  391. have hij : i ≠ j := fun he => hnot (he.symm ▸ hj)
  392. have hh := h i j hij
  393. rw [support_eq_inner, inner_sub_right] at hh
  394. exact sub_neg.mp hh
  395. have hc : Convex ℝ {z : ℂ | ⟪p i, z⟫_ℝ < ⟪p i, p i⟫_ℝ} :=
  396. convex_halfSpace_lt ((innerₗ ℂ) (p i)).isLinear _
  397. have hz := (convexHull_min hs hc) hi
  398. exact lt_irrefl _ (show ⟪p i, p i⟫_ℝ < ⟪p i, p i⟫_ℝ from hz)
  399. theorem support_mul (a b w : ℂ) :
  400. support (a * w) (b * w) = Complex.normSq w * support a b := by
  401. simp only [support, Complex.mul_re, Complex.mul_im, Complex.normSq_apply]
  402. ring
  403. theorem norm_subset_prod {ι : Type*} (s : Finset ι) (w : ι → ℂ)
  404. (hw : ∀ i ∈ s, ‖w i‖ = 1) : ‖∏ i ∈ s, w i‖ = 1 := by
  405. rw [norm_prod]
  406. exact Finset.prod_eq_one hw
  407. theorem norm_prod_sub_one_le {ι : Type*} (s : Finset ι) (w : ι → ℂ)
  408. (hw : ∀ i ∈ s, ‖w i‖ = 1) :
  409. ‖(∏ i ∈ s, w i) - 1‖ ≤ ∑ i ∈ s, ‖w i - 1‖ := by
  410. classical
  411. induction s using Finset.induction_on with
  412. | empty => simp
  413. | @insert i s hi ih =>
  414. rw [Finset.prod_insert hi, Finset.sum_insert hi]
  415. have hwi := hw i (Finset.mem_insert_self i s)
  416. have hws : ∀ j ∈ s, ‖w j‖ = 1 := fun j hj => hw j (Finset.mem_insert_of_mem hj)
  417. calc
  418. ‖w i * (∏ j ∈ s, w j) - 1‖ =
  419. ‖w i * ((∏ j ∈ s, w j) - 1) + (w i - 1)‖ := by congr 1; ring
  420. _ ≤ ‖w i * ((∏ j ∈ s, w j) - 1)‖ + ‖w i - 1‖ := norm_add_le _ _
  421. _ = ‖(∏ j ∈ s, w j) - 1‖ + ‖w i - 1‖ := by rw [norm_mul, hwi, one_mul]
  422. _ ≤ ‖w i - 1‖ + ∑ j ∈ s, ‖w j - 1‖ := by linarith [ih hws]
  423. theorem support_change_same_norm (a b a' b' : ℂ) (hn : ‖a'‖ = ‖a‖) :
  424. |support a' b' - support a b| ≤
  425. ‖a' - a‖ * ‖b'‖ + ‖a‖ * ‖b' - b‖ := by
  426. have he : support a' b' - support a b =
  427. ⟪a' - a, b'⟫_ℝ + ⟪a, b' - b⟫_ℝ := by
  428. simp only [support_eq_inner, inner_sub_left, inner_sub_right,
  429. real_inner_self_eq_norm_sq, hn]
  430. ring
  431. rw [he]
  432. exact (abs_add_le _ _).trans (add_le_add (abs_real_inner_le_norm _ _) (abs_real_inner_le_norm _ _))
  433. theorem rotated_support_bound {a b u v : ℂ} {H : ℝ}
  434. (ha : ‖a‖ ≤ 1) (hb : ‖b‖ ≤ 1) (hu : ‖u‖ = 1) (hv : ‖v‖ = 1)
  435. (hU : ‖u - 1‖ ≤ H) (hV : ‖v - 1‖ ≤ H) :
  436. support (a * u) (b * v) ≤ support a b + 2 * H := by
  437. have hH : 0 ≤ H := (norm_nonneg _).trans hU
  438. have hau : ‖a * u‖ = ‖a‖ := by rw [norm_mul, hu, mul_one]
  439. have hbv : ‖b * v‖ = ‖b‖ := by rw [norm_mul, hv, mul_one]
  440. have hdiffa : ‖a * u - a‖ ≤ H := by
  441. rw [← mul_sub_one, norm_mul]
  442. exact (mul_le_mul ha hU (norm_nonneg _) (by norm_num)).trans_eq (one_mul H)
  443. have hdiffb : ‖b * v - b‖ ≤ H := by
  444. rw [← mul_sub_one, norm_mul]
  445. exact (mul_le_mul hb hV (norm_nonneg _) (by norm_num)).trans_eq (one_mul H)
  446. have hh := support_change_same_norm a b (a * u) (b * v) hau
  447. rw [hbv] at hh
  448. have h1 : ‖a * u - a‖ * ‖b‖ ≤ H := by
  449. exact (mul_le_mul hdiffa hb (norm_nonneg _) hH).trans_eq (mul_one H)
  450. have h2 : ‖a‖ * ‖b * v - b‖ ≤ H := by
  451. exact (mul_le_mul ha hdiffb (norm_nonneg _) (by norm_num)).trans_eq (one_mul H)
  452. have := le_abs_self (support (a * u) (b * v) - support a b)
  453. linarith
  454. end Proof
  455. end OriginalRadialGeometry
  456. /- ## Amplification -/
  457. section OriginalAmplification
  458. /- Amplification by products of unit complex numbers. -/
  459. namespace Proof
  460. noncomputable section
  461. def subsetProduct {E : Type*} (w : E → ℂ) (S : Finset E) : ℂ := ∏ e ∈ S, w e
  462. def rotatedCopy {I E : Type*} (b : I → ℂ) (w : E → ℂ) (x : I × Finset E) : ℂ :=
  463. b x.1 * subsetProduct w x.2
  464. theorem subsetProduct_norm {E : Type*} (w : E → ℂ) (hw : ∀ e, ‖w e‖ = 1)
  465. (S : Finset E) : ‖subsetProduct w S‖ = 1 :=
  466. norm_subset_prod S w (fun e _ => hw e)
  467. theorem subsetProduct_close {E : Type*} [Fintype E] (w : E → ℂ)
  468. (hw : ∀ e, ‖w e‖ = 1) (S : Finset E) :
  469. ‖subsetProduct w S - 1‖ ≤ ∑ e, ‖w e - 1‖ := by
  470. classical
  471. refine (norm_prod_sub_one_le S w (fun e _ => hw e)).trans ?_
  472. exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ S)
  473. (fun e _ _ => norm_nonneg (w e - 1))
  474. theorem rotatedCopy_injective {I E : Type*} (b : I → ℂ) (w : E → ℂ)
  475. (hb : ∀ i, b i ≠ 0) (hn : Function.Injective (fun i => ‖b i‖))
  476. (hw : ∀ e, ‖w e‖ = 1) (hprod : Function.Injective (subsetProduct w)) :
  477. Function.Injective (rotatedCopy b w) := by
  478. rintro ⟨i, S⟩ ⟨j, T⟩ he
  479. have hnorm := congrArg norm he
  480. simp only [rotatedCopy, norm_mul, subsetProduct_norm w hw, mul_one] at hnorm
  481. have hij := hn hnorm
  482. subst j
  483. have hST := hprod (mul_left_cancel₀ (hb i) he)
  484. exact Prod.ext rfl hST
  485. theorem rotatedCopy_convexIndependent {I E : Type*} [Fintype E]
  486. (b : I → ℂ) (w : E → ℂ) (hb : ∀ i, b i ≠ 0)
  487. (hn : Function.Injective (fun i => ‖b i‖)) (hb1 : ∀ i, ‖b i‖ ≤ 1)
  488. (hw : ∀ e, ‖w e‖ = 1) (hprod : Function.Injective (subsetProduct w))
  489. (hsupport : ∀ i j, i ≠ j → support (b i) (b j) < -2 * ∑ e, ‖w e - 1‖) :
  490. ConvexIndependent ℝ (rotatedCopy b w) := by
  491. apply convexIndependent_of_support
  492. rintro ⟨i, S⟩ ⟨j, T⟩ hne
  493. by_cases hij : i = j
  494. · subst j
  495. apply support_negative_of_equal_norm
  496. · exact fun h => hne (rotatedCopy_injective b w hb hn hw hprod h)
  497. · simp only [rotatedCopy, norm_mul, subsetProduct_norm w hw]
  498. · have hbound := rotated_support_bound (hb1 i) (hb1 j)
  499. (subsetProduct_norm w hw S) (subsetProduct_norm w hw T)
  500. (subsetProduct_close w hw S) (subsetProduct_close w hw T)
  501. dsimp [rotatedCopy]
  502. linarith [hsupport i j hij]
  503. theorem rotatedCopy_unit_edge {I E : Type*} [DecidableEq E]
  504. (b : I → ℂ) (w : E → ℂ) (hw : ∀ e, ‖w e‖ = 1)
  505. (i j : I) (e : E) (he : ‖b i - b j * w e‖ = 1)
  506. (S : Finset E) (hS : e ∉ S) :
  507. dist (rotatedCopy b w (i, S)) (rotatedCopy b w (j, insert e S)) = 1 := by
  508. simp only [rotatedCopy, subsetProduct, Finset.prod_insert hS, dist_eq_norm]
  509. rw [show b i * (∏ f ∈ S, w f) - b j * (w e * ∏ f ∈ S, w f) =
  510. (b i - b j * w e) * ∏ f ∈ S, w f by ring]
  511. rw [norm_mul, he, norm_subset_prod S w (fun f _ => hw f), one_mul]
  512. end
  513. end Proof
  514. end OriginalAmplification
  515. /- ## GenericRotations -/
  516. section OriginalGenericRotations
  517. /- Distinct subset products of correction rotations in every feasible open radius set. -/
  518. namespace Proof
  519. open Set Filter
  520. open scoped Topology
  521. noncomputable section
  522. def edgeAngleSum {L P E : Type*} [Fintype E] (l : E → L) (p : E → P)
  523. (a : E → ℝ) (z : (L → ℝ) × (P → ℝ)) : ℝ :=
  524. ∑ e, a e * chordAngle (z.1 (l e)) (z.2 (p e))
  525. theorem edge_angle_rectangle {L P E : Type*} [Fintype E]
  526. [DecidableEq L] [DecidableEq P] [DecidableEq E]
  527. (l : E → L) (p : E → P) (hij : Function.Injective (fun e => (l e, p e)))
  528. (a : E → ℝ) (r : L → ℝ) (s : P → ℝ) (e : E) (x y : ℝ) :
  529. edgeAngleSum l p a (Function.update r (l e) x, Function.update s (p e) y) -
  530. edgeAngleSum l p a (r, Function.update s (p e) y) -
  531. edgeAngleSum l p a (Function.update r (l e) x, s) + edgeAngleSum l p a (r, s) =
  532. a e * (chordAngle x y - chordAngle (r (l e)) y - chordAngle x (s (p e)) +
  533. chordAngle (r (l e)) (s (p e))) := by
  534. let g := fun f => a f * (chordAngle (Function.update r (l e) x (l f)) (Function.update s (p e) y (p f)) -
  535. chordAngle (r (l f)) (Function.update s (p e) y (p f)) -
  536. chordAngle (Function.update r (l e) x (l f)) (s (p f)) + chordAngle (r (l f)) (s (p f)))
  537. have he : edgeAngleSum l p a (Function.update r (l e) x, Function.update s (p e) y) -
  538. edgeAngleSum l p a (r, Function.update s (p e) y) -
  539. edgeAngleSum l p a (Function.update r (l e) x, s) + edgeAngleSum l p a (r, s) = ∑ f, g f := by
  540. simp only [g, edgeAngleSum, mul_add, mul_sub, Finset.sum_add_distrib, Finset.sum_sub_distrib]
  541. rw [he, Finset.sum_eq_single e]
  542. · simp [g]
  543. · intro f _ hfe
  544. by_cases hl : l f = l e
  545. · have hp : p f ≠ p e := fun hh => hfe (hij (Prod.ext hl hh))
  546. simp [g, Function.update_of_ne hp]
  547. · simp [g, Function.update_of_ne hl]
  548. · simp
  549. theorem edge_angle_sum_not_constant {L P E : Type*} [Fintype E]
  550. [DecidableEq L] [DecidableEq P] [DecidableEq E]
  551. (l : E → L) (p : E → P) (hij : Function.Injective (fun e => (l e, p e)))
  552. (a : E → ℝ) (e : E) (ha : a e ≠ 0)
  553. (U : Set ((L → ℝ) × (P → ℝ))) (hU : IsOpen U) (hne : U.Nonempty)
  554. (hf : ∀ z ∈ U, ChordFeasible (z.1 (l e)) (z.2 (p e))) (k : ℝ) :
  555. ∃ z ∈ U, edgeAngleSum l p a z ≠ k := by
  556. by_contra hnone
  557. push Not at hnone
  558. obtain ⟨z, hz⟩ := hne
  559. obtain ⟨b, d, hb, hd, hrect⟩ := coordinate_rectangle hU hz (l e) (p e)
  560. have hfeas : ∀ x ∈ Icc (z.1 (l e)) b, ∀ y ∈ Icc (z.2 (p e)) d, ChordFeasible x y := by
  561. intro x hx y hy
  562. simpa using hf _ (hrect x hx y hy)
  563. have hpositive := chordAngle_rectangle_strict hb hd hfeas
  564. have h00 := hnone z hz
  565. have h11 := hnone _ (hrect b ⟨hb.le, le_rfl⟩ d ⟨hd.le, le_rfl⟩)
  566. have h01 := hnone _ (hrect (z.1 (l e)) ⟨le_rfl, hb.le⟩ d ⟨hd.le, le_rfl⟩)
  567. have h10 := hnone _ (hrect b ⟨hb.le, le_rfl⟩ (z.2 (p e)) ⟨le_rfl, hd.le⟩)
  568. simp only [Function.update_eq_self] at h01 h10
  569. have hid := edge_angle_rectangle l p hij a z.1 z.2 e b d
  570. rw [h00, h11, h01, h10] at hid
  571. have hzero : a e * (chordAngle b d - chordAngle (z.1 (l e)) d -
  572. chordAngle b (z.2 (p e)) + chordAngle (z.1 (l e)) (z.2 (p e))) = 0 := by linarith
  573. exact mul_ne_zero ha (ne_of_gt hpositive) hzero
  574. theorem edge_angles_continuousAt {L P E : Type*} [Fintype E]
  575. (l : E → L) (p : E → P) (a : E → ℝ) (z : (L → ℝ) × (P → ℝ))
  576. (hr : ∀ i, z.1 i ≠ 0) (hs : ∀ j, z.2 j ≠ 0) : ContinuousAt (edgeAngleSum l p a) z := by
  577. unfold edgeAngleSum chordAngle chordCos
  578. fun_prop (disch := aesop)
  579. def subsetDifference {E : Type*} [DecidableEq E] (S T : Finset E) (e : E) : ℝ :=
  580. (if e ∈ S then 1 else 0) - (if e ∈ T then 1 else 0)
  581. theorem subsetDifference_sum {E : Type*} [Fintype E] [DecidableEq E]
  582. (S T : Finset E) (f : E → ℝ) :
  583. ∑ e, subsetDifference S T e * f e = (∑ e ∈ S, f e) - ∑ e ∈ T, f e := by
  584. simp [subsetDifference, sub_mul, ite_mul, Finset.sum_sub_distrib]
  585. theorem subsetDifference_nonzero {E : Type*} [DecidableEq E]
  586. {S T : Finset E} (hne : S ≠ T) : ∃ e, subsetDifference S T e ≠ 0 := by
  587. by_contra hh
  588. push Not at hh
  589. apply hne
  590. ext e
  591. have he := hh e
  592. by_cases hS : e ∈ S <;> by_cases hT : e ∈ T <;> simp_all [subsetDifference]
  593. def phaseRotations {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)
  594. (z : (L → ℝ) × (P → ℝ)) (e : E) : ℂ :=
  595. Complex.exp (((θ e - chordAngle (z.1 (l e)) (z.2 (p e)) : ℝ) : ℂ) * Complex.I)
  596. theorem phaseRotations_norm {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)
  597. (z : (L → ℝ) × (P → ℝ)) (e : E) : ‖phaseRotations l p θ z e‖ = 1 := by
  598. exact Complex.norm_exp_ofReal_mul_I _
  599. theorem exp_phase_small_injective {x y : ℝ} (hsmall : |x - y| < Real.pi)
  600. (he : Complex.exp ((x : ℂ) * Complex.I) = Complex.exp ((y : ℂ) * Complex.I)) : x = y := by
  601. have hexp : Complex.exp (((x - y : ℝ) : ℂ) * Complex.I) = Complex.exp 0 := by
  602. rw [Complex.ofReal_sub, sub_mul, Complex.exp_sub, he, div_self (Complex.exp_ne_zero _), Complex.exp_zero]
  603. have hxy := abs_lt.mp hsmall
  604. have hh := Complex.exp_inj_of_neg_pi_lt_of_le_pi
  605. (x := ((x - y : ℝ) : ℂ) * Complex.I) (y := 0)
  606. (by simpa using hxy.1) (by simpa using hxy.2.le)
  607. (by simpa using neg_neg_of_pos Real.pi_pos) (by simpa using Real.pi_pos.le) hexp
  608. have := congrArg Complex.im hh
  609. exact sub_eq_zero.mp (by simpa using this)
  610. theorem subsetProduct_phase {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)
  611. (z : (L → ℝ) × (P → ℝ)) (S : Finset E) :
  612. subsetProduct (phaseRotations l p θ z) S =
  613. Complex.exp (((∑ e ∈ S, (θ e - chordAngle (z.1 (l e)) (z.2 (p e))) : ℝ) : ℂ) * Complex.I) := by
  614. unfold subsetProduct phaseRotations
  615. rw [← Complex.exp_sum]
  616. congr 1
  617. simp [Complex.ofReal_sum, Finset.sum_sub_distrib, sub_mul, Finset.sum_mul]
  618. def relationPhase {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)
  619. (S T : Finset E) (z : (L → ℝ) × (P → ℝ)) : ℝ :=
  620. (∑ e ∈ S, (θ e - chordAngle (z.1 (l e)) (z.2 (p e)))) -
  621. ∑ e ∈ T, (θ e - chordAngle (z.1 (l e)) (z.2 (p e)))
  622. theorem relationPhase_eq {L P E : Type*} [Fintype E] [DecidableEq E]
  623. (l : E → L) (p : E → P) (θ : E → ℝ) (S T : Finset E) (z : (L → ℝ) × (P → ℝ)) :
  624. relationPhase l p θ S T z =
  625. (∑ e, subsetDifference S T e * θ e) - edgeAngleSum l p (subsetDifference S T) z := by
  626. unfold relationPhase edgeAngleSum
  627. rw [← Finset.sum_sub_distrib, ← subsetDifference_sum S T]
  628. apply Finset.sum_congr rfl
  629. intro e _
  630. ring
  631. theorem relationPhase_exp {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)
  632. (S T : Finset E) (z : (L → ℝ) × (P → ℝ))
  633. (he : subsetProduct (phaseRotations l p θ z) S = subsetProduct (phaseRotations l p θ z) T) :
  634. Complex.exp (((relationPhase l p θ S T z : ℝ) : ℂ) * Complex.I) = 1 := by
  635. unfold relationPhase
  636. rw [Complex.ofReal_sub, sub_mul, Complex.exp_sub,
  637. ← subsetProduct_phase l p θ z S, ← subsetProduct_phase l p θ z T, he]
  638. apply div_self
  639. rw [subsetProduct_phase]
  640. exact Complex.exp_ne_zero _
  641. theorem phaseRotations_continuousAt {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)
  642. (z : (L → ℝ) × (P → ℝ)) (hr : ∀ i, z.1 i ≠ 0) (hs : ∀ j, z.2 j ≠ 0) (e : E) :
  643. ContinuousAt (fun u => phaseRotations l p θ u e) z := by
  644. unfold phaseRotations chordAngle chordCos
  645. fun_prop (disch := aesop)
  646. theorem subset_products_separate {L P E : Type*} [Fintype E]
  647. [DecidableEq L] [DecidableEq P] [DecidableEq E]
  648. (l : E → L) (p : E → P) (hij : Function.Injective (fun e => (l e, p e)))
  649. (θ : E → ℝ) (U : Set ((L → ℝ) × (P → ℝ))) (hU : IsOpen U) (hne : U.Nonempty)
  650. (hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0))
  651. (hf : ∀ e, ∀ z ∈ U, ChordFeasible (z.1 (l e)) (z.2 (p e)))
  652. (S T : Finset E) (hST : S ≠ T) :
  653. ∃ z ∈ U, subsetProduct (phaseRotations l p θ z) S ≠ subsetProduct (phaseRotations l p θ z) T := by
  654. by_contra hnone
  655. push Not at hnone
  656. obtain ⟨e, he⟩ := subsetDifference_nonzero hST
  657. obtain ⟨z₀, hz₀⟩ := hne
  658. let φ := relationPhase l p θ S T
  659. have hc : ContinuousOn φ U := by
  660. intro z hz
  661. have hh : ContinuousAt (fun u => (∑ e, subsetDifference S T e * θ e) -
  662. edgeAngleSum l p (subsetDifference S T) u) z :=
  663. continuousAt_const.sub (edge_angles_continuousAt l p (subsetDifference S T) z (hnz z hz).1 (hnz z hz).2)
  664. change ContinuousWithinAt φ U z
  665. rw [show φ = fun u => (∑ e, subsetDifference S T e * θ e) -
  666. edgeAngleSum l p (subsetDifference S T) u by funext u; exact relationPhase_eq l p θ S T u]
  667. exact hh.continuousWithinAt
  668. let V := U ∩ (fun z => |φ z - φ z₀|) ⁻¹' Iio Real.pi
  669. have hVo : IsOpen V :=
  670. (hc.sub continuousOn_const).abs.isOpen_inter_preimage hU isOpen_Iio
  671. have hVne : V.Nonempty := ⟨z₀, hz₀, by simpa using Real.pi_pos⟩
  672. have hVU : V ⊆ U := inter_subset_left
  673. have hconstant : ∀ z ∈ V, edgeAngleSum l p (subsetDifference S T) z =
  674. (∑ e, subsetDifference S T e * θ e) - φ z₀ := by
  675. intro z hz
  676. have h1 := relationPhase_exp l p θ S T z (hnone z (hVU hz))
  677. have h0 := relationPhase_exp l p θ S T z₀ (hnone z₀ hz₀)
  678. have hphase : φ z = φ z₀ := exp_phase_small_injective hz.2 (h1.trans h0.symm)
  679. rw [show φ z = (∑ e, subsetDifference S T e * θ e) -
  680. edgeAngleSum l p (subsetDifference S T) z from relationPhase_eq l p θ S T z] at hphase
  681. linarith
  682. obtain ⟨z, hz, hh⟩ := edge_angle_sum_not_constant l p hij (subsetDifference S T) e he V hVo hVne
  683. (fun z hz => hf e z (hVU hz)) ((∑ e, subsetDifference S T e * θ e) - φ z₀)
  684. exact hh (hconstant z hz)
  685. theorem exists_injective_subsetProducts {L P E : Type*} [Fintype E]
  686. [DecidableEq L] [DecidableEq P] [DecidableEq E]
  687. (l : E → L) (p : E → P) (hij : Function.Injective (fun e => (l e, p e)))
  688. (θ : E → ℝ) (U : Set ((L → ℝ) × (P → ℝ))) (hU : IsOpen U) (hne : U.Nonempty)
  689. (hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0))
  690. (hf : ∀ e, ∀ z ∈ U, ChordFeasible (z.1 (l e)) (z.2 (p e))) :
  691. ∃ z ∈ U, Function.Injective (subsetProduct (phaseRotations l p θ z)) := by
  692. classical
  693. let K := {st : Finset E × Finset E // st.1 ≠ st.2}
  694. let f := fun (k : K) (z : (L → ℝ) × (P → ℝ)) =>
  695. subsetProduct (phaseRotations l p θ z) k.val.1 - subsetProduct (phaseRotations l p θ z) k.val.2
  696. have hc : ∀ k, ContinuousOn (f k) U := by
  697. intro k z hz
  698. have hrot := phaseRotations_continuousAt l p θ z (hnz z hz).1 (hnz z hz).2
  699. apply ContinuousAt.continuousWithinAt
  700. unfold f subsetProduct
  701. fun_prop
  702. have hnc : ∀ k, ∀ V : Set ((L → ℝ) × (P → ℝ)),
  703. V ⊆ U → IsOpen V → V.Nonempty → ∃ z ∈ V, f k z ≠ 0 := by
  704. intro k V hVU hVo hVne
  705. obtain ⟨z, hz, hh⟩ := subset_products_separate l p hij θ V hVo hVne
  706. (fun z hz => hnz z (hVU hz)) (fun e z hz => hf e z (hVU hz)) k.val.1 k.val.2 k.property
  707. exact ⟨z, hz, sub_ne_zero.mpr hh⟩
  708. obtain ⟨z, hz, hh⟩ := finite_avoidance f U hU hne hc hnc Finset.univ
  709. refine ⟨z, hz, ?_⟩
  710. intro S T heq
  711. by_contra hST
  712. exact hh (⟨(S, T), hST⟩ : K) (Finset.mem_univ _) (sub_eq_zero.mpr heq)
  713. end
  714. end Proof
  715. end OriginalGenericRotations
  716. /- ## CorrectionAlgebra -/
  717. section OriginalCorrectionAlgebra
  718. /- Exact algebraic correction of a fourth-order error in a unit distance. -/
  719. namespace Proof
  720. noncomputable section
  721. def correctionRadicand (ε t M q : ℝ) : ℝ :=
  722. t ^ 2 - ε ^ 2 * M ^ 2 * q - ε ^ 6 * M ^ 4 / 4
  723. def chordNumerator (ε t M : ℝ) (q : ℂ) : ℂ :=
  724. ⟨q.re + ε ^ 4 * M ^ 2 / 2, -ε * Real.sqrt (correctionRadicand ε t M q.re)⟩
  725. def correction (ε t M : ℝ) (q : ℂ) : ℂ := chordNumerator ε t M q / q
  726. def correctionCoefficient (ε t M : ℝ) (q : ℂ) : ℂ :=
  727. (⟨ε * M ^ 2 / 2,
  728. M ^ 2 * (q.re + ε ^ 4 * M ^ 2 / 4) /
  729. (Real.sqrt (correctionRadicand ε t M q.re) - t)⟩ : ℂ) / q
  730. theorem chordNumerator_normSq (ε t M : ℝ) (q : ℂ)
  731. (him : q.im = ε * t) (hF : 0 ≤ correctionRadicand ε t M q.re) :
  732. Complex.normSq (chordNumerator ε t M q) = Complex.normSq q := by
  733. have hs := Real.sq_sqrt hF
  734. simp only [chordNumerator, Complex.normSq_apply]
  735. rw [him]
  736. dsimp [correctionRadicand] at hs ⊢
  737. linear_combination ε ^ 2 * hs
  738. theorem correction_norm (ε t M : ℝ) (q : ℂ) (hq : q ≠ 0)
  739. (him : q.im = ε * t) (hF : 0 ≤ correctionRadicand ε t M q.re) :
  740. ‖correction ε t M q‖ = 1 := by
  741. have hh : Complex.normSq (correction ε t M q) = 1 := by
  742. rw [correction, Complex.normSq_div, chordNumerator_normSq ε t M q him hF]
  743. exact div_self (ne_of_gt (Complex.normSq_pos.mpr hq))
  744. rw [Complex.normSq_eq_norm_sq] at hh
  745. nlinarith [norm_nonneg (correction ε t M q)]
  746. theorem correction_cubic_identity (ε t M : ℝ) (q : ℂ) (hq : q ≠ 0)
  747. (him : q.im = ε * t) (hF : 0 ≤ correctionRadicand ε t M q.re)
  748. (hden : Real.sqrt (correctionRadicand ε t M q.re) - t ≠ 0) :
  749. correction ε t M q - 1 = (ε : ℂ) ^ 3 * correctionCoefficient ε t M q := by
  750. have hs := Real.sq_sqrt hF
  751. have he : chordNumerator ε t M q - q = (ε : ℂ) ^ 3 *
  752. (⟨ε * M ^ 2 / 2,
  753. M ^ 2 * (q.re + ε ^ 4 * M ^ 2 / 4) /
  754. (Real.sqrt (correctionRadicand ε t M q.re) - t)⟩ : ℂ) := by
  755. apply Complex.ext
  756. · simp only [chordNumerator, Complex.sub_re, Complex.mul_re, ← Complex.ofReal_pow,
  757. Complex.ofReal_re, Complex.ofReal_im, zero_mul, sub_zero]
  758. ring
  759. · simp only [chordNumerator, Complex.sub_im, Complex.mul_im,
  760. ← Complex.ofReal_pow, Complex.ofReal_re, Complex.ofReal_im, zero_mul, add_zero]
  761. rw [him]
  762. rw [← mul_div_assoc]
  763. apply (eq_div_iff hden).mpr
  764. dsimp [correctionRadicand] at hs ⊢
  765. linear_combination -ε * hs
  766. unfold correction correctionCoefficient
  767. rw [← div_self hq, ← sub_div, he, mul_div_assoc]
  768. theorem correction_unit_distance (a b : ℂ) (ε t M : ℝ)
  769. (hq : starRingEnd ℂ a * b ≠ 0)
  770. (him : (starRingEnd ℂ a * b).im = ε * t)
  771. (hF : 0 ≤ correctionRadicand ε t M (starRingEnd ℂ a * b).re)
  772. (hdist : Complex.normSq (b - a) = 1 + ε ^ 4 * M ^ 2) :
  773. ‖a - b * correction ε t M (starRingEnd ℂ a * b)‖ = 1 := by
  774. let q := starRingEnd ℂ a * b
  775. let w := correction ε t M q
  776. have hw : ‖w‖ = 1 := correction_norm ε t M q hq him hF
  777. have hz : starRingEnd ℂ a * (b * w) = chordNumerator ε t M q := by
  778. change starRingEnd ℂ a * (b * (chordNumerator ε t M q / q)) = _
  779. rw [← mul_assoc]
  780. exact mul_div_cancel₀ _ hq
  781. have hreal : (a * starRingEnd ℂ (b * w)).re = q.re + ε ^ 4 * M ^ 2 / 2 := by
  782. have hh := congrArg Complex.re hz
  783. simp only [Complex.mul_re, Complex.mul_im, Complex.conj_re, Complex.conj_im,
  784. chordNumerator] at hh ⊢
  785. linarith
  786. have hbase : Complex.normSq a + Complex.normSq b - 2 * q.re = 1 + ε ^ 4 * M ^ 2 := by
  787. simpa [Complex.normSq_sub, q, mul_comm, add_comm] using hdist
  788. have hns : Complex.normSq (a - b * w) = 1 := by
  789. rw [Complex.normSq_sub, Complex.normSq_mul, Complex.normSq_eq_norm_sq w, hw, one_pow, mul_one,
  790. hreal]
  791. linarith
  792. rw [Complex.normSq_eq_norm_sq] at hns
  793. nlinarith [norm_nonneg (a - b * w)]
  794. end
  795. end Proof
  796. end OriginalCorrectionAlgebra
  797. /- ## SeedGerms -/
  798. section OriginalSeedGerms
  799. /- Continuous formulas for the small correction rotations at a seed. -/
  800. namespace Proof
  801. open Filter
  802. open scoped Topology
  803. noncomputable section
  804. def seedTangent (ε x t y u : ℝ) : ℝ :=
  805. (x - y) / 2 + ε ^ 2 * (x * pointD y u + y * lineC x t)
  806. def seedProduct (ε x t y u : ℝ) : ℂ :=
  807. starRingEnd ℂ (lineSeed ε x t) * pointSeed ε y u
  808. def seedCoefficient (ε x t y u : ℝ) : ℂ :=
  809. correctionCoefficient ε (seedTangent ε x t y u) (pointD y u - lineC x t)
  810. (seedProduct ε x t y u)
  811. def seedCorrection (ε x t y u : ℝ) : ℂ :=
  812. correction ε (seedTangent ε x t y u) (pointD y u - lineC x t)
  813. (seedProduct ε x t y u)
  814. theorem seedProduct_im (ε x t y u : ℝ) :
  815. (seedProduct ε x t y u).im = ε * seedTangent ε x t y u := by
  816. simp [seedProduct, seedTangent, lineSeed, pointSeed, Complex.mul_im]
  817. ring
  818. theorem seedProduct_zero (x t y u : ℝ) : seedProduct 0 x t y u = (-1 / 4 : ℂ) := by
  819. apply Complex.ext <;> norm_num [seedProduct, lineSeed, pointSeed, Complex.mul_re, Complex.mul_im]
  820. theorem continuous_lineSeed (x t : ℝ) : Continuous (fun ε => lineSeed ε x t) := by
  821. unfold lineSeed
  822. simp only [Complex.mk_eq_add_mul_I]
  823. fun_prop
  824. theorem continuous_pointSeed (x t : ℝ) : Continuous (fun ε => pointSeed ε x t) := by
  825. unfold pointSeed
  826. simp only [Complex.mk_eq_add_mul_I]
  827. fun_prop
  828. theorem continuous_seedProduct (x t y u : ℝ) : Continuous (fun ε => seedProduct ε x t y u) := by
  829. exact ((continuous_lineSeed x t).star).mul (continuous_pointSeed y u)
  830. theorem continuous_seedTangent (x t y u : ℝ) : Continuous (fun ε => seedTangent ε x t y u) := by
  831. unfold seedTangent
  832. fun_prop
  833. theorem seed_radicand_zero (x t y u : ℝ) :
  834. correctionRadicand 0 (seedTangent 0 x t y u) (pointD y u - lineC x t)
  835. (seedProduct 0 x t y u).re = ((x - y) / 2) ^ 2 := by
  836. simp [correctionRadicand, seedTangent]
  837. theorem seed_denominator_pos (x t y u : ℝ) (hxy : x < y) :
  838. 0 < Real.sqrt (correctionRadicand 0 (seedTangent 0 x t y u)
  839. (pointD y u - lineC x t) (seedProduct 0 x t y u).re) - seedTangent 0 x t y u := by
  840. rw [seed_radicand_zero]
  841. simp only [seedTangent, zero_pow (by decide : 2 ≠ 0), zero_mul, add_zero]
  842. rw [Real.sqrt_sq_eq_abs, abs_of_neg (by linarith : (x - y) / 2 < 0)]
  843. linarith
  844. theorem continuousAt_seedCoefficient (x t y u : ℝ) (hxy : x < y) :
  845. ContinuousAt (fun ε => seedCoefficient ε x t y u) 0 := by
  846. have hq : seedProduct 0 x t y u ≠ 0 := by rw [seedProduct_zero]; norm_num
  847. have hden := ne_of_gt (seed_denominator_pos x t y u hxy)
  848. have hcq := (continuous_seedProduct x t y u).continuousAt (x := 0)
  849. have hct := (continuous_seedTangent x t y u).continuousAt (x := 0)
  850. unfold seedCoefficient correctionCoefficient
  851. apply ContinuousAt.div _ hcq hq
  852. simp only [Complex.mk_eq_add_mul_I]
  853. have hreal : ContinuousAt (fun ε =>
  854. (pointD y u - lineC x t) ^ 2 *
  855. ((seedProduct ε x t y u).re + ε ^ 4 * (pointD y u - lineC x t) ^ 2 / 4) /
  856. (Real.sqrt (correctionRadicand ε (seedTangent ε x t y u)
  857. (pointD y u - lineC x t) (seedProduct ε x t y u).re) - seedTangent ε x t y u)) 0 := by
  858. apply ContinuousAt.div
  859. · fun_prop
  860. · unfold correctionRadicand
  861. fun_prop
  862. · exact hden
  863. fun_prop
  864. theorem seedCorrection_properties (x t y u : ℝ) (hxy : x < y)
  865. (hinc : u - t = (y - x) ^ 2) :
  866. ∀ᶠ ε in 𝓝 (0 : ℝ),
  867. ‖seedCorrection ε x t y u‖ = 1 ∧
  868. ‖lineSeed ε x t - pointSeed ε y u * seedCorrection ε x t y u‖ = 1 ∧
  869. seedCorrection ε x t y u - 1 = (ε : ℂ) ^ 3 * seedCoefficient ε x t y u := by
  870. have hq : ∀ᶠ ε in 𝓝 (0 : ℝ), seedProduct ε x t y u ≠ 0 :=
  871. (continuous_seedProduct x t y u).continuousAt.eventually_ne (by rw [seedProduct_zero]; norm_num)
  872. have hFcont : Continuous (fun ε => correctionRadicand ε (seedTangent ε x t y u)
  873. (pointD y u - lineC x t) (seedProduct ε x t y u).re) := by
  874. unfold correctionRadicand
  875. have ht := continuous_seedTangent x t y u
  876. have hq := continuous_seedProduct x t y u
  877. fun_prop
  878. have hF : ∀ᶠ ε in 𝓝 (0 : ℝ), 0 < correctionRadicand ε (seedTangent ε x t y u)
  879. (pointD y u - lineC x t) (seedProduct ε x t y u).re := by
  880. apply continuousAt_const.eventually_lt hFcont.continuousAt
  881. rw [seed_radicand_zero]
  882. exact sq_pos_of_ne_zero (by linarith)
  883. have hdc : Continuous (fun ε => Real.sqrt (correctionRadicand ε (seedTangent ε x t y u)
  884. (pointD y u - lineC x t) (seedProduct ε x t y u).re) - seedTangent ε x t y u) :=
  885. hFcont.sqrt.sub (continuous_seedTangent x t y u)
  886. have hd := hdc.continuousAt.eventually_ne (ne_of_gt (seed_denominator_pos x t y u hxy))
  887. filter_upwards [hq, hF, hd] with ε hq hF hd
  888. exact ⟨correction_norm _ _ _ _ hq (seedProduct_im ε x t y u) hF.le,
  889. correction_unit_distance _ _ _ _ _ hq (seedProduct_im ε x t y u) hF.le
  890. (incidence_distance_identity ε x t y u hinc),
  891. correction_cubic_identity _ _ _ _ hq (seedProduct_im ε x t y u) hF.le hd⟩
  892. theorem seedCorrection_im_negative (x t y u : ℝ) (hxy : x < y) :
  893. ∀ᶠ ε in 𝓝[>] (0 : ℝ),
  894. (seedProduct ε x t y u * seedCorrection ε x t y u).im < 0 := by
  895. have hq : ∀ᶠ ε in 𝓝 (0 : ℝ), seedProduct ε x t y u ≠ 0 :=
  896. (continuous_seedProduct x t y u).continuousAt.eventually_ne (by rw [seedProduct_zero]; norm_num)
  897. have hFcont : Continuous (fun ε => correctionRadicand ε (seedTangent ε x t y u)
  898. (pointD y u - lineC x t) (seedProduct ε x t y u).re) := by
  899. unfold correctionRadicand
  900. have ht := continuous_seedTangent x t y u
  901. have hq := continuous_seedProduct x t y u
  902. fun_prop
  903. have hF : ∀ᶠ ε in 𝓝 (0 : ℝ), 0 < correctionRadicand ε (seedTangent ε x t y u)
  904. (pointD y u - lineC x t) (seedProduct ε x t y u).re := by
  905. apply continuousAt_const.eventually_lt hFcont.continuousAt
  906. rw [seed_radicand_zero]
  907. exact sq_pos_of_ne_zero (by linarith)
  908. filter_upwards [hq.filter_mono nhdsWithin_le_nhds, hF.filter_mono nhdsWithin_le_nhds,
  909. self_mem_nhdsWithin] with ε hq hF (hε : 0 < ε)
  910. change (seedProduct ε x t y u * (chordNumerator ε (seedTangent ε x t y u)
  911. (pointD y u - lineC x t) (seedProduct ε x t y u) / seedProduct ε x t y u)).im < 0
  912. rw [mul_div_cancel₀ _ hq]
  913. change -ε * Real.sqrt (correctionRadicand ε (seedTangent ε x t y u)
  914. (pointD y u - lineC x t) (seedProduct ε x t y u).re) < 0
  915. exact mul_neg_of_neg_of_pos (neg_neg_of_pos hε) (Real.sqrt_pos.mpr hF)
  916. end
  917. end Proof
  918. end OriginalSeedGerms
  919. /- ## SeedLimits -/
  920. section OriginalSeedLimits
  921. /- Choosing one sufficiently small positive parameter for finitely many seed inequalities. -/
  922. namespace Proof
  923. open Filter
  924. open scoped Topology
  925. noncomputable section
  926. theorem eventually_scaled_ne (a b : ℝ → ℂ) (F : ℝ → ℝ)
  927. (hF : ContinuousAt F 0) (hF0 : F 0 ≠ 0)
  928. (hid : ∀ ε, Complex.normSq (a ε) - Complex.normSq (b ε) = ε ^ 2 * F ε) :
  929. ∀ᶠ ε in 𝓝[>] (0 : ℝ), ‖a ε‖ ≠ ‖b ε‖ := by
  930. have he : ∀ᶠ ε in 𝓝[>] (0 : ℝ), F ε ≠ 0 :=
  931. (hF.eventually_ne hF0).filter_mono nhdsWithin_le_nhds
  932. filter_upwards [he, self_mem_nhdsWithin] with ε hFε (hε : 0 < ε)
  933. intro hn
  934. have hs : Complex.normSq (a ε) = Complex.normSq (b ε) := by
  935. simp only [Complex.normSq_eq_norm_sq, hn]
  936. have hz := hid ε
  937. rw [hs, sub_self] at hz
  938. exact mul_ne_zero (pow_ne_zero 2 (ne_of_gt hε)) hFε hz.symm
  939. theorem eventually_scaled_support (a b : ℝ → ℂ) (A F : ℝ → ℝ)
  940. (hF : ContinuousAt F 0) (hF0 : F 0 < 0)
  941. (hid : ∀ ε, support (a ε) (b ε) + ε ^ 3 * A ε = ε ^ 2 * F ε) :
  942. ∀ᶠ ε in 𝓝[>] (0 : ℝ), support (a ε) (b ε) < -ε ^ 3 * A ε := by
  943. have he : ∀ᶠ ε in 𝓝[>] (0 : ℝ), F ε < 0 :=
  944. (hF.eventually_lt continuousAt_const hF0).filter_mono nhdsWithin_le_nhds
  945. filter_upwards [he, self_mem_nhdsWithin] with ε hFε (hε : 0 < ε)
  946. have hh : ε ^ 2 * F ε < 0 := mul_neg_of_pos_of_neg (pow_pos hε 2) hFε
  947. linarith [hid ε]
  948. theorem eventually_line_support (x t y u : ℝ) (A : ℝ → ℝ)
  949. (hA : ContinuousAt A 0) (hm : -(y - x) ^ 2 / 2 - (u - t) / 4 < 0) :
  950. ∀ᶠ ε in 𝓝[>] (0 : ℝ), support (lineSeed ε x t) (lineSeed ε y u) < -ε ^ 3 * A ε := by
  951. let F := fun ε => -(y - x) ^ 2 / 2 - (u - t) / 4 +
  952. ε ^ 2 * lineC x t * (lineC y u - lineC x t) + ε * A ε
  953. apply eventually_scaled_support _ _ A F
  954. · unfold F; fun_prop
  955. · simpa [F] using hm
  956. · intro ε
  957. rw [line_support_identity]
  958. dsimp [F]
  959. ring
  960. theorem eventually_point_support (x t y u : ℝ) (A : ℝ → ℝ)
  961. (hA : ContinuousAt A 0) (hm : -(y - x) ^ 2 / 2 + (u - t) / 4 < 0) :
  962. ∀ᶠ ε in 𝓝[>] (0 : ℝ), support (pointSeed ε x t) (pointSeed ε y u) < -ε ^ 3 * A ε := by
  963. let F := fun ε => -(y - x) ^ 2 / 2 + (u - t) / 4 +
  964. ε ^ 2 * pointD x t * (pointD y u - pointD x t) + ε * A ε
  965. apply eventually_scaled_support _ _ A F
  966. · unfold F; fun_prop
  967. · simpa [F] using hm
  968. · intro ε
  969. rw [point_support_identity]
  970. dsimp [F]
  971. ring
  972. theorem eventually_cross_support (x t y u : ℝ) (A : ℝ → ℝ) (hA : ContinuousAt A 0) :
  973. ∀ᶠ ε in 𝓝[>] (0 : ℝ),
  974. support (lineSeed ε x t) (pointSeed ε y u) < -ε ^ 3 * A ε ∧
  975. support (pointSeed ε y u) (lineSeed ε x t) < -ε ^ 3 * A ε := by
  976. have hc₁ : ContinuousAt (fun ε => support (lineSeed ε x t) (pointSeed ε y u) + ε ^ 3 * A ε) 0 := by
  977. unfold support lineSeed pointSeed; fun_prop
  978. have hc₂ : ContinuousAt (fun ε => support (pointSeed ε y u) (lineSeed ε x t) + ε ^ 3 * A ε) 0 := by
  979. unfold support lineSeed pointSeed; fun_prop
  980. have h₁ : ∀ᶠ ε in 𝓝 (0 : ℝ), support (lineSeed ε x t) (pointSeed ε y u) + ε ^ 3 * A ε < 0 :=
  981. hc₁.eventually_lt continuousAt_const (by norm_num [support, lineSeed, pointSeed])
  982. have h₂ : ∀ᶠ ε in 𝓝 (0 : ℝ), support (pointSeed ε y u) (lineSeed ε x t) + ε ^ 3 * A ε < 0 :=
  983. hc₂.eventually_lt continuousAt_const (by norm_num [support, lineSeed, pointSeed])
  984. filter_upwards [h₁.filter_mono nhdsWithin_le_nhds, h₂.filter_mono nhdsWithin_le_nhds] with ε h₁ h₂
  985. constructor <;> linarith
  986. theorem eventually_line_norm_ne (x t y u : ℝ) (htu : t ≠ u) :
  987. ∀ᶠ ε in 𝓝[>] (0 : ℝ), ‖lineSeed ε x t‖ ≠ ‖lineSeed ε y u‖ := by
  988. apply eventually_scaled_ne _ _ (fun ε => -(t - u) / 2 + ε ^ 2 * ((lineC x t) ^ 2 - (lineC y u) ^ 2))
  989. · fun_prop
  990. · simp only [zero_pow (by decide : 2 ≠ 0), zero_mul, add_zero]
  991. exact div_ne_zero (neg_ne_zero.mpr (sub_ne_zero.mpr htu)) (by norm_num)
  992. · intro ε
  993. rw [line_normSq, line_normSq]
  994. ring
  995. theorem eventually_point_norm_ne (x t y u : ℝ) (htu : t ≠ u) :
  996. ∀ᶠ ε in 𝓝[>] (0 : ℝ), ‖pointSeed ε x t‖ ≠ ‖pointSeed ε y u‖ := by
  997. apply eventually_scaled_ne _ _ (fun ε => (t - u) / 2 + ε ^ 2 * ((pointD x t) ^ 2 - (pointD y u) ^ 2))
  998. · fun_prop
  999. · simp only [zero_pow (by decide : 2 ≠ 0), zero_mul, add_zero]
  1000. exact div_ne_zero (sub_ne_zero.mpr htu) (by norm_num)
  1001. · intro ε
  1002. rw [point_normSq, point_normSq]
  1003. ring
  1004. theorem eventually_cross_norm_ne (x t y u : ℝ) (ht : 0 < t) (hu : 0 < u) :
  1005. ∀ᶠ ε in 𝓝[>] (0 : ℝ), ‖lineSeed ε x t‖ ≠ ‖pointSeed ε y u‖ := by
  1006. apply eventually_scaled_ne _ _ (fun ε => -(t + u) / 2 + ε ^ 2 * ((lineC x t) ^ 2 - (pointD y u) ^ 2))
  1007. · fun_prop
  1008. · simp only [zero_pow (by decide : 2 ≠ 0), zero_mul, add_zero]
  1009. linarith
  1010. · intro ε
  1011. rw [line_normSq, point_normSq]
  1012. ring
  1013. end
  1014. end Proof
  1015. end OriginalSeedLimits
  1016. /- ## Incidence -/
  1017. section OriginalIncidence
  1018. /- The coordinate incidence graph used in the construction. -/
  1019. namespace Proof
  1020. abbrev PointLabel (d : ℕ) := Fin d → Fin d
  1021. abbrev LineLabel (d : ℕ) := (i : Fin d) × ({j : Fin d // j ≠ i} → Fin d)
  1022. abbrev EdgeLabel (d : ℕ) := PointLabel d × Fin d
  1023. def edgePoint {d : ℕ} (e : EdgeLabel d) : PointLabel d := e.1
  1024. def edgeLine {d : ℕ} (e : EdgeLabel d) : LineLabel d := ⟨e.2, fun j => e.1 j⟩
  1025. theorem edge_endpoints_injective (d : ℕ) :
  1026. Function.Injective (fun e : EdgeLabel d => (edgeLine e, edgePoint e)) := by
  1027. intro e f h
  1028. have hpoint : e.1 = f.1 := congrArg Prod.snd h
  1029. have hline : e.2 = f.2 := congrArg (fun p => p.1.1) h
  1030. exact Prod.ext hpoint hline
  1031. theorem pointLabel_card (d : ℕ) : Fintype.card (PointLabel d) = d ^ d := by
  1032. simp [PointLabel]
  1033. theorem puncturedFin_card {d : ℕ} (i : Fin d) :
  1034. Fintype.card {j : Fin d // j ≠ i} = d - 1 := by
  1035. simp
  1036. theorem lineLabel_card (d : ℕ) : Fintype.card (LineLabel d) = d * d ^ (d - 1) := by
  1037. simp [LineLabel, Fintype.card_sigma]
  1038. theorem edgeLabel_card (d : ℕ) : Fintype.card (EdgeLabel d) = d ^ (d + 1) := by
  1039. simp [EdgeLabel, pow_succ]
  1040. theorem vertexLabel_card {d : ℕ} (hd : 1 ≤ d) :
  1041. Fintype.card (LineLabel d ⊕ PointLabel d) = 2 * d ^ d := by
  1042. rw [Fintype.card_sum, lineLabel_card, pointLabel_card]
  1043. have hpow : d * d ^ (d - 1) = d ^ d := by
  1044. rw [← pow_succ', Nat.sub_add_cancel hd]
  1045. omega
  1046. end Proof
  1047. end OriginalIncidence
  1048. /- ## Digits -/
  1049. section OriginalDigits
  1050. /- Separation of distinct finite sums of powers of five. -/
  1051. namespace Proof
  1052. noncomputable section
  1053. def digitSum (q : ℝ) (s : Finset ℕ) : ℝ := ∑ i ∈ s, q ^ i
  1054. theorem geometric_five (n : ℕ) :
  1055. 4 * (∑ i ∈ Finset.range n, (5 : ℝ) ^ i) = (5 : ℝ) ^ n - 1 := by
  1056. induction n with
  1057. | zero => norm_num
  1058. | succ n ih => rw [Finset.sum_range_succ, pow_succ]; linarith
  1059. theorem geometric_twentyfive (n : ℕ) :
  1060. 24 * (∑ i ∈ Finset.range n, (25 : ℝ) ^ i) = (25 : ℝ) ^ n - 1 := by
  1061. induction n with
  1062. | zero => norm_num
  1063. | succ n ih => rw [Finset.sum_range_succ, pow_succ]; linarith
  1064. theorem dominant_digit_bounds {q : ℝ} (hq : 0 ≤ q) {A B : Finset ℕ} {h : ℕ}
  1065. (hdis : Disjoint A B) (hmem : h ∈ A) (hmax : ∀ j ∈ A ∪ B, j ≤ h) :
  1066. q ^ h - (∑ i ∈ Finset.range h, q ^ i) ≤ digitSum q A - digitSum q B ∧
  1067. digitSum q A - digitSum q B ≤ q ^ h + (∑ i ∈ Finset.range h, q ^ i) := by
  1068. have hsubB : B ⊆ Finset.range h := by
  1069. intro j hj
  1070. have hle := hmax j (Finset.mem_union_right A hj)
  1071. have hne : j ≠ h := by
  1072. intro he
  1073. exact (Finset.disjoint_left.mp hdis hmem) (he ▸ hj)
  1074. exact Finset.mem_range.mpr (lt_of_le_of_ne hle hne)
  1075. have hsubA : A ⊆ Finset.range (h + 1) := by
  1076. intro j hj
  1077. exact Finset.mem_range.mpr (Nat.lt_succ_of_le (hmax j (Finset.mem_union_left B hj)))
  1078. have hAlo : q ^ h ≤ digitSum q A :=
  1079. Finset.single_le_sum (fun j _ => pow_nonneg hq j) hmem
  1080. have hBlo : 0 ≤ digitSum q B := Finset.sum_nonneg (fun j _ => pow_nonneg hq j)
  1081. have hAhi : digitSum q A ≤ ∑ i ∈ Finset.range (h + 1), q ^ i :=
  1082. Finset.sum_le_sum_of_subset_of_nonneg hsubA (fun j _ _ => pow_nonneg hq j)
  1083. have hBhi : digitSum q B ≤ ∑ i ∈ Finset.range h, q ^ i :=
  1084. Finset.sum_le_sum_of_subset_of_nonneg hsubB (fun j _ _ => pow_nonneg hq j)
  1085. rw [Finset.sum_range_succ] at hAhi
  1086. constructor <;> linarith
  1087. theorem dominant_five_separation {A B : Finset ℕ} {h : ℕ}
  1088. (hdis : Disjoint A B) (hmem : h ∈ A) (hmax : ∀ j ∈ A ∪ B, j ≤ h) :
  1089. 0 < digitSum 5 A - digitSum 5 B ∧
  1090. 0 < digitSum 25 A - digitSum 25 B ∧
  1091. digitSum 25 A - digitSum 25 B <
  1092. (50 / 27 : ℝ) * (digitSum 5 A - digitSum 5 B) ^ 2 := by
  1093. obtain ⟨h5lo, h5hi⟩ := dominant_digit_bounds (q := 5) (by norm_num) hdis hmem hmax
  1094. obtain ⟨h25lo, h25hi⟩ := dominant_digit_bounds (q := 25) (by norm_num) hdis hmem hmax
  1095. have g5 := geometric_five h
  1096. have g25 := geometric_twentyfive h
  1097. have hp5 : 0 < (5 : ℝ) ^ h := by positivity
  1098. have hp25 : 0 < (25 : ℝ) ^ h := by positivity
  1099. have hx : 3 / 4 * (5 : ℝ) ^ h < digitSum 5 A - digitSum 5 B := by linarith
  1100. have ht : digitSum 25 A - digitSum 25 B < 25 / 24 * (25 : ℝ) ^ h := by linarith
  1101. have hp : (25 : ℝ) ^ h = ((5 : ℝ) ^ h) ^ 2 := by
  1102. rw [← pow_mul, Nat.mul_comm, pow_mul]
  1103. norm_num
  1104. have hsq := mul_self_lt_mul_self (by positivity : (0 : ℝ) ≤ 3 / 4 * 5 ^ h) hx
  1105. refine ⟨by linarith, by linarith, ?_⟩
  1106. rw [hp] at ht
  1107. nlinarith
  1108. theorem digit_separation {s t : Finset ℕ} (hne : s ≠ t) :
  1109. digitSum 5 s ≠ digitSum 5 t ∧ digitSum 25 s ≠ digitSum 25 t ∧
  1110. |digitSum 25 s - digitSum 25 t| <
  1111. (50 / 27 : ℝ) * (digitSum 5 s - digitSum 5 t) ^ 2 := by
  1112. let A := s \ t
  1113. let B := t \ s
  1114. have hdis : Disjoint A B := by
  1115. simp only [A, B, Finset.disjoint_left, Finset.mem_sdiff]
  1116. aesop
  1117. have hneAB : (A ∪ B).Nonempty := by
  1118. by_contra hc
  1119. have he : A ∪ B = ∅ := Finset.not_nonempty_iff_eq_empty.mp hc
  1120. apply hne
  1121. ext i
  1122. have hi : i ∉ A ∪ B := by rw [he]; simp
  1123. simp only [A, B, Finset.mem_union, Finset.mem_sdiff] at hi
  1124. tauto
  1125. let h := (A ∪ B).max' hneAB
  1126. have hh : h ∈ A ∪ B := Finset.max'_mem _ _
  1127. have hmax : ∀ j ∈ A ∪ B, j ≤ h := fun j hj => Finset.le_max' _ j hj
  1128. have he5 : digitSum 5 s - digitSum 5 t = digitSum 5 A - digitSum 5 B := by
  1129. exact (Finset.sum_sdiff_sub_sum_sdiff (s₁ := t) (s₂ := s) (f := fun i => (5 : ℝ) ^ i)).symm
  1130. have he25 : digitSum 25 s - digitSum 25 t = digitSum 25 A - digitSum 25 B := by
  1131. exact (Finset.sum_sdiff_sub_sum_sdiff (s₁ := t) (s₂ := s) (f := fun i => (25 : ℝ) ^ i)).symm
  1132. rcases Finset.mem_union.mp hh with hh | hh
  1133. · obtain ⟨hx, ht, hbound⟩ := dominant_five_separation hdis hh hmax
  1134. refine ⟨?_, ?_, ?_⟩
  1135. · intro he; rw [he, sub_self] at he5; linarith
  1136. · intro he; rw [he, sub_self] at he25; linarith
  1137. · rw [he5, he25, abs_of_pos ht]; exact hbound
  1138. · have hmax' : ∀ j ∈ B ∪ A, j ≤ h := by simpa [Finset.union_comm] using hmax
  1139. obtain ⟨hx, ht, hbound⟩ := dominant_five_separation hdis.symm hh hmax'
  1140. refine ⟨?_, ?_, ?_⟩
  1141. · intro he; rw [he, sub_self] at he5; linarith
  1142. · intro he; rw [he, sub_self] at he25; linarith
  1143. · rw [he5, he25, abs_of_neg (by linarith : digitSum 25 A - digitSum 25 B < 0)]
  1144. nlinarith
  1145. end
  1146. end Proof
  1147. end OriginalDigits
  1148. /- ## LabelDigits -/
  1149. section OriginalLabelDigits
  1150. /- An injective assignment of lacunary digits to coordinate incidence labels. -/
  1151. namespace Proof
  1152. noncomputable section
  1153. def pointCells {d : ℕ} (p : PointLabel d) : Finset (Fin d × Fin d) :=
  1154. Finset.univ.image (fun i => (i, p i))
  1155. def lineCells {d : ℕ} (l : LineLabel d) : Finset (Fin d × Fin d) :=
  1156. Finset.univ.image (fun i : {j : Fin d // j ≠ l.1} => (i.val, l.2 i))
  1157. theorem mem_pointCells {d : ℕ} (p : PointLabel d) (i j : Fin d) :
  1158. (i, j) ∈ pointCells p ↔ p i = j := by
  1159. simp [pointCells]
  1160. theorem mem_lineCells {d : ℕ} (l : LineLabel d) (i j : Fin d) :
  1161. (i, j) ∈ lineCells l ↔ ∃ h : i ≠ l.1, l.2 ⟨i, h⟩ = j := by
  1162. simp [lineCells]
  1163. theorem pointCells_injective (d : ℕ) : Function.Injective (@pointCells d) := by
  1164. intro p q he
  1165. funext i
  1166. have hi : (i, p i) ∈ pointCells q := by rw [← he, mem_pointCells]
  1167. exact (mem_pointCells q i (p i)).mp hi |>.symm
  1168. theorem lineCells_injective (d : ℕ) : Function.Injective (@lineCells d) := by
  1169. rintro ⟨i, f⟩ ⟨j, g⟩ he
  1170. have hij : i = j := by
  1171. by_contra hne
  1172. have hj : (i, g ⟨i, hne⟩) ∈ lineCells ⟨j, g⟩ := by
  1173. rw [mem_lineCells]
  1174. exact ⟨hne, rfl⟩
  1175. rw [← he, mem_lineCells] at hj
  1176. obtain ⟨hbad, _⟩ := hj
  1177. exact hbad rfl
  1178. subst j
  1179. have hfg : f = g := by
  1180. funext k
  1181. have hk : (k.val, f k) ∈ lineCells ⟨i, g⟩ := by
  1182. rw [← he, mem_lineCells]
  1183. exact ⟨k.property, rfl⟩
  1184. obtain ⟨_, hh⟩ := (mem_lineCells _ _ _).mp hk
  1185. exact hh.symm
  1186. subst g
  1187. rfl
  1188. theorem incidence_cells {d : ℕ} (e : EdgeLabel d) :
  1189. pointCells (edgePoint e) = insert (e.2, e.1 e.2) (lineCells (edgeLine e)) := by
  1190. ext ⟨i, j⟩
  1191. simp only [Finset.mem_insert, mem_pointCells, mem_lineCells, edgePoint, edgeLine,
  1192. Prod.mk.injEq]
  1193. by_cases hi : i = e.2
  1194. · subst i
  1195. simp [eq_comm]
  1196. · simp [hi]
  1197. theorem completing_cell_absent {d : ℕ} (e : EdgeLabel d) :
  1198. (e.2, e.1 e.2) ∉ lineCells (edgeLine e) := by
  1199. simp [mem_lineCells, edgeLine]
  1200. def digitIndex (d : ℕ) : (Fin d × Fin d) ↪ ℕ :=
  1201. (Fintype.equivFin (Fin d × Fin d)).toEmbedding.trans ⟨Fin.val, Fin.val_injective⟩
  1202. def pointDigits {d : ℕ} (p : PointLabel d) : Finset ℕ := (pointCells p).map (digitIndex d)
  1203. def lineDigits {d : ℕ} (l : LineLabel d) : Finset ℕ := (lineCells l).map (digitIndex d)
  1204. theorem pointDigits_injective (d : ℕ) : Function.Injective (@pointDigits d) := by
  1205. intro p q he
  1206. exact pointCells_injective d (Finset.map_injective (digitIndex d) he)
  1207. theorem lineDigits_injective (d : ℕ) : Function.Injective (@lineDigits d) := by
  1208. intro p q he
  1209. exact lineCells_injective d (Finset.map_injective (digitIndex d) he)
  1210. def pointX {d : ℕ} (p : PointLabel d) : ℝ := digitSum 5 (pointDigits p)
  1211. def lineX {d : ℕ} (l : LineLabel d) : ℝ := digitSum 5 (lineDigits l)
  1212. def pointT {d : ℕ} (p : PointLabel d) : ℝ := 1 + digitSum 25 (pointDigits p)
  1213. def lineT {d : ℕ} (l : LineLabel d) : ℝ := 1 + digitSum 25 (lineDigits l)
  1214. theorem incidence_digit_identity {d : ℕ} (e : EdgeLabel d) :
  1215. let z : ℝ := 5 ^ (digitIndex d (e.2, e.1 e.2))
  1216. 0 < z ∧ pointX (edgePoint e) - lineX (edgeLine e) = z ∧
  1217. pointT (edgePoint e) - lineT (edgeLine e) = z ^ 2 := by
  1218. have hnew : digitIndex d (e.2, e.1 e.2) ∉ lineDigits (edgeLine e) := by
  1219. simp [lineDigits, completing_cell_absent]
  1220. have hcells : pointDigits (edgePoint e) =
  1221. insert (digitIndex d (e.2, e.1 e.2)) (lineDigits (edgeLine e)) := by
  1222. simp only [pointDigits, lineDigits, incidence_cells, Finset.map_insert]
  1223. dsimp only
  1224. refine ⟨by positivity, ?_, ?_⟩
  1225. · simp [pointX, lineX, digitSum, hcells, Finset.sum_insert hnew]
  1226. · simp only [pointT, lineT, hcells, digitSum, Finset.sum_insert hnew]
  1227. have hp : (25 : ℝ) ^ (digitIndex d (e.2, e.1 e.2)) =
  1228. ((5 : ℝ) ^ (digitIndex d (e.2, e.1 e.2))) ^ 2 := by
  1229. rw [← pow_mul, Nat.mul_comm, pow_mul]
  1230. norm_num
  1231. linarith
  1232. end
  1233. end Proof
  1234. end OriginalLabelDigits
  1235. /- ## SeedPattern -/
  1236. section OriginalSeedPattern
  1237. /- Abstract hypotheses on a finite incidence pattern and its lacunary realization. -/
  1238. namespace Proof
  1239. open Filter
  1240. open scoped Topology
  1241. noncomputable section
  1242. structure SeedPattern (L P E : Type*) where
  1243. line : E → L
  1244. point : E → P
  1245. endpoints_injective : Function.Injective (fun e => (line e, point e))
  1246. LX : L → ℝ
  1247. LT : L → ℝ
  1248. PX : P → ℝ
  1249. PT : P → ℝ
  1250. LT_pos : ∀ l, 0 < LT l
  1251. PT_pos : ∀ p, 0 < PT p
  1252. LT_injective : Function.Injective LT
  1253. PT_injective : Function.Injective PT
  1254. line_margin : ∀ l k, l ≠ k → -(LX k - LX l) ^ 2 / 2 - (LT k - LT l) / 4 < 0
  1255. point_margin : ∀ p q, p ≠ q → -(PX q - PX p) ^ 2 / 2 + (PT q - PT p) / 4 < 0
  1256. edge_positive : ∀ e, LX (line e) < PX (point e)
  1257. edge_identity : ∀ e, PT (point e) - LT (line e) = (PX (point e) - LX (line e)) ^ 2
  1258. def coordinatePattern (d : ℕ) : SeedPattern (LineLabel d) (PointLabel d) (EdgeLabel d) where
  1259. line := edgeLine
  1260. point := edgePoint
  1261. endpoints_injective := edge_endpoints_injective d
  1262. LX := lineX
  1263. LT := lineT
  1264. PX := pointX
  1265. PT := pointT
  1266. LT_pos l := by
  1267. have hh : 0 ≤ digitSum 25 (lineDigits l) := Finset.sum_nonneg (fun _ _ => by positivity)
  1268. dsimp [lineT]; linarith
  1269. PT_pos p := by
  1270. have hh : 0 ≤ digitSum 25 (pointDigits p) := Finset.sum_nonneg (fun _ _ => by positivity)
  1271. dsimp [pointT]; linarith
  1272. LT_injective := by
  1273. intro l k he
  1274. by_contra hne
  1275. have hh := (digit_separation ((lineDigits_injective d).ne hne)).2.1
  1276. apply hh
  1277. dsimp [lineT] at he
  1278. linarith
  1279. PT_injective := by
  1280. intro p q he
  1281. by_contra hne
  1282. have hh := (digit_separation ((pointDigits_injective d).ne hne)).2.1
  1283. apply hh
  1284. dsimp [pointT] at he
  1285. linarith
  1286. line_margin := by
  1287. intro l k hne
  1288. obtain ⟨hX, _, hsep⟩ := digit_separation ((lineDigits_injective d).ne hne.symm)
  1289. have hm := (signed_digit_margin hsep).1
  1290. have hsq : 0 < (digitSum 5 (lineDigits k) - digitSum 5 (lineDigits l)) ^ 2 :=
  1291. sq_pos_of_ne_zero (sub_ne_zero.mpr hX)
  1292. dsimp [lineX, lineT]
  1293. have he : 1 + digitSum 25 (lineDigits k) - (1 + digitSum 25 (lineDigits l)) =
  1294. digitSum 25 (lineDigits k) - digitSum 25 (lineDigits l) := by ring
  1295. rw [he]
  1296. linarith
  1297. point_margin := by
  1298. intro p q hne
  1299. obtain ⟨hX, _, hsep⟩ := digit_separation ((pointDigits_injective d).ne hne.symm)
  1300. have hm := (signed_digit_margin hsep).2
  1301. have hsq : 0 < (digitSum 5 (pointDigits q) - digitSum 5 (pointDigits p)) ^ 2 :=
  1302. sq_pos_of_ne_zero (sub_ne_zero.mpr hX)
  1303. dsimp [pointX, pointT]
  1304. have he : 1 + digitSum 25 (pointDigits q) - (1 + digitSum 25 (pointDigits p)) =
  1305. digitSum 25 (pointDigits q) - digitSum 25 (pointDigits p) := by ring
  1306. rw [he]
  1307. linarith
  1308. edge_positive e := by
  1309. obtain ⟨hz, hx, ht⟩ := incidence_digit_identity e
  1310. linarith
  1311. edge_identity e := by
  1312. obtain ⟨hz, hx, ht⟩ := incidence_digit_identity e
  1313. rw [hx, ht]
  1314. def SeedPattern.base {L P E : Type*} (S : SeedPattern L P E) (ε : ℝ) : L ⊕ P → ℂ :=
  1315. Sum.elim (fun l => lineSeed ε (S.LX l) (S.LT l)) (fun p => pointSeed ε (S.PX p) (S.PT p))
  1316. def SeedPattern.rot {L P E : Type*} (S : SeedPattern L P E) (ε : ℝ) (e : E) : ℂ :=
  1317. seedCorrection ε (S.LX (S.line e)) (S.LT (S.line e)) (S.PX (S.point e)) (S.PT (S.point e))
  1318. def SeedPattern.coeff {L P E : Type*} (S : SeedPattern L P E) (ε : ℝ) (e : E) : ℂ :=
  1319. seedCoefficient ε (S.LX (S.line e)) (S.LT (S.line e)) (S.PX (S.point e)) (S.PT (S.point e))
  1320. theorem SeedPattern.coeff_continuous {L P E : Type*} (S : SeedPattern L P E) (e : E) :
  1321. ContinuousAt (fun ε => S.coeff ε e) 0 :=
  1322. continuousAt_seedCoefficient _ _ _ _ (S.edge_positive e)
  1323. end
  1324. end Proof
  1325. end OriginalSeedPattern
  1326. /- ## PreparedSeed -/
  1327. section OriginalPreparedSeed
  1328. /- Existence of a finite seed with exact unit corrections and a strict support margin. -/
  1329. namespace Proof
  1330. open Filter
  1331. open scoped Topology
  1332. noncomputable section
  1333. structure PreparedSeed {L P E : Type*} [Fintype E] (l : E → L) (p : E → P) where
  1334. base : L ⊕ P → ℂ
  1335. rotation : E → ℂ
  1336. base_ne_zero : ∀ i, base i ≠ 0
  1337. base_norm_lt : ∀ i, ‖base i‖ < 1
  1338. radii_injective : Function.Injective (fun i => ‖base i‖)
  1339. rotation_norm : ∀ e, ‖rotation e‖ = 1
  1340. unit_edge : ∀ e, ‖base (Sum.inl (l e)) - base (Sum.inr (p e)) * rotation e‖ = 1
  1341. support_margin : ∀ i j, i ≠ j →
  1342. support (base i) (base j) < -2 * ∑ e, ‖rotation e - 1‖
  1343. chord_im_negative : ∀ e,
  1344. (starRingEnd ℂ (base (Sum.inl (l e))) * base (Sum.inr (p e)) * rotation e).im < 0
  1345. theorem SeedPattern.exists_prepared {L P E : Type*} [Fintype L] [Fintype P] [Fintype E]
  1346. (S : SeedPattern L P E) : Nonempty (PreparedSeed S.line S.point) := by
  1347. let A := fun ε : ℝ => 2 * ∑ e, ‖S.coeff ε e‖
  1348. have hcoeff : ∀ e, ContinuousAt (fun ε => S.coeff ε e) 0 := S.coeff_continuous
  1349. have hA : ContinuousAt A 0 := by unfold A; fun_prop
  1350. have hbase : ∀ i, Continuous (fun ε => S.base ε i) := by
  1351. intro i
  1352. cases i with
  1353. | inl l => exact continuous_lineSeed _ _
  1354. | inr p => exact continuous_pointSeed _ _
  1355. have hbase0 : ∀ i, ‖S.base 0 i‖ = 1 / 2 := by
  1356. intro i
  1357. cases i <;> norm_num [SeedPattern.base, lineSeed, pointSeed, Complex.norm_def, Complex.normSq_apply]
  1358. have hbounds : ∀ i, ∀ᶠ ε in 𝓝[>] (0 : ℝ), S.base ε i ≠ 0 ∧ ‖S.base ε i‖ < 1 := by
  1359. intro i
  1360. have hlo : ∀ᶠ ε in 𝓝 (0 : ℝ), 0 < ‖S.base ε i‖ :=
  1361. continuousAt_const.eventually_lt (hbase i).norm.continuousAt (by rw [hbase0]; norm_num)
  1362. have hhi : ∀ᶠ ε in 𝓝 (0 : ℝ), ‖S.base ε i‖ < 1 :=
  1363. (hbase i).norm.continuousAt.eventually_lt continuousAt_const (by rw [hbase0]; norm_num)
  1364. filter_upwards [hlo.filter_mono nhdsWithin_le_nhds, hhi.filter_mono nhdsWithin_le_nhds] with ε hlo hhi
  1365. exact ⟨norm_pos_iff.mp hlo, hhi⟩
  1366. have hnorms : ∀ i j, ∀ᶠ ε in 𝓝[>] (0 : ℝ), i ≠ j → ‖S.base ε i‖ ≠ ‖S.base ε j‖ := by
  1367. intro i j
  1368. by_cases hij : i = j
  1369. · exact Eventually.of_forall (fun _ h => (h hij).elim)
  1370. cases i with
  1371. | inl l =>
  1372. cases j with
  1373. | inl k =>
  1374. have hk : l ≠ k := fun h => hij (congrArg Sum.inl h)
  1375. exact (eventually_line_norm_ne _ _ _ _ (S.LT_injective.ne hk)).mono (fun _ h _ => h)
  1376. | inr p =>
  1377. exact (eventually_cross_norm_ne _ _ _ _ (S.LT_pos l) (S.PT_pos p)).mono (fun _ h _ => h)
  1378. | inr p =>
  1379. cases j with
  1380. | inl l =>
  1381. exact (eventually_cross_norm_ne _ _ _ _ (S.LT_pos l) (S.PT_pos p)).mono (fun _ h _ => h.symm)
  1382. | inr q =>
  1383. have hq : p ≠ q := fun h => hij (congrArg Sum.inr h)
  1384. exact (eventually_point_norm_ne _ _ _ _ (S.PT_injective.ne hq)).mono (fun _ h _ => h)
  1385. have hsupports : ∀ i j, ∀ᶠ ε in 𝓝[>] (0 : ℝ),
  1386. i ≠ j → support (S.base ε i) (S.base ε j) < -ε ^ 3 * A ε := by
  1387. intro i j
  1388. by_cases hij : i = j
  1389. · exact Eventually.of_forall (fun _ h => (h hij).elim)
  1390. cases i with
  1391. | inl l =>
  1392. cases j with
  1393. | inl k =>
  1394. have hk : l ≠ k := fun h => hij (congrArg Sum.inl h)
  1395. exact (eventually_line_support _ _ _ _ A hA (S.line_margin l k hk)).mono (fun _ h _ => h)
  1396. | inr p =>
  1397. exact (eventually_cross_support _ _ _ _ A hA).mono (fun _ h _ => h.1)
  1398. | inr p =>
  1399. cases j with
  1400. | inl l =>
  1401. exact (eventually_cross_support _ _ _ _ A hA).mono (fun _ h _ => h.2)
  1402. | inr q =>
  1403. have hq : p ≠ q := fun h => hij (congrArg Sum.inr h)
  1404. exact (eventually_point_support _ _ _ _ A hA (S.point_margin p q hq)).mono (fun _ h _ => h)
  1405. have hedges : ∀ e, ∀ᶠ ε in 𝓝[>] (0 : ℝ),
  1406. ‖S.rot ε e‖ = 1 ∧
  1407. ‖S.base ε (Sum.inl (S.line e)) - S.base ε (Sum.inr (S.point e)) * S.rot ε e‖ = 1 ∧
  1408. S.rot ε e - 1 = (ε : ℂ) ^ 3 * S.coeff ε e := fun e =>
  1409. (seedCorrection_properties _ _ _ _ (S.edge_positive e) (S.edge_identity e)).filter_mono
  1410. nhdsWithin_le_nhds
  1411. have him : ∀ e, ∀ᶠ ε in 𝓝[>] (0 : ℝ),
  1412. (starRingEnd ℂ (S.base ε (Sum.inl (S.line e))) *
  1413. S.base ε (Sum.inr (S.point e)) * S.rot ε e).im < 0 := fun e =>
  1414. seedCorrection_im_negative _ _ _ _ (S.edge_positive e)
  1415. have hbAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i, S.base ε i ≠ 0 ∧ ‖S.base ε i‖ < 1 := by
  1416. simpa only [eventually_all] using hbounds
  1417. have hnAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i j, i ≠ j → ‖S.base ε i‖ ≠ ‖S.base ε j‖ := by
  1418. simpa only [eventually_all] using hnorms
  1419. have hsAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i j, i ≠ j →
  1420. support (S.base ε i) (S.base ε j) < -ε ^ 3 * A ε := by
  1421. simpa only [eventually_all] using hsupports
  1422. have heAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ e,
  1423. ‖S.rot ε e‖ = 1 ∧
  1424. ‖S.base ε (Sum.inl (S.line e)) - S.base ε (Sum.inr (S.point e)) * S.rot ε e‖ = 1 ∧
  1425. S.rot ε e - 1 = (ε : ℂ) ^ 3 * S.coeff ε e := by
  1426. simpa only [eventually_all] using hedges
  1427. have hiAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ e,
  1428. (starRingEnd ℂ (S.base ε (Sum.inl (S.line e))) *
  1429. S.base ε (Sum.inr (S.point e)) * S.rot ε e).im < 0 := by
  1430. simpa only [eventually_all] using him
  1431. have hall := hbAll.and (hnAll.and (hsAll.and (heAll.and (hiAll.and self_mem_nhdsWithin))))
  1432. obtain ⟨ε, hb, hn, hs, he, hi, hε⟩ := hall.exists
  1433. have hε : 0 < ε := hε
  1434. have hsum : 2 * ∑ e, ‖S.rot ε e - 1‖ = ε ^ 3 * A ε := by
  1435. simp_rw [fun e => (he e).2.2, norm_mul, norm_pow, Complex.norm_real, Real.norm_eq_abs,
  1436. abs_of_pos hε]
  1437. rw [← Finset.mul_sum]
  1438. dsimp [A]
  1439. ring
  1440. refine ⟨{
  1441. base := S.base ε
  1442. rotation := S.rot ε
  1443. base_ne_zero := fun i => (hb i).1
  1444. base_norm_lt := fun i => (hb i).2
  1445. radii_injective := fun i j hh => by_contra fun hij => hn i j hij hh
  1446. rotation_norm := fun e => (he e).1
  1447. unit_edge := fun e => (he e).2.1
  1448. support_margin := ?_
  1449. chord_im_negative := hi }⟩
  1450. intro i j hij
  1451. have hh := hs i j hij
  1452. linarith [hsum]
  1453. end
  1454. end Proof
  1455. end OriginalPreparedSeed
  1456. /- ## PhaseGeometry -/
  1457. section OriginalPhaseGeometry
  1458. /- Unit chords and radial changes with the directions held fixed. -/
  1459. namespace Proof
  1460. noncomputable section
  1461. def unitChord (r s : ℝ) : ℂ := Complex.exp (((-chordAngle r s : ℝ) : ℂ) * Complex.I)
  1462. theorem unitChord_norm (r s : ℝ) : ‖unitChord r s‖ = 1 := Complex.norm_exp_ofReal_mul_I _
  1463. theorem unitChord_re {r s : ℝ} (hf : ChordFeasible r s) : (unitChord r s).re = chordCos r s := by
  1464. simp [unitChord, Complex.exp_re, chordAngle, Real.cos_arccos hf.2.2.1.le hf.2.2.2.le]
  1465. theorem unitChord_im (r s : ℝ) : (unitChord r s).im = -Real.sqrt (1 - chordCos r s ^ 2) := by
  1466. simp [unitChord, Complex.exp_im, chordAngle, Real.sin_arccos]
  1467. theorem unitChord_im_neg {r s : ℝ} (hf : ChordFeasible r s) : (unitChord r s).im < 0 := by
  1468. rw [unitChord_im]
  1469. exact neg_neg_of_pos (Real.sqrt_pos.mpr (chord_discriminant_pos hf.2.2.1 hf.2.2.2))
  1470. theorem unitChord_distance {r s : ℝ} (hf : ChordFeasible r s) :
  1471. ‖(r : ℂ) - (s : ℂ) * unitChord r s‖ = 1 := by
  1472. have hs : Complex.normSq ((r : ℂ) - (s : ℂ) * unitChord r s) = 1 := by
  1473. rw [Complex.normSq_sub, Complex.normSq_mul, Complex.normSq_eq_norm_sq (unitChord r s),
  1474. unitChord_norm, one_pow, mul_one]
  1475. simp only [Complex.normSq_ofReal, Complex.mul_re, Complex.ofReal_re,
  1476. Complex.ofReal_im, zero_mul, sub_zero, Complex.conj_re, unitChord_re hf]
  1477. unfold chordCos
  1478. field_simp [hf.1, hf.2.1]
  1479. ring
  1480. rw [Complex.normSq_eq_norm_sq] at hs
  1481. nlinarith [norm_nonneg ((r : ℂ) - (s : ℂ) * unitChord r s)]
  1482. theorem normSq_sub_mul (a b w : ℂ) :
  1483. Complex.normSq (a - b * w) = Complex.normSq a + Complex.normSq b * Complex.normSq w -
  1484. 2 * (starRingEnd ℂ a * b * w).re := by
  1485. simp only [Complex.normSq_apply, Complex.sub_re, Complex.sub_im, Complex.mul_re,
  1486. Complex.mul_im, Complex.conj_re, Complex.conj_im]
  1487. ring
  1488. theorem lower_half_unique {z w : ℂ} (hn : ‖z‖ = ‖w‖) (hr : z.re = w.re)
  1489. (hz : z.im < 0) (hw : w.im < 0) : z = w := by
  1490. have hsq : Complex.normSq z = Complex.normSq w := by
  1491. simp only [Complex.normSq_eq_norm_sq, hn]
  1492. apply Complex.ext hr
  1493. simp only [Complex.normSq_apply] at hsq
  1494. rw [hr] at hsq
  1495. nlinarith
  1496. theorem corrected_chord {a b w : ℂ} (ha : a ≠ 0) (hb : b ≠ 0) (hw : ‖w‖ = 1)
  1497. (he : ‖a - b * w‖ = 1) (him : (starRingEnd ℂ a * b * w).im < 0) :
  1498. ChordFeasible ‖a‖ ‖b‖ ∧
  1499. starRingEnd ℂ a * b * w = ((‖a‖ * ‖b‖ : ℝ) : ℂ) * unitChord ‖a‖ ‖b‖ := by
  1500. let q := starRingEnd ℂ a * b * w
  1501. have hr : 0 < ‖a‖ := norm_pos_iff.mpr ha
  1502. have hs : 0 < ‖b‖ := norm_pos_iff.mpr hb
  1503. have hprod : 0 < ‖a‖ * ‖b‖ := mul_pos hr hs
  1504. have hqnorm : ‖q‖ = ‖a‖ * ‖b‖ := by simp [q, hw]
  1505. have hqnormSq : q.re ^ 2 + q.im ^ 2 = (‖a‖ * ‖b‖) ^ 2 := by
  1506. have h := Complex.normSq_eq_norm_sq q
  1507. rw [hqnorm] at h
  1508. simpa [Complex.normSq_apply, pow_two] using h
  1509. have hqre : q.re = (‖a‖ ^ 2 + ‖b‖ ^ 2 - 1) / 2 := by
  1510. have h := normSq_sub_mul a b w
  1511. simp only [Complex.normSq_eq_norm_sq, he, hw, one_pow, mul_one] at h
  1512. change _ = _ - 2 * q.re at h
  1513. linarith
  1514. have hratio : q.re / (‖a‖ * ‖b‖) = chordCos ‖a‖ ‖b‖ := by
  1515. rw [hqre]
  1516. unfold chordCos
  1517. ring
  1518. have hqim : q.im < 0 := him
  1519. have hsqim : 0 < q.im ^ 2 := sq_pos_of_ne_zero (ne_of_lt hqim)
  1520. have hlo : -(‖a‖ * ‖b‖) < q.re := by nlinarith
  1521. have hhi : q.re < ‖a‖ * ‖b‖ := by nlinarith
  1522. have hf : ChordFeasible ‖a‖ ‖b‖ := by
  1523. refine ⟨ne_of_gt hr, ne_of_gt hs, ?_, ?_⟩
  1524. · rw [← hratio]
  1525. exact (lt_div_iff₀ hprod).mpr (by linarith)
  1526. · rw [← hratio]
  1527. exact (div_lt_iff₀ hprod).mpr (by linarith)
  1528. refine ⟨hf, ?_⟩
  1529. apply lower_half_unique
  1530. · calc
  1531. ‖q‖ = ‖a‖ * ‖b‖ := hqnorm
  1532. _ = ‖((‖a‖ * ‖b‖ : ℝ) : ℂ) * unitChord ‖a‖ ‖b‖‖ := by
  1533. rw [norm_mul, unitChord_norm, Complex.norm_of_nonneg hprod.le, mul_one]
  1534. · calc
  1535. q.re = (‖a‖ * ‖b‖) * chordCos ‖a‖ ‖b‖ := by rw [← hratio]; field_simp
  1536. _ = (((‖a‖ * ‖b‖ : ℝ) : ℂ) * unitChord ‖a‖ ‖b‖).re := by simp [unitChord_re hf]
  1537. · exact him
  1538. · simpa only [Complex.mul_im, Complex.ofReal_re, Complex.ofReal_im, zero_mul, zero_add, add_zero] using
  1539. mul_neg_of_pos_of_neg hprod (unitChord_im_neg hf)
  1540. def radialBase {I : Type*} (b : I → ℂ) (r : I → ℝ) (i : I) : ℂ :=
  1541. (r i : ℂ) * (b i / (‖b i‖ : ℂ))
  1542. theorem radialBase_at_norm {I : Type*} (b : I → ℂ) (hb : ∀ i, b i ≠ 0) :
  1543. radialBase b (fun i => ‖b i‖) = b := by
  1544. funext i
  1545. exact mul_div_cancel₀ _ (Complex.ofReal_ne_zero.mpr (norm_ne_zero_iff.mpr (hb i)))
  1546. theorem normalized_norm {b : ℂ} (hb : b ≠ 0) : ‖b / (‖b‖ : ℂ)‖ = 1 := by
  1547. rw [norm_div, Complex.norm_of_nonneg (norm_nonneg _)]
  1548. exact div_self (norm_ne_zero_iff.mpr hb)
  1549. theorem radialBase_norm {I : Type*} (b : I → ℂ) (hb : ∀ i, b i ≠ 0)
  1550. (r : I → ℝ) (hr : ∀ i, 0 ≤ r i) (i : I) : ‖radialBase b r i‖ = r i := by
  1551. rw [radialBase, norm_mul, normalized_norm (hb i), mul_one, Complex.norm_of_nonneg (hr i)]
  1552. def directionRatio (a b : ℂ) : ℂ := (a / (‖a‖ : ℂ)) / (b / (‖b‖ : ℂ))
  1553. theorem directionRatio_norm {a b : ℂ} (ha : a ≠ 0) (hb : b ≠ 0) : ‖directionRatio a b‖ = 1 := by
  1554. rw [directionRatio, norm_div, normalized_norm ha, normalized_norm hb, div_self (by norm_num : (1 : ℝ) ≠ 0)]
  1555. theorem directionRatio_cancel {a b : ℂ} (ha : a ≠ 0) (hb : b ≠ 0) :
  1556. starRingEnd ℂ a * b * directionRatio a b = ((‖a‖ * ‖b‖ : ℝ) : ℂ) := by
  1557. have hra : (‖a‖ : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr (norm_ne_zero_iff.mpr ha)
  1558. have hrb : (‖b‖ : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr (norm_ne_zero_iff.mpr hb)
  1559. have hnorm : starRingEnd ℂ a * a = (‖a‖ : ℂ) ^ 2 := by
  1560. rw [← Complex.normSq_eq_conj_mul_self, Complex.normSq_eq_norm_sq, Complex.ofReal_pow]
  1561. unfold directionRatio
  1562. calc
  1563. starRingEnd ℂ a * b * ((a / (‖a‖ : ℂ)) / (b / (‖b‖ : ℂ))) =
  1564. (starRingEnd ℂ a * a) * (‖b‖ : ℂ) / (‖a‖ : ℂ) := by field_simp [hra, hrb, hb]
  1565. _ = ((‖a‖ * ‖b‖ : ℝ) : ℂ) := by rw [hnorm, Complex.ofReal_mul]; field_simp [hra]
  1566. theorem phaseRotations_factor {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)
  1567. (σ : E → ℂ) (hσ : ∀ e, Complex.exp ((θ e : ℂ) * Complex.I) = σ e)
  1568. (z : (L → ℝ) × (P → ℝ)) (e : E) :
  1569. phaseRotations l p θ z e = σ e * unitChord (z.1 (l e)) (z.2 (p e)) := by
  1570. simp only [phaseRotations, unitChord, Complex.ofReal_sub, Complex.ofReal_neg, sub_mul, neg_mul,
  1571. Complex.exp_sub, Complex.exp_neg, hσ, div_eq_mul_inv]
  1572. theorem radial_unit_distance {a b : ℂ} (ha : a ≠ 0) (hb : b ≠ 0)
  1573. {r s : ℝ} (hf : ChordFeasible r s) :
  1574. ‖(r : ℂ) * (a / (‖a‖ : ℂ)) - (s : ℂ) * (b / (‖b‖ : ℂ)) *
  1575. (directionRatio a b * unitChord r s)‖ = 1 := by
  1576. have hbn : b / (‖b‖ : ℂ) ≠ 0 :=
  1577. div_ne_zero hb (Complex.ofReal_ne_zero.mpr (norm_ne_zero_iff.mpr hb))
  1578. have hra : (‖a‖ : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr (norm_ne_zero_iff.mpr ha)
  1579. have hrb : (‖b‖ : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr (norm_ne_zero_iff.mpr hb)
  1580. have he : (r : ℂ) * (a / (‖a‖ : ℂ)) - (s : ℂ) * (b / (‖b‖ : ℂ)) *
  1581. (directionRatio a b * unitChord r s) =
  1582. (a / (‖a‖ : ℂ)) * ((r : ℂ) - (s : ℂ) * unitChord r s) := by
  1583. unfold directionRatio
  1584. field_simp [hbn, hra, hrb, hb]
  1585. rw [he, norm_mul, normalized_norm ha, unitChord_distance hf, one_mul]
  1586. def PreparedSeed.angles {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}
  1587. (Q : PreparedSeed l p) (e : E) : ℝ :=
  1588. Complex.arg (directionRatio (Q.base (Sum.inl (l e))) (Q.base (Sum.inr (p e))))
  1589. def PreparedSeed.radii {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}
  1590. (Q : PreparedSeed l p) : (L → ℝ) × (P → ℝ) :=
  1591. (fun i => ‖Q.base (Sum.inl i)‖, fun j => ‖Q.base (Sum.inr j)‖)
  1592. theorem PreparedSeed.angles_exp {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}
  1593. (Q : PreparedSeed l p) (e : E) :
  1594. Complex.exp ((Q.angles e : ℂ) * Complex.I) =
  1595. directionRatio (Q.base (Sum.inl (l e))) (Q.base (Sum.inr (p e))) := by
  1596. have hnorm := directionRatio_norm (Q.base_ne_zero (Sum.inl (l e))) (Q.base_ne_zero (Sum.inr (p e)))
  1597. have hh := Complex.norm_mul_exp_arg_mul_I (directionRatio (Q.base (Sum.inl (l e))) (Q.base (Sum.inr (p e))))
  1598. simpa only [PreparedSeed.angles, hnorm, Complex.ofReal_one, one_mul] using hh
  1599. theorem PreparedSeed.feasible {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}
  1600. (Q : PreparedSeed l p) (e : E) : ChordFeasible (Q.radii.1 (l e)) (Q.radii.2 (p e)) :=
  1601. (corrected_chord (Q.base_ne_zero _) (Q.base_ne_zero _) (Q.rotation_norm e)
  1602. (Q.unit_edge e) (Q.chord_im_negative e)).1
  1603. theorem PreparedSeed.phase_at_radii {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}
  1604. (Q : PreparedSeed l p) : phaseRotations l p Q.angles Q.radii = Q.rotation := by
  1605. funext e
  1606. have ha := Q.base_ne_zero (Sum.inl (l e))
  1607. have hb := Q.base_ne_zero (Sum.inr (p e))
  1608. have he := (corrected_chord ha hb (Q.rotation_norm e) (Q.unit_edge e) (Q.chord_im_negative e)).2
  1609. apply mul_left_cancel₀ (mul_ne_zero ((map_ne_zero (starRingEnd ℂ)).mpr ha) hb)
  1610. rw [phaseRotations_factor l p Q.angles _ Q.angles_exp, ← mul_assoc, directionRatio_cancel ha hb]
  1611. exact he.symm
  1612. end
  1613. end Proof
  1614. end OriginalPhaseGeometry
  1615. /- ## Perturbation -/
  1616. section OriginalPerturbation
  1617. /- A simultaneous radius perturbation preserving support and separating every subset product. -/
  1618. namespace Proof
  1619. open Set Filter
  1620. open scoped Topology
  1621. noncomputable section
  1622. def joinedRadii {L P : Type*} (z : (L → ℝ) × (P → ℝ)) : L ⊕ P → ℝ := Sum.elim z.1 z.2
  1623. def PreparedSeed.varBase {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}
  1624. (Q : PreparedSeed l p) (z : (L → ℝ) × (P → ℝ)) : L ⊕ P → ℂ := radialBase Q.base (joinedRadii z)
  1625. theorem PreparedSeed.varBase_at_radii {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}
  1626. (Q : PreparedSeed l p) : Q.varBase Q.radii = Q.base := by
  1627. have hh : joinedRadii Q.radii = fun i => ‖Q.base i‖ := by funext i; cases i <;> rfl
  1628. unfold PreparedSeed.varBase
  1629. rw [hh]
  1630. exact radialBase_at_norm Q.base Q.base_ne_zero
  1631. theorem PreparedSeed.varBase_continuous {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}
  1632. (Q : PreparedSeed l p) (i : L ⊕ P) : Continuous (fun z => Q.varBase z i) := by
  1633. cases i <;> simp only [PreparedSeed.varBase, radialBase, joinedRadii, Sum.elim_inl, Sum.elim_inr] <;> fun_prop
  1634. theorem joinedRadii_continuous {L P : Type*} (i : L ⊕ P) :
  1635. Continuous (fun z : (L → ℝ) × (P → ℝ) => joinedRadii z i) := by
  1636. cases i <;> simp only [joinedRadii, Sum.elim_inl, Sum.elim_inr] <;> fun_prop
  1637. theorem PreparedSeed.varBase_unit_edge {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}
  1638. (Q : PreparedSeed l p) (z : (L → ℝ) × (P → ℝ)) (e : E)
  1639. (hf : ChordFeasible (z.1 (l e)) (z.2 (p e))) :
  1640. ‖Q.varBase z (Sum.inl (l e)) - Q.varBase z (Sum.inr (p e)) * phaseRotations l p Q.angles z e‖ = 1 := by
  1641. rw [phaseRotations_factor l p Q.angles _ Q.angles_exp]
  1642. exact radial_unit_distance (Q.base_ne_zero _) (Q.base_ne_zero _) hf
  1643. structure SeparatedSeed {L P E : Type*} [Fintype E] (l : E → L) (p : E → P) where
  1644. base : L ⊕ P → ℂ
  1645. rotation : E → ℂ
  1646. base_ne_zero : ∀ i, base i ≠ 0
  1647. base_norm_lt : ∀ i, ‖base i‖ < 1
  1648. radii_injective : Function.Injective (fun i => ‖base i‖)
  1649. rotation_norm : ∀ e, ‖rotation e‖ = 1
  1650. unit_edge : ∀ e, ‖base (Sum.inl (l e)) - base (Sum.inr (p e)) * rotation e‖ = 1
  1651. support_margin : ∀ i j, i ≠ j → support (base i) (base j) < -2 * ∑ e, ‖rotation e - 1‖
  1652. products_injective : Function.Injective (subsetProduct rotation)
  1653. def GoodRadii {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}
  1654. (Q : PreparedSeed l p) (z : (L → ℝ) × (P → ℝ)) : Prop :=
  1655. (∀ i, 0 < joinedRadii z i) ∧ (∀ i, ‖Q.varBase z i‖ < 1) ∧
  1656. Function.Injective (joinedRadii z) ∧
  1657. (∀ e, ChordFeasible (z.1 (l e)) (z.2 (p e))) ∧
  1658. ∀ i j, i ≠ j → support (Q.varBase z i) (Q.varBase z j) <
  1659. -2 * ∑ e, ‖phaseRotations l p Q.angles z e - 1‖
  1660. theorem PreparedSeed.goodRadii_nhds {L P E : Type*} [Fintype L] [Fintype P] [Fintype E]
  1661. {l : E → L} {p : E → P} (Q : PreparedSeed l p) :
  1662. ∀ᶠ z in 𝓝 Q.radii, GoodRadii Q z := by
  1663. have hjoined : ∀ i, joinedRadii Q.radii i = ‖Q.base i‖ := by intro i; cases i <;> rfl
  1664. have hr : ∀ i, Q.radii.1 i ≠ 0 := fun i => norm_ne_zero_iff.mpr (Q.base_ne_zero _)
  1665. have hs : ∀ j, Q.radii.2 j ≠ 0 := fun j => norm_ne_zero_iff.mpr (Q.base_ne_zero _)
  1666. have hrot : ∀ e, ContinuousAt (fun z => phaseRotations l p Q.angles z e) Q.radii :=
  1667. phaseRotations_continuousAt l p Q.angles Q.radii hr hs
  1668. have hbase : ∀ i, ContinuousAt (fun z => Q.varBase z i) Q.radii :=
  1669. fun i => (Q.varBase_continuous i).continuousAt
  1670. have hpos : ∀ i, ∀ᶠ z in 𝓝 Q.radii, 0 < joinedRadii z i := by
  1671. intro i
  1672. apply continuousAt_const.eventually_lt (joinedRadii_continuous i).continuousAt
  1673. rw [hjoined]
  1674. exact norm_pos_iff.mpr (Q.base_ne_zero i)
  1675. have hnorm : ∀ i, ∀ᶠ z in 𝓝 Q.radii, ‖Q.varBase z i‖ < 1 := by
  1676. intro i
  1677. apply (hbase i).norm.eventually_lt continuousAt_const
  1678. rw [Q.varBase_at_radii]
  1679. exact Q.base_norm_lt i
  1680. have hinj : ∀ i j, ∀ᶠ z in 𝓝 Q.radii, i ≠ j → joinedRadii z i ≠ joinedRadii z j := by
  1681. intro i j
  1682. by_cases hij : i = j
  1683. · exact Eventually.of_forall (fun _ h => (h hij).elim)
  1684. have hdiff : ContinuousAt (fun z => joinedRadii z i - joinedRadii z j) Q.radii :=
  1685. (joinedRadii_continuous i).continuousAt.sub (joinedRadii_continuous j).continuousAt
  1686. have hdiff0 : joinedRadii Q.radii i - joinedRadii Q.radii j ≠ 0 := by
  1687. rw [hjoined, hjoined]
  1688. exact sub_ne_zero.mpr (Q.radii_injective.ne hij)
  1689. exact (hdiff.eventually_ne hdiff0).mono (fun _ hh _ => sub_ne_zero.mp hh)
  1690. have hfeas : ∀ e, ∀ᶠ z in 𝓝 Q.radii, ChordFeasible (z.1 (l e)) (z.2 (p e)) := by
  1691. intro e
  1692. have hcos : ContinuousAt (fun z : (L → ℝ) × (P → ℝ) => chordCos (z.1 (l e)) (z.2 (p e))) Q.radii := by
  1693. unfold chordCos
  1694. fun_prop (disch := aesop)
  1695. have hl : ∀ᶠ z in 𝓝 Q.radii, -1 < chordCos (z.1 (l e)) (z.2 (p e)) :=
  1696. continuousAt_const.eventually_lt hcos (Q.feasible e).2.2.1
  1697. have hu : ∀ᶠ z in 𝓝 Q.radii, chordCos (z.1 (l e)) (z.2 (p e)) < 1 :=
  1698. hcos.eventually_lt continuousAt_const (Q.feasible e).2.2.2
  1699. filter_upwards [hpos (Sum.inl (l e)), hpos (Sum.inr (p e)), hl, hu] with z hr hs hl hu
  1700. exact ⟨ne_of_gt hr, ne_of_gt hs, hl, hu⟩
  1701. have hmargin : ∀ i j, ∀ᶠ z in 𝓝 Q.radii, i ≠ j →
  1702. support (Q.varBase z i) (Q.varBase z j) < -2 * ∑ e, ‖phaseRotations l p Q.angles z e - 1‖ := by
  1703. intro i j
  1704. by_cases hij : i = j
  1705. · exact Eventually.of_forall (fun _ h => (h hij).elim)
  1706. have hc : ContinuousAt (fun z => support (Q.varBase z i) (Q.varBase z j) +
  1707. 2 * ∑ e, ‖phaseRotations l p Q.angles z e - 1‖) Q.radii := by
  1708. have hri := Complex.continuous_re.continuousAt.comp (hbase i)
  1709. have hrj := Complex.continuous_re.continuousAt.comp (hbase j)
  1710. have hii := Complex.continuous_im.continuousAt.comp (hbase i)
  1711. have hij := Complex.continuous_im.continuousAt.comp (hbase j)
  1712. unfold support
  1713. exact ((hri.mul (hrj.sub hri)).add (hii.mul (hij.sub hii))).add
  1714. (continuousAt_const.mul
  1715. (tendsto_finsetSum Finset.univ (fun e _ =>
  1716. ((hrot e).sub continuousAt_const).norm)))
  1717. have hvalue : support (Q.varBase Q.radii i) (Q.varBase Q.radii j) +
  1718. 2 * ∑ e, ‖phaseRotations l p Q.angles Q.radii e - 1‖ < 0 := by
  1719. rw [Q.varBase_at_radii, Q.phase_at_radii]
  1720. linarith [Q.support_margin i j hij]
  1721. exact (hc.eventually_lt continuousAt_const hvalue).mono (fun _ hh _ => by linarith)
  1722. have hposAll : ∀ᶠ z in 𝓝 Q.radii, ∀ i, 0 < joinedRadii z i := by simpa only [eventually_all] using hpos
  1723. have hnAll : ∀ᶠ z in 𝓝 Q.radii, ∀ i, ‖Q.varBase z i‖ < 1 := by simpa only [eventually_all] using hnorm
  1724. have hiAll : ∀ᶠ z in 𝓝 Q.radii, ∀ i j, i ≠ j → joinedRadii z i ≠ joinedRadii z j := by
  1725. simpa only [eventually_all] using hinj
  1726. have hfAll : ∀ᶠ z in 𝓝 Q.radii, ∀ e, ChordFeasible (z.1 (l e)) (z.2 (p e)) := by
  1727. simpa only [eventually_all] using hfeas
  1728. have hmAll : ∀ᶠ z in 𝓝 Q.radii, ∀ i j, i ≠ j →
  1729. support (Q.varBase z i) (Q.varBase z j) < -2 * ∑ e, ‖phaseRotations l p Q.angles z e - 1‖ := by
  1730. simpa only [eventually_all] using hmargin
  1731. filter_upwards [hposAll, hnAll, hiAll, hfAll, hmAll] with z hp hn hi hf hm
  1732. exact ⟨hp, hn, fun i j h => by_contra (fun hij => hi i j hij h), hf, hm⟩
  1733. theorem PreparedSeed.exists_separated {L P E : Type*} [Fintype L] [Fintype P] [Fintype E]
  1734. {l : E → L} {p : E → P} (Q : PreparedSeed l p)
  1735. (hij : Function.Injective (fun e => (l e, p e))) : Nonempty (SeparatedSeed l p) := by
  1736. classical
  1737. obtain ⟨U, hUgood, hU, hz₀⟩ := mem_nhds_iff.mp Q.goodRadii_nhds
  1738. have hne : U.Nonempty := ⟨Q.radii, hz₀⟩
  1739. have hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0) := by
  1740. intro z hz
  1741. exact ⟨fun i => ne_of_gt ((hUgood hz).1 (Sum.inl i)), fun j => ne_of_gt ((hUgood hz).1 (Sum.inr j))⟩
  1742. obtain ⟨z, hz, hprod⟩ := exists_injective_subsetProducts l p hij Q.angles U hU hne hnz
  1743. (fun e z hz => (hUgood hz).2.2.2.1 e)
  1744. obtain ⟨hpos, hnorm, hinj, hfeas, hmargin⟩ := hUgood hz
  1745. have hrnorm : ∀ i, ‖Q.varBase z i‖ = joinedRadii z i :=
  1746. radialBase_norm Q.base Q.base_ne_zero (joinedRadii z) (fun i => (hpos i).le)
  1747. refine ⟨{
  1748. base := Q.varBase z
  1749. rotation := phaseRotations l p Q.angles z
  1750. base_ne_zero := fun i => norm_pos_iff.mp (by rw [hrnorm]; exact hpos i)
  1751. base_norm_lt := hnorm
  1752. radii_injective := ?_
  1753. rotation_norm := phaseRotations_norm l p Q.angles z
  1754. unit_edge := fun e => Q.varBase_unit_edge z e (hfeas e)
  1755. support_margin := hmargin
  1756. products_injective := hprod }⟩
  1757. intro i j hh
  1758. dsimp only at hh
  1759. rw [hrnorm, hrnorm] at hh
  1760. exact hinj hh
  1761. end
  1762. end Proof
  1763. end OriginalPerturbation
  1764. /- ## Counting -/
  1765. section OriginalCounting
  1766. /- Exact vertex counts and a lower bound for unordered unit pairs. -/
  1767. namespace Proof
  1768. noncomputable section
  1769. def pairDistance {X : Type*} [MetricSpace X] (p : Sym2 X) : ℝ :=
  1770. Sym2.lift ⟨dist, fun a b => dist_comm a b⟩ p
  1771. def unitPairs {X : Type*} [MetricSpace X] (P : Finset X) : Finset (Sym2 X) := by
  1772. classical
  1773. exact P.sym2.filter (fun p => pairDistance p = 1)
  1774. def rotatedSet {I E : Type*} [Fintype I] [Fintype E] (b : I → ℂ) (w : E → ℂ) : Finset ℂ := by
  1775. classical
  1776. exact Finset.univ.image (rotatedCopy b w)
  1777. theorem mem_rotatedSet {I E : Type*} [Fintype I] [Fintype E]
  1778. (b : I → ℂ) (w : E → ℂ) (x : I × Finset E) :
  1779. rotatedCopy b w x ∈ rotatedSet b w := by
  1780. classical
  1781. exact Finset.mem_image.mpr ⟨x, Finset.mem_univ _, rfl⟩
  1782. theorem rotatedSet_card {I E : Type*} [Fintype I] [Fintype E]
  1783. (b : I → ℂ) (w : E → ℂ) (hinj : Function.Injective (rotatedCopy b w)) :
  1784. (rotatedSet b w).card = Fintype.card I * 2 ^ Fintype.card E := by
  1785. classical
  1786. rw [rotatedSet, Finset.card_image_of_injective _ hinj]
  1787. simp
  1788. theorem rotatedSet_convexIndependent {I E : Type*} [Fintype I] [Fintype E]
  1789. (b : I → ℂ) (w : E → ℂ) (hc : ConvexIndependent ℝ (rotatedCopy b w)) :
  1790. ConvexIndependent ℝ (fun z : ↥(rotatedSet b w : Set ℂ) => (z : ℂ)) := by
  1791. have he : (rotatedSet b w : Set ℂ) = Set.range (rotatedCopy b w) := by
  1792. classical
  1793. simp [rotatedSet]
  1794. rw [he]
  1795. exact hc.range
  1796. abbrev LiftedEdge (E : Type*) := (e : E) × {S : Finset E // e ∉ S}
  1797. theorem subsets_avoiding_card {E : Type*} [Fintype E] [DecidableEq E] (e : E) :
  1798. Fintype.card {S : Finset E // e ∉ S} = 2 ^ (Fintype.card E - 1) := by
  1799. rw [Fintype.card_of_subtype ((Finset.univ.erase e).powerset)
  1800. (fun S => by simp [Finset.mem_powerset, Finset.subset_erase])]
  1801. simp
  1802. theorem liftedEdge_card {E : Type*} [Fintype E] [DecidableEq E] :
  1803. Fintype.card (LiftedEdge E) = Fintype.card E * 2 ^ (Fintype.card E - 1) := by
  1804. simp only [LiftedEdge, Fintype.card_sigma, subsets_avoiding_card,
  1805. Finset.sum_const, Finset.card_univ, smul_eq_mul]
  1806. def liftedPair {L P E : Type*} [DecidableEq E]
  1807. (l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ) (x : LiftedEdge E) : Sym2 ℂ :=
  1808. s(rotatedCopy b w (Sum.inl (l x.1), x.2.val),
  1809. rotatedCopy b w (Sum.inr (p x.1), insert x.1 x.2.val))
  1810. theorem liftedPair_injective {L P E : Type*} [DecidableEq E]
  1811. (l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)
  1812. (he : Function.Injective (fun e => (l e, p e)))
  1813. (hinj : Function.Injective (rotatedCopy b w)) :
  1814. Function.Injective (liftedPair l p b w) := by
  1815. rintro ⟨e, S⟩ ⟨f, T⟩ hh
  1816. simp only [liftedPair, Sym2.eq, Sym2.rel_iff', Prod.mk.injEq, Prod.swap_prod_mk] at hh
  1817. rcases hh with ⟨hl, hp⟩ | ⟨hl, hp⟩
  1818. · have hl := hinj hl
  1819. have hp := hinj hp
  1820. have hlf : l e = l f := Sum.inl.inj (congrArg Prod.fst hl)
  1821. have hpf : p e = p f := Sum.inr.inj (congrArg Prod.fst hp)
  1822. have hef := he (Prod.ext hlf hpf)
  1823. subst f
  1824. have hST : S = T := Subtype.ext (congrArg Prod.snd hl)
  1825. subst T
  1826. rfl
  1827. · have hbad := congrArg Prod.fst (hinj hl)
  1828. cases hbad
  1829. theorem liftedPair_mem_unitPairs {L P E : Type*}
  1830. [Fintype L] [Fintype P] [Fintype E] [DecidableEq E]
  1831. (l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)
  1832. (hw : ∀ e, ‖w e‖ = 1)
  1833. (hedge : ∀ e, ‖b (Sum.inl (l e)) - b (Sum.inr (p e)) * w e‖ = 1)
  1834. (x : LiftedEdge E) : liftedPair l p b w x ∈ unitPairs (rotatedSet b w) := by
  1835. classical
  1836. apply Finset.mem_filter.mpr
  1837. constructor
  1838. · apply Finset.mk_mem_sym2_iff.mpr
  1839. exact ⟨mem_rotatedSet b w _, mem_rotatedSet b w _⟩
  1840. · exact rotatedCopy_unit_edge b w hw _ _ x.1 (hedge x.1) x.2.val x.2.property
  1841. theorem amplification_unitPairs_bound {L P E : Type*}
  1842. [Fintype L] [Fintype P] [Fintype E] [DecidableEq E]
  1843. (l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)
  1844. (he : Function.Injective (fun e => (l e, p e)))
  1845. (hinj : Function.Injective (rotatedCopy b w)) (hw : ∀ e, ‖w e‖ = 1)
  1846. (hedge : ∀ e, ‖b (Sum.inl (l e)) - b (Sum.inr (p e)) * w e‖ = 1) :
  1847. Fintype.card E * 2 ^ (Fintype.card E - 1) ≤ (unitPairs (rotatedSet b w)).card := by
  1848. let f : LiftedEdge E → unitPairs (rotatedSet b w) := fun x =>
  1849. ⟨liftedPair l p b w x, liftedPair_mem_unitPairs l p b w hw hedge x⟩
  1850. have hf : Function.Injective f := fun x y h =>
  1851. liftedPair_injective l p b w he hinj (congrArg Subtype.val h)
  1852. have hc := Fintype.card_le_of_injective f hf
  1853. simpa only [liftedEdge_card, Fintype.card_coe] using hc
  1854. end
  1855. end Proof
  1856. end OriginalCounting
  1857. /- ## Counterexample -/
  1858. section OriginalCounterexample
  1859. /- Convex configurations with an unbounded ratio of unit distances to vertices. -/
  1860. namespace Proof
  1861. noncomputable section
  1862. def constructionSize (d : ℕ) : ℕ := 2 * d ^ d * 2 ^ (d ^ (d + 1))
  1863. theorem convex_unit_counterexample (d : ℕ) (hd : 2 ≤ d) :
  1864. ∃ P : Finset ℂ,
  1865. ConvexIndependent ℝ (fun z : ↥(P : Set ℂ) => (z : ℂ)) ∧
  1866. P.card = constructionSize d ∧ d * P.card ≤ 4 * (unitPairs P).card := by
  1867. classical
  1868. obtain ⟨Q⟩ := (coordinatePattern d).exists_prepared
  1869. obtain ⟨R⟩ := Q.exists_separated (coordinatePattern d).endpoints_injective
  1870. let P := rotatedSet R.base R.rotation
  1871. have hinj := rotatedCopy_injective R.base R.rotation R.base_ne_zero R.radii_injective
  1872. R.rotation_norm R.products_injective
  1873. have hconv := rotatedCopy_convexIndependent R.base R.rotation R.base_ne_zero R.radii_injective
  1874. (fun i => (R.base_norm_lt i).le) R.rotation_norm R.products_injective R.support_margin
  1875. have hcard := rotatedSet_card R.base R.rotation hinj
  1876. have hcount := amplification_unitPairs_bound (coordinatePattern d).line (coordinatePattern d).point
  1877. R.base R.rotation (coordinatePattern d).endpoints_injective hinj R.rotation_norm R.unit_edge
  1878. refine ⟨P, rotatedSet_convexIndependent R.base R.rotation hconv, ?_, ?_⟩
  1879. · simpa [P, vertexLabel_card (by omega : 1 ≤ d), edgeLabel_card, constructionSize,
  1880. pow_succ] using hcard
  1881. · have hm : 1 ≤ Fintype.card (EdgeLabel d) := by
  1882. rw [edgeLabel_card]
  1883. exact Nat.one_le_iff_ne_zero.mpr (pow_ne_zero _ (by omega))
  1884. have hpow : 2 ^ Fintype.card (EdgeLabel d) = 2 * 2 ^ (Fintype.card (EdgeLabel d) - 1) := by
  1885. rw [← pow_succ', Nat.sub_add_cancel hm]
  1886. have hid : d * P.card = 4 * (Fintype.card (EdgeLabel d) * 2 ^ (Fintype.card (EdgeLabel d) - 1)) := by
  1887. dsimp [P]
  1888. rw [hcard, vertexLabel_card (by omega : 1 ≤ d), hpow, edgeLabel_card, pow_succ]
  1889. ring
  1890. rw [hid]
  1891. exact Nat.mul_le_mul_left 4 hcount
  1892. theorem constructionSize_pos {d : ℕ} (hd : 1 ≤ d) : 0 < constructionSize d := by
  1893. unfold constructionSize
  1894. positivity
  1895. theorem convex_unit_ratios_unbounded (C : ℝ) :
  1896. ∃ P : Finset ℂ, ConvexIndependent ℝ (fun z : ↥(P : Set ℂ) => (z : ℂ)) ∧
  1897. C * (P.card : ℝ) < ((unitPairs P).card : ℝ) := by
  1898. obtain ⟨n, hn⟩ := exists_nat_gt (4 * C)
  1899. obtain ⟨P, hconv, hcard, hcount⟩ := convex_unit_counterexample (n + 2) (by omega)
  1900. have hP : (0 : ℝ) < P.card := by exact_mod_cast (hcard ▸ constructionSize_pos (by omega : 1 ≤ n + 2))
  1901. have hcountR : ((n + 2 : ℕ) : ℝ) * P.card ≤ 4 * (unitPairs P).card := by exact_mod_cast hcount
  1902. have hdR : 4 * C < ((n + 2 : ℕ) : ℝ) := by push_cast; linarith
  1903. refine ⟨P, hconv, ?_⟩
  1904. nlinarith [mul_pos (sub_pos.mpr hdR) hP]
  1905. end
  1906. end Proof
  1907. end OriginalCounterexample
  1908. /- ## PlaneBridge -/
  1909. section OriginalPlaneBridge
  1910. /- Transfer from the complex plane to the literal Euclidean-plane definitions. -/
  1911. namespace Proof
  1912. noncomputable section
  1913. open scoped EuclideanGeometry
  1914. def complexToPlane : ℂ ≃ₗᵢ[ℝ] ℝ² := Complex.orthonormalBasisOneI.repr
  1915. theorem pairDistance_eq_out {X : Type*} [MetricSpace X] (p : Sym2 X) :
  1916. pairDistance p = dist p.out.1 p.out.2 := by
  1917. have hp : s(p.out.1, p.out.2) = p := by rw [Sym2.mk, p.out_eq]
  1918. conv_lhs => rw [← hp]
  1919. rfl
  1920. theorem unitDistNum_eq_card_unitPairs {X : Type*} [MetricSpace X] (P : Finset X) :
  1921. unitDistNum P = (unitPairs P).card := by
  1922. classical
  1923. simp only [unitDistNum, unitPairs, pairDistance_eq_out]
  1924. theorem pairDistance_map_isometry {X Y : Type*} [MetricSpace X] [MetricSpace Y]
  1925. (f : X → Y) (hf : Isometry f) (p : Sym2 X) :
  1926. pairDistance (Sym2.map f p) = pairDistance p := by
  1927. refine Sym2.inductionOn p ?_
  1928. intro a b
  1929. exact hf.dist_eq a b
  1930. theorem unitPairs_image_isometry {X Y : Type*} [MetricSpace X] [MetricSpace Y] [DecidableEq Y]
  1931. (f : X → Y) (hf : Isometry f) (P : Finset X) :
  1932. unitPairs (P.image f) = (unitPairs P).image (Sym2.map f) := by
  1933. classical
  1934. rw [unitPairs, Finset.sym2_image, Finset.filter_image]
  1935. congr 1
  1936. ext p
  1937. simp only [Finset.mem_filter, pairDistance_map_isometry f hf, unitPairs]
  1938. theorem unitPairs_card_image_isometry {X Y : Type*} [MetricSpace X] [MetricSpace Y] [DecidableEq Y]
  1939. (f : X → Y) (hf : Isometry f) (P : Finset X) :
  1940. (unitPairs (P.image f)).card = (unitPairs P).card := by
  1941. classical
  1942. rw [unitPairs_image_isometry f hf, Finset.card_image_of_injective _
  1943. (Sym2.map.injective hf.injective)]
  1944. theorem convexIndependent_linearMap {I V W : Type*}
  1945. [AddCommGroup V] [Module ℝ V] [AddCommGroup W] [Module ℝ W]
  1946. (f : V →ₗ[ℝ] W) (hf : Function.Injective f) (p : I → V)
  1947. (hp : ConvexIndependent ℝ p) : ConvexIndependent ℝ (f ∘ p) := by
  1948. intro S i hi
  1949. apply hp S i
  1950. have himg : (f ∘ p) '' S = f '' (p '' S) := (Set.image_image f p S).symm
  1951. rw [himg, ← f.image_convexHull] at hi
  1952. obtain ⟨x, hx, hxi⟩ := hi
  1953. have heq : x = p i := hf hxi
  1954. simpa only [heq] using hx
  1955. theorem convexIndep_image_complexToPlane (P : Finset ℂ)
  1956. (hp : ConvexIndependent ℝ (fun z : ↥(P : Set ℂ) => (z : ℂ))) :
  1957. EuclideanGeometry.ConvexIndep (P.image complexToPlane) := by
  1958. classical
  1959. apply convexIndependent_set_iff_notMem_convexHull_sdiff.mp
  1960. have hc := convexIndependent_linearMap complexToPlane.toLinearEquiv.toLinearMap
  1961. complexToPlane.injective (fun z : ↥(P : Set ℂ) => (z : ℂ)) hp
  1962. have hrange : (P.image complexToPlane : Set ℝ²) =
  1963. Set.range (fun z : ↥(P : Set ℂ) => complexToPlane (z : ℂ)) := by
  1964. ext y
  1965. simp
  1966. rw [hrange]
  1967. exact hc.range
  1968. theorem convexUnitDistanceCounts_bddAbove (n : ℕ) :
  1969. BddAbove (convexUnitDistanceCounts n) := by
  1970. classical
  1971. refine ⟨(n + 1).choose 2, ?_⟩
  1972. rintro _ ⟨P, hP, _, rfl⟩
  1973. rw [unitDistNum_eq_card_unitPairs]
  1974. calc
  1975. (unitPairs P).card ≤ P.sym2.card := Finset.card_filter_le _ _
  1976. _ = (n + 1).choose 2 := by rw [Finset.card_sym2, hP]
  1977. theorem unitDistNum_le_max (P : Finset ℝ²) (hP : EuclideanGeometry.ConvexIndep P) :
  1978. unitDistNum P ≤ maxConvexUnitDistances P.card := by
  1979. apply le_csSup (convexUnitDistanceCounts_bddAbove P.card)
  1980. exact ⟨P, rfl, hP, rfl⟩
  1981. end
  1982. end Proof
  1983. end OriginalPlaneBridge
  1984. /- ## Problem -/
  1985. section OriginalProblem
  1986. /-
  1987. The negation of Erdős problem 96, with the Euclidean-plane, convexity,
  1988. unordered-pair-count, and supremum definitions of Formal Conjectures.
  1989. -/
  1990. namespace Proof
  1991. noncomputable section
  1992. open Filter EuclideanGeometry
  1993. open scoped EuclideanGeometry
  1994. theorem constructionSize_ge_dimension {d : ℕ} (hd : 1 ≤ d) :
  1995. d ≤ constructionSize d := by
  1996. have hpow : 1 ≤ 2 ^ (d ^ (d + 1)) := Nat.one_le_iff_ne_zero.mpr (by positivity)
  1997. calc
  1998. d ≤ d ^ d := le_self_pow hd (by omega)
  1999. _ ≤ 2 * d ^ d := by omega
  2000. _ ≤ constructionSize d := by
  2001. simpa only [constructionSize, mul_one] using Nat.mul_le_mul_left (2 * d ^ d) hpow
  2002. /-- The explicit family in the literal Euclidean plane. -/
  2003. theorem plane_counterexample (d : ℕ) (hd : 2 ≤ d) :
  2004. ∃ points : Finset ℝ²,
  2005. ConvexIndep points ∧ points.card = constructionSize d ∧
  2006. d * points.card ≤ 4 * unitDistNum points := by
  2007. classical
  2008. obtain ⟨P, hconv, hcard, hcount⟩ := convex_unit_counterexample d hd
  2009. let points := P.image complexToPlane
  2010. have hcard' : points.card = P.card :=
  2011. Finset.card_image_of_injective _ complexToPlane.injective
  2012. have hunit : unitDistNum points = (unitPairs P).card := by
  2013. rw [unitDistNum_eq_card_unitPairs]
  2014. exact unitPairs_card_image_isometry complexToPlane complexToPlane.isometry P
  2015. refine ⟨points, convexIndep_image_complexToPlane P hconv, hcard'.trans hcard, ?_⟩
  2016. rw [hcard', hunit]
  2017. exact hcount
  2018. /-- Counterexamples occur past every cardinality threshold and every proposed linear bound. -/
  2019. theorem large_convex_counterexample (C : ℝ) (N₀ : ℕ) :
  2020. ∃ points : Finset ℝ²,
  2021. N₀ ≤ points.card ∧ ConvexIndep points ∧
  2022. C * (points.card : ℝ) < (unitDistNum points : ℝ) := by
  2023. obtain ⟨n, hn⟩ := exists_nat_gt (4 * C)
  2024. let d := n + N₀ + 2
  2025. have hd : 2 ≤ d := by dsimp [d]; omega
  2026. obtain ⟨P, hconv, hcard, hcount⟩ := plane_counterexample d hd
  2027. have hsize : N₀ ≤ P.card := by
  2028. rw [hcard]
  2029. exact le_trans (by dsimp [d]; omega) (constructionSize_ge_dimension (by omega))
  2030. have hP : (0 : ℝ) < P.card := by
  2031. have hh : 0 < P.card := by rw [hcard]; exact constructionSize_pos (by omega)
  2032. exact_mod_cast hh
  2033. have hcountR : (d : ℝ) * P.card ≤ 4 * unitDistNum P := by exact_mod_cast hcount
  2034. have hdR : 4 * C < (d : ℝ) := by dsimp [d]; push_cast; linarith
  2035. refine ⟨P, hsize, hconv, ?_⟩
  2036. nlinarith [mul_pos (sub_pos.mpr hdR) hP]
  2037. /-- The maximum number of unit distances in a convex n-gon is not O(n). -/
  2038. theorem erdos_96_false :
  2039. ¬ ((fun n => (maxConvexUnitDistances n : ℝ)) =O[atTop] fun n => (n : ℝ)) := by
  2040. intro h
  2041. obtain ⟨C, hC⟩ := h.bound
  2042. obtain ⟨N₀, hN₀⟩ := eventually_atTop.mp hC
  2043. obtain ⟨P, hlarge, hconv, hcount⟩ := large_convex_counterexample C N₀
  2044. have hupper := hN₀ P.card hlarge
  2045. have hmax : (unitDistNum P : ℝ) ≤ (maxConvexUnitDistances P.card : ℝ) := by
  2046. exact_mod_cast unitDistNum_le_max P hconv
  2047. simp only [Real.norm_natCast] at hupper
  2048. linarith
  2049. end
  2050. end Proof
  2051. end OriginalProblem
  2052. /-- The negation of the exact proposition in the supplied task. -/
  2053. theorem target : ¬ (True ↔
  2054. ((fun n => (Erdos96.maxConvexUnitDistances n : ℝ)) =O[Filter.atTop]
  2055. fun n => (n : ℝ))) := by
  2056. intro h
  2057. exact Proof.erdos_96_false (h.mp True.intro)
  2058. end Combined_Erdos96
  2059. /-! ## Source: UnitDegree.lean -/
  2060. section Combined_UnitDegree
  2061. /-! Unit-distance degrees and density-preserving vertex deletion (Lemma 4.1). -/
  2062. namespace Proof
  2063. noncomputable section
  2064. variable {X : Type*} [MetricSpace X]
  2065. def unitNeighbors (P : Finset X) (x : X) : Finset X := by
  2066. classical
  2067. exact P.filter (fun y => dist x y = 1)
  2068. def unitDegree (P : Finset X) (x : X) : ℕ := (unitNeighbors P x).card
  2069. def HasUnitMinDegree (P : Finset X) (k : ℕ) : Prop :=
  2070. ∀ x ∈ P, k ≤ unitDegree P x
  2071. @[simp] theorem mem_unitNeighbors {P : Finset X} {x y : X} :
  2072. y ∈ unitNeighbors P x ↔ y ∈ P ∧ dist x y = 1 := by
  2073. classical
  2074. simp [unitNeighbors]
  2075. @[simp] theorem self_not_mem_unitNeighbors (P : Finset X) (x : X) :
  2076. x ∉ unitNeighbors P x := by simp
  2077. @[simp] theorem mk_mem_unitPairs {P : Finset X} {x y : X} :
  2078. s(x, y) ∈ unitPairs P ↔ x ∈ P ∧ y ∈ P ∧ dist x y = 1 := by
  2079. classical
  2080. rw [unitPairs, Finset.mem_filter, Finset.mk_mem_sym2_iff]
  2081. change ((x ∈ P ∧ y ∈ P) ∧ dist x y = 1) ↔ _
  2082. exact and_assoc
  2083. @[simp] theorem unitPairs_empty : unitPairs (∅ : Finset X) = ∅ := by
  2084. classical
  2085. simp [unitPairs]
  2086. theorem unitDegree_mono {P Q : Finset X} (h : P ⊆ Q) (x : X) :
  2087. unitDegree P x ≤ unitDegree Q x := by
  2088. classical
  2089. exact Finset.card_le_card (Finset.filter_subset_filter _ h)
  2090. theorem unitDegree_lt_card {P : Finset X} {x : X} (hx : x ∈ P) :
  2091. unitDegree P x < P.card := by
  2092. classical
  2093. apply Finset.card_lt_card
  2094. exact Finset.ssubset_iff_subset_ne.mpr
  2095. ⟨Finset.filter_subset _ _, fun he => self_not_mem_unitNeighbors P x (he.symm ▸ hx)⟩
  2096. theorem unitPairs_mono {P Q : Finset X} (h : P ⊆ Q) : unitPairs P ⊆ unitPairs Q := by
  2097. classical
  2098. intro e
  2099. induction e using Sym2.inductionOn with
  2100. | hf x y => simp only [mk_mem_unitPairs]; exact fun hh => ⟨h hh.1, h hh.2.1, hh.2.2⟩
  2101. theorem unitDegree_erase_le [DecidableEq X] (P : Finset X) (x v : X) :
  2102. unitDegree P x ≤ unitDegree (P.erase v) x + 1 := by
  2103. classical
  2104. unfold unitDegree unitNeighbors
  2105. rw [Finset.filter_erase]
  2106. by_cases h : v ∈ P.filter (fun y => dist x y = 1)
  2107. · exact (Finset.card_erase_add_one h).ge
  2108. · rw [Finset.erase_eq_of_notMem h]
  2109. omega
  2110. theorem unitPairs_erase_add_degree [DecidableEq X] {P : Finset X} {x : X} (hx : x ∈ P) :
  2111. (unitPairs (P.erase x)).card + unitDegree P x = (unitPairs P).card := by
  2112. classical
  2113. let f : X → Sym2 X := fun y => s(x, y)
  2114. have hf : Function.Injective f := by
  2115. intro y z h
  2116. simp only [f, Sym2.eq, Sym2.rel_iff', Prod.mk.injEq, Prod.swap_prod_mk] at h
  2117. rcases h with h | h
  2118. · exact h.2
  2119. · exact h.2.trans h.1
  2120. have hunion : unitPairs (P.erase x) ∪ (unitNeighbors P x).image f = unitPairs P := by
  2121. ext e
  2122. induction e using Sym2.inductionOn with
  2123. | hf a b =>
  2124. simp only [Finset.mem_union, mk_mem_unitPairs, Finset.mem_erase, Finset.mem_image,
  2125. mem_unitNeighbors, f, Sym2.eq, Sym2.rel_iff', Prod.mk.injEq, Prod.swap_prod_mk]
  2126. constructor
  2127. · rintro (⟨⟨_, ha⟩, ⟨_, hb⟩, hab⟩ | ⟨y, ⟨hy, hxy⟩, he⟩)
  2128. · exact ⟨ha, hb, hab⟩
  2129. · rcases he with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩
  2130. · exact ⟨hx, hy, hxy⟩
  2131. · exact ⟨hy, hx, by simpa only [dist_comm] using hxy⟩
  2132. · rintro ⟨ha, hb, hab⟩
  2133. by_cases hax : a = x
  2134. · subst a
  2135. exact Or.inr ⟨b, ⟨hb, hab⟩, Or.inl ⟨rfl, rfl⟩⟩
  2136. by_cases hbx : b = x
  2137. · subst b
  2138. exact Or.inr ⟨a, ⟨ha, by simpa only [dist_comm] using hab⟩, Or.inr ⟨rfl, rfl⟩⟩
  2139. exact Or.inl ⟨⟨hax, ha⟩, ⟨hbx, hb⟩, hab⟩
  2140. have hdis : Disjoint (unitPairs (P.erase x)) ((unitNeighbors P x).image f) := by
  2141. apply Finset.disjoint_left.mpr
  2142. intro e he hfmem
  2143. obtain ⟨y, _, rfl⟩ := Finset.mem_image.mp hfmem
  2144. have hh := (mk_mem_unitPairs.mp he).1
  2145. exact (Finset.mem_erase.mp hh).1 rfl
  2146. rw [← hunion, Finset.card_union_of_disjoint hdis, Finset.card_image_of_injective _ hf]
  2147. rfl
  2148. /-- Repeated deletion retains both a minimum-degree bound and the original density. -/
  2149. theorem dense_subset_min_degree (α : ℝ) (k : ℕ) (hα : (k : ℝ) < α)
  2150. (P : Finset X) (hP : P.Nonempty) (hcount : α * P.card ≤ (unitPairs P).card) :
  2151. ∃ Q : Finset X, Q ⊆ P ∧ Q.Nonempty ∧ HasUnitMinDegree Q (k + 1) ∧
  2152. α * Q.card ≤ (unitPairs Q).card := by
  2153. classical
  2154. revert hP hcount
  2155. refine Finset.strongInductionOn P ?_
  2156. intro P ih hP hcount
  2157. by_cases hd : HasUnitMinDegree P (k + 1)
  2158. · exact ⟨P, Finset.Subset.refl P, hP, hd, hcount⟩
  2159. simp only [HasUnitMinDegree, not_forall, not_le] at hd
  2160. obtain ⟨x, hx, hdeg⟩ := hd
  2161. have hdeg' : (unitDegree P x : ℝ) ≤ k := by exact_mod_cast (by omega : unitDegree P x ≤ k)
  2162. have hcard : ((P.erase x).card : ℝ) + 1 = P.card := by
  2163. exact_mod_cast Finset.card_erase_add_one hx
  2164. have hedge : ((unitPairs (P.erase x)).card : ℝ) + unitDegree P x = (unitPairs P).card := by
  2165. exact_mod_cast unitPairs_erase_add_degree hx
  2166. have hnew : α * (P.erase x).card < (unitPairs (P.erase x)).card := by
  2167. nlinarith
  2168. have hne : (P.erase x).Nonempty := by
  2169. by_contra hn
  2170. rw [Finset.not_nonempty_iff_eq_empty.mp hn] at hnew
  2171. simpa using hnew
  2172. obtain ⟨Q, hQP, hQ, hdQ, hcQ⟩ := ih (P.erase x) (Finset.erase_ssubset hx) hne hnew.le
  2173. exact ⟨Q, hQP.trans (Finset.erase_subset _ _), hQ, hdQ, hcQ⟩
  2174. open EuclideanGeometry
  2175. open scoped EuclideanGeometry
  2176. theorem convexIndep_subset {P Q : Finset ℝ²} (hP : ConvexIndep P) (hQP : Q ⊆ P) :
  2177. ConvexIndep Q := by
  2178. intro x hx hh
  2179. apply hP x (hQP hx)
  2180. have hsub : ((Q : Set ℝ²) \ {x}) ⊆ ((P : Set ℝ²) \ {x}) :=
  2181. fun y hy => ⟨hQP hy.1, hy.2⟩
  2182. exact convexHull_mono hsub hh
  2183. /-- All vertices can have arbitrarily many neighbours at the same distance, namely one. -/
  2184. theorem exists_convex_min_degree (k : ℕ) :
  2185. ∃ P : Finset ℝ², P.Nonempty ∧ ConvexIndep P ∧ HasUnitMinDegree P k := by
  2186. obtain ⟨P, _, hconv, hc⟩ := large_convex_counterexample ((k : ℝ) + 1) 0
  2187. rw [unitDistNum_eq_card_unitPairs] at hc
  2188. have hP : P.Nonempty := by
  2189. by_contra hn
  2190. rw [Finset.not_nonempty_iff_eq_empty.mp hn] at hc
  2191. simpa using hc
  2192. obtain ⟨Q, hQP, hQ, hd, _⟩ := dense_subset_min_degree ((k : ℝ) + 1) k
  2193. (by linarith) P hP hc.le
  2194. exact ⟨Q, hQ, convexIndep_subset hconv hQP, fun x hx => (Nat.le_succ k).trans (hd x hx)⟩
  2195. theorem exists_convex_equidistant (k : ℕ) :
  2196. ∃ P : Finset ℝ², P.Nonempty ∧ ConvexIndep P ∧ Erdos97.HasNEquidistantProperty k P := by
  2197. obtain ⟨P, hP, hconv, hd⟩ := exists_convex_min_degree k
  2198. exact ⟨P, hP, hconv, fun x hx => ⟨1, by norm_num, hd x hx⟩⟩
  2199. theorem erdos_97_false :
  2200. ¬ (∀ P : Finset ℝ², P.Nonempty → ConvexIndep P → ¬ Erdos97.HasNEquidistantProperty 4 P) := by
  2201. obtain ⟨P, hP, hconv, he⟩ := exists_convex_equidistant 4
  2202. exact fun h => h P hP hconv he
  2203. theorem erdos_97_general_false :
  2204. ¬ (∃ k : ℕ, ∀ P : Finset ℝ², P.Nonempty → ConvexIndep P →
  2205. ¬ Erdos97.HasNEquidistantProperty k P) := by
  2206. rintro ⟨k, hk⟩
  2207. obtain ⟨P, hP, hconv, he⟩ := exists_convex_equidistant k
  2208. exact hk P hP hconv he
  2209. end
  2210. end Proof
  2211. end Combined_UnitDegree
  2212. /-! ## Source: GeneralProducts.lean -/
  2213. section Combined_GeneralProducts
  2214. /-! Products with bounded exponents: Lemma 2.1 and the general form of Lemma 3.4. -/
  2215. namespace Proof
  2216. noncomputable section
  2217. def boundedProduct {E : Type*} [Fintype E] {q : ℕ}
  2218. (w : E → ℂ) (a : E → Fin q) : ℂ := ∏ e, w e ^ (a e).val
  2219. def rotationBudget {E : Type*} [Fintype E] (q : ℕ) (w : E → ℂ) : ℝ :=
  2220. (q - 1 : ℕ) * ∑ e, ‖w e - 1‖
  2221. theorem boundedProduct_norm {E : Type*} [Fintype E] {q : ℕ}
  2222. (w : E → ℂ) (hw : ∀ e, ‖w e‖ = 1) (a : E → Fin q) :
  2223. ‖boundedProduct w a‖ = 1 := by
  2224. simp [boundedProduct, norm_prod, norm_pow, hw]
  2225. theorem norm_pow_sub_one_le (w : ℂ) (hw : ‖w‖ = 1) (n : ℕ) :
  2226. ‖w ^ n - 1‖ ≤ n * ‖w - 1‖ := by
  2227. induction n with
  2228. | zero => simp
  2229. | succ n ih =>
  2230. calc
  2231. ‖w ^ (n + 1) - 1‖ = ‖(w ^ n - 1) * w + (w - 1)‖ := by
  2232. congr 1
  2233. rw [pow_succ]
  2234. ring
  2235. _ ≤ ‖(w ^ n - 1) * w‖ + ‖w - 1‖ := norm_add_le _ _
  2236. _ = ‖w ^ n - 1‖ + ‖w - 1‖ := by rw [norm_mul, hw, mul_one]
  2237. _ ≤ (n + 1 : ℕ) * ‖w - 1‖ := by push_cast; nlinarith
  2238. theorem boundedProduct_close {E : Type*} [Fintype E] {q : ℕ}
  2239. (w : E → ℂ) (hw : ∀ e, ‖w e‖ = 1) (a : E → Fin q) :
  2240. ‖boundedProduct w a - 1‖ ≤ rotationBudget q w := by
  2241. classical
  2242. calc
  2243. ‖boundedProduct w a - 1‖ ≤ ∑ e, ‖w e ^ (a e).val - 1‖ :=
  2244. norm_prod_sub_one_le Finset.univ _ (by simp [norm_pow, hw])
  2245. _ ≤ ∑ e, ((a e).val : ℝ) * ‖w e - 1‖ :=
  2246. Finset.sum_le_sum (fun e _ => norm_pow_sub_one_le _ (hw e) _)
  2247. _ ≤ ∑ e, ((q - 1 : ℕ) : ℝ) * ‖w e - 1‖ := by
  2248. apply Finset.sum_le_sum
  2249. intro e _
  2250. apply mul_le_mul_of_nonneg_right _ (norm_nonneg _)
  2251. exact_mod_cast Nat.le_sub_one_of_lt (a e).isLt
  2252. _ = rotationBudget q w := by rw [rotationBudget, Finset.mul_sum]
  2253. def boundedCopy {I E : Type*} [Fintype E] {q : ℕ}
  2254. (b : I → ℂ) (w : E → ℂ) (x : I × (E → Fin q)) : ℂ :=
  2255. b x.1 * boundedProduct w x.2
  2256. theorem boundedCopy_injective {I E : Type*} [Fintype E] {q : ℕ}
  2257. (b : I → ℂ) (w : E → ℂ) (hb : ∀ i, b i ≠ 0)
  2258. (hn : Function.Injective (fun i => ‖b i‖)) (hw : ∀ e, ‖w e‖ = 1)
  2259. (hprod : Function.Injective (boundedProduct (q := q) w)) :
  2260. Function.Injective (boundedCopy (q := q) b w) := by
  2261. rintro ⟨i, a⟩ ⟨j, c⟩ he
  2262. have hnorm := congrArg norm he
  2263. simp only [boundedCopy, norm_mul, boundedProduct_norm w hw, mul_one] at hnorm
  2264. have hij := hn hnorm
  2265. subst j
  2266. exact Prod.ext rfl (hprod (mul_left_cancel₀ (hb i) he))
  2267. theorem boundedCopy_support {I E : Type*} [Fintype E] {q : ℕ}
  2268. (b : I → ℂ) (w : E → ℂ) (hb : ∀ i, b i ≠ 0)
  2269. (hn : Function.Injective (fun i => ‖b i‖)) (hb1 : ∀ i, ‖b i‖ ≤ 1)
  2270. (hw : ∀ e, ‖w e‖ = 1) (hprod : Function.Injective (boundedProduct (q := q) w))
  2271. (hs : ∀ i j, i ≠ j → support (b i) (b j) < -2 * rotationBudget q w)
  2272. (x y : I × (E → Fin q)) (hne : x ≠ y) :
  2273. support (boundedCopy b w x) (boundedCopy b w y) < 0 := by
  2274. rcases x with ⟨i, a⟩
  2275. rcases y with ⟨j, c⟩
  2276. by_cases hij : i = j
  2277. · subst j
  2278. apply support_negative_of_equal_norm
  2279. · exact (boundedCopy_injective b w hb hn hw hprod).ne hne
  2280. · simp only [boundedCopy, norm_mul, boundedProduct_norm w hw]
  2281. · have hh := rotated_support_bound (hb1 i) (hb1 j)
  2282. (boundedProduct_norm w hw a) (boundedProduct_norm w hw c)
  2283. (boundedProduct_close w hw a) (boundedProduct_close w hw c)
  2284. dsimp [boundedCopy]
  2285. linarith [hs i j hij]
  2286. theorem boundedCopy_displacement {I E : Type*} [Fintype E] {q : ℕ}
  2287. (b : I → ℂ) (w : E → ℂ) (hb : ∀ i, ‖b i‖ ≤ 1)
  2288. (hw : ∀ e, ‖w e‖ = 1) (x : I × (E → Fin q)) :
  2289. ‖boundedCopy b w x - b x.1‖ ≤ rotationBudget q w := by
  2290. rw [boundedCopy, ← mul_sub_one, norm_mul]
  2291. exact (mul_le_mul (hb _) (boundedProduct_close w hw _) (norm_nonneg _)
  2292. (by norm_num)).trans_eq (one_mul _)
  2293. def boundedSet {I E : Type*} [Fintype I] [Fintype E] {q : ℕ}
  2294. (b : I → ℂ) (w : E → ℂ) : Finset ℂ := by
  2295. classical
  2296. exact Finset.univ.image (boundedCopy (q := q) b w)
  2297. theorem boundedSet_card {I E : Type*} [Fintype I] [Fintype E] {q : ℕ}
  2298. (b : I → ℂ) (w : E → ℂ) (hi : Function.Injective (boundedCopy (q := q) b w)) :
  2299. (boundedSet (q := q) b w).card = Fintype.card I * q ^ Fintype.card E := by
  2300. classical
  2301. rw [boundedSet, Finset.card_image_of_injective _ hi]
  2302. simp
  2303. def exponentDifference {E : Type*} {q : ℕ} (a b : E → Fin q) (e : E) : ℝ :=
  2304. ((a e).val : ℝ) - (b e).val
  2305. theorem exponentDifference_nonzero {E : Type*} {q : ℕ} {a b : E → Fin q}
  2306. (hne : a ≠ b) : ∃ e, exponentDifference a b e ≠ 0 := by
  2307. by_contra h
  2308. push Not at h
  2309. apply hne
  2310. funext e
  2311. apply Fin.ext
  2312. have hh := sub_eq_zero.mp (h e)
  2313. exact_mod_cast hh
  2314. def boundedPhase {L P E : Type*} [Fintype E] {q : ℕ}
  2315. (l : E → L) (p : E → P) (θ : E → ℝ) (a : E → Fin q)
  2316. (z : (L → ℝ) × (P → ℝ)) : ℝ :=
  2317. ∑ e, ((a e).val : ℝ) * (θ e - chordAngle (z.1 (l e)) (z.2 (p e)))
  2318. theorem boundedProduct_phase {L P E : Type*} [Fintype E] {q : ℕ}
  2319. (l : E → L) (p : E → P) (θ : E → ℝ) (z : (L → ℝ) × (P → ℝ))
  2320. (a : E → Fin q) :
  2321. boundedProduct (phaseRotations l p θ z) a =
  2322. Complex.exp ((boundedPhase l p θ a z : ℂ) * Complex.I) := by
  2323. unfold boundedProduct phaseRotations boundedPhase
  2324. simp_rw [← Complex.exp_nat_mul]
  2325. rw [← Complex.exp_sum]
  2326. congr 1
  2327. simp only [Complex.ofReal_sum, Complex.ofReal_mul, Complex.ofReal_natCast, Finset.sum_mul,
  2328. mul_assoc]
  2329. theorem boundedPhase_difference {L P E : Type*} [Fintype E] {q : ℕ}
  2330. (l : E → L) (p : E → P) (θ : E → ℝ) (a b : E → Fin q)
  2331. (z : (L → ℝ) × (P → ℝ)) :
  2332. boundedPhase l p θ a z - boundedPhase l p θ b z =
  2333. (∑ e, exponentDifference a b e * θ e) - edgeAngleSum l p (exponentDifference a b) z := by
  2334. simp only [boundedPhase, edgeAngleSum, ← Finset.sum_sub_distrib]
  2335. apply Finset.sum_congr rfl
  2336. intro e _
  2337. unfold exponentDifference
  2338. ring
  2339. open Set Filter
  2340. open scoped Topology
  2341. theorem bounded_products_separate {L P E : Type*} [Fintype E] {q : ℕ}
  2342. [DecidableEq L] [DecidableEq P] [DecidableEq E]
  2343. (l : E → L) (p : E → P) (hij : Function.Injective (fun e => (l e, p e)))
  2344. (θ : E → ℝ) (U : Set ((L → ℝ) × (P → ℝ))) (hU : IsOpen U) (hne : U.Nonempty)
  2345. (hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0))
  2346. (hf : ∀ e, ∀ z ∈ U, ChordFeasible (z.1 (l e)) (z.2 (p e)))
  2347. (a b : E → Fin q) (hab : a ≠ b) :
  2348. ∃ z ∈ U, boundedProduct (phaseRotations l p θ z) a ≠
  2349. boundedProduct (phaseRotations l p θ z) b := by
  2350. by_contra hnone
  2351. push Not at hnone
  2352. obtain ⟨e, he⟩ := exponentDifference_nonzero hab
  2353. obtain ⟨z₀, hz₀⟩ := hne
  2354. let φ := fun z => boundedPhase l p θ a z - boundedPhase l p θ b z
  2355. have hφ : ∀ z, φ z = (∑ e, exponentDifference a b e * θ e) -
  2356. edgeAngleSum l p (exponentDifference a b) z := boundedPhase_difference l p θ a b
  2357. have hc : ContinuousOn φ U := by
  2358. intro z hz
  2359. have hh : ContinuousAt (fun z => (∑ e, exponentDifference a b e * θ e) -
  2360. edgeAngleSum l p (exponentDifference a b) z) z := continuousAt_const.sub
  2361. (edge_angles_continuousAt l p (exponentDifference a b) z (hnz z hz).1 (hnz z hz).2)
  2362. simpa only [show φ = fun z => (∑ e, exponentDifference a b e * θ e) -
  2363. edgeAngleSum l p (exponentDifference a b) z from funext hφ] using hh.continuousWithinAt
  2364. have hexp : ∀ z ∈ U, Complex.exp ((φ z : ℂ) * Complex.I) = 1 := by
  2365. intro z hz
  2366. dsimp [φ]
  2367. rw [Complex.ofReal_sub, sub_mul, Complex.exp_sub, ← boundedProduct_phase,
  2368. ← boundedProduct_phase, hnone z hz]
  2369. apply div_self
  2370. rw [boundedProduct_phase]
  2371. exact Complex.exp_ne_zero _
  2372. let V := U ∩ (fun z => |φ z - φ z₀|) ⁻¹' Iio Real.pi
  2373. have hVo : IsOpen V :=
  2374. (hc.sub continuousOn_const).abs.isOpen_inter_preimage hU isOpen_Iio
  2375. have hVne : V.Nonempty := ⟨z₀, hz₀, by simpa using Real.pi_pos⟩
  2376. have hVU : V ⊆ U := inter_subset_left
  2377. have hconst : ∀ z ∈ V, edgeAngleSum l p (exponentDifference a b) z =
  2378. (∑ e, exponentDifference a b e * θ e) - φ z₀ := by
  2379. intro z hz
  2380. have hh : φ z = φ z₀ := exp_phase_small_injective hz.2
  2381. ((hexp z (hVU hz)).trans (hexp z₀ hz₀).symm)
  2382. rw [hφ] at hh
  2383. linarith
  2384. obtain ⟨z, hz, hh⟩ := edge_angle_sum_not_constant l p hij (exponentDifference a b) e he
  2385. V hVo hVne (fun z hz => hf e z (hVU hz))
  2386. ((∑ e, exponentDifference a b e * θ e) - φ z₀)
  2387. exact hh (hconst z hz)
  2388. theorem exists_injective_boundedProducts {L P E : Type*} [Fintype E] (q : ℕ)
  2389. [DecidableEq L] [DecidableEq P] [DecidableEq E]
  2390. (l : E → L) (p : E → P) (hij : Function.Injective (fun e => (l e, p e)))
  2391. (θ : E → ℝ) (U : Set ((L → ℝ) × (P → ℝ))) (hU : IsOpen U) (hne : U.Nonempty)
  2392. (hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0))
  2393. (hf : ∀ e, ∀ z ∈ U, ChordFeasible (z.1 (l e)) (z.2 (p e))) :
  2394. ∃ z ∈ U, Function.Injective (boundedProduct (q := q) (phaseRotations l p θ z)) := by
  2395. classical
  2396. let K := {ab : (E → Fin q) × (E → Fin q) // ab.1 ≠ ab.2}
  2397. let f := fun (k : K) (z : (L → ℝ) × (P → ℝ)) =>
  2398. boundedProduct (phaseRotations l p θ z) k.val.1 -
  2399. boundedProduct (phaseRotations l p θ z) k.val.2
  2400. have hc : ∀ k, ContinuousOn (f k) U := by
  2401. intro k z hz
  2402. have hrot := phaseRotations_continuousAt l p θ z (hnz z hz).1 (hnz z hz).2
  2403. apply ContinuousAt.continuousWithinAt
  2404. unfold f boundedProduct
  2405. fun_prop
  2406. have hnc : ∀ k, ∀ V : Set ((L → ℝ) × (P → ℝ)),
  2407. V ⊆ U → IsOpen V → V.Nonempty → ∃ z ∈ V, f k z ≠ 0 := by
  2408. intro k V hVU hVo hVne
  2409. obtain ⟨z, hz, hh⟩ := bounded_products_separate l p hij θ V hVo hVne
  2410. (fun z hz => hnz z (hVU hz)) (fun e z hz => hf e z (hVU hz))
  2411. k.val.1 k.val.2 k.property
  2412. exact ⟨z, hz, sub_ne_zero.mpr hh⟩
  2413. obtain ⟨z, hz, hh⟩ := finite_avoidance f U hU hne hc hnc Finset.univ
  2414. refine ⟨z, hz, ?_⟩
  2415. intro a b heq
  2416. by_contra hab
  2417. exact hh (⟨(a, b), hab⟩ : K) (Finset.mem_univ _) (sub_eq_zero.mpr heq)
  2418. end
  2419. end Proof
  2420. end Combined_GeneralProducts
  2421. /-! ## Source: BoundedCounting.lean -/
  2422. section Combined_BoundedCounting
  2423. /-! The exact number of distinct lifted unit edges for bounded exponents. -/
  2424. namespace Proof
  2425. noncomputable section
  2426. def incrementExponent {E : Type*} [DecidableEq E] {q : ℕ}
  2427. (a : E → Fin q) (e : E) (h : (a e).val + 1 < q) : E → Fin q :=
  2428. Function.update a e ⟨(a e).val + 1, h⟩
  2429. theorem boundedProduct_increment {E : Type*} [Fintype E] [DecidableEq E] {q : ℕ}
  2430. (w : E → ℂ) (a : E → Fin q) (e : E) (h : (a e).val + 1 < q) :
  2431. boundedProduct w (incrementExponent a e h) = boundedProduct w a * w e := by
  2432. have he : ∀ f, w f ^ (incrementExponent a e h f).val =
  2433. w f ^ (a f).val * (if f = e then w e else 1) := by
  2434. intro f
  2435. by_cases hf : f = e
  2436. · subst f
  2437. simp [incrementExponent, pow_succ]
  2438. · simp [incrementExponent, Function.update_of_ne hf, hf]
  2439. simp only [boundedProduct, he, Finset.prod_mul_distrib]
  2440. simp
  2441. abbrev BoundedLiftedEdge (E : Type*) (q : ℕ) :=
  2442. (e : E) × (Fin (q - 1) × ({f : E // f ≠ e} → Fin q))
  2443. def edgeExponent {E : Type*} [DecidableEq E] {q : ℕ}
  2444. (e : E) (a : Fin (q - 1) × ({f : E // f ≠ e} → Fin q)) (f : E) : Fin q :=
  2445. if h : f = e then ⟨a.1.val, by have := a.1.isLt; omega⟩ else a.2 ⟨f, h⟩
  2446. @[simp] theorem edgeExponent_self {E : Type*} [DecidableEq E] {q : ℕ}
  2447. (e : E) (a : Fin (q - 1) × ({f : E // f ≠ e} → Fin q)) :
  2448. (edgeExponent e a e).val = a.1.val := by simp [edgeExponent]
  2449. theorem edgeExponent_injective {E : Type*} [DecidableEq E] {q : ℕ} (e : E) :
  2450. Function.Injective (edgeExponent (q := q) e) := by
  2451. intro a b h
  2452. apply Prod.ext
  2453. · apply Fin.ext
  2454. simpa using congrArg (fun f => (f e).val) h
  2455. · funext f
  2456. have hh := congrFun h f.val
  2457. simpa [edgeExponent, f.property] using hh
  2458. theorem edgeExponent_succ_lt {E : Type*} [DecidableEq E] {q : ℕ}
  2459. (e : E) (a : Fin (q - 1) × ({f : E // f ≠ e} → Fin q)) :
  2460. (edgeExponent e a e).val + 1 < q := by
  2461. rw [edgeExponent_self]
  2462. have := a.1.isLt
  2463. omega
  2464. theorem boundedLiftedEdge_card {E : Type*} [Fintype E] [DecidableEq E] (q : ℕ) :
  2465. Fintype.card (BoundedLiftedEdge E q) =
  2466. Fintype.card E * (q - 1) * q ^ (Fintype.card E - 1) := by
  2467. simp [BoundedLiftedEdge, Fintype.card_sigma, mul_assoc]
  2468. def boundedLiftedPair {L P E : Type*} [Fintype E] [DecidableEq E] {q : ℕ}
  2469. (l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)
  2470. (x : BoundedLiftedEdge E q) : Sym2 ℂ :=
  2471. s(boundedCopy b w (Sum.inl (l x.1), edgeExponent x.1 x.2),
  2472. boundedCopy b w (Sum.inr (p x.1),
  2473. incrementExponent (edgeExponent x.1 x.2) x.1 (edgeExponent_succ_lt x.1 x.2)))
  2474. theorem boundedLiftedPair_injective {L P E : Type*} [Fintype E] [DecidableEq E] {q : ℕ}
  2475. (l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)
  2476. (he : Function.Injective (fun e => (l e, p e)))
  2477. (hinj : Function.Injective (boundedCopy (q := q) b w)) :
  2478. Function.Injective (boundedLiftedPair (q := q) l p b w) := by
  2479. rintro ⟨e, a⟩ ⟨f, c⟩ hh
  2480. simp only [boundedLiftedPair, Sym2.eq, Sym2.rel_iff', Prod.mk.injEq, Prod.swap_prod_mk] at hh
  2481. rcases hh with ⟨hl, hp⟩ | ⟨hl, _⟩
  2482. · have hl := hinj hl
  2483. have hp := hinj hp
  2484. have hef := he (Prod.ext (Sum.inl.inj (congrArg Prod.fst hl))
  2485. (Sum.inr.inj (congrArg Prod.fst hp)))
  2486. subst f
  2487. have hac := edgeExponent_injective e (congrArg Prod.snd hl)
  2488. subst c
  2489. rfl
  2490. · have hbad := congrArg Prod.fst (hinj hl)
  2491. cases hbad
  2492. theorem mem_boundedSet {I E : Type*} [Fintype I] [Fintype E] {q : ℕ}
  2493. (b : I → ℂ) (w : E → ℂ) (x : I × (E → Fin q)) :
  2494. boundedCopy b w x ∈ boundedSet (q := q) b w := by
  2495. classical
  2496. exact Finset.mem_image.mpr ⟨x, Finset.mem_univ _, rfl⟩
  2497. theorem boundedCopy_unit_edge {I E : Type*} [Fintype E] [DecidableEq E] {q : ℕ}
  2498. (b : I → ℂ) (w : E → ℂ) (hw : ∀ e, ‖w e‖ = 1)
  2499. (i j : I) (e : E) (he : ‖b i - b j * w e‖ = 1)
  2500. (a : E → Fin q) (h : (a e).val + 1 < q) :
  2501. dist (boundedCopy b w (i, a)) (boundedCopy b w (j, incrementExponent a e h)) = 1 := by
  2502. simp only [boundedCopy, boundedProduct_increment, dist_eq_norm]
  2503. rw [show b i * boundedProduct w a - b j * (boundedProduct w a * w e) =
  2504. (b i - b j * w e) * boundedProduct w a by ring]
  2505. rw [norm_mul, he, boundedProduct_norm w hw, one_mul]
  2506. theorem boundedLiftedPair_mem_unitPairs {L P E : Type*}
  2507. [Fintype L] [Fintype P] [Fintype E] [DecidableEq E] {q : ℕ}
  2508. (l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)
  2509. (hw : ∀ e, ‖w e‖ = 1)
  2510. (hedge : ∀ e, ‖b (Sum.inl (l e)) - b (Sum.inr (p e)) * w e‖ = 1)
  2511. (x : BoundedLiftedEdge E q) :
  2512. boundedLiftedPair l p b w x ∈ unitPairs (boundedSet (q := q) b w) := by
  2513. classical
  2514. apply mk_mem_unitPairs.mpr
  2515. exact ⟨mem_boundedSet b w _, mem_boundedSet b w _,
  2516. boundedCopy_unit_edge b w hw _ _ x.1 (hedge x.1) _ _⟩
  2517. theorem bounded_amplification_unitPairs_bound {L P E : Type*}
  2518. [Fintype L] [Fintype P] [Fintype E] [DecidableEq E] {q : ℕ}
  2519. (l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)
  2520. (he : Function.Injective (fun e => (l e, p e)))
  2521. (hinj : Function.Injective (boundedCopy (q := q) b w)) (hw : ∀ e, ‖w e‖ = 1)
  2522. (hedge : ∀ e, ‖b (Sum.inl (l e)) - b (Sum.inr (p e)) * w e‖ = 1) :
  2523. Fintype.card E * (q - 1) * q ^ (Fintype.card E - 1) ≤
  2524. (unitPairs (boundedSet (q := q) b w)).card := by
  2525. let f : BoundedLiftedEdge E q → unitPairs (boundedSet (q := q) b w) :=
  2526. fun x => ⟨boundedLiftedPair l p b w x, boundedLiftedPair_mem_unitPairs l p b w hw hedge x⟩
  2527. have hf : Function.Injective f := fun x y h =>
  2528. boundedLiftedPair_injective l p b w he hinj (congrArg Subtype.val h)
  2529. simpa only [boundedLiftedEdge_card, Fintype.card_coe] using Fintype.card_le_of_injective f hf
  2530. end
  2531. end Proof
  2532. end Combined_BoundedCounting
  2533. /-! ## Source: MiddleLevels.lean -/
  2534. section Combined_MiddleLevels
  2535. /-! The middle-levels incidence graph and its powers-of-five seed pattern. -/
  2536. namespace Proof
  2537. noncomputable section
  2538. abbrev MiddleLower (d : ℕ) := {A : Finset (Fin (2 * d - 1)) // A.card = d - 1}
  2539. abbrev MiddleUpper (d : ℕ) := {B : Finset (Fin (2 * d - 1)) // B.card = d}
  2540. abbrev MiddleEdge (d : ℕ) := (B : MiddleUpper d) × {j : Fin (2 * d - 1) // j ∈ B.val}
  2541. def middlePoint {d : ℕ} (e : MiddleEdge d) : MiddleUpper d := e.1
  2542. def middleLine {d : ℕ} (e : MiddleEdge d) : MiddleLower d :=
  2543. ⟨e.1.val.erase e.2.val, by rw [Finset.card_erase_of_mem e.2.property, e.1.property]⟩
  2544. theorem middle_endpoints_injective (d : ℕ) :
  2545. Function.Injective (fun e : MiddleEdge d => (middleLine e, middlePoint e)) := by
  2546. rintro ⟨B, j⟩ ⟨C, k⟩ h
  2547. have hBC : B = C := congrArg Prod.snd h
  2548. subst C
  2549. have hjk : j = k := by
  2550. apply Subtype.ext
  2551. exact (Finset.erase_inj B.val j.property).mp (congrArg (fun z => z.1.val) h)
  2552. subst k
  2553. rfl
  2554. theorem finite_layer_card (n r : ℕ) :
  2555. Fintype.card {A : Finset (Fin n) // A.card = r} = n.choose r := by
  2556. classical
  2557. rw [Fintype.card_of_subtype (Finset.univ.powersetCard r)
  2558. (fun A => by simp [Finset.mem_powersetCard])]
  2559. simp [Finset.card_powersetCard]
  2560. theorem middleLower_card (d : ℕ) :
  2561. Fintype.card (MiddleLower d) = (2 * d - 1).choose (d - 1) := finite_layer_card _ _
  2562. theorem middleUpper_card (d : ℕ) :
  2563. Fintype.card (MiddleUpper d) = (2 * d - 1).choose d := finite_layer_card _ _
  2564. theorem middle_layers_equal {d : ℕ} (hd : 1 ≤ d) :
  2565. (2 * d - 1).choose (d - 1) = (2 * d - 1).choose d :=
  2566. Nat.choose_symm_of_eq_add (by omega)
  2567. def middleVertexCount (d : ℕ) : ℕ := (2 * d).choose d
  2568. def middleEdgeCount (d : ℕ) : ℕ := d * (2 * d - 1).choose d
  2569. def finiteSize (d q : ℕ) : ℕ := middleVertexCount d * q ^ middleEdgeCount d
  2570. theorem middleVertex_card {d : ℕ} (hd : 1 ≤ d) :
  2571. Fintype.card (MiddleLower d ⊕ MiddleUpper d) = middleVertexCount d := by
  2572. rw [Fintype.card_sum, middleLower_card, middleUpper_card]
  2573. unfold middleVertexCount
  2574. have h := Nat.choose_succ_succ' (2 * d - 1) (d - 1)
  2575. simpa only [Nat.sub_add_cancel hd, Nat.sub_add_cancel (by omega : 1 ≤ 2 * d)] using h.symm
  2576. theorem middleEdge_card (d : ℕ) : Fintype.card (MiddleEdge d) = middleEdgeCount d := by
  2577. classical
  2578. rw [Fintype.card_sigma]
  2579. simp only [Fintype.card_coe]
  2580. simp_rw [show ∀ B : MiddleUpper d, B.val.card = d from fun B => B.property]
  2581. simp [middleUpper_card, middleEdgeCount, mul_comm]
  2582. theorem middleVertexCount_eq_twice {d : ℕ} (hd : 1 ≤ d) :
  2583. middleVertexCount d = 2 * (2 * d - 1).choose d := by
  2584. rw [← middleVertex_card hd, Fintype.card_sum, middleLower_card, middleUpper_card,
  2585. middle_layers_equal hd]
  2586. omega
  2587. theorem middleEdgeCount_twice {d : ℕ} (hd : 1 ≤ d) :
  2588. 2 * middleEdgeCount d = d * middleVertexCount d := by
  2589. rw [middleVertexCount_eq_twice hd, middleEdgeCount]
  2590. ring
  2591. theorem middleEdgeCount_formula {d : ℕ} (hd : 1 ≤ d) :
  2592. middleEdgeCount d = d * (2 * d).choose d / 2 := by
  2593. have h := middleEdgeCount_twice hd
  2594. change 2 * middleEdgeCount d = d * (2 * d).choose d at h
  2595. omega
  2596. theorem middleVertexCount_pos (d : ℕ) : 0 < middleVertexCount d := by
  2597. exact Nat.choose_pos (by omega)
  2598. theorem middleEdgeCount_pos {d : ℕ} (hd : 1 ≤ d) : 0 < middleEdgeCount d := by
  2599. exact Nat.mul_pos (by omega) (Nat.choose_pos (by omega))
  2600. theorem finiteSize_pos {d q : ℕ} (hq : 1 ≤ q) : 0 < finiteSize d q :=
  2601. Nat.mul_pos (middleVertexCount_pos d) (pow_pos (by omega) _)
  2602. def finiteDigits {n : ℕ} (A : Finset (Fin n)) : Finset ℕ :=
  2603. A.map ⟨Fin.val, Fin.val_injective⟩
  2604. theorem finiteDigits_injective (n : ℕ) : Function.Injective (@finiteDigits n) :=
  2605. Finset.map_injective _
  2606. def middleX {n : ℕ} (A : Finset (Fin n)) : ℝ := digitSum 5 (finiteDigits A)
  2607. def middleT {n : ℕ} (A : Finset (Fin n)) : ℝ := 1 + digitSum 25 (finiteDigits A)
  2608. theorem middleT_pos {n : ℕ} (A : Finset (Fin n)) : 0 < middleT A := by
  2609. have h : 0 ≤ digitSum 25 (finiteDigits A) := Finset.sum_nonneg (fun _ _ => by positivity)
  2610. dsimp [middleT]
  2611. linarith
  2612. theorem middleT_injective (n : ℕ) : Function.Injective (@middleT n) := by
  2613. intro A B h
  2614. by_contra hne
  2615. have hh := (digit_separation ((finiteDigits_injective n).ne hne)).2.1
  2616. apply hh
  2617. dsimp [middleT] at h
  2618. linarith
  2619. theorem middle_digit_margin {n : ℕ} {A B : Finset (Fin n)} (hne : A ≠ B) :
  2620. -(middleX B - middleX A) ^ 2 / 2 - (middleT B - middleT A) / 4 < 0 ∧
  2621. -(middleX B - middleX A) ^ 2 / 2 + (middleT B - middleT A) / 4 < 0 := by
  2622. obtain ⟨hX, _, hsep⟩ := digit_separation ((finiteDigits_injective n).ne hne.symm)
  2623. have hm := signed_digit_margin hsep
  2624. have hsq : 0 < (digitSum 5 (finiteDigits B) - digitSum 5 (finiteDigits A)) ^ 2 :=
  2625. sq_pos_of_ne_zero (sub_ne_zero.mpr hX)
  2626. dsimp [middleX, middleT]
  2627. constructor <;> nlinarith [hm.1, hm.2]
  2628. theorem middle_incidence_digits {d : ℕ} (e : MiddleEdge d) :
  2629. middleX e.1.val - middleX (middleLine e).val = (5 : ℝ) ^ e.2.val.val ∧
  2630. middleT e.1.val - middleT (middleLine e).val = ((5 : ℝ) ^ e.2.val.val) ^ 2 := by
  2631. have he : finiteDigits e.1.val = insert e.2.val.val (finiteDigits (middleLine e).val) := by
  2632. calc
  2633. finiteDigits e.1.val = finiteDigits (insert e.2.val (middleLine e).val) :=
  2634. congrArg finiteDigits (Finset.insert_erase e.2.property).symm
  2635. _ = _ := Finset.map_insert _ _ _
  2636. have hne : e.2.val.val ∉ finiteDigits (middleLine e).val := by
  2637. simp [finiteDigits, middleLine]
  2638. constructor
  2639. · simp [middleX, he, digitSum, Finset.sum_insert hne]
  2640. · simp only [middleT, he, digitSum, Finset.sum_insert hne]
  2641. have hp : (25 : ℝ) ^ e.2.val.val = ((5 : ℝ) ^ e.2.val.val) ^ 2 := by
  2642. rw [← pow_mul, Nat.mul_comm e.2.val.val 2, pow_mul]
  2643. norm_num
  2644. linarith
  2645. def middlePattern (d : ℕ) : SeedPattern (MiddleLower d) (MiddleUpper d) (MiddleEdge d) where
  2646. line := middleLine
  2647. point := middlePoint
  2648. endpoints_injective := middle_endpoints_injective d
  2649. LX A := middleX A.val
  2650. LT A := middleT A.val
  2651. PX B := middleX B.val
  2652. PT B := middleT B.val
  2653. LT_pos A := middleT_pos A.val
  2654. PT_pos B := middleT_pos B.val
  2655. LT_injective := fun A B h => Subtype.ext (middleT_injective _ h)
  2656. PT_injective := fun A B h => Subtype.ext (middleT_injective _ h)
  2657. line_margin A B h := (middle_digit_margin (fun he => h (Subtype.ext he))).1
  2658. point_margin A B h := (middle_digit_margin (fun he => h (Subtype.ext he))).2
  2659. edge_positive e := by
  2660. have hh := (middle_incidence_digits e).1
  2661. have hp : 0 < (5 : ℝ) ^ e.2.val.val := by positivity
  2662. change middleX (middleLine e).val < middleX e.1.val
  2663. linarith
  2664. edge_identity e := by
  2665. change middleT e.1.val - middleT (middleLine e).val =
  2666. (middleX e.1.val - middleX (middleLine e).val) ^ 2
  2667. rw [(middle_incidence_digits e).1, (middle_incidence_digits e).2]
  2668. end
  2669. end Proof
  2670. end Combined_MiddleLevels
  2671. /-! ## Source: LocalizedSeeds.lean -/
  2672. section Combined_LocalizedSeeds
  2673. /-! Seed preparation with an arbitrary exponent bound and prescribed localization. -/
  2674. namespace Proof
  2675. noncomputable section
  2676. open Set Filter
  2677. open scoped Topology
  2678. def seedCenter {L P : Type*} : L ⊕ P → ℂ :=
  2679. Sum.elim (fun _ => ⟨0, -1 / 2⟩) (fun _ => ⟨0, 1 / 2⟩)
  2680. theorem SeedPattern.base_zero {L P E : Type*} (S : SeedPattern L P E) (i : L ⊕ P) :
  2681. S.base 0 i = seedCenter i := by
  2682. cases i <;> simp [SeedPattern.base, lineSeed, pointSeed, seedCenter]
  2683. structure LocalPreparedSeed {L P E : Type*} [Fintype E]
  2684. (l : E → L) (p : E → P) (q : ℕ) (η : ℝ) where
  2685. seed : PreparedSeed l p
  2686. support_margin : ∀ i j, i ≠ j →
  2687. support (seed.base i) (seed.base j) < -2 * rotationBudget q seed.rotation
  2688. localized : ∀ i, ‖seed.base i - seedCenter i‖ + rotationBudget q seed.rotation < η
  2689. theorem SeedPattern.exists_local_prepared {L P E : Type*}
  2690. [Fintype L] [Fintype P] [Fintype E] (S : SeedPattern L P E)
  2691. (q : ℕ) (hq : 2 ≤ q) (η : ℝ) (hη : 0 < η) :
  2692. Nonempty (LocalPreparedSeed S.line S.point q η) := by
  2693. let A := fun ε : ℝ => 2 * ((q - 1 : ℕ) : ℝ) * ∑ e, ‖S.coeff ε e‖
  2694. have hcoeff : ∀ e, ContinuousAt (fun ε => S.coeff ε e) 0 := S.coeff_continuous
  2695. have hA : ContinuousAt A 0 := by unfold A; fun_prop
  2696. have hbase : ∀ i, Continuous (fun ε => S.base ε i) := by
  2697. intro i
  2698. cases i with
  2699. | inl l => exact continuous_lineSeed _ _
  2700. | inr p => exact continuous_pointSeed _ _
  2701. have hbase0 : ∀ i, ‖S.base 0 i‖ = 1 / 2 := by
  2702. intro i
  2703. cases i <;> norm_num [SeedPattern.base, lineSeed, pointSeed, Complex.norm_def, Complex.normSq_apply]
  2704. have hbounds : ∀ i, ∀ᶠ ε in 𝓝[>] (0 : ℝ), S.base ε i ≠ 0 ∧ ‖S.base ε i‖ < 1 := by
  2705. intro i
  2706. have hlo : ∀ᶠ ε in 𝓝 (0 : ℝ), 0 < ‖S.base ε i‖ :=
  2707. continuousAt_const.eventually_lt (hbase i).norm.continuousAt (by rw [hbase0]; norm_num)
  2708. have hhi : ∀ᶠ ε in 𝓝 (0 : ℝ), ‖S.base ε i‖ < 1 :=
  2709. (hbase i).norm.continuousAt.eventually_lt continuousAt_const (by rw [hbase0]; norm_num)
  2710. filter_upwards [hlo.filter_mono nhdsWithin_le_nhds, hhi.filter_mono nhdsWithin_le_nhds] with ε hlo hhi
  2711. exact ⟨norm_pos_iff.mp hlo, hhi⟩
  2712. have hnorms : ∀ i j, ∀ᶠ ε in 𝓝[>] (0 : ℝ), i ≠ j → ‖S.base ε i‖ ≠ ‖S.base ε j‖ := by
  2713. intro i j
  2714. by_cases hij : i = j
  2715. · exact Eventually.of_forall (fun _ h => (h hij).elim)
  2716. cases i with
  2717. | inl l =>
  2718. cases j with
  2719. | inl k =>
  2720. have hk : l ≠ k := fun h => hij (congrArg Sum.inl h)
  2721. exact (eventually_line_norm_ne _ _ _ _ (S.LT_injective.ne hk)).mono (fun _ h _ => h)
  2722. | inr p =>
  2723. exact (eventually_cross_norm_ne _ _ _ _ (S.LT_pos l) (S.PT_pos p)).mono (fun _ h _ => h)
  2724. | inr p =>
  2725. cases j with
  2726. | inl l =>
  2727. exact (eventually_cross_norm_ne _ _ _ _ (S.LT_pos l) (S.PT_pos p)).mono (fun _ h _ => h.symm)
  2728. | inr r =>
  2729. have hr : p ≠ r := fun h => hij (congrArg Sum.inr h)
  2730. exact (eventually_point_norm_ne _ _ _ _ (S.PT_injective.ne hr)).mono (fun _ h _ => h)
  2731. have hsupports : ∀ i j, ∀ᶠ ε in 𝓝[>] (0 : ℝ),
  2732. i ≠ j → support (S.base ε i) (S.base ε j) < -ε ^ 3 * A ε := by
  2733. intro i j
  2734. by_cases hij : i = j
  2735. · exact Eventually.of_forall (fun _ h => (h hij).elim)
  2736. cases i with
  2737. | inl l =>
  2738. cases j with
  2739. | inl k =>
  2740. have hk : l ≠ k := fun h => hij (congrArg Sum.inl h)
  2741. exact (eventually_line_support _ _ _ _ A hA (S.line_margin l k hk)).mono (fun _ h _ => h)
  2742. | inr p =>
  2743. exact (eventually_cross_support _ _ _ _ A hA).mono (fun _ h _ => h.1)
  2744. | inr p =>
  2745. cases j with
  2746. | inl l =>
  2747. exact (eventually_cross_support _ _ _ _ A hA).mono (fun _ h _ => h.2)
  2748. | inr r =>
  2749. have hr : p ≠ r := fun h => hij (congrArg Sum.inr h)
  2750. exact (eventually_point_support _ _ _ _ A hA (S.point_margin p r hr)).mono (fun _ h _ => h)
  2751. have hedges : ∀ e, ∀ᶠ ε in 𝓝[>] (0 : ℝ),
  2752. ‖S.rot ε e‖ = 1 ∧
  2753. ‖S.base ε (Sum.inl (S.line e)) - S.base ε (Sum.inr (S.point e)) * S.rot ε e‖ = 1 ∧
  2754. S.rot ε e - 1 = (ε : ℂ) ^ 3 * S.coeff ε e := fun e =>
  2755. (seedCorrection_properties _ _ _ _ (S.edge_positive e) (S.edge_identity e)).filter_mono
  2756. nhdsWithin_le_nhds
  2757. have him : ∀ e, ∀ᶠ ε in 𝓝[>] (0 : ℝ),
  2758. (starRingEnd ℂ (S.base ε (Sum.inl (S.line e))) *
  2759. S.base ε (Sum.inr (S.point e)) * S.rot ε e).im < 0 := fun e =>
  2760. seedCorrection_im_negative _ _ _ _ (S.edge_positive e)
  2761. have hlocal : ∀ i, ∀ᶠ ε in 𝓝[>] (0 : ℝ),
  2762. ‖S.base ε i - seedCenter i‖ + ε ^ 3 * A ε / 2 < η := by
  2763. intro i
  2764. have hc : ContinuousAt (fun ε => ‖S.base ε i - seedCenter i‖ + ε ^ 3 * A ε / 2) 0 := by
  2765. fun_prop
  2766. exact (hc.eventually_lt continuousAt_const (by simpa [S.base_zero] using hη)).filter_mono
  2767. nhdsWithin_le_nhds
  2768. have hbAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i, S.base ε i ≠ 0 ∧ ‖S.base ε i‖ < 1 := by
  2769. simpa only [eventually_all] using hbounds
  2770. have hnAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i j, i ≠ j → ‖S.base ε i‖ ≠ ‖S.base ε j‖ := by
  2771. simpa only [eventually_all] using hnorms
  2772. have hsAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i j, i ≠ j →
  2773. support (S.base ε i) (S.base ε j) < -ε ^ 3 * A ε := by
  2774. simpa only [eventually_all] using hsupports
  2775. have heAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ e,
  2776. ‖S.rot ε e‖ = 1 ∧
  2777. ‖S.base ε (Sum.inl (S.line e)) - S.base ε (Sum.inr (S.point e)) * S.rot ε e‖ = 1 ∧
  2778. S.rot ε e - 1 = (ε : ℂ) ^ 3 * S.coeff ε e := by
  2779. simpa only [eventually_all] using hedges
  2780. have hiAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ e,
  2781. (starRingEnd ℂ (S.base ε (Sum.inl (S.line e))) *
  2782. S.base ε (Sum.inr (S.point e)) * S.rot ε e).im < 0 := by
  2783. simpa only [eventually_all] using him
  2784. have hlAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i,
  2785. ‖S.base ε i - seedCenter i‖ + ε ^ 3 * A ε / 2 < η := by
  2786. simpa only [eventually_all] using hlocal
  2787. obtain ⟨ε, hb, hn, hs, he, hi, hl, hε⟩ :=
  2788. (hbAll.and (hnAll.and (hsAll.and (heAll.and (hiAll.and (hlAll.and self_mem_nhdsWithin)))))).exists
  2789. have hε : 0 < ε := hε
  2790. have hsum : 2 * rotationBudget q (S.rot ε) = ε ^ 3 * A ε := by
  2791. unfold rotationBudget
  2792. simp_rw [fun e => (he e).2.2, norm_mul, norm_pow, Complex.norm_real, Real.norm_eq_abs,
  2793. abs_of_pos hε]
  2794. rw [← Finset.mul_sum]
  2795. dsimp [A]
  2796. ring
  2797. have hsup : ∀ i j, i ≠ j →
  2798. support (S.base ε i) (S.base ε j) < -2 * rotationBudget q (S.rot ε) := by
  2799. intro i j hij
  2800. linarith [hs i j hij]
  2801. let Q : PreparedSeed S.line S.point := {
  2802. base := S.base ε
  2803. rotation := S.rot ε
  2804. base_ne_zero := fun i => (hb i).1
  2805. base_norm_lt := fun i => (hb i).2
  2806. radii_injective := fun i j hh => by_contra fun hij => hn i j hij hh
  2807. rotation_norm := fun e => (he e).1
  2808. unit_edge := fun e => (he e).2.1
  2809. support_margin := by
  2810. intro i j hij
  2811. have hh := hsup i j hij
  2812. have hK : (1 : ℝ) ≤ ((q - 1 : ℕ) : ℝ) := by exact_mod_cast (by omega : 1 ≤ q - 1)
  2813. have hnn : 0 ≤ ∑ e, ‖S.rot ε e - 1‖ := Finset.sum_nonneg (fun _ _ => norm_nonneg _)
  2814. unfold rotationBudget at hh
  2815. nlinarith
  2816. chord_im_negative := hi }
  2817. refine ⟨⟨Q, hsup, ?_⟩⟩
  2818. intro i
  2819. change ‖S.base ε i - seedCenter i‖ + rotationBudget q (S.rot ε) < η
  2820. linarith [hl i]
  2821. structure LocalSeparatedSeed {L P E : Type*} [Fintype E]
  2822. (l : E → L) (p : E → P) (q : ℕ) (η : ℝ) where
  2823. base : L ⊕ P → ℂ
  2824. rotation : E → ℂ
  2825. base_ne_zero : ∀ i, base i ≠ 0
  2826. base_norm_lt : ∀ i, ‖base i‖ < 1
  2827. radii_injective : Function.Injective (fun i => ‖base i‖)
  2828. rotation_norm : ∀ e, ‖rotation e‖ = 1
  2829. unit_edge : ∀ e, ‖base (Sum.inl (l e)) - base (Sum.inr (p e)) * rotation e‖ = 1
  2830. support_margin : ∀ i j, i ≠ j → support (base i) (base j) < -2 * rotationBudget q rotation
  2831. products_injective : Function.Injective (boundedProduct (q := q) rotation)
  2832. localized : ∀ i, ‖base i - seedCenter i‖ + rotationBudget q rotation < η
  2833. theorem LocalPreparedSeed.exists_separated {L P E : Type*}
  2834. [Fintype L] [Fintype P] [Fintype E] {l : E → L} {p : E → P} {q : ℕ} {η : ℝ}
  2835. (R : LocalPreparedSeed l p q η) (hij : Function.Injective (fun e => (l e, p e))) :
  2836. Nonempty (LocalSeparatedSeed l p q η) := by
  2837. classical
  2838. let Q := R.seed
  2839. have hr : ∀ i, Q.radii.1 i ≠ 0 := fun i => norm_ne_zero_iff.mpr (Q.base_ne_zero _)
  2840. have hs : ∀ j, Q.radii.2 j ≠ 0 := fun j => norm_ne_zero_iff.mpr (Q.base_ne_zero _)
  2841. have hrot : ∀ e, ContinuousAt (fun z => phaseRotations l p Q.angles z e) Q.radii :=
  2842. phaseRotations_continuousAt l p Q.angles Q.radii hr hs
  2843. have hbase : ∀ i, ContinuousAt (fun z => Q.varBase z i) Q.radii :=
  2844. fun i => (Q.varBase_continuous i).continuousAt
  2845. have hH : ContinuousAt (fun z => rotationBudget q (phaseRotations l p Q.angles z)) Q.radii := by
  2846. unfold rotationBudget
  2847. fun_prop
  2848. have hmargin : ∀ i j, ∀ᶠ z in 𝓝 Q.radii, i ≠ j →
  2849. support (Q.varBase z i) (Q.varBase z j) < -2 * rotationBudget q (phaseRotations l p Q.angles z) := by
  2850. intro i j
  2851. by_cases hij : i = j
  2852. · exact Eventually.of_forall (fun _ h => (h hij).elim)
  2853. have hc : ContinuousAt (fun z => support (Q.varBase z i) (Q.varBase z j) +
  2854. 2 * rotationBudget q (phaseRotations l p Q.angles z)) Q.radii := by
  2855. have hri := Complex.continuous_re.continuousAt.comp (hbase i)
  2856. have hrj := Complex.continuous_re.continuousAt.comp (hbase j)
  2857. have hii := Complex.continuous_im.continuousAt.comp (hbase i)
  2858. have hij := Complex.continuous_im.continuousAt.comp (hbase j)
  2859. unfold support
  2860. exact ((hri.mul (hrj.sub hri)).add (hii.mul (hij.sub hii))).add
  2861. (continuousAt_const.mul hH)
  2862. have hvalue : support (Q.varBase Q.radii i) (Q.varBase Q.radii j) +
  2863. 2 * rotationBudget q (phaseRotations l p Q.angles Q.radii) < 0 := by
  2864. rw [Q.varBase_at_radii, Q.phase_at_radii]
  2865. linarith [R.support_margin i j hij]
  2866. exact (hc.eventually_lt continuousAt_const hvalue).mono (fun _ hh _ => by linarith)
  2867. have hlocal : ∀ i, ∀ᶠ z in 𝓝 Q.radii,
  2868. ‖Q.varBase z i - seedCenter i‖ + rotationBudget q (phaseRotations l p Q.angles z) < η := by
  2869. intro i
  2870. have hc : ContinuousAt (fun z => ‖Q.varBase z i - seedCenter i‖ +
  2871. rotationBudget q (phaseRotations l p Q.angles z)) Q.radii := by fun_prop
  2872. apply hc.eventually_lt continuousAt_const
  2873. rw [Q.varBase_at_radii, Q.phase_at_radii]
  2874. exact R.localized i
  2875. have hmAll : ∀ᶠ z in 𝓝 Q.radii, ∀ i j, i ≠ j →
  2876. support (Q.varBase z i) (Q.varBase z j) < -2 * rotationBudget q (phaseRotations l p Q.angles z) := by
  2877. simpa only [eventually_all] using hmargin
  2878. have hlAll : ∀ᶠ z in 𝓝 Q.radii, ∀ i,
  2879. ‖Q.varBase z i - seedCenter i‖ + rotationBudget q (phaseRotations l p Q.angles z) < η := by
  2880. simpa only [eventually_all] using hlocal
  2881. obtain ⟨U, hUgood, hU, hz₀⟩ := mem_nhds_iff.mp (Q.goodRadii_nhds.and (hmAll.and hlAll))
  2882. have hne : U.Nonempty := ⟨Q.radii, hz₀⟩
  2883. have hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0) := by
  2884. intro z hz
  2885. exact ⟨fun i => ne_of_gt ((hUgood hz).1.1 (Sum.inl i)),
  2886. fun j => ne_of_gt ((hUgood hz).1.1 (Sum.inr j))⟩
  2887. obtain ⟨z, hz, hprod⟩ := exists_injective_boundedProducts q l p hij Q.angles U hU hne hnz
  2888. (fun e z hz => (hUgood hz).1.2.2.2.1 e)
  2889. obtain ⟨⟨hpos, hnorm, hinj, hfeas, _⟩, hmargin, hloc⟩ := hUgood hz
  2890. have hrnorm : ∀ i, ‖Q.varBase z i‖ = joinedRadii z i :=
  2891. radialBase_norm Q.base Q.base_ne_zero (joinedRadii z) (fun i => (hpos i).le)
  2892. refine ⟨{
  2893. base := Q.varBase z
  2894. rotation := phaseRotations l p Q.angles z
  2895. base_ne_zero := fun i => norm_pos_iff.mp (by rw [hrnorm]; exact hpos i)
  2896. base_norm_lt := hnorm
  2897. radii_injective := ?_
  2898. rotation_norm := phaseRotations_norm l p Q.angles z
  2899. unit_edge := fun e => Q.varBase_unit_edge z e (hfeas e)
  2900. support_margin := hmargin
  2901. products_injective := hprod
  2902. localized := hloc }⟩
  2903. intro i j hh
  2904. dsimp only at hh
  2905. rw [hrnorm, hrnorm] at hh
  2906. exact hinj hh
  2907. end
  2908. end Proof
  2909. end Combined_LocalizedSeeds
  2910. /-! ## Source: FiniteConstruction.lean -/
  2911. section Combined_FiniteConstruction
  2912. /-! The full finite construction of Theorem 1.3. -/
  2913. namespace Proof
  2914. noncomputable section
  2915. def lowerCenter : ℂ := ⟨0, -1 / 2⟩
  2916. def upperCenter : ℂ := ⟨0, 1 / 2⟩
  2917. def twoDisks (η : ℝ) : Set ℂ := Metric.ball lowerCenter η ∪ Metric.ball upperCenter η
  2918. def RadialSupport (P : Finset ℂ) : Prop :=
  2919. ∀ x ∈ P, ∀ y ∈ P, x ≠ y → support x y < 0
  2920. theorem RadialSupport.mono {P Q : Finset ℂ} (hP : RadialSupport P) (hQP : Q ⊆ P) :
  2921. RadialSupport Q := fun x hx y hy hne => hP x (hQP hx) y (hQP hy) hne
  2922. theorem RadialSupport.convexIndependent {P : Finset ℂ} (hP : RadialSupport P) :
  2923. ConvexIndependent ℝ (fun z : ↥(P : Set ℂ) => (z : ℂ)) := by
  2924. apply convexIndependent_of_support
  2925. intro x y hne
  2926. exact hP x.val x.property y.val y.property (fun h => hne (Subtype.ext h))
  2927. theorem twoDisks_open (η : ℝ) : IsOpen (twoDisks η) :=
  2928. Metric.isOpen_ball.union Metric.isOpen_ball
  2929. theorem SeedPattern.finite_construction {L R E : Type*}
  2930. [Fintype L] [Fintype R] [Fintype E] (S : SeedPattern L R E)
  2931. (q : ℕ) (hq : 2 ≤ q) (η : ℝ) (hη : 0 < η) :
  2932. ∃ P : Finset ℂ,
  2933. P.card = Fintype.card (L ⊕ R) * q ^ Fintype.card E ∧
  2934. Fintype.card E * (q - 1) * q ^ (Fintype.card E - 1) ≤ (unitPairs P).card ∧
  2935. RadialSupport P ∧ 0 ∉ P ∧ (P : Set ℂ) ⊆ twoDisks η := by
  2936. classical
  2937. obtain ⟨Q⟩ := S.exists_local_prepared q hq η hη
  2938. obtain ⟨B⟩ := Q.exists_separated S.endpoints_injective
  2939. let P := boundedSet (q := q) B.base B.rotation
  2940. have hinj := boundedCopy_injective B.base B.rotation B.base_ne_zero B.radii_injective
  2941. B.rotation_norm B.products_injective
  2942. refine ⟨P, boundedSet_card B.base B.rotation hinj,
  2943. bounded_amplification_unitPairs_bound S.line S.point B.base B.rotation
  2944. S.endpoints_injective hinj B.rotation_norm B.unit_edge, ?_, ?_, ?_⟩
  2945. · intro x hx y hy hne
  2946. obtain ⟨a, _, rfl⟩ := Finset.mem_image.mp hx
  2947. obtain ⟨b, _, rfl⟩ := Finset.mem_image.mp hy
  2948. exact boundedCopy_support B.base B.rotation B.base_ne_zero B.radii_injective
  2949. (fun i => (B.base_norm_lt i).le) B.rotation_norm B.products_injective B.support_margin
  2950. a b (fun h => hne (congrArg (boundedCopy B.base B.rotation) h))
  2951. · intro hz
  2952. obtain ⟨a, _, ha⟩ := Finset.mem_image.mp hz
  2953. have hn : boundedProduct B.rotation a.2 ≠ 0 := norm_ne_zero_iff.mp
  2954. (by rw [boundedProduct_norm B.rotation B.rotation_norm]; norm_num)
  2955. exact mul_ne_zero (B.base_ne_zero a.1) hn ha
  2956. · intro x hx
  2957. obtain ⟨a, _, rfl⟩ := Finset.mem_image.mp hx
  2958. have hclose : ‖boundedCopy B.base B.rotation a - seedCenter a.1‖ < η := by
  2959. have hd := boundedCopy_displacement B.base B.rotation (fun i => (B.base_norm_lt i).le)
  2960. B.rotation_norm a
  2961. have ht := norm_sub_le_norm_sub_add_norm_sub (boundedCopy B.base B.rotation a)
  2962. (B.base a.1) (seedCenter a.1)
  2963. linarith [B.localized a.1]
  2964. cases h : a.1 with
  2965. | inl l =>
  2966. apply Or.inl
  2967. simpa only [Metric.mem_ball, dist_eq_norm, h, seedCenter, Sum.elim_inl, lowerCenter] using hclose
  2968. | inr r =>
  2969. apply Or.inr
  2970. simpa only [Metric.mem_ball, dist_eq_norm, h, seedCenter, Sum.elim_inr, upperCenter] using hclose
  2971. /-- The finite theorem with an integer form of its edge-density bound. -/
  2972. theorem finite_construction (d q : ℕ) (hd : 2 ≤ d) (hq : 2 ≤ q)
  2973. (η : ℝ) (hη : 0 < η) :
  2974. ∃ P : Finset ℂ,
  2975. P.card = finiteSize d q ∧ d * (q - 1) * P.card ≤ 2 * q * (unitPairs P).card ∧
  2976. RadialSupport P ∧ 0 ∉ P ∧ (P : Set ℂ) ⊆ twoDisks η := by
  2977. obtain ⟨P, hc, he, hs, hn, hl⟩ := (middlePattern d).finite_construction q hq η hη
  2978. simp only [middleVertex_card (by omega : 1 ≤ d), middleEdge_card] at hc he
  2979. refine ⟨P, hc, ?_, hs, hn, hl⟩
  2980. have hm : 1 ≤ middleEdgeCount d := middleEdgeCount_pos (by omega)
  2981. have hpow : q ^ middleEdgeCount d = q * q ^ (middleEdgeCount d - 1) := by
  2982. rw [← pow_succ', Nat.sub_add_cancel hm]
  2983. calc
  2984. d * (q - 1) * P.card =
  2985. 2 * q * (middleEdgeCount d * (q - 1) * q ^ (middleEdgeCount d - 1)) := by
  2986. calc
  2987. _ = (d * middleVertexCount d) * (q - 1) * q * q ^ (middleEdgeCount d - 1) := by
  2988. rw [hc, hpow]
  2989. ring
  2990. _ = _ := by rw [← middleEdgeCount_twice (by omega : 1 ≤ d)]; ring
  2991. _ ≤ 2 * q * (unitPairs P).card := Nat.mul_le_mul_left _ he
  2992. /-- Theorem 1.3 in the manuscript's real-valued notation. -/
  2993. theorem finite_construction_real (d q : ℕ) (hd : 2 ≤ d) (hq : 2 ≤ q)
  2994. (η : ℝ) (hη : 0 < η) :
  2995. ∃ P : Finset ℂ,
  2996. P.card = finiteSize d q ∧
  2997. (d : ℝ) / 2 * (1 - 1 / (q : ℝ)) * P.card ≤ (unitPairs P).card ∧
  2998. RadialSupport P ∧ 0 ∉ P ∧ (P : Set ℂ) ⊆ twoDisks η := by
  2999. obtain ⟨P, hc, he, hs, hn, hl⟩ := finite_construction d q hd hq η hη
  3000. refine ⟨P, hc, ?_, hs, hn, hl⟩
  3001. have heR : (d : ℝ) * ((q - 1 : ℕ) : ℝ) * P.card ≤ 2 * q * (unitPairs P).card := by
  3002. exact_mod_cast he
  3003. rw [Nat.cast_sub (by omega : 1 ≤ q), Nat.cast_one] at heR
  3004. have hqR : (0 : ℝ) < q := by exact_mod_cast (by omega : 0 < q)
  3005. apply (mul_le_mul_iff_right₀ (show (0 : ℝ) < 2 * q by positivity)).mp
  3006. have hid : (2 * (q : ℝ)) * ((d : ℝ) / 2 * (1 - 1 / (q : ℝ)) * P.card) =
  3007. (d : ℝ) * ((q : ℝ) - 1) * P.card := by
  3008. field_simp [ne_of_gt hqR] <;> ring
  3009. rw [hid]
  3010. exact heR
  3011. end
  3012. end Proof
  3013. end Combined_FiniteConstruction
  3014. /-! ## Source: UnitGraph.lean -/
  3015. section Combined_UnitGraph
  3016. /-! Graph and finite-set counting tools for the prescribed-cardinality construction. -/
  3017. namespace Proof
  3018. noncomputable section
  3019. open Classical
  3020. variable {X Y : Type*} [MetricSpace X] [MetricSpace Y]
  3021. def unitDistanceGraph (P : Finset X) : SimpleGraph P where
  3022. Adj x y := dist (x : X) (y : X) = 1
  3023. symm := ⟨fun x y h => by simpa only [dist_comm] using h⟩
  3024. loopless := ⟨fun x => by simp⟩
  3025. theorem unitDistanceGraph_degree (P : Finset X) (x : P) :
  3026. (unitDistanceGraph P).degree x = unitDegree P x.val := by
  3027. have he : ((unitDistanceGraph P).neighborFinset x).image Subtype.val = unitNeighbors P x.val := by
  3028. ext y
  3029. simp only [Finset.mem_image, mem_unitNeighbors]
  3030. constructor
  3031. · rintro ⟨z, hz, rfl⟩
  3032. exact ⟨z.property, ((unitDistanceGraph P).mem_neighborFinset x z).mp hz⟩
  3033. · rintro ⟨hy, hxy⟩
  3034. exact ⟨⟨y, hy⟩, ((unitDistanceGraph P).mem_neighborFinset x ⟨y, hy⟩).mpr hxy, rfl⟩
  3035. have hc := Finset.card_image_of_injective ((unitDistanceGraph P).neighborFinset x)
  3036. (show Function.Injective (Subtype.val : P → X) from Subtype.val_injective)
  3037. rw [he] at hc
  3038. exact hc.symm
  3039. theorem unitDistanceGraph_edges (P : Finset X) :
  3040. ((unitDistanceGraph P).edgeFinset).image (Sym2.map (Subtype.val : P → X)) = unitPairs P := by
  3041. ext e
  3042. induction e using Sym2.inductionOn with
  3043. | hf x y =>
  3044. rw [mk_mem_unitPairs]
  3045. constructor
  3046. · rintro he
  3047. obtain ⟨f, hf, hfe⟩ := Finset.mem_image.mp he
  3048. induction f using Sym2.inductionOn with
  3049. | hf a b =>
  3050. have hab : dist (a : X) (b : X) = 1 := by
  3051. exact (SimpleGraph.mem_edgeSet (unitDistanceGraph P)).mp (SimpleGraph.mem_edgeFinset.mp hf)
  3052. have hm : s(a.val, b.val) ∈ unitPairs P :=
  3053. mk_mem_unitPairs.mpr ⟨a.property, b.property, hab⟩
  3054. rw [show s(a.val, b.val) = s(x, y) from hfe] at hm
  3055. exact mk_mem_unitPairs.mp hm
  3056. · rintro ⟨hx, hy, hxy⟩
  3057. apply Finset.mem_image.mpr
  3058. refine ⟨s((⟨x, hx⟩ : P), (⟨y, hy⟩ : P)), ?_, rfl⟩
  3059. exact SimpleGraph.mem_edgeFinset.mpr ((SimpleGraph.mem_edgeSet (unitDistanceGraph P)).mpr hxy)
  3060. theorem unitDistanceGraph_card_edges (P : Finset X) :
  3061. (unitDistanceGraph P).edgeFinset.card = (unitPairs P).card := by
  3062. rw [← unitDistanceGraph_edges, Finset.card_image_of_injective _
  3063. (Sym2.map.injective (show Function.Injective (Subtype.val : P → X) from Subtype.val_injective))]
  3064. theorem sum_unitDegree (P : Finset X) :
  3065. ∑ x ∈ P, unitDegree P x = 2 * (unitPairs P).card := by
  3066. have h := (unitDistanceGraph P).sum_degrees_eq_twice_card_edges
  3067. simp_rw [unitDistanceGraph_degree] at h
  3068. rw [unitDistanceGraph_card_edges] at h
  3069. simpa only [Finset.univ_eq_attach, Finset.sum_attach] using h
  3070. theorem exists_degree_le_average (P : Finset X) (hP : P.Nonempty) :
  3071. ∃ x ∈ P, (unitDegree P x : ℝ) * P.card ≤ 2 * (unitPairs P).card := by
  3072. by_contra h
  3073. push Not at h
  3074. have hsum : ∑ x ∈ P, (2 * ((unitPairs P).card : ℝ)) <
  3075. ∑ x ∈ P, (unitDegree P x : ℝ) * P.card :=
  3076. Finset.sum_lt_sum_of_nonempty hP (fun x hx => h x hx)
  3077. rw [Finset.sum_const, nsmul_eq_mul, ← Finset.sum_mul, ← Nat.cast_sum, sum_unitDegree] at hsum
  3078. push_cast at hsum
  3079. nlinarith
  3080. theorem unitNeighbors_image_isometry (f : X → Y) (hf : Isometry f) (P : Finset X) (x : X) :
  3081. unitNeighbors (P.image f) (f x) = (unitNeighbors P x).image f := by
  3082. unfold unitNeighbors
  3083. rw [Finset.filter_image]
  3084. simp only [hf.dist_eq]
  3085. theorem unitDegree_image_isometry (f : X → Y) (hf : Isometry f) (P : Finset X) (x : X) :
  3086. unitDegree (P.image f) (f x) = unitDegree P x := by
  3087. rw [unitDegree, unitNeighbors_image_isometry f hf, Finset.card_image_of_injective _ hf.injective]
  3088. rfl
  3089. theorem unitPairs_disjoint {P Q : Finset X} (h : Disjoint P Q) :
  3090. Disjoint (unitPairs P) (unitPairs Q) := by
  3091. apply Finset.disjoint_left.mpr
  3092. intro e hp hq
  3093. induction e using Sym2.inductionOn with
  3094. | hf x y => exact Finset.disjoint_left.mp h (mk_mem_unitPairs.mp hp).1 (mk_mem_unitPairs.mp hq).1
  3095. theorem unitPairs_union_bound {P Q : Finset X} (h : Disjoint P Q) :
  3096. (unitPairs P).card + (unitPairs Q).card ≤ (unitPairs (P ∪ Q)).card := by
  3097. rw [← Finset.card_union_of_disjoint (unitPairs_disjoint h)]
  3098. apply Finset.card_le_card
  3099. exact Finset.union_subset (unitPairs_mono Finset.subset_union_left)
  3100. (unitPairs_mono Finset.subset_union_right)
  3101. end
  3102. end Proof
  3103. end Combined_UnitGraph
  3104. /-! ## Source: RotatedCopies.lean -/
  3105. section Combined_RotatedCopies
  3106. /-! Arbitrarily small disjoint rotations preserving strict support (Lemma 4.2). -/
  3107. namespace Proof
  3108. noncomputable section
  3109. open Set Filter Classical
  3110. open scoped Topology
  3111. def rotate (θ : ℝ) (z : ℂ) : ℂ := z * Complex.exp ((θ : ℂ) * Complex.I)
  3112. theorem rotate_zero (z : ℂ) : rotate 0 z = z := by simp [rotate]
  3113. theorem rotate_norm (θ : ℝ) (z : ℂ) : ‖rotate θ z‖ = ‖z‖ := by
  3114. rw [rotate, norm_mul, Complex.norm_exp_ofReal_mul_I, mul_one]
  3115. theorem rotate_isometry (θ : ℝ) : Isometry (rotate θ) := by
  3116. apply Isometry.of_dist_eq
  3117. intro x y
  3118. simp only [rotate, dist_eq_norm, ← sub_mul, norm_mul, Complex.norm_exp_ofReal_mul_I, mul_one]
  3119. theorem rotate_ne_zero (θ : ℝ) {z : ℂ} (hz : z ≠ 0) : rotate θ z ≠ 0 :=
  3120. mul_ne_zero hz (Complex.exp_ne_zero _)
  3121. def rotatedUnion {I : Type*} [Fintype I] (A : I → Finset ℂ) (θ : I → ℝ) : Finset ℂ :=
  3122. Finset.univ.biUnion (fun i => (A i).image (rotate (θ i)))
  3123. theorem small_rotations {I : Type*} [Fintype I] (Q : Finset ℂ)
  3124. (hzero : 0 ∉ Q) (hQ : RadialSupport Q) (O : Set ℂ) (hO : IsOpen O)
  3125. (hQO : (Q : Set ℂ) ⊆ O) (τ : ℝ) (hτ : 0 < τ) :
  3126. ∃ θ : I → ℝ,
  3127. (∀ i, |θ i| < τ) ∧
  3128. Function.Injective (fun a : I × Q => rotate (θ a.1) a.2.val) ∧
  3129. (∀ a b : I × Q, a ≠ b → support (rotate (θ a.1) a.2.val) (rotate (θ b.1) b.2.val) < 0) ∧
  3130. (∀ a : I × Q, rotate (θ a.1) a.2.val ∈ O) := by
  3131. let rank : I → ℝ := fun i => ((Fintype.equivFin I i).val : ℝ)
  3132. have hrank : Function.Injective rank := by
  3133. intro i j h
  3134. apply (Fintype.equivFin I).injective
  3135. apply Fin.ext
  3136. dsimp [rank] at h
  3137. exact_mod_cast h
  3138. let F := fun (ε : ℝ) (a : I × Q) => rotate (ε * rank a.1) a.2.val
  3139. have hF : ∀ a, Continuous (fun ε => F ε a) := by
  3140. intro a
  3141. unfold F rotate
  3142. fun_prop
  3143. have hF0 : ∀ a, F 0 a = a.2.val := fun a => by simp [F, rotate]
  3144. have hsupport : ∀ a b : I × Q, ∀ᶠ ε in 𝓝 (0 : ℝ), a.2.val ≠ b.2.val →
  3145. support (F ε a) (F ε b) < 0 := by
  3146. intro a b
  3147. by_cases hab : a.2.val = b.2.val
  3148. · exact Eventually.of_forall (fun _ h => (h hab).elim)
  3149. have hc : ContinuousAt (fun ε => support (F ε a) (F ε b)) 0 := by
  3150. have ha := (hF a).continuousAt (x := 0)
  3151. have hb := (hF b).continuousAt (x := 0)
  3152. unfold support
  3153. fun_prop
  3154. have h0 : support (F 0 a) (F 0 b) < 0 := by
  3155. rw [hF0, hF0]
  3156. exact hQ _ a.2.property _ b.2.property hab
  3157. exact (hc.eventually_lt continuousAt_const h0).mono (fun _ h _ => h)
  3158. have hloc : ∀ a : I × Q, ∀ᶠ ε in 𝓝 (0 : ℝ), F ε a ∈ O := by
  3159. intro a
  3160. apply (hF a).continuousAt.eventually
  3161. apply hO.mem_nhds
  3162. change F 0 a ∈ O
  3163. rw [hF0]
  3164. exact hQO a.2.property
  3165. have hphase : ∀ i j : I, ∀ᶠ ε in 𝓝 (0 : ℝ), |ε * rank i - ε * rank j| < Real.pi := by
  3166. intro i j
  3167. have hc : ContinuousAt (fun ε : ℝ => |ε * rank i - ε * rank j|) 0 := by fun_prop
  3168. exact hc.eventually_lt continuousAt_const (by simpa using Real.pi_pos)
  3169. have hsmall : ∀ i : I, ∀ᶠ ε in 𝓝 (0 : ℝ), |ε * rank i| < τ := by
  3170. intro i
  3171. have hc : ContinuousAt (fun ε : ℝ => |ε * rank i|) 0 := by fun_prop
  3172. exact hc.eventually_lt continuousAt_const (by simpa using hτ)
  3173. have hsAll : ∀ᶠ ε in 𝓝 (0 : ℝ), ∀ a b : I × Q, a.2.val ≠ b.2.val →
  3174. support (F ε a) (F ε b) < 0 := by simpa only [eventually_all] using hsupport
  3175. have hlAll : ∀ᶠ ε in 𝓝 (0 : ℝ), ∀ a : I × Q, F ε a ∈ O := by
  3176. simpa only [eventually_all] using hloc
  3177. have hpAll : ∀ᶠ ε in 𝓝 (0 : ℝ), ∀ i j : I, |ε * rank i - ε * rank j| < Real.pi := by
  3178. simpa only [eventually_all] using hphase
  3179. have htAll : ∀ᶠ ε in 𝓝 (0 : ℝ), ∀ i : I, |ε * rank i| < τ := by
  3180. simpa only [eventually_all] using hsmall
  3181. obtain ⟨ε, ⟨hs, hl, hp, ht⟩, hε⟩ :=
  3182. (((hsAll.and (hlAll.and (hpAll.and htAll))).filter_mono nhdsWithin_le_nhds).and
  3183. (self_mem_nhdsWithin : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ε ∈ Ioi 0)).exists
  3184. have hε : 0 < ε := hε
  3185. have hinj : Function.Injective (F ε) := by
  3186. rintro ⟨i, x⟩ ⟨j, y⟩ he
  3187. by_cases hxy : x = y
  3188. · subst y
  3189. have hx : (x : ℂ) ≠ 0 := fun h => hzero (h ▸ x.property)
  3190. have hexp := mul_left_cancel₀ hx he
  3191. have hangle := exp_phase_small_injective (hp i j) hexp
  3192. exact Prod.ext (hrank (mul_left_cancel₀ (ne_of_gt hε) hangle)) rfl
  3193. · have hn := hs (i, x) (j, y) (fun h => hxy (Subtype.ext h))
  3194. rw [he] at hn
  3195. simpa [support] using hn
  3196. refine ⟨fun i => ε * rank i, ht, hinj, ?_, hl⟩
  3197. intro a b hab
  3198. by_cases hxy : a.2.val = b.2.val
  3199. · apply support_negative_of_equal_norm (hinj.ne hab)
  3200. change ‖rotate (ε * rank a.1) a.2.val‖ = ‖rotate (ε * rank b.1) b.2.val‖
  3201. rw [rotate_norm, rotate_norm, hxy]
  3202. · exact hs a b hxy
  3203. theorem small_rotated_copies {I : Type*} [Fintype I] (Q : Finset ℂ)
  3204. (hzero : 0 ∉ Q) (hQ : RadialSupport Q) (O : Set ℂ) (hO : IsOpen O)
  3205. (hQO : (Q : Set ℂ) ⊆ O) (A : I → Finset ℂ) (hA : ∀ i, A i ⊆ Q)
  3206. (τ : ℝ) (hτ : 0 < τ) :
  3207. ∃ θ : I → ℝ,
  3208. (∀ i, |θ i| < τ) ∧
  3209. Pairwise (fun i j => Disjoint ((A i).image (rotate (θ i))) ((A j).image (rotate (θ j)))) ∧
  3210. RadialSupport (rotatedUnion A θ) ∧
  3211. (rotatedUnion A θ : Set ℂ) ⊆ O ∧ 0 ∉ rotatedUnion A θ := by
  3212. obtain ⟨θ, ht, hinj, hs, hl⟩ := small_rotations (I := I) Q hzero hQ O hO hQO τ hτ
  3213. refine ⟨θ, ht, ?_, ?_, ?_, ?_⟩
  3214. · intro i j hij
  3215. apply Finset.disjoint_left.mpr
  3216. intro z hi hj
  3217. obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hi
  3218. obtain ⟨y, hy, he⟩ := Finset.mem_image.mp hj
  3219. have hh := hinj (a₁ := (j, ⟨y, hA j hy⟩)) (a₂ := (i, ⟨x, hA i hx⟩)) he
  3220. exact hij (congrArg Prod.fst hh).symm
  3221. · intro x hx y hy hxy
  3222. obtain ⟨i, _, hx⟩ := Finset.mem_biUnion.mp hx
  3223. obtain ⟨j, _, hy⟩ := Finset.mem_biUnion.mp hy
  3224. obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hx
  3225. obtain ⟨b, hb, rfl⟩ := Finset.mem_image.mp hy
  3226. apply hs (i, ⟨a, hA i ha⟩) (j, ⟨b, hA j hb⟩)
  3227. exact fun h => hxy (congrArg (fun a : I × Q => rotate (θ a.1) a.2.val) h)
  3228. · intro x hx
  3229. obtain ⟨i, _, hx⟩ := Finset.mem_biUnion.mp hx
  3230. obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hx
  3231. exact hl (i, ⟨a, hA i ha⟩)
  3232. · intro hz
  3233. obtain ⟨i, _, hz⟩ := Finset.mem_biUnion.mp hz
  3234. obtain ⟨a, ha, he⟩ := Finset.mem_image.mp hz
  3235. exact rotate_ne_zero (θ i) (fun h => hzero (h ▸ hA i ha)) he
  3236. end
  3237. end Proof
  3238. end Combined_RotatedCopies
  3239. /-! ## Source: Gluing.lean -/
  3240. section Combined_Gluing
  3241. /-! Counting and minimum-degree bounds for unions of disjoint rotated copies. -/
  3242. namespace Proof
  3243. noncomputable section
  3244. open Classical
  3245. theorem rotatedUnion_card {I : Type*} [Fintype I] (A : I → Finset ℂ) (θ : I → ℝ)
  3246. (hd : Pairwise (fun i j => Disjoint ((A i).image (rotate (θ i))) ((A j).image (rotate (θ j))))) :
  3247. (rotatedUnion A θ).card = ∑ i, (A i).card := by
  3248. rw [rotatedUnion, Finset.card_biUnion (fun i _ j _ hij => hd hij)]
  3249. apply Finset.sum_congr rfl
  3250. intro i _
  3251. exact Finset.card_image_of_injective _ (rotate_isometry (θ i)).injective
  3252. theorem rotatedUnion_edges {I : Type*} [Fintype I] (A : I → Finset ℂ) (θ : I → ℝ)
  3253. (hd : Pairwise (fun i j => Disjoint ((A i).image (rotate (θ i))) ((A j).image (rotate (θ j))))) :
  3254. ∑ i, (unitPairs (A i)).card ≤ (unitPairs (rotatedUnion A θ)).card := by
  3255. let U := fun i => unitPairs ((A i).image (rotate (θ i)))
  3256. have hdu : ((Finset.univ : Finset I) : Set I).PairwiseDisjoint U :=
  3257. fun i _ j _ hij => unitPairs_disjoint (hd hij)
  3258. have hsub : Finset.univ.biUnion U ⊆ unitPairs (rotatedUnion A θ) := by
  3259. intro e he
  3260. obtain ⟨i, hi, he⟩ := Finset.mem_biUnion.mp he
  3261. exact unitPairs_mono (Finset.subset_biUnion_of_mem
  3262. (fun i => (A i).image (rotate (θ i))) hi) he
  3263. have hc := Finset.card_le_card hsub
  3264. rw [Finset.card_biUnion hdu] at hc
  3265. simpa only [U, unitPairs_card_image_isometry _ (rotate_isometry _)] using hc
  3266. theorem rotatedUnion_degree {I : Type*} [Fintype I] (A : I → Finset ℂ) (θ : I → ℝ)
  3267. (k : ℕ) (hk : ∀ i, HasUnitMinDegree (A i) k) : HasUnitMinDegree (rotatedUnion A θ) k := by
  3268. intro x hx
  3269. obtain ⟨i, hi, hx⟩ := Finset.mem_biUnion.mp hx
  3270. obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hx
  3271. have hm := unitDegree_mono (Finset.subset_biUnion_of_mem
  3272. (fun i => (A i).image (rotate (θ i))) hi) (rotate (θ i) a)
  3273. rw [unitDegree_image_isometry _ (rotate_isometry _)] at hm
  3274. exact (hk i a ha).trans hm
  3275. theorem glue_dense_copies {I : Type*} [Fintype I] (Q : Finset ℂ)
  3276. (hzero : 0 ∉ Q) (hQ : RadialSupport Q) (η : ℝ)
  3277. (hloc : (Q : Set ℂ) ⊆ twoDisks η) (A : I → Finset ℂ) (hA : ∀ i, A i ⊆ Q)
  3278. (k : ℕ) (hk : ∀ i, HasUnitMinDegree (A i) k)
  3279. (α : ℝ) (hα : ∀ i, α * (A i).card ≤ (unitPairs (A i)).card) :
  3280. ∃ P : Finset ℂ, P.card = ∑ i, (A i).card ∧ RadialSupport P ∧
  3281. 0 ∉ P ∧ (P : Set ℂ) ⊆ twoDisks η ∧ HasUnitMinDegree P k ∧
  3282. α * P.card ≤ (unitPairs P).card := by
  3283. obtain ⟨θ, _, hd, hs, hl, hn⟩ := small_rotated_copies Q hzero hQ (twoDisks η)
  3284. (twoDisks_open η) hloc A hA 1 (by norm_num)
  3285. refine ⟨rotatedUnion A θ, rotatedUnion_card A θ hd, hs, hn, hl,
  3286. rotatedUnion_degree A θ k hk, ?_⟩
  3287. have he : (∑ i, ((unitPairs (A i)).card : ℝ)) ≤ (unitPairs (rotatedUnion A θ)).card := by
  3288. exact_mod_cast rotatedUnion_edges A θ hd
  3289. rw [rotatedUnion_card A θ hd, Nat.cast_sum, Finset.mul_sum]
  3290. exact (Finset.sum_le_sum (fun i _ => hα i)).trans he
  3291. /-- Every sufficiently large integer is a nonnegative combination of two consecutive sizes. -/
  3292. theorem consecutive_sizes_representation (s n : ℕ) (hs : 2 ≤ s) (hn : s ^ 2 ≤ n) :
  3293. ∃ a b : ℕ, n = a * s + b * (s - 1) := by
  3294. let r := n % (s - 1)
  3295. let t := n / (s - 1)
  3296. have hs' : 0 < s - 1 := by omega
  3297. have hr : r < s - 1 := Nat.mod_lt n hs'
  3298. have ht : s ≤ t := (Nat.le_div_iff_mul_le hs').mpr
  3299. ((Nat.mul_le_mul_left s (Nat.sub_le s 1)).trans (by simpa [pow_two] using hn))
  3300. have hrt : r ≤ t := by omega
  3301. refine ⟨r, t - r, ?_⟩
  3302. have he : r + (s - 1) * t = n := Nat.mod_add_div n (s - 1)
  3303. have hs1 : s - 1 + 1 = s := by omega
  3304. calc
  3305. n = r + (s - 1) * t := he.symm
  3306. _ = r + (s - 1) * ((t - r) + r) := by rw [Nat.sub_add_cancel hrt]
  3307. _ = r * (s - 1 + 1) + (t - r) * (s - 1) := by ring
  3308. _ = r * s + (t - r) * (s - 1) := by rw [hs1]
  3309. end
  3310. end Proof
  3311. end Combined_Gluing
  3312. /-! ## Source: PrescribedCardinality.lean -/
  3313. section Combined_PrescribedCardinality
  3314. /-! Dense configurations of every sufficiently large prescribed cardinality (Proposition 4.3). -/
  3315. namespace Proof
  3316. noncomputable section
  3317. open Classical
  3318. theorem erase_low_degree_density (Q : Finset ℂ) (hQ : Q.Nonempty) (k : ℕ)
  3319. (α : ℝ) (hα : (k : ℝ) < α) (hd : HasUnitMinDegree Q (k + 1))
  3320. (hc : α * Q.card ≤ (unitPairs Q).card) :
  3321. ∃ v ∈ Q, HasUnitMinDegree (Q.erase v) k ∧
  3322. ((k : ℝ) - 1) * (Q.erase v).card ≤ (unitPairs (Q.erase v)).card := by
  3323. obtain ⟨v, hv, havg⟩ := exists_degree_le_average Q hQ
  3324. have hsize : k + 2 ≤ Q.card := by
  3325. have hlo := hd v hv
  3326. have hhi := unitDegree_lt_card hv
  3327. omega
  3328. have hsizeR : (k : ℝ) + 2 ≤ Q.card := by exact_mod_cast hsize
  3329. have hspos : (0 : ℝ) < Q.card := by exact_mod_cast Finset.card_pos.mpr hQ
  3330. have hs2 : (0 : ℝ) ≤ (Q.card : ℝ) - 2 := by linarith [show (0 : ℝ) ≤ k from Nat.cast_nonneg k]
  3331. have hcard : ((Q.erase v).card : ℝ) = (Q.card : ℝ) - 1 := by
  3332. have hh : ((Q.erase v).card : ℝ) + 1 = Q.card := by
  3333. exact_mod_cast Finset.card_erase_add_one hv
  3334. linarith
  3335. have he : ((unitPairs (Q.erase v)).card : ℝ) + unitDegree Q v = (unitPairs Q).card := by
  3336. exact_mod_cast unitPairs_erase_add_degree hv
  3337. have heMul := congrArg (fun x : ℝ => x * (Q.card : ℝ)) he
  3338. have hm := mul_le_mul_of_nonneg_right hc hs2
  3339. have hremaining : α * Q.card * ((Q.card : ℝ) - 2) ≤
  3340. (unitPairs (Q.erase v)).card * (Q.card : ℝ) := by nlinarith
  3341. have hcoeff : ((k : ℝ) - 1) * (Q.erase v).card ≤ α * ((Q.card : ℝ) - 2) := by
  3342. calc
  3343. ((k : ℝ) - 1) * (Q.erase v).card =
  3344. (k : ℝ) * ((Q.card : ℝ) - 2) - ((Q.card : ℝ) - k - 1) := by rw [hcard]; ring
  3345. _ ≤ (k : ℝ) * ((Q.card : ℝ) - 2) := by linarith
  3346. _ ≤ α * ((Q.card : ℝ) - 2) := mul_le_mul_of_nonneg_right hα.le hs2
  3347. refine ⟨v, hv, ?_, ?_⟩
  3348. · intro x hx
  3349. have hdx := hd x (Finset.mem_of_mem_erase hx)
  3350. have her := unitDegree_erase_le Q x v
  3351. omega
  3352. · apply (mul_le_mul_iff_left₀ hspos).mp
  3353. nlinarith [mul_le_mul_of_nonneg_right hcoeff hspos.le]
  3354. def thresholdSize (k : ℕ) : ℕ := finiteSize (2 * k + 1) (2 * k + 2)
  3355. theorem thresholdSize_pos (k : ℕ) : 0 < thresholdSize k := finiteSize_pos (by omega)
  3356. theorem threshold_configuration (k : ℕ) (hk : 1 ≤ k) (n : ℕ)
  3357. (hn : thresholdSize k ^ 2 ≤ n) (η : ℝ) (hη : 0 < η) :
  3358. ∃ P : Finset ℂ, P.card = n ∧ RadialSupport P ∧ 0 ∉ P ∧
  3359. (P : Set ℂ) ⊆ twoDisks η ∧ HasUnitMinDegree P k ∧
  3360. ((k : ℝ) - 1) * n ≤ (unitPairs P).card := by
  3361. let α : ℝ := (k : ℝ) + 1 / (4 * (k : ℝ) + 4)
  3362. have hα : (k : ℝ) < α := by
  3363. have hh : (0 : ℝ) < 1 / (4 * (k : ℝ) + 4) := by positivity
  3364. dsimp [α]
  3365. linarith
  3366. obtain ⟨P, hPcard, hPcount, hP, hzero, hloc⟩ :=
  3367. finite_construction_real (2 * k + 1) (2 * k + 2) (by omega) (by omega) η hη
  3368. have hratio : ((2 * k + 1 : ℕ) : ℝ) / 2 * (1 - 1 / ((2 * k + 2 : ℕ) : ℝ)) = α := by
  3369. dsimp [α]
  3370. push_cast
  3371. field_simp
  3372. ring
  3373. rw [hratio] at hPcount
  3374. have hPne : P.Nonempty := Finset.card_pos.mp (by rw [hPcard]; exact finiteSize_pos (by omega))
  3375. obtain ⟨Q, hQP, hQ, hdegree, hcount⟩ := dense_subset_min_degree α k hα P hPne hPcount
  3376. obtain ⟨v, hv, hminusDegree, hminusCount⟩ := erase_low_degree_density Q hQ k α hα hdegree hcount
  3377. have hs : 2 ≤ Q.card := by
  3378. have h1 := hdegree v hv
  3379. have h2 := unitDegree_lt_card hv
  3380. omega
  3381. have hQM : Q.card ≤ thresholdSize k := by
  3382. exact (Finset.card_le_card hQP).trans_eq hPcard
  3383. have hnQ : Q.card ^ 2 ≤ n := (Nat.pow_le_pow_left hQM 2).trans hn
  3384. obtain ⟨a, b, hab⟩ := consecutive_sizes_representation Q.card n hs hnQ
  3385. let A : Fin a ⊕ Fin b → Finset ℂ := Sum.elim (fun _ => Q) (fun _ => Q.erase v)
  3386. have hA : ∀ i, A i ⊆ Q := by
  3387. intro i
  3388. cases i
  3389. · exact Finset.Subset.refl Q
  3390. · exact Finset.erase_subset _ _
  3391. have hdA : ∀ i, HasUnitMinDegree (A i) k := by
  3392. intro i
  3393. cases i
  3394. · exact fun x hx => (Nat.le_succ k).trans (hdegree x hx)
  3395. · exact hminusDegree
  3396. have hcA : ∀ i, ((k : ℝ) - 1) * (A i).card ≤ (unitPairs (A i)).card := by
  3397. intro i
  3398. cases i
  3399. · exact (mul_le_mul_of_nonneg_right (by linarith : (k : ℝ) - 1 ≤ α)
  3400. (Nat.cast_nonneg Q.card)).trans hcount
  3401. · exact hminusCount
  3402. obtain ⟨R, hRc, hRs, hRz, hRl, hRd, hRe⟩ := glue_dense_copies Q
  3403. (fun h => hzero (hQP h)) (hP.mono hQP) η (fun _ hx => hloc (hQP hx)) A hA k hdA
  3404. ((k : ℝ) - 1) hcA
  3405. have hsum : ∑ i, (A i).card = n := by
  3406. simpa [A, Fintype.sum_sum_type, Finset.card_erase_of_mem hv] using hab.symm
  3407. refine ⟨R, hRc.trans hsum, hRs, hRz, hRl, hRd, ?_⟩
  3408. rwa [hRc, hsum] at hRe
  3409. end
  3410. end Proof
  3411. end Combined_PrescribedCardinality
  3412. /-! ## Source: CardinalEstimates.lean -/
  3413. section Combined_CardinalEstimates
  3414. /-! Explicit cardinality estimates used to invert the construction thresholds. -/
  3415. namespace Proof
  3416. noncomputable section
  3417. def logTwo (x : ℝ) : ℝ := Real.logb 2 x
  3418. def doubleLog (x : ℝ) : ℝ := logTwo (logTwo x)
  3419. def tripleLog (x : ℝ) : ℝ := logTwo (doubleLog x)
  3420. theorem logTwo_mono {x y : ℝ} (hx : 0 < x) (hxy : x ≤ y) : logTwo x ≤ logTwo y :=
  3421. Real.logb_le_logb_of_le (by norm_num) hx hxy
  3422. theorem logTwo_le_logTwo {x y : ℝ} (hx : 0 < x) (hy : 0 < y) :
  3423. logTwo x ≤ logTwo y ↔ x ≤ y := Real.logb_le_logb (by norm_num) hx hy
  3424. theorem logTwo_pos {x : ℝ} (hx : 1 < x) : 0 < logTwo x := Real.logb_pos (by norm_num) hx
  3425. @[simp] theorem logTwo_two : logTwo 2 = 1 := Real.logb_self_eq_one (by norm_num)
  3426. @[simp] theorem logTwo_four : logTwo 4 = 2 := by
  3427. unfold logTwo
  3428. rw [show (4 : ℝ) = 2 ^ 2 by norm_num, Real.logb_pow, Real.logb_self_eq_one (by norm_num)]
  3429. norm_num
  3430. theorem middleVertexCount_le_four_pow (d : ℕ) : middleVertexCount d ≤ 4 ^ d := by
  3431. have h := Nat.choose_le_two_pow (2 * d) d
  3432. simpa only [middleVertexCount, pow_mul, show (2 : ℕ) ^ 2 = 4 from rfl] using h
  3433. theorem middleEdgeCount_le (d : ℕ) : middleEdgeCount d ≤ d * 4 ^ d := by
  3434. apply Nat.mul_le_mul_left
  3435. calc
  3436. (2 * d - 1).choose d ≤ 2 ^ (2 * d - 1) := Nat.choose_le_two_pow _ _
  3437. _ ≤ 2 ^ (2 * d) := Nat.pow_le_pow_right (by norm_num) (Nat.sub_le _ _)
  3438. _ = 4 ^ d := by rw [pow_mul]; rfl
  3439. theorem finiteSize_square_bound (d : ℕ) :
  3440. finiteSize d (d + 1) ^ 2 ≤ 2 ^ (4 * (d + 1) ^ 2 * 4 ^ d) := by
  3441. have hq : d + 1 ≤ 2 ^ (d + 1) := Nat.lt_two_pow_self.le
  3442. have hN : finiteSize d (d + 1) ≤ 2 ^ (2 * d + (d + 1) * middleEdgeCount d) := by
  3443. calc
  3444. finiteSize d (d + 1) ≤ 4 ^ d * (2 ^ (d + 1)) ^ middleEdgeCount d :=
  3445. Nat.mul_le_mul (middleVertexCount_le_four_pow d) (Nat.pow_le_pow_left hq _)
  3446. _ = 2 ^ (2 * d + (d + 1) * middleEdgeCount d) := by
  3447. rw [show (4 : ℕ) ^ d = 2 ^ (2 * d) by rw [pow_mul]; rfl, ← pow_mul, ← pow_add]
  3448. have hR : 1 ≤ 4 ^ d := Nat.one_le_pow d 4 (by norm_num)
  3449. have hE : 2 * (2 * d + (d + 1) * middleEdgeCount d) ≤ 4 * (d + 1) ^ 2 * 4 ^ d := by
  3450. calc
  3451. 2 * (2 * d + (d + 1) * middleEdgeCount d) ≤
  3452. 2 * (2 * d + (d + 1) * (d * 4 ^ d)) := by gcongr; exact middleEdgeCount_le d
  3453. _ ≤ 2 * ((2 * d) * 4 ^ d + (d + 1) * (d * 4 ^ d)) := by
  3454. apply Nat.mul_le_mul_left
  3455. apply Nat.add_le_add_right
  3456. simpa only [mul_one] using Nat.mul_le_mul_left (2 * d) hR
  3457. _ = (2 * (2 * d + (d + 1) * d)) * 4 ^ d := by ring
  3458. _ ≤ (4 * (d + 1) ^ 2) * 4 ^ d := Nat.mul_le_mul_right _ (by nlinarith)
  3459. calc
  3460. finiteSize d (d + 1) ^ 2 ≤ (2 ^ (2 * d + (d + 1) * middleEdgeCount d)) ^ 2 :=
  3461. Nat.pow_le_pow_left hN _
  3462. _ = 2 ^ (2 * (2 * d + (d + 1) * middleEdgeCount d)) := by
  3463. rw [← pow_mul, Nat.mul_comm (2 * d + (d + 1) * middleEdgeCount d) 2]
  3464. _ ≤ _ := Nat.pow_le_pow_right (by norm_num) hE
  3465. theorem finiteSize_ge_two {d q : ℕ} (hd : 1 ≤ d) (hq : 1 ≤ q) : 2 ≤ finiteSize d q := by
  3466. have hv : 2 ≤ middleVertexCount d := by
  3467. rw [middleVertexCount_eq_twice hd]
  3468. have h := Nat.choose_pos (show d ≤ 2 * d - 1 by omega)
  3469. omega
  3470. have hp : 1 ≤ q ^ middleEdgeCount d := Nat.one_le_pow _ _ hq
  3471. exact hv.trans (by simpa [finiteSize] using Nat.mul_le_mul_left (middleVertexCount d) hp)
  3472. theorem finiteSize_doubleLog_bound (d : ℕ) (hd : 1 ≤ d) :
  3473. doubleLog ((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ) ≤
  3474. 2 * (d : ℝ) + 2 * logTwo ((d : ℝ) + 1) + 2 := by
  3475. let E := 4 * (d + 1) ^ 2 * 4 ^ d
  3476. have hsize := finiteSize_ge_two hd (show 1 ≤ d + 1 by omega)
  3477. have hN : (1 : ℝ) < ((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ) := by
  3478. exact_mod_cast (by nlinarith : 1 < finiteSize d (d + 1) ^ 2)
  3479. have hbound : (((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ)) ≤ (2 : ℝ) ^ E := by
  3480. exact_mod_cast finiteSize_square_bound d
  3481. have hlog : logTwo ((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ) ≤ (E : ℝ) := by
  3482. have h := logTwo_mono (by linarith : (0 : ℝ) < ((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ)) hbound
  3483. simpa only [logTwo, Real.logb_pow, Real.logb_self_eq_one (by norm_num : (1 : ℝ) < 2), mul_one] using h
  3484. have hloglog := logTwo_mono (logTwo_pos hN) hlog
  3485. have hE : logTwo (E : ℝ) = 2 * (d : ℝ) + 2 * logTwo ((d : ℝ) + 1) + 2 := by
  3486. simp only [E, Nat.cast_mul, Nat.cast_pow, Nat.cast_add, Nat.cast_one, Nat.cast_ofNat, logTwo]
  3487. rw [Real.logb_mul (by positivity) (by positivity),
  3488. Real.logb_mul (by positivity) (by positivity), Real.logb_pow, Real.logb_pow]
  3489. change logTwo 4 + 2 * logTwo ((d : ℝ) + 1) + (d : ℝ) * logTwo 4 = _
  3490. rw [logTwo_four]
  3491. change 2 + 2 * logTwo ((d : ℝ) + 1) + (d : ℝ) * 2 =
  3492. 2 * (d : ℝ) + 2 * logTwo ((d : ℝ) + 1) + 2
  3493. ring
  3494. exact hloglog.trans_eq hE
  3495. end
  3496. end Proof
  3497. end Combined_CardinalEstimates
  3498. /-! ## Source: AnalyticThresholds.lean -/
  3499. section Combined_AnalyticThresholds
  3500. /-! Inversion of the size thresholds with an explicit absolute error constant. -/
  3501. namespace Proof
  3502. noncomputable section
  3503. open Filter
  3504. theorem tendsto_logTwo_atTop : Tendsto logTwo atTop atTop :=
  3505. Real.tendsto_logb_atTop (by norm_num)
  3506. theorem tendsto_doubleLog_nat : Tendsto (fun n : ℕ => doubleLog (n : ℝ)) atTop atTop :=
  3507. (tendsto_logTwo_atTop.comp tendsto_logTwo_atTop).comp tendsto_natCast_atTop_atTop
  3508. theorem logTwo_sublinear (c : ℝ) (hc : 0 < c) :
  3509. ∀ᶠ x : ℝ in atTop, logTwo x ≤ c * x := by
  3510. have hl : 0 < Real.log 2 := Real.log_pos (by norm_num)
  3511. have h := Real.isLittleO_log_id_atTop.def (mul_pos hc hl)
  3512. filter_upwards [h, eventually_ge_atTop (0 : ℝ)] with x hx hx0
  3513. change ‖Real.log x‖ ≤ c * Real.log 2 * ‖x‖ at hx
  3514. rw [Real.norm_eq_abs, Real.norm_eq_abs, abs_of_nonneg hx0] at hx
  3515. change Real.log x / Real.log 2 ≤ c * x
  3516. apply (div_le_iff₀ hl).mpr
  3517. nlinarith [le_abs_self (Real.log x)]
  3518. theorem threshold_doubleLog_bound (k : ℕ) :
  3519. doubleLog ((thresholdSize k ^ 2 : ℕ) : ℝ) ≤
  3520. 4 * (k : ℝ) + 2 * logTwo ((k : ℝ) + 1) + 6 := by
  3521. have h := finiteSize_doubleLog_bound (2 * k + 1) (by omega)
  3522. have he : logTwo ((2 * k + 1 : ℕ) + 1 : ℝ) = 1 + logTwo ((k : ℝ) + 1) := by
  3523. push_cast
  3524. rw [show 2 * (k : ℝ) + 1 + 1 = 2 * ((k : ℝ) + 1) by ring]
  3525. change Real.logb 2 (2 * ((k : ℝ) + 1)) = _
  3526. rw [Real.logb_mul (by norm_num) (by positivity)]
  3527. change logTwo 2 + logTwo ((k : ℝ) + 1) = _
  3528. rw [logTwo_two]
  3529. change doubleLog ((thresholdSize k ^ 2 : ℕ) : ℝ) ≤ _ at h
  3530. rw [he] at h
  3531. push_cast at h ⊢
  3532. linarith
  3533. theorem doubleLog_le_iff {x y : ℝ} (hx : 1 < x) (hy : 1 < y) :
  3534. doubleLog x ≤ doubleLog y ↔ x ≤ y := by
  3535. unfold doubleLog
  3536. rw [logTwo_le_logTwo (logTwo_pos hx) (logTwo_pos hy),
  3537. logTwo_le_logTwo (by linarith) (by linarith)]
  3538. theorem logarithmic_index : ∃ n₀ : ℕ, ∀ n ≥ n₀, ∃ k : ℕ,
  3539. 1 ≤ k ∧ thresholdSize k ^ 2 ≤ n ∧
  3540. doubleLog (n : ℝ) / 4 - 7 * tripleLog (n : ℝ) ≤ (k : ℝ) - 1 := by
  3541. have hreal : ∀ᶠ L : ℝ in atTop,
  3542. 40 ≤ L ∧ 1 ≤ logTwo L ∧ logTwo L ≤ L / 8 := by
  3543. filter_upwards [eventually_ge_atTop (40 : ℝ),
  3544. tendsto_logTwo_atTop.eventually (eventually_ge_atTop (1 : ℝ)),
  3545. logTwo_sublinear (1 / 8) (by norm_num)] with L hL hlog hsmall
  3546. exact ⟨hL, hlog, by linarith⟩
  3547. have hnat := tendsto_doubleLog_nat.eventually hreal
  3548. have hall : ∀ᶠ n : ℕ in atTop, 2 ≤ n ∧
  3549. 40 ≤ doubleLog (n : ℝ) ∧ 1 ≤ logTwo (doubleLog (n : ℝ)) ∧
  3550. logTwo (doubleLog (n : ℝ)) ≤ doubleLog (n : ℝ) / 8 :=
  3551. (eventually_ge_atTop 2).and hnat
  3552. obtain ⟨n₀, hn₀⟩ := eventually_atTop.mp hall
  3553. refine ⟨n₀, ?_⟩
  3554. intro n hn
  3555. obtain ⟨hn2, hL, hlog, hsmall⟩ := hn₀ n hn
  3556. let L := doubleLog (n : ℝ)
  3557. let x := L / 4 - logTwo L - 4
  3558. let k := Nat.floor x
  3559. have hx : 1 ≤ x := by dsimp [x, L]; linarith
  3560. have hk : 1 ≤ k := Nat.le_floor (by simpa using hx)
  3561. have hklo : x < (k : ℝ) + 1 := Nat.lt_floor_add_one x
  3562. have hkhi : (k : ℝ) ≤ x := Nat.floor_le (by linarith)
  3563. have hkl : (k : ℝ) + 1 ≤ L := by dsimp [x] at hkhi; dsimp [L]; linarith
  3564. have hlogk : logTwo ((k : ℝ) + 1) ≤ logTwo L := logTwo_mono (by positivity) hkl
  3565. have hT : doubleLog ((thresholdSize k ^ 2 : ℕ) : ℝ) ≤ L := by
  3566. have ht := threshold_doubleLog_bound k
  3567. dsimp [x] at hkhi
  3568. dsimp [L] at *
  3569. linarith
  3570. have hs : 2 ≤ thresholdSize k := finiteSize_ge_two (by omega) (by omega)
  3571. have hsR : (1 : ℝ) < ((thresholdSize k ^ 2 : ℕ) : ℝ) := by
  3572. exact_mod_cast (by nlinarith : 1 < thresholdSize k ^ 2)
  3573. have hnR : (1 : ℝ) < n := by exact_mod_cast (by omega : 1 < n)
  3574. have hthreshold : thresholdSize k ^ 2 ≤ n := by
  3575. exact_mod_cast (doubleLog_le_iff hsR hnR).mp hT
  3576. refine ⟨k, hk, hthreshold, ?_⟩
  3577. change L / 4 - 7 * logTwo L ≤ (k : ℝ) - 1
  3578. dsimp [x] at hklo
  3579. dsimp [L] at *
  3580. linarith
  3581. end
  3582. end Proof
  3583. end Combined_AnalyticThresholds
  3584. /-! ## Source: PlaneGeometry.lean -/
  3585. section Combined_PlaneGeometry
  3586. /-! Literal Euclidean-plane statements, and bipartiteness of the full unit-distance graph. -/
  3587. namespace Proof
  3588. noncomputable section
  3589. open Classical EuclideanGeometry
  3590. open scoped EuclideanGeometry
  3591. def planeLowerCenter : ℝ² := complexToPlane lowerCenter
  3592. def planeUpperCenter : ℝ² := complexToPlane upperCenter
  3593. def planeTwoDisks (η : ℝ) : Set ℝ² :=
  3594. Metric.ball planeLowerCenter η ∪ Metric.ball planeUpperCenter η
  3595. @[simp] theorem planeLowerCenter_first : planeLowerCenter 0 = 0 := rfl
  3596. @[simp] theorem planeLowerCenter_second : planeLowerCenter 1 = -1 / 2 := rfl
  3597. @[simp] theorem planeUpperCenter_first : planeUpperCenter 0 = 0 := rfl
  3598. @[simp] theorem planeUpperCenter_second : planeUpperCenter 1 = 1 / 2 := rfl
  3599. @[simp] theorem complexToPlane_second (z : ℂ) : complexToPlane z 1 = z.im := rfl
  3600. def PlaneRadialSupport (P : Finset ℝ²) : Prop :=
  3601. ∀ x ∈ P, ∀ y ∈ P, x ≠ y → inner ℝ x (y - x) < 0
  3602. def minimumUnitDegree {X : Type*} [MetricSpace X] (P : Finset X) : ℕ :=
  3603. (unitDistanceGraph P).minDegree
  3604. theorem le_minimumUnitDegree {X : Type*} [MetricSpace X] (P : Finset X)
  3605. (hP : P.Nonempty) (k : ℕ) (hk : HasUnitMinDegree P k) : k ≤ minimumUnitDegree P := by
  3606. letI : Nonempty P := ⟨⟨hP.choose, hP.choose_spec⟩⟩
  3607. apply SimpleGraph.le_minDegree_of_forall_le_degree
  3608. intro x
  3609. rw [unitDistanceGraph_degree]
  3610. exact hk x x.property
  3611. theorem radialSupport_image {P : Finset ℂ} (hP : RadialSupport P) :
  3612. PlaneRadialSupport (P.image complexToPlane) := by
  3613. intro x hx y hy hxy
  3614. obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hx
  3615. obtain ⟨b, hb, rfl⟩ := Finset.mem_image.mp hy
  3616. rw [← map_sub, complexToPlane.inner_map_map, ← support_eq_inner]
  3617. exact hP a ha b hb (fun h => hxy (congrArg complexToPlane h))
  3618. theorem twoDisks_image {P : Finset ℂ} {η : ℝ} (hP : (P : Set ℂ) ⊆ twoDisks η) :
  3619. ((P.image complexToPlane : Finset ℝ²) : Set ℝ²) ⊆ planeTwoDisks η := by
  3620. intro x hx
  3621. obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hx
  3622. have h := hP ha
  3623. simpa only [twoDisks, planeTwoDisks, planeLowerCenter, planeUpperCenter,
  3624. Set.mem_union, Metric.mem_ball, complexToPlane.isometry.dist_eq] using h
  3625. theorem unitMinDegree_image {P : Finset ℂ} {k : ℕ} (hP : HasUnitMinDegree P k) :
  3626. HasUnitMinDegree (P.image complexToPlane) k := by
  3627. intro x hx
  3628. obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hx
  3629. have he : (unitNeighbors P a).image complexToPlane ⊆
  3630. unitNeighbors (P.image complexToPlane) (complexToPlane a) := by
  3631. intro z hz
  3632. obtain ⟨b, hb, rfl⟩ := Finset.mem_image.mp hz
  3633. obtain ⟨hbP, hbd⟩ := mem_unitNeighbors.mp hb
  3634. exact mem_unitNeighbors.mpr ⟨Finset.mem_image_of_mem _ hbP,
  3635. (complexToPlane.isometry.dist_eq a b).trans hbd⟩
  3636. have hc := Finset.card_le_card he
  3637. rw [Finset.card_image_of_injective _ complexToPlane.injective] at hc
  3638. exact (hP a ha).trans hc
  3639. theorem im_neg_of_lower_ball {z : ℂ} {η : ℝ} (hη : η < 1 / 2)
  3640. (hz : z ∈ Metric.ball lowerCenter η) : z.im < 0 := by
  3641. have hnorm : ‖z - lowerCenter‖ < η := by simpa only [Metric.mem_ball, dist_eq_norm] using hz
  3642. have hi := Complex.im_le_norm (z - lowerCenter)
  3643. simp only [Complex.sub_im, lowerCenter] at hi hnorm
  3644. linarith
  3645. theorem im_pos_of_upper_ball {z : ℂ} {η : ℝ} (hη : η < 1 / 2)
  3646. (hz : z ∈ Metric.ball upperCenter η) : 0 < z.im := by
  3647. have hnorm : ‖z - upperCenter‖ < η := by simpa only [Metric.mem_ball, dist_eq_norm] using hz
  3648. have hi := (abs_le.mp (Complex.abs_im_le_norm (z - upperCenter))).1
  3649. simp only [Complex.sub_im, upperCenter] at hi hnorm
  3650. linarith
  3651. theorem second_neg_of_lower_ball {x : ℝ²} {η : ℝ} (hη : η < 1 / 2)
  3652. (hx : x ∈ Metric.ball planeLowerCenter η) : x 1 < 0 := by
  3653. obtain ⟨z, rfl⟩ := complexToPlane.surjective x
  3654. apply im_neg_of_lower_ball hη
  3655. simpa only [planeLowerCenter, Metric.mem_ball, complexToPlane.isometry.dist_eq] using hx
  3656. theorem second_pos_of_upper_ball {x : ℝ²} {η : ℝ} (hη : η < 1 / 2)
  3657. (hx : x ∈ Metric.ball planeUpperCenter η) : 0 < x 1 := by
  3658. obtain ⟨z, rfl⟩ := complexToPlane.surjective x
  3659. apply im_pos_of_upper_ball hη
  3660. simpa only [planeUpperCenter, Metric.mem_ball, complexToPlane.isometry.dist_eq] using hx
  3661. theorem no_unit_pair_in_ball {X : Type*} [MetricSpace X] {x y c : X} {η : ℝ}
  3662. (hη : η < 1 / 2) (hx : x ∈ Metric.ball c η) (hy : y ∈ Metric.ball c η) :
  3663. dist x y ≠ 1 := by
  3664. have ht := dist_triangle x c y
  3665. have hx' := Metric.mem_ball.mp hx
  3666. have hy' := Metric.mem_ball.mp hy
  3667. rw [dist_comm c y] at ht
  3668. linarith
  3669. def HorizontalBipartition (P : Finset ℝ²) : Prop :=
  3670. (unitDistanceGraph P).IsBipartiteWith {x | x.val 1 < 0} {x | 0 < x.val 1} ∧
  3671. ∀ x ∈ P, x 1 < 0 ∨ 0 < x 1
  3672. theorem twoDisks_horizontalBipartition {P : Finset ℝ²} {η : ℝ} (hη : η < 1 / 2)
  3673. (hP : (P : Set ℝ²) ⊆ planeTwoDisks η) : HorizontalBipartition P := by
  3674. have hc : ∀ x ∈ P, x 1 < 0 ∨ 0 < x 1 := by
  3675. intro x hx
  3676. rcases hP hx with h | h
  3677. · exact Or.inl (second_neg_of_lower_ball hη h)
  3678. · exact Or.inr (second_pos_of_upper_ball hη h)
  3679. refine ⟨⟨?_, ?_⟩, hc⟩
  3680. · apply Set.disjoint_left.mpr
  3681. intro x hx hy
  3682. change x.val 1 < 0 at hx
  3683. change 0 < x.val 1 at hy
  3684. exact lt_asymm hx hy
  3685. · intro x y hxy
  3686. change dist x.val y.val = 1 at hxy
  3687. rcases hP x.property with hx | hx <;> rcases hP y.property with hy | hy
  3688. · exact False.elim (no_unit_pair_in_ball hη hx hy hxy)
  3689. · exact Or.inl ⟨second_neg_of_lower_ball hη hx, second_pos_of_upper_ball hη hy⟩
  3690. · exact Or.inr ⟨second_pos_of_upper_ball hη hx, second_neg_of_lower_ball hη hy⟩
  3691. · exact False.elim (no_unit_pair_in_ball hη hx hy hxy)
  3692. theorem HorizontalBipartition.isBipartite {P : Finset ℝ²} (hP : HorizontalBipartition P) :
  3693. (unitDistanceGraph P).IsBipartite := hP.1.isBipartite
  3694. end
  3695. end Proof
  3696. end Combined_PlaneGeometry
  3697. /-! ## Source: MainTheorem.lean -/
  3698. section Combined_MainTheorem
  3699. /-! The quantitative theorem in the literal Euclidean plane. -/
  3700. namespace Proof
  3701. noncomputable section
  3702. open Classical EuclideanGeometry
  3703. open scoped EuclideanGeometry
  3704. /-- The finite construction, with the exact size and density in Theorem 1.3. -/
  3705. theorem finite_construction_plane (d q : ℕ) (hd : 2 ≤ d) (hq : 2 ≤ q)
  3706. (η : ℝ) (hη : 0 < η) : ∃ P : Finset ℝ²,
  3707. P.card = finiteSize d q ∧
  3708. (d : ℝ) / 2 * (1 - 1 / (q : ℝ)) * P.card ≤ unitDistNum P ∧
  3709. ConvexIndep P ∧ PlaneRadialSupport P ∧ 0 ∉ P ∧
  3710. (P : Set ℝ²) ⊆ planeTwoDisks η := by
  3711. obtain ⟨Q, hc, he, hs, hz, hl⟩ := finite_construction_real d q hd hq η hη
  3712. have hcard : (Q.image complexToPlane).card = Q.card :=
  3713. Finset.card_image_of_injective _ complexToPlane.injective
  3714. have hedge : unitDistNum (Q.image complexToPlane) = (unitPairs Q).card := by
  3715. rw [unitDistNum_eq_card_unitPairs, unitPairs_card_image_isometry _ complexToPlane.isometry]
  3716. refine ⟨Q.image complexToPlane, hcard.trans hc, ?_,
  3717. convexIndep_image_complexToPlane Q hs.convexIndependent, radialSupport_image hs, ?_,
  3718. twoDisks_image hl⟩
  3719. · rwa [hcard, hedge]
  3720. · intro hh
  3721. obtain ⟨a, ha, he⟩ := Finset.mem_image.mp hh
  3722. have ha0 := complexToPlane.injective (he.trans (map_zero complexToPlane).symm)
  3723. exact hz (ha0 ▸ ha)
  3724. /-- Proposition 4.3, including strict support and arbitrarily small prescribed disks. -/
  3725. theorem threshold_configuration_plane (k : ℕ) (hk : 1 ≤ k) (n : ℕ)
  3726. (hn : thresholdSize k ^ 2 ≤ n) (η : ℝ) (hη : 0 < η) :
  3727. ∃ P : Finset ℝ², P.card = n ∧ ConvexIndep P ∧ PlaneRadialSupport P ∧
  3728. 0 ∉ P ∧ (P : Set ℝ²) ⊆ planeTwoDisks η ∧ HasUnitMinDegree P k ∧
  3729. ((k : ℝ) - 1) * n ≤ unitDistNum P := by
  3730. obtain ⟨Q, hc, hs, hz, hl, hd, he⟩ := threshold_configuration k hk n hn η hη
  3731. have hcard : (Q.image complexToPlane).card = Q.card :=
  3732. Finset.card_image_of_injective _ complexToPlane.injective
  3733. have hedge : unitDistNum (Q.image complexToPlane) = (unitPairs Q).card := by
  3734. rw [unitDistNum_eq_card_unitPairs, unitPairs_card_image_isometry _ complexToPlane.isometry]
  3735. refine ⟨Q.image complexToPlane, hcard.trans hc,
  3736. convexIndep_image_complexToPlane Q hs.convexIndependent, radialSupport_image hs, ?_,
  3737. twoDisks_image hl, unitMinDegree_image hd, ?_⟩
  3738. · intro hh
  3739. obtain ⟨a, ha, he⟩ := Finset.mem_image.mp hh
  3740. have ha0 := complexToPlane.injective (he.trans (map_zero complexToPlane).symm)
  3741. exact hz (ha0 ▸ ha)
  3742. · rwa [hedge]
  3743. /-- Theorem 1.1, with the explicit absolute choice C = 7. Both the minimum degree
  3744. and the number of unordered unit-distance pairs have the leading coefficient 1/4. -/
  3745. theorem main_quantitative : ∃ n₀ : ℕ, ∀ n ≥ n₀, ∀ η : ℝ, 0 < η → η < 1 / 2 →
  3746. ∃ P : Finset ℝ², P.Nonempty ∧ P.card = n ∧ ConvexIndep P ∧
  3747. PlaneRadialSupport P ∧ 0 ∉ P ∧ (P : Set ℝ²) ⊆ planeTwoDisks η ∧
  3748. (unitDistanceGraph P).IsBipartite ∧ HorizontalBipartition P ∧
  3749. doubleLog (n : ℝ) / 4 - 7 * tripleLog (n : ℝ) ≤
  3750. min (minimumUnitDegree P : ℝ) ((unitDistNum P : ℝ) / n) := by
  3751. obtain ⟨n₀, hn₀⟩ := logarithmic_index
  3752. refine ⟨n₀, ?_⟩
  3753. intro n hn η hη hηhalf
  3754. obtain ⟨k, hk, ht, hbound⟩ := hn₀ n hn
  3755. obtain ⟨P, hc, hconv, hs, hz, hl, hd, he⟩ :=
  3756. threshold_configuration_plane k hk n ht η hη
  3757. have hnpos : 0 < n := (pow_pos (thresholdSize_pos k) 2).trans_le ht
  3758. have hP : P.Nonempty := Finset.card_pos.mp (by rwa [hc])
  3759. have hdeg : (k : ℝ) ≤ minimumUnitDegree P := by
  3760. exact_mod_cast le_minimumUnitDegree P hP k hd
  3761. have hdiv : (k : ℝ) - 1 ≤ (unitDistNum P : ℝ) / n :=
  3762. (le_div_iff₀ (by exact_mod_cast hnpos)).mpr he
  3763. have hb := twoDisks_horizontalBipartition hηhalf hl
  3764. exact ⟨P, hP, hc, hconv, hs, hz, hl, hb.isBipartite, hb,
  3765. le_min (by linarith) (hbound.trans hdiv)⟩
  3766. /-- The exact constant-quantified form of Theorem 1.1. -/
  3767. theorem main_theorem : ∃ C : ℝ, 0 < C ∧ ∃ n₀ : ℕ,
  3768. ∀ n ≥ n₀, ∀ η : ℝ, 0 < η → η < 1 / 2 →
  3769. ∃ P : Finset ℝ², P.Nonempty ∧ P.card = n ∧ ConvexIndep P ∧
  3770. (P : Set ℝ²) ⊆ planeTwoDisks η ∧ (unitDistanceGraph P).IsBipartite ∧
  3771. HorizontalBipartition P ∧
  3772. doubleLog (n : ℝ) / 4 - C * tripleLog (n : ℝ) ≤
  3773. min (minimumUnitDegree P : ℝ) ((unitDistNum P : ℝ) / n) := by
  3774. obtain ⟨n₀, hn₀⟩ := main_quantitative
  3775. refine ⟨7, by norm_num, n₀, ?_⟩
  3776. intro n hn η hη hηhalf
  3777. obtain ⟨P, hP, hc, hv, _, _, hl, hb, hh, he⟩ := hn₀ n hn η hη hηhalf
  3778. exact ⟨P, hP, hc, hv, hl, hb, hh, he⟩
  3779. end
  3780. end Proof
  3781. end Combined_MainTheorem
  3782. /-! ## Source: GrowthEstimates.lean -/
  3783. section Combined_GrowthEstimates
  3784. /-! Two-sided growth estimates, including the double-exponential size bound. -/
  3785. namespace Proof
  3786. noncomputable section
  3787. open Filter
  3788. theorem finiteSize_doubleLog_lower (d : ℕ) (hd : 2 ≤ d) :
  3789. 2 * (d : ℝ) - logTwo (2 * (d : ℝ) + 1) ≤
  3790. doubleLog (finiteSize d (d + 1) : ℝ) := by
  3791. have hv := middleVertexCount_pos d
  3792. have hvm : middleVertexCount d ≤ middleEdgeCount d := by
  3793. have ht := middleEdgeCount_twice (show 1 ≤ d by omega)
  3794. nlinarith
  3795. have hpow : 2 ^ middleEdgeCount d ≤ finiteSize d (d + 1) := by
  3796. calc
  3797. 2 ^ middleEdgeCount d ≤ (d + 1) ^ middleEdgeCount d := Nat.pow_le_pow_left (by omega) _
  3798. _ ≤ middleVertexCount d * (d + 1) ^ middleEdgeCount d := by
  3799. simpa only [one_mul] using Nat.mul_le_mul_right ((d + 1) ^ middleEdgeCount d) (show 1 ≤ middleVertexCount d by omega)
  3800. have hpowR : (2 : ℝ) ^ middleEdgeCount d ≤ (finiteSize d (d + 1) : ℝ) := by
  3801. exact_mod_cast hpow
  3802. have hm : (middleEdgeCount d : ℝ) ≤ logTwo (finiteSize d (d + 1) : ℝ) := by
  3803. have h := logTwo_mono (by positivity : (0 : ℝ) < 2 ^ middleEdgeCount d) hpowR
  3804. simpa only [logTwo, Real.logb_pow, Real.logb_self_eq_one (by norm_num : (1 : ℝ) < 2), mul_one] using h
  3805. have hvlog : (middleVertexCount d : ℝ) ≤ logTwo (finiteSize d (d + 1) : ℝ) :=
  3806. (show (middleVertexCount d : ℝ) ≤ middleEdgeCount d by exact_mod_cast hvm).trans hm
  3807. have hlower := logTwo_mono (by exact_mod_cast hv) hvlog
  3808. have hbin : (4 : ℝ) ^ d ≤ (2 * (d : ℝ) + 1) * (middleVertexCount d : ℝ) := by
  3809. exact_mod_cast Nat.four_pow_le_two_mul_add_one_mul_central_binom d
  3810. have hb := logTwo_mono (by positivity : (0 : ℝ) < 4 ^ d) hbin
  3811. change Real.logb 2 ((4 : ℝ) ^ d) ≤ Real.logb 2 ((2 * (d : ℝ) + 1) * ↑(middleVertexCount d)) at hb
  3812. rw [Real.logb_pow, Real.logb_mul (by positivity) (by exact_mod_cast hv.ne')] at hb
  3813. change (d : ℝ) * logTwo 4 ≤ logTwo (2 * (d : ℝ) + 1) + logTwo (middleVertexCount d : ℝ) at hb
  3814. rw [logTwo_four] at hb
  3815. change logTwo (middleVertexCount d : ℝ) ≤ doubleLog (finiteSize d (d + 1) : ℝ) at hlower
  3816. linarith
  3817. theorem finiteSize_doubleLog_upper (d : ℕ) (hd : 1 ≤ d) :
  3818. doubleLog (finiteSize d (d + 1) : ℝ) ≤
  3819. 2 * (d : ℝ) + 2 * logTwo ((d : ℝ) + 1) + 2 := by
  3820. have hs := finiteSize_ge_two hd (show 1 ≤ d + 1 by omega)
  3821. have hsR : (1 : ℝ) < (finiteSize d (d + 1) : ℝ) := by exact_mod_cast (by omega : 1 < finiteSize d (d + 1))
  3822. have hs2R : (1 : ℝ) < ((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ) := by exact_mod_cast (by nlinarith : 1 < finiteSize d (d + 1) ^ 2)
  3823. have hle : (finiteSize d (d + 1) : ℝ) ≤ ((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ) := by
  3824. exact_mod_cast (by nlinarith : finiteSize d (d + 1) ≤ finiteSize d (d + 1) ^ 2)
  3825. exact ((doubleLog_le_iff hsR hs2R).mpr hle).trans (finiteSize_doubleLog_bound d hd)
  3826. theorem threshold_doubleLog_lower (k : ℕ) (hk : 1 ≤ k) :
  3827. 4 * (k : ℝ) - logTwo ((k : ℝ) + 1) ≤
  3828. doubleLog ((thresholdSize k ^ 2 : ℕ) : ℝ) := by
  3829. have h := finiteSize_doubleLog_lower (2 * k + 1) (by omega)
  3830. have hm : logTwo (2 * ((2 * k + 1 : ℕ) : ℝ) + 1) ≤ 2 + logTwo ((k : ℝ) + 1) := by
  3831. have he : logTwo (4 * ((k : ℝ) + 1)) = 2 + logTwo ((k : ℝ) + 1) := by
  3832. unfold logTwo
  3833. rw [Real.logb_mul (by norm_num) (by positivity)]
  3834. change logTwo 4 + logTwo ((k : ℝ) + 1) = _
  3835. rw [logTwo_four]
  3836. rfl
  3837. rw [← he]
  3838. apply logTwo_mono (by positivity)
  3839. push_cast
  3840. linarith
  3841. have hs := finiteSize_ge_two (show 1 ≤ 2 * k + 1 by omega) (show 1 ≤ 2 * k + 2 by omega)
  3842. change 2 ≤ thresholdSize k at hs
  3843. have hr : (1 : ℝ) < (thresholdSize k : ℝ) := by exact_mod_cast (by omega : 1 < thresholdSize k)
  3844. have hr2 : (1 : ℝ) < ((thresholdSize k ^ 2 : ℕ) : ℝ) := by exact_mod_cast (by nlinarith : 1 < thresholdSize k ^ 2)
  3845. have hle : (thresholdSize k : ℝ) ≤ ((thresholdSize k ^ 2 : ℕ) : ℝ) := by
  3846. exact_mod_cast (by nlinarith : thresholdSize k ≤ thresholdSize k ^ 2)
  3847. have ht := (doubleLog_le_iff hr hr2).mpr hle
  3848. change 2 * ((2 * k + 1 : ℕ) : ℝ) - _ ≤ doubleLog (thresholdSize k : ℝ) at h
  3849. push_cast at h hm
  3850. linarith
  3851. theorem threshold_growth :
  3852. (fun k : ℕ => doubleLog ((thresholdSize k ^ 2 : ℕ) : ℝ) - 4 * (k : ℝ))
  3853. =O[atTop] (fun k => logTwo ((k : ℝ) + 1)) := by
  3854. apply Asymptotics.isBigO_iff.mpr
  3855. refine ⟨8, ?_⟩
  3856. filter_upwards [eventually_ge_atTop (1 : ℕ)] with k hk
  3857. have hl := threshold_doubleLog_lower k hk
  3858. have hu := threshold_doubleLog_bound k
  3859. have hlog : 1 ≤ logTwo ((k : ℝ) + 1) := by
  3860. calc
  3861. 1 = logTwo 2 := logTwo_two.symm
  3862. _ ≤ logTwo ((k : ℝ) + 1) := logTwo_mono (by norm_num) (by exact_mod_cast (by omega : 2 ≤ k + 1))
  3863. rw [Real.norm_eq_abs, Real.norm_eq_abs, abs_of_nonneg (by linarith : 0 ≤ logTwo ((k : ℝ) + 1))]
  3864. exact abs_le.mpr ⟨by linarith, by linarith⟩
  3865. def degreeSizeBound (k : ℕ) : ℕ := finiteSize (2 * k - 1) (2 * k)
  3866. theorem degreeSizeBound_growth_estimate (k : ℕ) (hk : 2 ≤ k) :
  3867. |doubleLog (degreeSizeBound k : ℝ) - 4 * (k : ℝ)| ≤ 5 * logTwo (k : ℝ) := by
  3868. have hlow := finiteSize_doubleLog_lower (2 * k - 1) (by omega)
  3869. have hu := finiteSize_doubleLog_upper (2 * k - 1) (by omega)
  3870. have he : 2 * k - 1 + 1 = 2 * k := by omega
  3871. rw [he] at hlow hu
  3872. change 2 * ((2 * k - 1 : ℕ) : ℝ) - _ ≤ doubleLog (degreeSizeBound k : ℝ) at hlow
  3873. change doubleLog (degreeSizeBound k : ℝ) ≤ _ at hu
  3874. have hkR : (2 : ℝ) ≤ k := by exact_mod_cast hk
  3875. have hcast : ((2 * k - 1 : ℕ) : ℝ) = 2 * (k : ℝ) - 1 := by
  3876. rw [Nat.cast_sub (by omega), Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one]
  3877. rw [hcast] at hlow hu
  3878. have hl : logTwo (2 * (k : ℝ)) = 1 + logTwo (k : ℝ) := by
  3879. unfold logTwo
  3880. rw [Real.logb_mul (by norm_num) (by positivity)]
  3881. change logTwo 2 + logTwo (k : ℝ) = _
  3882. rw [logTwo_two]
  3883. rfl
  3884. rw [sub_add_cancel, hl] at hu
  3885. have hlog : 1 ≤ logTwo (k : ℝ) := by
  3886. exact logTwo_two ▸ logTwo_mono (by norm_num : (0 : ℝ) < 2) hkR
  3887. have hl4 : logTwo (2 * (2 * (k : ℝ) - 1) + 1) ≤ 2 + logTwo (k : ℝ) := by
  3888. have hm := logTwo_mono (by linarith : 0 < 2 * (2 * (k : ℝ) - 1) + 1)
  3889. (by linarith : 2 * (2 * (k : ℝ) - 1) + 1 ≤ 4 * (k : ℝ))
  3890. change _ ≤ Real.logb 2 (4 * (k : ℝ)) at hm
  3891. rw [Real.logb_mul (by norm_num) (by positivity)] at hm
  3892. change _ ≤ logTwo 4 + logTwo (k : ℝ) at hm
  3893. rwa [logTwo_four] at hm
  3894. exact abs_le.mpr ⟨by linarith, by linarith⟩
  3895. theorem degreeSizeBound_growth :
  3896. (fun k : ℕ => doubleLog (degreeSizeBound k : ℝ) - 4 * (k : ℝ))
  3897. =O[atTop] (fun k => logTwo (k : ℝ)) := by
  3898. apply Asymptotics.isBigO_iff.mpr
  3899. refine ⟨5, ?_⟩
  3900. filter_upwards [eventually_ge_atTop (2 : ℕ)] with k hk
  3901. have hl : 0 ≤ logTwo (k : ℝ) := (logTwo_pos (by exact_mod_cast (by omega : 1 < k))).le
  3902. simpa only [Real.norm_eq_abs, abs_of_nonneg hl] using degreeSizeBound_growth_estimate k hk
  3903. /-- The double-exponential equality, with the error term separately proved to be O(log k). -/
  3904. theorem degreeSizeBound_double_exponential (k : ℕ) (hk : 2 ≤ k) :
  3905. (degreeSizeBound k : ℝ) = (2 : ℝ) ^ ((2 : ℝ) ^
  3906. (4 * (k : ℝ) + (doubleLog (degreeSizeBound k : ℝ) - 4 * (k : ℝ)))) := by
  3907. have hs : 2 ≤ degreeSizeBound k := finiteSize_ge_two (by omega) (by omega)
  3908. have hr : (1 : ℝ) < (degreeSizeBound k : ℝ) := by exact_mod_cast (by omega : 1 < degreeSizeBound k)
  3909. rw [add_sub_cancel]
  3910. unfold doubleLog logTwo
  3911. have hlogpos : 0 < Real.logb 2 (degreeSizeBound k : ℝ) := logTwo_pos hr
  3912. rw [Real.rpow_logb (by norm_num) (by norm_num) hlogpos,
  3913. Real.rpow_logb (by norm_num) (by norm_num) (by linarith)]
  3914. end
  3915. end Proof
  3916. end Combined_GrowthEstimates
  3917. /-! ## Source: Corollaries.lean -/
  3918. section Combined_Corollaries
  3919. /-! The quantitative, fixed-degree, and explicit-size corollaries. -/
  3920. namespace Proof
  3921. noncomputable section
  3922. open Classical Filter EuclideanGeometry
  3923. open scoped EuclideanGeometry
  3924. /-- Every sufficiently large prescribed cardinality admits any fixed minimum degree. -/
  3925. theorem eventual_minimum_degree (k : ℕ) (hk : 1 ≤ k) : ∃ n₀ : ℕ,
  3926. ∀ n ≥ n₀, ∀ η : ℝ, 0 < η → η < 1 / 2 →
  3927. ∃ P : Finset ℝ², P.Nonempty ∧ P.card = n ∧ ConvexIndep P ∧
  3928. HasUnitMinDegree P k ∧ (P : Set ℝ²) ⊆ planeTwoDisks η ∧
  3929. HorizontalBipartition P := by
  3930. refine ⟨thresholdSize k ^ 2, ?_⟩
  3931. intro n hn η hη hηhalf
  3932. obtain ⟨P, hc, hv, _, _, hl, hd, _⟩ := threshold_configuration_plane k hk n hn η hη
  3933. have hpos : 0 < n := (pow_pos (thresholdSize_pos k) 2).trans_le hn
  3934. exact ⟨P, Finset.card_pos.mp (by rwa [hc]), hc, hv, hd, hl,
  3935. twoDisks_horizontalBipartition hηhalf hl⟩
  3936. /-- The Ω(n log log n) lower bound holds even with the prescribed disk restriction. -/
  3937. theorem eventual_localized_density : ∃ n₀ : ℕ,
  3938. ∀ n ≥ n₀, ∀ η : ℝ, 0 < η → η < 1 / 2 →
  3939. ∃ P : Finset ℝ², P.Nonempty ∧ P.card = n ∧ ConvexIndep P ∧
  3940. (P : Set ℝ²) ⊆ planeTwoDisks η ∧ HorizontalBipartition P ∧
  3941. (n : ℝ) * doubleLog (n : ℝ) / 8 ≤ unitDistNum P := by
  3942. obtain ⟨n₀, hn₀⟩ := main_quantitative
  3943. have hsmall : ∀ᶠ n : ℕ in atTop, 7 * tripleLog (n : ℝ) ≤ doubleLog (n : ℝ) / 8 := by
  3944. have h := tendsto_doubleLog_nat.eventually (logTwo_sublinear (1 / 56) (by norm_num))
  3945. filter_upwards [h] with n hn
  3946. change logTwo (doubleLog (n : ℝ)) ≤ _ at hn
  3947. change 7 * logTwo (doubleLog (n : ℝ)) ≤ _
  3948. linarith
  3949. apply eventually_atTop.mp
  3950. filter_upwards [eventually_ge_atTop n₀, hsmall] with n hn hsmall
  3951. intro η hη hηhalf
  3952. obtain ⟨P, hP, hc, hv, _, _, hl, _, hh, hb⟩ := hn₀ n hn η hη hηhalf
  3953. have hnpos : (0 : ℝ) < n := by exact_mod_cast (hc ▸ Finset.card_pos.mpr hP)
  3954. have hdiv : doubleLog (n : ℝ) / 8 ≤ (unitDistNum P : ℝ) / n := by
  3955. have h := hb.trans (min_le_right _ _)
  3956. linarith
  3957. have he := (le_div_iff₀ hnpos).mp hdiv
  3958. refine ⟨P, hP, hc, hv, hl, hh, ?_⟩
  3959. nlinarith
  3960. /-- In standard asymptotic notation, n log₂ log₂ n = O(U_c(n)). -/
  3961. theorem convex_unit_distances_omega :
  3962. (fun n : ℕ => (n : ℝ) * doubleLog (n : ℝ)) =O[atTop]
  3963. (fun n => (Erdos96.maxConvexUnitDistances n : ℝ)) := by
  3964. obtain ⟨n₀, hn₀⟩ := eventual_localized_density
  3965. apply Asymptotics.isBigO_iff.mpr
  3966. refine ⟨8, ?_⟩
  3967. filter_upwards [eventually_ge_atTop n₀,
  3968. tendsto_doubleLog_nat.eventually (eventually_ge_atTop (0 : ℝ))] with n hn hlog
  3969. obtain ⟨P, _, hc, hv, _, _, he⟩ := hn₀ n hn (1 / 4) (by norm_num) (by norm_num)
  3970. have hm : (unitDistNum P : ℝ) ≤ Erdos96.maxConvexUnitDistances n := by
  3971. have h := unitDistNum_le_max P hv
  3972. rw [hc] at h
  3973. exact_mod_cast h
  3974. rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (Nat.cast_nonneg n) hlog), Real.norm_natCast]
  3975. linarith
  3976. /-- Corollary 4.4: a nonempty convex set of minimum degree k, with the stated size bound. -/
  3977. theorem bounded_size_minimum_degree (k : ℕ) (hk : 2 ≤ k)
  3978. (η : ℝ) (hη : 0 < η) (hηhalf : η < 1 / 2) :
  3979. ∃ Q : Finset ℝ², Q.Nonempty ∧ ConvexIndep Q ∧
  3980. HasUnitMinDegree Q k ∧ Q.card ≤ degreeSizeBound k ∧
  3981. (Q : Set ℝ²) ⊆ planeTwoDisks η ∧
  3982. HorizontalBipartition Q := by
  3983. let α : ℝ := (k : ℝ) - 1 + 1 / (4 * (k : ℝ))
  3984. have hkR : (2 : ℝ) ≤ k := by exact_mod_cast hk
  3985. have hcast : ((k - 1 : ℕ) : ℝ) = (k : ℝ) - 1 := by rw [Nat.cast_sub (by omega), Nat.cast_one]
  3986. have hα : ((k - 1 : ℕ) : ℝ) < α := by
  3987. rw [hcast]
  3988. dsimp [α]
  3989. have hp : (0 : ℝ) < 1 / (4 * (k : ℝ)) := by positivity
  3990. linarith
  3991. obtain ⟨P, hc, he, hv, _, _, hl⟩ :=
  3992. finite_construction_plane (2 * k - 1) (2 * k) (by omega) (by omega) η hη
  3993. have hratio : ((2 * k - 1 : ℕ) : ℝ) / 2 * (1 - 1 / ((2 * k : ℕ) : ℝ)) = α := by
  3994. rw [Nat.cast_sub (by omega), Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one]
  3995. dsimp [α]
  3996. field_simp
  3997. ring
  3998. rw [hratio, unitDistNum_eq_card_unitPairs] at he
  3999. have hP : P.Nonempty := Finset.card_pos.mp (by rw [hc]; exact finiteSize_pos (by omega))
  4000. obtain ⟨Q, hQP, hQ, hd, _⟩ := dense_subset_min_degree α (k - 1) hα P hP he
  4001. have hd' : HasUnitMinDegree Q k := by simpa only [Nat.sub_add_cancel (by omega : 1 ≤ k)] using hd
  4002. have hloc : (Q : Set ℝ²) ⊆ planeTwoDisks η := fun _ hx => hl (hQP hx)
  4003. exact ⟨Q, hQ, convexIndep_subset hv hQP, hd', (Finset.card_le_card hQP).trans_eq hc,
  4004. hloc, twoDisks_horizontalBipartition hηhalf hloc⟩
  4005. theorem degreeSizeBound_four : degreeSizeBound 4 = 3432 * 2 ^ 36036 := by
  4006. have hv : middleVertexCount 7 = 3432 := by norm_num [middleVertexCount, Nat.choose]
  4007. have hm : middleEdgeCount 7 = 12012 := by norm_num [middleEdgeCount, Nat.choose]
  4008. change finiteSize 7 8 = _
  4009. rw [finiteSize, hv, hm, show (8 : ℕ) = 2 ^ 3 from rfl, ← pow_mul]
  4010. /-- The numerical bound in the manuscript, for the exact equidistance predicate. -/
  4011. theorem explicit_erdos_97_counterexample (η : ℝ) (hη : 0 < η) (hηhalf : η < 1 / 2) :
  4012. ∃ Q : Finset ℝ², Q.Nonempty ∧ ConvexIndep Q ∧
  4013. Erdos97.HasNUnitDistanceProperty 4 Q ∧ Erdos97.HasNEquidistantProperty 4 Q ∧
  4014. Q.card ≤ 3432 * 2 ^ 36036 ∧ (Q : Set ℝ²) ⊆ planeTwoDisks η ∧
  4015. HorizontalBipartition Q := by
  4016. obtain ⟨Q, hQ, hv, hd, hc, hl, hh⟩ := bounded_size_minimum_degree 4 (by norm_num) η hη hηhalf
  4017. rw [degreeSizeBound_four] at hc
  4018. exact ⟨Q, hQ, hv, hd, fun x hx => ⟨1, by norm_num, hd x hx⟩, hc, hl, hh⟩
  4019. /-- The logical equivalence noted after Corollary 4.4. -/
  4020. theorem unbounded_density_iff_unbounded_minimum_degree :
  4021. (∀ α : ℝ, ∃ P : Finset ℝ², P.Nonempty ∧ ConvexIndep P ∧
  4022. α * P.card ≤ (unitPairs P).card) ↔
  4023. (∀ k : ℕ, ∃ P : Finset ℝ², P.Nonempty ∧ ConvexIndep P ∧ HasUnitMinDegree P k) := by
  4024. constructor
  4025. · intro h k
  4026. obtain ⟨P, hP, hv, hc⟩ := h ((k : ℝ) + 1)
  4027. obtain ⟨Q, hQP, hQ, hd, _⟩ := dense_subset_min_degree ((k : ℝ) + 1) k
  4028. (by linarith) P hP hc
  4029. exact ⟨Q, hQ, convexIndep_subset hv hQP, fun x hx => (Nat.le_succ k).trans (hd x hx)⟩
  4030. · intro h α
  4031. obtain ⟨k, hk⟩ := exists_nat_ge (2 * α)
  4032. obtain ⟨P, hP, hv, hd⟩ := h k
  4033. have hsum : ∑ x ∈ P, k ≤ ∑ x ∈ P, unitDegree P x := Finset.sum_le_sum (fun x hx => hd x hx)
  4034. rw [sum_unitDegree, Finset.sum_const, nsmul_eq_mul] at hsum
  4035. have hs : (P.card : ℝ) * (k : ℝ) ≤ 2 * (unitPairs P).card := by exact_mod_cast hsum
  4036. have hm := mul_le_mul_of_nonneg_right hk (Nat.cast_nonneg P.card : (0 : ℝ) ≤ P.card)
  4037. exact ⟨P, hP, hv, by nlinarith⟩
  4038. end
  4039. end Proof
  4040. end Combined_Corollaries
  4041. /-! ## Source: AxiomAudit.lean -/
  4042. section Combined_AxiomAudit
  4043. /-! A failing build gate for any nonstandard axiom in an exported result's
  4044. transitive proof dependencies. These checks reject sorryAx as well as any new axiom. -/
  4045. open Lean Elab Command in
  4046. elab "assert_standard_axioms " n:ident : command => do
  4047. let name ← liftCoreM <| Lean.Elab.realizeGlobalConstNoOverloadWithInfo n
  4048. let axioms ← Lean.collectAxioms name
  4049. for axiomName in axioms do
  4050. unless [``propext, ``Classical.choice, ``Quot.sound].contains axiomName do
  4051. throwError "{name} depends on the disallowed axiom {axiomName}"
  4052. logInfo m!"Verified {name}: only propext, Classical.choice, and Quot.sound are permitted."
  4053. assert_standard_axioms Proof.main_theorem
  4054. assert_standard_axioms Proof.main_quantitative
  4055. assert_standard_axioms Proof.finite_construction_plane
  4056. assert_standard_axioms Proof.finite_construction_real
  4057. assert_standard_axioms Proof.threshold_configuration_plane
  4058. assert_standard_axioms Proof.threshold_configuration
  4059. assert_standard_axioms Proof.logarithmic_index
  4060. assert_standard_axioms Proof.threshold_growth
  4061. assert_standard_axioms Proof.degreeSizeBound_growth
  4062. assert_standard_axioms Proof.degreeSizeBound_double_exponential
  4063. assert_standard_axioms Proof.eventual_minimum_degree
  4064. assert_standard_axioms Proof.eventual_localized_density
  4065. assert_standard_axioms Proof.convex_unit_distances_omega
  4066. assert_standard_axioms Proof.bounded_size_minimum_degree
  4067. assert_standard_axioms Proof.degreeSizeBound_four
  4068. assert_standard_axioms Proof.explicit_erdos_97_counterexample
  4069. assert_standard_axioms Proof.erdos_96_false
  4070. assert_standard_axioms Proof.erdos_97_false
  4071. assert_standard_axioms Proof.erdos_97_general_false
  4072. assert_standard_axioms target
  4073. assert_standard_axioms Proof.unbounded_density_iff_unbounded_minimum_degree
  4074. assert_standard_axioms Proof.small_rotated_copies
  4075. assert_standard_axioms Proof.dense_subset_min_degree
  4076. assert_standard_axioms Proof.erase_low_degree_density
  4077. assert_standard_axioms Proof.boundedCopy_support
  4078. assert_standard_axioms Proof.boundedCopy_displacement
  4079. assert_standard_axioms Proof.boundedSet_card
  4080. assert_standard_axioms Proof.bounded_amplification_unitPairs_bound
  4081. assert_standard_axioms Proof.exists_injective_boundedProducts
  4082. assert_standard_axioms Proof.middleVertex_card
  4083. assert_standard_axioms Proof.middleEdgeCount_formula
  4084. assert_standard_axioms Proof.middlePattern
  4085. assert_standard_axioms Proof.twoDisks_horizontalBipartition
  4086. end Combined_AxiomAudit