/-- Let `K` be the fraction field of an integrally closed domain `R` and let `L` be a finite
separable extension of `K`. Let `B : PowerBasis K L` be such that `IsIntegral R B.gen`.
Then for all, `z : L` that are integral over `R`, we have
`(discr K B.basis) • z ∈ adjoin R ({B.gen} : Set L)`. -/
theorem discr_mul_isIntegral_mem_adjoin [IsSeparable K L] [IsIntegrallyClosed R]
    [IsFractionRing R K] {B : PowerBasis K L} (hint : IsIntegral R B.gen) {z : L}
    (hz : IsIntegral R z) : discr K B.basis • z ∈ adjoin R ({B.gen} : Set L) := by
  have hinv : IsUnit (traceMatrix K B.basis).det := by
    simpa [← discr_def] using discr_isUnit_of_basis _ B.basis
  have H :
    (traceMatrix K B.basis).det • (traceMatrix K B.basis).mulVec (B.basis.equivFun z) =
      (traceMatrix K B.basis).det • fun i => trace K L (z * B.basis i) :=
    by congr; exact traceMatrix_of_basis_mulVec _ _
  have cramer := mulVec_cramer (traceMatrix K B.basis) fun i => trace K L (z * B.basis i)
  suffices ∀ i, ((traceMatrix K B.basis).det • B.basis.equivFun z) i ∈ (⊥ : Subalgebra R K) by
    rw [← B.basis.sum_repr z, Finset.smul_sum]
    refine' Subalgebra.sum_mem _ fun i _ => _
    replace this := this i
    rw [← discr_def, Pi.smul_apply, mem_bot] at this
    obtain ⟨r, hr⟩ := this
    rw [Basis.equivFun_apply] at hr
    rw [← smul_assoc, ← hr, algebraMap_smul]
    refine' Subalgebra.smul_mem _ _ _
    rw [B.basis_eq_pow i]
    refine' Subalgebra.pow_mem _ (subset_adjoin (Set.mem_singleton _)) _
  intro i
  rw [← H, ← mulVec_smul] at cramer
  replace cramer := congr_arg (mulVec (traceMatrix K B.basis)⁻¹) cramer
  rw [mulVec_mulVec, nonsing_inv_mul _ hinv, mulVec_mulVec, nonsing_inv_mul _ hinv, one_mulVec,
    one_mulVec] at cramer
  rw [← congr_fun cramer i, cramer_apply, det_apply]
  refine'
    Subalgebra.sum_mem _ fun σ _ => Subalgebra.zsmul_mem _ (Subalgebra.prod_mem _ fun j _ => _) _
  by_cases hji : j = i
  · simp only [updateColumn_apply, hji, eq_self_iff_true, PowerBasis.coe_basis]
    

Proof state:
case pos
A : Type u
B✝ : Type v
C : Type z
ι : Type w
inst✝²² : DecidableEq ι
inst✝²¹ : CommRing A
inst✝²⁰ : CommRing B✝
inst✝¹⁹ : Algebra A B✝
inst✝¹⁸ : CommRing C
inst✝¹⁷ : Algebra A C
ι' : Type u_1
inst✝¹⁶ : Fintype ι'
inst✝¹⁵ : Fintype ι
inst✝¹⁴ : DecidableEq ι'
K : Type u
L : Type v
E : Type z
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Field E
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra K E
inst✝⁸ : Module.Finite K L
inst✝⁷ : IsAlgClosed E
b : ι → L
pb : PowerBasis K L
R : Type z
inst✝⁶ : CommRing R
inst✝⁵ : Algebra R K
inst✝⁴ : Algebra R L
inst✝³ : IsScalarTower R K L
inst✝² : IsSeparable K L
inst✝¹ : IsIntegrallyClosed R
inst✝ : IsFractionRing R K
B : PowerBasis K L
hint : IsIntegral R B.gen
z : L
hz : IsIntegral R z
hinv : IsUnit (det (traceMatrix K ⇑B.basis))
H :
  det (traceMatrix K ⇑B.basis) • mulVec (traceMatrix K ⇑B.basis) ((Basis.equivFun B.basis) z) =
    det (traceMatrix K ⇑B.basis) • fun i => (trace K L) (z * B.basis i)
i : Fin B.dim
cramer :
  ((Matrix.cramer (traceMatrix K ⇑B.basis)) fun i => (trace K L) (z * B.basis i)) =
    det (traceMatrix K ⇑B.basis) • (Basis.equivFun B.basis) z
σ : Equiv.Perm (Fin B.dim)
x✝¹ : σ ∈ univ
j : Fin B.dim
x✝ : j ∈ univ
hji : j = i
⊢ (if True then (trace K L) (z * B.gen ^ ↑(σ i)) else traceMatrix K (fun i => B.gen ^ ↑i) (σ i) i) ∈ ⊥

Next tactic:
exact mem_bot.2 (IsIntegrallyClosed.isIntegral_iff.1 <| isIntegral_trace (hz.mul <| hint.pow _))