l3lab/ntp-mathlib huggingface dataset:
theorem diagonalTargetAffineLocallyOfOpenCover (P : AffineTargetMorphismProperty) (hP : P.IsLocal)
    {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)]
    (𝒰' : ∀ i, Scheme.OpenCover.{u} (pullback f (𝒰.map i))) [∀ i j, IsAffine ((𝒰' i).obj j)]
    (h𝒰' : ∀ i j k, P (pullback.mapDesc ((𝒰' i).map j) ((𝒰' i).map k) pullback.snd)) :
    (targetAffineLocally P).diagonal f := by
  let 𝒱 := (Scheme.Pullback.openCoverOfBase 𝒰 f f).bind fun i =>
    Scheme.Pullback.openCoverOfLeftRight.{u} (𝒰' i) (𝒰' i) pullback.snd pullback.snd
  have i1 : ∀ i, IsAffine (𝒱.obj i) := fun i => by dsimp; infer_instance
  refine' (hP.affine_openCover_iff _ _).mpr _
  rintro ⟨i, j, k⟩
  dsimp
  convert (affine_cancel_left_isIso hP.1
    (pullbackDiagonalMapIso _ _ ((𝒰' i).map j) ((𝒰' i).map k)).inv pullback.snd).mp _
  pick_goal 3
  · convert h𝒰' i j k; 

Proof state:
case h.e'_3
P : AffineTargetMorphismProperty
hP : AffineTargetMorphismProperty.IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
inst✝¹ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
𝒰' : (i : 𝒰.J) → Scheme.OpenCover (pullback f (Scheme.OpenCover.map 𝒰 i))
inst✝ : ∀ (i : 𝒰.J) (j : (𝒰' i).J), IsAffine (Scheme.OpenCover.obj (𝒰' i) j)
h𝒰' :
  ∀ (i : 𝒰.J) (j k : (𝒰' i).J),
    P (pullback.mapDesc (Scheme.OpenCover.map (𝒰' i) j) (Scheme.OpenCover.map (𝒰' i) k) pullback.snd)
𝒱 : Scheme.OpenCover (pullback f f) :=
  Scheme.OpenCover.bind (Scheme.Pullback.openCoverOfBase 𝒰 f f) fun i =>
    Scheme.Pullback.openCoverOfLeftRight (𝒰' i) (𝒰' i) pullback.snd pullback.snd
i1 : ∀ (i : 𝒱.J), IsAffine (Scheme.OpenCover.obj 𝒱 i)
i : (Scheme.Pullback.openCoverOfBase 𝒰 f f).J
j k : (𝒰' i).J
⊢ (pullbackDiagonalMapIso f (Scheme.OpenCover.map 𝒰 i) (Scheme.OpenCover.map (𝒰' i) j)
          (Scheme.OpenCover.map (𝒰' i) k)).inv ≫
      pullback.snd =
    pullback.mapDesc (Scheme.OpenCover.map (𝒰' i) j) (Scheme.OpenCover.map (𝒰' i) k) pullback.snd

Next tactic:
apply pullback.hom_ext
theorem diagonalTargetAffineLocallyOfOpenCover (P : AffineTargetMorphismProperty) (hP : P.IsLocal)
    {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)]
    (𝒰' : ∀ i, Scheme.OpenCover.{u} (pullback f (𝒰.map i))) [∀ i j, IsAffine ((𝒰' i).obj j)]
    (h𝒰' : ∀ i j k, P (pullback.mapDesc ((𝒰' i).map j) ((𝒰' i).map k) pullback.snd)) :
    (targetAffineLocally P).diagonal f := by
  let 𝒱 := (Scheme.Pullback.openCoverOfBase 𝒰 f f).bind fun i =>
    Scheme.Pullback.openCoverOfLeftRight.{u} (𝒰' i) (𝒰' i) pullback.snd pullback.snd
  have i1 : ∀ i, IsAffine (𝒱.obj i) := fun i => by dsimp; infer_instance
  refine' (hP.affine_openCover_iff _ _).mpr _
  rintro ⟨i, j, k⟩
  dsimp
  convert (affine_cancel_left_isIso hP.1
    (pullbackDiagonalMapIso _ _ ((𝒰' i).map j) ((𝒰' i).map k)).inv pullback.snd).mp _
  pick_goal 3
  · convert h𝒰' i j k; apply pullback.hom_ext <;> 

Proof state:
case h.e'_3.h₀
P : AffineTargetMorphismProperty
hP : AffineTargetMorphismProperty.IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
inst✝¹ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
𝒰' : (i : 𝒰.J) → Scheme.OpenCover (pullback f (Scheme.OpenCover.map 𝒰 i))
inst✝ : ∀ (i : 𝒰.J) (j : (𝒰' i).J), IsAffine (Scheme.OpenCover.obj (𝒰' i) j)
h𝒰' :
  ∀ (i : 𝒰.J) (j k : (𝒰' i).J),
    P (pullback.mapDesc (Scheme.OpenCover.map (𝒰' i) j) (Scheme.OpenCover.map (𝒰' i) k) pullback.snd)
𝒱 : Scheme.OpenCover (pullback f f) :=
  Scheme.OpenCover.bind (Scheme.Pullback.openCoverOfBase 𝒰 f f) fun i =>
    Scheme.Pullback.openCoverOfLeftRight (𝒰' i) (𝒰' i) pullback.snd pullback.snd
i1 : ∀ (i : 𝒱.J), IsAffine (Scheme.OpenCover.obj 𝒱 i)
i : (Scheme.Pullback.openCoverOfBase 𝒰 f f).J
j k : (𝒰' i).J
⊢ ((pullbackDiagonalMapIso f (Scheme.OpenCover.map 𝒰 i) (Scheme.OpenCover.map (𝒰' i) j)
            (Scheme.OpenCover.map (𝒰' i) k)).inv ≫
        pullback.snd) ≫
      pullback.fst =
    pullback.mapDesc (Scheme.OpenCover.map (𝒰' i) j) (Scheme.OpenCover.map (𝒰' i) k) pullback.snd ≫ pullback.fst

Next tactic:
simp
theorem diagonalTargetAffineLocallyOfOpenCover (P : AffineTargetMorphismProperty) (hP : P.IsLocal)
    {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)]
    (𝒰' : ∀ i, Scheme.OpenCover.{u} (pullback f (𝒰.map i))) [∀ i j, IsAffine ((𝒰' i).obj j)]
    (h𝒰' : ∀ i j k, P (pullback.mapDesc ((𝒰' i).map j) ((𝒰' i).map k) pullback.snd)) :
    (targetAffineLocally P).diagonal f := by
  let 𝒱 := (Scheme.Pullback.openCoverOfBase 𝒰 f f).bind fun i =>
    Scheme.Pullback.openCoverOfLeftRight.{u} (𝒰' i) (𝒰' i) pullback.snd pullback.snd
  have i1 : ∀ i, IsAffine (𝒱.obj i) := fun i => by dsimp; infer_instance
  refine' (hP.affine_openCover_iff _ _).mpr _
  rintro ⟨i, j, k⟩
  dsimp
  convert (affine_cancel_left_isIso hP.1
    (pullbackDiagonalMapIso _ _ ((𝒰' i).map j) ((𝒰' i).map k)).inv pullback.snd).mp _
  pick_goal 3
  · convert h𝒰' i j k; apply pullback.hom_ext <;> 

Proof state:
case h.e'_3.h₁
P : AffineTargetMorphismProperty
hP : AffineTargetMorphismProperty.IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
inst✝¹ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
𝒰' : (i : 𝒰.J) → Scheme.OpenCover (pullback f (Scheme.OpenCover.map 𝒰 i))
inst✝ : ∀ (i : 𝒰.J) (j : (𝒰' i).J), IsAffine (Scheme.OpenCover.obj (𝒰' i) j)
h𝒰' :
  ∀ (i : 𝒰.J) (j k : (𝒰' i).J),
    P (pullback.mapDesc (Scheme.OpenCover.map (𝒰' i) j) (Scheme.OpenCover.map (𝒰' i) k) pullback.snd)
𝒱 : Scheme.OpenCover (pullback f f) :=
  Scheme.OpenCover.bind (Scheme.Pullback.openCoverOfBase 𝒰 f f) fun i =>
    Scheme.Pullback.openCoverOfLeftRight (𝒰' i) (𝒰' i) pullback.snd pullback.snd
i1 : ∀ (i : 𝒱.J), IsAffine (Scheme.OpenCover.obj 𝒱 i)
i : (Scheme.Pullback.openCoverOfBase 𝒰 f f).J
j k : (𝒰' i).J
⊢ ((pullbackDiagonalMapIso f (Scheme.OpenCover.map 𝒰 i) (Scheme.OpenCover.map (𝒰' i) j)
            (Scheme.OpenCover.map (𝒰' i) k)).inv ≫
        pullback.snd) ≫
      pullback.snd =
    pullback.mapDesc (Scheme.OpenCover.map (𝒰' i) j) (Scheme.OpenCover.map (𝒰' i) k) pullback.snd ≫ pullback.snd

Next tactic:
simp
theorem diagonalTargetAffineLocallyOfOpenCover (P : AffineTargetMorphismProperty) (hP : P.IsLocal)
    {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)]
    (𝒰' : ∀ i, Scheme.OpenCover.{u} (pullback f (𝒰.map i))) [∀ i j, IsAffine ((𝒰' i).obj j)]
    (h𝒰' : ∀ i j k, P (pullback.mapDesc ((𝒰' i).map j) ((𝒰' i).map k) pullback.snd)) :
    (targetAffineLocally P).diagonal f := by
  let 𝒱 := (Scheme.Pullback.openCoverOfBase 𝒰 f f).bind fun i =>
    Scheme.Pullback.openCoverOfLeftRight.{u} (𝒰' i) (𝒰' i) pullback.snd pullback.snd
  have i1 : ∀ i, IsAffine (𝒱.obj i) := fun i => by dsimp; infer_instance
  refine' (hP.affine_openCover_iff _ _).mpr _
  rintro ⟨i, j, k⟩
  dsimp
  convert (affine_cancel_left_isIso hP.1
    (pullbackDiagonalMapIso _ _ ((𝒰' i).map j) ((𝒰' i).map k)).inv pullback.snd).mp _
  pick_goal 3
  · convert h𝒰' i j k; apply pullback.hom_ext <;> simp
  all_goals 

Proof state:
case h.e'_1.h.e'_7
P : AffineTargetMorphismProperty
hP : AffineTargetMorphismProperty.IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
inst✝¹ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
𝒰' : (i : 𝒰.J) → Scheme.OpenCover (pullback f (Scheme.OpenCover.map 𝒰 i))
inst✝ : ∀ (i : 𝒰.J) (j : (𝒰' i).J), IsAffine (Scheme.OpenCover.obj (𝒰' i) j)
h𝒰' :
  ∀ (i : 𝒰.J) (j k : (𝒰' i).J),
    P (pullback.mapDesc (Scheme.OpenCover.map (𝒰' i) j) (Scheme.OpenCover.map (𝒰' i) k) pullback.snd)
𝒱 : Scheme.OpenCover (pullback f f) :=
  Scheme.OpenCover.bind (Scheme.Pullback.openCoverOfBase 𝒰 f f) fun i =>
    Scheme.Pullback.openCoverOfLeftRight (𝒰' i) (𝒰' i) pullback.snd pullback.snd
i1 : ∀ (i : 𝒱.J), IsAffine (Scheme.OpenCover.obj 𝒱 i)
i : (Scheme.Pullback.openCoverOfBase 𝒰 f f).J
j k : (𝒰' i).J
⊢ pullback.map (Scheme.OpenCover.map (𝒰' i) j ≫ pullback.snd) (Scheme.OpenCover.map (𝒰' i) k ≫ pullback.snd)
        pullback.snd pullback.snd (Scheme.OpenCover.map (𝒰' i) j) (Scheme.OpenCover.map (𝒰' i) k)
        (𝟙 (Scheme.OpenCover.obj 𝒰 i))
        (_ :
          (Scheme.OpenCover.map (𝒰' i) (j, k).1 ≫ pullback.snd) ≫ 𝟙 (Scheme.OpenCover.obj 𝒰 i) =
            Scheme.OpenCover.map (𝒰' i) (j, k).1 ≫ pullback.snd)
        (_ :
          (Scheme.OpenCover.map (𝒰' i) (j, k).2 ≫ pullback.snd) ≫ 𝟙 (Scheme.OpenCover.obj 𝒰 i) =
            Scheme.OpenCover.map (𝒰' i) (j, k).2 ≫ pullback.snd) ≫
      pullback.map pullback.snd pullback.snd f f pullback.fst pullback.fst (Scheme.OpenCover.map 𝒰 i)
        (_ : pullback.snd ≫ Scheme.OpenCover.map 𝒰 i = pullback.fst ≫ f)
        (_ : pullback.snd ≫ Scheme.OpenCover.map 𝒰 i = pullback.fst ≫ f) =
    pullback.map (Scheme.OpenCover.map (𝒰' i) j ≫ pullback.snd) (Scheme.OpenCover.map (𝒰' i) k ≫ pullback.snd) f f
      (Scheme.OpenCover.map (𝒰' i) j ≫ pullback.fst) (Scheme.OpenCover.map (𝒰' i) k ≫ pullback.fst)
      (Scheme.OpenCover.map 𝒰 i)
      (_ :
        (Scheme.OpenCover.map (𝒰' i) j ≫ pullback.snd) ≫ Scheme.OpenCover.map 𝒰 i =
          (Scheme.OpenCover.map (𝒰' i) j ≫ pullback.fst) ≫ f)
      (_ :
        (Scheme.OpenCover.map (𝒰' i) k ≫ pullback.snd) ≫ Scheme.OpenCover.map 𝒰 i =
          (Scheme.OpenCover.map (𝒰' i) k ≫ pullback.fst) ≫ f)

Next tactic:
apply pullback.hom_ext
theorem AffineTargetMorphismProperty.diagonalOfTargetAffineLocally
    (P : AffineTargetMorphismProperty) (hP : P.IsLocal) {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y)
    [IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :
    P.diagonal (pullback.snd : pullback f g ⟶ _) := by
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y U : Scheme
f : X ⟶ Y
g : U ⟶ Y
inst✝¹ : IsAffine U
inst✝ : IsOpenImmersion g
H : MorphismProperty.diagonal (targetAffineLocally P) f
⊢ diagonal P pullback.snd

Next tactic:
rintro U V f₁ f₂ hU hV hf₁ hf₂
theorem AffineTargetMorphismProperty.diagonalOfTargetAffineLocally
    (P : AffineTargetMorphismProperty) (hP : P.IsLocal) {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y)
    [IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :
    P.diagonal (pullback.snd : pullback f g ⟶ _) := by
  rintro U V f₁ f₂ hU hV hf₁ hf₂
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y U✝ : Scheme
f : X ⟶ Y
g : U✝ ⟶ Y
inst✝¹ : IsAffine U✝
inst✝ : IsOpenImmersion g
H : MorphismProperty.diagonal (targetAffineLocally P) f
U V : Scheme
f₁ : U ⟶ pullback f g
f₂ : V ⟶ pullback f g
hU : IsAffine U
hV : IsAffine V
hf₁ : IsOpenImmersion f₁
hf₂ : IsOpenImmersion f₂
⊢ P (pullback.mapDesc f₁ f₂ pullback.snd)

Next tactic:
replace H := ((hP.affine_openCover_TFAE (pullback.diagonal f)).out 0 3).mp H
theorem AffineTargetMorphismProperty.diagonalOfTargetAffineLocally
    (P : AffineTargetMorphismProperty) (hP : P.IsLocal) {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y)
    [IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :
    P.diagonal (pullback.snd : pullback f g ⟶ _) := by
  rintro U V f₁ f₂ hU hV hf₁ hf₂
  replace H := ((hP.affine_openCover_TFAE (pullback.diagonal f)).out 0 3).mp H
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y U✝ : Scheme
f : X ⟶ Y
g : U✝ ⟶ Y
inst✝¹ : IsAffine U✝
inst✝ : IsOpenImmersion g
U V : Scheme
f₁ : U ⟶ pullback f g
f₂ : V ⟶ pullback f g
hU : IsAffine U
hV : IsAffine V
hf₁ : IsOpenImmersion f₁
hf₂ : IsOpenImmersion f₂
H : ∀ {U : Scheme} (g : U ⟶ pullback.diagonalObj f) [inst : IsAffine U] [inst_1 : IsOpenImmersion g], P pullback.snd
⊢ P (pullback.mapDesc f₁ f₂ pullback.snd)

Next tactic:
let g₁ := pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f
    (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (by rw [Category.assoc, Category.assoc, pullback.condition])
    (by rw [Category.assoc, Category.assoc, pullback.condition])
theorem AffineTargetMorphismProperty.diagonalOfTargetAffineLocally
    (P : AffineTargetMorphismProperty) (hP : P.IsLocal) {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y)
    [IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :
    P.diagonal (pullback.snd : pullback f g ⟶ _) := by
  rintro U V f₁ f₂ hU hV hf₁ hf₂
  replace H := ((hP.affine_openCover_TFAE (pullback.diagonal f)).out 0 3).mp H
  let g₁ := pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f
    (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (by 

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y U✝ : Scheme
f : X ⟶ Y
g : U✝ ⟶ Y
inst✝¹ : IsAffine U✝
inst✝ : IsOpenImmersion g
U V : Scheme
f₁ : U ⟶ pullback f g
f₂ : V ⟶ pullback f g
hU : IsAffine U
hV : IsAffine V
hf₁ : IsOpenImmersion f₁
hf₂ : IsOpenImmersion f₂
H : ∀ {U : Scheme} (g : U ⟶ pullback.diagonalObj f) [inst : IsAffine U] [inst_1 : IsOpenImmersion g], P pullback.snd
⊢ (f₁ ≫ pullback.snd) ≫ g = (f₁ ≫ pullback.fst) ≫ f

Next tactic:
rw [Category.assoc, Category.assoc, pullback.condition]
theorem AffineTargetMorphismProperty.diagonalOfTargetAffineLocally
    (P : AffineTargetMorphismProperty) (hP : P.IsLocal) {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y)
    [IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :
    P.diagonal (pullback.snd : pullback f g ⟶ _) := by
  rintro U V f₁ f₂ hU hV hf₁ hf₂
  replace H := ((hP.affine_openCover_TFAE (pullback.diagonal f)).out 0 3).mp H
  let g₁ := pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f
    (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (by rw [Category.assoc, Category.assoc, pullback.condition])
    (by 

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y U✝ : Scheme
f : X ⟶ Y
g : U✝ ⟶ Y
inst✝¹ : IsAffine U✝
inst✝ : IsOpenImmersion g
U V : Scheme
f₁ : U ⟶ pullback f g
f₂ : V ⟶ pullback f g
hU : IsAffine U
hV : IsAffine V
hf₁ : IsOpenImmersion f₁
hf₂ : IsOpenImmersion f₂
H : ∀ {U : Scheme} (g : U ⟶ pullback.diagonalObj f) [inst : IsAffine U] [inst_1 : IsOpenImmersion g], P pullback.snd
⊢ (f₂ ≫ pullback.snd) ≫ g = (f₂ ≫ pullback.fst) ≫ f

Next tactic:
rw [Category.assoc, Category.assoc, pullback.condition]
theorem AffineTargetMorphismProperty.diagonalOfTargetAffineLocally
    (P : AffineTargetMorphismProperty) (hP : P.IsLocal) {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y)
    [IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :
    P.diagonal (pullback.snd : pullback f g ⟶ _) := by
  rintro U V f₁ f₂ hU hV hf₁ hf₂
  replace H := ((hP.affine_openCover_TFAE (pullback.diagonal f)).out 0 3).mp H
  let g₁ := pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f
    (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (by rw [Category.assoc, Category.assoc, pullback.condition])
    (by rw [Category.assoc, Category.assoc, pullback.condition])
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y U✝ : Scheme
f : X ⟶ Y
g : U✝ ⟶ Y
inst✝¹ : IsAffine U✝
inst✝ : IsOpenImmersion g
U V : Scheme
f₁ : U ⟶ pullback f g
f₂ : V ⟶ pullback f g
hU : IsAffine U
hV : IsAffine V
hf₁ : IsOpenImmersion f₁
hf₂ : IsOpenImmersion f₂
H : ∀ {U : Scheme} (g : U ⟶ pullback.diagonalObj f) [inst : IsAffine U] [inst_1 : IsOpenImmersion g], P pullback.snd
g₁ : pullback (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) ⟶ pullback f f :=
  pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (_ : (f₁ ≫ pullback.snd) ≫ g = (f₁ ≫ pullback.fst) ≫ f) (_ : (f₂ ≫ pullback.snd) ≫ g = (f₂ ≫ pullback.fst) ≫ f)
⊢ P (pullback.mapDesc f₁ f₂ pullback.snd)

Next tactic:
specialize H g₁
theorem AffineTargetMorphismProperty.diagonalOfTargetAffineLocally
    (P : AffineTargetMorphismProperty) (hP : P.IsLocal) {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y)
    [IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :
    P.diagonal (pullback.snd : pullback f g ⟶ _) := by
  rintro U V f₁ f₂ hU hV hf₁ hf₂
  replace H := ((hP.affine_openCover_TFAE (pullback.diagonal f)).out 0 3).mp H
  let g₁ := pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f
    (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (by rw [Category.assoc, Category.assoc, pullback.condition])
    (by rw [Category.assoc, Category.assoc, pullback.condition])
  specialize H g₁
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y U✝ : Scheme
f : X ⟶ Y
g : U✝ ⟶ Y
inst✝¹ : IsAffine U✝
inst✝ : IsOpenImmersion g
U V : Scheme
f₁ : U ⟶ pullback f g
f₂ : V ⟶ pullback f g
hU : IsAffine U
hV : IsAffine V
hf₁ : IsOpenImmersion f₁
hf₂ : IsOpenImmersion f₂
g₁ : pullback (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) ⟶ pullback f f :=
  pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (_ : (f₁ ≫ pullback.snd) ≫ g = (f₁ ≫ pullback.fst) ≫ f) (_ : (f₂ ≫ pullback.snd) ≫ g = (f₂ ≫ pullback.fst) ≫ f)
H : P pullback.snd
⊢ P (pullback.mapDesc f₁ f₂ pullback.snd)

Next tactic:
rw [← affine_cancel_left_isIso hP.1 (pullbackDiagonalMapIso f _ f₁ f₂).hom]
theorem AffineTargetMorphismProperty.diagonalOfTargetAffineLocally
    (P : AffineTargetMorphismProperty) (hP : P.IsLocal) {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y)
    [IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :
    P.diagonal (pullback.snd : pullback f g ⟶ _) := by
  rintro U V f₁ f₂ hU hV hf₁ hf₂
  replace H := ((hP.affine_openCover_TFAE (pullback.diagonal f)).out 0 3).mp H
  let g₁ := pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f
    (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (by rw [Category.assoc, Category.assoc, pullback.condition])
    (by rw [Category.assoc, Category.assoc, pullback.condition])
  specialize H g₁
  rw [← affine_cancel_left_isIso hP.1 (pullbackDiagonalMapIso f _ f₁ f₂).hom]
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y U✝ : Scheme
f : X ⟶ Y
g : U✝ ⟶ Y
inst✝¹ : IsAffine U✝
inst✝ : IsOpenImmersion g
U V : Scheme
f₁ : U ⟶ pullback f g
f₂ : V ⟶ pullback f g
hU : IsAffine U
hV : IsAffine V
hf₁ : IsOpenImmersion f₁
hf₂ : IsOpenImmersion f₂
g₁ : pullback (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) ⟶ pullback f f :=
  pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (_ : (f₁ ≫ pullback.snd) ≫ g = (f₁ ≫ pullback.fst) ≫ f) (_ : (f₂ ≫ pullback.snd) ≫ g = (f₂ ≫ pullback.fst) ≫ f)
H : P pullback.snd
⊢ P ((pullbackDiagonalMapIso f g f₁ f₂).hom ≫ pullback.mapDesc f₁ f₂ pullback.snd)

Next tactic:
convert H
theorem AffineTargetMorphismProperty.diagonalOfTargetAffineLocally
    (P : AffineTargetMorphismProperty) (hP : P.IsLocal) {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y)
    [IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :
    P.diagonal (pullback.snd : pullback f g ⟶ _) := by
  rintro U V f₁ f₂ hU hV hf₁ hf₂
  replace H := ((hP.affine_openCover_TFAE (pullback.diagonal f)).out 0 3).mp H
  let g₁ := pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f
    (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (by rw [Category.assoc, Category.assoc, pullback.condition])
    (by rw [Category.assoc, Category.assoc, pullback.condition])
  specialize H g₁
  rw [← affine_cancel_left_isIso hP.1 (pullbackDiagonalMapIso f _ f₁ f₂).hom]
  convert H
  · 

Proof state:
case h.e'_3
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y U✝ : Scheme
f : X ⟶ Y
g : U✝ ⟶ Y
inst✝¹ : IsAffine U✝
inst✝ : IsOpenImmersion g
U V : Scheme
f₁ : U ⟶ pullback f g
f₂ : V ⟶ pullback f g
hU : IsAffine U
hV : IsAffine V
hf₁ : IsOpenImmersion f₁
hf₂ : IsOpenImmersion f₂
g₁ : pullback (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) ⟶ pullback f f :=
  pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (_ : (f₁ ≫ pullback.snd) ≫ g = (f₁ ≫ pullback.fst) ≫ f) (_ : (f₂ ≫ pullback.snd) ≫ g = (f₂ ≫ pullback.fst) ≫ f)
H : P pullback.snd
⊢ (pullbackDiagonalMapIso f g f₁ f₂).hom ≫ pullback.mapDesc f₁ f₂ pullback.snd = pullback.snd

Next tactic:
apply pullback.hom_ext
theorem AffineTargetMorphismProperty.diagonalOfTargetAffineLocally
    (P : AffineTargetMorphismProperty) (hP : P.IsLocal) {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y)
    [IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :
    P.diagonal (pullback.snd : pullback f g ⟶ _) := by
  rintro U V f₁ f₂ hU hV hf₁ hf₂
  replace H := ((hP.affine_openCover_TFAE (pullback.diagonal f)).out 0 3).mp H
  let g₁ := pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f
    (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (by rw [Category.assoc, Category.assoc, pullback.condition])
    (by rw [Category.assoc, Category.assoc, pullback.condition])
  specialize H g₁
  rw [← affine_cancel_left_isIso hP.1 (pullbackDiagonalMapIso f _ f₁ f₂).hom]
  convert H
  · apply pullback.hom_ext <;>
    

Proof state:
case h.e'_3.h₀
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y U✝ : Scheme
f : X ⟶ Y
g : U✝ ⟶ Y
inst✝¹ : IsAffine U✝
inst✝ : IsOpenImmersion g
U V : Scheme
f₁ : U ⟶ pullback f g
f₂ : V ⟶ pullback f g
hU : IsAffine U
hV : IsAffine V
hf₁ : IsOpenImmersion f₁
hf₂ : IsOpenImmersion f₂
g₁ : pullback (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) ⟶ pullback f f :=
  pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (_ : (f₁ ≫ pullback.snd) ≫ g = (f₁ ≫ pullback.fst) ≫ f) (_ : (f₂ ≫ pullback.snd) ≫ g = (f₂ ≫ pullback.fst) ≫ f)
H : P pullback.snd
⊢ ((pullbackDiagonalMapIso f g f₁ f₂).hom ≫ pullback.mapDesc f₁ f₂ pullback.snd) ≫ pullback.fst =
    pullback.snd ≫ pullback.fst

Next tactic:
simp only [Category.assoc, pullback.lift_fst, pullback.lift_snd, pullback.lift_fst_assoc,
      pullback.lift_snd_assoc, Category.comp_id, pullbackDiagonalMapIso_hom_fst,
      pullbackDiagonalMapIso_hom_snd]
theorem AffineTargetMorphismProperty.diagonalOfTargetAffineLocally
    (P : AffineTargetMorphismProperty) (hP : P.IsLocal) {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y)
    [IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :
    P.diagonal (pullback.snd : pullback f g ⟶ _) := by
  rintro U V f₁ f₂ hU hV hf₁ hf₂
  replace H := ((hP.affine_openCover_TFAE (pullback.diagonal f)).out 0 3).mp H
  let g₁ := pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f
    (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (by rw [Category.assoc, Category.assoc, pullback.condition])
    (by rw [Category.assoc, Category.assoc, pullback.condition])
  specialize H g₁
  rw [← affine_cancel_left_isIso hP.1 (pullbackDiagonalMapIso f _ f₁ f₂).hom]
  convert H
  · apply pullback.hom_ext <;>
    

Proof state:
case h.e'_3.h₁
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y U✝ : Scheme
f : X ⟶ Y
g : U✝ ⟶ Y
inst✝¹ : IsAffine U✝
inst✝ : IsOpenImmersion g
U V : Scheme
f₁ : U ⟶ pullback f g
f₂ : V ⟶ pullback f g
hU : IsAffine U
hV : IsAffine V
hf₁ : IsOpenImmersion f₁
hf₂ : IsOpenImmersion f₂
g₁ : pullback (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) ⟶ pullback f f :=
  pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
    (_ : (f₁ ≫ pullback.snd) ≫ g = (f₁ ≫ pullback.fst) ≫ f) (_ : (f₂ ≫ pullback.snd) ≫ g = (f₂ ≫ pullback.fst) ≫ f)
H : P pullback.snd
⊢ ((pullbackDiagonalMapIso f g f₁ f₂).hom ≫ pullback.mapDesc f₁ f₂ pullback.snd) ≫ pullback.snd =
    pullback.snd ≫ pullback.snd

Next tactic:
simp only [Category.assoc, pullback.lift_fst, pullback.lift_snd, pullback.lift_fst_assoc,
      pullback.lift_snd_assoc, Category.comp_id, pullbackDiagonalMapIso_hom_fst,
      pullbackDiagonalMapIso_hom_snd]