l3lab/ntp-mathlib huggingface dataset:
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · 

Proof state:
case pos
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
⊢ NeZero ↑↑n

Next tactic:
obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    

Proof state:
case pos.intro
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k✝ l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
k : ℕ
hk : Part.get (multiplicity p ↑n) hfin = Nat.succ k
⊢ NeZero ↑↑n

Next tactic:
haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
    

Proof state:
case pos.intro
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k✝ l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
k : ℕ
hk : Part.get (multiplicity p ↑n) hfin = Nat.succ k
this : NeZero p
⊢ NeZero ↑↑n

Next tactic:
haveI hpri : Fact p.Prime := CharP.char_is_prime_of_pos R p
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
    haveI hpri : Fact p.Prime := CharP.char_is_prime_of_pos R p
    

Proof state:
case pos.intro
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k✝ l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
k : ℕ
hk : Part.get (multiplicity p ↑n) hfin = Nat.succ k
this : NeZero p
hpri : Fact (Nat.Prime p)
⊢ NeZero ↑↑n

Next tactic:
have := hζ.pow_eq_one
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
    haveI hpri : Fact p.Prime := CharP.char_is_prime_of_pos R p
    have := hζ.pow_eq_one
    

Proof state:
case pos.intro
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k✝ l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
k : ℕ
hk : Part.get (multiplicity p ↑n) hfin = Nat.succ k
this✝ : NeZero p
hpri : Fact (Nat.Prime p)
this : ζ ^ ↑n = 1
⊢ NeZero ↑↑n

Next tactic:
rw [hm.1, hk, pow_succ, mul_assoc, pow_mul', ← frobenius_def, ← frobenius_one p] at this
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
    haveI hpri : Fact p.Prime := CharP.char_is_prime_of_pos R p
    have := hζ.pow_eq_one
    rw [hm.1, hk, pow_succ, mul_assoc, pow_mul', ← frobenius_def, ← frobenius_one p] at this
    

Proof state:
case pos.intro
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k✝ l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
k : ℕ
hk : Part.get (multiplicity p ↑n) hfin = Nat.succ k
this✝ : NeZero p
hpri : Fact (Nat.Prime p)
this : (frobenius R p) (ζ ^ (p ^ k * m)) = (frobenius R p) 1
⊢ NeZero ↑↑n

Next tactic:
exfalso
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
    haveI hpri : Fact p.Prime := CharP.char_is_prime_of_pos R p
    have := hζ.pow_eq_one
    rw [hm.1, hk, pow_succ, mul_assoc, pow_mul', ← frobenius_def, ← frobenius_one p] at this
    exfalso
    

Proof state:
case pos.intro.h
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k✝ l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
k : ℕ
hk : Part.get (multiplicity p ↑n) hfin = Nat.succ k
this✝ : NeZero p
hpri : Fact (Nat.Prime p)
this : (frobenius R p) (ζ ^ (p ^ k * m)) = (frobenius R p) 1
⊢ False

Next tactic:
have hpos : 0 < p ^ k * m := by
      refine' mul_pos (pow_pos hpri.1.pos _) (Nat.pos_of_ne_zero fun h => _)
      have H := hm.1
      rw [h] at H
      simp at H
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
    haveI hpri : Fact p.Prime := CharP.char_is_prime_of_pos R p
    have := hζ.pow_eq_one
    rw [hm.1, hk, pow_succ, mul_assoc, pow_mul', ← frobenius_def, ← frobenius_one p] at this
    exfalso
    have hpos : 0 < p ^ k * m := by
      

Proof state:
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k✝ l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
k : ℕ
hk : Part.get (multiplicity p ↑n) hfin = Nat.succ k
this✝ : NeZero p
hpri : Fact (Nat.Prime p)
this : (frobenius R p) (ζ ^ (p ^ k * m)) = (frobenius R p) 1
⊢ 0 < p ^ k * m

Next tactic:
refine' mul_pos (pow_pos hpri.1.pos _) (Nat.pos_of_ne_zero fun h => _)
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
    haveI hpri : Fact p.Prime := CharP.char_is_prime_of_pos R p
    have := hζ.pow_eq_one
    rw [hm.1, hk, pow_succ, mul_assoc, pow_mul', ← frobenius_def, ← frobenius_one p] at this
    exfalso
    have hpos : 0 < p ^ k * m := by
      refine' mul_pos (pow_pos hpri.1.pos _) (Nat.pos_of_ne_zero fun h => _)
      

Proof state:
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k✝ l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
k : ℕ
hk : Part.get (multiplicity p ↑n) hfin = Nat.succ k
this✝ : NeZero p
hpri : Fact (Nat.Prime p)
this : (frobenius R p) (ζ ^ (p ^ k * m)) = (frobenius R p) 1
h : m = 0
⊢ False

Next tactic:
have H := hm.1
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
    haveI hpri : Fact p.Prime := CharP.char_is_prime_of_pos R p
    have := hζ.pow_eq_one
    rw [hm.1, hk, pow_succ, mul_assoc, pow_mul', ← frobenius_def, ← frobenius_one p] at this
    exfalso
    have hpos : 0 < p ^ k * m := by
      refine' mul_pos (pow_pos hpri.1.pos _) (Nat.pos_of_ne_zero fun h => _)
      have H := hm.1
      

Proof state:
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k✝ l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
k : ℕ
hk : Part.get (multiplicity p ↑n) hfin = Nat.succ k
this✝ : NeZero p
hpri : Fact (Nat.Prime p)
this : (frobenius R p) (ζ ^ (p ^ k * m)) = (frobenius R p) 1
h : m = 0
H : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m
⊢ False

Next tactic:
rw [h] at H
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
    haveI hpri : Fact p.Prime := CharP.char_is_prime_of_pos R p
    have := hζ.pow_eq_one
    rw [hm.1, hk, pow_succ, mul_assoc, pow_mul', ← frobenius_def, ← frobenius_one p] at this
    exfalso
    have hpos : 0 < p ^ k * m := by
      refine' mul_pos (pow_pos hpri.1.pos _) (Nat.pos_of_ne_zero fun h => _)
      have H := hm.1
      rw [h] at H
      

Proof state:
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k✝ l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
k : ℕ
hk : Part.get (multiplicity p ↑n) hfin = Nat.succ k
this✝ : NeZero p
hpri : Fact (Nat.Prime p)
this : (frobenius R p) (ζ ^ (p ^ k * m)) = (frobenius R p) 1
h : m = 0
H : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * 0
⊢ False

Next tactic:
simp at H
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
    haveI hpri : Fact p.Prime := CharP.char_is_prime_of_pos R p
    have := hζ.pow_eq_one
    rw [hm.1, hk, pow_succ, mul_assoc, pow_mul', ← frobenius_def, ← frobenius_one p] at this
    exfalso
    have hpos : 0 < p ^ k * m := by
      refine' mul_pos (pow_pos hpri.1.pos _) (Nat.pos_of_ne_zero fun h => _)
      have H := hm.1
      rw [h] at H
      simp at H
    

Proof state:
case pos.intro.h
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k✝ l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
k : ℕ
hk : Part.get (multiplicity p ↑n) hfin = Nat.succ k
this✝ : NeZero p
hpri : Fact (Nat.Prime p)
this : (frobenius R p) (ζ ^ (p ^ k * m)) = (frobenius R p) 1
hpos : 0 < p ^ k * m
⊢ False

Next tactic:
refine' hζ.pow_ne_one_of_pos_of_lt hpos _ (frobenius_inj R p this)
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
    haveI hpri : Fact p.Prime := CharP.char_is_prime_of_pos R p
    have := hζ.pow_eq_one
    rw [hm.1, hk, pow_succ, mul_assoc, pow_mul', ← frobenius_def, ← frobenius_one p] at this
    exfalso
    have hpos : 0 < p ^ k * m := by
      refine' mul_pos (pow_pos hpri.1.pos _) (Nat.pos_of_ne_zero fun h => _)
      have H := hm.1
      rw [h] at H
      simp at H
    refine' hζ.pow_ne_one_of_pos_of_lt hpos _ (frobenius_inj R p this)
    · 

Proof state:
case pos.intro.h
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k✝ l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
k : ℕ
hk : Part.get (multiplicity p ↑n) hfin = Nat.succ k
this✝ : NeZero p
hpri : Fact (Nat.Prime p)
this : (frobenius R p) (ζ ^ (p ^ k * m)) = (frobenius R p) 1
hpos : 0 < p ^ k * m
⊢ p ^ k * m < ↑n

Next tactic:
rw [hm.1, hk, pow_succ, mul_assoc, mul_comm p]
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
    haveI hpri : Fact p.Prime := CharP.char_is_prime_of_pos R p
    have := hζ.pow_eq_one
    rw [hm.1, hk, pow_succ, mul_assoc, pow_mul', ← frobenius_def, ← frobenius_one p] at this
    exfalso
    have hpos : 0 < p ^ k * m := by
      refine' mul_pos (pow_pos hpri.1.pos _) (Nat.pos_of_ne_zero fun h => _)
      have H := hm.1
      rw [h] at H
      simp at H
    refine' hζ.pow_ne_one_of_pos_of_lt hpos _ (frobenius_inj R p this)
    · rw [hm.1, hk, pow_succ, mul_assoc, mul_comm p]
      

Proof state:
case pos.intro.h
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k✝ l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : p ∣ ↑n
k : ℕ
hk : Part.get (multiplicity p ↑n) hfin = Nat.succ k
this✝ : NeZero p
hpri : Fact (Nat.Prime p)
this : (frobenius R p) (ζ ^ (p ^ k * m)) = (frobenius R p) 1
hpos : 0 < p ^ k * m
⊢ p ^ k * m < p ^ k * m * p

Next tactic:
exact lt_mul_of_one_lt_right hpos hpri.1.one_lt
theorem neZero' {n : ℕ+} (hζ : IsPrimitiveRoot ζ n) : NeZero ((n : ℕ) : R) := by
  let p := ringChar R
  have hfin := multiplicity.finite_nat_iff.2 ⟨CharP.char_ne_one R p, n.pos⟩
  obtain ⟨m, hm⟩ := multiplicity.exists_eq_pow_mul_and_not_dvd hfin
  by_cases hp : p ∣ n
  · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (multiplicity.pos_of_dvd hfin hp).ne'
    haveI : NeZero p := NeZero.of_pos (Nat.pos_of_dvd_of_pos hp n.pos)
    haveI hpri : Fact p.Prime := CharP.char_is_prime_of_pos R p
    have := hζ.pow_eq_one
    rw [hm.1, hk, pow_succ, mul_assoc, pow_mul', ← frobenius_def, ← frobenius_one p] at this
    exfalso
    have hpos : 0 < p ^ k * m := by
      refine' mul_pos (pow_pos hpri.1.pos _) (Nat.pos_of_ne_zero fun h => _)
      have H := hm.1
      rw [h] at H
      simp at H
    refine' hζ.pow_ne_one_of_pos_of_lt hpos _ (frobenius_inj R p this)
    · rw [hm.1, hk, pow_succ, mul_assoc, mul_comm p]
      exact lt_mul_of_one_lt_right hpos hpri.1.one_lt
  · 

Proof state:
case neg
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k l : ℕ
ζ : R
inst✝¹ : CommRing R
inst✝ : IsDomain R
n : ℕ+
hζ : IsPrimitiveRoot ζ ↑n
p : ℕ := ringChar R
hfin : multiplicity.Finite p ↑n
m : ℕ
hm : ↑n = p ^ Part.get (multiplicity p ↑n) hfin * m ∧ ¬p ∣ m
hp : ¬p ∣ ↑n
⊢ NeZero ↑↑n

Next tactic:
exact NeZero.of_not_dvd R hp
theorem eq_neg_one_of_two_right [NoZeroDivisors R] {ζ : R} (h : IsPrimitiveRoot ζ 2) : ζ = -1 := by
  

Proof state:
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k l : ℕ
inst✝¹ : CommRing R
ζ✝ : Rˣ
h✝ : IsPrimitiveRoot ζ✝ k
inst✝ : NoZeroDivisors R
ζ : R
h : IsPrimitiveRoot ζ 2
⊢ ζ = -1

Next tactic:
apply (eq_or_eq_neg_of_sq_eq_sq ζ 1 _).resolve_left
theorem eq_neg_one_of_two_right [NoZeroDivisors R] {ζ : R} (h : IsPrimitiveRoot ζ 2) : ζ = -1 := by
  apply (eq_or_eq_neg_of_sq_eq_sq ζ 1 _).resolve_left
  · 

Proof state:
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k l : ℕ
inst✝¹ : CommRing R
ζ✝ : Rˣ
h✝ : IsPrimitiveRoot ζ✝ k
inst✝ : NoZeroDivisors R
ζ : R
h : IsPrimitiveRoot ζ 2
⊢ ¬ζ = 1

Next tactic:
rw [← pow_one ζ]
theorem eq_neg_one_of_two_right [NoZeroDivisors R] {ζ : R} (h : IsPrimitiveRoot ζ 2) : ζ = -1 := by
  apply (eq_or_eq_neg_of_sq_eq_sq ζ 1 _).resolve_left
  · rw [← pow_one ζ]; 

Proof state:
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k l : ℕ
inst✝¹ : CommRing R
ζ✝ : Rˣ
h✝ : IsPrimitiveRoot ζ✝ k
inst✝ : NoZeroDivisors R
ζ : R
h : IsPrimitiveRoot ζ 2
⊢ ¬ζ ^ 1 = 1

Next tactic:
apply h.pow_ne_one_of_pos_of_lt
theorem eq_neg_one_of_two_right [NoZeroDivisors R] {ζ : R} (h : IsPrimitiveRoot ζ 2) : ζ = -1 := by
  apply (eq_or_eq_neg_of_sq_eq_sq ζ 1 _).resolve_left
  · rw [← pow_one ζ]; apply h.pow_ne_one_of_pos_of_lt <;> 

Proof state:
case h0
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k l : ℕ
inst✝¹ : CommRing R
ζ✝ : Rˣ
h✝ : IsPrimitiveRoot ζ✝ k
inst✝ : NoZeroDivisors R
ζ : R
h : IsPrimitiveRoot ζ 2
⊢ 0 < 1

Next tactic:
decide
theorem eq_neg_one_of_two_right [NoZeroDivisors R] {ζ : R} (h : IsPrimitiveRoot ζ 2) : ζ = -1 := by
  apply (eq_or_eq_neg_of_sq_eq_sq ζ 1 _).resolve_left
  · rw [← pow_one ζ]; apply h.pow_ne_one_of_pos_of_lt <;> 

Proof state:
case hl
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k l : ℕ
inst✝¹ : CommRing R
ζ✝ : Rˣ
h✝ : IsPrimitiveRoot ζ✝ k
inst✝ : NoZeroDivisors R
ζ : R
h : IsPrimitiveRoot ζ 2
⊢ 1 < 2

Next tactic:
decide
theorem eq_neg_one_of_two_right [NoZeroDivisors R] {ζ : R} (h : IsPrimitiveRoot ζ 2) : ζ = -1 := by
  apply (eq_or_eq_neg_of_sq_eq_sq ζ 1 _).resolve_left
  · rw [← pow_one ζ]; apply h.pow_ne_one_of_pos_of_lt <;> decide
  · 

Proof state:
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k l : ℕ
inst✝¹ : CommRing R
ζ✝ : Rˣ
h✝ : IsPrimitiveRoot ζ✝ k
inst✝ : NoZeroDivisors R
ζ : R
h : IsPrimitiveRoot ζ 2
⊢ ζ ^ 2 = 1 ^ 2

Next tactic:
simp only [h.pow_eq_one, one_pow]
theorem neg_one (p : ℕ) [Nontrivial R] [h : CharP R p] (hp : p ≠ 2) :
    IsPrimitiveRoot (-1 : R) 2 := by
  

Proof state:
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k l : ℕ
inst✝¹ : CommRing R
ζ : Rˣ
h✝ : IsPrimitiveRoot ζ k
p : ℕ
inst✝ : Nontrivial R
h : CharP R p
hp : p ≠ 2
⊢ IsPrimitiveRoot (-1) 2

Next tactic:
convert IsPrimitiveRoot.orderOf (-1 : R)
theorem neg_one (p : ℕ) [Nontrivial R] [h : CharP R p] (hp : p ≠ 2) :
    IsPrimitiveRoot (-1 : R) 2 := by
  convert IsPrimitiveRoot.orderOf (-1 : R)
  

Proof state:
case h.e'_4
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k l : ℕ
inst✝¹ : CommRing R
ζ : Rˣ
h✝ : IsPrimitiveRoot ζ k
p : ℕ
inst✝ : Nontrivial R
h : CharP R p
hp : p ≠ 2
⊢ 2 = orderOf (-1)

Next tactic:
rw [orderOf_neg_one, if_neg]
theorem neg_one (p : ℕ) [Nontrivial R] [h : CharP R p] (hp : p ≠ 2) :
    IsPrimitiveRoot (-1 : R) 2 := by
  convert IsPrimitiveRoot.orderOf (-1 : R)
  rw [orderOf_neg_one, if_neg]
  

Proof state:
case h.e'_4.hnc
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k l : ℕ
inst✝¹ : CommRing R
ζ : Rˣ
h✝ : IsPrimitiveRoot ζ k
p : ℕ
inst✝ : Nontrivial R
h : CharP R p
hp : p ≠ 2
⊢ ¬ringChar R = 2

Next tactic:
rwa [ringChar.eq_iff.mpr h]
/-- If `1 < k` then `(∑ i in range k, ζ ^ i) = 0`. -/
theorem geom_sum_eq_zero [IsDomain R] {ζ : R} (hζ : IsPrimitiveRoot ζ k) (hk : 1 < k) :
    ∑ i in range k, ζ ^ i = 0 := by
  

Proof state:
M : Type u_1
N : Type u_2
G : Type u_3
R : Type u_4
S : Type u_5
F : Type u_6
inst✝⁴ : CommMonoid M
inst✝³ : CommMonoid N
inst✝² : DivisionCommMonoid G
k l : ℕ
inst✝¹ : CommRing R
ζ✝ : Rˣ
h : IsPrimitiveRoot ζ✝ k
inst✝ : IsDomain R
ζ : R
hζ : IsPrimitiveRoot ζ k
hk : 1 < k
⊢ ∑ i in range k, ζ ^ i = 0

Next tactic:
refine' eq_zero_of_ne_zero_of_mul_left_eq_zero (sub_ne_zero_of_ne (hζ.ne_one hk).symm) _