l3lab/ntp-mathlib huggingface dataset:
/-- If `L` is a finite extension of `K = Frac(A)`,
then `L` has a basis over `A` consisting of integral elements. -/
theorem FiniteDimensional.exists_is_basis_integral :
    ∃ (s : Finset L) (b : Basis s K L), ∀ x, IsIntegral A (b x) := by
  letI := Classical.decEq L
  letI : IsNoetherian K L := IsNoetherian.iff_fg.2 inferInstance
  let s' := IsNoetherian.finsetBasisIndex K L
  let bs' := IsNoetherian.finsetBasis K L
  obtain ⟨y, hy, his'⟩ := exists_integral_multiples A K (Finset.univ.image bs')
  have hy' : algebraMap A L y ≠ 0 := by
    refine' mt ((injective_iff_map_eq_zero (algebraMap A L)).mp _ _) hy
    rw [IsScalarTower.algebraMap_eq A K L]
    exact (algebraMap K L).injective.comp (IsFractionRing.injective A K)
  refine ⟨s', bs'.map {Algebra.lmul _ _ (algebraMap A L y) with
    toFun := fun x => algebraMap A L y * x
    invFun := fun x => (algebraMap A L y)⁻¹ * x
    left_inv := ?_
    right_inv := ?_}, ?_⟩
  · intro x; simp only [inv_mul_cancel_left₀ hy']
  · intro x; simp only [mul_inv_cancel_left₀ hy']
  · rintro ⟨x', hx'⟩
    

Proof state:
case intro.intro.refine_3.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁵ : CommRing R
inst✝¹⁴ : CommRing A
inst✝¹³ : Field K
inst✝¹² : IsDomain A
inst✝¹¹ : Algebra A K
inst✝¹⁰ : IsFractionRing A K
L : Type u_4
inst✝⁹ : Field L
C : Type u_5
inst✝⁸ : CommRing C
inst✝⁷ : Algebra K L
inst✝⁶ : Algebra A L
inst✝⁵ : IsScalarTower A K L
inst✝⁴ : Algebra C L
inst✝³ : IsIntegralClosure C A L
inst✝² : Algebra A C
inst✝¹ : IsScalarTower A C L
inst✝ : FiniteDimensional K L
this✝ : DecidableEq L := Classical.decEq L
this : IsNoetherian K L := IsNoetherian.iff_fg.mpr inferInstance
s' : Finset L := IsNoetherian.finsetBasisIndex K L
bs' : Basis { x // x ∈ IsNoetherian.finsetBasisIndex K L } K L := IsNoetherian.finsetBasis K L
y : A
hy : y ≠ 0
his' : ∀ x ∈ Finset.image (⇑bs') Finset.univ, IsIntegral A (y • x)
hy' : (algebraMap A L) y ≠ 0
x' : L
hx' : x' ∈ s'
⊢ IsIntegral A
    ((Basis.map bs'
        (let src := (lmul K L) ((algebraMap A L) y);
        {
          toLinearMap :=
            {
              toAddHom :=
                { toFun := fun x => (algebraMap A L) y * x,
                  map_add' :=
                    (_ :
                      ∀ (x y : L),
                        AddHom.toFun src.toAddHom (x + y) =
                          AddHom.toFun src.toAddHom x + AddHom.toFun src.toAddHom y) },
              map_smul' :=
                (_ :
                  ∀ (r : K) (x : L),
                    AddHom.toFun src.toAddHom (r • x) = (RingHom.id K) r • AddHom.toFun src.toAddHom x) },
          invFun := fun x => ((algebraMap A L) y)⁻¹ * x,
          left_inv := (_ : ∀ (x : L), ((algebraMap A L) y)⁻¹ * ((algebraMap A L) y * x) = x),
          right_inv := (_ : ∀ (x : L), (algebraMap A L) y * (((algebraMap A L) y)⁻¹ * x) = x) }))
      { val := x', property := hx' })

Next tactic:
simp only [Algebra.smul_def, Finset.mem_image, exists_prop, Finset.mem_univ,
      true_and_iff] at his'
/-- If `L` is a finite extension of `K = Frac(A)`,
then `L` has a basis over `A` consisting of integral elements. -/
theorem FiniteDimensional.exists_is_basis_integral :
    ∃ (s : Finset L) (b : Basis s K L), ∀ x, IsIntegral A (b x) := by
  letI := Classical.decEq L
  letI : IsNoetherian K L := IsNoetherian.iff_fg.2 inferInstance
  let s' := IsNoetherian.finsetBasisIndex K L
  let bs' := IsNoetherian.finsetBasis K L
  obtain ⟨y, hy, his'⟩ := exists_integral_multiples A K (Finset.univ.image bs')
  have hy' : algebraMap A L y ≠ 0 := by
    refine' mt ((injective_iff_map_eq_zero (algebraMap A L)).mp _ _) hy
    rw [IsScalarTower.algebraMap_eq A K L]
    exact (algebraMap K L).injective.comp (IsFractionRing.injective A K)
  refine ⟨s', bs'.map {Algebra.lmul _ _ (algebraMap A L y) with
    toFun := fun x => algebraMap A L y * x
    invFun := fun x => (algebraMap A L y)⁻¹ * x
    left_inv := ?_
    right_inv := ?_}, ?_⟩
  · intro x; simp only [inv_mul_cancel_left₀ hy']
  · intro x; simp only [mul_inv_cancel_left₀ hy']
  · rintro ⟨x', hx'⟩
    simp only [Algebra.smul_def, Finset.mem_image, exists_prop, Finset.mem_univ,
      true_and_iff] at his'
    

Proof state:
case intro.intro.refine_3.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁵ : CommRing R
inst✝¹⁴ : CommRing A
inst✝¹³ : Field K
inst✝¹² : IsDomain A
inst✝¹¹ : Algebra A K
inst✝¹⁰ : IsFractionRing A K
L : Type u_4
inst✝⁹ : Field L
C : Type u_5
inst✝⁸ : CommRing C
inst✝⁷ : Algebra K L
inst✝⁶ : Algebra A L
inst✝⁵ : IsScalarTower A K L
inst✝⁴ : Algebra C L
inst✝³ : IsIntegralClosure C A L
inst✝² : Algebra A C
inst✝¹ : IsScalarTower A C L
inst✝ : FiniteDimensional K L
this✝ : DecidableEq L := Classical.decEq L
this : IsNoetherian K L := IsNoetherian.iff_fg.mpr inferInstance
s' : Finset L := IsNoetherian.finsetBasisIndex K L
bs' : Basis { x // x ∈ IsNoetherian.finsetBasisIndex K L } K L := IsNoetherian.finsetBasis K L
y : A
hy : y ≠ 0
hy' : (algebraMap A L) y ≠ 0
x' : L
hx' : x' ∈ s'
his' : ∀ (x : L), (∃ a, (IsNoetherian.finsetBasis K L) a = x) → IsIntegral A ((algebraMap A L) y * x)
⊢ IsIntegral A
    ((Basis.map bs'
        (let src := (lmul K L) ((algebraMap A L) y);
        {
          toLinearMap :=
            {
              toAddHom :=
                { toFun := fun x => (algebraMap A L) y * x,
                  map_add' :=
                    (_ :
                      ∀ (x y : L),
                        AddHom.toFun src.toAddHom (x + y) =
                          AddHom.toFun src.toAddHom x + AddHom.toFun src.toAddHom y) },
              map_smul' :=
                (_ :
                  ∀ (r : K) (x : L),
                    AddHom.toFun src.toAddHom (r • x) = (RingHom.id K) r • AddHom.toFun src.toAddHom x) },
          invFun := fun x => ((algebraMap A L) y)⁻¹ * x,
          left_inv := (_ : ∀ (x : L), ((algebraMap A L) y)⁻¹ * ((algebraMap A L) y * x) = x),
          right_inv := (_ : ∀ (x : L), (algebraMap A L) y * (((algebraMap A L) y)⁻¹ * x) = x) }))
      { val := x', property := hx' })

Next tactic:
simp only [Basis.map_apply, LinearEquiv.coe_mk]
/-- If `L` is a finite extension of `K = Frac(A)`,
then `L` has a basis over `A` consisting of integral elements. -/
theorem FiniteDimensional.exists_is_basis_integral :
    ∃ (s : Finset L) (b : Basis s K L), ∀ x, IsIntegral A (b x) := by
  letI := Classical.decEq L
  letI : IsNoetherian K L := IsNoetherian.iff_fg.2 inferInstance
  let s' := IsNoetherian.finsetBasisIndex K L
  let bs' := IsNoetherian.finsetBasis K L
  obtain ⟨y, hy, his'⟩ := exists_integral_multiples A K (Finset.univ.image bs')
  have hy' : algebraMap A L y ≠ 0 := by
    refine' mt ((injective_iff_map_eq_zero (algebraMap A L)).mp _ _) hy
    rw [IsScalarTower.algebraMap_eq A K L]
    exact (algebraMap K L).injective.comp (IsFractionRing.injective A K)
  refine ⟨s', bs'.map {Algebra.lmul _ _ (algebraMap A L y) with
    toFun := fun x => algebraMap A L y * x
    invFun := fun x => (algebraMap A L y)⁻¹ * x
    left_inv := ?_
    right_inv := ?_}, ?_⟩
  · intro x; simp only [inv_mul_cancel_left₀ hy']
  · intro x; simp only [mul_inv_cancel_left₀ hy']
  · rintro ⟨x', hx'⟩
    simp only [Algebra.smul_def, Finset.mem_image, exists_prop, Finset.mem_univ,
      true_and_iff] at his'
    simp only [Basis.map_apply, LinearEquiv.coe_mk]
    

Proof state:
case intro.intro.refine_3.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁵ : CommRing R
inst✝¹⁴ : CommRing A
inst✝¹³ : Field K
inst✝¹² : IsDomain A
inst✝¹¹ : Algebra A K
inst✝¹⁰ : IsFractionRing A K
L : Type u_4
inst✝⁹ : Field L
C : Type u_5
inst✝⁸ : CommRing C
inst✝⁷ : Algebra K L
inst✝⁶ : Algebra A L
inst✝⁵ : IsScalarTower A K L
inst✝⁴ : Algebra C L
inst✝³ : IsIntegralClosure C A L
inst✝² : Algebra A C
inst✝¹ : IsScalarTower A C L
inst✝ : FiniteDimensional K L
this✝ : DecidableEq L := Classical.decEq L
this : IsNoetherian K L := IsNoetherian.iff_fg.mpr inferInstance
s' : Finset L := IsNoetherian.finsetBasisIndex K L
bs' : Basis { x // x ∈ IsNoetherian.finsetBasisIndex K L } K L := IsNoetherian.finsetBasis K L
y : A
hy : y ≠ 0
hy' : (algebraMap A L) y ≠ 0
x' : L
hx' : x' ∈ s'
his' : ∀ (x : L), (∃ a, (IsNoetherian.finsetBasis K L) a = x) → IsIntegral A ((algebraMap A L) y * x)
⊢ IsIntegral A ((algebraMap A L) y * (IsNoetherian.finsetBasis K L) { val := x', property := hx' })

Next tactic:
exact his' _ ⟨_, rfl⟩
theorem IsIntegralClosure.isNoetherian [IsIntegrallyClosed A] [IsNoetherianRing A] :
    IsNoetherian A C := by
  

Proof state:
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : IsIntegrallyClosed A
inst✝ : IsNoetherianRing A
⊢ IsNoetherian A C

Next tactic:
haveI := Classical.decEq L
theorem IsIntegralClosure.isNoetherian [IsIntegrallyClosed A] [IsNoetherianRing A] :
    IsNoetherian A C := by
  haveI := Classical.decEq L
  

Proof state:
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : IsIntegrallyClosed A
inst✝ : IsNoetherianRing A
this : DecidableEq L
⊢ IsNoetherian A C

Next tactic:
obtain ⟨s, b, hb_int⟩ := FiniteDimensional.exists_is_basis_integral A K L
theorem IsIntegralClosure.isNoetherian [IsIntegrallyClosed A] [IsNoetherianRing A] :
    IsNoetherian A C := by
  haveI := Classical.decEq L
  obtain ⟨s, b, hb_int⟩ := FiniteDimensional.exists_is_basis_integral A K L
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : IsIntegrallyClosed A
inst✝ : IsNoetherianRing A
this : DecidableEq L
s : Finset L
b : Basis { x // x ∈ s } K L
hb_int : ∀ (x : { x // x ∈ s }), IsIntegral A (b x)
⊢ IsNoetherian A C

Next tactic:
let b' := (traceForm K L).dualBasis (traceForm_nondegenerate K L) b
theorem IsIntegralClosure.isNoetherian [IsIntegrallyClosed A] [IsNoetherianRing A] :
    IsNoetherian A C := by
  haveI := Classical.decEq L
  obtain ⟨s, b, hb_int⟩ := FiniteDimensional.exists_is_basis_integral A K L
  let b' := (traceForm K L).dualBasis (traceForm_nondegenerate K L) b
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : IsIntegrallyClosed A
inst✝ : IsNoetherianRing A
this : DecidableEq L
s : Finset L
b : Basis { x // x ∈ s } K L
hb_int : ∀ (x : { x // x ∈ s }), IsIntegral A (b x)
b' : Basis { x // x ∈ s } K L := BilinForm.dualBasis (traceForm K L) (_ : BilinForm.Nondegenerate (traceForm K L)) b
⊢ IsNoetherian A C

Next tactic:
letI := isNoetherian_span_of_finite A (Set.finite_range b')
theorem IsIntegralClosure.isNoetherian [IsIntegrallyClosed A] [IsNoetherianRing A] :
    IsNoetherian A C := by
  haveI := Classical.decEq L
  obtain ⟨s, b, hb_int⟩ := FiniteDimensional.exists_is_basis_integral A K L
  let b' := (traceForm K L).dualBasis (traceForm_nondegenerate K L) b
  letI := isNoetherian_span_of_finite A (Set.finite_range b')
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : IsIntegrallyClosed A
inst✝ : IsNoetherianRing A
this✝ : DecidableEq L
s : Finset L
b : Basis { x // x ∈ s } K L
hb_int : ∀ (x : { x // x ∈ s }), IsIntegral A (b x)
b' : Basis { x // x ∈ s } K L := BilinForm.dualBasis (traceForm K L) (_ : BilinForm.Nondegenerate (traceForm K L)) b
this : IsNoetherian A ↥(Submodule.span A (Set.range ⇑b')) := isNoetherian_span_of_finite A (Set.finite_range ⇑b')
⊢ IsNoetherian A C

Next tactic:
let f : C →ₗ[A] Submodule.span A (Set.range b') :=
    (Submodule.inclusion (IsIntegralClosure.range_le_span_dualBasis C b hb_int)).comp
      ((Algebra.linearMap C L).restrictScalars A).rangeRestrict
theorem IsIntegralClosure.isNoetherian [IsIntegrallyClosed A] [IsNoetherianRing A] :
    IsNoetherian A C := by
  haveI := Classical.decEq L
  obtain ⟨s, b, hb_int⟩ := FiniteDimensional.exists_is_basis_integral A K L
  let b' := (traceForm K L).dualBasis (traceForm_nondegenerate K L) b
  letI := isNoetherian_span_of_finite A (Set.finite_range b')
  let f : C →ₗ[A] Submodule.span A (Set.range b') :=
    (Submodule.inclusion (IsIntegralClosure.range_le_span_dualBasis C b hb_int)).comp
      ((Algebra.linearMap C L).restrictScalars A).rangeRestrict
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : IsIntegrallyClosed A
inst✝ : IsNoetherianRing A
this✝ : DecidableEq L
s : Finset L
b : Basis { x // x ∈ s } K L
hb_int : ∀ (x : { x // x ∈ s }), IsIntegral A (b x)
b' : Basis { x // x ∈ s } K L := BilinForm.dualBasis (traceForm K L) (_ : BilinForm.Nondegenerate (traceForm K L)) b
this : IsNoetherian A ↥(Submodule.span A (Set.range ⇑b')) := isNoetherian_span_of_finite A (Set.finite_range ⇑b')
f : C →ₗ[A] ↥(Submodule.span A (Set.range ⇑b')) :=
  Submodule.inclusion
      (_ :
        LinearMap.range (↑A (Algebra.linearMap C L)) ≤
          Submodule.span A
            (Set.range ⇑(BilinForm.dualBasis (traceForm K L) (_ : BilinForm.Nondegenerate (traceForm K L)) b))) ∘ₗ
    LinearMap.rangeRestrict (↑A (Algebra.linearMap C L))
⊢ IsNoetherian A C

Next tactic:
refine' isNoetherian_of_ker_bot f _
theorem IsIntegralClosure.isNoetherian [IsIntegrallyClosed A] [IsNoetherianRing A] :
    IsNoetherian A C := by
  haveI := Classical.decEq L
  obtain ⟨s, b, hb_int⟩ := FiniteDimensional.exists_is_basis_integral A K L
  let b' := (traceForm K L).dualBasis (traceForm_nondegenerate K L) b
  letI := isNoetherian_span_of_finite A (Set.finite_range b')
  let f : C →ₗ[A] Submodule.span A (Set.range b') :=
    (Submodule.inclusion (IsIntegralClosure.range_le_span_dualBasis C b hb_int)).comp
      ((Algebra.linearMap C L).restrictScalars A).rangeRestrict
  refine' isNoetherian_of_ker_bot f _
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : IsIntegrallyClosed A
inst✝ : IsNoetherianRing A
this✝ : DecidableEq L
s : Finset L
b : Basis { x // x ∈ s } K L
hb_int : ∀ (x : { x // x ∈ s }), IsIntegral A (b x)
b' : Basis { x // x ∈ s } K L := BilinForm.dualBasis (traceForm K L) (_ : BilinForm.Nondegenerate (traceForm K L)) b
this : IsNoetherian A ↥(Submodule.span A (Set.range ⇑b')) := isNoetherian_span_of_finite A (Set.finite_range ⇑b')
f : C →ₗ[A] ↥(Submodule.span A (Set.range ⇑b')) :=
  Submodule.inclusion
      (_ :
        LinearMap.range (↑A (Algebra.linearMap C L)) ≤
          Submodule.span A
            (Set.range ⇑(BilinForm.dualBasis (traceForm K L) (_ : BilinForm.Nondegenerate (traceForm K L)) b))) ∘ₗ
    LinearMap.rangeRestrict (↑A (Algebra.linearMap C L))
⊢ LinearMap.ker f = ⊥

Next tactic:
rw [LinearMap.ker_comp, Submodule.ker_inclusion, Submodule.comap_bot, LinearMap.ker_codRestrict]
theorem IsIntegralClosure.isNoetherian [IsIntegrallyClosed A] [IsNoetherianRing A] :
    IsNoetherian A C := by
  haveI := Classical.decEq L
  obtain ⟨s, b, hb_int⟩ := FiniteDimensional.exists_is_basis_integral A K L
  let b' := (traceForm K L).dualBasis (traceForm_nondegenerate K L) b
  letI := isNoetherian_span_of_finite A (Set.finite_range b')
  let f : C →ₗ[A] Submodule.span A (Set.range b') :=
    (Submodule.inclusion (IsIntegralClosure.range_le_span_dualBasis C b hb_int)).comp
      ((Algebra.linearMap C L).restrictScalars A).rangeRestrict
  refine' isNoetherian_of_ker_bot f _
  rw [LinearMap.ker_comp, Submodule.ker_inclusion, Submodule.comap_bot, LinearMap.ker_codRestrict]
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : IsIntegrallyClosed A
inst✝ : IsNoetherianRing A
this✝ : DecidableEq L
s : Finset L
b : Basis { x // x ∈ s } K L
hb_int : ∀ (x : { x // x ∈ s }), IsIntegral A (b x)
b' : Basis { x // x ∈ s } K L := BilinForm.dualBasis (traceForm K L) (_ : BilinForm.Nondegenerate (traceForm K L)) b
this : IsNoetherian A ↥(Submodule.span A (Set.range ⇑b')) := isNoetherian_span_of_finite A (Set.finite_range ⇑b')
f : C →ₗ[A] ↥(Submodule.span A (Set.range ⇑b')) :=
  Submodule.inclusion
      (_ :
        LinearMap.range (↑A (Algebra.linearMap C L)) ≤
          Submodule.span A
            (Set.range ⇑(BilinForm.dualBasis (traceForm K L) (_ : BilinForm.Nondegenerate (traceForm K L)) b))) ∘ₗ
    LinearMap.rangeRestrict (↑A (Algebra.linearMap C L))
⊢ LinearMap.ker (↑A (Algebra.linearMap C L)) = ⊥

Next tactic:
exact LinearMap.ker_eq_bot_of_injective (IsIntegralClosure.algebraMap_injective C A L)
theorem IsIntegralClosure.module_free [NoZeroSMulDivisors A L] [IsPrincipalIdealRing A] :
    Module.Free A C := by
  

Proof state:
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : NoZeroSMulDivisors A L
inst✝ : IsPrincipalIdealRing A
⊢ Module.Free A C

Next tactic:
haveI : NoZeroSMulDivisors A C := IsIntegralClosure.noZeroSMulDivisors A L
theorem IsIntegralClosure.module_free [NoZeroSMulDivisors A L] [IsPrincipalIdealRing A] :
    Module.Free A C := by
  haveI : NoZeroSMulDivisors A C := IsIntegralClosure.noZeroSMulDivisors A L
  

Proof state:
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : NoZeroSMulDivisors A L
inst✝ : IsPrincipalIdealRing A
this : NoZeroSMulDivisors A C
⊢ Module.Free A C

Next tactic:
haveI : IsNoetherian A C := IsIntegralClosure.isNoetherian A K L _
theorem IsIntegralClosure.module_free [NoZeroSMulDivisors A L] [IsPrincipalIdealRing A] :
    Module.Free A C := by
  haveI : NoZeroSMulDivisors A C := IsIntegralClosure.noZeroSMulDivisors A L
  haveI : IsNoetherian A C := IsIntegralClosure.isNoetherian A K L _
  

Proof state:
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : NoZeroSMulDivisors A L
inst✝ : IsPrincipalIdealRing A
this✝ : NoZeroSMulDivisors A C
this : IsNoetherian A C
⊢ Module.Free A C

Next tactic:
exact Module.free_of_finite_type_torsion_free'
theorem IsIntegralClosure.rank [IsPrincipalIdealRing A] [NoZeroSMulDivisors A L] :
    FiniteDimensional.finrank A C = FiniteDimensional.finrank K L := by
  

Proof state:
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : IsPrincipalIdealRing A
inst✝ : NoZeroSMulDivisors A L
⊢ FiniteDimensional.finrank A C = FiniteDimensional.finrank K L

Next tactic:
haveI : Module.Free A C := IsIntegralClosure.module_free A K L C
theorem IsIntegralClosure.rank [IsPrincipalIdealRing A] [NoZeroSMulDivisors A L] :
    FiniteDimensional.finrank A C = FiniteDimensional.finrank K L := by
  haveI : Module.Free A C := IsIntegralClosure.module_free A K L C
  

Proof state:
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : IsPrincipalIdealRing A
inst✝ : NoZeroSMulDivisors A L
this : Module.Free A C
⊢ FiniteDimensional.finrank A C = FiniteDimensional.finrank K L

Next tactic:
haveI : IsNoetherian A C := IsIntegralClosure.isNoetherian A K L C