Solution (source code)

= Solution

A <cocone under a diagram> $D:\mathcal J\to\mathcal C$ with vertex $X$ is a natural family $\lambda_j:Dj\to X$, so $\lambda_kD(u)=\lambda_j$ for every $u:j\to k$. A <colimit> of $D$ is an initial such cocone: for every cocone $\lambda:D\Rightarrow\Delta X$, there is a unique $h:\operatorname{colim}D\to X$ with $h\iota_j=\lambda_j$ for all $j$.

Let $F:\mathcal I\to\mathcal J$ be a <final functor> and let $\lambda_i:D(Fi)\to X$ be a cocone under $DF$. For each $j$, choose an object $(i,u:j\to Fi)$ of the nonempty <comma category> $(j\downarrow F)$ and define
$$
\bar\lambda_j=\lambda_iD(u):D(j)\to X.
$$
A morphism $(i,u)\to(i',u')$ in the comma category gives $F(v)u=u'$, and the cocone identity shows that the two resulting maps are equal. Because $(j\downarrow F)$ is a <connected category>, a zigzag proves independence of the chosen object. The same construction applied after a morphism $j\to k$ proves naturality, so $\bar\lambda$ is a cocone. Any extension must have this value because it must satisfy the cocone identity along $u$, proving uniqueness. This is <cocone extension along a final functor>.

If $L$ is a colimit of $DF$, its universal cocone extends uniquely to $D$. Restriction and extension give mutually inverse correspondences between cocones from $D$ and from $DF$, so the extended cocone is a colimit of $D$. Therefore the existence of all colimits of shape $\mathcal I$ implies the required colimits of shape $\mathcal J$.

Now suppose $\mathcal J$ is a <sifted category>. For $D,E:\mathcal J\to\mathbf{Set}$, the product functor $-\times A$ is a <left adjoint>, so it preserves colimits. Applying this once in each variable gives
$$
\left(\operatorname*{colim}_{j\in\mathcal J}D_j\right)
\times
\left(\operatorname*{colim}_{k\in\mathcal J}E_k\right)
\cong
\operatorname*{colim}_{(j,k)\in\mathcal J\times\mathcal J}(D_j\times E_k).
$$
The diagonal $\Delta:\mathcal J\to\mathcal J\times\mathcal J$ is final, so the right side is
$$
\operatorname*{colim}_{j\in\mathcal J}(D_j\times E_j).
$$
Thus $\operatorname{colim}_{\mathcal J}$ preserves binary <products in a category>. Since $\mathcal J$ is connected, the colimit of the constant singleton diagram is a singleton, so it also preserves the <terminal object>. It therefore preserves finite products.