When is the homomorphism poset between posets a lattice? Let $P,Q$ be partially ordered sets (posets). We consider the set $\text{Hom}(P,Q)$ of order-preserving functions $f:P\to Q$. There is a natural ordering relation on $\text{Hom}(P,Q)$ given by $f\leq g$ if and only if $f(p) \leq_Q g(p)$ for all $p\in P$.
It is not hard to prove that if $Q$ is a lattice, then so is $\text{Hom}(P,Q)$. Does the converse hold, too?
 A: The answer is yes, and it follows from two observations:
Observation 1: $Q$ is a retract of $\textrm{Hom}(P,Q)$.
Proof: Fix $p^\ast\in P$ and define $r:\text{Hom}(P,Q)\to Q$ by $f\mapsto f(p^\ast)$. It's easy to see that $r$ is order-preserving. Moreover, define $e:Q\to \text{Hom}(P,Q)$ by $q\mapsto c_q$ where $c_q:P\to Q$ is the constant $q$-function. We verify that $r\circ e = \textsf{id}_Q$.
Observation 2: If $L$ is a lattice and $P$ is a poset that is a retract of $L$, then $P$ is a lattice.
Proof: Suppose $e:P\to L$ and $r:L\to P$ are order-preserving maps with $r\circ e = \mathsf{id}_P$. For $a,b\in P$ it suffices to check that $r(e(a)\vee e(b))$ is the least upper bound of $a,b\in P$. It is clearly an upper bound, so suppose we have $c\in P$ with $c\geq a,b$. We want to show that $c \geq r(e(a)\vee e(b))$. Since $e$ is order-preserving, we have $e(c) \geq e(a), e(b)$ therefore $e(c) \geq e(a)\vee e(b)$. Since $r$ is order-preserving, we get $r(e(c)) \geq r(e(a)\vee e(b))$ and since $r\circ e = \mathsf{id}_P$ we have $c=r(e(c)) \geq r(e(a)\vee e(b))$ which concludes the proof.
