Lean / Reader
Lean reader

RectRoots.lean

108 lines7 declarationsno sorryimports SineFold Mathlib.RingTheory.Polynomial.Cyclotomic.Roots

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

  1. import SineFold
  2. import Mathlib.RingTheory.Polynomial.Cyclotomic.Roots
  3. namespace ErdosPolynomial
  4. open Real Finset
  5. noncomputable def rectangle (A B : ℕ) (z : ℂ) : ℂ :=
  6. ∑ i ∈ range (A+1), ∑ j ∈ range (B+1), z^(i*j)
  7. theorem rectangle_comm (a b : ℕ) (z : ℂ) : rectangle a b z=rectangle b a z := by
  8. unfold rectangle
  9. rw [sum_comm]
  10. simp_rw [Nat.mul_comm]
  11. theorem rectangle_im (a b : ℕ) (θ : ℝ) :
  12. (rectangle a b (Complex.exp ((θ:ℂ)*Complex.I))).im=rect a b θ := by
  13. have imag (i j : ℕ) : ((Complex.exp ((θ:ℂ)*Complex.I))^(i*j)).im=sin ((j:ℝ)*((i:ℝ)*θ)) := by
  14. rw [←Complex.exp_nat_mul,show ((i*j:ℕ):ℂ)*((θ:ℂ)*Complex.I)=(((j:ℝ)*((i:ℝ)*θ):ℝ):ℂ)*Complex.I by push_cast;ring,Complex.exp_ofReal_mul_I_im]
  15. unfold rectangle rect sineRow
  16. rw [Complex.im_sum]
  17. simp_rw [Complex.im_sum,imag]
  18. rw [Finset.sum_range_succ']
  19. simp only [Nat.cast_zero,zero_mul,mul_zero,sin_zero,Finset.sum_const_zero,add_zero]
  20. apply Finset.sum_congr rfl
  21. intro i hi
  22. rw [Finset.sum_range_succ']
  23. simp
  24. private theorem full_boundary (m a b : ℕ) (hm : 0<m) (z : ℂ) (order : z^m=1)
  25. (boundary : foldSide m b=0) : 0 < (rectangle a b z).re := by
  26. have modlt := Nat.mod_lt b hm
  27. have bd : b%m=0 ∨ b%m=m-1 := by unfold foldSide at boundary;omega
  28. have cap : ∃ q, b+1=m*q ∨ b+1=m*q+1 := by
  29. have div := Nat.mod_add_div b m
  30. rcases bd with h|h
  31. · exact ⟨b/m,Or.inr (by omega)⟩
  32. · exact ⟨b/m+1,Or.inl (by rw [Nat.mul_add,Nat.mul_one];omega)⟩
  33. obtain ⟨q,hq⟩ := cap
  34. have row (i : ℕ) : 0 ≤ (∑ j ∈ range (b+1),z^(i*j)).re := by
  35. simp_rw [pow_mul]
  36. let x:=z^i
  37. change 0 ≤ (∑ j ∈ range (b+1),x^j).re
  38. by_cases one : x=1
  39. · simp [one];positivity
  40. have xm : x^m=1 := by unfold x;rw [←pow_mul,Nat.mul_comm,pow_mul,order,one_pow]
  41. have fact := geom_sum_mul x (b+1)
  42. have xn : x^(m*q)=1 := by rw [pow_mul,xm,one_pow]
  43. rcases hq with hq|hq
  44. · rw [hq,xn,sub_self] at fact
  45. have zero := (mul_eq_zero.mp fact).resolve_right (sub_ne_zero.mpr one)
  46. simp [hq,zero]
  47. · rw [hq,pow_succ,xn,one_mul] at fact
  48. have val : (∑ j ∈ range (m*q+1), x^j)=1 := mul_right_cancel₀ (sub_ne_zero.mpr one) (fact.trans (one_mul _).symm)
  49. simp [hq,val]
  50. unfold rectangle
  51. rw [Complex.re_sum]
  52. apply Finset.sum_pos' (fun i _ => row i)
  53. exact ⟨0,by simp,by simp; positivity⟩
  54. theorem rectangle_nonzero (a b m : ℕ) (hm : 0<m) :
  55. rectangle a b (Complex.exp (2*π*Complex.I/(m:ℂ))) ≠ 0 := by
  56. let θ : ℝ := 2*π/m
  57. let z := Complex.exp (2*π*Complex.I/(m:ℂ))
  58. have root : z^m=1 := (Complex.isPrimitiveRoot_exp m hm.ne').pow_eq_one
  59. have from_re (c d : ℕ) (hd : foldSide m d=0) : rectangle c d z ≠ 0 := by
  60. have positive:=full_boundary m c d hm z root hd
  61. rintro h
  62. simp [h] at positive
  63. by_cases lowa : foldSide m a=0
  64. · change rectangle a b z ≠ 0
  65. rw [rectangle_comm];exact from_re b a lowa
  66. by_cases lowb : foldSide m b=0
  67. · exact from_re a b lowb
  68. have mp : (0:ℝ)<m := by exact_mod_cast hm
  69. have abound:=fold_bound (a:=a) hm
  70. have bbound:=fold_bound (a:=b) hm
  71. have highm : (2:ℝ)<m := by exact_mod_cast (show 2<m by omega)
  72. have per : (m:ℝ)*θ=2*π := by dsimp [θ];field_simp
  73. have zθ : z=Complex.exp ((θ:ℂ)*Complex.I) := by dsimp [z,θ];push_cast;congr 1;ring
  74. have rhs : 0<rect (foldSide m a) (foldSide m b) θ := by
  75. apply rect_pos (θ:=θ) _ _ (by dsimp [θ];positivity) ((div_lt_iff₀ mp).mpr (by nlinarith [mul_lt_mul_of_pos_right highm Real.pi_pos])) (by omega) (by omega)
  76. · dsimp [θ];rw [←mul_div_assoc]; apply (div_le_iff₀ mp).mpr
  77. have aa : (2:ℝ)*(foldSide m a:ℕ)≤m := by exact_mod_cast abound.le
  78. nlinarith [mul_le_mul_of_nonneg_right aa Real.pi_pos.le]
  79. · dsimp [θ];rw [←mul_div_assoc]; apply (div_le_iff₀ mp).mpr
  80. have bb : (2:ℝ)*(foldSide m b:ℕ)≤m := by exact_mod_cast bbound.le
  81. nlinarith [mul_le_mul_of_nonneg_right bb Real.pi_pos.le]
  82. have high : 0<(rectangle a b z).im := by rw [zθ,rectangle_im,rect_fold a b m hm θ per];exact rhs
  83. intro hz
  84. change rectangle a b z=0 at hz
  85. simp [hz] at high
  86. noncomputable def rectPoly (a b : ℕ) : Polynomial ℚ :=
  87. ∑ i ∈ range (a+1), ∑ j ∈ range (b+1), Polynomial.X^(i*j)
  88. theorem no_cyclotomic_factor (a b m : ℕ) (hm : 0<m) : ¬Polynomial.cyclotomic m ℚ ∣ rectPoly a b := by
  89. let z:=Complex.exp (2*π*Complex.I/(m:ℂ))
  90. have prim : IsPrimitiveRoot z m := Complex.isPrimitiveRoot_exp m hm.ne'
  91. have eq : Polynomial.aeval z (rectPoly a b)=rectangle a b z := by simp [rectPoly,rectangle]
  92. rintro ⟨g,e⟩
  93. have zero : Polynomial.aeval z (Polynomial.cyclotomic m ℚ)=0 := by
  94. rw [Polynomial.aeval_def,Polynomial.eval₂_eq_eval_map,Polynomial.map_cyclotomic,←Polynomial.IsRoot.def]
  95. exact prim.isRoot_cyclotomic hm
  96. exact rectangle_nonzero a b m hm (by rw [←eq,e,map_mul,zero,zero_mul])
  97. #print axioms rectangle_nonzero
  98. #print axioms no_cyclotomic_factor
  99. end ErdosPolynomial