TITLE: Every partial order can be extended to a linear ordering
QUESTION [40 upvotes]: How do I show that every partial order can be extended to a linear ordering?    
I think that I manage to prove that claim for finite set, how can I prove it for infinite set?
Thank you.

REPLY [21 votes]: You will have to use the axiom of choice (or one of its consequences) in some form. One possibility is to use Zorn’s lemma. Let $\langle P,\le\rangle$ be a partial order. Let $$\mathscr{L}=\big\{\langle X,\preceq_X\rangle:X\subseteq P\text{ and }\preceq_X\text{ is a linear order on }X\\\text{ extending }\le\upharpoonright(X\times X)\}\;.$$
For $\langle X,\preceq_X\rangle,\langle Y,\preceq_Y\rangle\in\mathscr{L}$ define $\langle X,\preceq_X\rangle\sqsubseteq\langle Y,\preceq_Y\rangle$ iff $X\subseteq Y$ and $\preceq_Y\upharpoonright(X\times X)=\preceq_X$; clearly $\langle\mathscr{L},\sqsubseteq\rangle$ is a partial order. Let $\mathscr{C}$ be a chain in $\langle\mathscr{L},\sqsubseteq\rangle$.

Show that $\mathscr{C}$ has an upper bound in $\langle\mathscr{L},\sqsubseteq\rangle$; the most obvious choice works.

Use Zorn’s lemma to conclude that $\langle\mathscr{L},\sqsubseteq\rangle$ has a maximal element $\langle M,\preceq_M\rangle$.

Show that $M=P$.


Added: However, it’s not necessary to use the full axiom of choice: the result follows, for instance, from the Boolean prime ideal theorem, which is strictly weaker than AC. For example, one of the equivalents of the BPI is the compactness theorem for first-order logic, which can be used to give a very simple proof. Let $R$ be a binary relation symbol, and for each $p\in P$ let $c_p$ be a constant symbol. Let $\Phi$ be the set of all sentences $R(c_p,c_q)$ such that $p,q\in P$ and $p\le q$, together with axioms making $R$ a linear order. Then $\Phi$ is finitely satisfiable, so by the compactness theorem $\Phi$ has a model. That model yields a linear extension of $\le$.
Added2: Okay, I like ultrafilters. For $F\in[P]^{<\omega}$ let $U_F=\big\{G\in[P]^{<\omega}:F\subseteq G\big\}$; clearly $\big\{U_F:F\in[P]^{<\omega}\big\}$ is centred (= has the finite intersection property), so it can be extended to an ultrafilter $\mathscr{U}$ on $[P]^{<\omega}$. This requires the ultrafilter extension theorem, which is equivalent to the BPI, but the next step uses AC itself: for each finite $F\subseteq P$ let $\preceq_F$ be a linear order on $F$ that extends $\le\upharpoonright\!\!(F\times F)$, let $\le_F\,=\,\le\cup\preceq_F$, and denote by $P_F$ the partial order $\langle P,\le_F\rangle$.
For $p,q\in P$ write $p\preceq q$ iff $\big\{F\in[P]^{<\omega}:p\le_F q\big\}\in\mathscr{U}$. If $p\le q$, then $p\le_F q$ for all $F\in[P]^{<\omega}$, so $p\preceq q$. Now let $p,q\in P$ with $p\ne q$. Then exactly one of the sets $\big\{G\in U_{\{p,q\}}:p\le_G q\big\}$ and $\big\{G\in U_{\{p,q\}}:q\le_G p\big\}$ belongs to $\mathscr{U}$, so exactly one of $p\preceq q$ and $q\preceq p$ holds. Finally, if $p,q,r\in P$ with $p\preceq q\preceq r$, then
$$\big\{G\in U_{\{p,q,r\}}:p\le_G r\big\}\supseteq\\\big\{G\in U_{\{p,q,r\}}:p\le_G q\big\}\cap\big\{G\in U_{\{p,q,r\}}:q\le_G r\big\}\in\mathscr{U}\;,$$
so $p\preceq r$. Thus, $\preceq$ is a linear order on $P$ extending $\le$.