theorem compatiblePreservingOfFlat {C : Type u₁} [Category.{v₁} C] {D : Type u₁} [Category.{v₁} D]
    (K : GrothendieckTopology D) (G : C ⥤ D) [RepresentablyFlat G] : CompatiblePreserving K G := by
  constructor
  intro ℱ Z T x hx Y₁ Y₂ X f₁ f₂ g₁ g₂ hg₁ hg₂ e
  -- First, `f₁` and `f₂` form a cone over `cospan g₁ g₂ ⋙ u`.
  let c : Cone (cospan g₁ g₂ ⋙ G) :=
    (Cones.postcompose (diagramIsoCospan (cospan g₁ g₂ ⋙ G)).inv).obj (PullbackCone.mk f₁ f₂ e)
  /-
    This can then be viewed as a cospan of structured arrows, and we may obtain an arbitrary cone
    over it since `StructuredArrow W u` is cofiltered.
    Then, it suffices to prove that it is compatible when restricted onto `u(c'.X.right)`.
    -/
  let c' := IsCofiltered.cone (c.toStructuredArrow ⋙ StructuredArrow.pre _ _ _)
  have eq₁ : f₁ = (c'.pt.hom ≫ G.map (c'.π.app left).right) ≫ eqToHom (by simp) := by
    erw [← (c'.π.app left).w]
    dsimp
    simp
  have eq₂ : f₂ = (c'.pt.hom ≫ G.map (c'.π.app right).right) ≫ eqToHom (by simp) := by
    erw [← (c'.π.app right).w]
    dsimp
    simp
  conv_lhs => rw [eq₁]
  conv_rhs => rw [eq₂]
  simp only [op_comp, Functor.map_comp, types_comp_apply, eqToHom_op, eqToHom_map]
  apply congr_arg -- porting note: was `congr 1` which for some reason doesn't do anything here
  -- despite goal being of the form f a = f b, with f=`ℱ.val.map (Quiver.Hom.op c'.pt.hom)`
  /-
    Since everything now falls in the image of `u`,
    the result follows from the compatibility of `x` in the image of `u`.
    -/
  injection c'.π.naturality WalkingCospan.Hom.inl with _ e₁
  injection c'.π.naturality WalkingCospan.Hom.inr with _ e₂
  

Proof state:
case compatible.h
C✝ : Type u₁
inst✝⁵ : Category.{v₁, u₁} C✝
D✝ : Type u₂
inst✝⁴ : Category.{v₂, u₂} D✝
F : C✝ ⥤ D✝
A : Type u₃
inst✝³ : Category.{v₃, u₃} A
J : GrothendieckTopology C✝
K✝ : GrothendieckTopology D✝
L : GrothendieckTopology A
G✝ : C✝ ⥤ D✝
hG : CompatiblePreserving K✝ G✝
ℱ✝ : SheafOfTypes K✝
Z✝ : C✝
T✝ : Presieve Z✝
x✝ : FamilyOfElements (G✝.op ⋙ ℱ✝.val) T✝
h : Compatible x✝
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₁
inst✝¹ : Category.{v₁, u₁} D
K : GrothendieckTopology D
G : C ⥤ D
inst✝ : RepresentablyFlat G
ℱ : SheafOfTypes K
Z : C
T : Presieve Z
x : FamilyOfElements (G.op ⋙ ℱ.val) T
hx : Compatible x
Y₁ Y₂ : C
X : D
f₁ : X ⟶ G.obj Y₁
f₂ : X ⟶ G.obj Y₂
g₁ : Y₁ ⟶ Z
g₂ : Y₂ ⟶ Z
hg₁ : T g₁
hg₂ : T g₂
e : f₁ ≫ G.map g₁ = f₂ ≫ G.map g₂
c : Cone (cospan g₁ g₂ ⋙ G) :=
  (Cones.postcompose (diagramIsoCospan (cospan g₁ g₂ ⋙ G)).inv).obj (PullbackCone.mk f₁ f₂ e)
c' : Cone (Cone.toStructuredArrow c ⋙ StructuredArrow.pre c.pt (cospan g₁ g₂) G) :=
  IsCofiltered.cone (Cone.toStructuredArrow c ⋙ StructuredArrow.pre c.pt (cospan g₁ g₂) G)
eq₁ :
  f₁ =
    (c'.pt.hom ≫ G.map (c'.π.app left).right) ≫
      eqToHom
        (_ :
          G.obj ((StructuredArrow.pre X (cospan g₁ g₂) G).obj (StructuredArrow.mk (f₁ ≫ 𝟙 (G.obj Y₁)))).right =
            G.obj Y₁)
eq₂ :
  f₂ =
    (c'.pt.hom ≫ G.map (c'.π.app right).right) ≫
      eqToHom
        (_ :
          G.obj ((StructuredArrow.pre X (cospan g₁ g₂) G).obj (StructuredArrow.mk (f₂ ≫ 𝟙 (G.obj Y₂)))).right =
            G.obj Y₂)
left_eq✝¹ :
  (((Functor.const WalkingCospan).obj c'.pt).map Hom.inl).left ≫ (c'.π.app one).left =
    (c'.π.app left).left ≫ ((Cone.toStructuredArrow c ⋙ StructuredArrow.pre c.pt (cospan g₁ g₂) G).map Hom.inl).left
e₁ :
  (((Functor.const WalkingCospan).obj c'.pt).map Hom.inl).right ≫ (c'.π.app one).right =
    (c'.π.app left).right ≫ ((Cone.toStructuredArrow c ⋙ StructuredArrow.pre c.pt (cospan g₁ g₂) G).map Hom.inl).right
left_eq✝ :
  (((Functor.const WalkingCospan).obj c'.pt).map Hom.inr).left ≫ (c'.π.app one).left =
    (c'.π.app right).left ≫ ((Cone.toStructuredArrow c ⋙ StructuredArrow.pre c.pt (cospan g₁ g₂) G).map Hom.inr).left
e₂ :
  (((Functor.const WalkingCospan).obj c'.pt).map Hom.inr).right ≫ (c'.π.app one).right =
    (c'.π.app right).right ≫ ((Cone.toStructuredArrow c ⋙ StructuredArrow.pre c.pt (cospan g₁ g₂) G).map Hom.inr).right
⊢ ℱ.val.map
      (G.map
          ((IsCofiltered.cone
                    (Cone.toStructuredArrow
                        ((Cones.postcompose (diagramIsoCospan (cospan g₁ g₂ ⋙ G)).inv).obj (PullbackCone.mk f₁ f₂ e)) ⋙
                      StructuredArrow.pre
                        ((Cones.postcompose (diagramIsoCospan (cospan g₁ g₂ ⋙ G)).inv).obj (PullbackCone.mk f₁ f₂ e)).pt
                        (cospan g₁ g₂) G)).π.app
              left).right).op
      (eqToHom
        (_ :
          ℱ.val.obj (op (G.obj Y₁)) =
            ℱ.val.obj
              (op
                (G.obj
                  ((Cone.toStructuredArrow
                            ((Cones.postcompose (diagramIsoCospan (cospan g₁ g₂ ⋙ G)).inv).obj
                              (PullbackCone.mk f₁ f₂ e)) ⋙
                          StructuredArrow.pre
                            ((Cones.postcompose (diagramIsoCospan (cospan g₁ g₂ ⋙ G)).inv).obj
                                (PullbackCone.mk f₁ f₂ e)).pt
                            (cospan g₁ g₂) G).obj
                      left).right)))
        (x g₁ hg₁)) =
    ℱ.val.map
      (G.map
          ((IsCofiltered.cone
                    (Cone.toStructuredArrow
                        ((Cones.postcompose (diagramIsoCospan (cospan g₁ g₂ ⋙ G)).inv).obj (PullbackCone.mk f₁ f₂ e)) ⋙
                      StructuredArrow.pre
                        ((Cones.postcompose (diagramIsoCospan (cospan g₁ g₂ ⋙ G)).inv).obj (PullbackCone.mk f₁ f₂ e)).pt
                        (cospan g₁ g₂) G)).π.app
              right).right).op
      (eqToHom
        (_ :
          ℱ.val.obj (op (G.obj Y₂)) =
            ℱ.val.obj
              (op
                (G.obj
                  ((Cone.toStructuredArrow
                            ((Cones.postcompose (diagramIsoCospan (cospan g₁ g₂ ⋙ G)).inv).obj
                              (PullbackCone.mk f₁ f₂ e)) ⋙
                          StructuredArrow.pre
                            ((Cones.postcompose (diagramIsoCospan (cospan g₁ g₂ ⋙ G)).inv).obj
                                (PullbackCone.mk f₁ f₂ e)).pt
                            (cospan g₁ g₂) G).obj
                      right).right)))
        (x g₂ hg₂))

Next tactic:
exact hx (c'.π.app left).right (c'.π.app right).right hg₁ hg₂ (e₁.symm.trans e₂)