~ubuntu-branches/ubuntu/wily/coq-doc/wily

« back to all changes in this revision

Viewing changes to theories/QArith/Qround.v

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu, Stéphane Glondu, Samuel Mimram
  • Date: 2010-01-07 22:50:39 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100107225039-n3cq82589u0qt0s2
Tags: 8.2pl1-1
[ Stéphane Glondu ]
* New upstream release (Closes: #563669)
  - remove patches
* Packaging overhaul:
  - use git, advertise it in Vcs-* fields of debian/control
  - use debhelper 7 and dh with override
  - use source format 3.0 (quilt)
* debian/control:
  - set Maintainer to d-o-m, set Uploaders to Sam and myself
  - add Homepage field
  - bump Standards-Version to 3.8.3
* Register PDF documentation into doc-base
* Add debian/watch
* Update debian/copyright

[ Samuel Mimram ]
* Change coq-doc's description to mention that it provides documentation in
  pdf format, not postscript, closes: #543545.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
(************************************************************************)
 
8
 
 
9
Require Import QArith.
 
10
 
 
11
Lemma Qopp_lt_compat: forall p q : Q, p < q -> - q < - p.
 
12
Proof.
 
13
intros (a1,a2) (b1,b2); unfold Qle, Qlt; simpl.
 
14
do 2 rewrite <- Zopp_mult_distr_l; omega.
 
15
Qed.
 
16
 
 
17
Hint Resolve Qopp_lt_compat : qarith.
 
18
 
 
19
(************)
 
20
 
 
21
Coercion Local inject_Z : Z >-> Q.
 
22
 
 
23
Definition Qfloor (x:Q) := let (n,d) := x in Zdiv n (Zpos d).
 
24
Definition Qceiling (x:Q) := (-(Qfloor (-x)))%Z.
 
25
 
 
26
Lemma Qfloor_Z : forall z:Z, Qfloor z = z.
 
27
Proof.
 
28
intros z.
 
29
simpl.
 
30
auto with *.
 
31
Qed.
 
32
 
 
33
Lemma Qceiling_Z : forall z:Z, Qceiling z = z.
 
34
Proof.
 
35
intros z.
 
36
unfold Qceiling.
 
37
simpl.
 
38
rewrite Zdiv_1_r.
 
39
auto with *.
 
40
Qed.
 
41
 
 
42
Lemma Qfloor_le : forall x, Qfloor x <= x.
 
43
Proof.
 
44
intros [n d].
 
45
simpl.
 
46
unfold Qle.
 
47
simpl.
 
48
replace (n*1)%Z with n by ring.
 
49
rewrite Zmult_comm.
 
50
apply Z_mult_div_ge.
 
51
auto with *.
 
52
Qed.
 
53
 
 
54
Hint Resolve Qfloor_le : qarith.
 
55
 
 
56
Lemma Qle_ceiling : forall x, x <= Qceiling x.
 
57
Proof.
 
58
intros x.
 
59
apply Qle_trans with (- - x).
 
60
 rewrite Qopp_involutive.
 
61
 auto with *.
 
62
change (Qceiling x:Q) with (-(Qfloor(-x))).
 
63
auto with *.
 
64
Qed.
 
65
 
 
66
Hint Resolve Qle_ceiling : qarith.
 
67
 
 
68
Lemma Qle_floor_ceiling : forall x, Qfloor x <= Qceiling x.
 
69
Proof.
 
70
eauto with qarith.
 
71
Qed.
 
72
 
 
73
Lemma Qlt_floor : forall x, x < (Qfloor x+1)%Z.
 
74
Proof.
 
75
intros [n d].
 
76
simpl.
 
77
unfold Qlt.
 
78
simpl.
 
79
replace (n*1)%Z with n by ring.
 
80
ring_simplify.
 
81
replace (n / ' d * ' d + ' d)%Z with
 
82
  (('d * (n / 'd) + n mod 'd) + 'd - n mod 'd)%Z by ring.
 
83
rewrite <- Z_div_mod_eq; auto with*.
 
84
rewrite <- Zlt_plus_swap.
 
85
destruct (Z_mod_lt n ('d)); auto with *.
 
86
Qed.
 
87
 
 
88
Hint Resolve Qlt_floor : qarith.
 
89
 
 
90
Lemma Qceiling_lt : forall x, (Qceiling x-1)%Z < x.
 
91
Proof.
 
92
intros x.
 
93
unfold Qceiling.
 
94
replace (- Qfloor (- x) - 1)%Z with (-(Qfloor (-x) + 1))%Z by ring.
 
95
change ((- (Qfloor (- x) + 1))%Z:Q) with (-(Qfloor (- x) + 1)%Z).
 
96
apply Qlt_le_trans with (- - x); auto with *.
 
97
rewrite Qopp_involutive.
 
98
auto with *.
 
99
Qed.
 
100
 
 
101
Hint Resolve Qceiling_lt : qarith.
 
102
 
 
103
Lemma Qfloor_resp_le : forall x y, x <= y -> (Qfloor x <= Qfloor y)%Z.
 
104
Proof.
 
105
intros [xn xd] [yn yd] Hxy.
 
106
unfold Qle in *.
 
107
simpl in *.
 
108
rewrite <- (Zdiv_mult_cancel_r xn ('xd) ('yd)); auto with *.
 
109
rewrite <- (Zdiv_mult_cancel_r yn ('yd) ('xd)); auto with *.
 
110
rewrite (Zmult_comm ('yd) ('xd)).
 
111
apply Z_div_le; auto with *.
 
112
Qed.
 
113
 
 
114
Hint Resolve Qfloor_resp_le : qarith.
 
115
 
 
116
Lemma Qceiling_resp_le : forall x y, x <= y -> (Qceiling x <= Qceiling y)%Z.
 
117
Proof.
 
118
intros x y Hxy.
 
119
unfold Qceiling.
 
120
cut (Qfloor (-y) <= Qfloor (-x))%Z; auto with *.
 
121
Qed.
 
122
 
 
123
Hint Resolve Qceiling_resp_le : qarith.
 
124
 
 
125
Add Morphism Qfloor with signature Qeq ==> @eq _ as Qfloor_comp.
 
126
Proof.
 
127
intros x y H.
 
128
apply Zle_antisym.
 
129
 auto with *.
 
130
symmetry in H; auto with *.
 
131
Qed.
 
132
 
 
133
Add Morphism Qceiling with signature Qeq ==> @eq _ as Qceiling_comp.
 
134
Proof.
 
135
intros x y H.
 
136
apply Zle_antisym.
 
137
 auto with *.
 
138
symmetry in H; auto with *.
 
139
Qed.
 
 
b'\\ No newline at end of file'