1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 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 277 278 279 280 281 282 283 284 285 286 287 288 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
|
(************************************************************************)
(* * The Coq Proof Assistant / The Coq Development Team *)
(* v * Copyright INRIA, CNRS and contributors *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(* \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) *)
(************************************************************************)
Require Import Rdefinitions Raxioms RIneq.
Require Import Rbasic_fun.
Local Open Scope R_scope.
(****************************************************)
(** Rsqr : some results *)
(****************************************************)
Ltac ring_Rsqr := unfold Rsqr; ring.
Lemma Rsqr_neg : forall x:R, Rsqr x = Rsqr (- x).
Proof.
intros; ring_Rsqr.
Qed.
Lemma Rsqr_mult : forall x y:R, Rsqr (x * y) = Rsqr x * Rsqr y.
Proof.
intros; ring_Rsqr.
Qed.
Lemma Rsqr_plus : forall x y:R, Rsqr (x + y) = Rsqr x + Rsqr y + 2 * x * y.
Proof.
intros; ring_Rsqr.
Qed.
Lemma Rsqr_minus : forall x y:R, Rsqr (x - y) = Rsqr x + Rsqr y - 2 * x * y.
Proof.
intros; ring_Rsqr.
Qed.
Lemma Rsqr_neg_minus : forall x y:R, Rsqr (x - y) = Rsqr (y - x).
Proof.
intros; ring_Rsqr.
Qed.
Lemma Rsqr_1 : Rsqr 1 = 1.
Proof.
ring_Rsqr.
Qed.
Lemma Rsqr_gt_0_0 : forall x:R, 0 < Rsqr x -> x <> 0.
Proof.
intros; red; intro; rewrite H0 in H; rewrite Rsqr_0 in H;
elim (Rlt_irrefl 0 H).
Qed.
Lemma Rsqr_pos_lt : forall x:R, x <> 0 -> 0 < Rsqr x.
Proof.
intros; case (Rtotal_order 0 x); intro;
[ unfold Rsqr; apply Rmult_lt_0_compat; assumption
| elim H0; intro;
[ elim H; symmetry ; exact H1
| rewrite Rsqr_neg; generalize (Ropp_lt_gt_contravar x 0 H1);
rewrite Ropp_0; intro; unfold Rsqr;
apply Rmult_lt_0_compat; assumption ] ].
Qed.
Lemma Rsqr_div' x y : Rsqr (x / y) = Rsqr x / Rsqr y.
Proof.
unfold Rsqr, Rdiv.
rewrite Rinv_mult.
ring.
Qed.
Lemma Rsqr_div_depr : forall x y:R, y <> 0 -> Rsqr (x / y) = Rsqr x / Rsqr y.
Proof.
intros x y _.
apply Rsqr_div'.
Qed.
#[deprecated(since="8.16",note="Use Rsqr_div'.")]
Notation Rsqr_div := Rsqr_div_depr.
Lemma Rsqr_eq_0 : forall x:R, Rsqr x = 0 -> x = 0.
Proof.
unfold Rsqr; intros; generalize (Rmult_integral x x H); intro;
elim H0; intro; assumption.
Qed.
Lemma Rsqr_minus_plus : forall a b:R, (a - b) * (a + b) = Rsqr a - Rsqr b.
Proof.
intros; ring_Rsqr.
Qed.
Lemma Rsqr_plus_minus : forall a b:R, (a + b) * (a - b) = Rsqr a - Rsqr b.
Proof.
intros; ring_Rsqr.
Qed.
Lemma Rsqr_incr_0 :
forall x y:R, Rsqr x <= Rsqr y -> 0 <= x -> 0 <= y -> x <= y.
Proof.
intros; destruct (Rle_dec x y) as [Hle|Hnle];
[ assumption
| cut (y < x);
[ intro; unfold Rsqr in H;
generalize (Rmult_le_0_lt_compat y x y x H1 H1 H2 H2);
intro; generalize (Rle_lt_trans (x * x) (y * y) (x * x) H H3);
intro; elim (Rlt_irrefl (x * x) H4)
| auto with real ] ].
Qed.
Lemma Rsqr_incr_0_var : forall x y:R, Rsqr x <= Rsqr y -> 0 <= y -> x <= y.
Proof.
intros; destruct (Rle_dec x y) as [Hle|Hnle];
[ assumption
| cut (y < x);
[ intro; unfold Rsqr in H;
generalize (Rmult_le_0_lt_compat y x y x H0 H0 H1 H1);
intro; generalize (Rle_lt_trans (x * x) (y * y) (x * x) H H2);
intro; elim (Rlt_irrefl (x * x) H3)
| auto with real ] ].
Qed.
Lemma Rsqr_incr_1 :
forall x y:R, x <= y -> 0 <= x -> 0 <= y -> Rsqr x <= Rsqr y.
Proof.
intros; unfold Rsqr; apply Rmult_le_compat; assumption.
Qed.
Lemma Rsqr_incrst_0 :
forall x y:R, Rsqr x < Rsqr y -> 0 <= x -> 0 <= y -> x < y.
Proof.
intros; case (Rtotal_order x y); intro;
[ assumption
| elim H2; intro;
[ rewrite H3 in H; elim (Rlt_irrefl (Rsqr y) H)
| generalize (Rmult_le_0_lt_compat y x y x H1 H1 H3 H3); intro;
unfold Rsqr in H; generalize (Rlt_trans (x * x) (y * y) (x * x) H H4);
intro; elim (Rlt_irrefl (x * x) H5) ] ].
Qed.
Lemma Rsqr_incrst_1 :
forall x y:R, x < y -> 0 <= x -> 0 <= y -> Rsqr x < Rsqr y.
Proof.
intros; unfold Rsqr; apply Rmult_le_0_lt_compat; assumption.
Qed.
Lemma Rsqr_neg_pos_le_0 :
forall x y:R, Rsqr x <= Rsqr y -> 0 <= y -> - y <= x.
Proof.
intros; destruct (Rcase_abs x) as [Hlt|Hle].
generalize (Ropp_lt_gt_contravar x 0 Hlt); rewrite Ropp_0; intro;
generalize (Rlt_le 0 (- x) H1); intro; rewrite (Rsqr_neg x) in H;
generalize (Rsqr_incr_0 (- x) y H H2 H0); intro;
rewrite <- (Ropp_involutive x); apply Ropp_ge_le_contravar;
apply Rle_ge; assumption.
apply Rle_trans with 0;
[ rewrite <- Ropp_0; apply Ropp_ge_le_contravar; apply Rle_ge; assumption
| apply Rge_le; assumption ].
Qed.
Lemma Rsqr_neg_pos_le_1 :
forall x y:R, - y <= x -> x <= y -> 0 <= y -> Rsqr x <= Rsqr y.
Proof.
intros x y H H0 H1; destruct (Rcase_abs x) as [Hlt|Hle].
apply Ropp_lt_gt_contravar, Rlt_le in Hlt; rewrite Ropp_0 in Hlt;
apply Ropp_le_ge_contravar, Rge_le in H; rewrite Ropp_involutive in H;
rewrite (Rsqr_neg x); apply Rsqr_incr_1; assumption.
apply Rge_le in Hle; apply Rsqr_incr_1; assumption.
Qed.
Lemma neg_pos_Rsqr_le : forall x y:R, - y <= x -> x <= y -> Rsqr x <= Rsqr y.
Proof.
intros x y H H0; destruct (Rcase_abs x) as [Hlt|Hle].
apply Ropp_lt_gt_contravar, Rlt_le in Hlt; rewrite Ropp_0 in Hlt;
apply Ropp_le_ge_contravar, Rge_le in H; rewrite Ropp_involutive in H.
assert (0 <= y) by (apply Rle_trans with (-x); assumption).
rewrite (Rsqr_neg x); apply Rsqr_incr_1; assumption.
apply Rge_le in Hle;
assert (0 <= y) by (apply Rle_trans with x; assumption).
apply Rsqr_incr_1; assumption.
Qed.
Lemma neg_pos_Rsqr_lt : forall x y : R, - y < x -> x < y -> Rsqr x < Rsqr y.
Proof.
intros x y Hneg Hpos.
destruct (Rcase_abs x) as [Hlt|HLe].
- rewrite (Rsqr_neg x); apply Rsqr_incrst_1.
+ rewrite <- (Ropp_involutive y); apply Ropp_lt_contravar; exact Hneg.
+ rewrite <- (Ropp_0). apply Ropp_le_contravar, Rlt_le; exact Hlt.
+ apply (Rlt_trans _ _ _ Hneg) in Hlt.
rewrite <- (Ropp_0) in Hlt; apply Ropp_lt_cancel in Hlt; apply Rlt_le; exact Hlt.
- apply Rsqr_incrst_1.
+ exact Hpos.
+ apply Rge_le; exact HLe.
+ apply Rge_le in HLe.
apply (Rle_lt_trans _ _ _ HLe), Rlt_le in Hpos; exact Hpos.
Qed.
Lemma Rsqr_bounds_le : forall a b:R, -a <= b <= a -> 0 <= Rsqr b <= Rsqr a.
Proof.
intros a b [H1 H2].
split.
- apply Rle_0_sqr.
- apply neg_pos_Rsqr_le; assumption.
Qed.
Lemma Rsqr_bounds_lt : forall a b:R, -a < b < a -> 0 <= Rsqr b < Rsqr a.
Proof.
intros a b [H1 H2].
split.
- apply Rle_0_sqr.
- apply neg_pos_Rsqr_lt; assumption.
Qed.
Lemma Rsqr_abs : forall x:R, Rsqr x = Rsqr (Rabs x).
Proof.
intro; unfold Rabs; case (Rcase_abs x); intro;
[ apply Rsqr_neg | reflexivity ].
Qed.
Lemma Rsqr_le_abs_0 : forall x y:R, Rsqr x <= Rsqr y -> Rabs x <= Rabs y.
Proof.
intros; apply Rsqr_incr_0; repeat rewrite <- Rsqr_abs;
[ assumption | apply Rabs_pos | apply Rabs_pos ].
Qed.
Lemma Rsqr_le_abs_1 : forall x y:R, Rabs x <= Rabs y -> Rsqr x <= Rsqr y.
Proof.
intros; rewrite (Rsqr_abs x); rewrite (Rsqr_abs y);
apply (Rsqr_incr_1 (Rabs x) (Rabs y) H (Rabs_pos x) (Rabs_pos y)).
Qed.
Lemma Rsqr_lt_abs_0 : forall x y:R, Rsqr x < Rsqr y -> Rabs x < Rabs y.
Proof.
intros; apply Rsqr_incrst_0; repeat rewrite <- Rsqr_abs;
[ assumption | apply Rabs_pos | apply Rabs_pos ].
Qed.
Lemma Rsqr_lt_abs_1 : forall x y:R, Rabs x < Rabs y -> Rsqr x < Rsqr y.
Proof.
intros; rewrite (Rsqr_abs x); rewrite (Rsqr_abs y);
apply (Rsqr_incrst_1 (Rabs x) (Rabs y) H (Rabs_pos x) (Rabs_pos y)).
Qed.
Lemma Rsqr_inj : forall x y:R, 0 <= x -> 0 <= y -> Rsqr x = Rsqr y -> x = y.
Proof.
intros; generalize (Rle_le_eq (Rsqr x) (Rsqr y)); intro; elim H2; intros _ H3;
generalize (H3 H1); intro; elim H4; intros; apply Rle_antisym;
apply Rsqr_incr_0; assumption.
Qed.
Lemma Rsqr_eq_abs_0 : forall x y:R, Rsqr x = Rsqr y -> Rabs x = Rabs y.
Proof.
intros; unfold Rabs; case (Rcase_abs x) as [Hltx|Hgex];
case (Rcase_abs y) as [Hlty|Hgey].
rewrite (Rsqr_neg x), (Rsqr_neg y) in H;
generalize (Ropp_lt_gt_contravar y 0 Hlty);
generalize (Ropp_lt_gt_contravar x 0 Hltx); rewrite Ropp_0;
intros; generalize (Rlt_le 0 (- x) H0); generalize (Rlt_le 0 (- y) H1);
intros; apply Rsqr_inj; assumption.
rewrite (Rsqr_neg x) in H; generalize (Rge_le y 0 Hgey); intro;
generalize (Ropp_lt_gt_contravar x 0 Hltx); rewrite Ropp_0;
intro; generalize (Rlt_le 0 (- x) H1); intro; apply Rsqr_inj;
assumption.
rewrite (Rsqr_neg y) in H; generalize (Rge_le x 0 Hgex); intro;
generalize (Ropp_lt_gt_contravar y 0 Hlty); rewrite Ropp_0;
intro; generalize (Rlt_le 0 (- y) H1); intro; apply Rsqr_inj;
assumption.
apply Rsqr_inj; auto using Rge_le.
Qed.
Lemma Rsqr_eq_asb_1 : forall x y:R, Rabs x = Rabs y -> Rsqr x = Rsqr y.
Proof.
intros; cut (Rsqr (Rabs x) = Rsqr (Rabs y)).
intro; repeat rewrite <- Rsqr_abs in H0; assumption.
rewrite H; reflexivity.
Qed.
Lemma triangle_rectangle :
forall x y z:R,
0 <= z -> Rsqr x + Rsqr y <= Rsqr z -> - z <= x <= z /\ - z <= y <= z.
Proof.
intros;
generalize (plus_le_is_le (Rsqr x) (Rsqr y) (Rsqr z) (Rle_0_sqr y) H0);
rewrite Rplus_comm in H0;
generalize (plus_le_is_le (Rsqr y) (Rsqr x) (Rsqr z) (Rle_0_sqr x) H0);
intros; split;
[ split;
[ apply Rsqr_neg_pos_le_0; assumption
| apply Rsqr_incr_0_var; assumption ]
| split;
[ apply Rsqr_neg_pos_le_0; assumption
| apply Rsqr_incr_0_var; assumption ] ].
Qed.
Lemma triangle_rectangle_lt :
forall x y z:R,
Rsqr x + Rsqr y < Rsqr z -> Rabs x < Rabs z /\ Rabs y < Rabs z.
Proof.
intros; split;
[ generalize (plus_lt_is_lt (Rsqr x) (Rsqr y) (Rsqr z) (Rle_0_sqr y) H);
intro; apply Rsqr_lt_abs_0; assumption
| rewrite Rplus_comm in H;
generalize (plus_lt_is_lt (Rsqr y) (Rsqr x) (Rsqr z) (Rle_0_sqr x) H);
intro; apply Rsqr_lt_abs_0; assumption ].
Qed.
Lemma triangle_rectangle_le :
forall x y z:R,
Rsqr x + Rsqr y <= Rsqr z -> Rabs x <= Rabs z /\ Rabs y <= Rabs z.
Proof.
intros; split;
[ generalize (plus_le_is_le (Rsqr x) (Rsqr y) (Rsqr z) (Rle_0_sqr y) H);
intro; apply Rsqr_le_abs_0; assumption
| rewrite Rplus_comm in H;
generalize (plus_le_is_le (Rsqr y) (Rsqr x) (Rsqr z) (Rle_0_sqr x) H);
intro; apply Rsqr_le_abs_0; assumption ].
Qed.
Lemma Rsqr_inv' x : Rsqr (/ x) = / Rsqr x.
Proof.
unfold Rsqr.
now rewrite Rinv_mult.
Qed.
Lemma Rsqr_inv_depr : forall x:R, x <> 0 -> Rsqr (/ x) = / Rsqr x.
Proof.
intros x _.
apply Rsqr_inv'.
Qed.
#[deprecated(since="8.16",note="Use Rsqr_inv'.")]
Notation Rsqr_inv := Rsqr_inv_depr.
Lemma canonical_Rsqr :
forall (a:nonzeroreal) (b c x:R),
a * Rsqr x + b * x + c =
a * Rsqr (x + b / (2 * a)) + (4 * a * c - Rsqr b) / (4 * a).
Proof.
intros.
unfold Rsqr.
field.
apply a.
Qed.
Lemma Rsqr_eq : forall x y:R, Rsqr x = Rsqr y -> x = y \/ x = - y.
Proof.
intros; unfold Rsqr in H;
generalize (Rplus_eq_compat_l (- (y * y)) (x * x) (y * y) H);
rewrite Rplus_opp_l; replace (- (y * y) + x * x) with ((x - y) * (x + y)).
intro; generalize (Rmult_integral (x - y) (x + y) H0); intro; elim H1; intros.
left; apply Rminus_diag_uniq; assumption.
right; apply Rminus_diag_uniq; unfold Rminus; rewrite Ropp_involutive;
assumption.
ring.
Qed.
|