Fcore_rnd.v 31.3 KB
 Guillaume Melquiond committed Oct 01, 2010 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ``````(* This file is part of the Flocq formalization of floating-point arithmetic in Coq: http://flocq.gforge.inria.fr/ Copyright (C) 2010 Sylvie Boldo Copyright (C) 2010 Guillaume Melquiond This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the COPYING file for more details. *) `````` Guillaume Melquiond committed Feb 24, 2010 19 20 ``````Require Import Fcore_Raux. Require Import Fcore_defs. `````` Guillaume Melquiond committed Jan 23, 2009 21 22 23 24 25 `````` Section RND_prop. Open Scope R_scope. `````` Guillaume Melquiond committed Oct 01, 2010 26 ``````Theorem round_val_of_pred : `````` Guillaume Melquiond committed Oct 29, 2009 27 `````` forall rnd : R -> R -> Prop, `````` Guillaume Melquiond committed Oct 01, 2010 28 `````` round_pred rnd -> `````` Guillaume Melquiond committed Oct 29, 2009 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 `````` forall x, { f : R | rnd x f }. Proof. intros rnd (H1,H2) x. specialize (H1 x). (* . *) assert (H3 : bound (rnd x)). destruct H1 as (f, H1). exists f. intros g Hg. now apply H2 with (3 := Rle_refl x). (* . *) exists (projT1 (completeness _ H3 H1)). destruct completeness as (f1, (H4, H5)). simpl. destruct H1 as (f2, H1). assert (f1 = f2). apply Rle_antisym. apply H5. intros f3 H. now apply H2 with (3 := Rle_refl x). now apply H4. now rewrite H. Qed. `````` Guillaume Melquiond committed Oct 01, 2010 53 ``````Theorem round_fun_of_pred : `````` Guillaume Melquiond committed Oct 29, 2009 54 `````` forall rnd : R -> R -> Prop, `````` Guillaume Melquiond committed Oct 01, 2010 55 `````` round_pred rnd -> `````` Guillaume Melquiond committed Oct 29, 2009 56 57 58 `````` { f : R -> R | forall x, rnd x (f x) }. Proof. intros rnd H. `````` Guillaume Melquiond committed Oct 01, 2010 59 ``````exists (fun x => projT1 (round_val_of_pred rnd H x)). `````` Guillaume Melquiond committed Oct 29, 2009 60 ``````intros x. `````` Guillaume Melquiond committed Oct 01, 2010 61 ``````now destruct round_val_of_pred as (f, H1). `````` Guillaume Melquiond committed Oct 29, 2009 62 63 ``````Qed. `````` Guillaume Melquiond committed Oct 01, 2010 64 ``````Theorem round_unicity : `````` Guillaume Melquiond committed Oct 29, 2009 65 `````` forall rnd : R -> R -> Prop, `````` Guillaume Melquiond committed Oct 01, 2010 66 `````` round_pred_monotone rnd -> `````` Guillaume Melquiond committed Oct 29, 2009 67 68 69 70 71 72 73 74 75 76 77 `````` forall x f1 f2, rnd x f1 -> rnd x f2 -> f1 = f2. Proof. intros rnd Hr x f1 f2 H1 H2. apply Rle_antisym. now apply Hr with (3 := Rle_refl x). now apply Hr with (3 := Rle_refl x). Qed. `````` Guillaume Melquiond committed Oct 29, 2009 78 79 ``````Theorem Rnd_DN_pt_monotone : forall F : R -> Prop, `````` Guillaume Melquiond committed Oct 01, 2010 80 `````` round_pred_monotone (Rnd_DN_pt F). `````` Guillaume Melquiond committed Oct 29, 2009 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 ``````Proof. intros F x y f g (Hx1,(Hx2,_)) (Hy1,(_,Hy2)) Hxy. apply Hy2. apply Hx1. now apply Rle_trans with (2 := Hxy). Qed. Theorem Rnd_DN_monotone : forall F : R -> Prop, forall rnd : R -> R, Rnd_DN F rnd -> MonotoneP rnd. Proof. intros F rnd Hr x y Hxy. now eapply Rnd_DN_pt_monotone. Qed. `````` Guillaume Melquiond committed Jan 23, 2009 98 99 100 101 102 103 ``````Theorem Rnd_DN_pt_unicity : forall F : R -> Prop, forall x f1 f2 : R, Rnd_DN_pt F x f1 -> Rnd_DN_pt F x f2 -> f1 = f2. Proof. `````` Guillaume Melquiond committed Oct 29, 2009 104 ``````intros F. `````` Guillaume Melquiond committed Oct 01, 2010 105 ``````apply round_unicity. `````` Guillaume Melquiond committed Oct 29, 2009 106 ``````apply Rnd_DN_pt_monotone. `````` Guillaume Melquiond committed Jan 23, 2009 107 108 109 110 111 112 113 114 115 116 117 118 ``````Qed. Theorem Rnd_DN_unicity : forall F : R -> Prop, forall rnd1 rnd2 : R -> R, Rnd_DN F rnd1 -> Rnd_DN F rnd2 -> forall x, rnd1 x = rnd2 x. Proof. intros F rnd1 rnd2 H1 H2 x. now eapply Rnd_DN_pt_unicity. Qed. `````` Guillaume Melquiond committed Oct 29, 2009 119 120 ``````Theorem Rnd_UP_pt_monotone : forall F : R -> Prop, `````` Guillaume Melquiond committed Oct 01, 2010 121 `````` round_pred_monotone (Rnd_UP_pt F). `````` Guillaume Melquiond committed Oct 29, 2009 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 ``````Proof. intros F x y f g (Hx1,(_,Hx2)) (Hy1,(Hy2,_)) Hxy. apply Hx2. apply Hy1. now apply Rle_trans with (1 := Hxy). Qed. Theorem Rnd_UP_monotone : forall F : R -> Prop, forall rnd : R -> R, Rnd_UP F rnd -> MonotoneP rnd. Proof. intros F rnd Hr x y Hxy. now eapply Rnd_UP_pt_monotone. Qed. `````` Guillaume Melquiond committed Jan 23, 2009 139 140 141 142 143 144 ``````Theorem Rnd_UP_pt_unicity : forall F : R -> Prop, forall x f1 f2 : R, Rnd_UP_pt F x f1 -> Rnd_UP_pt F x f2 -> f1 = f2. Proof. `````` Guillaume Melquiond committed Oct 29, 2009 145 ``````intros F. `````` Guillaume Melquiond committed Oct 01, 2010 146 ``````apply round_unicity. `````` Guillaume Melquiond committed Oct 29, 2009 147 ``````apply Rnd_UP_pt_monotone. `````` Guillaume Melquiond committed Jan 23, 2009 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 ``````Qed. Theorem Rnd_UP_unicity : forall F : R -> Prop, forall rnd1 rnd2 : R -> R, Rnd_UP F rnd1 -> Rnd_UP F rnd2 -> forall x, rnd1 x = rnd2 x. Proof. intros F rnd1 rnd2 H1 H2 x. now eapply Rnd_UP_pt_unicity. Qed. Theorem Rnd_DN_UP_pt_sym : forall F : R -> Prop, ( forall x, F x -> F (- x) ) -> forall x f : R, `````` Guillaume Melquiond committed May 17, 2010 164 `````` Rnd_DN_pt F x f -> Rnd_UP_pt F (-x) (-f). `````` Guillaume Melquiond committed Jan 23, 2009 165 166 167 168 169 ``````Proof. intros F HF x f H. repeat split. apply HF. apply H. `````` Guillaume Melquiond committed May 17, 2010 170 ``````apply Ropp_le_contravar. `````` Guillaume Melquiond committed Jan 23, 2009 171 ``````apply H. `````` Guillaume Melquiond committed May 17, 2010 172 173 174 175 ``````intros g Hg. rewrite <- (Ropp_involutive g). intros Hxg. apply Ropp_le_contravar. `````` Guillaume Melquiond committed Jan 23, 2009 176 177 ``````apply H. now apply HF. `````` Guillaume Melquiond committed May 17, 2010 178 ``````now apply Ropp_le_cancel. `````` Guillaume Melquiond committed Jan 23, 2009 179 180 ``````Qed. `````` Guillaume Melquiond committed Apr 08, 2009 181 182 183 184 ``````Theorem Rnd_UP_DN_pt_sym : forall F : R -> Prop, ( forall x, F x -> F (- x) ) -> forall x f : R, `````` Guillaume Melquiond committed May 17, 2010 185 `````` Rnd_UP_pt F x f -> Rnd_DN_pt F (-x) (-f). `````` Guillaume Melquiond committed Apr 08, 2009 186 187 188 189 190 ``````Proof. intros F HF x f H. repeat split. apply HF. apply H. `````` Guillaume Melquiond committed May 17, 2010 191 ``````apply Ropp_le_contravar. `````` Guillaume Melquiond committed Apr 08, 2009 192 ``````apply H. `````` Guillaume Melquiond committed May 17, 2010 193 194 195 196 ``````intros g Hg. rewrite <- (Ropp_involutive g). intros Hxg. apply Ropp_le_contravar. `````` Guillaume Melquiond committed Apr 08, 2009 197 198 ``````apply H. now apply HF. `````` Guillaume Melquiond committed May 17, 2010 199 ``````now apply Ropp_le_cancel. `````` Guillaume Melquiond committed Apr 08, 2009 200 201 ``````Qed. `````` Guillaume Melquiond committed Jan 23, 2009 202 203 204 205 206 207 208 209 210 211 212 213 ``````Theorem Rnd_DN_UP_sym : forall F : R -> Prop, ( forall x, F x -> F (- x) ) -> forall rnd1 rnd2 : R -> R, Rnd_DN F rnd1 -> Rnd_UP F rnd2 -> forall x, rnd1 (- x) = - rnd2 x. Proof. intros F HF rnd1 rnd2 H1 H2 x. rewrite <- (Ropp_involutive (rnd1 (-x))). apply f_equal. apply (Rnd_UP_unicity F (fun x => - rnd1 (-x))) ; trivial. intros y. `````` Guillaume Melquiond committed May 17, 2010 214 ``````pattern y at 1 ; rewrite <- Ropp_involutive. `````` Guillaume Melquiond committed Jan 23, 2009 215 216 217 218 219 ``````apply Rnd_DN_UP_pt_sym. apply HF. apply H1. Qed. `````` Guillaume Melquiond committed Feb 24, 2010 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 ``````Theorem Rnd_DN_UP_pt_split : forall F : R -> Prop, forall x d u, Rnd_DN_pt F x d -> Rnd_UP_pt F x u -> forall f, F f -> (f <= d) \/ (u <= f). Proof. intros F x d u Hd Hu f Hf. destruct (Rle_or_lt f x). left. now apply Hd. right. assert (H' := Rlt_le _ _ H). now apply Hu. Qed. `````` Guillaume Melquiond committed Oct 30, 2009 237 238 239 240 241 242 243 244 245 246 247 248 ``````Theorem Rnd_DN_pt_refl : forall F : R -> Prop, forall x : R, F x -> Rnd_DN_pt F x x. Proof. intros F x Hx. repeat split. exact Hx. apply Rle_refl. now intros. Qed. `````` Guillaume Melquiond committed Jan 23, 2009 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 ``````Theorem Rnd_DN_pt_idempotent : forall F : R -> Prop, forall x f : R, Rnd_DN_pt F x f -> F x -> f = x. Proof. intros F x f (_,(Hx1,Hx2)) Hx. apply Rle_antisym. exact Hx1. apply Hx2. exact Hx. apply Rle_refl. Qed. Theorem Rnd_DN_idempotent : forall F : R -> Prop, forall rnd : R -> R, Rnd_DN F rnd -> IdempotentP F rnd. Proof. intros F rnd Hr. split. intros. eapply Hr. intros x Hx. now apply Rnd_DN_pt_idempotent with (2 := Hx). Qed. `````` Guillaume Melquiond committed Oct 30, 2009 277 278 279 280 281 282 283 284 285 286 287 288 ``````Theorem Rnd_UP_pt_refl : forall F : R -> Prop, forall x : R, F x -> Rnd_UP_pt F x x. Proof. intros F x Hx. repeat split. exact Hx. apply Rle_refl. now intros. Qed. `````` Guillaume Melquiond committed Jan 23, 2009 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 ``````Theorem Rnd_UP_pt_idempotent : forall F : R -> Prop, forall x f : R, Rnd_UP_pt F x f -> F x -> f = x. Proof. intros F x f (_,(Hx1,Hx2)) Hx. apply Rle_antisym. apply Hx2. exact Hx. apply Rle_refl. exact Hx1. Qed. Theorem Rnd_UP_idempotent : forall F : R -> Prop, forall rnd : R -> R, Rnd_UP F rnd -> IdempotentP F rnd. Proof. intros F rnd Hr. split. intros. eapply Hr. intros x Hx. now apply Rnd_UP_pt_idempotent with (2 := Hx). Qed. Theorem Rnd_DN_pt_le_rnd : forall F : R -> Prop, forall rnd : R -> R, Rounding_for_Format F rnd -> forall x fd : R, Rnd_DN_pt F x fd -> fd <= rnd x. Proof. intros F rnd (Hr1,(Hr2,Hr3)) x fd Hd. replace fd with (rnd fd). apply Hr1. apply Hd. apply Hr3. apply Hd. Qed. Theorem Rnd_DN_le_rnd : forall F : R -> Prop, forall rndd rnd: R -> R, Rnd_DN F rndd -> Rounding_for_Format F rnd -> forall x, rndd x <= rnd x. Proof. intros F rndd rnd Hd Hr x. eapply Rnd_DN_pt_le_rnd. apply Hr. apply Hd. Qed. Theorem Rnd_UP_pt_ge_rnd : forall F : R -> Prop, forall rnd : R -> R, Rounding_for_Format F rnd -> forall x fu : R, Rnd_UP_pt F x fu -> rnd x <= fu. Proof. intros F rnd (Hr1,(Hr2,Hr3)) x fu Hu. replace fu with (rnd fu). apply Hr1. apply Hu. apply Hr3. apply Hu. Qed. Theorem Rnd_UP_ge_rnd : forall F : R -> Prop, forall rndu rnd: R -> R, Rnd_UP F rndu -> Rounding_for_Format F rnd -> forall x, rnd x <= rndu x. Proof. intros F rndu rnd Hu Hr x. eapply Rnd_UP_pt_ge_rnd. apply Hr. apply Hu. Qed. `````` Guillaume Melquiond committed Oct 29, 2009 375 ``````Theorem Only_DN_or_UP : `````` Guillaume Melquiond committed Jan 23, 2009 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 `````` forall F : R -> Prop, forall x fd fu f : R, Rnd_DN_pt F x fd -> Rnd_UP_pt F x fu -> F f -> (fd <= f <= fu)%R -> f = fd \/ f = fu. Proof. intros F x fd fu f Hd Hu Hf ([Hdf|Hdf], Hfu). 2 : now left. destruct Hfu. 2 : now right. destruct (Rle_or_lt x f). elim Rlt_not_le with (1 := H). now apply Hu. elim Rlt_not_le with (1 := Hdf). apply Hd ; auto with real. Qed. Theorem Rnd_DN_or_UP_pt : forall F : R -> Prop, forall rnd : R -> R, Rounding_for_Format F rnd -> forall x fd fu : R, Rnd_DN_pt F x fd -> Rnd_UP_pt F x fu -> rnd x = fd \/ rnd x = fu. Proof. intros F rnd Hr x fd fu Hd Hu. eapply Only_DN_or_UP ; try eassumption. apply Hr. split. eapply Rnd_DN_pt_le_rnd ; eassumption. eapply Rnd_UP_pt_ge_rnd ; eassumption. Qed. Theorem Rnd_DN_or_UP : forall F : R -> Prop, forall rndd rndu rnd : R -> R, Rnd_DN F rndd -> Rnd_UP F rndu -> Rounding_for_Format F rnd -> forall x, rnd x = rndd x \/ rnd x = rndu x. Proof. intros F rndd rndu rnd Hd Hu Hr x. eapply Rnd_DN_or_UP_pt. apply Hr. apply Hd. apply Hu. Qed. `````` Guillaume Melquiond committed Oct 29, 2009 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 ``````Theorem Rnd_ZR_abs : forall (F : R -> Prop) (rnd: R-> R), Rnd_ZR F rnd -> forall x : R, (Rabs (rnd x) <= Rabs x)%R. Proof. intros F rnd H x. assert (F 0%R). replace 0%R with (rnd 0%R). eapply H. apply Rle_refl. destruct (H 0%R) as (H1, H2). apply Rle_antisym. apply H1. apply Rle_refl. apply H2. apply Rle_refl. (* . *) destruct (Rle_or_lt 0 x). (* positive *) rewrite Rabs_right. rewrite Rabs_right; auto with real. now apply (proj1 (H x)). apply Rle_ge. now apply (proj1 (H x)). (* negative *) rewrite Rabs_left1. rewrite Rabs_left1 ; auto with real. apply Ropp_le_contravar. apply (proj2 (H x)). auto with real. apply (proj2 (H x)) ; auto with real. Qed. `````` Guillaume Melquiond committed Oct 29, 2009 456 457 ``````Theorem Rnd_ZR_pt_monotone : forall F : R -> Prop, F 0 -> `````` Guillaume Melquiond committed Oct 01, 2010 458 `````` round_pred_monotone (Rnd_ZR_pt F). `````` Guillaume Melquiond committed Oct 29, 2009 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 ``````Proof. intros F F0 x y f g (Hx1, Hx2) (Hy1, Hy2) Hxy. destruct (Rle_or_lt 0 x) as [Hx|Hx]. (* . *) apply Hy1. now apply Rle_trans with x. now apply Hx1. apply Rle_trans with (2 := Hxy). now apply Hx1. (* . *) apply Rlt_le in Hx. destruct (Rle_or_lt 0 y) as [Hy|Hy]. apply Rle_trans with 0. now apply Hx2. now apply Hy1. apply Rlt_le in Hy. apply Hx2. exact Hx. now apply Hy2. apply Rle_trans with (1 := Hxy). now apply Hy2. Qed. `````` Guillaume Melquiond committed Jan 23, 2009 482 ``````Theorem Rnd_N_pt_DN_or_UP : `````` Guillaume Melquiond committed Sep 18, 2009 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 `````` forall F : R -> Prop, forall x f : R, Rnd_N_pt F x f -> Rnd_DN_pt F x f \/ Rnd_UP_pt F x f. Proof. intros F x f (Hf1,Hf2). destruct (Rle_or_lt x f) as [Hxf|Hxf]. (* . *) right. repeat split ; try assumption. intros g Hg Hxg. specialize (Hf2 g Hg). rewrite 2!Rabs_pos_eq in Hf2. now apply Rplus_le_reg_r with (-x)%R. now apply Rle_0_minus. now apply Rle_0_minus. (* . *) left. repeat split ; try assumption. now apply Rlt_le. intros g Hg Hxg. specialize (Hf2 g Hg). rewrite 2!Rabs_left1 in Hf2. generalize (Ropp_le_cancel _ _ Hf2). intros H. now apply Rplus_le_reg_r with (-x)%R. now apply Rle_minus. apply Rlt_le. now apply Rlt_minus. Qed. Theorem Rnd_N_pt_DN_or_UP_eq : `````` Guillaume Melquiond committed Jan 23, 2009 515 516 517 518 519 520 521 `````` forall F : R -> Prop, forall x fd fu f : R, Rnd_DN_pt F x fd -> Rnd_UP_pt F x fu -> Rnd_N_pt F x f -> f = fd \/ f = fu. Proof. intros F x fd fu f Hd Hu Hf. `````` Guillaume Melquiond committed Sep 18, 2009 522 523 524 525 526 ``````destruct (Rnd_N_pt_DN_or_UP F x f Hf) as [H|H]. left. apply Rnd_DN_pt_unicity with (1 := H) (2 := Hd). right. apply Rnd_UP_pt_unicity with (1 := H) (2 := Hu). `````` Guillaume Melquiond committed Jan 23, 2009 527 528 ``````Qed. `````` Guillaume Melquiond committed Sep 15, 2009 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 ``````Theorem Rnd_N_pt_sym : forall F : R -> Prop, ( forall x, F x -> F (- x) ) -> forall x f : R, Rnd_N_pt F (-x) (-f) -> Rnd_N_pt F x f. Proof. intros F HF x f (H1,H2). rewrite <- (Ropp_involutive f). repeat split. apply HF. apply H1. intros g H3. rewrite Ropp_involutive. replace (f - x)%R with (-(-f - -x))%R by ring. replace (g - x)%R with (-(-g - -x))%R by ring. rewrite 2!Rabs_Ropp. apply H2. now apply HF. Qed. `````` Guillaume Melquiond committed Jan 23, 2009 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 ``````Theorem Rnd_N_pt_monotone : forall F : R -> Prop, forall x y f g : R, Rnd_N_pt F x f -> Rnd_N_pt F y g -> x < y -> f <= g. Proof. intros F x y f g (Hf,Hx) (Hg,Hy) Hxy. apply Rnot_lt_le. intros Hgf. assert (Hfgx := Hx g Hg). assert (Hgfy := Hy f Hf). clear F Hf Hg Hx Hy. destruct (Rle_or_lt x g) as [Hxg|Hgx]. (* x <= g < f *) apply Rle_not_lt with (1 := Hfgx). rewrite 2!Rabs_pos_eq. now apply Rplus_lt_compat_r. apply Rle_0_minus. apply Rlt_le. now apply Rle_lt_trans with (1 := Hxg). now apply Rle_0_minus. assert (Hgy := Rlt_trans _ _ _ Hgx Hxy). destruct (Rle_or_lt f y) as [Hfy|Hyf]. (* g < f <= y *) apply Rle_not_lt with (1 := Hgfy). rewrite (Rabs_left (g - y)). 2: now apply Rlt_minus. rewrite Rabs_left1. apply Ropp_lt_contravar. now apply Rplus_lt_compat_r. now apply Rle_minus. (* g < x < y < f *) rewrite Rabs_left, Rabs_pos_eq, Ropp_minus_distr in Hgfy. rewrite Rabs_pos_eq, Rabs_left, Ropp_minus_distr in Hfgx. apply Rle_not_lt with (1 := Rplus_le_compat _ _ _ _ Hfgx Hgfy). apply Rminus_lt. ring_simplify. apply Rlt_minus. apply Rmult_lt_compat_l. now apply (Z2R_lt 0 2). exact Hxy. now apply Rlt_minus. apply Rle_0_minus. apply Rlt_le. now apply Rlt_trans with (1 := Hxy). apply Rle_0_minus. now apply Rlt_le. now apply Rlt_minus. Qed. Theorem Rnd_N_monotone : forall F : R -> Prop, forall rnd : R -> R, Rnd_N F rnd -> MonotoneP rnd. Proof. intros F rnd Hr x y [Hxy|Hxy]. now apply Rnd_N_pt_monotone with F x y. rewrite Hxy. apply Rle_refl. Qed. `````` Guillaume Melquiond committed May 11, 2010 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 ``````Theorem Rnd_N_pt_unicity : forall F : R -> Prop, forall x d u f1 f2 : R, Rnd_DN_pt F x d -> Rnd_UP_pt F x u -> x - d <> u - x -> Rnd_N_pt F x f1 -> Rnd_N_pt F x f2 -> f1 = f2. Proof. intros F x d u f1 f2 Hd Hu Hdu. assert (forall f1 f2, Rnd_N_pt F x f1 -> Rnd_N_pt F x f2 -> f1 < f2 -> False). clear f1 f2. intros f1 f2 Hf1 Hf2 H12. destruct (Rnd_N_pt_DN_or_UP F x f1 Hf1) as [Hd1|Hu1] ; destruct (Rnd_N_pt_DN_or_UP F x f2 Hf2) as [Hd2|Hu2]. apply Rlt_not_eq with (1 := H12). now apply Rnd_DN_pt_unicity with (1 := Hd1). apply Hdu. rewrite Rnd_DN_pt_unicity with (1 := Hd) (2 := Hd1). rewrite Rnd_UP_pt_unicity with (1 := Hu) (2 := Hu2). rewrite <- (Rabs_pos_eq (x - f1)). rewrite <- (Rabs_pos_eq (f2 - x)). rewrite Rabs_minus_sym. apply Rle_antisym. apply Hf1. apply Hf2. apply Hf2. apply Hf1. apply Rle_0_minus. apply Hu2. apply Rle_0_minus. apply Hd1. apply Rlt_not_le with (1 := H12). apply Rle_trans with x. apply Hd2. apply Hu1. apply Rgt_not_eq with (1 := H12). now apply Rnd_UP_pt_unicity with (1 := Hu2). intros Hf1 Hf2. now apply Rle_antisym ; apply Rnot_lt_le ; refine (H _ _ _ _). Qed. `````` Guillaume Melquiond committed Oct 30, 2009 651 652 653 654 655 656 657 658 659 660 661 662 663 664 ``````Theorem Rnd_N_pt_refl : forall F : R -> Prop, forall x : R, F x -> Rnd_N_pt F x x. Proof. intros F x Hx. repeat split. exact Hx. intros g _. unfold Rminus at 1. rewrite Rplus_opp_r, Rabs_R0. apply Rabs_pos. Qed. `````` Guillaume Melquiond committed Jan 23, 2009 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 ``````Theorem Rnd_N_pt_idempotent : forall F : R -> Prop, forall x f : R, Rnd_N_pt F x f -> F x -> f = x. Proof. intros F x f (_,Hf) Hx. apply Rminus_diag_uniq. destruct (Req_dec (f - x) 0) as [H|H]. exact H. elim Rabs_no_R0 with (1 := H). apply Rle_antisym. replace 0 with (Rabs (x - x)). now apply Hf. unfold Rminus. rewrite Rplus_opp_r. apply Rabs_R0. apply Rabs_pos. Qed. Theorem Rnd_N_idempotent : forall F : R -> Prop, forall rnd : R -> R, Rnd_N F rnd -> IdempotentP F rnd. Proof. intros F rnd Hr. split. intros x. eapply Hr. intros x Hx. now apply Rnd_N_pt_idempotent with F. Qed. `````` Guillaume Melquiond committed Sep 16, 2009 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 ``````Theorem Rnd_N_pt_0 : forall F : R -> Prop, F 0 -> Rnd_N_pt F 0 0. Proof. intros F HF. split. exact HF. intros g _. rewrite 2!Rminus_0_r, Rabs_R0. apply Rabs_pos. Qed. Theorem Rnd_N_pt_pos : forall F : R -> Prop, F 0 -> forall x f, 0 <= x -> Rnd_N_pt F x f -> 0 <= f. Proof. intros F HF x f [Hx|Hx] Hxf. eapply Rnd_N_pt_monotone ; try eassumption. now apply Rnd_N_pt_0. right. apply sym_eq. apply Rnd_N_pt_idempotent with F. now rewrite Hx. exact HF. Qed. Theorem Rnd_N_pt_neg : forall F : R -> Prop, F 0 -> forall x f, x <= 0 -> Rnd_N_pt F x f -> f <= 0. Proof. intros F HF x f [Hx|Hx] Hxf. eapply Rnd_N_pt_monotone ; try eassumption. now apply Rnd_N_pt_0. right. apply Rnd_N_pt_idempotent with F. now rewrite <- Hx. exact HF. Qed. `````` Guillaume Melquiond committed Sep 02, 2010 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 ``````Theorem Rnd_N_pt_abs : forall F : R -> Prop, F 0 -> ( forall x, F x -> F (- x) ) -> forall x f : R, Rnd_N_pt F x f -> Rnd_N_pt F (Rabs x) (Rabs f). Proof. intros F HF0 HF x f Hxf. unfold Rabs at 1. destruct (Rcase_abs x) as [Hx|Hx]. rewrite Rabs_left1. apply Rnd_N_pt_sym. exact HF. now rewrite 2!Ropp_involutive. apply Rnd_N_pt_neg with (3 := Hxf). exact HF0. now apply Rlt_le. rewrite Rabs_pos_eq. exact Hxf. apply Rnd_N_pt_pos with (3 := Hxf). exact HF0. now apply Rge_le. Qed. `````` Guillaume Melquiond committed Apr 13, 2010 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 ``````Theorem Rnd_DN_UP_pt_N : forall F : R -> Prop, forall x d u f : R, F f -> Rnd_DN_pt F x d -> Rnd_UP_pt F x u -> (Rabs (f - x) <= x - d)%R -> (Rabs (f - x) <= u - x)%R -> Rnd_N_pt F x f. Proof. intros F x d u f Hf Hxd Hxu Hd Hu. split. exact Hf. intros g Hg. destruct (Rnd_DN_UP_pt_split F x d u Hxd Hxu g Hg) as [Hgd|Hgu]. (* g <= d *) apply Rle_trans with (1 := Hd). rewrite Rabs_left1. rewrite Ropp_minus_distr. apply Rplus_le_compat_l. now apply Ropp_le_contravar. apply Rle_minus. apply Rle_trans with (1 := Hgd). apply Hxd. (* u <= g *) apply Rle_trans with (1 := Hu). rewrite Rabs_pos_eq. now apply Rplus_le_compat_r. apply Rle_0_minus. apply Rle_trans with (2 := Hgu). apply Hxu. Qed. `````` Guillaume Melquiond committed May 17, 2010 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 ``````Theorem Rnd_DN_pt_N : forall F : R -> Prop, forall x d u : R, Rnd_DN_pt F x d -> Rnd_UP_pt F x u -> (x - d <= u - x)%R -> Rnd_N_pt F x d. Proof. intros F x d u Hd Hu Hx. assert (Hdx: (Rabs (d - x) = x - d)%R). rewrite Rabs_minus_sym. apply Rabs_pos_eq. apply Rle_0_minus. apply Hd. apply Rnd_DN_UP_pt_N with (2 := Hd) (3 := Hu). apply Hd. rewrite Hdx. apply Rle_refl. now rewrite Hdx. Qed. Theorem Rnd_UP_pt_N : forall F : R -> Prop, forall x d u : R, Rnd_DN_pt F x d -> Rnd_UP_pt F x u -> (u - x <= x - d)%R -> Rnd_N_pt F x u. Proof. intros F x d u Hd Hu Hx. assert (Hux: (Rabs (u - x) = u - x)%R). apply Rabs_pos_eq. apply Rle_0_minus. apply Hu. apply Rnd_DN_UP_pt_N with (2 := Hd) (3 := Hu). apply Hu. now rewrite Hux. rewrite Hux. apply Rle_refl. Qed. `````` Guillaume Melquiond committed Oct 07, 2009 841 842 843 844 845 ``````Definition Rnd_NG_pt_unicity_prop F P := forall x d u, Rnd_DN_pt F x d -> Rnd_N_pt F x d -> Rnd_UP_pt F x u -> Rnd_N_pt F x u -> P x d -> P x u -> d = u. `````` Guillaume Melquiond committed Sep 24, 2009 846 `````` `````` Guillaume Melquiond committed Oct 07, 2009 847 848 849 ``````Theorem Rnd_NG_pt_unicity : forall (F : R -> Prop) (P : R -> R -> Prop), Rnd_NG_pt_unicity_prop F P -> `````` Guillaume Melquiond committed Sep 24, 2009 850 `````` forall x f1 f2 : R, `````` Guillaume Melquiond committed Oct 07, 2009 851 `````` Rnd_NG_pt F P x f1 -> Rnd_NG_pt F P x f2 -> `````` Guillaume Melquiond committed Sep 24, 2009 852 853 854 855 856 857 858 859 860 861 `````` f1 = f2. Proof. intros F P HP x f1 f2 (H1a,H1b) (H2a,H2b). destruct H1b as [H1b|H1b]. destruct H2b as [H2b|H2b]. destruct (Rnd_N_pt_DN_or_UP _ _ _ H1a) as [H1c|H1c] ; destruct (Rnd_N_pt_DN_or_UP _ _ _ H2a) as [H2c|H2c]. eapply Rnd_DN_pt_unicity ; eassumption. now apply (HP x f1 f2). apply sym_eq. `````` Guillaume Melquiond committed Oct 07, 2009 862 ``````now apply (HP x f2 f1 H2c H2a H1c H1a). `````` Guillaume Melquiond committed Sep 24, 2009 863 864 865 866 867 868 ``````eapply Rnd_UP_pt_unicity ; eassumption. now apply H2b. apply sym_eq. now apply H1b. Qed. `````` Guillaume Melquiond committed Oct 07, 2009 869 870 871 ``````Theorem Rnd_NG_pt_monotone : forall (F : R -> Prop) (P : R -> R -> Prop), Rnd_NG_pt_unicity_prop F P -> `````` Guillaume Melquiond committed Oct 01, 2010 872 `````` round_pred_monotone (Rnd_NG_pt F P). `````` Guillaume Melquiond committed Jan 23, 2009 873 ``````Proof. `````` Guillaume Melquiond committed Sep 24, 2009 874 ``````intros F P HP x y f g (Hf,Hx) (Hg,Hy) [Hxy|Hxy]. `````` Guillaume Melquiond committed Jan 23, 2009 875 876 877 ``````now apply Rnd_N_pt_monotone with F x y. apply Req_le. rewrite <- Hxy in Hg, Hy. `````` Guillaume Melquiond committed Oct 07, 2009 878 ``````eapply Rnd_NG_pt_unicity ; try split ; eassumption. `````` Guillaume Melquiond committed Sep 24, 2009 879 880 ``````Qed. `````` Guillaume Melquiond committed Mar 02, 2010 881 882 883 884 885 886 887 888 889 890 891 892 ``````Theorem Rnd_NG_pt_refl : forall (F : R -> Prop) (P : R -> R -> Prop), forall x, F x -> Rnd_NG_pt F P x x. Proof. intros F P x Hx. split. now apply Rnd_N_pt_refl. right. intros f2 Hf2. now apply Rnd_N_pt_idempotent with F. Qed. `````` Guillaume Melquiond committed Oct 07, 2009 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 ``````Theorem Rnd_NG_pt_sym : forall (F : R -> Prop) (P : R -> R -> Prop), ( forall x, F x -> F (-x) ) -> ( forall x f, P x f -> P (-x) (-f) ) -> forall x f : R, Rnd_NG_pt F P (-x) (-f) -> Rnd_NG_pt F P x f. Proof. intros F P HF HP x f (H1,H2). split. now apply Rnd_N_pt_sym. destruct H2 as [H2|H2]. left. rewrite <- (Ropp_involutive x), <- (Ropp_involutive f). now apply HP. right. intros f2 Hxf2. rewrite <- (Ropp_involutive f). rewrite <- H2 with (-f2). apply sym_eq. apply Ropp_involutive. apply Rnd_N_pt_sym. exact HF. now rewrite 2!Ropp_involutive. Qed. `````` Guillaume Melquiond committed Sep 24, 2009 917 `````` `````` Guillaume Melquiond committed Oct 07, 2009 918 ``````Theorem Rnd_NG_unicity : `````` Guillaume Melquiond committed Sep 24, 2009 919 `````` forall (F : R -> Prop) (P : R -> R -> Prop), `````` Guillaume Melquiond committed Oct 07, 2009 920 921 922 923 `````` Rnd_NG_pt_unicity_prop F P -> forall rnd1 rnd2 : R -> R, Rnd_NG F P rnd1 -> Rnd_NG F P rnd2 -> forall x, rnd1 x = rnd2 x. `````` Guillaume Melquiond committed Sep 24, 2009 924 ``````Proof. `````` Guillaume Melquiond committed Oct 07, 2009 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 ``````intros F P HP rnd1 rnd2 H1 H2 x. now apply Rnd_NG_pt_unicity with F P x. Qed. Theorem Rnd_NA_NG_pt : forall F : R -> Prop, F 0 -> forall x f, Rnd_NA_pt F x f <-> Rnd_NG_pt F (fun x f => Rabs x <= Rabs f) x f. Proof. intros F HF x f. destruct (Rle_or_lt 0 x) as [Hx|Hx]. (* *) split ; intros (H1, H2). (* . *) assert (Hf := Rnd_N_pt_pos F HF x f Hx H1). split. exact H1. destruct (Rnd_N_pt_DN_or_UP _ _ _ H1) as [H3|H3]. (* . . *) right. intros f2 Hxf2. specialize (H2 _ Hxf2). destruct (Rnd_N_pt_DN_or_UP _ _ _ Hxf2) as [H4|H4]. `````` Guillaume Melquiond committed Sep 24, 2009 949 ``````eapply Rnd_DN_pt_unicity ; eassumption. `````` Guillaume Melquiond committed Oct 07, 2009 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 ``````apply Rle_antisym. rewrite Rabs_pos_eq with (1 := Hf) in H2. rewrite Rabs_pos_eq in H2. exact H2. now apply Rnd_N_pt_pos with F x. apply Rle_trans with x. apply H3. apply H4. (* . . *) left. rewrite Rabs_pos_eq with (1 := Hf). rewrite Rabs_pos_eq with (1 := Hx). apply H3. (* . *) split. exact H1. intros f2 Hxf2. destruct H2 as [H2|H2]. assert (Hf := Rnd_N_pt_pos F HF x f Hx H1). assert (Hf2 := Rnd_N_pt_pos F HF x f2 Hx Hxf2). rewrite 2!Rabs_pos_eq ; trivial. rewrite 2!Rabs_pos_eq in H2 ; trivial. destruct (Rnd_N_pt_DN_or_UP _ _ _ Hxf2) as [H3|H3]. apply Rle_trans with (2 := H2). apply H3. apply H3. apply H1. apply H2. rewrite (H2 _ Hxf2). apply Rle_refl. (* *) assert (Hx' := Rlt_le _ _ Hx). clear Hx. rename Hx' into Hx. split ; intros (H1, H2). (* . *) assert (Hf := Rnd_N_pt_neg F HF x f Hx H1). split. exact H1. destruct (Rnd_N_pt_DN_or_UP _ _ _ H1) as [H3|H3]. (* . . *) left. rewrite Rabs_left1 with (1 := Hf). rewrite Rabs_left1 with (1 := Hx). apply Ropp_le_contravar. apply H3. (* . . *) right. intros f2 Hxf2. specialize (H2 _ Hxf2). destruct (Rnd_N_pt_DN_or_UP _ _ _ Hxf2) as [H4|H4]. apply Rle_antisym. apply Rle_trans with x. apply H4. apply H3. rewrite Rabs_left1 with (1 := Hf) in H2. rewrite Rabs_left1 in H2. now apply Ropp_le_cancel. now apply Rnd_N_pt_neg with F x. `````` Guillaume Melquiond committed Sep 24, 2009 1008 ``````eapply Rnd_UP_pt_unicity ; eassumption. `````` Guillaume Melquiond committed Oct 07, 2009 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 ``````(* . *) split. exact H1. intros f2 Hxf2. destruct H2 as [H2|H2]. assert (Hf := Rnd_N_pt_neg F HF x f Hx H1). assert (Hf2 := Rnd_N_pt_neg F HF x f2 Hx Hxf2). rewrite 2!Rabs_left1 ; trivial. rewrite 2!Rabs_left1 in H2 ; trivial. apply Ropp_le_contravar. apply Ropp_le_cancel in H2. destruct (Rnd_N_pt_DN_or_UP _ _ _ Hxf2) as [H3|H3]. apply H3. apply H1. apply H2. apply Rle_trans with (1 := H2). apply H3. rewrite (H2 _ Hxf2). apply Rle_refl. `````` Guillaume Melquiond committed Sep 24, 2009 1028 1029 ``````Qed. `````` Guillaume Melquiond committed Oct 29, 2009 1030 ``````Theorem Rnd_NA_pt_unicity_prop : `````` Guillaume Melquiond committed Oct 07, 2009 1031 1032 1033 `````` forall F : R -> Prop, F 0 -> Rnd_NG_pt_unicity_prop F (fun a b => (Rabs a <= Rabs b)%R). `````` Guillaume Melquiond committed Sep 24, 2009 1034 ``````Proof. `````` Guillaume Melquiond committed Oct 07, 2009 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 ``````intros F HF x d u Hxd1 Hxd2 Hxu1 Hxu2 Hd Hu. apply Rle_antisym. apply Rle_trans with x. apply Hxd1. apply Hxu1. destruct (Rle_or_lt 0 x) as [Hx|Hx]. apply Hxu1. apply Hxd1. rewrite Rabs_pos_eq with (1 := Hx) in Hd. rewrite Rabs_pos_eq in Hd. exact Hd. now apply Hxd1. apply Hxd1. apply Hxu1. rewrite Rabs_left with (1 := Hx) in Hu. rewrite Rabs_left1 in Hu. now apply Ropp_le_cancel. apply Hxu1. apply HF. now apply Rlt_le. Qed. Theorem Rnd_NA_pt_unicity : forall F : R -> Prop, F 0 -> forall x f1 f2 : R, Rnd_NA_pt F x f1 -> Rnd_NA_pt F x f2 -> f1 = f2. Proof. intros F HF x f1 f2 H1 H2. apply (Rnd_NG_pt_unicity F _ (Rnd_NA_pt_unicity_prop F HF) x). now apply -> Rnd_NA_NG_pt. now apply -> Rnd_NA_NG_pt. Qed. Theorem Rnd_NA_unicity : forall (F : R -> Prop), F 0 -> forall rnd1 rnd2 : R -> R, Rnd_NA F rnd1 -> Rnd_NA F rnd2 -> forall x, rnd1 x = rnd2 x. Proof. intros F HF rnd1 rnd2 H1 H2 x. now apply Rnd_NA_pt_unicity with F x. `````` Guillaume Melquiond committed Sep 24, 2009 1079 1080 1081 1082 1083 ``````Qed. Theorem Rnd_NA_pt_monotone : forall F : R -> Prop, F 0 -> `````` Guillaume Melquiond committed Oct 01, 2010 1084 `````` round_pred_monotone (Rnd_NA_pt F). `````` Guillaume Melquiond committed Sep 24, 2009 1085 1086 ``````Proof. intros F HF x y f g Hxf Hyg Hxy. `````` Guillaume Melquiond committed Oct 07, 2009 1087 1088 1089 1090 ``````apply (Rnd_NG_pt_monotone F _ (Rnd_NA_pt_unicity_prop F HF) x y). now apply -> Rnd_NA_NG_pt. now apply -> Rnd_NA_NG_pt. exact Hxy. `````` Guillaume Melquiond committed Jan 23, 2009 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 ``````Qed. Theorem Rnd_NA_monotone : forall F : R -> Prop, F 0 -> forall rnd : R -> R, Rnd_NA F rnd -> MonotoneP rnd. Proof. intros F rnd Hr x y Hxy. now apply Rnd_NA_pt_monotone with F. Qed. `````` Guillaume Melquiond committed Oct 30, 2009 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 ``````Theorem Rnd_NA_pt_refl : forall F : R -> Prop, forall x : R, F x -> Rnd_NA_pt F x x. Proof. intros F x Hx. split. now apply Rnd_N_pt_refl. intros f Hxf. apply Req_le. apply f_equal. now apply Rnd_N_pt_idempotent with (1 := Hxf). Qed. `````` Guillaume Melquiond committed Jan 23, 2009 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 ``````Theorem Rnd_NA_pt_idempotent : forall F : R -> Prop, forall x f : R, Rnd_NA_pt F x f -> F x -> f = x. Proof. intros F x f (Hf,_) Hx. now apply Rnd_N_pt_idempotent with F. Qed. Theorem Rnd_NA_idempotent : forall F : R -> Prop, forall rnd : R -> R, Rnd_NA F rnd -> IdempotentP F rnd. Proof. intros F rnd Hr. split. intros x. eapply Hr. intros x Hx. now apply Rnd_NA_pt_idempotent with F. Qed. `````` Guillaume Melquiond committed Oct 01, 2010 1142 ``````Theorem round_pred_pos_imp_rnd : `````` Guillaume Melquiond committed Nov 02, 2009 1143 `````` forall P : R -> R -> Prop, `````` Guillaume Melquiond committed Oct 01, 2010 1144 `````` round_pred_monotone P -> `````` Guillaume Melquiond committed Nov 02, 2009 1145 1146 1147 1148 1149 1150 1151 `````` P 0 0 -> forall x f, P x f -> 0 <= x -> 0 <= f. Proof. intros P HP HP0 x f Hxf Hx. now apply (HP 0 x). Qed. `````` Guillaume Melquiond committed Oct 01, 2010 1152 ``````Theorem round_pred_rnd_imp_pos : `````` Guillaume Melquiond committed Nov 02, 2009 1153 `````` forall P : R -> R -> Prop, `````` Guillaume Melquiond committed Oct 01, 2010 1154 `````` round_pred_monotone P -> `````` Guillaume Melquiond committed Nov 02, 2009 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 `````` P 0 0 -> forall x f, P x f -> 0 < f -> 0 < x. Proof. intros P HP HP0 x f Hxf Hf. apply Rnot_le_lt. intros Hx. apply Rlt_not_le with (1 := Hf). now apply (HP x 0). Qed. `````` Guillaume Melquiond committed Oct 01, 2010 1165 ``````Theorem round_pred_neg_imp_rnd : `````` Guillaume Melquiond committed Nov 02, 2009 1166 `````` forall P : R -> R -> Prop, `````` Guillaume Melquiond committed Oct 01, 2010 1167 `````` round_pred_monotone P -> `````` Guillaume Melquiond committed Nov 02, 2009 1168 1169 1170 1171 1172 1173 1174 `````` P 0 0 -> forall x f, P x f -> x <= 0 -> f <= 0. Proof. intros P HP HP0 x f Hxf Hx. now apply (HP x 0). Qed. `````` Guillaume Melquiond committed Oct 01, 2010 1175 ``````Theorem round_pred_rnd_imp_neg : `````` Guillaume Melquiond committed Nov 02, 2009 1176 `````` forall P : R -> R -> Prop, `````` Guillaume Melquiond committed Oct 01, 2010 1177 `````` round_pred_monotone P -> `````` Guillaume Melquiond committed Nov 02, 2009 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 `````` P 0 0 -> forall x f, P x f -> f < 0 -> x < 0. Proof. intros P HP HP0 x f Hxf Hf. apply Rnot_le_lt. intros Hx. apply Rlt_not_le with (1 := Hf). now apply (HP 0 x). Qed. `````` Guillaume Melquiond committed Jan 23, 2009 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 ``````Theorem Rnd_0 : forall F : R -> Prop, forall rnd : R -> R, F 0 -> Rounding_for_Format F rnd -> rnd 0 = 0. Proof. intros F rnd H0 (_,H2). now apply H2. Qed. Theorem Rnd_pos_imp_pos : forall F : R -> Prop, forall rnd : R -> R, F 0 -> Rounding_for_Format F rnd -> forall x, 0 <= x -> 0 <= rnd x. Proof. intros F rnd H0 H x H'. rewrite <- Rnd_0 with (2 := H) ; trivial. now apply H. Qed. Theorem Rnd_neg_imp_neg : forall F : R -> Prop, forall rnd : R -> R, F 0 -> Rounding_for_Format F rnd -> forall x, x <= 0 -> rnd x <= 0. Proof. intros F rnd H0 H x H'. rewrite <- Rnd_0 with (2 := H) ; trivial. now apply H. Qed. `````` Guillaume Melquiond committed Feb 04, 2010 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 ``````Theorem Rnd_DN_pt_equiv_format : forall F1 F2 : R -> Prop, forall a b : R, F1 a -> ( forall x, a <= x <= b -> (F1 x <-> F2 x) ) -> forall x f, a <= x <= b -> Rnd_DN_pt F1 x f -> Rnd_DN_pt F2 x f. Proof. intros F1 F2 a b Ha HF x f Hx (H1, (H2, H3)). split. apply -> HF. exact H1. split. now apply H3. now apply Rle_trans with (1 := H2). split. exact H2. intros k Hk Hl. destruct (Rlt_or_le k a) as [H|H]. apply Rlt_le. apply Rlt_le_trans with (1 := H). now apply H3. apply H3. apply <- HF. exact Hk. split. exact H. now apply Rle_trans with (1 := Hl). exact Hl. Qed. Theorem Rnd_UP_pt_equiv_format : forall F1 F2 : R -> Prop, forall a b : R, F1 b -> ( forall x, a <= x <= b -> (F1 x <-> F2 x) ) -> forall x f, a <= x <= b -> Rnd_UP_pt F1 x f -> Rnd_UP_pt F2 x f. Proof. intros F1 F2 a b Hb HF x f Hx (H1, (H2, H3)). split. apply -> HF. exact H1. split. now apply Rle_trans with (2 := H2). now apply H3. split. exact H2. intros k Hk Hl. destruct (Rle_or_lt k b) as [H|H]. apply H3. apply <- HF. exact Hk. split. now apply Rle_trans with (2 := Hl). exact H. exact Hl. apply Rlt_le. apply Rle_lt_trans with (2 := H). now apply H3. Qed. `````` Guillaume Melquiond committed Feb 24, 2010 1283 1284 1285 1286 ``````(* ensures a real number can always be rounded *) Inductive satisfies_any (F : R -> Prop) := Satisfies_any : F 0 -> ( forall x : R, F x -> F (-x) ) -> `````` Guillaume Melquiond committed Oct 01, 2010 1287 `````` round_pred_total (Rnd_DN_pt F) -> satisfies_any F. `````` Guillaume Melquiond committed Feb 24, 2010 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 `````` Theorem satisfies_any_eq : forall F1 F2 : R -> Prop, ( forall x, F1 x <-> F2 x ) -> satisfies_any F1 -> satisfies_any F2. Proof. intros F1 F2 Heq (Hzero, Hsym, Hrnd). split. now apply -> Heq. intros x Hx. apply -> Heq. apply Hsym. now apply <- Heq. intros x. destruct (Hrnd x) as (f, (H1, (H2, H3))). exists f. split. now apply -> Heq. split. exact H2. intros g Hg Hgx. apply H3. now apply <- Heq. exact Hgx. Qed. Theorem satisfies_any_imp_DN : forall F : R -> Prop, satisfies_any F -> `````` Guillaume Melquiond committed Oct 01, 2010 1318 `````` round_pred (Rnd_DN_pt F). `````` Guillaume Melquiond committed Feb 24, 2010 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 ``````Proof. intros F (_,_,Hrnd). split. apply Hrnd. apply Rnd_DN_pt_monotone. Qed. Theorem satisfies_any_imp_UP : forall F : R -> Prop, satisfies_any F -> `````` Guillaume Melquiond committed Oct 01, 2010 1329 `````` round_pred (Rnd_UP_pt F). `````` Guillaume Melquiond committed Feb 24, 2010 1330 1331 1332 1333 1334 1335 ``````Proof. intros F Hany. split. intros x. destruct (proj1 (satisfies_any_imp_DN F Hany) (-x)) as (f, Hf). exists (-f). `````` Guillaume Melquiond committed May 17, 2010 1336 ``````rewrite <- (Ropp_involutive x). `````` Guillaume Melquiond committed Feb 24, 2010 1337 1338 ``````apply Rnd_DN_UP_pt_sym. apply Hany. `````` Guillaume Melquiond committed May 17, 2010 1339 ``````exact Hf. `````` Guillaume Melquiond committed Feb 24, 2010 1340 1341 1342 1343 1344 1345 ``````apply Rnd_UP_pt_monotone. Qed. Theorem satisfies_any_imp_ZR : forall F : R -> Prop, satisfies_any F -> `````` Guillaume Melquiond committed Oct 01, 2010 1346 `````` round_pred (Rnd_ZR_pt F). `````` Guillaume Melquiond committed Feb 24, 2010 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 ``````Proof. intros F Hany. split. intros x. destruct (Rle_or_lt 0 x) as [Hx|Hx]. (* positive *) destruct (proj1 (satisfies_any_imp_DN F Hany) x) as (f, Hf). exists f. split. now intros _. intros Hx'. (* zero *) assert (x = 0). now apply Rle_antisym. rewrite H in Hf |- *. clear H Hx Hx'. rewrite Rnd_DN_pt_idempotent with (1 := Hf). apply Rnd_UP_pt_refl. apply Hany. apply Hany. (* negative *) destruct (proj1 (satisfies_any_imp_UP F Hany) x) as (f, Hf). exists f. split. intros Hx'. elim (Rlt_irrefl 0). now apply Rle_lt_trans with x. now intros _. (* . *) apply Rnd_ZR_pt_monotone. apply Hany. Qed. Definition NG_existence_prop (F : R -> Prop) (P : R -> R -> Prop) := forall x d u, ~F x -> Rnd_DN_pt F x d -> Rnd_UP_pt F x u -> P x u \/ P x d. Theorem satisfies_any_imp_NG : forall (F : R -> Prop) (P : R -> R -> Prop), satisfies_any F -> NG_existence_prop F P -> `````` Guillaume Melquiond committed Oct 01, 2010 1387 `````` round_pred_total (Rnd_NG_pt F P). `````` Guillaume Melquiond committed Feb 24, 2010 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 ``````Proof. intros F P Hany HP x. destruct (proj1 (satisfies_any_imp_DN F Hany) x) as (d, Hd). destruct (proj1 (satisfies_any_imp_UP F Hany) x) as (u, Hu). destruct (total_order_T (Rabs (u - x)) (Rabs (d - x))) as [[H|H]|H]. (* |up(x) - x| < |dn(x) - x| *) exists u. split. (* - . *) split. apply Hu. intros g Hg. destruct (Rle_or_lt x g) as [Hxg|Hxg]. rewrite 2!Rabs_pos_eq. apply Rplus_le_compat_r. now apply Hu. now apply Rle_0_minus. apply Rle_0_minus. apply Hu. apply Rlt_le in Hxg. apply Rlt_le. apply Rlt_le_trans with (1 := H). do 2 rewrite <- (Rabs_minus_sym x). rewrite 2!Rabs_pos_eq. apply Rplus_le_compat_l. apply Ropp_le_contravar. now apply Hd. now apply Rle_0_minus. apply Rle_0_minus. apply Hd. (* - . *) right. intros f Hf. destruct (Rnd_N_pt_DN_or_UP_eq F x _ _ _ Hd Hu Hf) as [K|K] ; rewrite K. elim Rlt_not_le with (1 := H). rewrite <- K. apply Hf. apply Hu. apply refl_equal. (* |up(x) - x| = |dn(x) - x| *) destruct (Req_dec x d) as [He|Hne]. (* - x = d = u *) exists x. split. apply Rnd_N_pt_refl. rewrite He. apply Hd. right. intros. apply Rnd_N_pt_idempotent with (1 := H0). rewrite He. apply Hd. assert (Hf : ~F x). intros Hf. apply Hne. apply sym_eq. now apply Rnd_DN_pt_idempotent with (1 := Hd). destruct (HP x _ _ Hf Hd Hu) as [H'|H']. (* - u >> d *) exists u. split. split. apply Hu. intros g Hg. destruct (Rle_or_lt x g) as [Hxg|Hxg]. rewrite 2!Rabs_pos_eq. apply Rplus_le_compat_r. now apply Hu. now apply Rle_0_minus. apply Rle_0_minus. apply Hu. apply Rlt_le in Hxg. rewrite H. rewrite 2!Rabs_left1. apply Ropp_le_contravar. apply Rplus_le_compat_r. now apply Hd. now apply Rle_minus. apply Rle_minus. apply Hd. now left. (* - d >> u *) exists d. split. split. apply Hd. intros g Hg. destruct (Rle_or_lt x g) as [Hxg|Hxg]. rewrite <- H. rewrite 2!Rabs_pos_eq. apply Rplus_le_compat_r. now apply Hu. now apply Rle_0_minus. apply Rle_0_minus. apply Hu. apply Rlt_le in Hxg. rewrite 2!Rabs_left1. apply Ropp_le_contravar. apply Rplus_le_compat_r. now apply Hd. now apply Rle_minus. apply Rle_minus. apply Hd. now left. (* |up(x) - x| > |dn(x) - x| *) exists d. split. split. apply Hd. intros g Hg. destruct (Rle_or_lt x g) as [Hxg|Hxg]. apply Rlt_le. apply Rlt_le_trans with (1 := H). rewrite 2!Rabs_pos_eq. apply Rplus_le_compat_r. now apply Hu. now apply Rle_0_minus. apply Rle_0_minus. apply Hu. apply Rlt_le in Hxg. rewrite 2!Rabs_left1. apply Ropp_le_contravar. apply Rplus_le_compat_r. now apply Hd. now apply Rle_minus. apply Rle_minus. apply Hd. right. intros f Hf. destruct (Rnd_N_pt_DN_or_UP_eq F x _ _ _ Hd Hu Hf) as [K|K] ; rewrite K. apply refl_equal. elim Rlt_not_le with (1 := H). rewrite <- K. apply Hf. apply Hd. Qed. Theorem satisfies_any_imp_NA : forall F : R -> Prop, satisfies_any F -> `````` Guillaume Melquiond committed Oct 01, 2010 1528 `````` round_pred (Rnd_NA_pt F). `````` Guillaume Melquiond committed Feb 24, 2010 1529 1530 1531 ``````Proof. intros F Hany. split. `````` Guillaume Melquiond committed Oct 01, 2010 1532 ``````assert (H : round_pred_total (Rnd_NG_pt F (fun a b => (Rabs a <= Rabs b)%R))). `````` Guillaume Melquiond committed Feb 24, 2010 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 ``````apply satisfies_any_imp_NG. apply Hany. intros x d u Hf Hd Hu. destruct (Rle_lt_dec 0 x) as [Hx|Hx]. left. rewrite Rabs_pos_eq with (1 := Hx). rewrite Rabs_pos_eq. apply Hu. apply Rle_trans with (1 := Hx). apply Hu. right. rewrite Rabs_left with (1 := Hx). rewrite Rabs_left1. apply Ropp_le_contravar. apply Hd. apply Rlt_le in Hx. apply Rle_trans with (2 := Hx). apply Hd. intros x. destruct (H x) as (f, Hf). exists f. apply <- Rnd_NA_NG_pt. apply Hf. apply Hany. apply Rnd_NA_pt_monotone. apply Hany. Qed. `````` Guillaume Melquiond committed Jan 23, 2009 1561 ``End RND_prop.``