Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(* -*- coding: utf-8 -*- *)
(************************************************************************)
(*         *   The Coq Proof Assistant / The Coq Development Team       *)
(*  v      *   INRIA, CNRS and contributors - Copyright 1999-2018       *)
(* <O___,, *       (see CREDITS file for the list of authors)           *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)
Binary Integers : results about order predicates
Initial author : Pierre Crégut (CNET, Lannion, France)
THIS FILE IS DEPRECATED. It is now almost entirely made of compatibility formulations for results already present in BinInt.Z.
Require Import BinPos BinInt Decidable Zcompare.
Require Import Arith_base. (* Useless now, for compatibility only *)

Local Open Scope Z_scope.

(*********************************************************)
Properties of the order relations on binary integers

Trichotomy

n, m:Z

{n < m} + {n = m} + {n > m}
n, m:Z

{n < m} + {n = m} + {n > m}
n, m:Z

{(n ?= m) = Lt} + {n = m} + {(n ?= m) = Gt}
n, m:Z

((n ?= m) = Eq -> n = m) -> {(n ?= m) = Lt} + {n = m} + {(n ?= m) = Gt}
destruct (n ?= m); [ left; right | left; left | right]; auto. Defined.
n, m:Z

n < m \/ n = m \/ n > m
n, m:Z

n < m \/ n = m \/ n > m
n, m:Z

n < m \/ n = m \/ m < n
apply Z.lt_trichotomy. Qed. (**********************************************************************)

Decidability of equality and order on Z

Notation dec_eq := Z.eq_decidable (only parsing).
Notation dec_Zle := Z.le_decidable (only parsing).
Notation dec_Zlt := Z.lt_decidable (only parsing).

n, m:Z

decidable (Zne n m)
n, m:Z

decidable (Zne n m)
destruct (Z.eq_decidable n m); [right|left]; subst; auto. Qed.
n, m:Z

decidable (n > m)
n, m:Z

decidable (n > m)
destruct (Z.lt_decidable m n); [left|right]; Z.swap_greater; auto. Qed.
n, m:Z

decidable (n >= m)
n, m:Z

decidable (n >= m)
destruct (Z.le_decidable m n); [left|right]; Z.swap_greater; auto. Qed.
n, m:Z

n <> m -> n < m \/ m < n
n, m:Z

n <> m -> n < m \/ m < n
apply Z.lt_gt_cases. Qed. Register dec_Zne as plugins.omega.dec_Zne. Register dec_Zgt as plugins.omega.dec_Zgt. Register dec_Zge as plugins.omega.dec_Zge. Register not_Zeq as plugins.omega.not_Zeq.

Relating strict and large orders

Notation Zgt_iff_lt := Z.gt_lt_iff (only parsing).
Notation Zge_iff_le := Z.ge_le_iff (only parsing).

n, m:Z

n <= m -> ~ m < n
n, m:Z

n <= m -> ~ m < n
apply Z.le_ngt. Qed.
n, m:Z

n < m -> ~ m <= n
n, m:Z

n < m -> ~ m <= n
apply Z.lt_nge. Qed.
n, m:Z

n <= m -> ~ n > m
n, m:Z

n <= m -> ~ n > m
trivial. Qed.
n, m:Z

n > m -> ~ n <= m
n, m:Z

n > m -> ~ n <= m
n, m:Z

m < n -> ~ n <= m
apply Z.lt_nge. Qed.
n, m:Z

~ n >= m -> n < m
n, m:Z

~ n >= m -> n < m
n, m:Z

~ m <= n -> n < m
apply Z.nle_gt. Qed.
n, m:Z

~ n < m -> n >= m
n, m:Z

~ n < m -> n >= m
trivial. Qed.
n, m:Z

~ n > m -> n <= m
n, m:Z

~ n > m -> n <= m
trivial. Qed.
n, m:Z

~ n <= m -> n > m
n, m:Z

~ n <= m -> n > m
n, m:Z

~ n <= m -> m < n
apply Z.nle_gt. Qed.
n, m:Z

~ Zne n m -> n = m
n, m:Z

~ Zne n m -> n = m
n, m:Z
H:~ Zne n m

n = m
destruct (Z.eq_decidable n m); [assumption|now elim H]. Qed. Register Znot_le_gt as plugins.omega.Znot_le_gt. Register Znot_lt_ge as plugins.omega.Znot_lt_ge. Register Znot_ge_lt as plugins.omega.Znot_ge_lt. Register Znot_gt_le as plugins.omega.Znot_gt_le. Register not_Zne as plugins.omega.not_Zne.

Equivalence and order properties

Reflexivity
Notation Zeq_le := Z.eq_le_incl (only parsing).

Hint Resolve Z.le_refl: zarith.
Antisymmetry
Notation Zle_antisym := Z.le_antisymm (only parsing).
Asymmetry
Notation Zlt_asym := Z.lt_asymm (only parsing).

n, m:Z

n > m -> ~ m > n
n, m:Z

n > m -> ~ m > n
n, m:Z

m < n -> ~ n < m
apply Z.lt_asymm. Qed.
Irreflexivity
Notation Zlt_not_eq := Z.lt_neq (only parsing).

n:Z

~ n > n
n:Z

~ n > n
n:Z

~ n < n
apply Z.lt_irrefl. Qed.
Large = strict or equal
Notation Zlt_le_weak := Z.lt_le_incl (only parsing).
Notation Zle_lt_or_eq_iff := Z.lt_eq_cases (only parsing).

n, m:Z

n <= m -> n < m \/ n = m
n, m:Z

n <= m -> n < m \/ n = m
apply Z.lt_eq_cases. Qed.
Dichotomy
Notation Zle_or_lt := Z.le_gt_cases (only parsing).
Transitivity of strict orders
n, m, p:Z

n > m -> m > p -> n > p
n, m, p:Z

n > m -> m > p -> n > p
n, m, p:Z

m < n -> p < m -> p < n
intros; now transitivity m. Qed.
Mixed transitivity
n, m, p:Z

m <= n -> m > p -> n > p
n, m, p:Z

m <= n -> m > p -> n > p
n, m, p:Z

m <= n -> p < m -> p < n
Z.order. Qed.
n, m, p:Z

n > m -> p <= m -> n > p
n, m, p:Z

n > m -> p <= m -> n > p
n, m, p:Z

m < n -> p <= m -> p < n
Z.order. Qed.
Transitivity of large orders
n, m, p:Z

n >= m -> m >= p -> n >= p
n, m, p:Z

n >= m -> m >= p -> n >= p
n, m, p:Z

m <= n -> p <= m -> p <= n
Z.order. Qed. Hint Resolve Z.le_trans: zarith.

Compatibility of order and operations on Z

Successor

Compatibility of successor wrt to order
n, m:Z

m <= n -> Z.succ m <= Z.succ n
n, m:Z

m <= n -> Z.succ m <= Z.succ n
apply Z.succ_le_mono. Qed.
n, m:Z

n < m -> Z.succ n < Z.succ m
n, m:Z

n < m -> Z.succ n < Z.succ m
apply Z.succ_lt_mono. Qed.
n, m:Z

m > n -> Z.succ m > Z.succ n
n, m:Z

m > n -> Z.succ m > Z.succ n
n, m:Z

n < m -> Z.succ n < Z.succ m
apply Z.succ_lt_mono. Qed. Hint Resolve Zsucc_le_compat: zarith.
Simplification of successor wrt to order
n, m:Z

Z.succ m > Z.succ n -> m > n
n, m:Z

Z.succ m > Z.succ n -> m > n
n, m:Z

Z.succ n < Z.succ m -> n < m
apply Z.succ_lt_mono. Qed.
n, m:Z

Z.succ m <= Z.succ n -> m <= n
n, m:Z

Z.succ m <= Z.succ n -> m <= n
apply Z.succ_le_mono. Qed.
n, m:Z

Z.succ n < Z.succ m -> n < m
n, m:Z

Z.succ n < Z.succ m -> n < m
apply Z.succ_lt_mono. Qed.
Special base instances of order
Notation Zlt_succ := Z.lt_succ_diag_r (only parsing).
Notation Zlt_pred := Z.lt_pred_l (only parsing).

n:Z

Z.succ n > n
n:Z

Z.succ n > n
n:Z

n < Z.succ n
apply Z.lt_succ_diag_r. Qed.
n:Z

~ Z.succ n <= n
n:Z

~ Z.succ n <= n
apply Z.lt_nge, Z.lt_succ_diag_r. Qed.
Relating strict and large order using successor or predecessor
n, m:Z

m > n -> Z.succ n <= m
n, m:Z

m > n -> Z.succ n <= m
n, m:Z

n < m -> Z.succ n <= m
apply Z.le_succ_l. Qed.
n, m:Z

n <= m -> Z.succ m > n
n, m:Z

n <= m -> Z.succ m > n
n, m:Z

n <= m -> n < Z.succ m
apply Z.lt_succ_r. Qed.
n, m:Z

n <= m -> n < Z.succ m
n, m:Z

n <= m -> n < Z.succ m
apply Z.lt_succ_r. Qed.
n, m:Z

n < m -> Z.succ n <= m
n, m:Z

n < m -> Z.succ n <= m
apply Z.le_succ_l. Qed.
n, m:Z

Z.succ m > n -> n <= m
n, m:Z

Z.succ m > n -> n <= m
n, m:Z

n < Z.succ m -> n <= m
apply Z.lt_succ_r. Qed.
n, m:Z

n < Z.succ m -> n <= m
n, m:Z

n < Z.succ m -> n <= m
apply Z.lt_succ_r. Qed.
n, m:Z

Z.succ n <= m -> m > n
n, m:Z

Z.succ n <= m -> m > n
n, m:Z

Z.succ n <= m -> n < m
apply Z.le_succ_l. Qed.
Weakening order
Notation Zle_succ := Z.le_succ_diag_r (only parsing).
Notation Zle_pred := Z.le_pred_l (only parsing).
Notation Zlt_lt_succ := Z.lt_lt_succ_r (only parsing).
Notation Zle_le_succ := Z.le_le_succ_r (only parsing).

n, m:Z

Z.succ n <= m -> n <= m
n, m:Z

Z.succ n <= m -> n <= m
n, m:Z
H:Z.succ n <= m

n <= m
now apply Z.lt_le_incl, Z.le_succ_l. Qed. Hint Resolve Z.le_succ_diag_r: zarith. Hint Resolve Z.le_le_succ_r: zarith.
Relating order wrt successor and order wrt predecessor
n, m:Z

m > Z.succ n -> Z.pred m > n
n, m:Z

m > Z.succ n -> Z.pred m > n
n, m:Z

Z.succ n < m -> n < Z.pred m
apply Z.lt_succ_lt_pred. Qed.
n, m:Z

Z.succ n < m -> n < Z.pred m
n, m:Z

Z.succ n < m -> n < Z.pred m
apply Z.lt_succ_lt_pred. Qed.
Relating strict order and large order on positive
n:Z

0 < n -> 0 <= Z.pred n
n:Z

0 < n -> 0 <= Z.pred n
apply Z.lt_le_pred. Qed.
n:Z

n > 0 -> 0 <= Z.pred n
n:Z

n > 0 -> 0 <= Z.pred n
n:Z

0 < n -> 0 <= Z.pred n
apply Z.lt_le_pred. Qed.
Special cases of ordered integers

forall p q : positive, Z.neg p <= Z.pos q

forall p q : positive, Z.neg p <= Z.pos q
exact Pos2Z.neg_le_pos. Qed.

forall p : positive, Z.pos p > 0

forall p : positive, Z.pos p > 0
easy. Qed. (* weaker but useful (in [Z.pow] for instance) *)

forall p : positive, 0 <= Z.pos p

forall p : positive, 0 <= Z.pos p
exact Pos2Z.pos_is_nonneg. Qed.

forall p : positive, Z.neg p < 0

forall p : positive, Z.neg p < 0
exact Pos2Z.neg_is_neg. Qed.

forall n : nat, 0 <= Z.of_nat n

forall n : nat, 0 <= Z.of_nat n

0 <= 0
n:nat
IHn:0 <= Z.of_nat n
0 <= Z.pos (Pos.of_succ_nat n)
n:nat
IHn:0 <= Z.of_nat n

0 <= Z.pos (Pos.of_succ_nat n)
easy. Qed. Hint Immediate Z.eq_le_incl: zarith.
Derived lemma
n, m:Z

Z.succ n > m -> n > m \/ m = n
n, m:Z

Z.succ n > m -> n > m \/ m = n
n, m:Z

m < Z.succ n -> m < n \/ m = n
n, m:Z
H:m < Z.succ n

m < n \/ m = n
now apply Z.lt_eq_cases, Z.lt_succ_r. Qed.

Addition

Compatibility of addition wrt to order
Notation Zplus_lt_le_compat := Z.add_lt_le_mono (only parsing).
Notation Zplus_le_lt_compat := Z.add_le_lt_mono (only parsing).
Notation Zplus_le_compat := Z.add_le_mono (only parsing).
Notation Zplus_lt_compat := Z.add_lt_mono (only parsing).

n, m, p:Z

n > m -> p + n > p + m
n, m, p:Z

n > m -> p + n > p + m
n, m, p:Z

m < n -> p + m < p + n
apply Z.add_lt_mono_l. Qed.
n, m, p:Z

n > m -> n + p > m + p
n, m, p:Z

n > m -> n + p > m + p
n, m, p:Z

m < n -> m + p < n + p
apply Z.add_lt_mono_r. Qed.
n, m, p:Z

n <= m -> p + n <= p + m
n, m, p:Z

n <= m -> p + n <= p + m
apply Z.add_le_mono_l. Qed.
n, m, p:Z

n <= m -> n + p <= m + p
n, m, p:Z

n <= m -> n + p <= m + p
apply Z.add_le_mono_r. Qed.
n, m, p:Z

n < m -> p + n < p + m
n, m, p:Z

n < m -> p + n < p + m
apply Z.add_lt_mono_l. Qed.
n, m, p:Z

n < m -> n + p < m + p
n, m, p:Z

n < m -> n + p < m + p
apply Z.add_lt_mono_r. Qed.
Compatibility of addition wrt to being positive
Notation Zplus_le_0_compat := Z.add_nonneg_nonneg (only parsing).
Simplification of addition wrt to order
n, m, p:Z

p + n <= p + m -> n <= m
n, m, p:Z

p + n <= p + m -> n <= m
apply Z.add_le_mono_l. Qed.
n, m, p:Z

n + p <= m + p -> n <= m
n, m, p:Z

n + p <= m + p -> n <= m
apply Z.add_le_mono_r. Qed.
n, m, p:Z

p + n < p + m -> n < m
n, m, p:Z

p + n < p + m -> n < m
apply Z.add_lt_mono_l. Qed.
n, m, p:Z

n + p < m + p -> n < m
n, m, p:Z

n + p < m + p -> n < m
apply Z.add_lt_mono_r. Qed.
n, m, p:Z

p + n > p + m -> n > m
n, m, p:Z

p + n > p + m -> n > m
n, m, p:Z

p + m < p + n -> m < n
apply Z.add_lt_mono_l. Qed.
n, m, p:Z

n + p > m + p -> n > m
n, m, p:Z

n + p > m + p -> n > m
n, m, p:Z

m + p < n + p -> m < n
apply Z.add_lt_mono_r. Qed.

Multiplication

Compatibility of multiplication by a positive wrt to order
n, m, p:Z

n <= m -> 0 <= p -> n * p <= m * p
n, m, p:Z

n <= m -> 0 <= p -> n * p <= m * p
n, m, p:Z
H:n <= m
H0:0 <= p

n * p <= m * p
now apply Z.mul_le_mono_nonneg_r. Qed.
n, m, p:Z

n <= m -> 0 <= p -> p * n <= p * m
n, m, p:Z

n <= m -> 0 <= p -> p * n <= p * m
n, m, p:Z
H:n <= m
H0:0 <= p

p * n <= p * m
now apply Z.mul_le_mono_nonneg_l. Qed.
n, m, p:Z

0 < p -> n < m -> n * p < m * p
n, m, p:Z

0 < p -> n < m -> n * p < m * p
apply Z.mul_lt_mono_pos_r. Qed.
n, m, p:Z

p > 0 -> n > m -> n * p > m * p
n, m, p:Z

p > 0 -> n > m -> n * p > m * p
n, m, p:Z

0 < p -> m < n -> m * p < n * p
apply Z.mul_lt_mono_pos_r. Qed.
n, m, p:Z

p > 0 -> n < m -> n * p < m * p
n, m, p:Z

p > 0 -> n < m -> n * p < m * p
n, m, p:Z

0 < p -> n < m -> n * p < m * p
apply Z.mul_lt_mono_pos_r. Qed.
n, m, p:Z

p > 0 -> n <= m -> n * p <= m * p
n, m, p:Z

p > 0 -> n <= m -> n * p <= m * p
n, m, p:Z

0 < p -> n <= m -> n * p <= m * p
apply Z.mul_le_mono_pos_r. Qed.
n, m, p:Z

0 < p -> n <= m -> n * p <= m * p
n, m, p:Z

0 < p -> n <= m -> n * p <= m * p
apply Z.mul_le_mono_pos_r. Qed.
n, m, p:Z

p > 0 -> n < m -> p * n < p * m
n, m, p:Z

p > 0 -> n < m -> p * n < p * m
n, m, p:Z

0 < p -> n < m -> p * n < p * m
apply Z.mul_lt_mono_pos_l. Qed.
n, m, p:Z

0 < p -> n < m -> p * n < p * m
n, m, p:Z

0 < p -> n < m -> p * n < p * m
apply Z.mul_lt_mono_pos_l. Qed.
n, m, p:Z

p > 0 -> n > m -> p * n > p * m
n, m, p:Z

p > 0 -> n > m -> p * n > p * m
n, m, p:Z

0 < p -> m < n -> p * m < p * n
apply Z.mul_lt_mono_pos_l. Qed.
n, m, p:Z

n >= m -> p >= 0 -> n * p >= m * p
n, m, p:Z

n >= m -> p >= 0 -> n * p >= m * p
n, m, p:Z

m <= n -> 0 <= p -> m * p <= n * p
n, m, p:Z
H:m <= n
H0:0 <= p

m * p <= n * p
now apply Z.mul_le_mono_nonneg_r. Qed.
n, m, p:Z

n >= m -> p >= 0 -> p * n >= p * m
n, m, p:Z

n >= m -> p >= 0 -> p * n >= p * m
n, m, p:Z

m <= n -> 0 <= p -> p * m <= p * n
n, m, p:Z
H:m <= n
H0:0 <= p

p * m <= p * n
now apply Z.mul_le_mono_nonneg_l. Qed.
n, m, p, q:Z

n >= p -> m >= q -> p >= 0 -> q >= 0 -> n * m >= p * q
n, m, p, q:Z

n >= p -> m >= q -> p >= 0 -> q >= 0 -> n * m >= p * q
n, m, p, q:Z

p <= n -> q <= m -> 0 <= p -> 0 <= q -> p * q <= n * m
n, m, p, q:Z
H:p <= n
H0:q <= m
H1:0 <= p
H2:0 <= q

p * q <= n * m
now apply Z.mul_le_mono_nonneg. Qed.
n, m, p, q:Z

n <= p -> m <= q -> 0 <= n -> 0 <= m -> n * m <= p * q
n, m, p, q:Z

n <= p -> m <= q -> 0 <= n -> 0 <= m -> n * m <= p * q
n, m, p, q:Z
H:n <= p
H0:m <= q
H1:0 <= n
H2:0 <= m

n * m <= p * q
now apply Z.mul_le_mono_nonneg. Qed.
Simplification of multiplication by a positive wrt to being positive
n, m, p:Z

p > 0 -> n * p < m * p -> n < m
n, m, p:Z

p > 0 -> n * p < m * p -> n < m
n, m, p:Z

0 < p -> n * p < m * p -> n < m
apply Z.mul_lt_mono_pos_r. Qed.
n, m, p:Z

0 < p -> n * p < m * p -> n < m
n, m, p:Z

0 < p -> n * p < m * p -> n < m
apply Z.mul_lt_mono_pos_r. Qed.
n, m, p:Z

p > 0 -> n * p <= m * p -> n <= m
n, m, p:Z

p > 0 -> n * p <= m * p -> n <= m
n, m, p:Z

0 < p -> n * p <= m * p -> n <= m
apply Z.mul_le_mono_pos_r. Qed.
n, m, p:Z

0 < p -> n * p <= m * p -> n <= m
n, m, p:Z

0 < p -> n * p <= m * p -> n <= m
apply Z.mul_le_mono_pos_r. Qed.
n, m, p:Z

p > 0 -> n * p >= m * p -> n >= m
n, m, p:Z

p > 0 -> n * p >= m * p -> n >= m
n, m, p:Z

0 < p -> m * p <= n * p -> m <= n
apply Z.mul_le_mono_pos_r. Qed.
n, m, p:Z

p > 0 -> n * p > m * p -> n > m
n, m, p:Z

p > 0 -> n * p > m * p -> n > m
n, m, p:Z

0 < p -> m * p < n * p -> m < n
apply Z.mul_lt_mono_pos_r. Qed.
n, m, p, q:Z

0 <= n < p -> 0 <= m < q -> n * m < p * q
n, m, p, q:Z

0 <= n < p -> 0 <= m < q -> n * m < p * q
n, m, p, q:Z
Hn:0 <= n
Hnp:n < p
Hm:0 <= m
Hmq:m < q

n * m < p * q
now apply Z.mul_lt_mono_nonneg. Qed.
n, m, p, q:Z

0 < n <= p -> 0 < m < q -> n * m < p * q
n, m, p, q:Z

0 < n <= p -> 0 < m < q -> n * m < p * q
n, m, p, q:Z
Hn:0 < n
Hnp:n <= p
Hm:0 < m
Hmq:m < q

n * m < p * q
n, m, p, q:Z
Hn:0 < n
Hnp:n <= p
Hm:0 < m
Hmq:m < q

n * m <= p * m
n, m, p, q:Z
Hn:0 < n
Hnp:n <= p
Hm:0 < m
Hmq:m < q
p * m < p * q
n, m, p, q:Z
Hn:0 < n
Hnp:n <= p
Hm:0 < m
Hmq:m < q

p * m < p * q
apply Z.mul_lt_mono_pos_l; Z.order. Qed.
Compatibility of multiplication by a positive wrt to being positive
Notation Zmult_le_0_compat := Z.mul_nonneg_nonneg (only parsing).
Notation Zmult_lt_0_compat := Z.mul_pos_pos (only parsing).
Notation Zmult_lt_O_compat := Z.mul_pos_pos (only parsing).

n, m:Z

n > 0 -> m > 0 -> n * m > 0
n, m:Z

n > 0 -> m > 0 -> n * m > 0
n, m:Z

0 < n -> 0 < m -> 0 < n * m
apply Z.mul_pos_pos. Qed. (* To remove someday ... *)
n, m:Z

n > 0 -> 0 <= m -> 0 <= m * n
n, m:Z

n > 0 -> 0 <= m -> 0 <= m * n
n, m:Z

0 < n -> 0 <= m -> 0 <= m * n
n, m:Z
H:0 < n
H0:0 <= m

0 <= m * n
n, m:Z
H:0 < n
H0:0 <= m

0 <= m
n, m:Z
H:0 < n
H0:0 <= m
0 <= n
n, m:Z
H:0 < n
H0:0 <= m

0 <= n
now apply Z.lt_le_incl. Qed.
Simplification of multiplication by a positive wrt to being positive
n, m:Z

n > 0 -> 0 <= m * n -> 0 <= m
n, m:Z

n > 0 -> 0 <= m * n -> 0 <= m
n, m:Z

0 < n -> 0 <= m * n -> 0 <= m
apply Z.mul_nonneg_cancel_r. Qed.
n, m:Z

0 < n -> 0 < m * n -> 0 < m
n, m:Z

0 < n -> 0 < m * n -> 0 < m
apply Z.mul_pos_cancel_r. Qed.
n, m:Z

n > 0 -> 0 < m * n -> 0 < m
n, m:Z

n > 0 -> 0 < m * n -> 0 < m
n, m:Z

0 < n -> 0 < m * n -> 0 < m
apply Z.mul_pos_cancel_r. Qed.
n, m:Z

n > 0 -> n * m > 0 -> m > 0
n, m:Z

n > 0 -> n * m > 0 -> m > 0
n, m:Z

0 < n -> 0 < n * m -> 0 < m
apply Z.mul_pos_cancel_l. Qed.

Square

Simplification of square wrt order
n, m:Z

0 <= n -> m * m < n * n -> m < n
n, m:Z

0 <= n -> m * m < n * n -> m < n
apply Z.square_lt_simpl_nonneg. Qed.
n, m:Z

n >= 0 -> n * n > m * m -> n > m
n, m:Z

n >= 0 -> n * n > m * m -> n > m
n, m:Z

0 <= n -> m * m < n * n -> m < n
apply Z.square_lt_simpl_nonneg. Qed.

Equivalence between inequalities

Notation Zle_plus_swap := Z.le_add_le_sub_r (only parsing).
Notation Zlt_plus_swap := Z.lt_add_lt_sub_r (only parsing).
Notation Zlt_minus_simpl_swap := Z.lt_sub_pos (only parsing).

n, m, p:Z

n + p = m <-> n = m - p
n, m, p:Z

n + p = m <-> n = m - p
apply Z.add_move_r. Qed.
n, m:Z

0 < n - m -> m < n
n, m:Z

0 < n - m -> m < n
apply Z.lt_0_sub. Qed.
n, m:Z

0 <= n - m -> m <= n
n, m:Z

0 <= n - m -> m <= n
apply Z.le_0_sub. Qed.
n, m:Z

m <= n -> 0 <= n - m
n, m:Z

m <= n -> 0 <= n - m
apply Z.le_0_sub. Qed.
For compatibility
Notation Zlt_O_minus_lt := Zlt_0_minus_lt (only parsing).