l3lab/ntp-mathlib huggingface dataset:
/-- 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
    

Proof state:
case intro
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)
cramer :
  mulVec (traceMatrix K ⇑B.basis) ((Matrix.cramer (traceMatrix K ⇑B.basis)) fun i => (trace K L) (z * B.basis i)) =
    det (traceMatrix K ⇑B.basis) • fun i => (trace K L) (z * B.basis i)
i : Fin B.dim
x✝ : i ∈ univ
r : R
hr : (algebraMap R K) r = discr K ⇑B.basis • (B.basis.repr z) i
⊢ discr K ⇑B.basis • (B.basis.repr z) i • B.basis i ∈ adjoin R {B.gen}

Next tactic:
rw [← smul_assoc, ← hr, algebraMap_smul]
/-- 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]
    

Proof state:
case intro
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)
cramer :
  mulVec (traceMatrix K ⇑B.basis) ((Matrix.cramer (traceMatrix K ⇑B.basis)) fun i => (trace K L) (z * B.basis i)) =
    det (traceMatrix K ⇑B.basis) • fun i => (trace K L) (z * B.basis i)
i : Fin B.dim
x✝ : i ∈ univ
r : R
hr : (algebraMap R K) r = discr K ⇑B.basis • (B.basis.repr z) i
⊢ r • B.basis i ∈ adjoin R {B.gen}

Next tactic:
refine' Subalgebra.smul_mem _ _ _
/-- 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 _ _ _
    

Proof state:
case intro
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)
cramer :
  mulVec (traceMatrix K ⇑B.basis) ((Matrix.cramer (traceMatrix K ⇑B.basis)) fun i => (trace K L) (z * B.basis i)) =
    det (traceMatrix K ⇑B.basis) • fun i => (trace K L) (z * B.basis i)
i : Fin B.dim
x✝ : i ∈ univ
r : R
hr : (algebraMap R K) r = discr K ⇑B.basis • (B.basis.repr z) i
⊢ B.basis i ∈ adjoin R {B.gen}

Next tactic:
rw [B.basis_eq_pow i]
/-- 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]
    

Proof state:
case intro
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)
cramer :
  mulVec (traceMatrix K ⇑B.basis) ((Matrix.cramer (traceMatrix K ⇑B.basis)) fun i => (trace K L) (z * B.basis i)) =
    det (traceMatrix K ⇑B.basis) • fun i => (trace K L) (z * B.basis i)
i : Fin B.dim
x✝ : i ∈ univ
r : R
hr : (algebraMap R K) r = discr K ⇑B.basis • (B.basis.repr z) i
⊢ B.gen ^ ↑i ∈ adjoin R {B.gen}

Next tactic:
refine' Subalgebra.pow_mem _ (subset_adjoin (Set.mem_singleton _)) _
/-- 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 _)) _
  

Proof state:
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)
cramer :
  mulVec (traceMatrix K ⇑B.basis) ((Matrix.cramer (traceMatrix K ⇑B.basis)) fun i => (trace K L) (z * B.basis i)) =
    det (traceMatrix K ⇑B.basis) • fun i => (trace K L) (z * B.basis i)
⊢ ∀ (i : Fin B.dim), (det (traceMatrix K ⇑B.basis) • (Basis.equivFun B.basis) z) i ∈ ⊥

Next tactic:
intro i
/-- 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
  

Proof state:
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)
cramer :
  mulVec (traceMatrix K ⇑B.basis) ((Matrix.cramer (traceMatrix K ⇑B.basis)) fun i => (trace K L) (z * B.basis i)) =
    det (traceMatrix K ⇑B.basis) • fun i => (trace K L) (z * B.basis i)
i : Fin B.dim
⊢ (det (traceMatrix K ⇑B.basis) • (Basis.equivFun B.basis) z) i ∈ ⊥

Next tactic:
rw [← H, ← mulVec_smul] at cramer
/-- 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
  

Proof state:
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)
cramer :
  mulVec (traceMatrix K ⇑B.basis) ((Matrix.cramer (traceMatrix K ⇑B.basis)) fun i => (trace K L) (z * B.basis i)) =
    mulVec (traceMatrix K ⇑B.basis) (det (traceMatrix K ⇑B.basis) • (Basis.equivFun B.basis) z)
i : Fin B.dim
⊢ (det (traceMatrix K ⇑B.basis) • (Basis.equivFun B.basis) z) i ∈ ⊥

Next tactic:
replace cramer := congr_arg (mulVec (traceMatrix K B.basis)⁻¹) cramer
/-- 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
  

Proof state:
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 :
  mulVec (traceMatrix K ⇑B.basis)⁻¹
      (mulVec (traceMatrix K ⇑B.basis)
        ((Matrix.cramer (traceMatrix K ⇑B.basis)) fun i => (trace K L) (z * B.basis i))) =
    mulVec (traceMatrix K ⇑B.basis)⁻¹
      (mulVec (traceMatrix K ⇑B.basis) (det (traceMatrix K ⇑B.basis) • (Basis.equivFun B.basis) z))
⊢ (det (traceMatrix K ⇑B.basis) • (Basis.equivFun B.basis) z) i ∈ ⊥

Next tactic:
rw [mulVec_mulVec, nonsing_inv_mul _ hinv, mulVec_mulVec, nonsing_inv_mul _ hinv, one_mulVec,
    one_mulVec] at cramer