l3lab/ntp-mathlib huggingface dataset:
/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/
theorem exists_mem_finsetApprox (a : S) {b} (hb : b ≠ (0 : R)) :
    ∃ q : S,
      ∃ r ∈ finsetApprox bS adm, abv (Algebra.norm R (r • a - b • q)) <
      abv (Algebra.norm R (algebraMap R S b)) := by
  have dim_pos := Fintype.card_pos_iff.mpr bS.index_nonempty
  set ε : ℝ := normBound abv bS ^ (-1 / Fintype.card ι : ℝ) with ε_eq
  have hε : 0 < ε := Real.rpow_pos_of_pos (Int.cast_pos.mpr (normBound_pos abv bS)) _
  have ε_le : (normBound abv bS : ℝ) * (abv b • ε) ^ (Fintype.card ι : ℝ)
                ≤ abv b ^ (Fintype.card ι : ℝ) := by
    have := normBound_pos abv bS
    have := abv.nonneg b
    rw [ε_eq, Algebra.smul_def, eq_intCast, mul_rpow, ← rpow_mul, div_mul_cancel, rpow_neg_one,
      mul_left_comm, mul_inv_cancel, mul_one, rpow_nat_cast] <;>
      try norm_cast; linarith
    · exact Iff.mpr Int.cast_nonneg this
    · linarith
  set μ : Fin (cardM bS adm).succ ↪ R := distinctElems bS adm with hμ
  let s : ι →₀ R := bS.repr a
  have s_eq : ∀ i, s i = bS.repr a i := fun i => rfl
  let qs : Fin (cardM bS adm).succ → ι → R := fun j i => μ j * s i / b
  let rs : Fin (cardM bS adm).succ → ι → R := fun j i => μ j * s i % b
  have r_eq : ∀ j i, rs j i = μ j * s i % b := fun i j => rfl
  have μ_eq : ∀ i j, μ j * s i = b * qs j i + rs j i := by
    intro i j
    rw [r_eq, EuclideanDomain.div_add_mod]
  have μ_mul_a_eq : ∀ j, μ j • a = b • ∑ i, qs j i • bS i + ∑ i, rs j i • bS i := by
    

Proof state:
R : Type u_1
S : Type u_2
K : Type u_3
L : Type u_4
inst✝¹⁶ : EuclideanDomain R
inst✝¹⁵ : CommRing S
inst✝¹⁴ : IsDomain S
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Algebra R K
inst✝¹⁰ : IsFractionRing R K
inst✝⁹ : Algebra K L
inst✝⁸ : FiniteDimensional K L
inst✝⁷ : IsSeparable K L
algRL : Algebra R L
inst✝⁶ : IsScalarTower R K L
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra S L
ist : IsScalarTower R S L
iic : IsIntegralClosure S R L
abv : AbsoluteValue R ℤ
ι : Type u_5
inst✝³ : DecidableEq ι
inst✝² : Fintype ι
bS : Basis ι R S
adm : AbsoluteValue.IsAdmissible abv
inst✝¹ : Infinite R
inst✝ : DecidableEq R
a : S
b : R
hb : b ≠ 0
dim_pos : 0 < Fintype.card ι
ε : ℝ := ↑(normBound abv bS) ^ (-1 / ↑(Fintype.card ι))
ε_eq : ε = ↑(normBound abv bS) ^ (-1 / ↑(Fintype.card ι))
hε : 0 < ε
ε_le : ↑(normBound abv bS) * (abv b • ε) ^ ↑(Fintype.card ι) ≤ ↑(abv b) ^ ↑(Fintype.card ι)
μ : Fin (Nat.succ (cardM bS adm)) ↪ R := distinctElems bS adm
hμ : μ = distinctElems bS adm
s : ι →₀ R := bS.repr a
s_eq : ∀ (i : ι), s i = (bS.repr a) i
qs : Fin (Nat.succ (cardM bS adm)) → ι → R := fun j i => μ j * s i / b
rs : Fin (Nat.succ (cardM bS adm)) → ι → R := fun j i => μ j * s i % b
r_eq : ∀ (j : Fin (Nat.succ (cardM bS adm))) (i : ι), rs j i = μ j * s i % b
μ_eq : ∀ (i : ι) (j : Fin (Nat.succ (cardM bS adm))), μ j * s i = b * qs j i + rs j i
⊢ ∀ (j : Fin (Nat.succ (cardM bS adm))), μ j • a = b • ∑ i : ι, qs j i • bS i + ∑ i : ι, rs j i • bS i

Next tactic:
intro j
/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/
theorem exists_mem_finsetApprox (a : S) {b} (hb : b ≠ (0 : R)) :
    ∃ q : S,
      ∃ r ∈ finsetApprox bS adm, abv (Algebra.norm R (r • a - b • q)) <
      abv (Algebra.norm R (algebraMap R S b)) := by
  have dim_pos := Fintype.card_pos_iff.mpr bS.index_nonempty
  set ε : ℝ := normBound abv bS ^ (-1 / Fintype.card ι : ℝ) with ε_eq
  have hε : 0 < ε := Real.rpow_pos_of_pos (Int.cast_pos.mpr (normBound_pos abv bS)) _
  have ε_le : (normBound abv bS : ℝ) * (abv b • ε) ^ (Fintype.card ι : ℝ)
                ≤ abv b ^ (Fintype.card ι : ℝ) := by
    have := normBound_pos abv bS
    have := abv.nonneg b
    rw [ε_eq, Algebra.smul_def, eq_intCast, mul_rpow, ← rpow_mul, div_mul_cancel, rpow_neg_one,
      mul_left_comm, mul_inv_cancel, mul_one, rpow_nat_cast] <;>
      try norm_cast; linarith
    · exact Iff.mpr Int.cast_nonneg this
    · linarith
  set μ : Fin (cardM bS adm).succ ↪ R := distinctElems bS adm with hμ
  let s : ι →₀ R := bS.repr a
  have s_eq : ∀ i, s i = bS.repr a i := fun i => rfl
  let qs : Fin (cardM bS adm).succ → ι → R := fun j i => μ j * s i / b
  let rs : Fin (cardM bS adm).succ → ι → R := fun j i => μ j * s i % b
  have r_eq : ∀ j i, rs j i = μ j * s i % b := fun i j => rfl
  have μ_eq : ∀ i j, μ j * s i = b * qs j i + rs j i := by
    intro i j
    rw [r_eq, EuclideanDomain.div_add_mod]
  have μ_mul_a_eq : ∀ j, μ j • a = b • ∑ i, qs j i • bS i + ∑ i, rs j i • bS i := by
    intro j
    

Proof state:
R : Type u_1
S : Type u_2
K : Type u_3
L : Type u_4
inst✝¹⁶ : EuclideanDomain R
inst✝¹⁵ : CommRing S
inst✝¹⁴ : IsDomain S
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Algebra R K
inst✝¹⁰ : IsFractionRing R K
inst✝⁹ : Algebra K L
inst✝⁸ : FiniteDimensional K L
inst✝⁷ : IsSeparable K L
algRL : Algebra R L
inst✝⁶ : IsScalarTower R K L
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra S L
ist : IsScalarTower R S L
iic : IsIntegralClosure S R L
abv : AbsoluteValue R ℤ
ι : Type u_5
inst✝³ : DecidableEq ι
inst✝² : Fintype ι
bS : Basis ι R S
adm : AbsoluteValue.IsAdmissible abv
inst✝¹ : Infinite R
inst✝ : DecidableEq R
a : S
b : R
hb : b ≠ 0
dim_pos : 0 < Fintype.card ι
ε : ℝ := ↑(normBound abv bS) ^ (-1 / ↑(Fintype.card ι))
ε_eq : ε = ↑(normBound abv bS) ^ (-1 / ↑(Fintype.card ι))
hε : 0 < ε
ε_le : ↑(normBound abv bS) * (abv b • ε) ^ ↑(Fintype.card ι) ≤ ↑(abv b) ^ ↑(Fintype.card ι)
μ : Fin (Nat.succ (cardM bS adm)) ↪ R := distinctElems bS adm
hμ : μ = distinctElems bS adm
s : ι →₀ R := bS.repr a
s_eq : ∀ (i : ι), s i = (bS.repr a) i
qs : Fin (Nat.succ (cardM bS adm)) → ι → R := fun j i => μ j * s i / b
rs : Fin (Nat.succ (cardM bS adm)) → ι → R := fun j i => μ j * s i % b
r_eq : ∀ (j : Fin (Nat.succ (cardM bS adm))) (i : ι), rs j i = μ j * s i % b
μ_eq : ∀ (i : ι) (j : Fin (Nat.succ (cardM bS adm))), μ j * s i = b * qs j i + rs j i
j : Fin (Nat.succ (cardM bS adm))
⊢ μ j • a = b • ∑ i : ι, qs j i • bS i + ∑ i : ι, rs j i • bS i

Next tactic:
rw [← bS.sum_repr a]
/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/
theorem exists_mem_finsetApprox (a : S) {b} (hb : b ≠ (0 : R)) :
    ∃ q : S,
      ∃ r ∈ finsetApprox bS adm, abv (Algebra.norm R (r • a - b • q)) <
      abv (Algebra.norm R (algebraMap R S b)) := by
  have dim_pos := Fintype.card_pos_iff.mpr bS.index_nonempty
  set ε : ℝ := normBound abv bS ^ (-1 / Fintype.card ι : ℝ) with ε_eq
  have hε : 0 < ε := Real.rpow_pos_of_pos (Int.cast_pos.mpr (normBound_pos abv bS)) _
  have ε_le : (normBound abv bS : ℝ) * (abv b • ε) ^ (Fintype.card ι : ℝ)
                ≤ abv b ^ (Fintype.card ι : ℝ) := by
    have := normBound_pos abv bS
    have := abv.nonneg b
    rw [ε_eq, Algebra.smul_def, eq_intCast, mul_rpow, ← rpow_mul, div_mul_cancel, rpow_neg_one,
      mul_left_comm, mul_inv_cancel, mul_one, rpow_nat_cast] <;>
      try norm_cast; linarith
    · exact Iff.mpr Int.cast_nonneg this
    · linarith
  set μ : Fin (cardM bS adm).succ ↪ R := distinctElems bS adm with hμ
  let s : ι →₀ R := bS.repr a
  have s_eq : ∀ i, s i = bS.repr a i := fun i => rfl
  let qs : Fin (cardM bS adm).succ → ι → R := fun j i => μ j * s i / b
  let rs : Fin (cardM bS adm).succ → ι → R := fun j i => μ j * s i % b
  have r_eq : ∀ j i, rs j i = μ j * s i % b := fun i j => rfl
  have μ_eq : ∀ i j, μ j * s i = b * qs j i + rs j i := by
    intro i j
    rw [r_eq, EuclideanDomain.div_add_mod]
  have μ_mul_a_eq : ∀ j, μ j • a = b • ∑ i, qs j i • bS i + ∑ i, rs j i • bS i := by
    intro j
    rw [← bS.sum_repr a]
    

Proof state:
R : Type u_1
S : Type u_2
K : Type u_3
L : Type u_4
inst✝¹⁶ : EuclideanDomain R
inst✝¹⁵ : CommRing S
inst✝¹⁴ : IsDomain S
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Algebra R K
inst✝¹⁰ : IsFractionRing R K
inst✝⁹ : Algebra K L
inst✝⁸ : FiniteDimensional K L
inst✝⁷ : IsSeparable K L
algRL : Algebra R L
inst✝⁶ : IsScalarTower R K L
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra S L
ist : IsScalarTower R S L
iic : IsIntegralClosure S R L
abv : AbsoluteValue R ℤ
ι : Type u_5
inst✝³ : DecidableEq ι
inst✝² : Fintype ι
bS : Basis ι R S
adm : AbsoluteValue.IsAdmissible abv
inst✝¹ : Infinite R
inst✝ : DecidableEq R
a : S
b : R
hb : b ≠ 0
dim_pos : 0 < Fintype.card ι
ε : ℝ := ↑(normBound abv bS) ^ (-1 / ↑(Fintype.card ι))
ε_eq : ε = ↑(normBound abv bS) ^ (-1 / ↑(Fintype.card ι))
hε : 0 < ε
ε_le : ↑(normBound abv bS) * (abv b • ε) ^ ↑(Fintype.card ι) ≤ ↑(abv b) ^ ↑(Fintype.card ι)
μ : Fin (Nat.succ (cardM bS adm)) ↪ R := distinctElems bS adm
hμ : μ = distinctElems bS adm
s : ι →₀ R := bS.repr a
s_eq : ∀ (i : ι), s i = (bS.repr a) i
qs : Fin (Nat.succ (cardM bS adm)) → ι → R := fun j i => μ j * s i / b
rs : Fin (Nat.succ (cardM bS adm)) → ι → R := fun j i => μ j * s i % b
r_eq : ∀ (j : Fin (Nat.succ (cardM bS adm))) (i : ι), rs j i = μ j * s i % b
μ_eq : ∀ (i : ι) (j : Fin (Nat.succ (cardM bS adm))), μ j * s i = b * qs j i + rs j i
j : Fin (Nat.succ (cardM bS adm))
⊢ μ j • ∑ i : ι, (bS.repr a) i • bS i = b • ∑ i : ι, qs j i • bS i + ∑ i : ι, rs j i • bS i

Next tactic:
simp only [Finset.smul_sum, ← Finset.sum_add_distrib]
/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/
theorem exists_mem_finset_approx' (h : Algebra.IsAlgebraic R L) (a : S) {b : S} (hb : b ≠ 0) :
    ∃ q : S,
      ∃ r ∈ finsetApprox bS adm, abv (Algebra.norm R (r • a - q * b)) < abv (Algebra.norm R b) := by
  

Proof state:
R : Type u_1
S : Type u_2
K : Type u_3
L : Type u_4
inst✝¹⁶ : EuclideanDomain R
inst✝¹⁵ : CommRing S
inst✝¹⁴ : IsDomain S
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Algebra R K
inst✝¹⁰ : IsFractionRing R K
inst✝⁹ : Algebra K L
inst✝⁸ : FiniteDimensional K L
inst✝⁷ : IsSeparable K L
algRL : Algebra R L
inst✝⁶ : IsScalarTower R K L
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra S L
ist : IsScalarTower R S L
iic : IsIntegralClosure S R L
abv : AbsoluteValue R ℤ
ι : Type u_5
inst✝³ : DecidableEq ι
inst✝² : Fintype ι
bS : Basis ι R S
adm : AbsoluteValue.IsAdmissible abv
inst✝¹ : Infinite R
inst✝ : DecidableEq R
h : Algebra.IsAlgebraic R L
a b : S
hb : b ≠ 0
⊢ ∃ q, ∃ r ∈ finsetApprox bS adm, abv ((Algebra.norm R) (r • a - q * b)) < abv ((Algebra.norm R) b)

Next tactic:
have inj : Function.Injective (algebraMap R L) := by
    rw [IsScalarTower.algebraMap_eq R S L]
    exact (IsIntegralClosure.algebraMap_injective S R L).comp bS.algebraMap_injective
/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/
theorem exists_mem_finset_approx' (h : Algebra.IsAlgebraic R L) (a : S) {b : S} (hb : b ≠ 0) :
    ∃ q : S,
      ∃ r ∈ finsetApprox bS adm, abv (Algebra.norm R (r • a - q * b)) < abv (Algebra.norm R b) := by
  have inj : Function.Injective (algebraMap R L) := by
    

Proof state:
R : Type u_1
S : Type u_2
K : Type u_3
L : Type u_4
inst✝¹⁶ : EuclideanDomain R
inst✝¹⁵ : CommRing S
inst✝¹⁴ : IsDomain S
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Algebra R K
inst✝¹⁰ : IsFractionRing R K
inst✝⁹ : Algebra K L
inst✝⁸ : FiniteDimensional K L
inst✝⁷ : IsSeparable K L
algRL : Algebra R L
inst✝⁶ : IsScalarTower R K L
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra S L
ist : IsScalarTower R S L
iic : IsIntegralClosure S R L
abv : AbsoluteValue R ℤ
ι : Type u_5
inst✝³ : DecidableEq ι
inst✝² : Fintype ι
bS : Basis ι R S
adm : AbsoluteValue.IsAdmissible abv
inst✝¹ : Infinite R
inst✝ : DecidableEq R
h : Algebra.IsAlgebraic R L
a b : S
hb : b ≠ 0
⊢ Function.Injective ⇑(algebraMap R L)

Next tactic:
rw [IsScalarTower.algebraMap_eq R S L]
/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/
theorem exists_mem_finset_approx' (h : Algebra.IsAlgebraic R L) (a : S) {b : S} (hb : b ≠ 0) :
    ∃ q : S,
      ∃ r ∈ finsetApprox bS adm, abv (Algebra.norm R (r • a - q * b)) < abv (Algebra.norm R b) := by
  have inj : Function.Injective (algebraMap R L) := by
    rw [IsScalarTower.algebraMap_eq R S L]
    

Proof state:
R : Type u_1
S : Type u_2
K : Type u_3
L : Type u_4
inst✝¹⁶ : EuclideanDomain R
inst✝¹⁵ : CommRing S
inst✝¹⁴ : IsDomain S
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Algebra R K
inst✝¹⁰ : IsFractionRing R K
inst✝⁹ : Algebra K L
inst✝⁸ : FiniteDimensional K L
inst✝⁷ : IsSeparable K L
algRL : Algebra R L
inst✝⁶ : IsScalarTower R K L
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra S L
ist : IsScalarTower R S L
iic : IsIntegralClosure S R L
abv : AbsoluteValue R ℤ
ι : Type u_5
inst✝³ : DecidableEq ι
inst✝² : Fintype ι
bS : Basis ι R S
adm : AbsoluteValue.IsAdmissible abv
inst✝¹ : Infinite R
inst✝ : DecidableEq R
h : Algebra.IsAlgebraic R L
a b : S
hb : b ≠ 0
⊢ Function.Injective ⇑(RingHom.comp (algebraMap S L) (algebraMap R S))

Next tactic:
exact (IsIntegralClosure.algebraMap_injective S R L).comp bS.algebraMap_injective
/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/
theorem exists_mem_finset_approx' (h : Algebra.IsAlgebraic R L) (a : S) {b : S} (hb : b ≠ 0) :
    ∃ q : S,
      ∃ r ∈ finsetApprox bS adm, abv (Algebra.norm R (r • a - q * b)) < abv (Algebra.norm R b) := by
  have inj : Function.Injective (algebraMap R L) := by
    rw [IsScalarTower.algebraMap_eq R S L]
    exact (IsIntegralClosure.algebraMap_injective S R L).comp bS.algebraMap_injective
  

Proof state:
R : Type u_1
S : Type u_2
K : Type u_3
L : Type u_4
inst✝¹⁶ : EuclideanDomain R
inst✝¹⁵ : CommRing S
inst✝¹⁴ : IsDomain S
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Algebra R K
inst✝¹⁰ : IsFractionRing R K
inst✝⁹ : Algebra K L
inst✝⁸ : FiniteDimensional K L
inst✝⁷ : IsSeparable K L
algRL : Algebra R L
inst✝⁶ : IsScalarTower R K L
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra S L
ist : IsScalarTower R S L
iic : IsIntegralClosure S R L
abv : AbsoluteValue R ℤ
ι : Type u_5
inst✝³ : DecidableEq ι
inst✝² : Fintype ι
bS : Basis ι R S
adm : AbsoluteValue.IsAdmissible abv
inst✝¹ : Infinite R
inst✝ : DecidableEq R
h : Algebra.IsAlgebraic R L
a b : S
hb : b ≠ 0
inj : Function.Injective ⇑(algebraMap R L)
⊢ ∃ q, ∃ r ∈ finsetApprox bS adm, abv ((Algebra.norm R) (r • a - q * b)) < abv ((Algebra.norm R) b)

Next tactic:
obtain ⟨a', b', hb', h⟩ := IsIntegralClosure.exists_smul_eq_mul h inj a hb
/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/
theorem exists_mem_finset_approx' (h : Algebra.IsAlgebraic R L) (a : S) {b : S} (hb : b ≠ 0) :
    ∃ q : S,
      ∃ r ∈ finsetApprox bS adm, abv (Algebra.norm R (r • a - q * b)) < abv (Algebra.norm R b) := by
  have inj : Function.Injective (algebraMap R L) := by
    rw [IsScalarTower.algebraMap_eq R S L]
    exact (IsIntegralClosure.algebraMap_injective S R L).comp bS.algebraMap_injective
  obtain ⟨a', b', hb', h⟩ := IsIntegralClosure.exists_smul_eq_mul h inj a hb
  

Proof state:
case intro.intro.intro
R : Type u_1
S : Type u_2
K : Type u_3
L : Type u_4
inst✝¹⁶ : EuclideanDomain R
inst✝¹⁵ : CommRing S
inst✝¹⁴ : IsDomain S
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Algebra R K
inst✝¹⁰ : IsFractionRing R K
inst✝⁹ : Algebra K L
inst✝⁸ : FiniteDimensional K L
inst✝⁷ : IsSeparable K L
algRL : Algebra R L
inst✝⁶ : IsScalarTower R K L
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra S L
ist : IsScalarTower R S L
iic : IsIntegralClosure S R L
abv : AbsoluteValue R ℤ
ι : Type u_5
inst✝³ : DecidableEq ι
inst✝² : Fintype ι
bS : Basis ι R S
adm : AbsoluteValue.IsAdmissible abv
inst✝¹ : Infinite R
inst✝ : DecidableEq R
h✝ : Algebra.IsAlgebraic R L
a b : S
hb : b ≠ 0
inj : Function.Injective ⇑(algebraMap R L)
a' : S
b' : R
hb' : b' ≠ 0
h : b' • a = b * a'
⊢ ∃ q, ∃ r ∈ finsetApprox bS adm, abv ((Algebra.norm R) (r • a - q * b)) < abv ((Algebra.norm R) b)

Next tactic:
obtain ⟨q, r, hr, hqr⟩ := exists_mem_finsetApprox bS adm a' hb'
/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/
theorem exists_mem_finset_approx' (h : Algebra.IsAlgebraic R L) (a : S) {b : S} (hb : b ≠ 0) :
    ∃ q : S,
      ∃ r ∈ finsetApprox bS adm, abv (Algebra.norm R (r • a - q * b)) < abv (Algebra.norm R b) := by
  have inj : Function.Injective (algebraMap R L) := by
    rw [IsScalarTower.algebraMap_eq R S L]
    exact (IsIntegralClosure.algebraMap_injective S R L).comp bS.algebraMap_injective
  obtain ⟨a', b', hb', h⟩ := IsIntegralClosure.exists_smul_eq_mul h inj a hb
  obtain ⟨q, r, hr, hqr⟩ := exists_mem_finsetApprox bS adm a' hb'
  

Proof state:
case intro.intro.intro.intro.intro.intro
R : Type u_1
S : Type u_2
K : Type u_3
L : Type u_4
inst✝¹⁶ : EuclideanDomain R
inst✝¹⁵ : CommRing S
inst✝¹⁴ : IsDomain S
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Algebra R K
inst✝¹⁰ : IsFractionRing R K
inst✝⁹ : Algebra K L
inst✝⁸ : FiniteDimensional K L
inst✝⁷ : IsSeparable K L
algRL : Algebra R L
inst✝⁶ : IsScalarTower R K L
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra S L
ist : IsScalarTower R S L
iic : IsIntegralClosure S R L
abv : AbsoluteValue R ℤ
ι : Type u_5
inst✝³ : DecidableEq ι
inst✝² : Fintype ι
bS : Basis ι R S
adm : AbsoluteValue.IsAdmissible abv
inst✝¹ : Infinite R
inst✝ : DecidableEq R
h✝ : Algebra.IsAlgebraic R L
a b : S
hb : b ≠ 0
inj : Function.Injective ⇑(algebraMap R L)
a' : S
b' : R
hb' : b' ≠ 0
h : b' • a = b * a'
q : S
r : R
hr : r ∈ finsetApprox bS adm
hqr : abv ((Algebra.norm R) (r • a' - b' • q)) < abv ((Algebra.norm R) ((algebraMap R S) b'))
⊢ ∃ q, ∃ r ∈ finsetApprox bS adm, abv ((Algebra.norm R) (r • a - q * b)) < abv ((Algebra.norm R) b)

Next tactic:
refine' ⟨q, r, hr, _⟩
/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/
theorem exists_mem_finset_approx' (h : Algebra.IsAlgebraic R L) (a : S) {b : S} (hb : b ≠ 0) :
    ∃ q : S,
      ∃ r ∈ finsetApprox bS adm, abv (Algebra.norm R (r • a - q * b)) < abv (Algebra.norm R b) := by
  have inj : Function.Injective (algebraMap R L) := by
    rw [IsScalarTower.algebraMap_eq R S L]
    exact (IsIntegralClosure.algebraMap_injective S R L).comp bS.algebraMap_injective
  obtain ⟨a', b', hb', h⟩ := IsIntegralClosure.exists_smul_eq_mul h inj a hb
  obtain ⟨q, r, hr, hqr⟩ := exists_mem_finsetApprox bS adm a' hb'
  refine' ⟨q, r, hr, _⟩
  

Proof state:
case intro.intro.intro.intro.intro.intro
R : Type u_1
S : Type u_2
K : Type u_3
L : Type u_4
inst✝¹⁶ : EuclideanDomain R
inst✝¹⁵ : CommRing S
inst✝¹⁴ : IsDomain S
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Algebra R K
inst✝¹⁰ : IsFractionRing R K
inst✝⁹ : Algebra K L
inst✝⁸ : FiniteDimensional K L
inst✝⁷ : IsSeparable K L
algRL : Algebra R L
inst✝⁶ : IsScalarTower R K L
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra S L
ist : IsScalarTower R S L
iic : IsIntegralClosure S R L
abv : AbsoluteValue R ℤ
ι : Type u_5
inst✝³ : DecidableEq ι
inst✝² : Fintype ι
bS : Basis ι R S
adm : AbsoluteValue.IsAdmissible abv
inst✝¹ : Infinite R
inst✝ : DecidableEq R
h✝ : Algebra.IsAlgebraic R L
a b : S
hb : b ≠ 0
inj : Function.Injective ⇑(algebraMap R L)
a' : S
b' : R
hb' : b' ≠ 0
h : b' • a = b * a'
q : S
r : R
hr : r ∈ finsetApprox bS adm
hqr : abv ((Algebra.norm R) (r • a' - b' • q)) < abv ((Algebra.norm R) ((algebraMap R S) b'))
⊢ abv ((Algebra.norm R) (r • a - q * b)) < abv ((Algebra.norm R) b)

Next tactic:
refine'
    lt_of_mul_lt_mul_left _ (show 0 ≤ abv (Algebra.norm R (algebraMap R S b')) from abv.nonneg _)
/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/
theorem exists_mem_finset_approx' (h : Algebra.IsAlgebraic R L) (a : S) {b : S} (hb : b ≠ 0) :
    ∃ q : S,
      ∃ r ∈ finsetApprox bS adm, abv (Algebra.norm R (r • a - q * b)) < abv (Algebra.norm R b) := by
  have inj : Function.Injective (algebraMap R L) := by
    rw [IsScalarTower.algebraMap_eq R S L]
    exact (IsIntegralClosure.algebraMap_injective S R L).comp bS.algebraMap_injective
  obtain ⟨a', b', hb', h⟩ := IsIntegralClosure.exists_smul_eq_mul h inj a hb
  obtain ⟨q, r, hr, hqr⟩ := exists_mem_finsetApprox bS adm a' hb'
  refine' ⟨q, r, hr, _⟩
  refine'
    lt_of_mul_lt_mul_left _ (show 0 ≤ abv (Algebra.norm R (algebraMap R S b')) from abv.nonneg _)
  

Proof state:
case intro.intro.intro.intro.intro.intro
R : Type u_1
S : Type u_2
K : Type u_3
L : Type u_4
inst✝¹⁶ : EuclideanDomain R
inst✝¹⁵ : CommRing S
inst✝¹⁴ : IsDomain S
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Algebra R K
inst✝¹⁰ : IsFractionRing R K
inst✝⁹ : Algebra K L
inst✝⁸ : FiniteDimensional K L
inst✝⁷ : IsSeparable K L
algRL : Algebra R L
inst✝⁶ : IsScalarTower R K L
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra S L
ist : IsScalarTower R S L
iic : IsIntegralClosure S R L
abv : AbsoluteValue R ℤ
ι : Type u_5
inst✝³ : DecidableEq ι
inst✝² : Fintype ι
bS : Basis ι R S
adm : AbsoluteValue.IsAdmissible abv
inst✝¹ : Infinite R
inst✝ : DecidableEq R
h✝ : Algebra.IsAlgebraic R L
a b : S
hb : b ≠ 0
inj : Function.Injective ⇑(algebraMap R L)
a' : S
b' : R
hb' : b' ≠ 0
h : b' • a = b * a'
q : S
r : R
hr : r ∈ finsetApprox bS adm
hqr : abv ((Algebra.norm R) (r • a' - b' • q)) < abv ((Algebra.norm R) ((algebraMap R S) b'))
⊢ abv ((Algebra.norm R) ((algebraMap R S) b')) * abv ((Algebra.norm R) (r • a - q * b)) <
    abv ((Algebra.norm R) ((algebraMap R S) b')) * abv ((Algebra.norm R) b)

Next tactic:
refine'
    lt_of_le_of_lt (le_of_eq _)
      (mul_lt_mul hqr le_rfl (abv.pos ((Algebra.norm_ne_zero_iff_of_basis bS).mpr hb))
        (abv.nonneg _))
/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/
theorem exists_mem_finset_approx' (h : Algebra.IsAlgebraic R L) (a : S) {b : S} (hb : b ≠ 0) :
    ∃ q : S,
      ∃ r ∈ finsetApprox bS adm, abv (Algebra.norm R (r • a - q * b)) < abv (Algebra.norm R b) := by
  have inj : Function.Injective (algebraMap R L) := by
    rw [IsScalarTower.algebraMap_eq R S L]
    exact (IsIntegralClosure.algebraMap_injective S R L).comp bS.algebraMap_injective
  obtain ⟨a', b', hb', h⟩ := IsIntegralClosure.exists_smul_eq_mul h inj a hb
  obtain ⟨q, r, hr, hqr⟩ := exists_mem_finsetApprox bS adm a' hb'
  refine' ⟨q, r, hr, _⟩
  refine'
    lt_of_mul_lt_mul_left _ (show 0 ≤ abv (Algebra.norm R (algebraMap R S b')) from abv.nonneg _)
  refine'
    lt_of_le_of_lt (le_of_eq _)
      (mul_lt_mul hqr le_rfl (abv.pos ((Algebra.norm_ne_zero_iff_of_basis bS).mpr hb))
        (abv.nonneg _))
  

Proof state:
case intro.intro.intro.intro.intro.intro
R : Type u_1
S : Type u_2
K : Type u_3
L : Type u_4
inst✝¹⁶ : EuclideanDomain R
inst✝¹⁵ : CommRing S
inst✝¹⁴ : IsDomain S
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Algebra R K
inst✝¹⁰ : IsFractionRing R K
inst✝⁹ : Algebra K L
inst✝⁸ : FiniteDimensional K L
inst✝⁷ : IsSeparable K L
algRL : Algebra R L
inst✝⁶ : IsScalarTower R K L
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra S L
ist : IsScalarTower R S L
iic : IsIntegralClosure S R L
abv : AbsoluteValue R ℤ
ι : Type u_5
inst✝³ : DecidableEq ι
inst✝² : Fintype ι
bS : Basis ι R S
adm : AbsoluteValue.IsAdmissible abv
inst✝¹ : Infinite R
inst✝ : DecidableEq R
h✝ : Algebra.IsAlgebraic R L
a b : S
hb : b ≠ 0
inj : Function.Injective ⇑(algebraMap R L)
a' : S
b' : R
hb' : b' ≠ 0
h : b' • a = b * a'
q : S
r : R
hr : r ∈ finsetApprox bS adm
hqr : abv ((Algebra.norm R) (r • a' - b' • q)) < abv ((Algebra.norm R) ((algebraMap R S) b'))
⊢ abv ((Algebra.norm R) ((algebraMap R S) b')) * abv ((Algebra.norm R) (r • a - q * b)) =
    abv ((Algebra.norm R) (r • a' - b' • q)) * abv ((Algebra.norm R) b)

Next tactic:
rw [← abv.map_mul, ← MonoidHom.map_mul, ← abv.map_mul, ← MonoidHom.map_mul, ← Algebra.smul_def,
    smul_sub b', sub_mul, smul_comm, h, mul_comm b a', Algebra.smul_mul_assoc r a' b,
    Algebra.smul_mul_assoc b' q b]
theorem prod_finsetApprox_ne_zero : algebraMap R S (∏ m in finsetApprox bS adm, m) ≠ 0 := by
  

Proof state:
R : Type u_1
S : Type u_2
K : Type u_3
L : Type u_4
inst✝¹⁶ : EuclideanDomain R
inst✝¹⁵ : CommRing S
inst✝¹⁴ : IsDomain S
inst✝¹³ : Field K
inst✝¹² : Field L
inst✝¹¹ : Algebra R K
inst✝¹⁰ : IsFractionRing R K
inst✝⁹ : Algebra K L
inst✝⁸ : FiniteDimensional K L
inst✝⁷ : IsSeparable K L
algRL : Algebra R L
inst✝⁶ : IsScalarTower R K L
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra S L
ist : IsScalarTower R S L
iic : IsIntegralClosure S R L
abv : AbsoluteValue R ℤ
ι : Type u_5
inst✝³ : DecidableEq ι
inst✝² : Fintype ι
bS : Basis ι R S
adm : AbsoluteValue.IsAdmissible abv
inst✝¹ : Infinite R
inst✝ : DecidableEq R
⊢ (algebraMap R S) (∏ m in finsetApprox bS adm, m) ≠ 0

Next tactic:
refine' mt ((injective_iff_map_eq_zero _).mp bS.algebraMap_injective _) _