/-- 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 =>
        

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)) =
    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
        ↑((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

Next tactic:
congr; congr
        rw [← hζ.val_toRootsOfUnity_coe]
        rfl; rfl
        rw [← hζ.val_toRootsOfUnity_coe]