Library Coq.Arith.Compare_dec
Proofs of decidability
A ternary comparison function in the spirit of Z.compare.
Fixpoint nat_compare n m :=
match n,
m with
|
O,
O =>
Eq
|
O,
S _ =>
Lt
|
S _,
O =>
Gt
|
S n´,
S m´ =>
nat_compare n´ m´
end.
Lemma nat_compare_S :
forall n m,
nat_compare (
S n) (
S m)
= nat_compare n m.
Lemma nat_compare_eq_iff :
forall n m,
nat_compare n m = Eq <-> n = m.
Lemma nat_compare_eq :
forall n m,
nat_compare n m = Eq ->
n = m.
Lemma nat_compare_lt :
forall n m,
n<m <-> nat_compare n m = Lt.
Lemma nat_compare_gt :
forall n m,
n>m <-> nat_compare n m = Gt.
Lemma nat_compare_le :
forall n m,
n<=m <-> nat_compare n m <> Gt.
Lemma nat_compare_ge :
forall n m,
n>=m <-> nat_compare n m <> Lt.
Lemma nat_compare_spec :
forall x y,
CompareSpec (
x=y) (
x<y) (
y<x) (
nat_compare x y).
Some projections of the above equivalences.
A previous definition of nat_compare in terms of lt_eq_lt_dec.
The new version avoids the creation of proof parts.
A boolean version of le over nat.