File: Mathlib/RingTheory/Polynomial/Cyclotomic/Basic.lean

full_name: Polynomial.cyclotomic'
code: /-- The modified `n`-th cyclotomic polynomial with coefficients in `R`, it is the usual cyclotomic
polynomial if there is a primitive `n`-th root of unity in `R`. -/
def cyclotomic' (n : ℕ) (R : Type*) [CommRing R] [IsDomain R] : R[X] 
goal: R[X]

full_name: Polynomial.cyclotomic'_zero
code: /-- The zeroth modified cyclotomic polyomial is `1`. -/
@[simp]
theorem cyclotomic'_zero (R : Type*) [CommRing R] [IsDomain R] : cyclotomic' 0 R = 1 
goal: Polynomial.cyclotomic' 0 R = 1

full_name: Polynomial.cyclotomic'_one
code: /-- The first modified cyclotomic polyomial is `X - 1`. -/
@[simp]
theorem cyclotomic'_one (R : Type*) [CommRing R] [IsDomain R] : cyclotomic' 1 R = X - 1 
goal: Polynomial.cyclotomic' 1 R = Polynomial.X - 1

full_name: Polynomial.cyclotomic'_two
code: /-- The second modified cyclotomic polyomial is `X + 1` if the characteristic of `R` is not `2`. -/
@[simp]
theorem cyclotomic'_two (R : Type*) [CommRing R] [IsDomain R] (p : ℕ) [CharP R p] (hp : p ≠ 2) :
    cyclotomic' 2 R = X + 1 
goal: Polynomial.cyclotomic' 2 R = Polynomial.X + 1

full_name: Polynomial.cyclotomic'.monic
code: /-- `cyclotomic' n R` is monic. -/
theorem cyclotomic'.monic (n : ℕ) (R : Type*) [CommRing R] [IsDomain R] :
    (cyclotomic' n R).Monic 
goal: (Polynomial.cyclotomic' n R).Monic

full_name: Polynomial.cyclotomic'_ne_zero
code: /-- `cyclotomic' n R` is different from `0`. -/
theorem cyclotomic'_ne_zero (n : ℕ) (R : Type*) [CommRing R] [IsDomain R] : cyclotomic' n R ≠ 0 
goal: Polynomial.cyclotomic' n R ≠ 0

full_name: Polynomial.natDegree_cyclotomic'
code: /-- The natural degree of `cyclotomic' n R` is `totient n` if there is a primitive root of
unity in `R`. -/
theorem natDegree_cyclotomic' {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
    (cyclotomic' n R).natDegree = Nat.totient n 
goal: (Polynomial.cyclotomic' n R).natDegree = n.totient

full_name: Polynomial.degree_cyclotomic'
code: /-- The degree of `cyclotomic' n R` is `totient n` if there is a primitive root of unity in `R`. -/
theorem degree_cyclotomic' {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
    (cyclotomic' n R).degree = Nat.totient n 
goal: (Polynomial.cyclotomic' n R).degree = ↑n.totient

full_name: Polynomial.roots_of_cyclotomic
code: /-- The roots of `cyclotomic' n R` are the primitive `n`-th roots of unity. -/
theorem roots_of_cyclotomic (n : ℕ) (R : Type*) [CommRing R] [IsDomain R] :
    (cyclotomic' n R).roots = (primitiveRoots n R).val 
goal: (Polynomial.cyclotomic' n R).roots = (primitiveRoots n R).val

full_name: Polynomial.X_pow_sub_one_eq_prod
code: /-- If there is a primitive `n`th root of unity in `K`, then `X ^ n - 1 = ∏ (X - μ)`, where `μ`
varies over the `n`-th roots of unity. -/
theorem X_pow_sub_one_eq_prod {ζ : R} {n : ℕ} (hpos : 0 < n) (h : IsPrimitiveRoot ζ n) :
    X ^ n - 1 = ∏ ζ ∈ nthRootsFinset n R, (X - C ζ) 
goal: Polynomial.X ^ n - 1 = ∏ ζ ∈ Polynomial.nthRootsFinset n R, (Polynomial.X - Polynomial.C ζ)

full_name: Polynomial.cyclotomic'_splits
code: /-- `cyclotomic' n K` splits. -/
theorem cyclotomic'_splits (n : ℕ) : Splits (RingHom.id K) (cyclotomic' n K) 
goal: Polynomial.Splits (RingHom.id K) (Polynomial.cyclotomic' n K)

full_name: Polynomial.X_pow_sub_one_splits
code: /-- If there is a primitive `n`-th root of unity in `K`, then `X ^ n - 1` splits. -/
theorem X_pow_sub_one_splits {ζ : K} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
    Splits (RingHom.id K) (X ^ n - C (1 : K)) 
goal: Polynomial.Splits (RingHom.id K) (Polynomial.X ^ n - Polynomial.C 1)

full_name: Polynomial.prod_cyclotomic'_eq_X_pow_sub_one
code: /-- If there is a primitive `n`-th root of unity in `K`, then
`∏ i ∈ Nat.divisors n, cyclotomic' i K = X ^ n - 1`. -/
theorem prod_cyclotomic'_eq_X_pow_sub_one {K : Type*} [CommRing K] [IsDomain K] {ζ : K} {n : ℕ}
    (hpos : 0 < n) (h : IsPrimitiveRoot ζ n) :
    ∏ i ∈ Nat.divisors n, cyclotomic' i K = X ^ n - 1 
goal: ∏ i ∈ n.divisors, Polynomial.cyclotomic' i K = Polynomial.X ^ n - 1

full_name: Polynomial.cyclotomic'_eq_X_pow_sub_one_div
code: /-- If there is a primitive `n`-th root of unity in `K`, then
`cyclotomic' n K = (X ^ k - 1) /ₘ (∏ i ∈ Nat.properDivisors k, cyclotomic' i K)`. -/
theorem cyclotomic'_eq_X_pow_sub_one_div {K : Type*} [CommRing K] [IsDomain K] {ζ : K} {n : ℕ}
    (hpos : 0 < n) (h : IsPrimitiveRoot ζ n) :
    cyclotomic' n K = (X ^ n - 1) /ₘ ∏ i ∈ Nat.properDivisors n, cyclotomic' i K 
goal: Polynomial.cyclotomic' n K = (Polynomial.X ^ n - 1) /ₘ ∏ i ∈ n.properDivisors, Polynomial.cyclotomic' i K

full_name: Polynomial.int_coeff_of_cyclotomic'
code: /-- If there is a primitive `n`-th root of unity in `K`, then `cyclotomic' n K` comes from a
monic polynomial with integer coefficients. -/
theorem int_coeff_of_cyclotomic' {K : Type*} [CommRing K] [IsDomain K] {ζ : K} {n : ℕ}
    (h : IsPrimitiveRoot ζ n) : ∃ P : ℤ[X], map (Int.castRingHom K) P =
      cyclotomic' n K ∧ P.degree = (cyclotomic' n K).degree ∧ P.Monic 
goal: ∃ P,
  Polynomial.map (Int.castRingHom K) P = Polynomial.cyclotomic' n K ∧
    P.degree = (Polynomial.cyclotomic' n K).degree ∧ P.Monic

full_name: Polynomial.unique_int_coeff_of_cycl
code: /-- If `K` is of characteristic `0` and there is a primitive `n`-th root of unity in `K`,
then `cyclotomic n K` comes from a unique polynomial with integer coefficients. -/
theorem unique_int_coeff_of_cycl {K : Type*} [CommRing K] [IsDomain K] [CharZero K] {ζ : K}
    {n : ℕ+} (h : IsPrimitiveRoot ζ n) :
    ∃! P : ℤ[X], map (Int.castRingHom K) P = cyclotomic' n K 
goal: ∃! P, Polynomial.map (Int.castRingHom K) P = Polynomial.cyclotomic' (↑n) K

full_name: Polynomial.cyclotomic
code: /-- The `n`-th cyclotomic polynomial with coefficients in `R`. -/
def cyclotomic (n : ℕ) (R : Type*) [Ring R] : R[X] 
goal: R[X]

full_name: Polynomial.int_cyclotomic_rw
code: theorem int_cyclotomic_rw {n : ℕ} (h : n ≠ 0) :
    cyclotomic n ℤ = (int_coeff_of_cyclotomic' (Complex.isPrimitiveRoot_exp n h)).choose 
goal: Polynomial.cyclotomic n ℤ = ⋯.choose

full_name: Polynomial.map_cyclotomic_int
code: /-- `cyclotomic n R` comes from `cyclotomic n ℤ`. -/
theorem map_cyclotomic_int (n : ℕ) (R : Type*) [Ring R] :
    map (Int.castRingHom R) (cyclotomic n ℤ) = cyclotomic n R 
goal: Polynomial.map (Int.castRingHom R) (Polynomial.cyclotomic n ℤ) = Polynomial.cyclotomic n R

full_name: Polynomial.int_cyclotomic_spec
code: theorem int_cyclotomic_spec (n : ℕ) :
    map (Int.castRingHom ℂ) (cyclotomic n ℤ) = cyclotomic' n ℂ ∧
      (cyclotomic n ℤ).degree = (cyclotomic' n ℂ).degree ∧ (cyclotomic n ℤ).Monic 
goal: Polynomial.map (Int.castRingHom ℂ) (Polynomial.cyclotomic n ℤ) = Polynomial.cyclotomic' n ℂ ∧
  (Polynomial.cyclotomic n ℤ).degree = (Polynomial.cyclotomic' n ℂ).degree ∧ (Polynomial.cyclotomic n ℤ).Monic

full_name: Polynomial.int_cyclotomic_unique
code: theorem int_cyclotomic_unique {n : ℕ} {P : ℤ[X]} (h : map (Int.castRingHom ℂ) P = cyclotomic' n ℂ) :
    P = cyclotomic n ℤ 
goal: P = Polynomial.cyclotomic n ℤ

full_name: Polynomial.map_cyclotomic
code: /-- The definition of `cyclotomic n R` commutes with any ring homomorphism. -/
@[simp]
theorem map_cyclotomic (n : ℕ) {R S : Type*} [Ring R] [Ring S] (f : R →+* S) :
    map f (cyclotomic n R) = cyclotomic n S 
goal: Polynomial.map f (Polynomial.cyclotomic n R) = Polynomial.cyclotomic n S

full_name: Polynomial.cyclotomic.eval_apply
code: theorem cyclotomic.eval_apply {R S : Type*} (q : R) (n : ℕ) [Ring R] [Ring S] (f : R →+* S) :
    eval (f q) (cyclotomic n S) = f (eval q (cyclotomic n R)) 
goal: Polynomial.eval (f q) (Polynomial.cyclotomic n S) = f (Polynomial.eval q (Polynomial.cyclotomic n R))

full_name: Polynomial.cyclotomic_zero
code: /-- The zeroth cyclotomic polyomial is `1`. -/
@[simp]
theorem cyclotomic_zero (R : Type*) [Ring R] : cyclotomic 0 R = 1 
goal: Polynomial.cyclotomic 0 R = 1

full_name: Polynomial.cyclotomic_one
code: /-- The first cyclotomic polyomial is `X - 1`. -/
@[simp]
theorem cyclotomic_one (R : Type*) [Ring R] : cyclotomic 1 R = X - 1 
goal: Polynomial.cyclotomic 1 R = Polynomial.X - 1

full_name: Polynomial.cyclotomic.monic
code: /-- `cyclotomic n` is monic. -/
theorem cyclotomic.monic (n : ℕ) (R : Type*) [Ring R] : (cyclotomic n R).Monic 
goal: (Polynomial.cyclotomic n R).Monic

full_name: Polynomial.cyclotomic.isPrimitive
code: /-- `cyclotomic n` is primitive. -/
theorem cyclotomic.isPrimitive (n : ℕ) (R : Type*) [CommRing R] : (cyclotomic n R).IsPrimitive 
goal: (Polynomial.cyclotomic n R).IsPrimitive

full_name: Polynomial.cyclotomic_ne_zero
code: /-- `cyclotomic n R` is different from `0`. -/
theorem cyclotomic_ne_zero (n : ℕ) (R : Type*) [Ring R] [Nontrivial R] : cyclotomic n R ≠ 0 
goal: Polynomial.cyclotomic n R ≠ 0

full_name: Polynomial.degree_cyclotomic
code: /-- The degree of `cyclotomic n` is `totient n`. -/
theorem degree_cyclotomic (n : ℕ) (R : Type*) [Ring R] [Nontrivial R] :
    (cyclotomic n R).degree = Nat.totient n 
goal: (Polynomial.cyclotomic n R).degree = ↑n.totient

full_name: Polynomial.natDegree_cyclotomic
code: /-- The natural degree of `cyclotomic n` is `totient n`. -/
theorem natDegree_cyclotomic (n : ℕ) (R : Type*) [Ring R] [Nontrivial R] :
    (cyclotomic n R).natDegree = Nat.totient n 
goal: (Polynomial.cyclotomic n R).natDegree = n.totient

full_name: Polynomial.degree_cyclotomic_pos
code: /-- The degree of `cyclotomic n R` is positive. -/
theorem degree_cyclotomic_pos (n : ℕ) (R : Type*) (hpos : 0 < n) [Ring R] [Nontrivial R] :
    0 < (cyclotomic n R).degree 
goal: 0 < (Polynomial.cyclotomic n R).degree

full_name: Polynomial.prod_cyclotomic_eq_X_pow_sub_one
code: /-- `∏ i ∈ Nat.divisors n, cyclotomic i R = X ^ n - 1`. -/
theorem prod_cyclotomic_eq_X_pow_sub_one {n : ℕ} (hpos : 0 < n) (R : Type*) [CommRing R] :
    ∏ i ∈ Nat.divisors n, cyclotomic i R = X ^ n - 1 
goal: ∏ i ∈ n.divisors, Polynomial.cyclotomic i R = Polynomial.X ^ n - 1

full_name: Polynomial.cyclotomic.dvd_X_pow_sub_one
code: theorem cyclotomic.dvd_X_pow_sub_one (n : ℕ) (R : Type*) [Ring R] :
    cyclotomic n R ∣ X ^ n - 1 
goal: Polynomial.cyclotomic n R ∣ Polynomial.X ^ n - 1

full_name: Polynomial.prod_cyclotomic_eq_geom_sum
code: theorem prod_cyclotomic_eq_geom_sum {n : ℕ} (h : 0 < n) (R) [CommRing R] :
    ∏ i ∈ n.divisors.erase 1, cyclotomic i R = ∑ i ∈ Finset.range n, X ^ i 
goal: ∏ i ∈ n.divisors.erase 1, Polynomial.cyclotomic i R = ∑ i ∈ Finset.range n, Polynomial.X ^ i

full_name: Polynomial.cyclotomic_prime
code: /-- If `p` is prime, then `cyclotomic p R = ∑ i ∈ range p, X ^ i`. -/
theorem cyclotomic_prime (R : Type*) [Ring R] (p : ℕ) [hp : Fact p.Prime] :
    cyclotomic p R = ∑ i ∈ Finset.range p, X ^ i 
goal: Polynomial.cyclotomic p R = ∑ i ∈ Finset.range p, Polynomial.X ^ i

full_name: Polynomial.cyclotomic_prime_mul_X_sub_one
code: theorem cyclotomic_prime_mul_X_sub_one (R : Type*) [Ring R] (p : ℕ) [hn : Fact (Nat.Prime p)] :
    cyclotomic p R * (X - 1) = X ^ p - 1 
goal: Polynomial.cyclotomic p R * (Polynomial.X - 1) = Polynomial.X ^ p - 1

full_name: Polynomial.cyclotomic_two
code: @[simp]
theorem cyclotomic_two (R : Type*) [Ring R] : cyclotomic 2 R = X + 1 
goal: Polynomial.cyclotomic 2 R = Polynomial.X + 1

full_name: Polynomial.cyclotomic_three
code: @[simp]
theorem cyclotomic_three (R : Type*) [Ring R] : cyclotomic 3 R = X ^ 2 + X + 1 
goal: Polynomial.cyclotomic 3 R = Polynomial.X ^ 2 + Polynomial.X + 1

full_name: Polynomial.cyclotomic_dvd_geom_sum_of_dvd
code: theorem cyclotomic_dvd_geom_sum_of_dvd (R) [Ring R] {d n : ℕ} (hdn : d ∣ n) (hd : d ≠ 1) :
    cyclotomic d R ∣ ∑ i ∈ Finset.range n, X ^ i 
goal: Polynomial.cyclotomic d R ∣ ∑ i ∈ Finset.range n, Polynomial.X ^ i

full_name: Polynomial.X_pow_sub_one_mul_prod_cyclotomic_eq_X_pow_sub_one_of_dvd
code: theorem X_pow_sub_one_mul_prod_cyclotomic_eq_X_pow_sub_one_of_dvd (R) [CommRing R] {d n : ℕ}
    (h : d ∈ n.properDivisors) :
    ((X ^ d - 1) * ∏ x ∈ n.divisors \ d.divisors, cyclotomic x R) = X ^ n - 1 
goal: (Polynomial.X ^ d - 1) * ∏ x ∈ n.divisors \ d.divisors, Polynomial.cyclotomic x R = Polynomial.X ^ n - 1

full_name: Polynomial.X_pow_sub_one_mul_cyclotomic_dvd_X_pow_sub_one_of_dvd
code: theorem X_pow_sub_one_mul_cyclotomic_dvd_X_pow_sub_one_of_dvd (R) [CommRing R] {d n : ℕ}
    (h : d ∈ n.properDivisors) : (X ^ d - 1) * cyclotomic n R ∣ X ^ n - 1 
goal: (Polynomial.X ^ d - 1) * Polynomial.cyclotomic n R ∣ Polynomial.X ^ n - 1

full_name: Polynomial.cyclotomic_eq_prod_X_pow_sub_one_pow_moebius
code: /-- `cyclotomic n R` can be expressed as a product in a fraction field of `R[X]`
  using Möbius inversion. -/
theorem cyclotomic_eq_prod_X_pow_sub_one_pow_moebius {n : ℕ} (R : Type*) [CommRing R]
    [IsDomain R] : algebraMap _ (RatFunc R) (cyclotomic n R) =
      ∏ i ∈ n.divisorsAntidiagonal, algebraMap R[X] _ (X ^ i.snd - 1) ^ μ i.fst 
goal: (algebraMap R[X] (RatFunc R)) (Polynomial.cyclotomic n R) =
  ∏ i ∈ n.divisorsAntidiagonal, (algebraMap R[X] (RatFunc R)) (Polynomial.X ^ i.2 - 1) ^ ArithmeticFunction.moebius i.1

full_name: Polynomial.cyclotomic_eq_X_pow_sub_one_div
code: /-- We have
`cyclotomic n R = (X ^ k - 1) /ₘ (∏ i ∈ Nat.properDivisors k, cyclotomic i K)`. -/
theorem cyclotomic_eq_X_pow_sub_one_div {R : Type*} [CommRing R] {n : ℕ} (hpos : 0 < n) :
    cyclotomic n R = (X ^ n - 1) /ₘ ∏ i ∈ Nat.properDivisors n, cyclotomic i R 
goal: Polynomial.cyclotomic n R = (Polynomial.X ^ n - 1) /ₘ ∏ i ∈ n.properDivisors, Polynomial.cyclotomic i R

full_name: Polynomial.X_pow_sub_one_dvd_prod_cyclotomic
code: /-- If `m` is a proper divisor of `n`, then `X ^ m - 1` divides
`∏ i ∈ Nat.properDivisors n, cyclotomic i R`. -/
theorem X_pow_sub_one_dvd_prod_cyclotomic (R : Type*) [CommRing R] {n m : ℕ} (hpos : 0 < n)
    (hm : m ∣ n) (hdiff : m ≠ n) : X ^ m - 1 ∣ ∏ i ∈ Nat.properDivisors n, cyclotomic i R 
goal: Polynomial.X ^ m - 1 ∣ ∏ i ∈ n.properDivisors, Polynomial.cyclotomic i R

full_name: Polynomial.cyclotomic_eq_prod_X_sub_primitiveRoots
code: /-- If there is a primitive `n`-th root of unity in `K`, then
`cyclotomic n K = ∏ μ ∈ primitiveRoots n K, (X - C μ)`. ∈ particular,
`cyclotomic n K = cyclotomic' n K` -/
theorem cyclotomic_eq_prod_X_sub_primitiveRoots {K : Type*} [CommRing K] [IsDomain K] {ζ : K}
    {n : ℕ} (hz : IsPrimitiveRoot ζ n) : cyclotomic n K = ∏ μ ∈ primitiveRoots n K, (X - C μ) 
goal: Polynomial.cyclotomic n K = ∏ μ ∈ primitiveRoots n K, (Polynomial.X - Polynomial.C μ)

full_name: Polynomial.eq_cyclotomic_iff
code: theorem eq_cyclotomic_iff {R : Type*} [CommRing R] {n : ℕ} (hpos : 0 < n) (P : R[X]) :
    P = cyclotomic n R ↔
    (P * ∏ i ∈ Nat.properDivisors n, Polynomial.cyclotomic i R) = X ^ n - 1 
goal: P = Polynomial.cyclotomic n R ↔ P * ∏ i ∈ n.properDivisors, Polynomial.cyclotomic i R = Polynomial.X ^ n - 1

full_name: Polynomial.cyclotomic_prime_pow_eq_geom_sum
code: /-- If `p ^ k` is a prime power, then
`cyclotomic (p ^ (n + 1)) R = ∑ i ∈ range p, (X ^ (p ^ n)) ^ i`. -/
theorem cyclotomic_prime_pow_eq_geom_sum {R : Type*} [CommRing R] {p n : ℕ} (hp : p.Prime) :
    cyclotomic (p ^ (n + 1)) R = ∑ i ∈ Finset.range p, (X ^ p ^ n) ^ i 
goal: Polynomial.cyclotomic (p ^ (n + 1)) R = ∑ i ∈ Finset.range p, (Polynomial.X ^ p ^ n) ^ i

full_name: Polynomial.cyclotomic_prime_pow_mul_X_pow_sub_one
code: theorem cyclotomic_prime_pow_mul_X_pow_sub_one (R : Type*) [CommRing R] (p k : ℕ)
    [hn : Fact (Nat.Prime p)] :
    cyclotomic (p ^ (k + 1)) R * (X ^ p ^ k - 1) = X ^ p ^ (k + 1) - 1 
goal: Polynomial.cyclotomic (p ^ (k + 1)) R * (Polynomial.X ^ p ^ k - 1) = Polynomial.X ^ p ^ (k + 1) - 1

full_name: Polynomial.cyclotomic_coeff_zero
code: /-- The constant term of `cyclotomic n R` is `1` if `2 ≤ n`. -/
theorem cyclotomic_coeff_zero (R : Type*) [CommRing R] {n : ℕ} (hn : 1 < n) :
    (cyclotomic n R).coeff 0 = 1 
goal: (Polynomial.cyclotomic n R).coeff 0 = 1

full_name: Polynomial.coprime_of_root_cyclotomic
code: /-- If `(a : ℕ)` is a root of `cyclotomic n (ZMod p)`, where `p` is a prime, then `a` and `p` are
coprime. -/
theorem coprime_of_root_cyclotomic {n : ℕ} (hpos : 0 < n) {p : ℕ} [hprime : Fact p.Prime] {a : ℕ}
    (hroot : IsRoot (cyclotomic n (ZMod p)) (Nat.castRingHom (ZMod p) a)) : a.Coprime p 
goal: a.Coprime p

full_name: Polynomial.orderOf_root_cyclotomic_dvd
code: /-- If `(a : ℕ)` is a root of `cyclotomic n (ZMod p)`, then the multiplicative order of `a` modulo
`p` divides `n`. -/
theorem orderOf_root_cyclotomic_dvd {n : ℕ} (hpos : 0 < n) {p : ℕ} [Fact p.Prime] {a : ℕ}
    (hroot : IsRoot (cyclotomic n (ZMod p)) (Nat.castRingHom (ZMod p) a)) :
    orderOf (ZMod.unitOfCoprime a (coprime_of_root_cyclotomic hpos hroot)) ∣ n 
goal: orderOf (ZMod.unitOfCoprime a ⋯) ∣ n