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 Z.compare
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 Export BinPos BinInt. Require Import Lt Gt Plus Mult. (* Useless now, for compatibility only *) Local Open Scope Z_scope. (***************************)
Proof Z.gt_lt_iff.forall n m : Z, (n ?= m) = Gt <-> (m ?= n) = LtProof eq_sym (Z.compare_antisym n m).n, m:ZCompOpp (n ?= m) = (m ?= n)
Proof Z.lt_trans.forall n m p : Z, (n ?= m) = Lt -> (m ?= p) = Lt -> (n ?= p) = Ltforall n m p : Z, (n ?= m) = Gt -> (m ?= p) = Gt -> (n ?= p) = Gtforall n m p : Z, (n ?= m) = Gt -> (m ?= p) = Gt -> (n ?= p) = Gtn, m, p:Z(n ?= m) = Gt -> (m ?= p) = Gt -> (n ?= p) = Gtn, m, p:Zn > m -> m > p -> n > pn, m, p:Zm < n -> p < m -> p < nnow transitivity m. Qed.n, m, p:ZH:m < nH0:p < mp < n
n, m:Z(n ?= m) = (- m ?= - n)n, m:Z(n ?= m) = (- m ?= - n)apply Z.compare_opp. Qed.n, m:Z(- m ?= - n) = (n ?= m)
n, m:Z(n ?= m) = Gt -> exists h : positive, n + - m = Z.pos hn, m:Z(n ?= m) = Gt -> exists h : positive, n + - m = Z.pos hn, m:Z(n - m ?= 0) = Gt -> exists h : positive, n + - m = Z.pos hn, m:Z(n + - m ?= 0) = Gt -> exists h : positive, n + - m = Z.pos hnow exists p. Qed.n, m:Zp:positive(Z.pos p ?= 0) = Gt -> exists h : positive, Z.pos p = Z.pos h
n, m, p:Z(p + n ?= p + m) = (n ?= m)apply Z.add_compare_mono_l. Qed.n, m, p:Z(p + n ?= p + m) = (n ?= m)r:comparisonn, m, p, q:Z(n ?= m) = r -> (p ?= q) = r -> (n + p ?= m + q) = rr:comparisonn, m, p, q:Z(n ?= m) = r -> (p ?= q) = r -> (n + p ?= m + q) = rr:comparisonn, m, p, q:Z(n - m ?= 0) = r -> (p - q ?= 0) = r -> (n + p - (m + q) ?= 0) = rr:comparisonn, m, p, q:Z(n + - m ?= 0) = r -> (p + - q ?= 0) = r -> (n + p + - (m + q) ?= 0) = rr:comparisonn, m, p, q:Z(n + - m ?= 0) = r -> (p + - q ?= 0) = r -> (n + p + (- m + - q) ?= 0) = rdestruct (n+-m), (p+-q); simpl; intros; now subst. Qed.r:comparisonn, m, p, q:Z(n + - m ?= 0) = r -> (p + - q ?= 0) = r -> (n + - m + (p + - q) ?= 0) = rn:Z(Z.succ n ?= n) = Gtn:Z(Z.succ n ?= n) = Gtapply Z.lt_succ_diag_r. Qed.n:Zn < Z.succ nn, m:Z(n ?= m) = Gt <-> (n ?= m + 1) <> Ltn, m:Z(n ?= m) = Gt <-> (n ?= m + 1) <> Ltn, m:Zn > m <-> n >= m + 1n, m:Zm < n <-> m + 1 <= napply Z.le_succ_l. Qed.n, m:Zm + 1 <= n <-> m < n
n, m:Z(Z.succ n ?= Z.succ m) = (n ?= m)n, m:Z(Z.succ n ?= Z.succ m) = (n ?= m)apply Z.add_compare_mono_l. Qed.n, m:Z(1 + n ?= 1 + m) = (n ?= m)
forall (p : positive) (n m : Z), (Z.pos p * n ?= Z.pos p * m) = (n ?= m)intros p [|n|n] [|m|m]; simpl; trivial; now rewrite Pos.mul_compare_mono_l. Qed.forall (p : positive) (n m : Z), (Z.pos p * n ?= Z.pos p * m) = (n ?= m)n, m, p:Zp > 0 -> (n ?= m) = (p * n ?= p * m)n, m, p:Zp > 0 -> (n ?= m) = (p * n ?= p * m)n, m:Zp:positiveH:Z.pos p > 0(n ?= m) = (Z.pos p * n ?= Z.pos p * m)apply Zcompare_mult_compat. Qed.n, m:Zp:positiveH:Z.pos p > 0(Z.pos p * n ?= Z.pos p * m) = (n ?= m)n, m, p:Zp > 0 -> (n ?= m) = (n * p ?= m * p)intros; rewrite 2 (Z.mul_comm _ p); now apply Zmult_compare_compat_l. Qed.n, m, p:Zp > 0 -> (n ?= m) = (n * p ?= m * p)
forall (c1 c2 c3 : Prop) (n m : Z), (n = m -> c1) -> (n < m -> c2) -> (n > m -> c3) -> match n ?= m with | Eq => c1 | Lt => c2 | Gt => c3 endforall (c1 c2 c3 : Prop) (n m : Z), (n = m -> c1) -> (n < m -> c2) -> (n > m -> c3) -> match n ?= m with | Eq => c1 | Lt => c2 | Gt => c3 endc1, c2, c3:Propn, m:ZH:n = m -> c1H0:n < m -> c2H1:n > m -> c3match n ?= m with | Eq => c1 | Lt => c2 | Gt => c3 endnow Z.swap_greater. Qed.c1, c2, c3:Propn, m:ZH:n = m -> c1H0:n < m -> c2H1:n > m -> c3m < n -> c3forall (c1 c2 c3 : Prop) (n m : Z), c1 -> n = m -> match n ?= m with | Eq => c1 | Lt => c2 | Gt => c3 endforall (c1 c2 c3 : Prop) (n m : Z), c1 -> n = m -> match n ?= m with | Eq => c1 | Lt => c2 | Gt => c3 endc1, c2, c3:Propn, m:ZH:c1H0:n = mmatch n ?= m with | Eq => c1 | Lt => c2 | Gt => c3 endnow rewrite Z.compare_refl. Qed.c1, c2, c3:Propm:ZH:c1match m ?= m with | Eq => c1 | Lt => c2 | Gt => c3 endforall n m : Z, n <= m -> match n ?= m with | Gt => False | _ => True endforall n m : Z, n <= m -> match n ?= m with | Gt => False | _ => True endcase Z.compare_spec; trivial; Z.order. Qed.n, m:ZH:n <= mmatch n ?= m with | Gt => False | _ => True endforall n m : Z, n < m -> match n ?= m with | Lt => True | _ => False endintros x y H; now rewrite H. Qed.forall n m : Z, n < m -> match n ?= m with | Lt => True | _ => False endforall n m : Z, n >= m -> match n ?= m with | Lt => False | _ => True endforall n m : Z, n >= m -> match n ?= m with | Lt => False | _ => True endnow case Z.compare_spec. Qed.n, m:ZH:n >= mmatch n ?= m with | Lt => False | _ => True endforall n m : Z, n > m -> match n ?= m with | Gt => True | _ => False endintros x y H; now rewrite H. Qed.forall n m : Z, n > m -> match n ?= m with | Gt => True | _ => False end
Compatibility notations
Notation Zcompare_Eq_eq := Z.compare_eq (only parsing). Notation Zcompare_Eq_iff_eq := Z.compare_eq_iff (only parsing). Notation Zabs_non_eq := Z.abs_neq (only parsing). Notation Zsgn_0 := Z.sgn_null (only parsing). Notation Zsgn_1 := Z.sgn_pos (only parsing). Notation Zsgn_m1 := Z.sgn_neg (only parsing).
Not kept: Zcompare_egal_dec