Section nat_hsOrd.
#[local]
Instance nat_isProset : isProset nat :=
{ leProp := Nat.le
; Proset_isSetoid := mkSetoid_from_eq
; leProp_PreOrder := Nat.le_preorder
; leProp_PartialOrder := Nat.le_partialorder
}.
Fixpoint nat_compare (x : nat) (y : nat) {struct x} : comparison :=
match x, y with
| O, O => Eq
| O, S y' => Lt
| S x', O => Gt
| S x', S y' => nat_compare x' y'
end.
Proof with eauto with *.
revert x y hyp_lt. induction x as [ | x IH], y as [ | y]; simpl; ii.
- inversion hyp_lt.
- split; lia.
- inversion hyp_lt.
- pose proof (IH y hyp_lt) as [x_le_y x_ne_y]. split; lia.
Qed.
Proof with eauto with *.
revert x y hyp_eq. induction x as [ | x IH], y as [ | y]; simpl; ii.
- reflexivity.
- inversion hyp_eq.
- inversion hyp_eq.
- pose proof (IH y hyp_eq) as x_eq_y. f_equal. exact x_eq_y.
Qed.

Lemma nat_compare_gt (x : nat) (y : nat)
(hyp_gt : nat_compare x y = Gt)
: y <= x /\ x <> y.