Lean / Reader
Lean readerRectRoots.lean
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.
import SineFoldimport Mathlib.RingTheory.Polynomial.Cyclotomic.Rootsnamespace ErdosPolynomialopen Real Finsetnoncomputable def rectangle (A B : ℕ) (z : ℂ) : ℂ :=∑ i ∈ range (A+1), ∑ j ∈ range (B+1), z^(i*j)theorem rectangle_comm (a b : ℕ) (z : ℂ) : rectangle a b z=rectangle b a z := byunfold rectanglerw [sum_comm]simp_rw [Nat.mul_comm]theorem rectangle_im (a b : ℕ) (θ : ℝ) :(rectangle a b (Complex.exp ((θ:ℂ)*Complex.I))).im=rect a b θ := byhave imag (i j : ℕ) : ((Complex.exp ((θ:ℂ)*Complex.I))^(i*j)).im=sin ((j:ℝ)*((i:ℝ)*θ)) := byrw [←Complex.exp_nat_mul,show ((i*j:ℕ):ℂ)*((θ:ℂ)*Complex.I)=(((j:ℝ)*((i:ℝ)*θ):ℝ):ℂ)*Complex.I by push_cast;ring,Complex.exp_ofReal_mul_I_im]unfold rectangle rect sineRowrw [Complex.im_sum]simp_rw [Complex.im_sum,imag]rw [Finset.sum_range_succ']simp only [Nat.cast_zero,zero_mul,mul_zero,sin_zero,Finset.sum_const_zero,add_zero]apply Finset.sum_congr rflintro i hirw [Finset.sum_range_succ']simpprivate theorem full_boundary (m a b : ℕ) (hm : 0<m) (z : ℂ) (order : z^m=1)(boundary : foldSide m b=0) : 0 < (rectangle a b z).re := byhave modlt := Nat.mod_lt b hmhave bd : b%m=0 ∨ b%m=m-1 := by unfold foldSide at boundary;omegahave cap : ∃ q, b+1=m*q ∨ b+1=m*q+1 := byhave div := Nat.mod_add_div b mrcases bd with h|h· exact ⟨b/m,Or.inr (by omega)⟩· exact ⟨b/m+1,Or.inl (by rw [Nat.mul_add,Nat.mul_one];omega)⟩obtain ⟨q,hq⟩ := caphave row (i : ℕ) : 0 ≤ (∑ j ∈ range (b+1),z^(i*j)).re := bysimp_rw [pow_mul]let x:=z^ichange 0 ≤ (∑ j ∈ range (b+1),x^j).reby_cases one : x=1· simp [one];positivityhave xm : x^m=1 := by unfold x;rw [←pow_mul,Nat.mul_comm,pow_mul,order,one_pow]have fact := geom_sum_mul x (b+1)have xn : x^(m*q)=1 := by rw [pow_mul,xm,one_pow]rcases hq with hq|hq· rw [hq,xn,sub_self] at facthave zero := (mul_eq_zero.mp fact).resolve_right (sub_ne_zero.mpr one)simp [hq,zero]· rw [hq,pow_succ,xn,one_mul] at facthave val : (∑ j ∈ range (m*q+1), x^j)=1 := mul_right_cancel₀ (sub_ne_zero.mpr one) (fact.trans (one_mul _).symm)simp [hq,val]unfold rectanglerw [Complex.re_sum]apply Finset.sum_pos' (fun i _ => row i)exact ⟨0,by simp,by simp; positivity⟩theorem rectangle_nonzero (a b m : ℕ) (hm : 0<m) :rectangle a b (Complex.exp (2*π*Complex.I/(m:ℂ))) ≠ 0 := bylet θ : ℝ := 2*π/mlet z := Complex.exp (2*π*Complex.I/(m:ℂ))have root : z^m=1 := (Complex.isPrimitiveRoot_exp m hm.ne').pow_eq_onehave from_re (c d : ℕ) (hd : foldSide m d=0) : rectangle c d z ≠ 0 := byhave positive:=full_boundary m c d hm z root hdrintro hsimp [h] at positiveby_cases lowa : foldSide m a=0· change rectangle a b z ≠ 0rw [rectangle_comm];exact from_re b a lowaby_cases lowb : foldSide m b=0· exact from_re a b lowbhave mp : (0:ℝ)<m := by exact_mod_cast hmhave abound:=fold_bound (a:=a) hmhave bbound:=fold_bound (a:=b) hmhave highm : (2:ℝ)<m := by exact_mod_cast (show 2<m by omega)have per : (m:ℝ)*θ=2*π := by dsimp [θ];field_simphave zθ : z=Complex.exp ((θ:ℂ)*Complex.I) := by dsimp [z,θ];push_cast;congr 1;ringhave rhs : 0<rect (foldSide m a) (foldSide m b) θ := byapply 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)· dsimp [θ];rw [←mul_div_assoc]; apply (div_le_iff₀ mp).mprhave aa : (2:ℝ)*(foldSide m a:ℕ)≤m := by exact_mod_cast abound.lenlinarith [mul_le_mul_of_nonneg_right aa Real.pi_pos.le]· dsimp [θ];rw [←mul_div_assoc]; apply (div_le_iff₀ mp).mprhave bb : (2:ℝ)*(foldSide m b:ℕ)≤m := by exact_mod_cast bbound.lenlinarith [mul_le_mul_of_nonneg_right bb Real.pi_pos.le]have high : 0<(rectangle a b z).im := by rw [zθ,rectangle_im,rect_fold a b m hm θ per];exact rhsintro hzchange rectangle a b z=0 at hzsimp [hz] at highnoncomputable def rectPoly (a b : ℕ) : Polynomial ℚ :=∑ i ∈ range (a+1), ∑ j ∈ range (b+1), Polynomial.X^(i*j)theorem no_cyclotomic_factor (a b m : ℕ) (hm : 0<m) : ¬Polynomial.cyclotomic m ℚ ∣ rectPoly a b := bylet z:=Complex.exp (2*π*Complex.I/(m:ℂ))have prim : IsPrimitiveRoot z m := Complex.isPrimitiveRoot_exp m hm.ne'have eq : Polynomial.aeval z (rectPoly a b)=rectangle a b z := by simp [rectPoly,rectangle]rintro ⟨g,e⟩have zero : Polynomial.aeval z (Polynomial.cyclotomic m ℚ)=0 := byrw [Polynomial.aeval_def,Polynomial.eval₂_eq_eval_map,Polynomial.map_cyclotomic,←Polynomial.IsRoot.def]exact prim.isRoot_cyclotomic hmexact rectangle_nonzero a b m hm (by rw [←eq,e,map_mul,zero,zero_mul])#print axioms rectangle_nonzero#print axioms no_cyclotomic_factorend ErdosPolynomial