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: R_Ifp.v 9245 2006-10-17 12:53:34Z notin $ i*)
11
(**********************************************************)
12
(** Complements for the reals.Integer and fractional part *)
14
(**********************************************************)
18
Open Local Scope R_scope.
20
(*********************************************************)
21
(** * Fractional part *)
22
(*********************************************************)
25
Definition Int_part (r:R) : Z := (up r - 1)%Z.
28
Definition frac_part (r:R) : R := r - IZR (Int_part r).
31
Lemma tech_up : forall (r:R) (z:Z), r < IZR z -> IZR z <= r + 1 -> z = up r.
33
intros; generalize (archimed r); intro; elim H1; intros; clear H1;
34
unfold Rgt in H2; unfold Rminus in H3;
35
generalize (Rplus_le_compat_l r (IZR (up r) + - r) 1 H3);
36
intro; clear H3; rewrite (Rplus_comm (IZR (up r)) (- r)) in H1;
37
rewrite <- (Rplus_assoc r (- r) (IZR (up r))) in H1;
38
rewrite (Rplus_opp_r r) in H1; elim (Rplus_ne (IZR (up r)));
39
intros a b; rewrite b in H1; clear a b; apply (single_z_r_R1 r z (up r));
40
auto with zarith real.
45
forall (r:R) (z:Z), IZR z <= r -> r < IZR (z + 1) -> (z + 1)%Z = up r.
47
intros; generalize (Rplus_le_compat_l 1 (IZR z) r H); intro; clear H;
48
rewrite (Rplus_comm 1 (IZR z)) in H1; rewrite (Rplus_comm 1 r) in H1;
49
cut (1 = IZR 1); auto with zarith real.
50
intro; generalize H1; pattern 1 at 1 in |- *; rewrite H; intro; clear H H1;
51
rewrite <- (plus_IZR z 1) in H2; apply (tech_up r (z + 1));
52
auto with zarith real.
56
Lemma fp_R0 : frac_part 0 = 0.
58
unfold frac_part in |- *; unfold Int_part in |- *; elim (archimed 0); intros;
59
unfold Rminus in |- *; elim (Rplus_ne (- IZR (up 0 - 1)));
60
intros a b; rewrite b; clear a b; rewrite <- Z_R_minus;
63
rewrite (Rminus_diag_eq (IZR 1) (IZR 1) (refl_equal (IZR 1)));
65
elim (archimed 0); intros; clear H2; unfold Rgt in H1;
66
rewrite (Rminus_0_r (IZR (up 0))) in H0; generalize (lt_O_IZR (up 0) H1);
67
intro; clear H1; generalize (le_IZR_R1 (up 0) H0);
68
intro; clear H H0; omega.
72
Lemma for_base_fp : forall r:R, IZR (up r) - r > 0 /\ IZR (up r) - r <= 1.
74
intro; split; cut (IZR (up r) > r /\ IZR (up r) - r <= 1).
75
intro; elim H; intros.
76
apply (Rgt_minus (IZR (up r)) r H0).
78
intro; elim H; intros.
84
Lemma base_fp : forall r:R, frac_part r >= 0 /\ frac_part r < 1.
86
intro; unfold frac_part in |- *; unfold Int_part in |- *; split.
88
cut (r - IZR (up r) >= -1).
89
rewrite <- Z_R_minus; simpl in |- *; intro; unfold Rminus in |- *;
90
rewrite Ropp_plus_distr; rewrite <- Rplus_assoc;
91
fold (r - IZR (up r)) in |- *; fold (r - IZR (up r) - -1) in |- *;
92
apply Rge_minus; auto with zarith real.
93
rewrite <- Ropp_minus_distr; apply Ropp_le_ge_contravar; elim (for_base_fp r);
94
auto with zarith real.
96
cut (r - IZR (up r) < 0).
97
rewrite <- Z_R_minus; simpl in |- *; intro; unfold Rminus in |- *;
98
rewrite Ropp_plus_distr; rewrite <- Rplus_assoc;
99
fold (r - IZR (up r)) in |- *; rewrite Ropp_involutive;
100
elim (Rplus_ne 1); intros a b; pattern 1 at 2 in |- *;
101
rewrite <- a; clear a b; rewrite (Rplus_comm (r - IZR (up r)) 1);
102
apply Rplus_lt_compat_l; auto with zarith real.
103
elim (for_base_fp r); intros; rewrite <- Ropp_0; rewrite <- Ropp_minus_distr;
104
apply Ropp_gt_lt_contravar; auto with zarith real.
107
(*********************************************************)
109
(*********************************************************)
112
Lemma base_Int_part :
113
forall r:R, IZR (Int_part r) <= r /\ IZR (Int_part r) - r > -1.
115
intro; unfold Int_part in |- *; elim (archimed r); intros.
116
split; rewrite <- (Z_R_minus (up r) 1); simpl in |- *.
117
generalize (Rle_minus (IZR (up r) - r) 1 H0); intro; unfold Rminus in H1;
118
rewrite (Rplus_assoc (IZR (up r)) (- r) (-1)) in H1;
119
rewrite (Rplus_comm (- r) (-1)) in H1;
120
rewrite <- (Rplus_assoc (IZR (up r)) (-1) (- r)) in H1;
121
fold (IZR (up r) - 1) in H1; fold (IZR (up r) - 1 - r) in H1;
122
apply Rminus_le; auto with zarith real.
123
generalize (Rplus_gt_compat_l (-1) (IZR (up r)) r H); intro;
124
rewrite (Rplus_comm (-1) (IZR (up r))) in H1;
125
generalize (Rplus_gt_compat_l (- r) (IZR (up r) + -1) (-1 + r) H1);
126
intro; clear H H0 H1; rewrite (Rplus_comm (- r) (IZR (up r) + -1)) in H2;
127
fold (IZR (up r) - 1) in H2; fold (IZR (up r) - 1 - r) in H2;
128
rewrite (Rplus_comm (- r) (-1 + r)) in H2;
129
rewrite (Rplus_assoc (-1) r (- r)) in H2; rewrite (Rplus_opp_r r) in H2;
130
elim (Rplus_ne (-1)); intros a b; rewrite a in H2;
131
clear a b; auto with zarith real.
135
Lemma Int_part_INR : forall n:nat, Int_part (INR n) = Z_of_nat n.
137
intros n; unfold Int_part in |- *.
138
cut (up (INR n) = (Z_of_nat n + Z_of_nat 1)%Z).
139
intros H'; rewrite H'; simpl in |- *; ring.
140
apply sym_equal; apply tech_up; auto.
141
replace (Z_of_nat n + Z_of_nat 1)%Z with (Z_of_nat (S n)).
142
repeat rewrite <- INR_IZR_INZ.
144
rewrite Zplus_comm; rewrite <- Znat.inj_plus; simpl in |- *; auto.
145
rewrite plus_IZR; simpl in |- *; auto with real.
146
repeat rewrite <- INR_IZR_INZ; auto with real.
150
Lemma fp_nat : forall r:R, frac_part r = 0 -> exists c : Z, r = IZR c.
152
unfold frac_part in |- *; intros; split with (Int_part r);
153
apply Rminus_diag_uniq; auto with zarith real.
157
Lemma R0_fp_O : forall r:R, 0 <> frac_part r -> 0 <> r.
159
red in |- *; intros; rewrite <- H0 in H; generalize fp_R0; intro;
160
auto with zarith real.
164
Lemma Rminus_Int_part1 :
166
frac_part r1 >= frac_part r2 ->
167
Int_part (r1 - r2) = (Int_part r1 - Int_part r2)%Z.
169
intros; elim (base_fp r1); elim (base_fp r2); intros;
170
generalize (Rge_le (frac_part r2) 0 H0); intro; clear H0;
171
generalize (Ropp_le_ge_contravar 0 (frac_part r2) H4);
172
intro; clear H4; rewrite Ropp_0 in H0;
173
generalize (Rge_le 0 (- frac_part r2) H0); intro;
174
clear H0; generalize (Rge_le (frac_part r1) 0 H2);
175
intro; clear H2; generalize (Ropp_lt_gt_contravar (frac_part r2) 1 H1);
176
intro; clear H1; unfold Rgt in H2;
178
(sum_inequa_Rle_lt 0 (frac_part r1) 1 (-1) (- frac_part r2) 0 H0 H3 H2 H4);
179
intro; elim H1; intros; clear H1; elim (Rplus_ne 1);
180
intros a b; rewrite a in H6; clear a b H5;
181
generalize (Rge_minus (frac_part r1) (frac_part r2) H);
182
intro; clear H; fold (frac_part r1 - frac_part r2) in H6;
183
generalize (Rge_le (frac_part r1 - frac_part r2) 0 H1);
184
intro; clear H1 H3 H4 H0 H2; unfold frac_part in H6, H;
185
unfold Rminus in H6, H;
186
rewrite (Ropp_plus_distr r2 (- IZR (Int_part r2))) in H;
187
rewrite (Ropp_involutive (IZR (Int_part r2))) in H;
188
rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (- r2 + IZR (Int_part r2)))
190
rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- r2) (IZR (Int_part r2)))
191
in H; rewrite (Rplus_comm (- IZR (Int_part r1)) (- r2)) in H;
192
rewrite (Rplus_assoc (- r2) (- IZR (Int_part r1)) (IZR (Int_part r2))) in H;
193
rewrite <- (Rplus_assoc r1 (- r2) (- IZR (Int_part r1) + IZR (Int_part r2)))
194
in H; rewrite (Rplus_comm (- IZR (Int_part r1)) (IZR (Int_part r2))) in H;
195
fold (r1 - r2) in H; fold (IZR (Int_part r2) - IZR (Int_part r1)) in H;
197
(Rplus_le_compat_l (IZR (Int_part r1) - IZR (Int_part r2)) 0
198
(r1 - r2 + (IZR (Int_part r2) - IZR (Int_part r1))) H);
200
rewrite (Rplus_comm (r1 - r2) (IZR (Int_part r2) - IZR (Int_part r1))) in H0;
202
(Rplus_assoc (IZR (Int_part r1) - IZR (Int_part r2))
203
(IZR (Int_part r2) - IZR (Int_part r1)) (r1 - r2))
204
in H0; unfold Rminus in H0; fold (r1 - r2) in H0;
206
(Rplus_assoc (IZR (Int_part r1)) (- IZR (Int_part r2))
207
(IZR (Int_part r2) + - IZR (Int_part r1))) in H0;
209
(Rplus_assoc (- IZR (Int_part r2)) (IZR (Int_part r2))
210
(- IZR (Int_part r1))) in H0;
211
rewrite (Rplus_opp_l (IZR (Int_part r2))) in H0;
212
elim (Rplus_ne (- IZR (Int_part r1))); intros a b;
213
rewrite b in H0; clear a b;
214
elim (Rplus_ne (IZR (Int_part r1) + - IZR (Int_part r2)));
215
intros a b; rewrite a in H0; clear a b;
216
rewrite (Rplus_opp_r (IZR (Int_part r1))) in H0; elim (Rplus_ne (r1 - r2));
217
intros a b; rewrite b in H0; clear a b;
218
fold (IZR (Int_part r1) - IZR (Int_part r2)) in H0;
219
rewrite (Ropp_plus_distr r2 (- IZR (Int_part r2))) in H6;
220
rewrite (Ropp_involutive (IZR (Int_part r2))) in H6;
221
rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (- r2 + IZR (Int_part r2)))
223
rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- r2) (IZR (Int_part r2)))
224
in H6; rewrite (Rplus_comm (- IZR (Int_part r1)) (- r2)) in H6;
225
rewrite (Rplus_assoc (- r2) (- IZR (Int_part r1)) (IZR (Int_part r2))) in H6;
226
rewrite <- (Rplus_assoc r1 (- r2) (- IZR (Int_part r1) + IZR (Int_part r2)))
228
rewrite (Rplus_comm (- IZR (Int_part r1)) (IZR (Int_part r2))) in H6;
229
fold (r1 - r2) in H6; fold (IZR (Int_part r2) - IZR (Int_part r1)) in H6;
231
(Rplus_lt_compat_l (IZR (Int_part r1) - IZR (Int_part r2))
232
(r1 - r2 + (IZR (Int_part r2) - IZR (Int_part r1))) 1 H6);
234
rewrite (Rplus_comm (r1 - r2) (IZR (Int_part r2) - IZR (Int_part r1))) in H;
236
(Rplus_assoc (IZR (Int_part r1) - IZR (Int_part r2))
237
(IZR (Int_part r2) - IZR (Int_part r1)) (r1 - r2))
239
rewrite <- (Ropp_minus_distr (IZR (Int_part r1)) (IZR (Int_part r2))) in H;
240
rewrite (Rplus_opp_r (IZR (Int_part r1) - IZR (Int_part r2))) in H;
241
elim (Rplus_ne (r1 - r2)); intros a b; rewrite b in H;
242
clear a b; rewrite (Z_R_minus (Int_part r1) (Int_part r2)) in H0;
243
rewrite (Z_R_minus (Int_part r1) (Int_part r2)) in H;
244
cut (1 = IZR 1); auto with zarith real.
245
intro; rewrite H1 in H; clear H1;
246
rewrite <- (plus_IZR (Int_part r1 - Int_part r2) 1) in H;
247
generalize (up_tech (r1 - r2) (Int_part r1 - Int_part r2) H0 H);
248
intros; clear H H0; unfold Int_part at 1 in |- *;
253
Lemma Rminus_Int_part2 :
255
frac_part r1 < frac_part r2 ->
256
Int_part (r1 - r2) = (Int_part r1 - Int_part r2 - 1)%Z.
258
intros; elim (base_fp r1); elim (base_fp r2); intros;
259
generalize (Rge_le (frac_part r2) 0 H0); intro; clear H0;
260
generalize (Ropp_le_ge_contravar 0 (frac_part r2) H4);
261
intro; clear H4; rewrite Ropp_0 in H0;
262
generalize (Rge_le 0 (- frac_part r2) H0); intro;
263
clear H0; generalize (Rge_le (frac_part r1) 0 H2);
264
intro; clear H2; generalize (Ropp_lt_gt_contravar (frac_part r2) 1 H1);
265
intro; clear H1; unfold Rgt in H2;
267
(sum_inequa_Rle_lt 0 (frac_part r1) 1 (-1) (- frac_part r2) 0 H0 H3 H2 H4);
268
intro; elim H1; intros; clear H1; elim (Rplus_ne (-1));
269
intros a b; rewrite b in H5; clear a b H6;
270
generalize (Rlt_minus (frac_part r1) (frac_part r2) H);
271
intro; clear H; fold (frac_part r1 - frac_part r2) in H5;
272
clear H3 H4 H0 H2; unfold frac_part in H5, H1; unfold Rminus in H5, H1;
273
rewrite (Ropp_plus_distr r2 (- IZR (Int_part r2))) in H5;
274
rewrite (Ropp_involutive (IZR (Int_part r2))) in H5;
275
rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (- r2 + IZR (Int_part r2)))
277
rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- r2) (IZR (Int_part r2)))
278
in H5; rewrite (Rplus_comm (- IZR (Int_part r1)) (- r2)) in H5;
279
rewrite (Rplus_assoc (- r2) (- IZR (Int_part r1)) (IZR (Int_part r2))) in H5;
280
rewrite <- (Rplus_assoc r1 (- r2) (- IZR (Int_part r1) + IZR (Int_part r2)))
282
rewrite (Rplus_comm (- IZR (Int_part r1)) (IZR (Int_part r2))) in H5;
283
fold (r1 - r2) in H5; fold (IZR (Int_part r2) - IZR (Int_part r1)) in H5;
285
(Rplus_lt_compat_l (IZR (Int_part r1) - IZR (Int_part r2)) (-1)
286
(r1 - r2 + (IZR (Int_part r2) - IZR (Int_part r1))) H5);
288
rewrite (Rplus_comm (r1 - r2) (IZR (Int_part r2) - IZR (Int_part r1))) in H;
290
(Rplus_assoc (IZR (Int_part r1) - IZR (Int_part r2))
291
(IZR (Int_part r2) - IZR (Int_part r1)) (r1 - r2))
292
in H; unfold Rminus in H; fold (r1 - r2) in H;
294
(Rplus_assoc (IZR (Int_part r1)) (- IZR (Int_part r2))
295
(IZR (Int_part r2) + - IZR (Int_part r1))) in H;
297
(Rplus_assoc (- IZR (Int_part r2)) (IZR (Int_part r2))
298
(- IZR (Int_part r1))) in H;
299
rewrite (Rplus_opp_l (IZR (Int_part r2))) in H;
300
elim (Rplus_ne (- IZR (Int_part r1))); intros a b;
301
rewrite b in H; clear a b; rewrite (Rplus_opp_r (IZR (Int_part r1))) in H;
302
elim (Rplus_ne (r1 - r2)); intros a b; rewrite b in H;
303
clear a b; fold (IZR (Int_part r1) - IZR (Int_part r2)) in H;
304
fold (IZR (Int_part r1) - IZR (Int_part r2) - 1) in H;
305
rewrite (Ropp_plus_distr r2 (- IZR (Int_part r2))) in H1;
306
rewrite (Ropp_involutive (IZR (Int_part r2))) in H1;
307
rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (- r2 + IZR (Int_part r2)))
309
rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- r2) (IZR (Int_part r2)))
310
in H1; rewrite (Rplus_comm (- IZR (Int_part r1)) (- r2)) in H1;
311
rewrite (Rplus_assoc (- r2) (- IZR (Int_part r1)) (IZR (Int_part r2))) in H1;
312
rewrite <- (Rplus_assoc r1 (- r2) (- IZR (Int_part r1) + IZR (Int_part r2)))
314
rewrite (Rplus_comm (- IZR (Int_part r1)) (IZR (Int_part r2))) in H1;
315
fold (r1 - r2) in H1; fold (IZR (Int_part r2) - IZR (Int_part r1)) in H1;
317
(Rplus_lt_compat_l (IZR (Int_part r1) - IZR (Int_part r2))
318
(r1 - r2 + (IZR (Int_part r2) - IZR (Int_part r1))) 0 H1);
320
rewrite (Rplus_comm (r1 - r2) (IZR (Int_part r2) - IZR (Int_part r1))) in H0;
322
(Rplus_assoc (IZR (Int_part r1) - IZR (Int_part r2))
323
(IZR (Int_part r2) - IZR (Int_part r1)) (r1 - r2))
325
rewrite <- (Ropp_minus_distr (IZR (Int_part r1)) (IZR (Int_part r2))) in H0;
326
rewrite (Rplus_opp_r (IZR (Int_part r1) - IZR (Int_part r2))) in H0;
327
elim (Rplus_ne (r1 - r2)); intros a b; rewrite b in H0;
328
clear a b; rewrite <- (Rplus_opp_l 1) in H0;
329
rewrite <- (Rplus_assoc (IZR (Int_part r1) - IZR (Int_part r2)) (-1) 1)
330
in H0; fold (IZR (Int_part r1) - IZR (Int_part r2) - 1) in H0;
331
rewrite (Z_R_minus (Int_part r1) (Int_part r2)) in H0;
332
rewrite (Z_R_minus (Int_part r1) (Int_part r2)) in H;
333
cut (1 = IZR 1); auto with zarith real.
334
intro; rewrite H1 in H; rewrite H1 in H0; clear H1;
335
rewrite (Z_R_minus (Int_part r1 - Int_part r2) 1) in H;
336
rewrite (Z_R_minus (Int_part r1 - Int_part r2) 1) in H0;
337
rewrite <- (plus_IZR (Int_part r1 - Int_part r2 - 1) 1) in H0;
338
generalize (Rlt_le (IZR (Int_part r1 - Int_part r2 - 1)) (r1 - r2) H);
340
generalize (up_tech (r1 - r2) (Int_part r1 - Int_part r2 - 1) H1 H0);
341
intros; clear H0 H1; unfold Int_part at 1 in |- *;
348
frac_part r1 >= frac_part r2 ->
349
frac_part (r1 - r2) = frac_part r1 - frac_part r2.
351
intros; unfold frac_part in |- *; generalize (Rminus_Int_part1 r1 r2 H);
352
intro; rewrite H0; rewrite <- (Z_R_minus (Int_part r1) (Int_part r2));
353
unfold Rminus in |- *;
354
rewrite (Ropp_plus_distr (IZR (Int_part r1)) (- IZR (Int_part r2)));
355
rewrite (Ropp_plus_distr r2 (- IZR (Int_part r2)));
356
rewrite (Ropp_involutive (IZR (Int_part r2)));
357
rewrite (Rplus_assoc r1 (- r2) (- IZR (Int_part r1) + IZR (Int_part r2)));
358
rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (- r2 + IZR (Int_part r2)));
359
rewrite <- (Rplus_assoc (- r2) (- IZR (Int_part r1)) (IZR (Int_part r2)));
360
rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- r2) (IZR (Int_part r2)));
361
rewrite (Rplus_comm (- r2) (- IZR (Int_part r1)));
362
auto with zarith real.
368
frac_part r1 < frac_part r2 ->
369
frac_part (r1 - r2) = frac_part r1 - frac_part r2 + 1.
371
intros; unfold frac_part in |- *; generalize (Rminus_Int_part2 r1 r2 H);
372
intro; rewrite H0; rewrite <- (Z_R_minus (Int_part r1 - Int_part r2) 1);
373
rewrite <- (Z_R_minus (Int_part r1) (Int_part r2));
374
unfold Rminus in |- *;
376
(Ropp_plus_distr (IZR (Int_part r1) + - IZR (Int_part r2)) (- IZR 1))
377
; rewrite (Ropp_plus_distr r2 (- IZR (Int_part r2)));
378
rewrite (Ropp_involutive (IZR 1));
379
rewrite (Ropp_involutive (IZR (Int_part r2)));
380
rewrite (Ropp_plus_distr (IZR (Int_part r1)));
381
rewrite (Ropp_involutive (IZR (Int_part r2))); simpl in |- *;
383
(Rplus_assoc (r1 + - r2) (- IZR (Int_part r1) + IZR (Int_part r2)) 1)
384
; rewrite (Rplus_assoc r1 (- r2) (- IZR (Int_part r1) + IZR (Int_part r2)));
385
rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (- r2 + IZR (Int_part r2)));
386
rewrite <- (Rplus_assoc (- r2) (- IZR (Int_part r1)) (IZR (Int_part r2)));
387
rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- r2) (IZR (Int_part r2)));
388
rewrite (Rplus_comm (- r2) (- IZR (Int_part r1)));
389
auto with zarith real.
393
Lemma plus_Int_part1 :
395
frac_part r1 + frac_part r2 >= 1 ->
396
Int_part (r1 + r2) = (Int_part r1 + Int_part r2 + 1)%Z.
398
intros; generalize (Rge_le (frac_part r1 + frac_part r2) 1 H); intro; clear H;
399
elim (base_fp r1); elim (base_fp r2); intros; clear H H2;
400
generalize (Rplus_lt_compat_l (frac_part r2) (frac_part r1) 1 H3);
401
intro; clear H3; generalize (Rplus_lt_compat_l 1 (frac_part r2) 1 H1);
402
intro; clear H1; rewrite (Rplus_comm 1 (frac_part r2)) in H2;
404
(Rlt_trans (frac_part r2 + frac_part r1) (frac_part r2 + 1) 2 H H2);
405
intro; clear H H2; rewrite (Rplus_comm (frac_part r2) (frac_part r1)) in H1;
406
unfold frac_part in H0, H1; unfold Rminus in H0, H1;
407
rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (r2 + - IZR (Int_part r2)))
408
in H1; rewrite (Rplus_comm r2 (- IZR (Int_part r2))) in H1;
409
rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- IZR (Int_part r2)) r2)
411
rewrite (Rplus_comm (- IZR (Int_part r1) + - IZR (Int_part r2)) r2) in H1;
412
rewrite <- (Rplus_assoc r1 r2 (- IZR (Int_part r1) + - IZR (Int_part r2)))
414
rewrite <- (Ropp_plus_distr (IZR (Int_part r1)) (IZR (Int_part r2))) in H1;
415
rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (r2 + - IZR (Int_part r2)))
416
in H0; rewrite (Rplus_comm r2 (- IZR (Int_part r2))) in H0;
417
rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- IZR (Int_part r2)) r2)
419
rewrite (Rplus_comm (- IZR (Int_part r1) + - IZR (Int_part r2)) r2) in H0;
420
rewrite <- (Rplus_assoc r1 r2 (- IZR (Int_part r1) + - IZR (Int_part r2)))
422
rewrite <- (Ropp_plus_distr (IZR (Int_part r1)) (IZR (Int_part r2))) in H0;
424
(Rplus_le_compat_l (IZR (Int_part r1) + IZR (Int_part r2)) 1
425
(r1 + r2 + - (IZR (Int_part r1) + IZR (Int_part r2))) H0);
428
(Rplus_lt_compat_l (IZR (Int_part r1) + IZR (Int_part r2))
429
(r1 + r2 + - (IZR (Int_part r1) + IZR (Int_part r2))) 2 H1);
431
rewrite (Rplus_comm (r1 + r2) (- (IZR (Int_part r1) + IZR (Int_part r2))))
434
(Rplus_assoc (IZR (Int_part r1) + IZR (Int_part r2))
435
(- (IZR (Int_part r1) + IZR (Int_part r2))) (r1 + r2))
436
in H; rewrite (Rplus_opp_r (IZR (Int_part r1) + IZR (Int_part r2))) in H;
437
elim (Rplus_ne (r1 + r2)); intros a b; rewrite b in H;
439
rewrite (Rplus_comm (r1 + r2) (- (IZR (Int_part r1) + IZR (Int_part r2))))
442
(Rplus_assoc (IZR (Int_part r1) + IZR (Int_part r2))
443
(- (IZR (Int_part r1) + IZR (Int_part r2))) (r1 + r2))
444
in H0; rewrite (Rplus_opp_r (IZR (Int_part r1) + IZR (Int_part r2))) in H0;
445
elim (Rplus_ne (r1 + r2)); intros a b; rewrite b in H0;
447
rewrite <- (Rplus_assoc (IZR (Int_part r1) + IZR (Int_part r2)) 1 1) in H0;
448
cut (1 = IZR 1); auto with zarith real.
449
intro; rewrite H1 in H0; rewrite H1 in H; clear H1;
450
rewrite <- (plus_IZR (Int_part r1) (Int_part r2)) in H;
451
rewrite <- (plus_IZR (Int_part r1) (Int_part r2)) in H0;
452
rewrite <- (plus_IZR (Int_part r1 + Int_part r2) 1) in H;
453
rewrite <- (plus_IZR (Int_part r1 + Int_part r2) 1) in H0;
454
rewrite <- (plus_IZR (Int_part r1 + Int_part r2 + 1) 1) in H0;
455
generalize (up_tech (r1 + r2) (Int_part r1 + Int_part r2 + 1) H H0);
456
intro; clear H H0; unfold Int_part at 1 in |- *; omega.
460
Lemma plus_Int_part2 :
462
frac_part r1 + frac_part r2 < 1 ->
463
Int_part (r1 + r2) = (Int_part r1 + Int_part r2)%Z.
465
intros; elim (base_fp r1); elim (base_fp r2); intros; clear H1 H3;
466
generalize (Rge_le (frac_part r2) 0 H0); intro; clear H0;
467
generalize (Rge_le (frac_part r1) 0 H2); intro; clear H2;
468
generalize (Rplus_le_compat_l (frac_part r1) 0 (frac_part r2) H1);
469
intro; clear H1; elim (Rplus_ne (frac_part r1)); intros a b;
470
rewrite a in H2; clear a b;
471
generalize (Rle_trans 0 (frac_part r1) (frac_part r1 + frac_part r2) H0 H2);
472
intro; clear H0 H2; unfold frac_part in H, H1; unfold Rminus in H, H1;
473
rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (r2 + - IZR (Int_part r2)))
474
in H1; rewrite (Rplus_comm r2 (- IZR (Int_part r2))) in H1;
475
rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- IZR (Int_part r2)) r2)
477
rewrite (Rplus_comm (- IZR (Int_part r1) + - IZR (Int_part r2)) r2) in H1;
478
rewrite <- (Rplus_assoc r1 r2 (- IZR (Int_part r1) + - IZR (Int_part r2)))
480
rewrite <- (Ropp_plus_distr (IZR (Int_part r1)) (IZR (Int_part r2))) in H1;
481
rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (r2 + - IZR (Int_part r2)))
482
in H; rewrite (Rplus_comm r2 (- IZR (Int_part r2))) in H;
483
rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- IZR (Int_part r2)) r2) in H;
484
rewrite (Rplus_comm (- IZR (Int_part r1) + - IZR (Int_part r2)) r2) in H;
485
rewrite <- (Rplus_assoc r1 r2 (- IZR (Int_part r1) + - IZR (Int_part r2)))
487
rewrite <- (Ropp_plus_distr (IZR (Int_part r1)) (IZR (Int_part r2))) in H;
489
(Rplus_le_compat_l (IZR (Int_part r1) + IZR (Int_part r2)) 0
490
(r1 + r2 + - (IZR (Int_part r1) + IZR (Int_part r2))) H1);
493
(Rplus_lt_compat_l (IZR (Int_part r1) + IZR (Int_part r2))
494
(r1 + r2 + - (IZR (Int_part r1) + IZR (Int_part r2))) 1 H);
496
rewrite (Rplus_comm (r1 + r2) (- (IZR (Int_part r1) + IZR (Int_part r2))))
499
(Rplus_assoc (IZR (Int_part r1) + IZR (Int_part r2))
500
(- (IZR (Int_part r1) + IZR (Int_part r2))) (r1 + r2))
501
in H1; rewrite (Rplus_opp_r (IZR (Int_part r1) + IZR (Int_part r2))) in H1;
502
elim (Rplus_ne (r1 + r2)); intros a b; rewrite b in H1;
504
rewrite (Rplus_comm (r1 + r2) (- (IZR (Int_part r1) + IZR (Int_part r2))))
507
(Rplus_assoc (IZR (Int_part r1) + IZR (Int_part r2))
508
(- (IZR (Int_part r1) + IZR (Int_part r2))) (r1 + r2))
509
in H0; rewrite (Rplus_opp_r (IZR (Int_part r1) + IZR (Int_part r2))) in H0;
510
elim (Rplus_ne (IZR (Int_part r1) + IZR (Int_part r2)));
511
intros a b; rewrite a in H0; clear a b; elim (Rplus_ne (r1 + r2));
512
intros a b; rewrite b in H0; clear a b; cut (1 = IZR 1);
513
auto with zarith real.
514
intro; rewrite H in H1; clear H;
515
rewrite <- (plus_IZR (Int_part r1) (Int_part r2)) in H0;
516
rewrite <- (plus_IZR (Int_part r1) (Int_part r2)) in H1;
517
rewrite <- (plus_IZR (Int_part r1 + Int_part r2) 1) in H1;
518
generalize (up_tech (r1 + r2) (Int_part r1 + Int_part r2) H0 H1);
519
intro; clear H0 H1; unfold Int_part at 1 in |- *;
524
Lemma plus_frac_part1 :
526
frac_part r1 + frac_part r2 >= 1 ->
527
frac_part (r1 + r2) = frac_part r1 + frac_part r2 - 1.
529
intros; unfold frac_part in |- *; generalize (plus_Int_part1 r1 r2 H); intro;
530
rewrite H0; rewrite (plus_IZR (Int_part r1 + Int_part r2) 1);
531
rewrite (plus_IZR (Int_part r1) (Int_part r2)); simpl in |- *;
532
unfold Rminus at 3 4 in |- *;
533
rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (r2 + - IZR (Int_part r2)));
534
rewrite (Rplus_comm r2 (- IZR (Int_part r2)));
535
rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- IZR (Int_part r2)) r2);
536
rewrite (Rplus_comm (- IZR (Int_part r1) + - IZR (Int_part r2)) r2);
537
rewrite <- (Rplus_assoc r1 r2 (- IZR (Int_part r1) + - IZR (Int_part r2)));
538
rewrite <- (Ropp_plus_distr (IZR (Int_part r1)) (IZR (Int_part r2)));
539
unfold Rminus in |- *;
541
(Rplus_assoc (r1 + r2) (- (IZR (Int_part r1) + IZR (Int_part r2))) (-1))
542
; rewrite <- (Ropp_plus_distr (IZR (Int_part r1) + IZR (Int_part r2)) 1);
543
trivial with zarith real.
547
Lemma plus_frac_part2 :
549
frac_part r1 + frac_part r2 < 1 ->
550
frac_part (r1 + r2) = frac_part r1 + frac_part r2.
552
intros; unfold frac_part in |- *; generalize (plus_Int_part2 r1 r2 H); intro;
553
rewrite H0; rewrite (plus_IZR (Int_part r1) (Int_part r2));
554
unfold Rminus at 2 3 in |- *;
555
rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (r2 + - IZR (Int_part r2)));
556
rewrite (Rplus_comm r2 (- IZR (Int_part r2)));
557
rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- IZR (Int_part r2)) r2);
558
rewrite (Rplus_comm (- IZR (Int_part r1) + - IZR (Int_part r2)) r2);
559
rewrite <- (Rplus_assoc r1 r2 (- IZR (Int_part r1) + - IZR (Int_part r2)));
560
rewrite <- (Ropp_plus_distr (IZR (Int_part r1)) (IZR (Int_part r2)));
561
unfold Rminus in |- *; trivial with zarith real.