l3lab/ntp-mathlib huggingface dataset:
/-- If `f` is continuous on `[a, ∞)`, and is `O (exp (-b * x))` at `∞` for some `b > 0`, then
`f` is integrable on `(a, ∞)`. -/
theorem integrable_of_isBigO_exp_neg {f : ℝ → ℝ} {a b : ℝ} (h0 : 0 < b)
    (h1 : ContinuousOn f (Ici a)) (h2 : f =O[atTop] fun x => exp (-b * x)) :
    IntegrableOn f (Ioi a) := by
  cases' h2.isBigOWith with c h3
  rw [Asymptotics.isBigOWith_iff, eventually_atTop] at h3
  cases' h3 with r bdr
  let v := max a r
  -- show integrable on `(a, v]` from continuity
  have int_left : IntegrableOn f (Ioc a v) := by
    rw [← intervalIntegrable_iff_integrableOn_Ioc_of_le (le_max_left a r)]
    have u : Icc a v ⊆ Ici a := Icc_subset_Ici_self
    exact (h1.mono u).intervalIntegrable_of_Icc (le_max_left a r)
  suffices IntegrableOn f (Ioi v) by
    have t := integrableOn_union.mpr ⟨int_left, this⟩
    simpa only [Ioc_union_Ioi_eq_Ioi, le_max_iff, le_refl, true_or_iff] using t
  -- now show integrable on `(v, ∞)` from asymptotic
  constructor
  · exact (h1.mono <| Ioi_subset_Ici <| le_max_left a r).aestronglyMeasurable measurableSet_Ioi
  have : HasFiniteIntegral (fun x : ℝ => c * exp (-b * x)) (volume.restrict (Ioi v)) :=
    (exp_neg_integrableOn_Ioi v h0).hasFiniteIntegral.const_mul c
  apply this.mono
  refine' (ae_restrict_iff' measurableSet_Ioi).mpr _
  

Proof state:
case intro.intro.right
f : ℝ → ℝ
a b : ℝ
h0 : 0 < b
h1 : ContinuousOn f (Ici a)
h2 : f =O[atTop] fun x => rexp (-b * x)
c r : ℝ
bdr : ∀ b_1 ≥ r, ‖f b_1‖ ≤ c * ‖rexp (-b * b_1)‖
v : ℝ := max a r
int_left : IntegrableOn f (Ioc a v)
this : HasFiniteIntegral fun x => c * rexp (-b * x)
⊢ ∀ᵐ (x : ℝ), x ∈ Ioi v → ‖f x‖ ≤ ‖c * rexp (-b * x)‖

Next tactic:
refine' ae_of_all _ fun x h1x => _
/-- If `f` is continuous on `[a, ∞)`, and is `O (exp (-b * x))` at `∞` for some `b > 0`, then
`f` is integrable on `(a, ∞)`. -/
theorem integrable_of_isBigO_exp_neg {f : ℝ → ℝ} {a b : ℝ} (h0 : 0 < b)
    (h1 : ContinuousOn f (Ici a)) (h2 : f =O[atTop] fun x => exp (-b * x)) :
    IntegrableOn f (Ioi a) := by
  cases' h2.isBigOWith with c h3
  rw [Asymptotics.isBigOWith_iff, eventually_atTop] at h3
  cases' h3 with r bdr
  let v := max a r
  -- show integrable on `(a, v]` from continuity
  have int_left : IntegrableOn f (Ioc a v) := by
    rw [← intervalIntegrable_iff_integrableOn_Ioc_of_le (le_max_left a r)]
    have u : Icc a v ⊆ Ici a := Icc_subset_Ici_self
    exact (h1.mono u).intervalIntegrable_of_Icc (le_max_left a r)
  suffices IntegrableOn f (Ioi v) by
    have t := integrableOn_union.mpr ⟨int_left, this⟩
    simpa only [Ioc_union_Ioi_eq_Ioi, le_max_iff, le_refl, true_or_iff] using t
  -- now show integrable on `(v, ∞)` from asymptotic
  constructor
  · exact (h1.mono <| Ioi_subset_Ici <| le_max_left a r).aestronglyMeasurable measurableSet_Ioi
  have : HasFiniteIntegral (fun x : ℝ => c * exp (-b * x)) (volume.restrict (Ioi v)) :=
    (exp_neg_integrableOn_Ioi v h0).hasFiniteIntegral.const_mul c
  apply this.mono
  refine' (ae_restrict_iff' measurableSet_Ioi).mpr _
  refine' ae_of_all _ fun x h1x => _
  

Proof state:
case intro.intro.right
f : ℝ → ℝ
a b : ℝ
h0 : 0 < b
h1 : ContinuousOn f (Ici a)
h2 : f =O[atTop] fun x => rexp (-b * x)
c r : ℝ
bdr : ∀ b_1 ≥ r, ‖f b_1‖ ≤ c * ‖rexp (-b * b_1)‖
v : ℝ := max a r
int_left : IntegrableOn f (Ioc a v)
this : HasFiniteIntegral fun x => c * rexp (-b * x)
x : ℝ
h1x : x ∈ Ioi v
⊢ ‖f x‖ ≤ ‖c * rexp (-b * x)‖

Next tactic:
rw [norm_mul, norm_eq_abs]
/-- If `f` is continuous on `[a, ∞)`, and is `O (exp (-b * x))` at `∞` for some `b > 0`, then
`f` is integrable on `(a, ∞)`. -/
theorem integrable_of_isBigO_exp_neg {f : ℝ → ℝ} {a b : ℝ} (h0 : 0 < b)
    (h1 : ContinuousOn f (Ici a)) (h2 : f =O[atTop] fun x => exp (-b * x)) :
    IntegrableOn f (Ioi a) := by
  cases' h2.isBigOWith with c h3
  rw [Asymptotics.isBigOWith_iff, eventually_atTop] at h3
  cases' h3 with r bdr
  let v := max a r
  -- show integrable on `(a, v]` from continuity
  have int_left : IntegrableOn f (Ioc a v) := by
    rw [← intervalIntegrable_iff_integrableOn_Ioc_of_le (le_max_left a r)]
    have u : Icc a v ⊆ Ici a := Icc_subset_Ici_self
    exact (h1.mono u).intervalIntegrable_of_Icc (le_max_left a r)
  suffices IntegrableOn f (Ioi v) by
    have t := integrableOn_union.mpr ⟨int_left, this⟩
    simpa only [Ioc_union_Ioi_eq_Ioi, le_max_iff, le_refl, true_or_iff] using t
  -- now show integrable on `(v, ∞)` from asymptotic
  constructor
  · exact (h1.mono <| Ioi_subset_Ici <| le_max_left a r).aestronglyMeasurable measurableSet_Ioi
  have : HasFiniteIntegral (fun x : ℝ => c * exp (-b * x)) (volume.restrict (Ioi v)) :=
    (exp_neg_integrableOn_Ioi v h0).hasFiniteIntegral.const_mul c
  apply this.mono
  refine' (ae_restrict_iff' measurableSet_Ioi).mpr _
  refine' ae_of_all _ fun x h1x => _
  rw [norm_mul, norm_eq_abs]
  

Proof state:
case intro.intro.right
f : ℝ → ℝ
a b : ℝ
h0 : 0 < b
h1 : ContinuousOn f (Ici a)
h2 : f =O[atTop] fun x => rexp (-b * x)
c r : ℝ
bdr : ∀ b_1 ≥ r, ‖f b_1‖ ≤ c * ‖rexp (-b * b_1)‖
v : ℝ := max a r
int_left : IntegrableOn f (Ioc a v)
this : HasFiniteIntegral fun x => c * rexp (-b * x)
x : ℝ
h1x : x ∈ Ioi v
⊢ |f x| ≤ ‖c‖ * ‖rexp (-b * x)‖

Next tactic:
rw [mem_Ioi] at h1x
/-- If `f` is continuous on `[a, ∞)`, and is `O (exp (-b * x))` at `∞` for some `b > 0`, then
`f` is integrable on `(a, ∞)`. -/
theorem integrable_of_isBigO_exp_neg {f : ℝ → ℝ} {a b : ℝ} (h0 : 0 < b)
    (h1 : ContinuousOn f (Ici a)) (h2 : f =O[atTop] fun x => exp (-b * x)) :
    IntegrableOn f (Ioi a) := by
  cases' h2.isBigOWith with c h3
  rw [Asymptotics.isBigOWith_iff, eventually_atTop] at h3
  cases' h3 with r bdr
  let v := max a r
  -- show integrable on `(a, v]` from continuity
  have int_left : IntegrableOn f (Ioc a v) := by
    rw [← intervalIntegrable_iff_integrableOn_Ioc_of_le (le_max_left a r)]
    have u : Icc a v ⊆ Ici a := Icc_subset_Ici_self
    exact (h1.mono u).intervalIntegrable_of_Icc (le_max_left a r)
  suffices IntegrableOn f (Ioi v) by
    have t := integrableOn_union.mpr ⟨int_left, this⟩
    simpa only [Ioc_union_Ioi_eq_Ioi, le_max_iff, le_refl, true_or_iff] using t
  -- now show integrable on `(v, ∞)` from asymptotic
  constructor
  · exact (h1.mono <| Ioi_subset_Ici <| le_max_left a r).aestronglyMeasurable measurableSet_Ioi
  have : HasFiniteIntegral (fun x : ℝ => c * exp (-b * x)) (volume.restrict (Ioi v)) :=
    (exp_neg_integrableOn_Ioi v h0).hasFiniteIntegral.const_mul c
  apply this.mono
  refine' (ae_restrict_iff' measurableSet_Ioi).mpr _
  refine' ae_of_all _ fun x h1x => _
  rw [norm_mul, norm_eq_abs]
  rw [mem_Ioi] at h1x
  

Proof state:
case intro.intro.right
f : ℝ → ℝ
a b : ℝ
h0 : 0 < b
h1 : ContinuousOn f (Ici a)
h2 : f =O[atTop] fun x => rexp (-b * x)
c r : ℝ
bdr : ∀ b_1 ≥ r, ‖f b_1‖ ≤ c * ‖rexp (-b * b_1)‖
v : ℝ := max a r
int_left : IntegrableOn f (Ioc a v)
this : HasFiniteIntegral fun x => c * rexp (-b * x)
x : ℝ
h1x : v < x
⊢ |f x| ≤ ‖c‖ * ‖rexp (-b * x)‖

Next tactic:
specialize bdr x ((le_max_right a r).trans h1x.le)
/-- If `f` is continuous on `[a, ∞)`, and is `O (exp (-b * x))` at `∞` for some `b > 0`, then
`f` is integrable on `(a, ∞)`. -/
theorem integrable_of_isBigO_exp_neg {f : ℝ → ℝ} {a b : ℝ} (h0 : 0 < b)
    (h1 : ContinuousOn f (Ici a)) (h2 : f =O[atTop] fun x => exp (-b * x)) :
    IntegrableOn f (Ioi a) := by
  cases' h2.isBigOWith with c h3
  rw [Asymptotics.isBigOWith_iff, eventually_atTop] at h3
  cases' h3 with r bdr
  let v := max a r
  -- show integrable on `(a, v]` from continuity
  have int_left : IntegrableOn f (Ioc a v) := by
    rw [← intervalIntegrable_iff_integrableOn_Ioc_of_le (le_max_left a r)]
    have u : Icc a v ⊆ Ici a := Icc_subset_Ici_self
    exact (h1.mono u).intervalIntegrable_of_Icc (le_max_left a r)
  suffices IntegrableOn f (Ioi v) by
    have t := integrableOn_union.mpr ⟨int_left, this⟩
    simpa only [Ioc_union_Ioi_eq_Ioi, le_max_iff, le_refl, true_or_iff] using t
  -- now show integrable on `(v, ∞)` from asymptotic
  constructor
  · exact (h1.mono <| Ioi_subset_Ici <| le_max_left a r).aestronglyMeasurable measurableSet_Ioi
  have : HasFiniteIntegral (fun x : ℝ => c * exp (-b * x)) (volume.restrict (Ioi v)) :=
    (exp_neg_integrableOn_Ioi v h0).hasFiniteIntegral.const_mul c
  apply this.mono
  refine' (ae_restrict_iff' measurableSet_Ioi).mpr _
  refine' ae_of_all _ fun x h1x => _
  rw [norm_mul, norm_eq_abs]
  rw [mem_Ioi] at h1x
  specialize bdr x ((le_max_right a r).trans h1x.le)
  

Proof state:
case intro.intro.right
f : ℝ → ℝ
a b : ℝ
h0 : 0 < b
h1 : ContinuousOn f (Ici a)
h2 : f =O[atTop] fun x => rexp (-b * x)
c r : ℝ
v : ℝ := max a r
int_left : IntegrableOn f (Ioc a v)
this : HasFiniteIntegral fun x => c * rexp (-b * x)
x : ℝ
h1x : v < x
bdr : ‖f x‖ ≤ c * ‖rexp (-b * x)‖
⊢ |f x| ≤ ‖c‖ * ‖rexp (-b * x)‖

Next tactic:
exact bdr.trans (mul_le_mul_of_nonneg_right (le_abs_self c) (norm_nonneg _))
/-- The cast from `Int` to `Rat` as a `FractionRing`. -/
instance Rat.isFractionRing : IsFractionRing ℤ ℚ where
  map_units' := by
    

Proof state:
R : Type u_1
inst✝⁵ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁴ : CommRing S
inst✝³ : Algebra R S
P : Type u_3
inst✝² : CommRing P
A : Type u_4
inst✝¹ : CommRing A
inst✝ : IsDomain A
K : Type u_5
⊢ ∀ (y : ↥(nonZeroDivisors ℤ)), IsUnit ((algebraMap ℤ ℚ) ↑y)

Next tactic:
rintro ⟨x, hx⟩
/-- The cast from `Int` to `Rat` as a `FractionRing`. -/
instance Rat.isFractionRing : IsFractionRing ℤ ℚ where
  map_units' := by
    rintro ⟨x, hx⟩
    

Proof state:
case mk
R : Type u_1
inst✝⁵ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁴ : CommRing S
inst✝³ : Algebra R S
P : Type u_3
inst✝² : CommRing P
A : Type u_4
inst✝¹ : CommRing A
inst✝ : IsDomain A
K : Type u_5
x : ℤ
hx : x ∈ nonZeroDivisors ℤ
⊢ IsUnit ((algebraMap ℤ ℚ) ↑{ val := x, property := hx })

Next tactic:
rw [mem_nonZeroDivisors_iff_ne_zero] at hx
/-- The cast from `Int` to `Rat` as a `FractionRing`. -/
instance Rat.isFractionRing : IsFractionRing ℤ ℚ where
  map_units' := by
    rintro ⟨x, hx⟩
    rw [mem_nonZeroDivisors_iff_ne_zero] at hx
    

Proof state:
case mk
R : Type u_1
inst✝⁵ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁴ : CommRing S
inst✝³ : Algebra R S
P : Type u_3
inst✝² : CommRing P
A : Type u_4
inst✝¹ : CommRing A
inst✝ : IsDomain A
K : Type u_5
x : ℤ
hx✝ : x ∈ nonZeroDivisors ℤ
hx : x ≠ 0
⊢ IsUnit ((algebraMap ℤ ℚ) ↑{ val := x, property := hx✝ })

Next tactic:
simpa only [eq_intCast, isUnit_iff_ne_zero, Int.cast_eq_zero, Ne.def, Subtype.coe_mk] using hx
/-- The cast from `Int` to `Rat` as a `FractionRing`. -/
instance Rat.isFractionRing : IsFractionRing ℤ ℚ where
  map_units' := by
    rintro ⟨x, hx⟩
    rw [mem_nonZeroDivisors_iff_ne_zero] at hx
    simpa only [eq_intCast, isUnit_iff_ne_zero, Int.cast_eq_zero, Ne.def, Subtype.coe_mk] using hx
  surj' := by
    

Proof state:
R : Type u_1
inst✝⁵ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁴ : CommRing S
inst✝³ : Algebra R S
P : Type u_3
inst✝² : CommRing P
A : Type u_4
inst✝¹ : CommRing A
inst✝ : IsDomain A
K : Type u_5
⊢ ∀ (z : ℚ), ∃ x, z * (algebraMap ℤ ℚ) ↑x.2 = (algebraMap ℤ ℚ) x.1

Next tactic:
rintro ⟨n, d, hd, h⟩
/-- The cast from `Int` to `Rat` as a `FractionRing`. -/
instance Rat.isFractionRing : IsFractionRing ℤ ℚ where
  map_units' := by
    rintro ⟨x, hx⟩
    rw [mem_nonZeroDivisors_iff_ne_zero] at hx
    simpa only [eq_intCast, isUnit_iff_ne_zero, Int.cast_eq_zero, Ne.def, Subtype.coe_mk] using hx
  surj' := by
    rintro ⟨n, d, hd, h⟩
    

Proof state:
case mk'
R : Type u_1
inst✝⁵ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁴ : CommRing S
inst✝³ : Algebra R S
P : Type u_3
inst✝² : CommRing P
A : Type u_4
inst✝¹ : CommRing A
inst✝ : IsDomain A
K : Type u_5
n : ℤ
d : ℕ
hd : d ≠ 0
h : Nat.Coprime (Int.natAbs n) d
⊢ ∃ x, mk' n d * (algebraMap ℤ ℚ) ↑x.2 = (algebraMap ℤ ℚ) x.1

Next tactic:
refine' ⟨⟨n, ⟨d, _⟩⟩, Rat.mul_den_eq_num⟩
/-- The cast from `Int` to `Rat` as a `FractionRing`. -/
instance Rat.isFractionRing : IsFractionRing ℤ ℚ where
  map_units' := by
    rintro ⟨x, hx⟩
    rw [mem_nonZeroDivisors_iff_ne_zero] at hx
    simpa only [eq_intCast, isUnit_iff_ne_zero, Int.cast_eq_zero, Ne.def, Subtype.coe_mk] using hx
  surj' := by
    rintro ⟨n, d, hd, h⟩
    refine' ⟨⟨n, ⟨d, _⟩⟩, Rat.mul_den_eq_num⟩
    

Proof state:
case mk'
R : Type u_1
inst✝⁵ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁴ : CommRing S
inst✝³ : Algebra R S
P : Type u_3
inst✝² : CommRing P
A : Type u_4
inst✝¹ : CommRing A
inst✝ : IsDomain A
K : Type u_5
n : ℤ
d : ℕ
hd : d ≠ 0
h : Nat.Coprime (Int.natAbs n) d
⊢ ↑d ∈ nonZeroDivisors ℤ

Next tactic:
rw [mem_nonZeroDivisors_iff_ne_zero, Int.coe_nat_ne_zero_iff_pos]
/-- The cast from `Int` to `Rat` as a `FractionRing`. -/
instance Rat.isFractionRing : IsFractionRing ℤ ℚ where
  map_units' := by
    rintro ⟨x, hx⟩
    rw [mem_nonZeroDivisors_iff_ne_zero] at hx
    simpa only [eq_intCast, isUnit_iff_ne_zero, Int.cast_eq_zero, Ne.def, Subtype.coe_mk] using hx
  surj' := by
    rintro ⟨n, d, hd, h⟩
    refine' ⟨⟨n, ⟨d, _⟩⟩, Rat.mul_den_eq_num⟩
    rw [mem_nonZeroDivisors_iff_ne_zero, Int.coe_nat_ne_zero_iff_pos]
    

Proof state:
case mk'
R : Type u_1
inst✝⁵ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁴ : CommRing S
inst✝³ : Algebra R S
P : Type u_3
inst✝² : CommRing P
A : Type u_4
inst✝¹ : CommRing A
inst✝ : IsDomain A
K : Type u_5
n : ℤ
d : ℕ
hd : d ≠ 0
h : Nat.Coprime (Int.natAbs n) d
⊢ 0 < d

Next tactic:
exact Nat.zero_lt_of_ne_zero hd
/-- The cast from `Int` to `Rat` as a `FractionRing`. -/
instance Rat.isFractionRing : IsFractionRing ℤ ℚ where
  map_units' := by
    rintro ⟨x, hx⟩
    rw [mem_nonZeroDivisors_iff_ne_zero] at hx
    simpa only [eq_intCast, isUnit_iff_ne_zero, Int.cast_eq_zero, Ne.def, Subtype.coe_mk] using hx
  surj' := by
    rintro ⟨n, d, hd, h⟩
    refine' ⟨⟨n, ⟨d, _⟩⟩, Rat.mul_den_eq_num⟩
    rw [mem_nonZeroDivisors_iff_ne_zero, Int.coe_nat_ne_zero_iff_pos]
    exact Nat.zero_lt_of_ne_zero hd
  exists_of_eq {x y} := by
    

Proof state:
R : Type u_1
inst✝⁵ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁴ : CommRing S
inst✝³ : Algebra R S
P : Type u_3
inst✝² : CommRing P
A : Type u_4
inst✝¹ : CommRing A
inst✝ : IsDomain A
K : Type u_5
x y : ℤ
⊢ (algebraMap ℤ ℚ) x = (algebraMap ℤ ℚ) y → ∃ c, ↑c * x = ↑c * y

Next tactic:
rw [eq_intCast, eq_intCast, Int.cast_inj]
/-- The cast from `Int` to `Rat` as a `FractionRing`. -/
instance Rat.isFractionRing : IsFractionRing ℤ ℚ where
  map_units' := by
    rintro ⟨x, hx⟩
    rw [mem_nonZeroDivisors_iff_ne_zero] at hx
    simpa only [eq_intCast, isUnit_iff_ne_zero, Int.cast_eq_zero, Ne.def, Subtype.coe_mk] using hx
  surj' := by
    rintro ⟨n, d, hd, h⟩
    refine' ⟨⟨n, ⟨d, _⟩⟩, Rat.mul_den_eq_num⟩
    rw [mem_nonZeroDivisors_iff_ne_zero, Int.coe_nat_ne_zero_iff_pos]
    exact Nat.zero_lt_of_ne_zero hd
  exists_of_eq {x y} := by
    rw [eq_intCast, eq_intCast, Int.cast_inj]
    

Proof state:
R : Type u_1
inst✝⁵ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁴ : CommRing S
inst✝³ : Algebra R S
P : Type u_3
inst✝² : CommRing P
A : Type u_4
inst✝¹ : CommRing A
inst✝ : IsDomain A
K : Type u_5
x y : ℤ
⊢ x = y → ∃ c, ↑c * x = ↑c * y

Next tactic:
rintro rfl
/-- The cast from `Int` to `Rat` as a `FractionRing`. -/
instance Rat.isFractionRing : IsFractionRing ℤ ℚ where
  map_units' := by
    rintro ⟨x, hx⟩
    rw [mem_nonZeroDivisors_iff_ne_zero] at hx
    simpa only [eq_intCast, isUnit_iff_ne_zero, Int.cast_eq_zero, Ne.def, Subtype.coe_mk] using hx
  surj' := by
    rintro ⟨n, d, hd, h⟩
    refine' ⟨⟨n, ⟨d, _⟩⟩, Rat.mul_den_eq_num⟩
    rw [mem_nonZeroDivisors_iff_ne_zero, Int.coe_nat_ne_zero_iff_pos]
    exact Nat.zero_lt_of_ne_zero hd
  exists_of_eq {x y} := by
    rw [eq_intCast, eq_intCast, Int.cast_inj]
    rintro rfl
    

Proof state:
R : Type u_1
inst✝⁵ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁴ : CommRing S
inst✝³ : Algebra R S
P : Type u_3
inst✝² : CommRing P
A : Type u_4
inst✝¹ : CommRing A
inst✝ : IsDomain A
K : Type u_5
x : ℤ
⊢ ∃ c, ↑c * x = ↑c * x

Next tactic:
use 1
protected theorem mul_inv_cancel (x : K) (hx : x ≠ 0) : x * IsFractionRing.inv A x = 1 := by
  

Proof state:
R : Type u_1
inst✝¹⁰ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁹ : CommRing S
inst✝⁸ : Algebra R S
P : Type u_3
inst✝⁷ : CommRing P
A : Type u_4
inst✝⁶ : CommRing A
inst✝⁵ : IsDomain A
K : Type u_5
inst✝⁴ : CommRing K
inst✝³ : Algebra R K
inst✝² : IsFractionRing R K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
x : K
hx : x ≠ 0
⊢ x * IsFractionRing.inv A x = 1

Next tactic:
rw [IsFractionRing.inv, dif_neg hx, ←
    IsUnit.mul_left_inj
      (map_units K
        ⟨(sec _ x).1,
          mem_nonZeroDivisors_iff_ne_zero.2 fun h0 =>
            hx <| eq_zero_of_fst_eq_zero (sec_spec (nonZeroDivisors A) x) h0⟩),
    one_mul, mul_assoc]
protected theorem mul_inv_cancel (x : K) (hx : x ≠ 0) : x * IsFractionRing.inv A x = 1 := by
  rw [IsFractionRing.inv, dif_neg hx, ←
    IsUnit.mul_left_inj
      (map_units K
        ⟨(sec _ x).1,
          mem_nonZeroDivisors_iff_ne_zero.2 fun h0 =>
            hx <| eq_zero_of_fst_eq_zero (sec_spec (nonZeroDivisors A) x) h0⟩),
    one_mul, mul_assoc]
  

Proof state:
R : Type u_1
inst✝¹⁰ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁹ : CommRing S
inst✝⁸ : Algebra R S
P : Type u_3
inst✝⁷ : CommRing P
A : Type u_4
inst✝⁶ : CommRing A
inst✝⁵ : IsDomain A
K : Type u_5
inst✝⁴ : CommRing K
inst✝³ : Algebra R K
inst✝² : IsFractionRing R K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
x : K
hx : x ≠ 0
⊢ x *
      (mk' K ↑(sec (nonZeroDivisors A) x).2
          { val := (sec (nonZeroDivisors A) x).1,
            property := (_ : (sec (nonZeroDivisors A) x).1 ∈ nonZeroDivisors A) } *
        (algebraMap A K)
          ↑{ val := (sec (nonZeroDivisors A) x).1,
              property := (_ : (sec (nonZeroDivisors A) x).1 ∈ nonZeroDivisors A) }) =
    (algebraMap A K)
      ↑{ val := (sec (nonZeroDivisors A) x).1, property := (_ : (sec (nonZeroDivisors A) x).1 ∈ nonZeroDivisors A) }

Next tactic:
rw [mk'_spec, ← eq_mk'_iff_mul_eq]
protected theorem mul_inv_cancel (x : K) (hx : x ≠ 0) : x * IsFractionRing.inv A x = 1 := by
  rw [IsFractionRing.inv, dif_neg hx, ←
    IsUnit.mul_left_inj
      (map_units K
        ⟨(sec _ x).1,
          mem_nonZeroDivisors_iff_ne_zero.2 fun h0 =>
            hx <| eq_zero_of_fst_eq_zero (sec_spec (nonZeroDivisors A) x) h0⟩),
    one_mul, mul_assoc]
  rw [mk'_spec, ← eq_mk'_iff_mul_eq]
  

Proof state:
R : Type u_1
inst✝¹⁰ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁹ : CommRing S
inst✝⁸ : Algebra R S
P : Type u_3
inst✝⁷ : CommRing P
A : Type u_4
inst✝⁶ : CommRing A
inst✝⁵ : IsDomain A
K : Type u_5
inst✝⁴ : CommRing K
inst✝³ : Algebra R K
inst✝² : IsFractionRing R K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
x : K
hx : x ≠ 0
⊢ x =
    mk' K
      (↑{ val := (sec (nonZeroDivisors A) x).1, property := (_ : (sec (nonZeroDivisors A) x).1 ∈ nonZeroDivisors A) })
      (sec (nonZeroDivisors A) x).2

Next tactic:
exact (mk'_sec _ x).symm
/-- A `CommRing` `K` which is the localization of an integral domain `R` at `R - {0}` is a field.
See note [reducible non-instances]. -/
@[reducible]
noncomputable def toField : Field K :=
  { IsFractionRing.isDomain A, inferInstanceAs (CommRing K) with
    inv := IsFractionRing.inv A
    mul_inv_cancel := IsFractionRing.mul_inv_cancel A
    inv_zero := by
      

Proof state:
R : Type u_1
inst✝¹⁰ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁹ : CommRing S
inst✝⁸ : Algebra R S
P : Type u_3
inst✝⁷ : CommRing P
A : Type u_4
inst✝⁶ : CommRing A
inst✝⁵ : IsDomain A
K : Type u_5
inst✝⁴ : CommRing K
inst✝³ : Algebra R K
inst✝² : IsFractionRing R K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
src✝¹ : IsDomain K := IsFractionRing.isDomain A
src✝ : CommRing K := inferInstanceAs (CommRing K)
⊢ 0⁻¹ = 0

Next tactic:
change IsFractionRing.inv A (0 : K) = 0
/-- A `CommRing` `K` which is the localization of an integral domain `R` at `R - {0}` is a field.
See note [reducible non-instances]. -/
@[reducible]
noncomputable def toField : Field K :=
  { IsFractionRing.isDomain A, inferInstanceAs (CommRing K) with
    inv := IsFractionRing.inv A
    mul_inv_cancel := IsFractionRing.mul_inv_cancel A
    inv_zero := by
      change IsFractionRing.inv A (0 : K) = 0
      

Proof state:
R : Type u_1
inst✝¹⁰ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁹ : CommRing S
inst✝⁸ : Algebra R S
P : Type u_3
inst✝⁷ : CommRing P
A : Type u_4
inst✝⁶ : CommRing A
inst✝⁵ : IsDomain A
K : Type u_5
inst✝⁴ : CommRing K
inst✝³ : Algebra R K
inst✝² : IsFractionRing R K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
src✝¹ : IsDomain K := IsFractionRing.isDomain A
src✝ : CommRing K := inferInstanceAs (CommRing K)
⊢ IsFractionRing.inv A 0 = 0

Next tactic:
rw [IsFractionRing.inv]
/-- A `CommRing` `K` which is the localization of an integral domain `R` at `R - {0}` is a field.
See note [reducible non-instances]. -/
@[reducible]
noncomputable def toField : Field K :=
  { IsFractionRing.isDomain A, inferInstanceAs (CommRing K) with
    inv := IsFractionRing.inv A
    mul_inv_cancel := IsFractionRing.mul_inv_cancel A
    inv_zero := by
      change IsFractionRing.inv A (0 : K) = 0
      rw [IsFractionRing.inv]
      

Proof state:
R : Type u_1
inst✝¹⁰ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁹ : CommRing S
inst✝⁸ : Algebra R S
P : Type u_3
inst✝⁷ : CommRing P
A : Type u_4
inst✝⁶ : CommRing A
inst✝⁵ : IsDomain A
K : Type u_5
inst✝⁴ : CommRing K
inst✝³ : Algebra R K
inst✝² : IsFractionRing R K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
src✝¹ : IsDomain K := IsFractionRing.isDomain A
src✝ : CommRing K := inferInstanceAs (CommRing K)
⊢ (if h : 0 = 0 then 0
    else
      mk' K ↑(sec (nonZeroDivisors A) 0).2
        { val := (sec (nonZeroDivisors A) 0).1, property := (_ : (sec (nonZeroDivisors A) 0).1 ∈ nonZeroDivisors A) }) =
    0

Next tactic:
exact dif_pos rfl
theorem div_surjective (z : K) :
    ∃ x y : A, y ∈ nonZeroDivisors A ∧ algebraMap _ _ x / algebraMap _ _ y = z :=
  let ⟨x, ⟨y, hy⟩, h⟩ := mk'_surjective (nonZeroDivisors A) z
  ⟨x, y, hy, by 

Proof state:
R : Type u_1
inst✝¹¹ : CommRing R
M : Submonoid R
S : Type u_2
inst✝¹⁰ : CommRing S
inst✝⁹ : Algebra R S
P : Type u_3
inst✝⁸ : CommRing P
A : Type u_4
inst✝⁷ : CommRing A
inst✝⁶ : IsDomain A
K : Type u_5
B : Type u_6
inst✝⁵ : CommRing B
inst✝⁴ : IsDomain B
inst✝³ : Field K
L : Type u_7
inst✝² : Field L
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
g : A →+* L
z : K
x y : A
hy : y ∈ nonZeroDivisors A
h : mk' K x { val := y, property := hy } = z
⊢ (algebraMap A K) x / (algebraMap A K) y = z

Next tactic:
rwa [mk'_eq_div] at h
@[simp]
theorem mk'_eq_zero_iff_eq_zero [Algebra R K] [IsFractionRing R K] {x : R} {y : nonZeroDivisors R} :
    mk' K x y = 0 ↔ x = 0 := by
  

Proof state:
R : Type u_1
inst✝¹³ : CommRing R
M : Submonoid R
S : Type u_2
inst✝¹² : CommRing S
inst✝¹¹ : Algebra R S
P : Type u_3
inst✝¹⁰ : CommRing P
A : Type u_4
inst✝⁹ : CommRing A
inst✝⁸ : IsDomain A
K : Type u_5
B : Type u_6
inst✝⁷ : CommRing B
inst✝⁶ : IsDomain B
inst✝⁵ : Field K
L : Type u_7
inst✝⁴ : Field L
inst✝³ : Algebra A K
inst✝² : IsFractionRing A K
g : A →+* L
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
x : R
y : ↥(nonZeroDivisors R)
⊢ mk' K x y = 0 ↔ x = 0

Next tactic:
refine' ⟨fun hxy => _, fun h => by rw [h, mk'_zero]⟩
@[simp]
theorem mk'_eq_zero_iff_eq_zero [Algebra R K] [IsFractionRing R K] {x : R} {y : nonZeroDivisors R} :
    mk' K x y = 0 ↔ x = 0 := by
  refine' ⟨fun hxy => _, fun h => by 

Proof state:
R : Type u_1
inst✝¹³ : CommRing R
M : Submonoid R
S : Type u_2
inst✝¹² : CommRing S
inst✝¹¹ : Algebra R S
P : Type u_3
inst✝¹⁰ : CommRing P
A : Type u_4
inst✝⁹ : CommRing A
inst✝⁸ : IsDomain A
K : Type u_5
B : Type u_6
inst✝⁷ : CommRing B
inst✝⁶ : IsDomain B
inst✝⁵ : Field K
L : Type u_7
inst✝⁴ : Field L
inst✝³ : Algebra A K
inst✝² : IsFractionRing A K
g : A →+* L
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
x : R
y : ↥(nonZeroDivisors R)
h : x = 0
⊢ mk' K x y = 0

Next tactic:
rw [h, mk'_zero]