The following theorem is due to Dilworth : Let P be a partially ordered set. If the maximal number of elements in an independent subset (anti-chain) of P is k, then P is the union of k chains (cliques).
In this article we formalize an elegant proof of the above theorem for finite posets by Perles . The result is then used in proving the case of infinite posets following the original proof of Dilworth .
A dual of Dilworth's theorem also holds: a poset with maximum clique m is a union of m independent sets. The proof of this dual fact is considerably easier; we follow the proof by Mirsky . Mirsky states also a corollary that a poset of r x s + 1 elements possesses a clique of size r + 1 or an independent set of size s + 1, or both. This corollary is then used to prove the result of Erdős and Szekeres .
Instead of using posets, we drop reflexivity and state the facts about anti-symmetric and transitive relations.
 Grzegorz Bancerek. Cardinal numbers. Formalized Mathematics, 1(2):377-382, 1990.
 Grzegorz Bancerek. The fundamental properties of natural numbers. Formalized Mathematics, 1(1):41-46, 1990.
 Grzegorz Bancerek. The ordinal numbers. Formalized Mathematics, 1(1):91-96, 1990.
 Grzegorz Bancerek. Bounds in posets and relational substructures. Formalized Mathematics, 6(1):81-91, 1997.
 Grzegorz Bancerek. Directed sets, nets, ideals, filters, and maps. Formalized Mathematics, 6(1):93-107, 1997.
 Czesław Byliński. Some basic properties of sets. Formalized Mathematics, 1(1):47-53, 1990.