1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * This file is distributed under the terms of the *)
6
(* * GNU Lesser General Public License Version 2.1 *)
7
(************************************************************************)
9
(*i $Id: auxiliary.v 11739 2009-01-02 19:33:19Z herbelin $ i*)
11
(** Binary Integers (Pierre Cr�gut, CNET, Lannion, France) *)
13
Require Export Arith_base.
14
Require Import BinInt.
15
Require Import Zorder.
16
Require Import Decidable.
17
Require Import Peano_dec.
18
Require Export Compare_dec.
20
Open Local Scope Z_scope.
22
(***************************************************************)
23
(** * Moving terms from one side to the other of an inequality *)
25
Theorem Zne_left : forall n m:Z, Zne n m -> Zne (n + - m) 0.
27
intros x y; unfold Zne in |- *; unfold not in |- *; intros H1 H2; apply H1;
28
apply Zplus_reg_l with (- y); rewrite Zplus_opp_l;
29
rewrite Zplus_comm; trivial with arith.
32
Theorem Zegal_left : forall n m:Z, n = m -> n + - m = 0.
34
intros x y H; apply (Zplus_reg_l y); rewrite Zplus_permute;
35
rewrite Zplus_opp_r; do 2 rewrite Zplus_0_r; assumption.
38
Theorem Zle_left : forall n m:Z, n <= m -> 0 <= m + - n.
40
intros x y H; replace 0 with (x + - x).
41
apply Zplus_le_compat_r; trivial.
45
Theorem Zle_left_rev : forall n m:Z, 0 <= m + - n -> n <= m.
47
intros x y H; apply Zplus_le_reg_r with (- x).
48
rewrite Zplus_opp_r; trivial.
51
Theorem Zlt_left_rev : forall n m:Z, 0 < m + - n -> n < m.
53
intros x y H; apply Zplus_lt_reg_r with (- x).
54
rewrite Zplus_opp_r; trivial.
57
Theorem Zlt_left : forall n m:Z, n < m -> 0 <= m + -1 + - n.
59
intros x y H; apply Zle_left; apply Zsucc_le_reg;
60
change (Zsucc x <= Zsucc (Zpred y)) in |- *; rewrite <- Zsucc_pred;
61
apply Zlt_le_succ; assumption.
64
Theorem Zlt_left_lt : forall n m:Z, n < m -> 0 < m + - n.
66
intros x y H; replace 0 with (x + - x).
67
apply Zplus_lt_compat_r; trivial.
71
Theorem Zge_left : forall n m:Z, n >= m -> 0 <= n + - m.
73
intros x y H; apply Zle_left; apply Zge_le; assumption.
76
Theorem Zgt_left : forall n m:Z, n > m -> 0 <= n + -1 + - m.
78
intros x y H; apply Zlt_left; apply Zgt_lt; assumption.
81
Theorem Zgt_left_gt : forall n m:Z, n > m -> n + - m > 0.
83
intros x y H; replace 0 with (y + - y).
84
apply Zplus_gt_compat_r; trivial.
88
Theorem Zgt_left_rev : forall n m:Z, n + - m > 0 -> n > m.
90
intros x y H; apply Zplus_gt_reg_r with (- y).
91
rewrite Zplus_opp_r; trivial.
94
Theorem Zle_mult_approx :
95
forall n m p:Z, n > 0 -> p > 0 -> 0 <= m -> 0 <= m * n + p.
97
intros x y z H1 H2 H3; apply Zle_trans with (m := y * x);
98
[ apply Zmult_gt_0_le_0_compat; assumption
99
| pattern (y * x) at 1 in |- *; rewrite <- Zplus_0_r;
100
apply Zplus_le_compat_l; apply Zlt_le_weak; apply Zgt_lt;
104
Theorem Zmult_le_approx :
105
forall n m p:Z, n > 0 -> n > p -> 0 <= m * n + p -> 0 <= m.
107
intros x y z H1 H2 H3; apply Zlt_succ_le; apply Zmult_gt_0_lt_0_reg_r with x;
109
| apply Zle_lt_trans with (1 := H3); rewrite <- Zmult_succ_l_reverse;
110
apply Zplus_lt_compat_l; apply Zgt_lt; assumption ].