/--
`extendAlongYoneda A` is an extension of `A` to the presheaf category along the yoneda embedding.
`uniqueExtensionAlongYoneda` shows it is unique among functors preserving colimits with this
property (up to isomorphism).

The first part of [MM92], Chapter I, Section 5, Corollary 4.
See Property 1 of <https://ncatlab.org/nlab/show/Yoneda+extension#properties>.
-/
noncomputable def isExtensionAlongYoneda :
    (yoneda : C ⥤ Cᵒᵖ ⥤ Type u₁) ⋙ extendAlongYoneda A ≅ A :=
  NatIso.ofComponents
    (fun X =>
      (colimit.isColimit _).coconePointUniqueUpToIso
        (colimitOfDiagramTerminal (terminalOpOfInitial (isInitial _)) _))
    (by
      intro X Y f
      -- porting note: this is slightly different to the `change` in mathlib3 which
      -- didn't work
      change (colimit.desc _ _ ≫ _) = colimit.desc _ _ ≫ _
      ext
      

Proof state:
case w
C : Type u₁
inst✝² : SmallCategory C
ℰ : Type u₂
inst✝¹ : Category.{u₁, u₂} ℰ
A : C ⥤ ℰ
inst✝ : HasColimits ℰ
X Y : C
f : X ⟶ Y
j✝ : (Functor.Elements (yoneda.obj X))ᵒᵖ
⊢ colimit.ι ((CategoryOfElements.π (yoneda.obj X)).leftOp ⋙ A) j✝ ≫
      colimit.desc ((CategoryOfElements.π (yoneda.obj X)).leftOp ⋙ A)
          { pt := (fun P => (colimit.cocone ((CategoryOfElements.π P).leftOp ⋙ A)).pt) (yoneda.obj Y),
            ι :=
              (Iso.mk
                    (fun ι =>
                      { val := fun j => ι.app j,
                        property :=
                          (_ :
                            ∀ {j j' : (Functor.Elements (yoneda.obj X))ᵒᵖ} (f : j ⟶ j'),
                              ((CategoryOfElements.π (yoneda.obj X)).leftOp ⋙ A).map f ≫ (fun j => ι.app j) j' =
                                (fun j => ι.app j) j) })
                    fun p => NatTrans.mk fun j => ↑p j).inv
                ({ toFun := fun k => NatTrans.mk fun c p => ↑k (Opposite.op { fst := c, snd := p }),
                      invFun := fun τ =>
                        { val := fun p => τ.app p.unop.fst p.unop.snd,
                          property :=
                            (_ :
                              ∀ (p p' : (Functor.Elements (yoneda.obj X))ᵒᵖ) (f : p ⟶ p'),
                                ((CategoryOfElements.π (yoneda.obj X)).leftOp ⋙ A).map f ≫
                                    (fun p => τ.app p.unop.fst p.unop.snd) p' =
                                  (fun p => τ.app p.unop.fst p.unop.snd) p) },
                      left_inv :=
                        (_ :
                          ∀
                            (x :
                              { p //
                                ∀ {j j' : (Functor.Elements (yoneda.obj X))ᵒᵖ} (f : j ⟶ j'),
                                  ((CategoryOfElements.π (yoneda.obj X)).leftOp ⋙ A).map f ≫ p j' = p j }),
                            (fun τ =>
                                  { val := fun p => τ.app p.unop.fst p.unop.snd,
                                    property :=
                                      (_ :
                                        ∀ (p p' : (Functor.Elements (yoneda.obj X))ᵒᵖ) (f : p ⟶ p'),
                                          ((CategoryOfElements.π (yoneda.obj X)).leftOp ⋙ A).map f ≫
                                              (fun p => τ.app p.unop.fst p.unop.snd) p' =
                                            (fun p => τ.app p.unop.fst p.unop.snd) p) })
                                ((fun k => NatTrans.mk fun c p => ↑k (Opposite.op { fst := c, snd := p })) x) =
                              x),
                      right_inv :=
                        (_ :
                          ∀
                            (x :
                              yoneda.obj X ⟶
                                (restrictedYoneda A).obj
                                  ((fun P => (colimit.cocone ((CategoryOfElements.π P).leftOp ⋙ A)).pt)
                                    (yoneda.obj Y))),
                            (fun k => NatTrans.mk fun c p => ↑k (Opposite.op { fst := c, snd := p }))
                                ((fun τ =>
                                    { val := fun p => τ.app p.unop.fst p.unop.snd,
                                      property :=
                                        (_ :
                                          ∀ (p p' : (Functor.Elements (yoneda.obj X))ᵒᵖ) (f : p ⟶ p'),
                                            ((CategoryOfElements.π (yoneda.obj X)).leftOp ⋙ A).map f ≫
                                                (fun p => τ.app p.unop.fst p.unop.snd) p' =
                                              (fun p => τ.app p.unop.fst p.unop.snd) p) })
                                  x) =
                              x) }.symm
                  (yoneda.map f ≫
                    ((fun P E => restrictYonedaHomEquiv A P E (colimit.isColimit ((CategoryOfElements.π P).leftOp ⋙ A)))
                        (yoneda.obj Y)
                        ((fun P => (colimit.cocone ((CategoryOfElements.π P).leftOp ⋙ A)).pt) (yoneda.obj Y)))
                      (𝟙 ((fun P => (colimit.cocone ((CategoryOfElements.π P).leftOp ⋙ A)).pt) (yoneda.obj Y))))) } ≫
        ((fun X =>
              IsColimit.coconePointUniqueUpToIso (colimit.isColimit ((CategoryOfElements.π (yoneda.obj X)).leftOp ⋙ A))
                (colimitOfDiagramTerminal (terminalOpOfInitial (isInitial X))
                  ((CategoryOfElements.π (yoneda.obj X)).leftOp ⋙ A)))
            Y).hom =
    colimit.ι ((CategoryOfElements.π (yoneda.obj X)).leftOp ⋙ A) j✝ ≫
      colimit.desc ((CategoryOfElements.π (yoneda.obj X)).leftOp ⋙ A)
          (coconeOfDiagramTerminal (terminalOpOfInitial (isInitial X))
            ((CategoryOfElements.π (yoneda.obj X)).leftOp ⋙ A)) ≫
        A.map f

Next tactic:
rw [colimit.ι_desc_assoc, colimit.ι_desc_assoc]