l3lab/ntp-mathlib huggingface dataset:
/-- Continuous functions are dense in `MeasureTheory.Lp`, `1 ≤ p < ∞`. This theorem assumes that
the domain is a compact space because otherwise `ContinuousMap.toLp` is undefined. Use
`BoundedContinuousFunction.toLp_denseRange` if the domain is not a compact space.  -/
theorem toLp_denseRange [CompactSpace α] [μ.WeaklyRegular] [IsFiniteMeasure μ] :
    DenseRange (toLp p μ 𝕜 : C(α, E) →L[𝕜] Lp E p μ) := by
  refine (BoundedContinuousFunction.toLp_denseRange _ _ hp 𝕜).mono ?_
  refine range_subset_iff.2 fun f ↦ ?_
  

Proof state:
α : Type u_1
inst✝¹¹ : MeasurableSpace α
inst✝¹⁰ : TopologicalSpace α
inst✝⁹ : T4Space α
inst✝⁸ : BorelSpace α
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
μ : Measure α
p : ℝ≥0∞
inst✝⁶ : SecondCountableTopologyEither α E
_i : Fact (1 ≤ p)
hp : p ≠ ⊤
𝕜 : Type u_3
inst✝⁵ : NormedField 𝕜
inst✝⁴ : NormedAlgebra ℝ 𝕜
inst✝³ : NormedSpace 𝕜 E
inst✝² : CompactSpace α
inst✝¹ : Measure.WeaklyRegular μ
inst✝ : IsFiniteMeasure μ
f : α →ᵇ E
⊢ (BoundedContinuousFunction.toLp p μ 𝕜) f ∈ range ⇑(toLp p μ 𝕜)

Next tactic:
exact ⟨f.toContinuousMap, rfl⟩
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
private def map_ideal (I : Ideal R) : Ideal S where
  carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
  zero_mem' := ⟨⟨0, 1⟩, by simp⟩
  add_mem' := by
    

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
⊢ ∀ {a b : S},
    a ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1} →
      b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1} →
        a + b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1}

Next tactic:
rintro a b ⟨a', ha⟩ ⟨b', hb⟩
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
private def map_ideal (I : Ideal R) : Ideal S where
  carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
  zero_mem' := ⟨⟨0, 1⟩, by simp⟩
  add_mem' := by
    rintro a b ⟨a', ha⟩ ⟨b', hb⟩
    

Proof state:
case intro.intro
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
a b : S
a' : ↥I × ↥M
ha : a * (algebraMap R S) ↑a'.2 = (algebraMap R S) ↑a'.1
b' : ↥I × ↥M
hb : b * (algebraMap R S) ↑b'.2 = (algebraMap R S) ↑b'.1
⊢ a + b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1}

Next tactic:
let Z : { x // x ∈ I } := ⟨(a'.2 : R) * (b'.1 : R) + (b'.2 : R) * (a'.1 : R),
      I.add_mem (I.mul_mem_left _ b'.1.2) (I.mul_mem_left _ a'.1.2)⟩
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
private def map_ideal (I : Ideal R) : Ideal S where
  carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
  zero_mem' := ⟨⟨0, 1⟩, by simp⟩
  add_mem' := by
    rintro a b ⟨a', ha⟩ ⟨b', hb⟩
    let Z : { x // x ∈ I } := ⟨(a'.2 : R) * (b'.1 : R) + (b'.2 : R) * (a'.1 : R),
      I.add_mem (I.mul_mem_left _ b'.1.2) (I.mul_mem_left _ a'.1.2)⟩
    

Proof state:
case intro.intro
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
a b : S
a' : ↥I × ↥M
ha : a * (algebraMap R S) ↑a'.2 = (algebraMap R S) ↑a'.1
b' : ↥I × ↥M
hb : b * (algebraMap R S) ↑b'.2 = (algebraMap R S) ↑b'.1
Z : ↥I := { val := ↑a'.2 * ↑b'.1 + ↑b'.2 * ↑a'.1, property := (_ : ↑a'.2 * ↑b'.1 + ↑b'.2 * ↑a'.1 ∈ I) }
⊢ a + b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1}

Next tactic:
use ⟨Z, a'.2 * b'.2⟩
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
private def map_ideal (I : Ideal R) : Ideal S where
  carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
  zero_mem' := ⟨⟨0, 1⟩, by simp⟩
  add_mem' := by
    rintro a b ⟨a', ha⟩ ⟨b', hb⟩
    let Z : { x // x ∈ I } := ⟨(a'.2 : R) * (b'.1 : R) + (b'.2 : R) * (a'.1 : R),
      I.add_mem (I.mul_mem_left _ b'.1.2) (I.mul_mem_left _ a'.1.2)⟩
    use ⟨Z, a'.2 * b'.2⟩
    

Proof state:
case h
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
a b : S
a' : ↥I × ↥M
ha : a * (algebraMap R S) ↑a'.2 = (algebraMap R S) ↑a'.1
b' : ↥I × ↥M
hb : b * (algebraMap R S) ↑b'.2 = (algebraMap R S) ↑b'.1
Z : ↥I := { val := ↑a'.2 * ↑b'.1 + ↑b'.2 * ↑a'.1, property := (_ : ↑a'.2 * ↑b'.1 + ↑b'.2 * ↑a'.1 ∈ I) }
⊢ (a + b) * (algebraMap R S) ↑(Z, a'.2 * b'.2).2 = (algebraMap R S) ↑(Z, a'.2 * b'.2).1

Next tactic:
simp only [RingHom.map_add, Submodule.coe_mk, Submonoid.coe_mul, RingHom.map_mul]
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
private def map_ideal (I : Ideal R) : Ideal S where
  carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
  zero_mem' := ⟨⟨0, 1⟩, by simp⟩
  add_mem' := by
    rintro a b ⟨a', ha⟩ ⟨b', hb⟩
    let Z : { x // x ∈ I } := ⟨(a'.2 : R) * (b'.1 : R) + (b'.2 : R) * (a'.1 : R),
      I.add_mem (I.mul_mem_left _ b'.1.2) (I.mul_mem_left _ a'.1.2)⟩
    use ⟨Z, a'.2 * b'.2⟩
    simp only [RingHom.map_add, Submodule.coe_mk, Submonoid.coe_mul, RingHom.map_mul]
    

Proof state:
case h
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
a b : S
a' : ↥I × ↥M
ha : a * (algebraMap R S) ↑a'.2 = (algebraMap R S) ↑a'.1
b' : ↥I × ↥M
hb : b * (algebraMap R S) ↑b'.2 = (algebraMap R S) ↑b'.1
Z : ↥I := { val := ↑a'.2 * ↑b'.1 + ↑b'.2 * ↑a'.1, property := (_ : ↑a'.2 * ↑b'.1 + ↑b'.2 * ↑a'.1 ∈ I) }
⊢ (a + b) * ((algebraMap R S) ↑a'.2 * (algebraMap R S) ↑b'.2) =
    (algebraMap R S) ↑a'.2 * (algebraMap R S) ↑b'.1 + (algebraMap R S) ↑b'.2 * (algebraMap R S) ↑a'.1

Next tactic:
rw [add_mul, ← mul_assoc a, ha, mul_comm (algebraMap R S a'.2) (algebraMap R S b'.2), ←
      mul_assoc b, hb]
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
private def map_ideal (I : Ideal R) : Ideal S where
  carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
  zero_mem' := ⟨⟨0, 1⟩, by simp⟩
  add_mem' := by
    rintro a b ⟨a', ha⟩ ⟨b', hb⟩
    let Z : { x // x ∈ I } := ⟨(a'.2 : R) * (b'.1 : R) + (b'.2 : R) * (a'.1 : R),
      I.add_mem (I.mul_mem_left _ b'.1.2) (I.mul_mem_left _ a'.1.2)⟩
    use ⟨Z, a'.2 * b'.2⟩
    simp only [RingHom.map_add, Submodule.coe_mk, Submonoid.coe_mul, RingHom.map_mul]
    rw [add_mul, ← mul_assoc a, ha, mul_comm (algebraMap R S a'.2) (algebraMap R S b'.2), ←
      mul_assoc b, hb]
    

Proof state:
case h
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
a b : S
a' : ↥I × ↥M
ha : a * (algebraMap R S) ↑a'.2 = (algebraMap R S) ↑a'.1
b' : ↥I × ↥M
hb : b * (algebraMap R S) ↑b'.2 = (algebraMap R S) ↑b'.1
Z : ↥I := { val := ↑a'.2 * ↑b'.1 + ↑b'.2 * ↑a'.1, property := (_ : ↑a'.2 * ↑b'.1 + ↑b'.2 * ↑a'.1 ∈ I) }
⊢ (algebraMap R S) ↑a'.1 * (algebraMap R S) ↑b'.2 + (algebraMap R S) ↑b'.1 * (algebraMap R S) ↑a'.2 =
    (algebraMap R S) ↑a'.2 * (algebraMap R S) ↑b'.1 + (algebraMap R S) ↑b'.2 * (algebraMap R S) ↑a'.1

Next tactic:
ring
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
private def map_ideal (I : Ideal R) : Ideal S where
  carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
  zero_mem' := ⟨⟨0, 1⟩, by 

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
⊢ 0 * (algebraMap R S) ↑(0, 1).2 = (algebraMap R S) ↑(0, 1).1

Next tactic:
simp
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
private def map_ideal (I : Ideal R) : Ideal S where
  carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
  zero_mem' := ⟨⟨0, 1⟩, by simp⟩
  add_mem' := by
    rintro a b ⟨a', ha⟩ ⟨b', hb⟩
    let Z : { x // x ∈ I } := ⟨(a'.2 : R) * (b'.1 : R) + (b'.2 : R) * (a'.1 : R),
      I.add_mem (I.mul_mem_left _ b'.1.2) (I.mul_mem_left _ a'.1.2)⟩
    use ⟨Z, a'.2 * b'.2⟩
    simp only [RingHom.map_add, Submodule.coe_mk, Submonoid.coe_mul, RingHom.map_mul]
    rw [add_mul, ← mul_assoc a, ha, mul_comm (algebraMap R S a'.2) (algebraMap R S b'.2), ←
      mul_assoc b, hb]
    ring
  smul_mem' := by
    

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
⊢ ∀ (c : S) {x : S},
    x ∈
        {
              toAddSubsemigroup :=
                { carrier := {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1},
                  add_mem' :=
                    (_ :
                      ∀ {a b : S},
                        a ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1} →
                          b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1} →
                            a + b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1}) },
              zero_mem' := (_ : ∃ x, 0 * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1) }.toAddSubsemigroup.carrier →
      c • x ∈
        {
              toAddSubsemigroup :=
                { carrier := {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1},
                  add_mem' :=
                    (_ :
                      ∀ {a b : S},
                        a ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1} →
                          b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1} →
                            a + b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1}) },
              zero_mem' := (_ : ∃ x, 0 * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1) }.toAddSubsemigroup.carrier

Next tactic:
rintro c x ⟨x', hx⟩
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
private def map_ideal (I : Ideal R) : Ideal S where
  carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
  zero_mem' := ⟨⟨0, 1⟩, by simp⟩
  add_mem' := by
    rintro a b ⟨a', ha⟩ ⟨b', hb⟩
    let Z : { x // x ∈ I } := ⟨(a'.2 : R) * (b'.1 : R) + (b'.2 : R) * (a'.1 : R),
      I.add_mem (I.mul_mem_left _ b'.1.2) (I.mul_mem_left _ a'.1.2)⟩
    use ⟨Z, a'.2 * b'.2⟩
    simp only [RingHom.map_add, Submodule.coe_mk, Submonoid.coe_mul, RingHom.map_mul]
    rw [add_mul, ← mul_assoc a, ha, mul_comm (algebraMap R S a'.2) (algebraMap R S b'.2), ←
      mul_assoc b, hb]
    ring
  smul_mem' := by
    rintro c x ⟨x', hx⟩
    

Proof state:
case intro
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
c x : S
x' : ↥I × ↥M
hx : x * (algebraMap R S) ↑x'.2 = (algebraMap R S) ↑x'.1
⊢ c • x ∈
    {
          toAddSubsemigroup :=
            { carrier := {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1},
              add_mem' :=
                (_ :
                  ∀ {a b : S},
                    a ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1} →
                      b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1} →
                        a + b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1}) },
          zero_mem' := (_ : ∃ x, 0 * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1) }.toAddSubsemigroup.carrier

Next tactic:
obtain ⟨c', hc⟩ := IsLocalization.surj M c
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
private def map_ideal (I : Ideal R) : Ideal S where
  carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
  zero_mem' := ⟨⟨0, 1⟩, by simp⟩
  add_mem' := by
    rintro a b ⟨a', ha⟩ ⟨b', hb⟩
    let Z : { x // x ∈ I } := ⟨(a'.2 : R) * (b'.1 : R) + (b'.2 : R) * (a'.1 : R),
      I.add_mem (I.mul_mem_left _ b'.1.2) (I.mul_mem_left _ a'.1.2)⟩
    use ⟨Z, a'.2 * b'.2⟩
    simp only [RingHom.map_add, Submodule.coe_mk, Submonoid.coe_mul, RingHom.map_mul]
    rw [add_mul, ← mul_assoc a, ha, mul_comm (algebraMap R S a'.2) (algebraMap R S b'.2), ←
      mul_assoc b, hb]
    ring
  smul_mem' := by
    rintro c x ⟨x', hx⟩
    obtain ⟨c', hc⟩ := IsLocalization.surj M c
    

Proof state:
case intro.intro
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
c x : S
x' : ↥I × ↥M
hx : x * (algebraMap R S) ↑x'.2 = (algebraMap R S) ↑x'.1
c' : R × ↥M
hc : c * (algebraMap R S) ↑c'.2 = (algebraMap R S) c'.1
⊢ c • x ∈
    {
          toAddSubsemigroup :=
            { carrier := {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1},
              add_mem' :=
                (_ :
                  ∀ {a b : S},
                    a ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1} →
                      b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1} →
                        a + b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1}) },
          zero_mem' := (_ : ∃ x, 0 * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1) }.toAddSubsemigroup.carrier

Next tactic:
let Z : { x // x ∈ I } := ⟨c'.1 * x'.1, I.mul_mem_left c'.1 x'.1.2⟩
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
private def map_ideal (I : Ideal R) : Ideal S where
  carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
  zero_mem' := ⟨⟨0, 1⟩, by simp⟩
  add_mem' := by
    rintro a b ⟨a', ha⟩ ⟨b', hb⟩
    let Z : { x // x ∈ I } := ⟨(a'.2 : R) * (b'.1 : R) + (b'.2 : R) * (a'.1 : R),
      I.add_mem (I.mul_mem_left _ b'.1.2) (I.mul_mem_left _ a'.1.2)⟩
    use ⟨Z, a'.2 * b'.2⟩
    simp only [RingHom.map_add, Submodule.coe_mk, Submonoid.coe_mul, RingHom.map_mul]
    rw [add_mul, ← mul_assoc a, ha, mul_comm (algebraMap R S a'.2) (algebraMap R S b'.2), ←
      mul_assoc b, hb]
    ring
  smul_mem' := by
    rintro c x ⟨x', hx⟩
    obtain ⟨c', hc⟩ := IsLocalization.surj M c
    let Z : { x // x ∈ I } := ⟨c'.1 * x'.1, I.mul_mem_left c'.1 x'.1.2⟩
    

Proof state:
case intro.intro
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
c x : S
x' : ↥I × ↥M
hx : x * (algebraMap R S) ↑x'.2 = (algebraMap R S) ↑x'.1
c' : R × ↥M
hc : c * (algebraMap R S) ↑c'.2 = (algebraMap R S) c'.1
Z : ↥I := { val := c'.1 * ↑x'.1, property := (_ : c'.1 * ↑x'.1 ∈ I) }
⊢ c • x ∈
    {
          toAddSubsemigroup :=
            { carrier := {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1},
              add_mem' :=
                (_ :
                  ∀ {a b : S},
                    a ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1} →
                      b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1} →
                        a + b ∈ {z | ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1}) },
          zero_mem' := (_ : ∃ x, 0 * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1) }.toAddSubsemigroup.carrier

Next tactic:
use ⟨Z, c'.2 * x'.2⟩
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
private def map_ideal (I : Ideal R) : Ideal S where
  carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
  zero_mem' := ⟨⟨0, 1⟩, by simp⟩
  add_mem' := by
    rintro a b ⟨a', ha⟩ ⟨b', hb⟩
    let Z : { x // x ∈ I } := ⟨(a'.2 : R) * (b'.1 : R) + (b'.2 : R) * (a'.1 : R),
      I.add_mem (I.mul_mem_left _ b'.1.2) (I.mul_mem_left _ a'.1.2)⟩
    use ⟨Z, a'.2 * b'.2⟩
    simp only [RingHom.map_add, Submodule.coe_mk, Submonoid.coe_mul, RingHom.map_mul]
    rw [add_mul, ← mul_assoc a, ha, mul_comm (algebraMap R S a'.2) (algebraMap R S b'.2), ←
      mul_assoc b, hb]
    ring
  smul_mem' := by
    rintro c x ⟨x', hx⟩
    obtain ⟨c', hc⟩ := IsLocalization.surj M c
    let Z : { x // x ∈ I } := ⟨c'.1 * x'.1, I.mul_mem_left c'.1 x'.1.2⟩
    use ⟨Z, c'.2 * x'.2⟩
    

Proof state:
case h
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
c x : S
x' : ↥I × ↥M
hx : x * (algebraMap R S) ↑x'.2 = (algebraMap R S) ↑x'.1
c' : R × ↥M
hc : c * (algebraMap R S) ↑c'.2 = (algebraMap R S) c'.1
Z : ↥I := { val := c'.1 * ↑x'.1, property := (_ : c'.1 * ↑x'.1 ∈ I) }
⊢ c • x * (algebraMap R S) ↑(Z, c'.2 * x'.2).2 = (algebraMap R S) ↑(Z, c'.2 * x'.2).1

Next tactic:
simp only [← hx, ← hc, smul_eq_mul, Submodule.coe_mk, Submonoid.coe_mul, RingHom.map_mul]
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
private def map_ideal (I : Ideal R) : Ideal S where
  carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
  zero_mem' := ⟨⟨0, 1⟩, by simp⟩
  add_mem' := by
    rintro a b ⟨a', ha⟩ ⟨b', hb⟩
    let Z : { x // x ∈ I } := ⟨(a'.2 : R) * (b'.1 : R) + (b'.2 : R) * (a'.1 : R),
      I.add_mem (I.mul_mem_left _ b'.1.2) (I.mul_mem_left _ a'.1.2)⟩
    use ⟨Z, a'.2 * b'.2⟩
    simp only [RingHom.map_add, Submodule.coe_mk, Submonoid.coe_mul, RingHom.map_mul]
    rw [add_mul, ← mul_assoc a, ha, mul_comm (algebraMap R S a'.2) (algebraMap R S b'.2), ←
      mul_assoc b, hb]
    ring
  smul_mem' := by
    rintro c x ⟨x', hx⟩
    obtain ⟨c', hc⟩ := IsLocalization.surj M c
    let Z : { x // x ∈ I } := ⟨c'.1 * x'.1, I.mul_mem_left c'.1 x'.1.2⟩
    use ⟨Z, c'.2 * x'.2⟩
    simp only [← hx, ← hc, smul_eq_mul, Submodule.coe_mk, Submonoid.coe_mul, RingHom.map_mul]
    

Proof state:
case h
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
c x : S
x' : ↥I × ↥M
hx : x * (algebraMap R S) ↑x'.2 = (algebraMap R S) ↑x'.1
c' : R × ↥M
hc : c * (algebraMap R S) ↑c'.2 = (algebraMap R S) c'.1
Z : ↥I := { val := c'.1 * ↑x'.1, property := (_ : c'.1 * ↑x'.1 ∈ I) }
⊢ c * x * ((algebraMap R S) ↑c'.2 * (algebraMap R S) ↑x'.2) = c * (algebraMap R S) ↑c'.2 * (x * (algebraMap R S) ↑x'.2)

Next tactic:
ring
theorem mem_map_algebraMap_iff {I : Ideal R} {z} : z ∈ Ideal.map (algebraMap R S) I ↔
    ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 := by
  

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
z : S
⊢ z ∈ Ideal.map (algebraMap R S) I ↔ ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1

Next tactic:
constructor
theorem mem_map_algebraMap_iff {I : Ideal R} {z} : z ∈ Ideal.map (algebraMap R S) I ↔
    ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 := by
  constructor
  · 

Proof state:
case mp
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
z : S
⊢ z ∈ Ideal.map (algebraMap R S) I → ∃ x, z * (algebraMap R S) ↑x.2 = (algebraMap R S) ↑x.1

Next tactic:
change _ → z ∈ map_ideal M S I
theorem mem_map_algebraMap_iff {I : Ideal R} {z} : z ∈ Ideal.map (algebraMap R S) I ↔
    ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 := by
  constructor
  · change _ → z ∈ map_ideal M S I
    

Proof state:
case mp
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
z : S
⊢ z ∈ Ideal.map (algebraMap R S) I → z ∈ IsLocalization.map_ideal M S I

Next tactic:
refine' fun h => Ideal.mem_sInf.1 h fun z hz => _
theorem mem_map_algebraMap_iff {I : Ideal R} {z} : z ∈ Ideal.map (algebraMap R S) I ↔
    ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 := by
  constructor
  · change _ → z ∈ map_ideal M S I
    refine' fun h => Ideal.mem_sInf.1 h fun z hz => _
    

Proof state:
case mp
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
z✝ : S
h : z✝ ∈ Ideal.map (algebraMap R S) I
z : S
hz : z ∈ ⇑(algebraMap R S) '' ↑I
⊢ z ∈ ↑(IsLocalization.map_ideal M S I)

Next tactic:
obtain ⟨y, hy⟩ := hz
theorem mem_map_algebraMap_iff {I : Ideal R} {z} : z ∈ Ideal.map (algebraMap R S) I ↔
    ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 := by
  constructor
  · change _ → z ∈ map_ideal M S I
    refine' fun h => Ideal.mem_sInf.1 h fun z hz => _
    obtain ⟨y, hy⟩ := hz
    

Proof state:
case mp.intro
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
I : Ideal R
z✝ : S
h : z✝ ∈ Ideal.map (algebraMap R S) I
z : S
y : R
hy : y ∈ ↑I ∧ (algebraMap R S) y = z
⊢ z ∈ ↑(IsLocalization.map_ideal M S I)

Next tactic:
let Z : { x // x ∈ I } := ⟨y, hy.left⟩