l3lab/ntp-mathlib huggingface dataset:
theorem uniq {K : J ⥤ C} {c : Cone K} (hc : IsLimit c) (s : Cone (K ⋙ F))
    (f₁ f₂ : s.pt ⟶ F.obj c.pt) (h₁ : ∀ j : J, f₁ ≫ (F.mapCone c).π.app j = s.π.app j)
    (h₂ : ∀ j : J, f₂ ≫ (F.mapCone c).π.app j = s.π.app j) : f₁ = f₂ := by
  -- We can make two cones over the diagram of `s` via `f₁` and `f₂`.
  let α₁ : (F.mapCone c).toStructuredArrow ⋙ map f₁ ⟶ s.toStructuredArrow :=
    { app := fun X => eqToHom (by simp [← h₁]) }
  let α₂ : (F.mapCone c).toStructuredArrow ⋙ map f₂ ⟶ s.toStructuredArrow :=
    { app := fun X => eqToHom (by simp [← h₂]) }
  let c₁ : Cone (s.toStructuredArrow ⋙ pre s.pt K F) :=
    (Cones.postcompose (whiskerRight α₁ (pre s.pt K F) : _)).obj (c.toStructuredArrowCone F f₁)
  let c₂ : Cone (s.toStructuredArrow ⋙ pre s.pt K F) :=
    (Cones.postcompose (whiskerRight α₂ (pre s.pt K F) : _)).obj (c.toStructuredArrowCone F f₂)
  -- The two cones can then be combined and we may obtain a cone over the two cones since
  -- `StructuredArrow s.pt F` is cofiltered.
  let c₀ := IsCofiltered.cone (biconeMk _ c₁ c₂)
  let g₁ : c₀.pt ⟶ c₁.pt := c₀.π.app Bicone.left
  let g₂ : c₀.pt ⟶ c₂.pt := c₀.π.app Bicone.right
  -- Then `g₁.right` and `g₂.right` are two maps from the same cone into the `c`.
  have : ∀ j : J, g₁.right ≫ c.π.app j = g₂.right ≫ c.π.app j := by
    intro j
    injection c₀.π.naturality (BiconeHom.left j) with _ e₁
    injection c₀.π.naturality (BiconeHom.right j) with _ e₂
    convert e₁.symm.trans e₂ <;> simp
  have : c.extend g₁.right = c.extend g₂.right := by
    unfold Cone.extend
    

Proof state:
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ (F.mapCone c).π.app j = s.π.app j
h₂ : ∀ (j : J), f₂ ≫ (F.mapCone c).π.app j = s.π.app j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
  NatTrans.mk fun X => eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (c.π.app X)) = StructuredArrow.mk (s.π.app X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
  NatTrans.mk fun X => eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (c.π.app X)) = StructuredArrow.mk (s.π.app X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
  (Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
  (Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := c₀.π.app Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := c₀.π.app Bicone.right
this : ∀ (j : J), g₁.right ≫ c.π.app j = g₂.right ≫ c.π.app j
⊢ { pt := c₀.pt.right, π := (Cone.extensions c).app (op c₀.pt.right) { down := g₁.right } } =
    { pt := c₀.pt.right, π := (Cone.extensions c).app (op c₀.pt.right) { down := g₂.right } }

Next tactic:
congr 1
theorem uniq {K : J ⥤ C} {c : Cone K} (hc : IsLimit c) (s : Cone (K ⋙ F))
    (f₁ f₂ : s.pt ⟶ F.obj c.pt) (h₁ : ∀ j : J, f₁ ≫ (F.mapCone c).π.app j = s.π.app j)
    (h₂ : ∀ j : J, f₂ ≫ (F.mapCone c).π.app j = s.π.app j) : f₁ = f₂ := by
  -- We can make two cones over the diagram of `s` via `f₁` and `f₂`.
  let α₁ : (F.mapCone c).toStructuredArrow ⋙ map f₁ ⟶ s.toStructuredArrow :=
    { app := fun X => eqToHom (by simp [← h₁]) }
  let α₂ : (F.mapCone c).toStructuredArrow ⋙ map f₂ ⟶ s.toStructuredArrow :=
    { app := fun X => eqToHom (by simp [← h₂]) }
  let c₁ : Cone (s.toStructuredArrow ⋙ pre s.pt K F) :=
    (Cones.postcompose (whiskerRight α₁ (pre s.pt K F) : _)).obj (c.toStructuredArrowCone F f₁)
  let c₂ : Cone (s.toStructuredArrow ⋙ pre s.pt K F) :=
    (Cones.postcompose (whiskerRight α₂ (pre s.pt K F) : _)).obj (c.toStructuredArrowCone F f₂)
  -- The two cones can then be combined and we may obtain a cone over the two cones since
  -- `StructuredArrow s.pt F` is cofiltered.
  let c₀ := IsCofiltered.cone (biconeMk _ c₁ c₂)
  let g₁ : c₀.pt ⟶ c₁.pt := c₀.π.app Bicone.left
  let g₂ : c₀.pt ⟶ c₂.pt := c₀.π.app Bicone.right
  -- Then `g₁.right` and `g₂.right` are two maps from the same cone into the `c`.
  have : ∀ j : J, g₁.right ≫ c.π.app j = g₂.right ≫ c.π.app j := by
    intro j
    injection c₀.π.naturality (BiconeHom.left j) with _ e₁
    injection c₀.π.naturality (BiconeHom.right j) with _ e₂
    convert e₁.symm.trans e₂ <;> simp
  have : c.extend g₁.right = c.extend g₂.right := by
    unfold Cone.extend
    congr 1
    

Proof state:
case e_π
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ (F.mapCone c).π.app j = s.π.app j
h₂ : ∀ (j : J), f₂ ≫ (F.mapCone c).π.app j = s.π.app j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
  NatTrans.mk fun X => eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (c.π.app X)) = StructuredArrow.mk (s.π.app X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
  NatTrans.mk fun X => eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (c.π.app X)) = StructuredArrow.mk (s.π.app X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
  (Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
  (Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := c₀.π.app Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := c₀.π.app Bicone.right
this : ∀ (j : J), g₁.right ≫ c.π.app j = g₂.right ≫ c.π.app j
⊢ (Cone.extensions c).app (op c₀.pt.right) { down := g₁.right } =
    (Cone.extensions c).app (op c₀.pt.right) { down := g₂.right }

Next tactic:
ext x
theorem uniq {K : J ⥤ C} {c : Cone K} (hc : IsLimit c) (s : Cone (K ⋙ F))
    (f₁ f₂ : s.pt ⟶ F.obj c.pt) (h₁ : ∀ j : J, f₁ ≫ (F.mapCone c).π.app j = s.π.app j)
    (h₂ : ∀ j : J, f₂ ≫ (F.mapCone c).π.app j = s.π.app j) : f₁ = f₂ := by
  -- We can make two cones over the diagram of `s` via `f₁` and `f₂`.
  let α₁ : (F.mapCone c).toStructuredArrow ⋙ map f₁ ⟶ s.toStructuredArrow :=
    { app := fun X => eqToHom (by simp [← h₁]) }
  let α₂ : (F.mapCone c).toStructuredArrow ⋙ map f₂ ⟶ s.toStructuredArrow :=
    { app := fun X => eqToHom (by simp [← h₂]) }
  let c₁ : Cone (s.toStructuredArrow ⋙ pre s.pt K F) :=
    (Cones.postcompose (whiskerRight α₁ (pre s.pt K F) : _)).obj (c.toStructuredArrowCone F f₁)
  let c₂ : Cone (s.toStructuredArrow ⋙ pre s.pt K F) :=
    (Cones.postcompose (whiskerRight α₂ (pre s.pt K F) : _)).obj (c.toStructuredArrowCone F f₂)
  -- The two cones can then be combined and we may obtain a cone over the two cones since
  -- `StructuredArrow s.pt F` is cofiltered.
  let c₀ := IsCofiltered.cone (biconeMk _ c₁ c₂)
  let g₁ : c₀.pt ⟶ c₁.pt := c₀.π.app Bicone.left
  let g₂ : c₀.pt ⟶ c₂.pt := c₀.π.app Bicone.right
  -- Then `g₁.right` and `g₂.right` are two maps from the same cone into the `c`.
  have : ∀ j : J, g₁.right ≫ c.π.app j = g₂.right ≫ c.π.app j := by
    intro j
    injection c₀.π.naturality (BiconeHom.left j) with _ e₁
    injection c₀.π.naturality (BiconeHom.right j) with _ e₂
    convert e₁.symm.trans e₂ <;> simp
  have : c.extend g₁.right = c.extend g₂.right := by
    unfold Cone.extend
    congr 1
    ext x
    

Proof state:
case e_π.w.h
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ (F.mapCone c).π.app j = s.π.app j
h₂ : ∀ (j : J), f₂ ≫ (F.mapCone c).π.app j = s.π.app j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
  NatTrans.mk fun X => eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (c.π.app X)) = StructuredArrow.mk (s.π.app X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
  NatTrans.mk fun X => eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (c.π.app X)) = StructuredArrow.mk (s.π.app X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
  (Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
  (Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := c₀.π.app Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := c₀.π.app Bicone.right
this : ∀ (j : J), g₁.right ≫ c.π.app j = g₂.right ≫ c.π.app j
x : J
⊢ ((Cone.extensions c).app (op c₀.pt.right) { down := g₁.right }).app x =
    ((Cone.extensions c).app (op c₀.pt.right) { down := g₂.right }).app x

Next tactic:
apply this
theorem uniq {K : J ⥤ C} {c : Cone K} (hc : IsLimit c) (s : Cone (K ⋙ F))
    (f₁ f₂ : s.pt ⟶ F.obj c.pt) (h₁ : ∀ j : J, f₁ ≫ (F.mapCone c).π.app j = s.π.app j)
    (h₂ : ∀ j : J, f₂ ≫ (F.mapCone c).π.app j = s.π.app j) : f₁ = f₂ := by
  -- We can make two cones over the diagram of `s` via `f₁` and `f₂`.
  let α₁ : (F.mapCone c).toStructuredArrow ⋙ map f₁ ⟶ s.toStructuredArrow :=
    { app := fun X => eqToHom (by simp [← h₁]) }
  let α₂ : (F.mapCone c).toStructuredArrow ⋙ map f₂ ⟶ s.toStructuredArrow :=
    { app := fun X => eqToHom (by simp [← h₂]) }
  let c₁ : Cone (s.toStructuredArrow ⋙ pre s.pt K F) :=
    (Cones.postcompose (whiskerRight α₁ (pre s.pt K F) : _)).obj (c.toStructuredArrowCone F f₁)
  let c₂ : Cone (s.toStructuredArrow ⋙ pre s.pt K F) :=
    (Cones.postcompose (whiskerRight α₂ (pre s.pt K F) : _)).obj (c.toStructuredArrowCone F f₂)
  -- The two cones can then be combined and we may obtain a cone over the two cones since
  -- `StructuredArrow s.pt F` is cofiltered.
  let c₀ := IsCofiltered.cone (biconeMk _ c₁ c₂)
  let g₁ : c₀.pt ⟶ c₁.pt := c₀.π.app Bicone.left
  let g₂ : c₀.pt ⟶ c₂.pt := c₀.π.app Bicone.right
  -- Then `g₁.right` and `g₂.right` are two maps from the same cone into the `c`.
  have : ∀ j : J, g₁.right ≫ c.π.app j = g₂.right ≫ c.π.app j := by
    intro j
    injection c₀.π.naturality (BiconeHom.left j) with _ e₁
    injection c₀.π.naturality (BiconeHom.right j) with _ e₂
    convert e₁.symm.trans e₂ <;> simp
  have : c.extend g₁.right = c.extend g₂.right := by
    unfold Cone.extend
    congr 1
    ext x
    apply this
  -- And thus they are equal as `c` is the limit.
  

Proof state:
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ (F.mapCone c).π.app j = s.π.app j
h₂ : ∀ (j : J), f₂ ≫ (F.mapCone c).π.app j = s.π.app j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
  NatTrans.mk fun X => eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (c.π.app X)) = StructuredArrow.mk (s.π.app X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
  NatTrans.mk fun X => eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (c.π.app X)) = StructuredArrow.mk (s.π.app X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
  (Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
  (Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := c₀.π.app Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := c₀.π.app Bicone.right
this✝ : ∀ (j : J), g₁.right ≫ c.π.app j = g₂.right ≫ c.π.app j
this : Cone.extend c g₁.right = Cone.extend c g₂.right
⊢ f₁ = f₂

Next tactic:
have : g₁.right = g₂.right
/-- Representably flat functors preserve finite limits. -/
noncomputable def preservesFiniteLimitsOfFlat (F : C ⥤ D) [RepresentablyFlat F] :
    PreservesFiniteLimits F := by
  

Proof state:
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
⊢ PreservesFiniteLimits F

Next tactic:
apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize
/-- Representably flat functors preserve finite limits. -/
noncomputable def preservesFiniteLimitsOfFlat (F : C ⥤ D) [RepresentablyFlat F] :
    PreservesFiniteLimits F := by
  apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize
  

Proof state:
case h
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
⊢ (J : Type ?u.150871) → {𝒥 : SmallCategory J} → FinCategory J → PreservesLimitsOfShape J F

Next tactic:
intro J _ _
/-- Representably flat functors preserve finite limits. -/
noncomputable def preservesFiniteLimitsOfFlat (F : C ⥤ D) [RepresentablyFlat F] :
    PreservesFiniteLimits F := by
  apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize
  intro J _ _; 

Proof state:
case h
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type ?u.150871
𝒥✝ : SmallCategory J
x✝ : FinCategory J
⊢ PreservesLimitsOfShape J F

Next tactic:
constructor
/-- Representably flat functors preserve finite limits. -/
noncomputable def preservesFiniteLimitsOfFlat (F : C ⥤ D) [RepresentablyFlat F] :
    PreservesFiniteLimits F := by
  apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize
  intro J _ _; constructor
  

Proof state:
case h.preservesLimit
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type ?u.150871
𝒥✝ : SmallCategory J
x✝ : FinCategory J
⊢ autoParam ({K : J ⥤ C} → PreservesLimit K F) _auto✝

Next tactic:
intro K
/-- Representably flat functors preserve finite limits. -/
noncomputable def preservesFiniteLimitsOfFlat (F : C ⥤ D) [RepresentablyFlat F] :
    PreservesFiniteLimits F := by
  apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize
  intro J _ _; constructor
  intro K; 

Proof state:
case h.preservesLimit
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type ?u.150871
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
⊢ PreservesLimit K F

Next tactic:
constructor
/-- Representably flat functors preserve finite limits. -/
noncomputable def preservesFiniteLimitsOfFlat (F : C ⥤ D) [RepresentablyFlat F] :
    PreservesFiniteLimits F := by
  apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize
  intro J _ _; constructor
  intro K; constructor
  

Proof state:
case h.preservesLimit.preserves
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type ?u.150871
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
⊢ {c : Cone K} → IsLimit c → IsLimit (F.mapCone c)

Next tactic:
intro c hc
/-- Representably flat functors preserve finite limits. -/
noncomputable def preservesFiniteLimitsOfFlat (F : C ⥤ D) [RepresentablyFlat F] :
    PreservesFiniteLimits F := by
  apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize
  intro J _ _; constructor
  intro K; constructor
  intro c hc
  

Proof state:
case h.preservesLimit.preserves
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type ?u.150871
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
c : Cone K
hc : IsLimit c
⊢ IsLimit (F.mapCone c)

Next tactic:
exact
    { lift := PreservesFiniteLimitsOfFlat.lift F hc
      fac := PreservesFiniteLimitsOfFlat.fac F hc
      uniq := fun s m h => by
        apply PreservesFiniteLimitsOfFlat.uniq F hc
        exact h
        exact PreservesFiniteLimitsOfFlat.fac F hc s }
/-- Representably flat functors preserve finite limits. -/
noncomputable def preservesFiniteLimitsOfFlat (F : C ⥤ D) [RepresentablyFlat F] :
    PreservesFiniteLimits F := by
  apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize
  intro J _ _; constructor
  intro K; constructor
  intro c hc
  exact
    { lift := PreservesFiniteLimitsOfFlat.lift F hc
      fac := PreservesFiniteLimitsOfFlat.fac F hc
      uniq := fun s m h => by
        

Proof state:
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type v₁
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
m : s.pt ⟶ (F.mapCone c).pt
h : ∀ (j : J), m ≫ (F.mapCone c).π.app j = s.π.app j
⊢ m = PreservesFiniteLimitsOfFlat.lift F hc s

Next tactic:
apply PreservesFiniteLimitsOfFlat.uniq F hc
/-- Representably flat functors preserve finite limits. -/
noncomputable def preservesFiniteLimitsOfFlat (F : C ⥤ D) [RepresentablyFlat F] :
    PreservesFiniteLimits F := by
  apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize
  intro J _ _; constructor
  intro K; constructor
  intro c hc
  exact
    { lift := PreservesFiniteLimitsOfFlat.lift F hc
      fac := PreservesFiniteLimitsOfFlat.fac F hc
      uniq := fun s m h => by
        apply PreservesFiniteLimitsOfFlat.uniq F hc
        

Proof state:
case h₁
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type v₁
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
m : s.pt ⟶ (F.mapCone c).pt
h : ∀ (j : J), m ≫ (F.mapCone c).π.app j = s.π.app j
⊢ ∀ (j : J), m ≫ (F.mapCone c).π.app j = s.π.app j
case h₂
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type v₁
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
m : s.pt ⟶ (F.mapCone c).pt
h : ∀ (j : J), m ≫ (F.mapCone c).π.app j = s.π.app j
⊢ ∀ (j : J), PreservesFiniteLimitsOfFlat.lift F hc s ≫ (F.mapCone c).π.app j = s.π.app j

Next tactic:
exact h
/-- Representably flat functors preserve finite limits. -/
noncomputable def preservesFiniteLimitsOfFlat (F : C ⥤ D) [RepresentablyFlat F] :
    PreservesFiniteLimits F := by
  apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize
  intro J _ _; constructor
  intro K; constructor
  intro c hc
  exact
    { lift := PreservesFiniteLimitsOfFlat.lift F hc
      fac := PreservesFiniteLimitsOfFlat.fac F hc
      uniq := fun s m h => by
        apply PreservesFiniteLimitsOfFlat.uniq F hc
        exact h
        

Proof state:
case h₂
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type v₁
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
m : s.pt ⟶ (F.mapCone c).pt
h : ∀ (j : J), m ≫ (F.mapCone c).π.app j = s.π.app j
⊢ ∀ (j : J), PreservesFiniteLimitsOfFlat.lift F hc s ≫ (F.mapCone c).π.app j = s.π.app j

Next tactic:
exact PreservesFiniteLimitsOfFlat.fac F hc s
/-- If `C` is finitely cocomplete, then `F : C ⥤ D` is representably flat iff it preserves
finite limits.
-/
noncomputable def preservesFiniteLimitsIffFlat [HasFiniteLimits C] (F : C ⥤ D) :
    RepresentablyFlat F ≃ PreservesFiniteLimits F where
  toFun _ := preservesFiniteLimitsOfFlat F
  invFun _ := flat_of_preservesFiniteLimits F
  left_inv _ := proof_irrel _ _
  right_inv x := by
    

Proof state:
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
inst✝ : HasFiniteLimits C
F : C ⥤ D
x : PreservesFiniteLimits F
⊢ (fun x => preservesFiniteLimitsOfFlat F) (_ : RepresentablyFlat F) = x

Next tactic:
cases x
/-- If `C` is finitely cocomplete, then `F : C ⥤ D` is representably flat iff it preserves
finite limits.
-/
noncomputable def preservesFiniteLimitsIffFlat [HasFiniteLimits C] (F : C ⥤ D) :
    RepresentablyFlat F ≃ PreservesFiniteLimits F where
  toFun _ := preservesFiniteLimitsOfFlat F
  invFun _ := flat_of_preservesFiniteLimits F
  left_inv _ := proof_irrel _ _
  right_inv x := by
    cases x
    

Proof state:
case mk
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
inst✝ : HasFiniteLimits C
F : C ⥤ D
preservesFiniteLimits✝ : (J : Type) → [inst : SmallCategory J] → [inst_1 : FinCategory J] → PreservesLimitsOfShape J F
⊢ (fun x => preservesFiniteLimitsOfFlat F) (_ : RepresentablyFlat F) = PreservesFiniteLimits.mk

Next tactic:
unfold preservesFiniteLimitsOfFlat
/-- If `C` is finitely cocomplete, then `F : C ⥤ D` is representably flat iff it preserves
finite limits.
-/
noncomputable def preservesFiniteLimitsIffFlat [HasFiniteLimits C] (F : C ⥤ D) :
    RepresentablyFlat F ≃ PreservesFiniteLimits F where
  toFun _ := preservesFiniteLimitsOfFlat F
  invFun _ := flat_of_preservesFiniteLimits F
  left_inv _ := proof_irrel _ _
  right_inv x := by
    cases x
    unfold preservesFiniteLimitsOfFlat
    

Proof state:
case mk
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
inst✝ : HasFiniteLimits C
F : C ⥤ D
preservesFiniteLimits✝ : (J : Type) → [inst : SmallCategory J] → [inst_1 : FinCategory J] → PreservesLimitsOfShape J F
⊢ (fun x => preservesFiniteLimitsOfPreservesFiniteLimitsOfSize F fun J {𝒥} x_1 => PreservesLimitsOfShape.mk)
      (_ : RepresentablyFlat F) =
    PreservesFiniteLimits.mk

Next tactic:
dsimp only [preservesFiniteLimitsOfPreservesFiniteLimitsOfSize]
/-- If `C` is finitely cocomplete, then `F : C ⥤ D` is representably flat iff it preserves
finite limits.
-/
noncomputable def preservesFiniteLimitsIffFlat [HasFiniteLimits C] (F : C ⥤ D) :
    RepresentablyFlat F ≃ PreservesFiniteLimits F where
  toFun _ := preservesFiniteLimitsOfFlat F
  invFun _ := flat_of_preservesFiniteLimits F
  left_inv _ := proof_irrel _ _
  right_inv x := by
    cases x
    unfold preservesFiniteLimitsOfFlat
    dsimp only [preservesFiniteLimitsOfPreservesFiniteLimitsOfSize]
    

Proof state:
case mk
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
inst✝ : HasFiniteLimits C
F : C ⥤ D
preservesFiniteLimits✝ : (J : Type) → [inst : SmallCategory J] → [inst_1 : FinCategory J] → PreservesLimitsOfShape J F
⊢ PreservesFiniteLimits.mk = PreservesFiniteLimits.mk

Next tactic:
congr
/-- If `C` is finitely cocomplete, then `F : C ⥤ D` is representably flat iff it preserves
finite limits.
-/
noncomputable def preservesFiniteLimitsIffFlat [HasFiniteLimits C] (F : C ⥤ D) :
    RepresentablyFlat F ≃ PreservesFiniteLimits F where
  toFun _ := preservesFiniteLimitsOfFlat F
  invFun _ := flat_of_preservesFiniteLimits F
  left_inv _ := proof_irrel _ _
  right_inv x := by
    cases x
    unfold preservesFiniteLimitsOfFlat
    dsimp only [preservesFiniteLimitsOfPreservesFiniteLimitsOfSize]
    congr
    -- porting note: this next line wasn't needed in lean 3
    

Proof state:
case mk.e_preservesFiniteLimits
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
inst✝ : HasFiniteLimits C
F : C ⥤ D
preservesFiniteLimits✝ : (J : Type) → [inst : SmallCategory J] → [inst_1 : FinCategory J] → PreservesLimitsOfShape J F
⊢ (fun J x x_1 => preservesLimitsOfShapeOfEquiv (ULiftHomULiftCategory.equiv J).symm F) = preservesFiniteLimits✝

Next tactic:
apply Subsingleton.elim