Buckets:
| import OAI.NumberTheory.ShortEgyptian.Distinctness | |
| namespace OAI | |
| namespace ShortEgyptian | |
| open scoped BigOperators | |
| open Finset | |
| noncomputable def phase (x : ℝ) : ℂ := Complex.exp (↑(2 * Real.pi * x) * Complex.I) | |
| theorem phase_norm (x : ℝ) : ‖phase x‖ = 1 := by | |
| simp [phase, Complex.norm_exp] | |
| theorem phase_add (x y : ℝ) : phase (x + y) = phase x * phase y := by | |
| simp [phase, mul_add, add_mul, Complex.exp_add] | |
| theorem phase_zero : phase 0 = 1 := by simp [phase] | |
| theorem phase_int (n : ℤ) : phase n = 1 := by | |
| have heq : (↑(2 * Real.pi * (n : ℝ)) : ℂ) * Complex.I = | |
| (n : ℂ) * (2 * Real.pi * Complex.I) := by push_cast; ring | |
| rw [phase, heq, Complex.exp_int_mul_two_pi_mul_I] | |
| theorem phase_re (x : ℝ) : (phase x).re = Real.cos (2 * Real.pi * x) := by | |
| simp [phase, Complex.exp_re] | |
| theorem phase_im (x : ℝ) : (phase x).im = Real.sin (2 * Real.pi * x) := by | |
| simp [phase, Complex.exp_im] | |
| theorem phase_sub_one_norm (x : ℝ) : ‖phase x - 1‖ = 2 * |Real.sin (Real.pi * x)| := by | |
| have hsq : ‖phase x - 1‖ ^ 2 = (2 * |Real.sin (Real.pi * x)|) ^ 2 := by | |
| rw [Complex.sq_norm, Complex.normSq_apply] | |
| simp only [Complex.sub_re, Complex.one_re, phase_re, Complex.sub_im, | |
| Complex.one_im, phase_im, sub_zero] | |
| rw [show 2 * Real.pi * x = 2 * (Real.pi * x) by ring, | |
| Real.sin_two_mul, Real.cos_two_mul] | |
| have hh := Real.sin_sq_add_cos_sq (Real.pi * x) | |
| rw [mul_pow, sq_abs] | |
| nlinarith [sq_nonneg (Real.cos (Real.pi * x) ^ 2 - 1)] | |
| exact (sq_eq_sq₀ (norm_nonneg _) (by positivity)).mp hsq | |
| theorem sin_pi_lower {β x : ℝ} (hβ : 0 ≤ β) (hx : β ≤ x) (hx' : x ≤ 1 - β) : | |
| 2 * β ≤ Real.sin (Real.pi * x) := by | |
| have hx0 : 0 ≤ x := le_trans hβ hx | |
| have hx1 : x ≤ 1 := by linarith | |
| by_cases hh : x ≤ 1 / 2 | |
| · have h := Real.mul_le_sin (x := Real.pi * x) (by positivity) | |
| (by nlinarith [Real.pi_pos]) | |
| have heq : 2 / Real.pi * (Real.pi * x) = 2 * x := by field_simp | |
| rw [heq] at h | |
| linarith | |
| · have h := Real.mul_le_sin (x := Real.pi * (1 - x)) (by positivity) | |
| (by nlinarith [Real.pi_pos]) | |
| have heq : 2 / Real.pi * (Real.pi * (1 - x)) = 2 * (1 - x) := by field_simp | |
| rw [heq, show Real.pi * (1 - x) = Real.pi - Real.pi * x by ring, | |
| Real.sin_pi_sub] at h | |
| linarith | |
| theorem phase_increment_inv {x : ℝ} (hx : 0 < x) (hx' : x < 1) : | |
| (phase x - 1)⁻¹ = (-1 / 2 : ℂ) - | |
| (↑(Real.cos (Real.pi * x) / (2 * Real.sin (Real.pi * x))) : ℂ) * Complex.I := by | |
| have hs : 0 < Real.sin (Real.pi * x) := | |
| Real.sin_pos_of_pos_of_lt_pi (by positivity) (by nlinarith [Real.pi_pos]) | |
| let b : ℂ := (-1 / 2 : ℂ) - | |
| (↑(Real.cos (Real.pi * x) / (2 * Real.sin (Real.pi * x))) : ℂ) * Complex.I | |
| have hmul : b * (phase x - 1) = 1 := by | |
| apply Complex.ext <;> simp only [b, Complex.mul_re, Complex.mul_im, Complex.sub_re, | |
| Complex.sub_im, Complex.div_re, Complex.div_im, Complex.neg_re, Complex.neg_im, | |
| Complex.one_re, Complex.one_im, Complex.I_re, | |
| Complex.I_im, Complex.ofReal_re, Complex.ofReal_im, phase_re, phase_im] | |
| all_goals | |
| norm_num | |
| rw [show 2 * Real.pi * x = 2 * (Real.pi * x) by ring, | |
| Real.sin_two_mul, Real.cos_two_mul] | |
| field_simp | |
| nlinarith [Real.sin_sq_add_cos_sq (Real.pi * x), | |
| congrArg (fun t : ℝ => Real.cos (Real.pi * x) * t) | |
| (Real.sin_sq_add_cos_sq (Real.pi * x))] | |
| have hne : phase x - 1 ≠ 0 := by | |
| intro hh | |
| rw [hh, mul_zero] at hmul | |
| exact zero_ne_one hmul | |
| change (phase x - 1)⁻¹ = b | |
| rw [← one_div] | |
| exact (div_eq_iff hne).mpr hmul.symm | |
| theorem phase_increment_im_mono : | |
| MonotoneOn (fun x : ℝ => ((phase x - 1)⁻¹).im) (Set.Ioo 0 1) := by | |
| intro x hx y hy hxy | |
| rcases hx with ⟨hx0, hx1⟩ | |
| rcases hy with ⟨hy0, hy1⟩ | |
| dsimp only | |
| rw [phase_increment_inv hx0 hx1, phase_increment_inv hy0 hy1] | |
| simp only [Complex.sub_im, Complex.div_im, Complex.neg_im, Complex.one_im, | |
| Complex.neg_re, Complex.one_re, | |
| Complex.mul_im, Complex.I_re, Complex.I_im, Complex.ofReal_re, Complex.ofReal_im] | |
| norm_num | |
| have hsx : 0 < Real.sin (Real.pi * x) := | |
| Real.sin_pos_of_pos_of_lt_pi (by positivity) (by nlinarith [Real.pi_pos]) | |
| have hsy : 0 < Real.sin (Real.pi * y) := | |
| Real.sin_pos_of_pos_of_lt_pi (by positivity) (by nlinarith [Real.pi_pos]) | |
| have hd := Real.sin_nonneg_of_nonneg_of_le_pi (x := Real.pi * y - Real.pi * x) | |
| (by nlinarith [Real.pi_pos]) (by nlinarith [Real.pi_pos]) | |
| rw [Real.sin_sub] at hd | |
| apply (div_le_div_iff₀ (by positivity : 0 < 2 * Real.sin (Real.pi * y)) | |
| (by positivity : 0 < 2 * Real.sin (Real.pi * x))).mpr | |
| nlinarith | |
| theorem summation_by_parts_differences (a b : ℕ → ℂ) (N : ℕ) : | |
| (∑ n ∈ range N, b n * (a (n + 1) - a n)) = | |
| b N * a N - b 0 * a 0 - ∑ n ∈ range N, (b (n + 1) - b n) * a (n + 1) := by | |
| have heq (n : ℕ) : b n * (a (n + 1) - a n) = | |
| (b (n + 1) * a (n + 1) - b n * a n) - | |
| (b (n + 1) - b n) * a (n + 1) := by ring | |
| simp_rw [heq] | |
| rw [Finset.sum_sub_distrib, Finset.sum_range_sub (fun n => b n * a n)] | |
| theorem vertical_variation (b : ℕ → ℂ) (N : ℕ) | |
| (hre : ∀ n ≤ N, (b n).re = (b 0).re) | |
| (him : ∀ n < N, (b n).im ≤ (b (n + 1)).im) : | |
| (∑ n ∈ range N, ‖b (n + 1) - b n‖) = (b N).im - (b 0).im := by | |
| have hnorm (n : ℕ) (hn : n ∈ range N) : | |
| ‖b (n + 1) - b n‖ = (b (n + 1)).im - (b n).im := by | |
| have hn' := Finset.mem_range.mp hn | |
| rw [Complex.norm_eq_sqrt_sq_add_sq, Complex.sub_re, Complex.sub_im, | |
| hre (n + 1) (by omega), hre n (by omega), sub_self, zero_pow (by norm_num), zero_add, | |
| Real.sqrt_sq (sub_nonneg.mpr (him n hn'))] | |
| rw [Finset.sum_congr rfl hnorm] | |
| exact Finset.sum_range_sub (fun n => (b n).im) N | |
| theorem phase_sum_first_derivative {β : ℝ} (hβ : 0 < β) | |
| (f : ℕ → ℝ) (q : ℤ) (N : ℕ) | |
| (hlow : ∀ n ≤ N, β ≤ f (n + 1) - f n - q) | |
| (hupp : ∀ n ≤ N, f (n + 1) - f n - q ≤ 1 - β) | |
| (hmono : ∀ n < N, f (n + 1) - f n ≤ f (n + 2) - f (n + 1)) : | |
| ‖∑ n ∈ range N, phase (f n)‖ ≤ 1 / β := by | |
| let d (n : ℕ) : ℝ := f (n + 1) - f n - q | |
| let b (n : ℕ) : ℂ := (phase (d n) - 1)⁻¹ | |
| have hd0 (n : ℕ) (hn : n ≤ N) : 0 < d n := lt_of_lt_of_le hβ (hlow n hn) | |
| have hd1 (n : ℕ) (hn : n ≤ N) : d n < 1 := lt_of_le_of_lt (hupp n hn) (by linarith) | |
| have hb (n : ℕ) (hn : n ≤ N) : ‖b n‖ ≤ 1 / (4 * β) := by | |
| have hs := sin_pi_lower hβ.le (hlow n hn) (hupp n hn) | |
| have hnorm : 4 * β ≤ ‖phase (d n) - 1‖ := by | |
| rw [phase_sub_one_norm, abs_of_nonneg (by linarith : 0 ≤ Real.sin (Real.pi * d n))] | |
| linarith | |
| dsimp only [b] | |
| rw [norm_inv, ← one_div] | |
| exact one_div_le_one_div_of_le (by positivity) hnorm | |
| have hne (n : ℕ) (hn : n ≤ N) : phase (d n) - 1 ≠ 0 := by | |
| intro hh | |
| have hs := sin_pi_lower hβ.le (hlow n hn) (hupp n hn) | |
| have hn0 := phase_sub_one_norm (d n) | |
| rw [hh, norm_zero] at hn0 | |
| have habs := le_abs_self (Real.sin (Real.pi * d n)) | |
| linarith | |
| have hre (n : ℕ) (hn : n ≤ N) : (b n).re = (-1 / 2 : ℝ) := by | |
| dsimp only [b] | |
| rw [phase_increment_inv (hd0 n hn) (hd1 n hn)] | |
| simp only [Complex.sub_re, Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, | |
| Complex.I_re, Complex.I_im] | |
| norm_num | |
| have him (n : ℕ) (hn : n < N) : (b n).im ≤ (b (n + 1)).im := by | |
| apply phase_increment_im_mono ⟨hd0 n (by omega), hd1 n (by omega)⟩ | |
| ⟨hd0 (n + 1) (by omega), hd1 (n + 1) (by omega)⟩ | |
| dsimp [d] | |
| linarith [hmono n hn] | |
| have hrel (n : ℕ) (hn : n ∈ range N) : | |
| b n * (phase (f (n + 1)) - phase (f n)) = phase (f n) := by | |
| have heq : f (n + 1) = f n + d n + q := by dsimp [d]; ring | |
| rw [heq, phase_add, phase_add, phase_int, mul_one] | |
| dsimp only [b] | |
| rw [show phase (f n) * phase (d n) - phase (f n) = | |
| (phase (d n) - 1) * phase (f n) by ring, | |
| ← mul_assoc, inv_mul_cancel₀ (hne n (by simpa using (mem_range.mp hn).le)), one_mul] | |
| have heq := summation_by_parts_differences (fun n => phase (f n)) b N | |
| rw [Finset.sum_congr rfl hrel] at heq | |
| have hv := vertical_variation b N (fun n hn => (hre n hn).trans (hre 0 (by omega)).symm) him | |
| have hvle : (∑ n ∈ range N, ‖b (n + 1) - b n‖) ≤ 2 / (4 * β) := by | |
| rw [hv] | |
| have h1 := Complex.im_le_norm (b N) | |
| have h0 := Complex.abs_im_le_norm (b 0) | |
| have h0' := neg_le_abs (b 0).im | |
| have hadd : 1 / (4 * β) + 1 / (4 * β) = 2 / (4 * β) := by ring | |
| linarith [hb N le_rfl, hb 0 (by omega)] | |
| have hs : ‖∑ n ∈ range N, (b (n + 1) - b n) * phase (f (n + 1))‖ ≤ | |
| 2 / (4 * β) := by | |
| calc | |
| _ ≤ ∑ n ∈ range N, ‖(b (n + 1) - b n) * phase (f (n + 1))‖ := norm_sum_le _ _ | |
| _ = ∑ n ∈ range N, ‖b (n + 1) - b n‖ := by simp | |
| _ ≤ _ := hvle | |
| rw [heq] | |
| have hn := norm_sub_le (b N * phase (f N) - b 0 * phase (f 0)) | |
| (∑ n ∈ range N, (b (n + 1) - b n) * phase (f (n + 1))) | |
| have hn' := norm_sub_le (b N * phase (f N)) (b 0 * phase (f 0)) | |
| simp only [norm_mul, phase_norm, mul_one] at hn' | |
| have hsum : 1 / (4 * β) + 1 / (4 * β) + 2 / (4 * β) = 1 / β := by ring | |
| linarith [hb N le_rfl, hb 0 (by omega)] | |
| end ShortEgyptian | |
| end OAI | |
Xet Storage Details
- Size:
- 9.28 kB
- Xet hash:
- d8f7c11744cd2a45bdc616db90bd3a3bcd7058f4470c68d4699a6d1b8746e73d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.