Theorem: Complex.isPrimitiveRoot_exp_of_coprime
File: Mathlib/RingTheory/RootsOfUnity/Complex.lean

tactic: rw [IsPrimitiveRoot.iff_def]
state_before: i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
⊢ IsPrimitiveRoot (exp (2 * ↑π * I * (↑i / ↑n))) n

tactic: simp only [← exp_nat_mul, exp_eq_one_iff]
state_before: i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
⊢ exp (2 * ↑π * I * (↑i / ↑n)) ^ n = 1 ∧ ∀ (l : ℕ), exp (2 * ↑π * I * (↑i / ↑n)) ^ l = 1 → n ∣ l

tactic: have hn0 : (n : ℂ) ≠ 0 := by exact_mod_cast h0
state_before: i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
⊢ (∃ n_1, ↑n * (2 * ↑π * I * (↑i / ↑n)) = ↑n_1 * (2 * ↑π * I)) ∧
    ∀ (l : ℕ), (∃ n_1, ↑l * (2 * ↑π * I * (↑i / ↑n)) = ↑n_1 * (2 * ↑π * I)) → n ∣ l

tactic: constructor
state_before: i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
⊢ (∃ n_1, ↑n * (2 * ↑π * I * (↑i / ↑n)) = ↑n_1 * (2 * ↑π * I)) ∧
    ∀ (l : ℕ), (∃ n_1, ↑l * (2 * ↑π * I * (↑i / ↑n)) = ↑n_1 * (2 * ↑π * I)) → n ∣ l

tactic: exact_mod_cast h0
state_before: i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
⊢ ↑n ≠ 0

tactic: use i
state_before: case left
i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
⊢ ∃ n_1, ↑n * (2 * ↑π * I * (↑i / ↑n)) = ↑n_1 * (2 * ↑π * I)

tactic: field_simp [hn0, mul_comm (i : ℂ), mul_comm (n : ℂ)]
state_before: case left
i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
⊢ ↑n * (2 * ↑π * I * (↑i / ↑n)) = ↑↑i * (2 * ↑π * I)

tactic: simp only [hn0, mul_right_comm _ _ ↑n, mul_left_inj' two_pi_I_ne_zero, Ne.def, not_false_iff,
  mul_comm _ (i : ℂ), ← mul_assoc _ (i : ℂ), exists_imp, field_simps]
state_before: case right
i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
⊢ ∀ (l : ℕ), (∃ n_1, ↑l * (2 * ↑π * I * (↑i / ↑n)) = ↑n_1 * (2 * ↑π * I)) → n ∣ l

tactic: norm_cast
state_before: case right
i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
⊢ ∀ (l : ℕ) (x : ℤ), ↑i * ↑l * (2 * ↑π * I) = ↑x * (2 * ↑π * I) * ↑n → n ∣ l

tactic: rintro l k hk
state_before: case right
i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
⊢ ∀ (l : ℕ) (x : ℤ), ↑(i * l) * (↑(2 * π) * I) = ↑x * (↑(2 * π) * I) * ↑n → n ∣ l

tactic: conv_rhs at hk => rw [mul_comm, ← mul_assoc]
state_before: case right
i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
l : ℕ
k : ℤ
hk : ↑(i * l) * (↑(2 * π) * I) = ↑k * (↑(2 * π) * I) * ↑n
⊢ n ∣ l

tactic: have hz : 2 * ↑π * I ≠ 0 := by simp [pi_pos.ne.symm, I_ne_zero]
state_before: case right
i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
l : ℕ
k : ℤ
hk : ↑(i * l) * (↑(2 * π) * I) = ↑n * ↑k * (↑(2 * π) * I)
⊢ n ∣ l

tactic: field_simp [hz] at hk
state_before: case right
i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
l : ℕ
k : ℤ
hk : ↑(i * l) * (↑(2 * π) * I) = ↑n * ↑k * (↑(2 * π) * I)
hz : 2 * ↑π * I ≠ 0
⊢ n ∣ l

tactic: norm_cast at hk
state_before: case right
i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
l : ℕ
k : ℤ
hz : 2 * ↑π * I ≠ 0
hk : ↑i * ↑l = ↑n * ↑k
⊢ n ∣ l

tactic: have : n ∣ i * l := by rw [← Int.coe_nat_dvd, hk, mul_comm]; apply dvd_mul_left
state_before: case right
i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
l : ℕ
k : ℤ
hz : 2 * ↑π * I ≠ 0
hk : ↑(i * l) = ↑n * k
⊢ n ∣ l

tactic: exact hi.symm.dvd_of_dvd_mul_left this
state_before: case right
i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
l : ℕ
k : ℤ
hz : 2 * ↑π * I ≠ 0
hk : ↑(i * l) = ↑n * k
this : n ∣ i * l
⊢ n ∣ l

tactic: simp [pi_pos.ne.symm, I_ne_zero]
state_before: i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
l : ℕ
k : ℤ
hk : ↑(i * l) * (↑(2 * π) * I) = ↑n * ↑k * (↑(2 * π) * I)
⊢ 2 * ↑π * I ≠ 0

tactic: rw [← Int.coe_nat_dvd, hk, mul_comm]
state_before: i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
l : ℕ
k : ℤ
hz : 2 * ↑π * I ≠ 0
hk : ↑(i * l) = ↑n * k
⊢ n ∣ i * l

tactic: apply dvd_mul_left
state_before: i n : ℕ
h0 : n ≠ 0
hi : Nat.coprime i n
hn0 : ↑n ≠ 0
l : ℕ
k : ℤ
hz : 2 * ↑π * I ≠ 0
hk : ↑(i * l) = ↑n * k
⊢ ↑n ∣ k * ↑n