-- Mathlib/NumberTheory/Cyclotomic/Discriminant.lean
theorem discr_prime_pow [hcycl : IsCyclotomicExtension {p ^ k} K L] [hp : Fact (p : ℕ).Prime]
    (hζ : IsPrimitiveRoot ζ ↑(p ^ k)) (hirr : Irreducible (cyclotomic (↑(p ^ k) : ℕ) K)) :
    discr K (hζ.powerBasis K).basis =
      (-1) ^ ((p ^ k : ℕ).totient / 2) * p ^ ((p : ℕ) ^ (k - 1) * ((p - 1) * k - 1))

Proof state:
case pos
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
k : ℕ
coe_two : 2 = ↑2
hp : Fact (Nat.Prime ↑2)
hcycl : IsCyclotomicExtension {2 ^ (k + 1)} K L
hζ : IsPrimitiveRoot ζ ↑(2 ^ (k + 1))
hirr : Irreducible (cyclotomic (↑(2 ^ (k + 1))) K)
hk : k = 0
⊢ discr K ⇑(IsPrimitiveRoot.powerBasis K hζ).basis =
    (-1) ^ (φ (↑2 ^ (k + 1)) / 2) * ↑↑2 ^ (↑2 ^ (k + 1 - 1) * ((↑2 - 1) * (k + 1) - 1))

Tactic:
subst hk

Result:
case pos
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
coe_two : 2 = ↑2
hp : Fact (Nat.Prime ↑2)
hcycl : IsCyclotomicExtension {2 ^ (0 + 1)} K L
hζ : IsPrimitiveRoot ζ ↑(2 ^ (0 + 1))
hirr : Irreducible (cyclotomic (↑(2 ^ (0 + 1))) K)
⊢ discr K ⇑(IsPrimitiveRoot.powerBasis K hζ).basis =
    (-1) ^ (φ (↑2 ^ (0 + 1)) / 2) * ↑↑2 ^ (↑2 ^ (0 + 1 - 1) * ((↑2 - 1) * (0 + 1) - 1))

Proof state:
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
coe_two : 2 = ↑2
hp : Fact (Nat.Prime ↑2)
hcycl✝ : IsCyclotomicExtension {2 ^ (0 + 1)} K L
hcycl : IsCyclotomicExtension {2} K L
hζ✝ : IsPrimitiveRoot ζ ↑(2 ^ (0 + 1))
hζ : IsPrimitiveRoot ζ ↑2
hirr : Irreducible (cyclotomic (↑(2 ^ (0 + 1))) K)
⊢ -1 = (algebraMap K L) (-1)

Tactic:
simp

Result:
no goals

Proof state:
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
coe_two : 2 = ↑2
hp : Fact (Nat.Prime ↑2)
hcycl✝ : IsCyclotomicExtension {2 ^ (0 + 1)} K L
hcycl : IsCyclotomicExtension {2} K L
hζ✝ : IsPrimitiveRoot ζ ↑(2 ^ (0 + 1))
hζ : IsPrimitiveRoot ζ ↑2
hirr : Irreducible (cyclotomic (↑(2 ^ (0 + 1))) K)
this : (minpoly K ζ).natDegree = 1
e : Fin (minpoly K ζ).natDegree ≃ Fin 1
⊢ -1 = (algebraMap K L) (-1)

Tactic:
simp

Result:
no goals

Proof state:
case zero
p : ℕ+
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
hp : Fact (Nat.Prime ↑p)
hcycl : IsCyclotomicExtension {p ^ 0} K L
hζ : IsPrimitiveRoot ζ ↑(p ^ 0)
hirr : Irreducible (cyclotomic (↑(p ^ 0)) K)
hζone : ζ = 1
⊢ (Matrix.of fun i j => ((traceForm K L) (ζ ^ ↑i)) (ζ ^ ↑j)).det = 1 * ↑↑p ^ (↑p ^ (0 - 1) * (0 - 1))

Tactic:
rw [hζ.powerBasis_dim _, hζone, ← (algebraMap K L).map_one,
  minpoly.eq_X_sub_C_of_algebraMap_inj _ (algebraMap K L).injective, natDegree_X_sub_C]

Result:
case zero
p : ℕ+
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
hp : Fact (Nat.Prime ↑p)
hcycl : IsCyclotomicExtension {p ^ 0} K L
hζ : IsPrimitiveRoot ζ ↑(p ^ 0)
hirr : Irreducible (cyclotomic (↑(p ^ 0)) K)
hζone : ζ = 1
⊢ (Matrix.of fun i j => ((traceForm K L) ((algebraMap K L) 1 ^ ↑i)) ((algebraMap K L) 1 ^ ↑j)).det =
    1 * ↑↑p ^ (↑p ^ (0 - 1) * (0 - 1))

Proof state:
case pos
p : ℕ+
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
hp : Fact (Nat.Prime ↑p)
k : ℕ
hcycl : IsCyclotomicExtension {p ^ (k + 1)} K L
hζ : IsPrimitiveRoot ζ ↑(p ^ (k + 1))
hirr : Irreducible (cyclotomic (↑(p ^ (k + 1))) K)
hk : p ^ (k + 1) = 2
coe_two : 2 = ↑2
⊢ discr K ⇑(IsPrimitiveRoot.powerBasis K hζ).basis =
    (-1) ^ (φ (↑p ^ (k + 1)) / 2) * ↑↑p ^ (↑p ^ (k + 1 - 1) * ((↑p - 1) * (k + 1) - 1))

Tactic:
have hp : p = 2 := by
  rw [← PNat.coe_inj, PNat.pow_coe, ← pow_one 2] at hk
  replace hk :=
    eq_of_prime_pow_eq (prime_iff.1 hp.out) (prime_iff.1 Nat.prime_two) (succ_pos _) hk
  rwa [coe_two, PNat.coe_inj] at hk

Result:
case pos
p : ℕ+
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
hp✝ : Fact (Nat.Prime ↑p)
k : ℕ
hcycl : IsCyclotomicExtension {p ^ (k + 1)} K L
hζ : IsPrimitiveRoot ζ ↑(p ^ (k + 1))
hirr : Irreducible (cyclotomic (↑(p ^ (k + 1))) K)
hk : p ^ (k + 1) = 2
coe_two : 2 = ↑2
hp : p = 2
⊢ discr K ⇑(IsPrimitiveRoot.powerBasis K hζ).basis =
    (-1) ^ (φ (↑p ^ (k + 1)) / 2) * ↑↑p ^ (↑p ^ (k + 1 - 1) * ((↑p - 1) * (k + 1) - 1))

Proof state:
case pos
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
k : ℕ
coe_two : 2 = ↑2
hp : Fact (Nat.Prime ↑2)
hcycl : IsCyclotomicExtension {2 ^ (k + 1)} K L
hζ : IsPrimitiveRoot ζ ↑(2 ^ (k + 1))
hirr : Irreducible (cyclotomic (↑(2 ^ (k + 1))) K)
hk : ↑2 ^ (k + 1) = ↑2
⊢ discr K ⇑(IsPrimitiveRoot.powerBasis K hζ).basis =
    (-1) ^ (φ (↑2 ^ (k + 1)) / 2) * ↑↑2 ^ (↑2 ^ (k + 1 - 1) * ((↑2 - 1) * (k + 1) - 1))

Tactic:
nth_rw 2 [← pow_one 2] at hk

Result:
case pos
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
k : ℕ
coe_two : 2 = ↑2
hp : Fact (Nat.Prime ↑2)
hcycl : IsCyclotomicExtension {2 ^ (k + 1)} K L
hζ : IsPrimitiveRoot ζ ↑(2 ^ (k + 1))
hirr : Irreducible (cyclotomic (↑(2 ^ (k + 1))) K)
hk : ↑2 ^ (k + 1) = ↑(2 ^ 1)
⊢ discr K ⇑(IsPrimitiveRoot.powerBasis K hζ).basis =
    (-1) ^ (φ (↑2 ^ (k + 1)) / 2) * ↑↑2 ^ (↑2 ^ (k + 1 - 1) * ((↑2 - 1) * (k + 1) - 1))

Proof state:
p : ℕ+
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
hp : Fact (Nat.Prime ↑p)
k : ℕ
hcycl : IsCyclotomicExtension {p ^ (k + 1)} K L
hζ : IsPrimitiveRoot ζ ↑(p ^ (k + 1))
hirr : Irreducible (cyclotomic (↑(p ^ (k + 1))) K)
hk : p ^ (k + 1) = 2
coe_two : 2 = ↑2
⊢ p = 2

Tactic:
rw [← PNat.coe_inj, PNat.pow_coe, ← pow_one 2] at hk

Result:
p : ℕ+
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
hp : Fact (Nat.Prime ↑p)
k : ℕ
hcycl : IsCyclotomicExtension {p ^ (k + 1)} K L
hζ : IsPrimitiveRoot ζ ↑(p ^ (k + 1))
hirr : Irreducible (cyclotomic (↑(p ^ (k + 1))) K)
hk : ↑p ^ (k + 1) = ↑(2 ^ 1)
coe_two : 2 = ↑2
⊢ p = 2

Proof state:
case pos.intro.convert_2
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
coe_two : 2 = ↑2
hp : Fact (Nat.Prime ↑2)
hcycl✝ : IsCyclotomicExtension {2 ^ (0 + 1)} K L
hcycl : IsCyclotomicExtension {2} K L
hζ✝ : IsPrimitiveRoot ζ ↑(2 ^ (0 + 1))
hζ : IsPrimitiveRoot ζ ↑2
hirr : Irreducible (cyclotomic (↑(2 ^ (0 + 1))) K)
this : (minpoly K ζ).natDegree = 1
e : Fin (minpoly K ζ).natDegree ≃ Fin 1
⊢ (discr K fun i => (algebraMap K L) (-1) ^ ↑i) = 1

Tactic:
simp only [discr, traceMatrix_apply, Matrix.det_unique, Fin.default_eq_zero, Fin.val_zero,
  _root_.pow_zero, traceForm_apply, mul_one]

Result:
case pos.intro.convert_2
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
coe_two : 2 = ↑2
hp : Fact (Nat.Prime ↑2)
hcycl✝ : IsCyclotomicExtension {2 ^ (0 + 1)} K L
hcycl : IsCyclotomicExtension {2} K L
hζ✝ : IsPrimitiveRoot ζ ↑(2 ^ (0 + 1))
hζ : IsPrimitiveRoot ζ ↑2
hirr : Irreducible (cyclotomic (↑(2 ^ (0 + 1))) K)
this : (minpoly K ζ).natDegree = 1
e : Fin (minpoly K ζ).natDegree ≃ Fin 1
⊢ (trace K L) 1 = 1

Proof state:
case h.e'_2.e_b.h
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
coe_two : 2 = ↑2
hp : Fact (Nat.Prime ↑2)
hcycl✝ : IsCyclotomicExtension {2 ^ (0 + 1)} K L
hcycl : IsCyclotomicExtension {2} K L
hζ✝ : IsPrimitiveRoot ζ ↑(2 ^ (0 + 1))
hζ : IsPrimitiveRoot ζ ↑2
hirr : Irreducible (cyclotomic (↑(2 ^ (0 + 1))) K)
this : (minpoly K ζ).natDegree = 1
e : Fin (minpoly K ζ).natDegree ≃ Fin 1
i : Fin 1
⊢ ↑(e.symm i) = 0

Tactic:
rw [← Nat.lt_one_iff]

Result:
case h.e'_2.e_b.h
K : Type u
L : Type v
ζ : L
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
coe_two : 2 = ↑2
hp : Fact (Nat.Prime ↑2)
hcycl✝ : IsCyclotomicExtension {2 ^ (0 + 1)} K L
hcycl : IsCyclotomicExtension {2} K L
hζ✝ : IsPrimitiveRoot ζ ↑(2 ^ (0 + 1))
hζ : IsPrimitiveRoot ζ ↑2
hirr : Irreducible (cyclotomic (↑(2 ^ (0 + 1))) K)
this : (minpoly K ζ).natDegree = 1
e : Fin (minpoly K ζ).natDegree ≃ Fin 1
i : Fin 1
⊢ ↑(e.symm i) < 1