l3lab/ntp-mathlib huggingface dataset:
/-- The cardinality of the multiset `nthRoots ↑n (1 : R)` is `n`
if there is a primitive root of unity in `R`. -/
nonrec theorem card_nthRoots {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
    Multiset.card (nthRoots n (1 : R)) = n := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.card_zero, nthRoots_zero]
  rw [eq_iff_le_not_lt]
  use card_nthRoots n 1
  · rw [not_lt]
    

Proof state:
case right
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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
⊢ n ≤ Multiset.card (nthRoots n 1)

Next tactic:
have hcard :
        Fintype.card { x // x ∈ nthRoots n (1 : R) } ≤ Multiset.card (nthRoots n (1 : R)).attach :=
      Multiset.card_le_of_le (Multiset.dedup_le _)
/-- The cardinality of the multiset `nthRoots ↑n (1 : R)` is `n`
if there is a primitive root of unity in `R`. -/
nonrec theorem card_nthRoots {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
    Multiset.card (nthRoots n (1 : R)) = n := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.card_zero, nthRoots_zero]
  rw [eq_iff_le_not_lt]
  use card_nthRoots n 1
  · rw [not_lt]
    have hcard :
        Fintype.card { x // x ∈ nthRoots n (1 : R) } ≤ Multiset.card (nthRoots n (1 : R)).attach :=
      Multiset.card_le_of_le (Multiset.dedup_le _)
    

Proof state:
case right
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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
hcard : Fintype.card { x // x ∈ nthRoots n 1 } ≤ Multiset.card (Multiset.attach (nthRoots n 1))
⊢ n ≤ Multiset.card (nthRoots n 1)

Next tactic:
rw [Multiset.card_attach] at hcard
/-- The cardinality of the multiset `nthRoots ↑n (1 : R)` is `n`
if there is a primitive root of unity in `R`. -/
nonrec theorem card_nthRoots {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
    Multiset.card (nthRoots n (1 : R)) = n := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.card_zero, nthRoots_zero]
  rw [eq_iff_le_not_lt]
  use card_nthRoots n 1
  · rw [not_lt]
    have hcard :
        Fintype.card { x // x ∈ nthRoots n (1 : R) } ≤ Multiset.card (nthRoots n (1 : R)).attach :=
      Multiset.card_le_of_le (Multiset.dedup_le _)
    rw [Multiset.card_attach] at hcard
    

Proof state:
case right
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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
hcard : Fintype.card { x // x ∈ nthRoots n 1 } ≤ Multiset.card (nthRoots n 1)
⊢ n ≤ Multiset.card (nthRoots n 1)

Next tactic:
rw [← PNat.toPNat'_coe hpos] at hcard h ⊢
/-- The cardinality of the multiset `nthRoots ↑n (1 : R)` is `n`
if there is a primitive root of unity in `R`. -/
nonrec theorem card_nthRoots {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
    Multiset.card (nthRoots n (1 : R)) = n := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.card_zero, nthRoots_zero]
  rw [eq_iff_le_not_lt]
  use card_nthRoots n 1
  · rw [not_lt]
    have hcard :
        Fintype.card { x // x ∈ nthRoots n (1 : R) } ≤ Multiset.card (nthRoots n (1 : R)).attach :=
      Multiset.card_le_of_le (Multiset.dedup_le _)
    rw [Multiset.card_attach] at hcard
    rw [← PNat.toPNat'_coe hpos] at hcard h ⊢
    

Proof state:
case right
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
n : ℕ
h : IsPrimitiveRoot ζ ↑(Nat.toPNat' n)
hpos : n > 0
hcard : Fintype.card { x // x ∈ nthRoots (↑(Nat.toPNat' n)) 1 } ≤ Multiset.card (nthRoots (↑(Nat.toPNat' n)) 1)
⊢ ↑(Nat.toPNat' n) ≤ Multiset.card (nthRoots (↑(Nat.toPNat' n)) 1)

Next tactic:
set m := Nat.toPNat' n
/-- The cardinality of the multiset `nthRoots ↑n (1 : R)` is `n`
if there is a primitive root of unity in `R`. -/
nonrec theorem card_nthRoots {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
    Multiset.card (nthRoots n (1 : R)) = n := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.card_zero, nthRoots_zero]
  rw [eq_iff_le_not_lt]
  use card_nthRoots n 1
  · rw [not_lt]
    have hcard :
        Fintype.card { x // x ∈ nthRoots n (1 : R) } ≤ Multiset.card (nthRoots n (1 : R)).attach :=
      Multiset.card_le_of_le (Multiset.dedup_le _)
    rw [Multiset.card_attach] at hcard
    rw [← PNat.toPNat'_coe hpos] at hcard h ⊢
    set m := Nat.toPNat' n
    

Proof state:
case right
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
n : ℕ
hpos : n > 0
m : ℕ+ := Nat.toPNat' n
h : IsPrimitiveRoot ζ ↑m
hcard : Fintype.card { x // x ∈ nthRoots (↑m) 1 } ≤ Multiset.card (nthRoots (↑m) 1)
⊢ ↑m ≤ Multiset.card (nthRoots (↑m) 1)

Next tactic:
rw [← Fintype.card_congr (rootsOfUnityEquivNthRoots R m), card_rootsOfUnity h] at hcard
/-- The cardinality of the multiset `nthRoots ↑n (1 : R)` is `n`
if there is a primitive root of unity in `R`. -/
nonrec theorem card_nthRoots {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
    Multiset.card (nthRoots n (1 : R)) = n := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.card_zero, nthRoots_zero]
  rw [eq_iff_le_not_lt]
  use card_nthRoots n 1
  · rw [not_lt]
    have hcard :
        Fintype.card { x // x ∈ nthRoots n (1 : R) } ≤ Multiset.card (nthRoots n (1 : R)).attach :=
      Multiset.card_le_of_le (Multiset.dedup_le _)
    rw [Multiset.card_attach] at hcard
    rw [← PNat.toPNat'_coe hpos] at hcard h ⊢
    set m := Nat.toPNat' n
    rw [← Fintype.card_congr (rootsOfUnityEquivNthRoots R m), card_rootsOfUnity h] at hcard
    

Proof state:
case right
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
n : ℕ
hpos : n > 0
m : ℕ+ := Nat.toPNat' n
h : IsPrimitiveRoot ζ ↑m
hcard : ↑m ≤ Multiset.card (nthRoots (↑m) 1)
⊢ ↑m ≤ Multiset.card (nthRoots (↑m) 1)

Next tactic:
exact hcard
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := 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
n : ℕ
h : IsPrimitiveRoot ζ n
⊢ Multiset.Nodup (nthRoots n 1)

Next tactic:
rcases Nat.eq_zero_or_pos n with hzero | hpos
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · 

Proof state:
case inl
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
n : ℕ
h : IsPrimitiveRoot ζ n
hzero : n = 0
⊢ Multiset.Nodup (nthRoots n 1)

Next tactic:
simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  

Proof state:
case inr
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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
⊢ Multiset.Nodup (nthRoots n 1)

Next tactic:
apply (Multiset.dedup_eq_self (α := R)).1
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  apply (Multiset.dedup_eq_self (α := R)).1
  

Proof state:
case inr
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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
⊢ Multiset.dedup (nthRoots n 1) = nthRoots n 1

Next tactic:
rw [eq_iff_le_not_lt]
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  apply (Multiset.dedup_eq_self (α := R)).1
  rw [eq_iff_le_not_lt]
  

Proof state:
case inr
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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
⊢ Multiset.dedup (nthRoots n 1) ≤ nthRoots n 1 ∧ ¬Multiset.dedup (nthRoots n 1) < nthRoots n 1

Next tactic:
constructor
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  apply (Multiset.dedup_eq_self (α := R)).1
  rw [eq_iff_le_not_lt]
  constructor
  · 

Proof state:
case inr.left
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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
⊢ Multiset.dedup (nthRoots n 1) ≤ nthRoots n 1

Next tactic:
exact Multiset.dedup_le (nthRoots n (1 : R))
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  apply (Multiset.dedup_eq_self (α := R)).1
  rw [eq_iff_le_not_lt]
  constructor
  · exact Multiset.dedup_le (nthRoots n (1 : R))
  · 

Proof state:
case inr.right
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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
⊢ ¬Multiset.dedup (nthRoots n 1) < nthRoots n 1

Next tactic:
by_contra ha
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  apply (Multiset.dedup_eq_self (α := R)).1
  rw [eq_iff_le_not_lt]
  constructor
  · exact Multiset.dedup_le (nthRoots n (1 : R))
  · by_contra ha
    

Proof state:
case inr.right
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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
ha : Multiset.dedup (nthRoots n 1) < nthRoots n 1
⊢ False

Next tactic:
replace ha := Multiset.card_lt_of_lt ha
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  apply (Multiset.dedup_eq_self (α := R)).1
  rw [eq_iff_le_not_lt]
  constructor
  · exact Multiset.dedup_le (nthRoots n (1 : R))
  · by_contra ha
    replace ha := Multiset.card_lt_of_lt ha
    

Proof state:
case inr.right
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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
ha : Multiset.card (Multiset.dedup (nthRoots n 1)) < Multiset.card (nthRoots n 1)
⊢ False

Next tactic:
rw [card_nthRoots h] at ha
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  apply (Multiset.dedup_eq_self (α := R)).1
  rw [eq_iff_le_not_lt]
  constructor
  · exact Multiset.dedup_le (nthRoots n (1 : R))
  · by_contra ha
    replace ha := Multiset.card_lt_of_lt ha
    rw [card_nthRoots h] at ha
    

Proof state:
case inr.right
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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
ha : Multiset.card (Multiset.dedup (nthRoots n 1)) < n
⊢ False

Next tactic:
have hrw : Multiset.card (nthRoots n (1 : R)).dedup =
        Fintype.card { x // x ∈ nthRoots n (1 : R) } := by
      set fs := (⟨(nthRoots n (1 : R)).dedup, Multiset.nodup_dedup _⟩ : Finset R)
      rw [← Finset.card_mk, Fintype.card_of_subtype fs _]
      intro x
      simp only [Multiset.mem_dedup, Finset.mem_mk]
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  apply (Multiset.dedup_eq_self (α := R)).1
  rw [eq_iff_le_not_lt]
  constructor
  · exact Multiset.dedup_le (nthRoots n (1 : R))
  · by_contra ha
    replace ha := Multiset.card_lt_of_lt ha
    rw [card_nthRoots h] at ha
    have hrw : Multiset.card (nthRoots n (1 : R)).dedup =
        Fintype.card { x // x ∈ nthRoots n (1 : R) } := 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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
ha : Multiset.card (Multiset.dedup (nthRoots n 1)) < n
⊢ Multiset.card (Multiset.dedup (nthRoots n 1)) = Fintype.card { x // x ∈ nthRoots n 1 }

Next tactic:
set fs := (⟨(nthRoots n (1 : R)).dedup, Multiset.nodup_dedup _⟩ : Finset R)
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  apply (Multiset.dedup_eq_self (α := R)).1
  rw [eq_iff_le_not_lt]
  constructor
  · exact Multiset.dedup_le (nthRoots n (1 : R))
  · by_contra ha
    replace ha := Multiset.card_lt_of_lt ha
    rw [card_nthRoots h] at ha
    have hrw : Multiset.card (nthRoots n (1 : R)).dedup =
        Fintype.card { x // x ∈ nthRoots n (1 : R) } := by
      set fs := (⟨(nthRoots n (1 : R)).dedup, Multiset.nodup_dedup _⟩ : Finset R)
      

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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
ha : Multiset.card (Multiset.dedup (nthRoots n 1)) < n
fs : Finset R := { val := Multiset.dedup (nthRoots n 1), nodup := (_ : Multiset.Nodup (Multiset.dedup (nthRoots n 1))) }
⊢ Multiset.card (Multiset.dedup (nthRoots n 1)) = Fintype.card { x // x ∈ nthRoots n 1 }

Next tactic:
rw [← Finset.card_mk, Fintype.card_of_subtype fs _]
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  apply (Multiset.dedup_eq_self (α := R)).1
  rw [eq_iff_le_not_lt]
  constructor
  · exact Multiset.dedup_le (nthRoots n (1 : R))
  · by_contra ha
    replace ha := Multiset.card_lt_of_lt ha
    rw [card_nthRoots h] at ha
    have hrw : Multiset.card (nthRoots n (1 : R)).dedup =
        Fintype.card { x // x ∈ nthRoots n (1 : R) } := by
      set fs := (⟨(nthRoots n (1 : R)).dedup, Multiset.nodup_dedup _⟩ : Finset R)
      rw [← Finset.card_mk, Fintype.card_of_subtype fs _]
      

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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
ha : Multiset.card (Multiset.dedup (nthRoots n 1)) < n
fs : Finset R := { val := Multiset.dedup (nthRoots n 1), nodup := (_ : Multiset.Nodup (Multiset.dedup (nthRoots n 1))) }
⊢ ∀ (x : R), x ∈ fs ↔ x ∈ nthRoots n 1

Next tactic:
intro x
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  apply (Multiset.dedup_eq_self (α := R)).1
  rw [eq_iff_le_not_lt]
  constructor
  · exact Multiset.dedup_le (nthRoots n (1 : R))
  · by_contra ha
    replace ha := Multiset.card_lt_of_lt ha
    rw [card_nthRoots h] at ha
    have hrw : Multiset.card (nthRoots n (1 : R)).dedup =
        Fintype.card { x // x ∈ nthRoots n (1 : R) } := by
      set fs := (⟨(nthRoots n (1 : R)).dedup, Multiset.nodup_dedup _⟩ : Finset R)
      rw [← Finset.card_mk, Fintype.card_of_subtype fs _]
      intro x
      

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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
ha : Multiset.card (Multiset.dedup (nthRoots n 1)) < n
fs : Finset R := { val := Multiset.dedup (nthRoots n 1), nodup := (_ : Multiset.Nodup (Multiset.dedup (nthRoots n 1))) }
x : R
⊢ x ∈ fs ↔ x ∈ nthRoots n 1

Next tactic:
simp only [Multiset.mem_dedup, Finset.mem_mk]
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  apply (Multiset.dedup_eq_self (α := R)).1
  rw [eq_iff_le_not_lt]
  constructor
  · exact Multiset.dedup_le (nthRoots n (1 : R))
  · by_contra ha
    replace ha := Multiset.card_lt_of_lt ha
    rw [card_nthRoots h] at ha
    have hrw : Multiset.card (nthRoots n (1 : R)).dedup =
        Fintype.card { x // x ∈ nthRoots n (1 : R) } := by
      set fs := (⟨(nthRoots n (1 : R)).dedup, Multiset.nodup_dedup _⟩ : Finset R)
      rw [← Finset.card_mk, Fintype.card_of_subtype fs _]
      intro x
      simp only [Multiset.mem_dedup, Finset.mem_mk]
    

Proof state:
case inr.right
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
n : ℕ
h : IsPrimitiveRoot ζ n
hpos : n > 0
ha : Multiset.card (Multiset.dedup (nthRoots n 1)) < n
hrw : Multiset.card (Multiset.dedup (nthRoots n 1)) = Fintype.card { x // x ∈ nthRoots n 1 }
⊢ False

Next tactic:
rw [← PNat.toPNat'_coe hpos] at h hrw ha
/-- The multiset `nthRoots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nthRoots_nodup {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) : (nthRoots n (1 : R)).Nodup := by
  rcases Nat.eq_zero_or_pos n with hzero | hpos
  · simp only [hzero, Multiset.nodup_zero, nthRoots_zero]
  apply (Multiset.dedup_eq_self (α := R)).1
  rw [eq_iff_le_not_lt]
  constructor
  · exact Multiset.dedup_le (nthRoots n (1 : R))
  · by_contra ha
    replace ha := Multiset.card_lt_of_lt ha
    rw [card_nthRoots h] at ha
    have hrw : Multiset.card (nthRoots n (1 : R)).dedup =
        Fintype.card { x // x ∈ nthRoots n (1 : R) } := by
      set fs := (⟨(nthRoots n (1 : R)).dedup, Multiset.nodup_dedup _⟩ : Finset R)
      rw [← Finset.card_mk, Fintype.card_of_subtype fs _]
      intro x
      simp only [Multiset.mem_dedup, Finset.mem_mk]
    rw [← PNat.toPNat'_coe hpos] at h hrw ha
    

Proof state:
case inr.right
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
n : ℕ
h : IsPrimitiveRoot ζ ↑(Nat.toPNat' n)
hpos : n > 0
ha : Multiset.card (Multiset.dedup (nthRoots (↑(Nat.toPNat' n)) 1)) < ↑(Nat.toPNat' n)
hrw :
  Multiset.card (Multiset.dedup (nthRoots (↑(Nat.toPNat' n)) 1)) =
    Fintype.card { x // x ∈ nthRoots (↑(Nat.toPNat' n)) 1 }
⊢ False

Next tactic:
set m := Nat.toPNat' n