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
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}destruct (n ?= m); [ left; right | left; left | right]; auto. Defined.n, m:Z((n ?= m) = Eq -> n = m) -> {(n ?= m) = Lt} + {n = m} + {(n ?= m) = Gt}n, m:Zn < m \/ n = m \/ n > mn, m:Zn < m \/ n = m \/ n > mapply Z.lt_trichotomy. Qed. (**********************************************************************)n, m:Zn < m \/ n = m \/ m < n
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:Zdecidable (Zne n m)destruct (Z.eq_decidable n m); [right|left]; subst; auto. Qed.n, m:Zdecidable (Zne n m)n, m:Zdecidable (n > m)destruct (Z.lt_decidable m n); [left|right]; Z.swap_greater; auto. Qed.n, m:Zdecidable (n > m)n, m:Zdecidable (n >= m)destruct (Z.le_decidable m n); [left|right]; Z.swap_greater; auto. Qed.n, m:Zdecidable (n >= m)n, m:Zn <> m -> n < m \/ m < napply 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.n, m:Zn <> m -> n < m \/ m < n
Notation Zgt_iff_lt := Z.gt_lt_iff (only parsing). Notation Zge_iff_le := Z.ge_le_iff (only parsing).n, m:Zn <= m -> ~ m < napply Z.le_ngt. Qed.n, m:Zn <= m -> ~ m < nn, m:Zn < m -> ~ m <= napply Z.lt_nge. Qed.n, m:Zn < m -> ~ m <= nn, m:Zn <= m -> ~ n > mtrivial. Qed.n, m:Zn <= m -> ~ n > mn, m:Zn > m -> ~ n <= mn, m:Zn > m -> ~ n <= mapply Z.lt_nge. Qed.n, m:Zm < n -> ~ n <= mn, m:Z~ n >= m -> n < mn, m:Z~ n >= m -> n < mapply Z.nle_gt. Qed.n, m:Z~ m <= n -> n < mn, m:Z~ n < m -> n >= mtrivial. Qed.n, m:Z~ n < m -> n >= mn, m:Z~ n > m -> n <= mtrivial. Qed.n, m:Z~ n > m -> n <= mn, m:Z~ n <= m -> n > mn, m:Z~ n <= m -> n > mapply Z.nle_gt. Qed.n, m:Z~ n <= m -> m < nn, m:Z~ Zne n m -> n = mn, m:Z~ Zne n m -> n = mdestruct (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.n, m:ZH:~ Zne n mn = m
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:Zn > m -> ~ m > nn, m:Zn > m -> ~ m > napply Z.lt_asymm. Qed.n, m:Zm < n -> ~ n < m
Irreflexivity
Notation Zlt_not_eq := Z.lt_neq (only parsing).n:Z~ n > nn:Z~ n > napply Z.lt_irrefl. Qed.n:Z~ n < n
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:Zn <= m -> n < m \/ n = mapply Z.lt_eq_cases. Qed.n, m:Zn <= m -> n < m \/ n = m
Dichotomy
Notation Zle_or_lt := Z.le_gt_cases (only parsing).
Transitivity of strict orders
n, m, p:Zn > m -> m > p -> n > pn, m, p:Zn > m -> m > p -> n > pintros; now transitivity m. Qed.n, m, p:Zm < n -> p < m -> p < n
Mixed transitivity
n, m, p:Zm <= n -> m > p -> n > pn, m, p:Zm <= n -> m > p -> n > pZ.order. Qed.n, m, p:Zm <= n -> p < m -> p < nn, m, p:Zn > m -> p <= m -> n > pn, m, p:Zn > m -> p <= m -> n > pZ.order. Qed.n, m, p:Zm < n -> p <= m -> p < n
Transitivity of large orders
n, m, p:Zn >= m -> m >= p -> n >= pn, m, p:Zn >= m -> m >= p -> n >= pZ.order. Qed. Hint Resolve Z.le_trans: zarith.n, m, p:Zm <= n -> p <= m -> p <= n
Compatibility of successor wrt to order
n, m:Zm <= n -> Z.succ m <= Z.succ napply Z.succ_le_mono. Qed.n, m:Zm <= n -> Z.succ m <= Z.succ nn, m:Zn < m -> Z.succ n < Z.succ mapply Z.succ_lt_mono. Qed.n, m:Zn < m -> Z.succ n < Z.succ mn, m:Zm > n -> Z.succ m > Z.succ nn, m:Zm > n -> Z.succ m > Z.succ napply Z.succ_lt_mono. Qed. Hint Resolve Zsucc_le_compat: zarith.n, m:Zn < m -> Z.succ n < Z.succ m
Simplification of successor wrt to order
n, m:ZZ.succ m > Z.succ n -> m > nn, m:ZZ.succ m > Z.succ n -> m > napply Z.succ_lt_mono. Qed.n, m:ZZ.succ n < Z.succ m -> n < mn, m:ZZ.succ m <= Z.succ n -> m <= napply Z.succ_le_mono. Qed.n, m:ZZ.succ m <= Z.succ n -> m <= nn, m:ZZ.succ n < Z.succ m -> n < mapply Z.succ_lt_mono. Qed.n, m:ZZ.succ n < Z.succ m -> n < m
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:ZZ.succ n > nn:ZZ.succ n > napply Z.lt_succ_diag_r. Qed.n:Zn < Z.succ nn:Z~ Z.succ n <= napply Z.lt_nge, Z.lt_succ_diag_r. Qed.n:Z~ Z.succ n <= n
Relating strict and large order using successor or predecessor
n, m:Zm > n -> Z.succ n <= mn, m:Zm > n -> Z.succ n <= mapply Z.le_succ_l. Qed.n, m:Zn < m -> Z.succ n <= mn, m:Zn <= m -> Z.succ m > nn, m:Zn <= m -> Z.succ m > napply Z.lt_succ_r. Qed.n, m:Zn <= m -> n < Z.succ mn, m:Zn <= m -> n < Z.succ mapply Z.lt_succ_r. Qed.n, m:Zn <= m -> n < Z.succ mn, m:Zn < m -> Z.succ n <= mapply Z.le_succ_l. Qed.n, m:Zn < m -> Z.succ n <= mn, m:ZZ.succ m > n -> n <= mn, m:ZZ.succ m > n -> n <= mapply Z.lt_succ_r. Qed.n, m:Zn < Z.succ m -> n <= mn, m:Zn < Z.succ m -> n <= mapply Z.lt_succ_r. Qed.n, m:Zn < Z.succ m -> n <= mn, m:ZZ.succ n <= m -> m > nn, m:ZZ.succ n <= m -> m > napply Z.le_succ_l. Qed.n, m:ZZ.succ n <= m -> n < m
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:ZZ.succ n <= m -> n <= mn, m:ZZ.succ n <= m -> n <= mnow 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.n, m:ZH:Z.succ n <= mn <= m
Relating order wrt successor and order wrt predecessor
n, m:Zm > Z.succ n -> Z.pred m > nn, m:Zm > Z.succ n -> Z.pred m > napply Z.lt_succ_lt_pred. Qed.n, m:ZZ.succ n < m -> n < Z.pred mn, m:ZZ.succ n < m -> n < Z.pred mapply Z.lt_succ_lt_pred. Qed.n, m:ZZ.succ n < m -> n < Z.pred m
Relating strict order and large order on positive
n:Z0 < n -> 0 <= Z.pred napply Z.lt_le_pred. Qed.n:Z0 < n -> 0 <= Z.pred nn:Zn > 0 -> 0 <= Z.pred nn:Zn > 0 -> 0 <= Z.pred napply Z.lt_le_pred. Qed.n:Z0 < n -> 0 <= Z.pred n
Special cases of ordered integers
forall p q : positive, Z.neg p <= Z.pos qexact Pos2Z.neg_le_pos. Qed.forall p q : positive, Z.neg p <= Z.pos qforall p : positive, Z.pos p > 0easy. Qed. (* weaker but useful (in [Z.pow] for instance) *)forall p : positive, Z.pos p > 0forall p : positive, 0 <= Z.pos pexact Pos2Z.pos_is_nonneg. Qed.forall p : positive, 0 <= Z.pos pforall p : positive, Z.neg p < 0exact Pos2Z.neg_is_neg. Qed.forall p : positive, Z.neg p < 0forall n : nat, 0 <= Z.of_nat nforall n : nat, 0 <= Z.of_nat n0 <= 0n:natIHn:0 <= Z.of_nat n0 <= Z.pos (Pos.of_succ_nat n)easy. Qed. Hint Immediate Z.eq_le_incl: zarith.n:natIHn:0 <= Z.of_nat n0 <= Z.pos (Pos.of_succ_nat n)
Derived lemma
n, m:ZZ.succ n > m -> n > m \/ m = nn, m:ZZ.succ n > m -> n > m \/ m = nn, m:Zm < Z.succ n -> m < n \/ m = nnow apply Z.lt_eq_cases, Z.lt_succ_r. Qed.n, m:ZH:m < Z.succ nm < n \/ m = n
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:Zn > m -> p + n > p + mn, m, p:Zn > m -> p + n > p + mapply Z.add_lt_mono_l. Qed.n, m, p:Zm < n -> p + m < p + nn, m, p:Zn > m -> n + p > m + pn, m, p:Zn > m -> n + p > m + papply Z.add_lt_mono_r. Qed.n, m, p:Zm < n -> m + p < n + pn, m, p:Zn <= m -> p + n <= p + mapply Z.add_le_mono_l. Qed.n, m, p:Zn <= m -> p + n <= p + mn, m, p:Zn <= m -> n + p <= m + papply Z.add_le_mono_r. Qed.n, m, p:Zn <= m -> n + p <= m + pn, m, p:Zn < m -> p + n < p + mapply Z.add_lt_mono_l. Qed.n, m, p:Zn < m -> p + n < p + mn, m, p:Zn < m -> n + p < m + papply Z.add_lt_mono_r. Qed.n, m, p:Zn < m -> n + p < m + p
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:Zp + n <= p + m -> n <= mapply Z.add_le_mono_l. Qed.n, m, p:Zp + n <= p + m -> n <= mn, m, p:Zn + p <= m + p -> n <= mapply Z.add_le_mono_r. Qed.n, m, p:Zn + p <= m + p -> n <= mn, m, p:Zp + n < p + m -> n < mapply Z.add_lt_mono_l. Qed.n, m, p:Zp + n < p + m -> n < mn, m, p:Zn + p < m + p -> n < mapply Z.add_lt_mono_r. Qed.n, m, p:Zn + p < m + p -> n < mn, m, p:Zp + n > p + m -> n > mn, m, p:Zp + n > p + m -> n > mapply Z.add_lt_mono_l. Qed.n, m, p:Zp + m < p + n -> m < nn, m, p:Zn + p > m + p -> n > mn, m, p:Zn + p > m + p -> n > mapply Z.add_lt_mono_r. Qed.n, m, p:Zm + p < n + p -> m < n
Compatibility of multiplication by a positive wrt to order
n, m, p:Zn <= m -> 0 <= p -> n * p <= m * pn, m, p:Zn <= m -> 0 <= p -> n * p <= m * pnow apply Z.mul_le_mono_nonneg_r. Qed.n, m, p:ZH:n <= mH0:0 <= pn * p <= m * pn, m, p:Zn <= m -> 0 <= p -> p * n <= p * mn, m, p:Zn <= m -> 0 <= p -> p * n <= p * mnow apply Z.mul_le_mono_nonneg_l. Qed.n, m, p:ZH:n <= mH0:0 <= pp * n <= p * mn, m, p:Z0 < p -> n < m -> n * p < m * papply Z.mul_lt_mono_pos_r. Qed.n, m, p:Z0 < p -> n < m -> n * p < m * pn, m, p:Zp > 0 -> n > m -> n * p > m * pn, m, p:Zp > 0 -> n > m -> n * p > m * papply Z.mul_lt_mono_pos_r. Qed.n, m, p:Z0 < p -> m < n -> m * p < n * pn, m, p:Zp > 0 -> n < m -> n * p < m * pn, m, p:Zp > 0 -> n < m -> n * p < m * papply Z.mul_lt_mono_pos_r. Qed.n, m, p:Z0 < p -> n < m -> n * p < m * pn, m, p:Zp > 0 -> n <= m -> n * p <= m * pn, m, p:Zp > 0 -> n <= m -> n * p <= m * papply Z.mul_le_mono_pos_r. Qed.n, m, p:Z0 < p -> n <= m -> n * p <= m * pn, m, p:Z0 < p -> n <= m -> n * p <= m * papply Z.mul_le_mono_pos_r. Qed.n, m, p:Z0 < p -> n <= m -> n * p <= m * pn, m, p:Zp > 0 -> n < m -> p * n < p * mn, m, p:Zp > 0 -> n < m -> p * n < p * mapply Z.mul_lt_mono_pos_l. Qed.n, m, p:Z0 < p -> n < m -> p * n < p * mn, m, p:Z0 < p -> n < m -> p * n < p * mapply Z.mul_lt_mono_pos_l. Qed.n, m, p:Z0 < p -> n < m -> p * n < p * mn, m, p:Zp > 0 -> n > m -> p * n > p * mn, m, p:Zp > 0 -> n > m -> p * n > p * mapply Z.mul_lt_mono_pos_l. Qed.n, m, p:Z0 < p -> m < n -> p * m < p * nn, m, p:Zn >= m -> p >= 0 -> n * p >= m * pn, m, p:Zn >= m -> p >= 0 -> n * p >= m * pn, m, p:Zm <= n -> 0 <= p -> m * p <= n * pnow apply Z.mul_le_mono_nonneg_r. Qed.n, m, p:ZH:m <= nH0:0 <= pm * p <= n * pn, m, p:Zn >= m -> p >= 0 -> p * n >= p * mn, m, p:Zn >= m -> p >= 0 -> p * n >= p * mn, m, p:Zm <= n -> 0 <= p -> p * m <= p * nnow apply Z.mul_le_mono_nonneg_l. Qed.n, m, p:ZH:m <= nH0:0 <= pp * m <= p * nn, m, p, q:Zn >= p -> m >= q -> p >= 0 -> q >= 0 -> n * m >= p * qn, m, p, q:Zn >= p -> m >= q -> p >= 0 -> q >= 0 -> n * m >= p * qn, m, p, q:Zp <= n -> q <= m -> 0 <= p -> 0 <= q -> p * q <= n * mnow apply Z.mul_le_mono_nonneg. Qed.n, m, p, q:ZH:p <= nH0:q <= mH1:0 <= pH2:0 <= qp * q <= n * mn, m, p, q:Zn <= p -> m <= q -> 0 <= n -> 0 <= m -> n * m <= p * qn, m, p, q:Zn <= p -> m <= q -> 0 <= n -> 0 <= m -> n * m <= p * qnow apply Z.mul_le_mono_nonneg. Qed.n, m, p, q:ZH:n <= pH0:m <= qH1:0 <= nH2:0 <= mn * m <= p * q
Simplification of multiplication by a positive wrt to being positive
n, m, p:Zp > 0 -> n * p < m * p -> n < mn, m, p:Zp > 0 -> n * p < m * p -> n < mapply Z.mul_lt_mono_pos_r. Qed.n, m, p:Z0 < p -> n * p < m * p -> n < mn, m, p:Z0 < p -> n * p < m * p -> n < mapply Z.mul_lt_mono_pos_r. Qed.n, m, p:Z0 < p -> n * p < m * p -> n < mn, m, p:Zp > 0 -> n * p <= m * p -> n <= mn, m, p:Zp > 0 -> n * p <= m * p -> n <= mapply Z.mul_le_mono_pos_r. Qed.n, m, p:Z0 < p -> n * p <= m * p -> n <= mn, m, p:Z0 < p -> n * p <= m * p -> n <= mapply Z.mul_le_mono_pos_r. Qed.n, m, p:Z0 < p -> n * p <= m * p -> n <= mn, m, p:Zp > 0 -> n * p >= m * p -> n >= mn, m, p:Zp > 0 -> n * p >= m * p -> n >= mapply Z.mul_le_mono_pos_r. Qed.n, m, p:Z0 < p -> m * p <= n * p -> m <= nn, m, p:Zp > 0 -> n * p > m * p -> n > mn, m, p:Zp > 0 -> n * p > m * p -> n > mapply Z.mul_lt_mono_pos_r. Qed.n, m, p:Z0 < p -> m * p < n * p -> m < nn, m, p, q:Z0 <= n < p -> 0 <= m < q -> n * m < p * qn, m, p, q:Z0 <= n < p -> 0 <= m < q -> n * m < p * qnow apply Z.mul_lt_mono_nonneg. Qed.n, m, p, q:ZHn:0 <= nHnp:n < pHm:0 <= mHmq:m < qn * m < p * qn, m, p, q:Z0 < n <= p -> 0 < m < q -> n * m < p * qn, m, p, q:Z0 < n <= p -> 0 < m < q -> n * m < p * qn, m, p, q:ZHn:0 < nHnp:n <= pHm:0 < mHmq:m < qn * m < p * qn, m, p, q:ZHn:0 < nHnp:n <= pHm:0 < mHmq:m < qn * m <= p * mn, m, p, q:ZHn:0 < nHnp:n <= pHm:0 < mHmq:m < qp * m < p * qapply Z.mul_lt_mono_pos_l; Z.order. Qed.n, m, p, q:ZHn:0 < nHnp:n <= pHm:0 < mHmq:m < qp * m < p * q
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:Zn > 0 -> m > 0 -> n * m > 0n, m:Zn > 0 -> m > 0 -> n * m > 0apply Z.mul_pos_pos. Qed. (* To remove someday ... *)n, m:Z0 < n -> 0 < m -> 0 < n * mn, m:Zn > 0 -> 0 <= m -> 0 <= m * nn, m:Zn > 0 -> 0 <= m -> 0 <= m * nn, m:Z0 < n -> 0 <= m -> 0 <= m * nn, m:ZH:0 < nH0:0 <= m0 <= m * nn, m:ZH:0 < nH0:0 <= m0 <= mn, m:ZH:0 < nH0:0 <= m0 <= nnow apply Z.lt_le_incl. Qed.n, m:ZH:0 < nH0:0 <= m0 <= n
Simplification of multiplication by a positive wrt to being positive
n, m:Zn > 0 -> 0 <= m * n -> 0 <= mn, m:Zn > 0 -> 0 <= m * n -> 0 <= mapply Z.mul_nonneg_cancel_r. Qed.n, m:Z0 < n -> 0 <= m * n -> 0 <= mn, m:Z0 < n -> 0 < m * n -> 0 < mapply Z.mul_pos_cancel_r. Qed.n, m:Z0 < n -> 0 < m * n -> 0 < mn, m:Zn > 0 -> 0 < m * n -> 0 < mn, m:Zn > 0 -> 0 < m * n -> 0 < mapply Z.mul_pos_cancel_r. Qed.n, m:Z0 < n -> 0 < m * n -> 0 < mn, m:Zn > 0 -> n * m > 0 -> m > 0n, m:Zn > 0 -> n * m > 0 -> m > 0apply Z.mul_pos_cancel_l. Qed.n, m:Z0 < n -> 0 < n * m -> 0 < m
Simplification of square wrt order
n, m:Z0 <= n -> m * m < n * n -> m < napply Z.square_lt_simpl_nonneg. Qed.n, m:Z0 <= n -> m * m < n * n -> m < nn, m:Zn >= 0 -> n * n > m * m -> n > mn, m:Zn >= 0 -> n * n > m * m -> n > mapply Z.square_lt_simpl_nonneg. Qed.n, m:Z0 <= n -> m * m < n * n -> m < n
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:Zn + p = m <-> n = m - papply Z.add_move_r. Qed.n, m, p:Zn + p = m <-> n = m - pn, m:Z0 < n - m -> m < napply Z.lt_0_sub. Qed.n, m:Z0 < n - m -> m < nn, m:Z0 <= n - m -> m <= napply Z.le_0_sub. Qed.n, m:Z0 <= n - m -> m <= nn, m:Zm <= n -> 0 <= n - mapply Z.le_0_sub. Qed.n, m:Zm <= n -> 0 <= n - m
For compatibility
Notation Zlt_O_minus_lt := Zlt_0_minus_lt (only parsing).