-- Mathlib/AlgebraicGeometry/Morphisms/Constructors.lean
/-- If `P` respects isos, then `stalkwise P` is local at the target. -/
lemma stalkwiseIsLocalAtTarget_of_respectsIso (hP : RingHom.RespectsIso P) :
    IsLocalAtTarget (stalkwise P)

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hP' : (RingHom.toMorphismProperty fun {R S} [CommRing R] [CommRing S] => P).RespectsIso
this : (stalkwise fun {R S} [CommRing R] [CommRing S] => P).RespectsIso := stalkwise_respectsIso hP
X Y : Scheme
f : X ⟶ Y
ι : Type u
U : ι → Y.Opens
hU : iSup U = ⊤
hf : ∀ (i : ι), stalkwise (fun {R S} [CommRing R] [CommRing S] => P) (f ∣_ U i)
x : ↑↑X.toPresheafedSpace
⊢ (ConcreteCategory.hom f.base) x ∈ ⊤

Tactic:
trivial

Result:
no goals

Proof state:
case restrict
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hP' : (RingHom.toMorphismProperty fun {R S} [CommRing R] [CommRing S] => P).RespectsIso
this : (stalkwise fun {R S} [CommRing R] [CommRing S] => P).RespectsIso := stalkwise_respectsIso hP
X Y : Scheme
f : X ⟶ Y
U : Y.Opens
hf : stalkwise (fun {R S} [CommRing R] [CommRing S] => P) f
x : ↑↑(↑(f ⁻¹ᵁ U)).toPresheafedSpace
⊢ P (CommRingCat.Hom.hom (Scheme.Hom.stalkMap (f ∣_ U) x))

Tactic:
apply ((RingHom.toMorphismProperty P).arrow_mk_iso_iff <|
  morphismRestrictStalkMap f U x).mpr <| hf _

Result:
no goals

Proof state:
case of_sSup_eq_top.intro
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hP' : (RingHom.toMorphismProperty fun {R S} [CommRing R] [CommRing S] => P).RespectsIso
this : (stalkwise fun {R S} [CommRing R] [CommRing S] => P).RespectsIso := stalkwise_respectsIso hP
X Y : Scheme
f : X ⟶ Y
ι : Type u
U : ι → Y.Opens
hU : iSup U = ⊤
hf : ∀ (i : ι), stalkwise (fun {R S} [CommRing R] [CommRing S] => P) (f ∣_ U i)
x : ↑↑X.toPresheafedSpace
hy : (ConcreteCategory.hom f.base) x ∈ iSup U
i : ι
hi : (ConcreteCategory.hom f.base) x ∈ U i
⊢ P (CommRingCat.Hom.hom (Scheme.Hom.stalkMap f x))

Tactic:
exact ((RingHom.toMorphismProperty P).arrow_mk_iso_iff <|
  morphismRestrictStalkMap f (U i) ⟨x, hi⟩).mp <| hf i ⟨x, hi⟩

Result:
no goals

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hP' : (RingHom.toMorphismProperty fun {R S} [CommRing R] [CommRing S] => P).RespectsIso
⊢ IsLocalAtTarget (stalkwise fun {R S} [CommRing R] [CommRing S] => P)

Tactic:
letI := stalkwise_respectsIso hP

Result:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hP' : (RingHom.toMorphismProperty fun {R S} [CommRing R] [CommRing S] => P).RespectsIso
this : (stalkwise fun {R S} [CommRing R] [CommRing S] => P).RespectsIso := stalkwise_respectsIso hP
⊢ IsLocalAtTarget (stalkwise fun {R S} [CommRing R] [CommRing S] => P)

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hP' : (RingHom.toMorphismProperty fun {R S} [CommRing R] [CommRing S] => P).RespectsIso
this : (stalkwise fun {R S} [CommRing R] [CommRing S] => P).RespectsIso := stalkwise_respectsIso hP
X Y : Scheme
f : X ⟶ Y
ι : Type u
U : ι → Y.Opens
hU : iSup U = ⊤
hf : ∀ (i : ι), stalkwise (fun {R S} [CommRing R] [CommRing S] => P) (f ∣_ U i)
x : ↑↑X.toPresheafedSpace
⊢ (ConcreteCategory.hom f.base) x ∈ iSup U

Tactic:
rw [hU]

Result:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hP' : (RingHom.toMorphismProperty fun {R S} [CommRing R] [CommRing S] => P).RespectsIso
this : (stalkwise fun {R S} [CommRing R] [CommRing S] => P).RespectsIso := stalkwise_respectsIso hP
X Y : Scheme
f : X ⟶ Y
ι : Type u
U : ι → Y.Opens
hU : iSup U = ⊤
hf : ∀ (i : ι), stalkwise (fun {R S} [CommRing R] [CommRing S] => P) (f ∣_ U i)
x : ↑↑X.toPresheafedSpace
⊢ (ConcreteCategory.hom f.base) x ∈ ⊤

Proof state:
case of_sSup_eq_top
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hP' : (RingHom.toMorphismProperty fun {R S} [CommRing R] [CommRing S] => P).RespectsIso
this : (stalkwise fun {R S} [CommRing R] [CommRing S] => P).RespectsIso := stalkwise_respectsIso hP
X Y : Scheme
f : X ⟶ Y
ι : Type u
U : ι → Y.Opens
hU : iSup U = ⊤
hf : ∀ (i : ι), stalkwise (fun {R S} [CommRing R] [CommRing S] => P) (f ∣_ U i)
x : ↑↑X.toPresheafedSpace
⊢ P (CommRingCat.Hom.hom (Scheme.Hom.stalkMap f x))

Tactic:
have hy : f.base x ∈ iSup U := by rw [hU]; trivial

Result:
case of_sSup_eq_top
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hP' : (RingHom.toMorphismProperty fun {R S} [CommRing R] [CommRing S] => P).RespectsIso
this : (stalkwise fun {R S} [CommRing R] [CommRing S] => P).RespectsIso := stalkwise_respectsIso hP
X Y : Scheme
f : X ⟶ Y
ι : Type u
U : ι → Y.Opens
hU : iSup U = ⊤
hf : ∀ (i : ι), stalkwise (fun {R S} [CommRing R] [CommRing S] => P) (f ∣_ U i)
x : ↑↑X.toPresheafedSpace
hy : (ConcreteCategory.hom f.base) x ∈ iSup U
⊢ P (CommRingCat.Hom.hom (Scheme.Hom.stalkMap f x))

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hP' : (RingHom.toMorphismProperty fun {R S} [CommRing R] [CommRing S] => P).RespectsIso
this : (stalkwise fun {R S} [CommRing R] [CommRing S] => P).RespectsIso := stalkwise_respectsIso hP
⊢ IsLocalAtTarget (stalkwise fun {R S} [CommRing R] [CommRing S] => P)

Tactic:
apply IsLocalAtTarget.mk'

Result:
case restrict
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hP' : (RingHom.toMorphismProperty fun {R S} [CommRing R] [CommRing S] => P).RespectsIso
this : (stalkwise fun {R S} [CommRing R] [CommRing S] => P).RespectsIso := stalkwise_respectsIso hP
⊢ ∀ {X Y : Scheme} (f : X ⟶ Y) (U : Y.Opens),
    stalkwise (fun {R S} [CommRing R] [CommRing S] => P) f →
      stalkwise (fun {R S} [CommRing R] [CommRing S] => P) (f ∣_ U)

case of_sSup_eq_top
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.RespectsIso fun {R S} [CommRing R] [CommRing S] => P
hP' : (RingHom.toMorphismProperty fun {R S} [CommRing R] [CommRing S] => P).RespectsIso
this : (stalkwise fun {R S} [CommRing R] [CommRing S] => P).RespectsIso := stalkwise_respectsIso hP
⊢ ∀ {X Y : Scheme} (f : X ⟶ Y) {ι : Type u} (U : ι → Y.Opens),
    iSup U = ⊤ →
      (∀ (i : ι), stalkwise (fun {R S} [CommRing R] [CommRing S] => P) (f ∣_ U i)) →
        stalkwise (fun {R S} [CommRing R] [CommRing S] => P) f