-- Mathlib/RingTheory/RingHom/Locally.lean
/-- If `P` is stable under base change, then so is `Locally P`. -/
lemma locally_isStableUnderBaseChange (hPi : RespectsIso P) (hPb : IsStableUnderBaseChange P) :
    IsStableUnderBaseChange (Locally P)

Proof state:
case intro.intro
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hPi : RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hPb : IsStableUnderBaseChange fun {R S} [CommRing R] [CommRing S] => P
R S T : Type u
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing T
inst✝¹ : Algebra R S
inst✝ : Algebra R T
s : Set T
hsone : Ideal.span s = ⊤
hs : ∀ t ∈ s, (fun {R S} [CommRing R] [CommRing S] => P) ((algebraMap T (Localization.Away t)).comp (algebraMap R T))
this✝ : (a : ↑s) → Algebra (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a) :=
  fun a => (Algebra.TensorProduct.map (AlgHom.id R S) (IsScalarTower.toAlgHom R T (Localization.Away ↑a))).toAlgebra
this : (a : ↑s) → Algebra T (S ⊗[R] Localization.Away ↑a) :=
  fun a => ((algebraMap (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)).comp (algebraMap T (S ⊗[R] T))).toAlgebra
⊢ ∃ ι s,
    ∃ (_ : Ideal.span (Set.range s) = ⊤),
      ∃ Sₜ x x_1,
        ∃ (_ : ∀ (i : ι), IsLocalization.Away (s i) (Sₜ i)),
          ∀ (i : ι), P ((algebraMap (S ⊗[R] T) (Sₜ i)).comp Algebra.TensorProduct.includeLeftRingHom)

Tactic:
haveI (a : s) : IsScalarTower T (S ⊗[R] T) (S ⊗[R] Localization.Away a.val) :=
  IsScalarTower.of_algebraMap_eq' rfl

Result:
case intro.intro
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hPi : RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hPb : IsStableUnderBaseChange fun {R S} [CommRing R] [CommRing S] => P
R S T : Type u
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing T
inst✝¹ : Algebra R S
inst✝ : Algebra R T
s : Set T
hsone : Ideal.span s = ⊤
hs : ∀ t ∈ s, (fun {R S} [CommRing R] [CommRing S] => P) ((algebraMap T (Localization.Away t)).comp (algebraMap R T))
this✝¹ : (a : ↑s) → Algebra (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a) :=
  fun a => (Algebra.TensorProduct.map (AlgHom.id R S) (IsScalarTower.toAlgHom R T (Localization.Away ↑a))).toAlgebra
this✝ : (a : ↑s) → Algebra T (S ⊗[R] Localization.Away ↑a) :=
  fun a => ((algebraMap (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)).comp (algebraMap T (S ⊗[R] T))).toAlgebra
this : ∀ (a : ↑s), IsScalarTower T (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)
⊢ ∃ ι s,
    ∃ (_ : Ideal.span (Set.range s) = ⊤),
      ∃ Sₜ x x_1,
        ∃ (_ : ∀ (i : ι), IsLocalization.Away (s i) (Sₜ i)),
          ∀ (i : ι), P ((algebraMap (S ⊗[R] T) (Sₜ i)).comp Algebra.TensorProduct.includeLeftRingHom)

Proof state:
case intro.intro
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hPi : RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hPb : IsStableUnderBaseChange fun {R S} [CommRing R] [CommRing S] => P
R S T : Type u
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing T
inst✝¹ : Algebra R S
inst✝ : Algebra R T
s : Set T
hsone : Ideal.span s = ⊤
hs : ∀ t ∈ s, (fun {R S} [CommRing R] [CommRing S] => P) ((algebraMap T (Localization.Away t)).comp (algebraMap R T))
this : (a : ↑s) → Algebra (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a) :=
  fun a => (Algebra.TensorProduct.map (AlgHom.id R S) (IsScalarTower.toAlgHom R T (Localization.Away ↑a))).toAlgebra
⊢ ∃ ι s,
    ∃ (_ : Ideal.span (Set.range s) = ⊤),
      ∃ Sₜ x x_1,
        ∃ (_ : ∀ (i : ι), IsLocalization.Away (s i) (Sₜ i)),
          ∀ (i : ι), P ((algebraMap (S ⊗[R] T) (Sₜ i)).comp Algebra.TensorProduct.includeLeftRingHom)

Tactic:
letI (a : s) : Algebra T (S ⊗[R] Localization.Away a.val) :=
  ((algebraMap _ (S ⊗[R] Localization.Away a.val)).comp (algebraMap T (S ⊗[R] T))).toAlgebra

Result:
case intro.intro
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hPi : RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hPb : IsStableUnderBaseChange fun {R S} [CommRing R] [CommRing S] => P
R S T : Type u
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing T
inst✝¹ : Algebra R S
inst✝ : Algebra R T
s : Set T
hsone : Ideal.span s = ⊤
hs : ∀ t ∈ s, (fun {R S} [CommRing R] [CommRing S] => P) ((algebraMap T (Localization.Away t)).comp (algebraMap R T))
this✝ : (a : ↑s) → Algebra (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a) :=
  fun a => (Algebra.TensorProduct.map (AlgHom.id R S) (IsScalarTower.toAlgHom R T (Localization.Away ↑a))).toAlgebra
this : (a : ↑s) → Algebra T (S ⊗[R] Localization.Away ↑a) :=
  fun a => ((algebraMap (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)).comp (algebraMap T (S ⊗[R] T))).toAlgebra
⊢ ∃ ι s,
    ∃ (_ : Ideal.span (Set.range s) = ⊤),
      ∃ Sₜ x x_1,
        ∃ (_ : ∀ (i : ι), IsLocalization.Away (s i) (Sₜ i)),
          ∀ (i : ι), P ((algebraMap (S ⊗[R] T) (Sₜ i)).comp Algebra.TensorProduct.includeLeftRingHom)

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hPi : RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hPb : IsStableUnderBaseChange fun {R S} [CommRing R] [CommRing S] => P
R S T : Type u
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing T
inst✝¹ : Algebra R S
inst✝ : Algebra R T
s : Set T
hsone : Ideal.span s = ⊤
hs : ∀ t ∈ s, (fun {R S} [CommRing R] [CommRing S] => P) ((algebraMap T (Localization.Away t)).comp (algebraMap R T))
this✝⁴ : (a : ↑s) → Algebra (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a) :=
  fun a => (Algebra.TensorProduct.map (AlgHom.id R S) (IsScalarTower.toAlgHom R T (Localization.Away ↑a))).toAlgebra
this✝³ : (a : ↑s) → Algebra T (S ⊗[R] Localization.Away ↑a) :=
  fun a => ((algebraMap (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)).comp (algebraMap T (S ⊗[R] T))).toAlgebra
this✝² : ∀ (a : ↑s), IsScalarTower T (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)
this✝¹ : ∀ (a : ↑s), IsScalarTower T (Localization.Away ↑a) (S ⊗[R] Localization.Away ↑a)
this✝ : ∀ (a : ↑s), IsScalarTower S (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)
this : ∀ (a : ↑s), Algebra.IsPushout T (Localization.Away ↑a) (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)
a : ↑s
⊢ (algebraMap (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)).comp Algebra.TensorProduct.includeLeftRingHom =
    Algebra.TensorProduct.includeLeftRingHom

Tactic:
ext x

Result:
case a
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hPi : RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hPb : IsStableUnderBaseChange fun {R S} [CommRing R] [CommRing S] => P
R S T : Type u
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing T
inst✝¹ : Algebra R S
inst✝ : Algebra R T
s : Set T
hsone : Ideal.span s = ⊤
hs : ∀ t ∈ s, (fun {R S} [CommRing R] [CommRing S] => P) ((algebraMap T (Localization.Away t)).comp (algebraMap R T))
this✝⁴ : (a : ↑s) → Algebra (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a) :=
  fun a => (Algebra.TensorProduct.map (AlgHom.id R S) (IsScalarTower.toAlgHom R T (Localization.Away ↑a))).toAlgebra
this✝³ : (a : ↑s) → Algebra T (S ⊗[R] Localization.Away ↑a) :=
  fun a => ((algebraMap (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)).comp (algebraMap T (S ⊗[R] T))).toAlgebra
this✝² : ∀ (a : ↑s), IsScalarTower T (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)
this✝¹ : ∀ (a : ↑s), IsScalarTower T (Localization.Away ↑a) (S ⊗[R] Localization.Away ↑a)
this✝ : ∀ (a : ↑s), IsScalarTower S (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)
this : ∀ (a : ↑s), Algebra.IsPushout T (Localization.Away ↑a) (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)
a : ↑s
x : S
⊢ ((algebraMap (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)).comp Algebra.TensorProduct.includeLeftRingHom) x =
    Algebra.TensorProduct.includeLeftRingHom x