l3lab/ntp-mathlib huggingface dataset:
/-- The `MulEquiv` that takes an automorphism `f` to the element `k : (ZMod n)ˣ` such that
  `f μ = μ ^ k` for any root of unity `μ`. A strengthening of `IsPrimitiveRoot.autToPow`. -/
@[simps]
noncomputable def autEquivPow : (L ≃ₐ[K] L) ≃* (ZMod n)ˣ :=
  let hζ := zeta_spec n K L
  let hμ t := hζ.pow_of_coprime _ (ZMod.val_coe_unit_coprime t)
  { (zeta_spec n K L).autToPow K with
    invFun := fun t =>
      (hζ.powerBasis K).equivOfMinpoly ((hμ t).powerBasis K)
        (by
          haveI := IsCyclotomicExtension.neZero' n K L
          simp only [IsPrimitiveRoot.powerBasis_gen]
          have hr :=
            IsPrimitiveRoot.minpoly_eq_cyclotomic_of_irreducible
              ((zeta_spec n K L).pow_of_coprime _ (ZMod.val_coe_unit_coprime t)) h
          exact ((zeta_spec n K L).minpoly_eq_cyclotomic_of_irreducible h).symm.trans hr)
    left_inv := fun f => by
      simp only [MonoidHom.toFun_eq_coe]
      apply AlgEquiv.coe_algHom_injective
      apply (hζ.powerBasis K).algHom_ext
-- Porting note: the proof is slightly different because of coercions.
      

Proof state:
case a.h
n : ℕ+
K : Type u_1
inst✝⁴ : Field K
L : Type u_2
μ : L
inst✝³ : CommRing L
inst✝² : IsDomain L
hμ✝ : IsPrimitiveRoot μ ↑n
inst✝¹ : Algebra K L
inst✝ : IsCyclotomicExtension {n} K L
h : Irreducible (cyclotomic (↑n) K)
hζ : IsPrimitiveRoot (zeta n K L) ↑n := zeta_spec n K L
hμ : ∀ (t : (ZMod ↑n)ˣ), IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑t) ↑n :=
  fun t => IsPrimitiveRoot.pow_of_coprime hζ (ZMod.val ↑t) (ZMod.val_coe_unit_coprime t)
src✝ : (L ≃ₐ[K] L) →* (ZMod ↑n)ˣ := IsPrimitiveRoot.autToPow K (_ : IsPrimitiveRoot (zeta n K L) ↑n)
f : L ≃ₐ[K] L
⊢ ↑(PowerBasis.equivOfMinpoly (IsPrimitiveRoot.powerBasis K hζ)
          (IsPrimitiveRoot.powerBasis K
            (_ :
              IsPrimitiveRoot
                (zeta n K L ^ ZMod.val ↑((IsPrimitiveRoot.autToPow K (_ : IsPrimitiveRoot (zeta n K L) ↑n)) f)) ↑n))
          (_ :
            minpoly K (IsPrimitiveRoot.powerBasis K hζ).gen =
              minpoly K
                (IsPrimitiveRoot.powerBasis K
                    (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑(OneHom.toFun (↑src✝) f)) ↑n)).gen))
      (IsPrimitiveRoot.powerBasis K hζ).gen =
    ↑f (IsPrimitiveRoot.powerBasis K hζ).gen

Next tactic:
simp only [AlgHom.coe_coe]
/-- The `MulEquiv` that takes an automorphism `f` to the element `k : (ZMod n)ˣ` such that
  `f μ = μ ^ k` for any root of unity `μ`. A strengthening of `IsPrimitiveRoot.autToPow`. -/
@[simps]
noncomputable def autEquivPow : (L ≃ₐ[K] L) ≃* (ZMod n)ˣ :=
  let hζ := zeta_spec n K L
  let hμ t := hζ.pow_of_coprime _ (ZMod.val_coe_unit_coprime t)
  { (zeta_spec n K L).autToPow K with
    invFun := fun t =>
      (hζ.powerBasis K).equivOfMinpoly ((hμ t).powerBasis K)
        (by
          haveI := IsCyclotomicExtension.neZero' n K L
          simp only [IsPrimitiveRoot.powerBasis_gen]
          have hr :=
            IsPrimitiveRoot.minpoly_eq_cyclotomic_of_irreducible
              ((zeta_spec n K L).pow_of_coprime _ (ZMod.val_coe_unit_coprime t)) h
          exact ((zeta_spec n K L).minpoly_eq_cyclotomic_of_irreducible h).symm.trans hr)
    left_inv := fun f => by
      simp only [MonoidHom.toFun_eq_coe]
      apply AlgEquiv.coe_algHom_injective
      apply (hζ.powerBasis K).algHom_ext
-- Porting note: the proof is slightly different because of coercions.
      simp only [AlgHom.coe_coe]
      

Proof state:
case a.h
n : ℕ+
K : Type u_1
inst✝⁴ : Field K
L : Type u_2
μ : L
inst✝³ : CommRing L
inst✝² : IsDomain L
hμ✝ : IsPrimitiveRoot μ ↑n
inst✝¹ : Algebra K L
inst✝ : IsCyclotomicExtension {n} K L
h : Irreducible (cyclotomic (↑n) K)
hζ : IsPrimitiveRoot (zeta n K L) ↑n := zeta_spec n K L
hμ : ∀ (t : (ZMod ↑n)ˣ), IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑t) ↑n :=
  fun t => IsPrimitiveRoot.pow_of_coprime hζ (ZMod.val ↑t) (ZMod.val_coe_unit_coprime t)
src✝ : (L ≃ₐ[K] L) →* (ZMod ↑n)ˣ := IsPrimitiveRoot.autToPow K (_ : IsPrimitiveRoot (zeta n K L) ↑n)
f : L ≃ₐ[K] L
⊢ (PowerBasis.equivOfMinpoly (IsPrimitiveRoot.powerBasis K hζ)
        (IsPrimitiveRoot.powerBasis K
          (_ :
            IsPrimitiveRoot
              (zeta n K L ^ ZMod.val ↑((IsPrimitiveRoot.autToPow K (_ : IsPrimitiveRoot (zeta n K L) ↑n)) f)) ↑n))
        (_ :
          minpoly K (IsPrimitiveRoot.powerBasis K hζ).gen =
            minpoly K
              (IsPrimitiveRoot.powerBasis K
                  (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑(OneHom.toFun (↑src✝) f)) ↑n)).gen))
      (IsPrimitiveRoot.powerBasis K hζ).gen =
    f (IsPrimitiveRoot.powerBasis K hζ).gen

Next tactic:
rw [PowerBasis.equivOfMinpoly_gen]
/-- The `MulEquiv` that takes an automorphism `f` to the element `k : (ZMod n)ˣ` such that
  `f μ = μ ^ k` for any root of unity `μ`. A strengthening of `IsPrimitiveRoot.autToPow`. -/
@[simps]
noncomputable def autEquivPow : (L ≃ₐ[K] L) ≃* (ZMod n)ˣ :=
  let hζ := zeta_spec n K L
  let hμ t := hζ.pow_of_coprime _ (ZMod.val_coe_unit_coprime t)
  { (zeta_spec n K L).autToPow K with
    invFun := fun t =>
      (hζ.powerBasis K).equivOfMinpoly ((hμ t).powerBasis K)
        (by
          haveI := IsCyclotomicExtension.neZero' n K L
          simp only [IsPrimitiveRoot.powerBasis_gen]
          have hr :=
            IsPrimitiveRoot.minpoly_eq_cyclotomic_of_irreducible
              ((zeta_spec n K L).pow_of_coprime _ (ZMod.val_coe_unit_coprime t)) h
          exact ((zeta_spec n K L).minpoly_eq_cyclotomic_of_irreducible h).symm.trans hr)
    left_inv := fun f => by
      simp only [MonoidHom.toFun_eq_coe]
      apply AlgEquiv.coe_algHom_injective
      apply (hζ.powerBasis K).algHom_ext
-- Porting note: the proof is slightly different because of coercions.
      simp only [AlgHom.coe_coe]
      rw [PowerBasis.equivOfMinpoly_gen]
      

Proof state:
case a.h
n : ℕ+
K : Type u_1
inst✝⁴ : Field K
L : Type u_2
μ : L
inst✝³ : CommRing L
inst✝² : IsDomain L
hμ✝ : IsPrimitiveRoot μ ↑n
inst✝¹ : Algebra K L
inst✝ : IsCyclotomicExtension {n} K L
h : Irreducible (cyclotomic (↑n) K)
hζ : IsPrimitiveRoot (zeta n K L) ↑n := zeta_spec n K L
hμ : ∀ (t : (ZMod ↑n)ˣ), IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑t) ↑n :=
  fun t => IsPrimitiveRoot.pow_of_coprime hζ (ZMod.val ↑t) (ZMod.val_coe_unit_coprime t)
src✝ : (L ≃ₐ[K] L) →* (ZMod ↑n)ˣ := IsPrimitiveRoot.autToPow K (_ : IsPrimitiveRoot (zeta n K L) ↑n)
f : L ≃ₐ[K] L
⊢ (IsPrimitiveRoot.powerBasis K
        (_ :
          IsPrimitiveRoot
            (zeta n K L ^ ZMod.val ↑((IsPrimitiveRoot.autToPow K (_ : IsPrimitiveRoot (zeta n K L) ↑n)) f)) ↑n)).gen =
    f (IsPrimitiveRoot.powerBasis K hζ).gen

Next tactic:
simp only [IsPrimitiveRoot.powerBasis_gen, IsPrimitiveRoot.autToPow_spec]
/-- The `MulEquiv` that takes an automorphism `f` to the element `k : (ZMod n)ˣ` such that
  `f μ = μ ^ k` for any root of unity `μ`. A strengthening of `IsPrimitiveRoot.autToPow`. -/
@[simps]
noncomputable def autEquivPow : (L ≃ₐ[K] L) ≃* (ZMod n)ˣ :=
  let hζ := zeta_spec n K L
  let hμ t := hζ.pow_of_coprime _ (ZMod.val_coe_unit_coprime t)
  { (zeta_spec n K L).autToPow K with
    invFun := fun t =>
      (hζ.powerBasis K).equivOfMinpoly ((hμ t).powerBasis K)
        (by
          haveI := IsCyclotomicExtension.neZero' n K L
          simp only [IsPrimitiveRoot.powerBasis_gen]
          have hr :=
            IsPrimitiveRoot.minpoly_eq_cyclotomic_of_irreducible
              ((zeta_spec n K L).pow_of_coprime _ (ZMod.val_coe_unit_coprime t)) h
          exact ((zeta_spec n K L).minpoly_eq_cyclotomic_of_irreducible h).symm.trans hr)
    left_inv := fun f => by
      simp only [MonoidHom.toFun_eq_coe]
      apply AlgEquiv.coe_algHom_injective
      apply (hζ.powerBasis K).algHom_ext
-- Porting note: the proof is slightly different because of coercions.
      simp only [AlgHom.coe_coe]
      rw [PowerBasis.equivOfMinpoly_gen]
      simp only [IsPrimitiveRoot.powerBasis_gen, IsPrimitiveRoot.autToPow_spec]
    right_inv := fun x => by
      

Proof state:
n : ℕ+
K : Type u_1
inst✝⁴ : Field K
L : Type u_2
μ : L
inst✝³ : CommRing L
inst✝² : IsDomain L
hμ✝ : IsPrimitiveRoot μ ↑n
inst✝¹ : Algebra K L
inst✝ : IsCyclotomicExtension {n} K L
h : Irreducible (cyclotomic (↑n) K)
hζ : IsPrimitiveRoot (zeta n K L) ↑n := zeta_spec n K L
hμ : ∀ (t : (ZMod ↑n)ˣ), IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑t) ↑n :=
  fun t => IsPrimitiveRoot.pow_of_coprime hζ (ZMod.val ↑t) (ZMod.val_coe_unit_coprime t)
src✝ : (L ≃ₐ[K] L) →* (ZMod ↑n)ˣ := IsPrimitiveRoot.autToPow K (_ : IsPrimitiveRoot (zeta n K L) ↑n)
x : (ZMod ↑n)ˣ
⊢ OneHom.toFun (↑src✝)
      ((fun t =>
          PowerBasis.equivOfMinpoly (IsPrimitiveRoot.powerBasis K hζ)
            (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑t) ↑n))
            (_ :
              minpoly K (IsPrimitiveRoot.powerBasis K hζ).gen =
                minpoly K (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑t) ↑n)).gen))
        x) =
    x

Next tactic:
simp only [MonoidHom.toFun_eq_coe]
/-- The `MulEquiv` that takes an automorphism `f` to the element `k : (ZMod n)ˣ` such that
  `f μ = μ ^ k` for any root of unity `μ`. A strengthening of `IsPrimitiveRoot.autToPow`. -/
@[simps]
noncomputable def autEquivPow : (L ≃ₐ[K] L) ≃* (ZMod n)ˣ :=
  let hζ := zeta_spec n K L
  let hμ t := hζ.pow_of_coprime _ (ZMod.val_coe_unit_coprime t)
  { (zeta_spec n K L).autToPow K with
    invFun := fun t =>
      (hζ.powerBasis K).equivOfMinpoly ((hμ t).powerBasis K)
        (by
          haveI := IsCyclotomicExtension.neZero' n K L
          simp only [IsPrimitiveRoot.powerBasis_gen]
          have hr :=
            IsPrimitiveRoot.minpoly_eq_cyclotomic_of_irreducible
              ((zeta_spec n K L).pow_of_coprime _ (ZMod.val_coe_unit_coprime t)) h
          exact ((zeta_spec n K L).minpoly_eq_cyclotomic_of_irreducible h).symm.trans hr)
    left_inv := fun f => by
      simp only [MonoidHom.toFun_eq_coe]
      apply AlgEquiv.coe_algHom_injective
      apply (hζ.powerBasis K).algHom_ext
-- Porting note: the proof is slightly different because of coercions.
      simp only [AlgHom.coe_coe]
      rw [PowerBasis.equivOfMinpoly_gen]
      simp only [IsPrimitiveRoot.powerBasis_gen, IsPrimitiveRoot.autToPow_spec]
    right_inv := fun x => by
      simp only [MonoidHom.toFun_eq_coe]
      

Proof state:
n : ℕ+
K : Type u_1
inst✝⁴ : Field K
L : Type u_2
μ : L
inst✝³ : CommRing L
inst✝² : IsDomain L
hμ✝ : IsPrimitiveRoot μ ↑n
inst✝¹ : Algebra K L
inst✝ : IsCyclotomicExtension {n} K L
h : Irreducible (cyclotomic (↑n) K)
hζ : IsPrimitiveRoot (zeta n K L) ↑n := zeta_spec n K L
hμ : ∀ (t : (ZMod ↑n)ˣ), IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑t) ↑n :=
  fun t => IsPrimitiveRoot.pow_of_coprime hζ (ZMod.val ↑t) (ZMod.val_coe_unit_coprime t)
src✝ : (L ≃ₐ[K] L) →* (ZMod ↑n)ˣ := IsPrimitiveRoot.autToPow K (_ : IsPrimitiveRoot (zeta n K L) ↑n)
x : (ZMod ↑n)ˣ
⊢ (IsPrimitiveRoot.autToPow K (_ : IsPrimitiveRoot (zeta n K L) ↑n))
      (PowerBasis.equivOfMinpoly (IsPrimitiveRoot.powerBasis K hζ)
        (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑x) ↑n))
        (_ :
          minpoly K (IsPrimitiveRoot.powerBasis K hζ).gen =
            minpoly K (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑x) ↑n)).gen)) =
    x

Next tactic:
generalize_proofs _ h
/-- The `MulEquiv` that takes an automorphism `f` to the element `k : (ZMod n)ˣ` such that
  `f μ = μ ^ k` for any root of unity `μ`. A strengthening of `IsPrimitiveRoot.autToPow`. -/
@[simps]
noncomputable def autEquivPow : (L ≃ₐ[K] L) ≃* (ZMod n)ˣ :=
  let hζ := zeta_spec n K L
  let hμ t := hζ.pow_of_coprime _ (ZMod.val_coe_unit_coprime t)
  { (zeta_spec n K L).autToPow K with
    invFun := fun t =>
      (hζ.powerBasis K).equivOfMinpoly ((hμ t).powerBasis K)
        (by
          haveI := IsCyclotomicExtension.neZero' n K L
          simp only [IsPrimitiveRoot.powerBasis_gen]
          have hr :=
            IsPrimitiveRoot.minpoly_eq_cyclotomic_of_irreducible
              ((zeta_spec n K L).pow_of_coprime _ (ZMod.val_coe_unit_coprime t)) h
          exact ((zeta_spec n K L).minpoly_eq_cyclotomic_of_irreducible h).symm.trans hr)
    left_inv := fun f => by
      simp only [MonoidHom.toFun_eq_coe]
      apply AlgEquiv.coe_algHom_injective
      apply (hζ.powerBasis K).algHom_ext
-- Porting note: the proof is slightly different because of coercions.
      simp only [AlgHom.coe_coe]
      rw [PowerBasis.equivOfMinpoly_gen]
      simp only [IsPrimitiveRoot.powerBasis_gen, IsPrimitiveRoot.autToPow_spec]
    right_inv := fun x => by
      simp only [MonoidHom.toFun_eq_coe]
      generalize_proofs _ h
      

Proof state:
n : ℕ+
K : Type u_1
inst✝⁴ : Field K
L : Type u_2
μ : L
inst✝³ : CommRing L
inst✝² : IsDomain L
hμ✝ : IsPrimitiveRoot μ ↑n
inst✝¹ : Algebra K L
inst✝ : IsCyclotomicExtension {n} K L
h✝¹ : Irreducible (cyclotomic (↑n) K)
hζ : IsPrimitiveRoot (zeta n K L) ↑n := zeta_spec n K L
hμ : ∀ (t : (ZMod ↑n)ˣ), IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑t) ↑n :=
  fun t => IsPrimitiveRoot.pow_of_coprime hζ (ZMod.val ↑t) (ZMod.val_coe_unit_coprime t)
src✝ : (L ≃ₐ[K] L) →* (ZMod ↑n)ˣ := IsPrimitiveRoot.autToPow K (_ : IsPrimitiveRoot (zeta n K L) ↑n)
x : (ZMod ↑n)ˣ
h✝ : IsPrimitiveRoot (zeta n K L) ↑n
h :
  minpoly K (IsPrimitiveRoot.powerBasis K hζ).gen =
    minpoly K (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑x) ↑n)).gen
⊢ (IsPrimitiveRoot.autToPow K h✝)
      (PowerBasis.equivOfMinpoly (IsPrimitiveRoot.powerBasis K hζ)
        (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑x) ↑n)) h) =
    x

Next tactic:
have key := hζ.autToPow_spec K ((hζ.powerBasis K).equivOfMinpoly ((hμ x).powerBasis K) h)
/-- The `MulEquiv` that takes an automorphism `f` to the element `k : (ZMod n)ˣ` such that
  `f μ = μ ^ k` for any root of unity `μ`. A strengthening of `IsPrimitiveRoot.autToPow`. -/
@[simps]
noncomputable def autEquivPow : (L ≃ₐ[K] L) ≃* (ZMod n)ˣ :=
  let hζ := zeta_spec n K L
  let hμ t := hζ.pow_of_coprime _ (ZMod.val_coe_unit_coprime t)
  { (zeta_spec n K L).autToPow K with
    invFun := fun t =>
      (hζ.powerBasis K).equivOfMinpoly ((hμ t).powerBasis K)
        (by
          haveI := IsCyclotomicExtension.neZero' n K L
          simp only [IsPrimitiveRoot.powerBasis_gen]
          have hr :=
            IsPrimitiveRoot.minpoly_eq_cyclotomic_of_irreducible
              ((zeta_spec n K L).pow_of_coprime _ (ZMod.val_coe_unit_coprime t)) h
          exact ((zeta_spec n K L).minpoly_eq_cyclotomic_of_irreducible h).symm.trans hr)
    left_inv := fun f => by
      simp only [MonoidHom.toFun_eq_coe]
      apply AlgEquiv.coe_algHom_injective
      apply (hζ.powerBasis K).algHom_ext
-- Porting note: the proof is slightly different because of coercions.
      simp only [AlgHom.coe_coe]
      rw [PowerBasis.equivOfMinpoly_gen]
      simp only [IsPrimitiveRoot.powerBasis_gen, IsPrimitiveRoot.autToPow_spec]
    right_inv := fun x => by
      simp only [MonoidHom.toFun_eq_coe]
      generalize_proofs _ h
      have key := hζ.autToPow_spec K ((hζ.powerBasis K).equivOfMinpoly ((hμ x).powerBasis K) h)
      

Proof state:
n : ℕ+
K : Type u_1
inst✝⁴ : Field K
L : Type u_2
μ : L
inst✝³ : CommRing L
inst✝² : IsDomain L
hμ✝ : IsPrimitiveRoot μ ↑n
inst✝¹ : Algebra K L
inst✝ : IsCyclotomicExtension {n} K L
h✝¹ : Irreducible (cyclotomic (↑n) K)
hζ : IsPrimitiveRoot (zeta n K L) ↑n := zeta_spec n K L
hμ : ∀ (t : (ZMod ↑n)ˣ), IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑t) ↑n :=
  fun t => IsPrimitiveRoot.pow_of_coprime hζ (ZMod.val ↑t) (ZMod.val_coe_unit_coprime t)
src✝ : (L ≃ₐ[K] L) →* (ZMod ↑n)ˣ := IsPrimitiveRoot.autToPow K (_ : IsPrimitiveRoot (zeta n K L) ↑n)
x : (ZMod ↑n)ˣ
h✝ : IsPrimitiveRoot (zeta n K L) ↑n
h :
  minpoly K (IsPrimitiveRoot.powerBasis K hζ).gen =
    minpoly K (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑x) ↑n)).gen
key :
  zeta n K L ^
      ZMod.val
        ↑((IsPrimitiveRoot.autToPow K hζ)
            (PowerBasis.equivOfMinpoly (IsPrimitiveRoot.powerBasis K hζ)
              (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑x) ↑n)) h)) =
    (PowerBasis.equivOfMinpoly (IsPrimitiveRoot.powerBasis K hζ)
        (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑x) ↑n)) h)
      (zeta n K L)
⊢ (IsPrimitiveRoot.autToPow K h✝)
      (PowerBasis.equivOfMinpoly (IsPrimitiveRoot.powerBasis K hζ)
        (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑x) ↑n)) h) =
    x

Next tactic:
have := (hζ.powerBasis K).equivOfMinpoly_gen ((hμ x).powerBasis K) h
/-- The `MulEquiv` that takes an automorphism `f` to the element `k : (ZMod n)ˣ` such that
  `f μ = μ ^ k` for any root of unity `μ`. A strengthening of `IsPrimitiveRoot.autToPow`. -/
@[simps]
noncomputable def autEquivPow : (L ≃ₐ[K] L) ≃* (ZMod n)ˣ :=
  let hζ := zeta_spec n K L
  let hμ t := hζ.pow_of_coprime _ (ZMod.val_coe_unit_coprime t)
  { (zeta_spec n K L).autToPow K with
    invFun := fun t =>
      (hζ.powerBasis K).equivOfMinpoly ((hμ t).powerBasis K)
        (by
          haveI := IsCyclotomicExtension.neZero' n K L
          simp only [IsPrimitiveRoot.powerBasis_gen]
          have hr :=
            IsPrimitiveRoot.minpoly_eq_cyclotomic_of_irreducible
              ((zeta_spec n K L).pow_of_coprime _ (ZMod.val_coe_unit_coprime t)) h
          exact ((zeta_spec n K L).minpoly_eq_cyclotomic_of_irreducible h).symm.trans hr)
    left_inv := fun f => by
      simp only [MonoidHom.toFun_eq_coe]
      apply AlgEquiv.coe_algHom_injective
      apply (hζ.powerBasis K).algHom_ext
-- Porting note: the proof is slightly different because of coercions.
      simp only [AlgHom.coe_coe]
      rw [PowerBasis.equivOfMinpoly_gen]
      simp only [IsPrimitiveRoot.powerBasis_gen, IsPrimitiveRoot.autToPow_spec]
    right_inv := fun x => by
      simp only [MonoidHom.toFun_eq_coe]
      generalize_proofs _ h
      have key := hζ.autToPow_spec K ((hζ.powerBasis K).equivOfMinpoly ((hμ x).powerBasis K) h)
      have := (hζ.powerBasis K).equivOfMinpoly_gen ((hμ x).powerBasis K) h
      rw [hζ.powerBasis_gen K] at this
      rw [this, IsPrimitiveRoot.powerBasis_gen] at key
-- Porting note: was `rw ← hζ.coe_to_roots_of_unity_coe at key {occs := occurrences.pos [1, 5]}`.
      conv at key =>
        congr; congr
        rw [← hζ.val_toRootsOfUnity_coe]
        rfl; rfl
        

Proof state:
case a
n : ℕ+
K : Type u_1
inst✝⁴ : Field K
L : Type u_2
μ : L
inst✝³ : CommRing L
inst✝² : IsDomain L
hμ✝ : IsPrimitiveRoot μ ↑n
inst✝¹ : Algebra K L
inst✝ : IsCyclotomicExtension {n} K L
h✝¹ : Irreducible (cyclotomic (↑n) K)
hζ : IsPrimitiveRoot (zeta n K L) ↑n := zeta_spec n K L
hμ : ∀ (t : (ZMod ↑n)ˣ), IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑t) ↑n :=
  fun t => IsPrimitiveRoot.pow_of_coprime hζ (ZMod.val ↑t) (ZMod.val_coe_unit_coprime t)
src✝ : (L ≃ₐ[K] L) →* (ZMod ↑n)ˣ := IsPrimitiveRoot.autToPow K (_ : IsPrimitiveRoot (zeta n K L) ↑n)
x : (ZMod ↑n)ˣ
h✝ : IsPrimitiveRoot (zeta n K L) ↑n
h :
  minpoly K (IsPrimitiveRoot.powerBasis K hζ).gen =
    minpoly K (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑x) ↑n)).gen
key :
  zeta n K L ^
      ZMod.val
        ↑((IsPrimitiveRoot.autToPow K hζ)
            (PowerBasis.equivOfMinpoly (IsPrimitiveRoot.powerBasis K hζ)
              (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑x) ↑n)) h)) =
    zeta n K L ^ ZMod.val ↑x
this :
  (PowerBasis.equivOfMinpoly (IsPrimitiveRoot.powerBasis K hζ)
        (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑x) ↑n)) h)
      (zeta n K L) =
    (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L ^ ZMod.val ↑x) ↑n)).gen
| zeta n K L ^ ZMod.val ↑x

Next tactic:
rw [← hζ.val_toRootsOfUnity_coe]
theorem fromZetaAut_spec : fromZetaAut hμ h (zeta n K L) = μ := by
  

Proof state:
n : ℕ+
K : Type u_1
inst✝⁴ : Field K
L : Type u_2
μ : L
inst✝³ : CommRing L
inst✝² : IsDomain L
hμ : IsPrimitiveRoot μ ↑n
inst✝¹ : Algebra K L
inst✝ : IsCyclotomicExtension {n} K L
h : Irreducible (cyclotomic (↑n) K)
⊢ (fromZetaAut hμ h) (zeta n K L) = μ

Next tactic:
simp_rw [fromZetaAut, autEquivPow_symm_apply]
theorem fromZetaAut_spec : fromZetaAut hμ h (zeta n K L) = μ := by
  simp_rw [fromZetaAut, autEquivPow_symm_apply]
-- Porting note: `generalize_proofs` did not generalize the same proofs, making the proof different.
  

Proof state:
n : ℕ+
K : Type u_1
inst✝⁴ : Field K
L : Type u_2
μ : L
inst✝³ : CommRing L
inst✝² : IsDomain L
hμ : IsPrimitiveRoot μ ↑n
inst✝¹ : Algebra K L
inst✝ : IsCyclotomicExtension {n} K L
h : Irreducible (cyclotomic (↑n) K)
⊢ (PowerBasis.equivOfMinpoly (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L) ↑n))
        (IsPrimitiveRoot.powerBasis K
          (_ :
            IsPrimitiveRoot
              (zeta n K L ^
                ZMod.val
                  ↑(ZMod.unitOfCoprime (Exists.choose (_ : ∃ i < ↑n, zeta n K L ^ i = μ))
                      (_ : Nat.Coprime (Exists.choose (_ : ∃ i < ↑n, zeta n K L ^ i = μ)) ↑n)))
              ↑n))
        (_ :
          minpoly K (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L) ↑n)).gen =
            minpoly K
              (IsPrimitiveRoot.powerBasis K
                  (_ :
                    IsPrimitiveRoot
                      (zeta n K L ^
                        ZMod.val
                          ↑(ZMod.unitOfCoprime (Exists.choose (_ : ∃ i < ↑n, zeta n K L ^ i = μ))
                              (_ : Nat.Coprime (Exists.choose (_ : ∃ i < ↑n, zeta n K L ^ i = μ)) ↑n)))
                      ↑n)).gen))
      (zeta n K L) =
    μ

Next tactic:
generalize_proofs h1 h2
theorem fromZetaAut_spec : fromZetaAut hμ h (zeta n K L) = μ := by
  simp_rw [fromZetaAut, autEquivPow_symm_apply]
-- Porting note: `generalize_proofs` did not generalize the same proofs, making the proof different.
  generalize_proofs h1 h2
  

Proof state:
n : ℕ+
K : Type u_1
inst✝⁴ : Field K
L : Type u_2
μ : L
inst✝³ : CommRing L
inst✝² : IsDomain L
hμ : IsPrimitiveRoot μ ↑n
inst✝¹ : Algebra K L
inst✝ : IsCyclotomicExtension {n} K L
h : Irreducible (cyclotomic (↑n) K)
h1 :
  IsPrimitiveRoot
    (zeta n K L ^
      ZMod.val
        ↑(ZMod.unitOfCoprime (Exists.choose (_ : ∃ i < ↑n, zeta n K L ^ i = μ))
            (_ : Nat.Coprime (Exists.choose (_ : ∃ i < ↑n, zeta n K L ^ i = μ)) ↑n)))
    ↑n
h2 :
  minpoly K (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L) ↑n)).gen =
    minpoly K (IsPrimitiveRoot.powerBasis K h1).gen
⊢ (PowerBasis.equivOfMinpoly (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L) ↑n))
        (IsPrimitiveRoot.powerBasis K h1) h2)
      (zeta n K L) =
    μ

Next tactic:
nth_rewrite 4 [← (zeta_spec n K L).powerBasis_gen K]
theorem fromZetaAut_spec : fromZetaAut hμ h (zeta n K L) = μ := by
  simp_rw [fromZetaAut, autEquivPow_symm_apply]
-- Porting note: `generalize_proofs` did not generalize the same proofs, making the proof different.
  generalize_proofs h1 h2
  nth_rewrite 4 [← (zeta_spec n K L).powerBasis_gen K]
  

Proof state:
n : ℕ+
K : Type u_1
inst✝⁴ : Field K
L : Type u_2
μ : L
inst✝³ : CommRing L
inst✝² : IsDomain L
hμ : IsPrimitiveRoot μ ↑n
inst✝¹ : Algebra K L
inst✝ : IsCyclotomicExtension {n} K L
h : Irreducible (cyclotomic (↑n) K)
h1 :
  IsPrimitiveRoot
    (zeta n K L ^
      ZMod.val
        ↑(ZMod.unitOfCoprime (Exists.choose (_ : ∃ i < ↑n, zeta n K L ^ i = μ))
            (_ : Nat.Coprime (Exists.choose (_ : ∃ i < ↑n, zeta n K L ^ i = μ)) ↑n)))
    ↑n
h2 :
  minpoly K (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L) ↑n)).gen =
    minpoly K (IsPrimitiveRoot.powerBasis K h1).gen
⊢ (PowerBasis.equivOfMinpoly (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L) ↑n))
        (IsPrimitiveRoot.powerBasis K h1) h2)
      (IsPrimitiveRoot.powerBasis K (_ : IsPrimitiveRoot (zeta n K L) ↑n)).gen =
    μ

Next tactic:
have := Exists.choose_spec ((zeta_spec n K L).eq_pow_of_pow_eq_one hμ.pow_eq_one n.pos)