(* *********************************************************************)
(*                                                                     *)
(*              The Compcert verified compiler                         *)
(*                                                                     *)
(*          Xavier Leroy, INRIA Paris-Rocquencourt                     *)
(*                                                                     *)
(*  Copyright Institut National de Recherche en Informatique et en     *)
(*  Automatique.  All rights reserved.  This file is distributed       *)
(*  under the terms of the GNU General Public License as published by  *)
(*  the Free Software Foundation, either version 2 of the License, or  *)
(*  (at your option) any later version.  This file is also distributed *)
(*  under the terms of the INRIA Non-Commercial License Agreement.     *)
(*                                                                     *)
(* *********************************************************************)
(** Postorder numbering of a directed graph. *)
(** The graph is presented as a finite map from nodes (of type [positive]) to the lists of their successors. *)
Definition node: Type := positive.
Definition graph: Type := PTree.t (list node).
(** A sorting function over lists of positives.  While not necessary for correctness, we process the successors of a node in increasing order. This preserves more of the shape of the original graph and is good for our CFG linearization heuristic. *)
Module PositiveOrd.
Definition t := positive.
Definition leb (x y: t): bool := if plt y x then false else true.

(* Specifications: *)
(*  Infix "<=?" := leb (at level 35). *)
Theorem leb_total : forall x y, is_true (leb x y) \/ is_true (leb y x).
End PositiveOrd.