Module PositiveOrderedTypeBits <: UsualOrderedType.
Definition t:=positive.
Include HasUsualEq <+ UsualIsEq.
Definition eqb := Pos.eqb.
Definition eqb_eq := Pos.eqb_eq.
Include HasEqBool2Dec.
Fixpoint bits_lt (p q:positive) : Prop :=
match p, q with
| xH, xI _ => True
| xH, _ => False
| xO p, xO q => bits_lt p q
| xO _, _ => True
| xI p, xI q => bits_lt p q
| xI _, _ => False
end.
Definition lt:=bits_lt.
Instance lt_compat : Proper (eq==>eq==>iff) lt.
Instance lt_strorder : StrictOrder lt.
Fixpoint compare x y :=
match x, y with
| x~1, y~1 => compare x y
| x~1, _ => Gt
| x~0, y~0 => compare x y
| x~0, _ => Lt
| 1, y~1 => Lt
| 1, 1 => Eq
| 1, y~0 => Gt
end.

Lemma compare_spec : forall x y, CompSpec eq lt x y (compare x y).