Library Coq.Numbers.NatInt.NZOrder
Trichotomy
Asymmetry and transitivity.
Some type classes about order
We know enough now to benefit from the generic order tactic.
Some direct consequences of order.
Theorem lt_neq :
forall n m,
n < m ->
n ~= m.
Theorem le_neq :
forall n m,
n < m <-> n <= m /\ n ~= m.
Theorem eq_le_incl :
forall n m,
n == m ->
n <= m.
Lemma lt_stepl :
forall x y z,
x < y ->
x == z ->
z < y.
Lemma lt_stepr :
forall x y z,
x < y ->
y == z ->
x < z.
Lemma le_stepl :
forall x y z,
x <= y ->
x == z ->
z <= y.
Lemma le_stepr :
forall x y z,
x <= y ->
y == z ->
x <= z.
Declare Left Step lt_stepl.
Declare Right Step lt_stepr.
Declare Left Step le_stepl.
Declare Right Step le_stepr.
Theorem le_lt_trans :
forall n m p,
n <= m ->
m < p ->
n < p.
Theorem lt_le_trans :
forall n m p,
n < m ->
m <= p ->
n < p.
Theorem le_antisymm :
forall n m,
n <= m ->
m <= n ->
n == m.
More properties of < and <= with respect to S and 0.
The order tactic enriched with some knowledge of 0,1,2
More Trichotomy, decidability and double negation elimination.
The following theorem is cleary redundant, but helps not to
remember whether one has to say le_gt_cases or lt_ge_cases
Decidability of equality, even though true in each finite ring, does not
have a uniform proof. Otherwise, the proof for two fixed numbers would
reduce to a normal form that will say if the numbers are equal or not,
which cannot be true in all finite rings. Therefore, we prove decidability
in the presence of order.
DNE stands for double-negation elimination
Redundant but useful
Redundant but useful
The difference between integers and natural numbers is that for
every integer there is a predecessor, which is not true for natural
numbers. However, for both classes, every number that is bigger than
some other number has a predecessor. The proof of this fact by regular
induction does not go through, so we need to use strong
(course-of-value) induction.
Stronger variant of induction with assumptions n >= 0 (n < 0)
in the induction step
Section Induction.
Variable A :
t ->
Prop.
Hypothesis A_wd :
Proper (
eq==>iff)
A.
Section Center.
Variable z :
t.
Section RightInduction.
Let A´ (
n :
t) :=
forall m,
z <= m ->
m < n ->
A m.
Let right_step :=
forall n,
z <= n ->
A n ->
A (
S n).
Let right_step´ :=
forall n,
z <= n ->
A´ n ->
A n.
Let right_step´´ :=
forall n,
A´ n <-> A´ (
S n).
Lemma rs_rs´ :
A z ->
right_step ->
right_step´.
Lemma rs´_rs´´ :
right_step´ ->
right_step´´.
Lemma rbase :
A´ z.
Lemma A´A_right : (
forall n,
A´ n) ->
forall n,
z <= n ->
A n.
Theorem strong_right_induction:
right_step´ ->
forall n,
z <= n ->
A n.
Theorem right_induction :
A z ->
right_step ->
forall n,
z <= n ->
A n.
Theorem right_induction´ :
(
forall n,
n <= z ->
A n) ->
right_step ->
forall n,
A n.
Theorem strong_right_induction´ :
(
forall n,
n <= z ->
A n) ->
right_step´ ->
forall n,
A n.
End RightInduction.
Section LeftInduction.
Let A´ (
n :
t) :=
forall m,
m <= z ->
n <= m ->
A m.
Let left_step :=
forall n,
n < z ->
A (
S n) ->
A n.
Let left_step´ :=
forall n,
n <= z ->
A´ (
S n) ->
A n.
Let left_step´´ :=
forall n,
A´ n <-> A´ (
S n).
Lemma ls_ls´ :
A z ->
left_step ->
left_step´.
Lemma ls´_ls´´ :
left_step´ ->
left_step´´.
Lemma lbase :
A´ (
S z).
Lemma A´A_left : (
forall n,
A´ n) ->
forall n,
n <= z ->
A n.
Theorem strong_left_induction:
left_step´ ->
forall n,
n <= z ->
A n.
Theorem left_induction :
A z ->
left_step ->
forall n,
n <= z ->
A n.
Theorem left_induction´ :
(
forall n,
z <= n ->
A n) ->
left_step ->
forall n,
A n.
Theorem strong_left_induction´ :
(
forall n,
z <= n ->
A n) ->
left_step´ ->
forall n,
A n.
End LeftInduction.
Theorem order_induction :
A z ->
(
forall n,
z <= n ->
A n ->
A (
S n)) ->
(
forall n,
n < z ->
A (
S n) ->
A n) ->
forall n,
A n.
Theorem order_induction´ :
A z ->
(
forall n,
z <= n ->
A n ->
A (
S n)) ->
(
forall n,
n <= z ->
A n ->
A (
P n)) ->
forall n,
A n.
End Center.
Theorem order_induction_0 :
A 0 ->
(
forall n, 0
<= n ->
A n ->
A (
S n)) ->
(
forall n,
n < 0 ->
A (
S n) ->
A n) ->
forall n,
A n.
Theorem order_induction´_0 :
A 0 ->
(
forall n, 0
<= n ->
A n ->
A (
S n)) ->
(
forall n,
n <= 0 ->
A n ->
A (
P n)) ->
forall n,
A n.
Elimintation principle for <
Elimination principle for <=
If we have moreover a compare function, we can build
an OrderedType structure.