(**********************************************************************)
(** * Properties of comparison on binary positive numbers *)

(** First, we express [compare_cont] in term of [compare] *)

Definition switch_Eq c c' :=
 match c' with
  | Eq => c
  | Lt => Lt
  | Gt => Gt
 end.

(* Specifications: *)
Lemma compare_cont_spec p q c : compare_cont c p q = switch_Eq c (p ?= q).
Theorem compare_cont_Eq p q c : compare_cont c p q = Eq -> c = Eq.
Lemma compare_cont_Lt_Gt p q : compare_cont Lt p q = Gt <-> p > q.
Lemma compare_cont_Lt_Lt p q : compare_cont Lt p q = Lt <-> p <= q.
Lemma compare_cont_Gt_Lt p q : compare_cont Gt p q = Lt <-> p < q.
Lemma compare_cont_Gt_Gt p q : compare_cont Gt p q = Gt <-> p >= q.
Lemma compare_cont_Lt_not_Lt p q : compare_cont Lt p q <> Lt <-> p > q.
Lemma compare_cont_Lt_not_Gt p q : compare_cont Lt p q <> Gt <-> p <= q.
Lemma compare_cont_Gt_not_Lt p q : compare_cont Gt p q <> Lt <-> p >= q.
Lemma compare_cont_Gt_not_Gt p q : compare_cont Gt p q <> Gt <-> p < q.
Lemma compare_xO_xO p q : (p~0 ?= q~0) = (p ?= q).
Lemma compare_xI_xI p q : (p~1 ?= q~1) = (p ?= q).
Lemma compare_xI_xO p q : (p~1 ?= q~0) = switch_Eq Gt (p ?= q).
Lemma compare_xO_xI p q : (p~0 ?= q~1) = switch_Eq Lt (p ?= q).