(* ========================================================================= *) (* #73: Erdos-Szekeres theorem on ascending / descending subsequences. *) (* ========================================================================= *) (* ------------------------------------------------------------------------- *) (* Pigeonhole lemma. *) (* ------------------------------------------------------------------------- *) (* ------------------------------------------------------------------------- *) (* Abbreviation for "monotonicity of f on s w.r.t. ordering r". *) (* ------------------------------------------------------------------------- *) (* ------------------------------------------------------------------------- *) (* The main result. *) (* ------------------------------------------------------------------------- *)