-- 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:
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_1 : CommRing S] [inst_2 : CommRing T] [inst_3 : Algebra R S]
    [inst_4 : Algebra R T],
    Locally (fun {R S} [CommRing R] [CommRing S] => P) (algebraMap R T) →
      Locally (fun {R S} [CommRing R] [CommRing S] => P) Algebra.TensorProduct.includeLeftRingHom

Tactic:
introv hf

Result:
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
hf : Locally (fun {R S} [CommRing R] [CommRing S] => P) (algebraMap R T)
⊢ Locally (fun {R S} [CommRing R] [CommRing S] => P) 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
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)

Tactic:
haveI (a : s) : IsScalarTower T (Localization.Away a.val) (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)
this : ∀ (a : ↑s), IsScalarTower T (Localization.Away ↑a) (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.refine_3
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
⊢ P ((algebraMap (S ⊗[R] T) ((fun a => S ⊗[R] Localization.Away ↑a) a)).comp Algebra.TensorProduct.includeLeftRingHom)

Tactic:
have : (algebraMap (S ⊗[R] T) (S ⊗[R] Localization.Away a.val)).comp
    Algebra.TensorProduct.includeLeftRingHom =
    Algebra.TensorProduct.includeLeftRingHom := by
  ext x
  simp [RingHom.algebraMap_toAlgebra]

Result:
case intro.intro.refine_3
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
this :
  (algebraMap (S ⊗[R] T) (S ⊗[R] Localization.Away ↑a)).comp Algebra.TensorProduct.includeLeftRingHom =
    Algebra.TensorProduct.includeLeftRingHom
⊢ P ((algebraMap (S ⊗[R] T) ((fun a => S ⊗[R] Localization.Away ↑a) a)).comp Algebra.TensorProduct.includeLeftRingHom)