l3lab/ntp-mathlib huggingface dataset:
theorem lift_spec_mul_add {g : R →+* P} (hg : ∀ y : M, IsUnit (g y)) (z w w' v) :
    ((toLocalizationWithZeroMap M S).lift g.toMonoidWithZeroHom hg) z * w + w' = v ↔
      g ((toLocalizationMap M S).sec z).1 * w + g ((toLocalizationMap M S).sec z).2 * w' =
        g ((toLocalizationMap M S).sec z).2 * v := by
  erw [mul_comm, ← mul_assoc, mul_add_inv_left hg, mul_comm]
  

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
z : S
w w' v : P
⊢ ↑(RingHom.toMonoidWithZeroHom g)
            (Submonoid.LocalizationMap.sec (toLocalizationWithZeroMap M S).toLocalizationMap z).1 *
          w +
        g ↑(Submonoid.LocalizationMap.sec (toLocalizationWithZeroMap M S).toLocalizationMap z).2 * w' =
      g ↑(Submonoid.LocalizationMap.sec (toLocalizationWithZeroMap M S).toLocalizationMap z).2 * v ↔
    g (Submonoid.LocalizationMap.sec (toLocalizationMap M S) z).1 * w +
        g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) z).2 * w' =
      g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) z).2 * v

Next tactic:
rfl
/-- Given a localization map `f : R →+* S` for a submonoid `M ⊆ R` and a map of `CommSemiring`s
`g : R →+* P` such that `g y` is invertible for all `y : M`, the homomorphism induced from
`S` to `P` sending `z : S` to `g x * (g y)⁻¹`, where `(x, y) : R × M` are such that
`z = f x * (f y)⁻¹`. -/
noncomputable def lift {g : R →+* P} (hg : ∀ y : M, IsUnit (g y)) : S →+* P :=
  { Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S)
      g.toMonoidWithZeroHom hg with
    map_add' := by
      

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
src✝ : S →*₀ P :=
  Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S) (RingHom.toMonoidWithZeroHom g) hg
⊢ ∀ (x y : S),
    OneHom.toFun
        (↑{ toOneHom := { toFun := src✝.toFun, map_one' := (_ : ZeroHom.toFun (↑src✝) 1 = 1) },
            map_mul' :=
              (_ : ∀ (x y : S), ZeroHom.toFun (↑src✝) (x * y) = ZeroHom.toFun (↑src✝) x * ZeroHom.toFun (↑src✝) y) })
        (x + y) =
      OneHom.toFun
          (↑{ toOneHom := { toFun := src✝.toFun, map_one' := (_ : ZeroHom.toFun (↑src✝) 1 = 1) },
              map_mul' :=
                (_ : ∀ (x y : S), ZeroHom.toFun (↑src✝) (x * y) = ZeroHom.toFun (↑src✝) x * ZeroHom.toFun (↑src✝) y) })
          x +
        OneHom.toFun
          (↑{ toOneHom := { toFun := src✝.toFun, map_one' := (_ : ZeroHom.toFun (↑src✝) 1 = 1) },
              map_mul' :=
                (_ : ∀ (x y : S), ZeroHom.toFun (↑src✝) (x * y) = ZeroHom.toFun (↑src✝) x * ZeroHom.toFun (↑src✝) y) })
          y

Next tactic:
intro x y
/-- Given a localization map `f : R →+* S` for a submonoid `M ⊆ R` and a map of `CommSemiring`s
`g : R →+* P` such that `g y` is invertible for all `y : M`, the homomorphism induced from
`S` to `P` sending `z : S` to `g x * (g y)⁻¹`, where `(x, y) : R × M` are such that
`z = f x * (f y)⁻¹`. -/
noncomputable def lift {g : R →+* P} (hg : ∀ y : M, IsUnit (g y)) : S →+* P :=
  { Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S)
      g.toMonoidWithZeroHom hg with
    map_add' := by
      intro x y
      

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
src✝ : S →*₀ P :=
  Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S) (RingHom.toMonoidWithZeroHom g) hg
x y : S
⊢ OneHom.toFun
      (↑{ toOneHom := { toFun := src✝.toFun, map_one' := (_ : ZeroHom.toFun (↑src✝) 1 = 1) },
          map_mul' :=
            (_ : ∀ (x y : S), ZeroHom.toFun (↑src✝) (x * y) = ZeroHom.toFun (↑src✝) x * ZeroHom.toFun (↑src✝) y) })
      (x + y) =
    OneHom.toFun
        (↑{ toOneHom := { toFun := src✝.toFun, map_one' := (_ : ZeroHom.toFun (↑src✝) 1 = 1) },
            map_mul' :=
              (_ : ∀ (x y : S), ZeroHom.toFun (↑src✝) (x * y) = ZeroHom.toFun (↑src✝) x * ZeroHom.toFun (↑src✝) y) })
        x +
      OneHom.toFun
        (↑{ toOneHom := { toFun := src✝.toFun, map_one' := (_ : ZeroHom.toFun (↑src✝) 1 = 1) },
            map_mul' :=
              (_ : ∀ (x y : S), ZeroHom.toFun (↑src✝) (x * y) = ZeroHom.toFun (↑src✝) x * ZeroHom.toFun (↑src✝) y) })
        y

Next tactic:
erw [(toLocalizationMap M S).lift_spec, mul_add, mul_comm, eq_comm, lift_spec_mul_add,
        add_comm, mul_comm, mul_assoc, mul_comm, mul_assoc, lift_spec_mul_add]
/-- Given a localization map `f : R →+* S` for a submonoid `M ⊆ R` and a map of `CommSemiring`s
`g : R →+* P` such that `g y` is invertible for all `y : M`, the homomorphism induced from
`S` to `P` sending `z : S` to `g x * (g y)⁻¹`, where `(x, y) : R × M` are such that
`z = f x * (f y)⁻¹`. -/
noncomputable def lift {g : R →+* P} (hg : ∀ y : M, IsUnit (g y)) : S →+* P :=
  { Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S)
      g.toMonoidWithZeroHom hg with
    map_add' := by
      intro x y
      erw [(toLocalizationMap M S).lift_spec, mul_add, mul_comm, eq_comm, lift_spec_mul_add,
        add_comm, mul_comm, mul_assoc, mul_comm, mul_assoc, lift_spec_mul_add]
      

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
src✝ : S →*₀ P :=
  Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S) (RingHom.toMonoidWithZeroHom g) hg
x y : S
⊢ g (Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).1 *
        (g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).2 *
          ↑(RingHom.toMonoidWithZeroHom g) ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).2) +
      g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).2 *
        (g (Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).1 *
          ↑(RingHom.toMonoidWithZeroHom g) ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).2) =
    g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).2 *
      (g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).2 *
        ↑(RingHom.toMonoidWithZeroHom g) (Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).1)

Next tactic:
simp_rw [← mul_assoc]
/-- Given a localization map `f : R →+* S` for a submonoid `M ⊆ R` and a map of `CommSemiring`s
`g : R →+* P` such that `g y` is invertible for all `y : M`, the homomorphism induced from
`S` to `P` sending `z : S` to `g x * (g y)⁻¹`, where `(x, y) : R × M` are such that
`z = f x * (f y)⁻¹`. -/
noncomputable def lift {g : R →+* P} (hg : ∀ y : M, IsUnit (g y)) : S →+* P :=
  { Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S)
      g.toMonoidWithZeroHom hg with
    map_add' := by
      intro x y
      erw [(toLocalizationMap M S).lift_spec, mul_add, mul_comm, eq_comm, lift_spec_mul_add,
        add_comm, mul_comm, mul_assoc, mul_comm, mul_assoc, lift_spec_mul_add]
      simp_rw [← mul_assoc]
      

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
src✝ : S →*₀ P :=
  Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S) (RingHom.toMonoidWithZeroHom g) hg
x y : S
⊢ g (Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).1 *
          g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).2 *
        ↑(RingHom.toMonoidWithZeroHom g) ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).2 +
      g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).2 *
          g (Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).1 *
        ↑(RingHom.toMonoidWithZeroHom g) ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).2 =
    g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).2 *
        g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).2 *
      ↑(RingHom.toMonoidWithZeroHom g) (Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).1

Next tactic:
show g _ * g _ * g _ + g _ * g _ * g _ = g _ * g _ * g _
/-- Given a localization map `f : R →+* S` for a submonoid `M ⊆ R` and a map of `CommSemiring`s
`g : R →+* P` such that `g y` is invertible for all `y : M`, the homomorphism induced from
`S` to `P` sending `z : S` to `g x * (g y)⁻¹`, where `(x, y) : R × M` are such that
`z = f x * (f y)⁻¹`. -/
noncomputable def lift {g : R →+* P} (hg : ∀ y : M, IsUnit (g y)) : S →+* P :=
  { Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S)
      g.toMonoidWithZeroHom hg with
    map_add' := by
      intro x y
      erw [(toLocalizationMap M S).lift_spec, mul_add, mul_comm, eq_comm, lift_spec_mul_add,
        add_comm, mul_comm, mul_assoc, mul_comm, mul_assoc, lift_spec_mul_add]
      simp_rw [← mul_assoc]
      show g _ * g _ * g _ + g _ * g _ * g _ = g _ * g _ * g _
      

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
src✝ : S →*₀ P :=
  Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S) (RingHom.toMonoidWithZeroHom g) hg
x y : S
⊢ g (Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).1 *
          g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).2 *
        g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).2 +
      g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).2 *
          g (Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).1 *
        g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).2 =
    g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).2 *
        g ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).2 *
      g (Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).1

Next tactic:
simp_rw [← map_mul g, ← map_add g]
/-- Given a localization map `f : R →+* S` for a submonoid `M ⊆ R` and a map of `CommSemiring`s
`g : R →+* P` such that `g y` is invertible for all `y : M`, the homomorphism induced from
`S` to `P` sending `z : S` to `g x * (g y)⁻¹`, where `(x, y) : R × M` are such that
`z = f x * (f y)⁻¹`. -/
noncomputable def lift {g : R →+* P} (hg : ∀ y : M, IsUnit (g y)) : S →+* P :=
  { Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S)
      g.toMonoidWithZeroHom hg with
    map_add' := by
      intro x y
      erw [(toLocalizationMap M S).lift_spec, mul_add, mul_comm, eq_comm, lift_spec_mul_add,
        add_comm, mul_comm, mul_assoc, mul_comm, mul_assoc, lift_spec_mul_add]
      simp_rw [← mul_assoc]
      show g _ * g _ * g _ + g _ * g _ * g _ = g _ * g _ * g _
      simp_rw [← map_mul g, ← map_add g]
      

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
src✝ : S →*₀ P :=
  Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S) (RingHom.toMonoidWithZeroHom g) hg
x y : S
⊢ g
      ((Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).1 *
            ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).2 *
          ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).2 +
        ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).2 *
            (Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).1 *
          ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).2) =
    g
      (↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).2 *
          ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).2 *
        (Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).1)

Next tactic:
apply eq_of_eq (S := S) hg
/-- Given a localization map `f : R →+* S` for a submonoid `M ⊆ R` and a map of `CommSemiring`s
`g : R →+* P` such that `g y` is invertible for all `y : M`, the homomorphism induced from
`S` to `P` sending `z : S` to `g x * (g y)⁻¹`, where `(x, y) : R × M` are such that
`z = f x * (f y)⁻¹`. -/
noncomputable def lift {g : R →+* P} (hg : ∀ y : M, IsUnit (g y)) : S →+* P :=
  { Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S)
      g.toMonoidWithZeroHom hg with
    map_add' := by
      intro x y
      erw [(toLocalizationMap M S).lift_spec, mul_add, mul_comm, eq_comm, lift_spec_mul_add,
        add_comm, mul_comm, mul_assoc, mul_comm, mul_assoc, lift_spec_mul_add]
      simp_rw [← mul_assoc]
      show g _ * g _ * g _ + g _ * g _ * g _ = g _ * g _ * g _
      simp_rw [← map_mul g, ← map_add g]
      apply eq_of_eq (S := S) hg
      

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
src✝ : S →*₀ P :=
  Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S) (RingHom.toMonoidWithZeroHom g) hg
x y : S
⊢ (algebraMap R S)
      ((Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).1 *
            ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).2 *
          ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).2 +
        ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).2 *
            (Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).1 *
          ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).2) =
    (algebraMap R S)
      (↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) y).2 *
          ↑(Submonoid.LocalizationMap.sec (toLocalizationMap M S) x).2 *
        (Submonoid.LocalizationMap.sec (toLocalizationMap M S) (x + y)).1)

Next tactic:
simp only [sec_spec', toLocalizationMap_sec, map_add, map_mul]
/-- Given a localization map `f : R →+* S` for a submonoid `M ⊆ R` and a map of `CommSemiring`s
`g : R →+* P` such that `g y` is invertible for all `y : M`, the homomorphism induced from
`S` to `P` sending `z : S` to `g x * (g y)⁻¹`, where `(x, y) : R × M` are such that
`z = f x * (f y)⁻¹`. -/
noncomputable def lift {g : R →+* P} (hg : ∀ y : M, IsUnit (g y)) : S →+* P :=
  { Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S)
      g.toMonoidWithZeroHom hg with
    map_add' := by
      intro x y
      erw [(toLocalizationMap M S).lift_spec, mul_add, mul_comm, eq_comm, lift_spec_mul_add,
        add_comm, mul_comm, mul_assoc, mul_comm, mul_assoc, lift_spec_mul_add]
      simp_rw [← mul_assoc]
      show g _ * g _ * g _ + g _ * g _ * g _ = g _ * g _ * g _
      simp_rw [← map_mul g, ← map_add g]
      apply eq_of_eq (S := S) hg
      simp only [sec_spec', toLocalizationMap_sec, map_add, map_mul]
      

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
src✝ : S →*₀ P :=
  Submonoid.LocalizationWithZeroMap.lift (toLocalizationWithZeroMap M S) (RingHom.toMonoidWithZeroHom g) hg
x y : S
⊢ (algebraMap R S) ↑(sec M y).2 * y * (algebraMap R S) ↑(sec M x).2 * (algebraMap R S) ↑(sec M (x + y)).2 +
      (algebraMap R S) ↑(sec M y).2 * ((algebraMap R S) ↑(sec M x).2 * x) * (algebraMap R S) ↑(sec M (x + y)).2 =
    (algebraMap R S) ↑(sec M y).2 * (algebraMap R S) ↑(sec M x).2 * ((algebraMap R S) ↑(sec M (x + y)).2 * (x + y))

Next tactic:
ring
theorem algHom_subsingleton [Algebra R P] : Subsingleton (S →ₐ[R] P) :=
  ⟨fun f g =>
    AlgHom.coe_ringHom_injective <|
      IsLocalization.ringHom_ext M <| by 

Proof state:
R : Type u_1
inst✝⁵ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝⁴ : CommSemiring S
inst✝³ : Algebra R S
P : Type u_3
inst✝² : CommSemiring P
inst✝¹ : IsLocalization M S
g✝ : R →+* P
hg : ∀ (y : ↥M), IsUnit (g✝ ↑y)
inst✝ : Algebra R P
f g : S →ₐ[R] P
⊢ RingHom.comp (↑f) (algebraMap R S) = RingHom.comp (↑g) (algebraMap R S)

Next tactic:
rw [f.comp_algebraMap, g.comp_algebraMap]
/-- To show `j` and `k` agree on the whole localization, it suffices to show they agree
on the image of the base ring, if they preserve `1` and `*`. -/
protected theorem ext (j k : S → P) (hj1 : j 1 = 1) (hk1 : k 1 = 1)
    (hjm : ∀ a b, j (a * b) = j a * j b) (hkm : ∀ a b, k (a * b) = k a * k b)
    (h : ∀ a, j (algebraMap R S a) = k (algebraMap R S a)) : j = k :=
  let j' : MonoidHom S P :=
    { toFun := j, map_one' := hj1, map_mul' := hjm }
  let k' : MonoidHom S P :=
    { toFun := k, map_one' := hk1, map_mul' := hkm }
  have : j' = k' := monoidHom_ext M (MonoidHom.ext h)
  show j'.toFun = k'.toFun by 

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
j k : S → P
hj1 : j 1 = 1
hk1 : k 1 = 1
hjm : ∀ (a b : S), j (a * b) = j a * j b
hkm : ∀ (a b : S), k (a * b) = k a * k b
h : ∀ (a : R), j ((algebraMap R S) a) = k ((algebraMap R S) a)
j' : S →* P := { toOneHom := { toFun := j, map_one' := hj1 }, map_mul' := hjm }
k' : S →* P := { toOneHom := { toFun := k, map_one' := hk1 }, map_mul' := hkm }
this : j' = k'
⊢ j'.toFun = k'.toFun

Next tactic:
rw [this]
/-- If `CommSemiring` homs `g : R →+* P, l : P →+* A` induce maps of localizations, the composition
of the induced maps equals the map of localizations induced by `l ∘ g`. -/
theorem map_map {A : Type*} [CommSemiring A] {U : Submonoid A} {W} [CommSemiring W] [Algebra A W]
    [IsLocalization U W] {l : P →+* A} (hl : T ≤ U.comap l) (x : S) :
    map W l hl (map Q g hy x) = map W (l.comp g) (fun x hx => hl (hy hx)) x := by
  

Proof state:
R : Type u_1
inst✝¹¹ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝¹⁰ : CommSemiring S
inst✝⁹ : Algebra R S
P : Type u_3
inst✝⁸ : CommSemiring P
inst✝⁷ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
T : Submonoid P
Q : Type u_4
inst✝⁶ : CommSemiring Q
hy : M ≤ Submonoid.comap g T
inst✝⁵ : Algebra P Q
inst✝⁴ : IsLocalization T Q
A : Type u_5
inst✝³ : CommSemiring A
U : Submonoid A
W : Type u_6
inst✝² : CommSemiring W
inst✝¹ : Algebra A W
inst✝ : IsLocalization U W
l : P →+* A
hl : T ≤ Submonoid.comap l U
x : S
⊢ (map W l hl) ((map Q g hy) x) = (map W (RingHom.comp l g) (_ : ∀ x ∈ M, g x ∈ Submonoid.comap l U)) x

Next tactic:
rw [← map_comp_map (Q := Q) hy hl]
/-- If `CommSemiring` homs `g : R →+* P, l : P →+* A` induce maps of localizations, the composition
of the induced maps equals the map of localizations induced by `l ∘ g`. -/
theorem map_map {A : Type*} [CommSemiring A] {U : Submonoid A} {W} [CommSemiring W] [Algebra A W]
    [IsLocalization U W] {l : P →+* A} (hl : T ≤ U.comap l) (x : S) :
    map W l hl (map Q g hy x) = map W (l.comp g) (fun x hx => hl (hy hx)) x := by
  rw [← map_comp_map (Q := Q) hy hl]; 

Proof state:
R : Type u_1
inst✝¹¹ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝¹⁰ : CommSemiring S
inst✝⁹ : Algebra R S
P : Type u_3
inst✝⁸ : CommSemiring P
inst✝⁷ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
T : Submonoid P
Q : Type u_4
inst✝⁶ : CommSemiring Q
hy : M ≤ Submonoid.comap g T
inst✝⁵ : Algebra P Q
inst✝⁴ : IsLocalization T Q
A : Type u_5
inst✝³ : CommSemiring A
U : Submonoid A
W : Type u_6
inst✝² : CommSemiring W
inst✝¹ : Algebra A W
inst✝ : IsLocalization U W
l : P →+* A
hl : T ≤ Submonoid.comap l U
x : S
⊢ (map W l hl) ((map Q g hy) x) = (RingHom.comp (map W l hl) (map Q g hy)) x

Next tactic:
rfl
theorem map_smul (x : S) (z : R) : map Q g hy (z • x : S) = g z • map Q g hy x := by
  

Proof state:
R : Type u_1
inst✝⁷ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝⁶ : CommSemiring S
inst✝⁵ : Algebra R S
P : Type u_3
inst✝⁴ : CommSemiring P
inst✝³ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
T : Submonoid P
Q : Type u_4
inst✝² : CommSemiring Q
hy : M ≤ Submonoid.comap g T
inst✝¹ : Algebra P Q
inst✝ : IsLocalization T Q
x : S
z : R
⊢ (map Q g hy) (z • x) = g z • (map Q g hy) x

Next tactic:
rw [Algebra.smul_def, Algebra.smul_def, RingHom.map_mul, map_eq]
/-- If `S`, `Q` are localizations of `R` and `P` at submonoids `M, T` respectively, an
isomorphism `j : R ≃+* P` such that `j(M) = T` induces an isomorphism of localizations
`S ≃+* Q`. -/
@[simps]
noncomputable def ringEquivOfRingEquiv (h : R ≃+* P) (H : M.map h.toMonoidHom = T) : S ≃+* Q :=
  have H' : T.map h.symm.toMonoidHom = M := by
    

Proof state:
R : Type u_1
inst✝⁷ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝⁶ : CommSemiring S
inst✝⁵ : Algebra R S
P : Type u_3
inst✝⁴ : CommSemiring P
inst✝³ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
T : Submonoid P
Q : Type u_4
inst✝² : CommSemiring Q
hy : M ≤ Submonoid.comap g T
inst✝¹ : Algebra P Q
inst✝ : IsLocalization T Q
h : R ≃+* P
H : Submonoid.map (RingEquiv.toMonoidHom h) M = T
⊢ Submonoid.map (RingEquiv.toMonoidHom (RingEquiv.symm h)) T = M

Next tactic:
rw [← M.map_id, ← H, Submonoid.map_map]
/-- If `S`, `Q` are localizations of `R` and `P` at submonoids `M, T` respectively, an
isomorphism `j : R ≃+* P` such that `j(M) = T` induces an isomorphism of localizations
`S ≃+* Q`. -/
@[simps]
noncomputable def ringEquivOfRingEquiv (h : R ≃+* P) (H : M.map h.toMonoidHom = T) : S ≃+* Q :=
  have H' : T.map h.symm.toMonoidHom = M := by
    rw [← M.map_id, ← H, Submonoid.map_map]
    

Proof state:
R : Type u_1
inst✝⁷ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝⁶ : CommSemiring S
inst✝⁵ : Algebra R S
P : Type u_3
inst✝⁴ : CommSemiring P
inst✝³ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
T : Submonoid P
Q : Type u_4
inst✝² : CommSemiring Q
hy : M ≤ Submonoid.comap g T
inst✝¹ : Algebra P Q
inst✝ : IsLocalization T Q
h : R ≃+* P
H : Submonoid.map (RingEquiv.toMonoidHom h) M = T
⊢ Submonoid.map (MonoidHom.comp (RingEquiv.toMonoidHom (RingEquiv.symm h)) (RingEquiv.toMonoidHom h)) M =
    Submonoid.map (MonoidHom.id R) M

Next tactic:
congr
/-- If `S`, `Q` are localizations of `R` and `P` at submonoids `M, T` respectively, an
isomorphism `j : R ≃+* P` such that `j(M) = T` induces an isomorphism of localizations
`S ≃+* Q`. -/
@[simps]
noncomputable def ringEquivOfRingEquiv (h : R ≃+* P) (H : M.map h.toMonoidHom = T) : S ≃+* Q :=
  have H' : T.map h.symm.toMonoidHom = M := by
    rw [← M.map_id, ← H, Submonoid.map_map]
    congr
    

Proof state:
case e_f
R : Type u_1
inst✝⁷ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝⁶ : CommSemiring S
inst✝⁵ : Algebra R S
P : Type u_3
inst✝⁴ : CommSemiring P
inst✝³ : IsLocalization M S
g : R →+* P
hg : ∀ (y : ↥M), IsUnit (g ↑y)
T : Submonoid P
Q : Type u_4
inst✝² : CommSemiring Q
hy : M ≤ Submonoid.comap g T
inst✝¹ : Algebra P Q
inst✝ : IsLocalization T Q
h : R ≃+* P
H : Submonoid.map (RingEquiv.toMonoidHom h) M = T
⊢ MonoidHom.comp (RingEquiv.toMonoidHom (RingEquiv.symm h)) (RingEquiv.toMonoidHom h) = MonoidHom.id R

Next tactic:
ext