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

« back to all changes in this revision

Viewing changes to theories/Reals/Ranalysis1.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
(*i $Id: Ranalysis1.v 10710 2008-03-23 09:24:09Z herbelin $ i*)
 
10
 
 
11
Require Import Rbase.
 
12
Require Import Rfunctions.
 
13
Require Export Rlimit.
 
14
Require Export Rderiv.
 
15
Open Local Scope R_scope.
 
16
Implicit Type f : R -> R.
 
17
 
 
18
(****************************************************)
 
19
(** *         Basic operations on functions         *)
 
20
(****************************************************)
 
21
Definition plus_fct f1 f2 (x:R) : R := f1 x + f2 x.
 
22
Definition opp_fct f (x:R) : R := - f x.
 
23
Definition mult_fct f1 f2 (x:R) : R := f1 x * f2 x.
 
24
Definition mult_real_fct (a:R) f (x:R) : R := a * f x.
 
25
Definition minus_fct f1 f2 (x:R) : R := f1 x - f2 x.
 
26
Definition div_fct f1 f2 (x:R) : R := f1 x / f2 x.
 
27
Definition div_real_fct (a:R) f (x:R) : R := a / f x.
 
28
Definition comp f1 f2 (x:R) : R := f1 (f2 x).
 
29
Definition inv_fct f (x:R) : R := / f x.
 
30
 
 
31
Delimit Scope Rfun_scope with F.
 
32
 
 
33
Arguments Scope plus_fct [Rfun_scope Rfun_scope R_scope].
 
34
Arguments Scope mult_fct [Rfun_scope Rfun_scope R_scope].
 
35
Arguments Scope minus_fct [Rfun_scope Rfun_scope R_scope].
 
36
Arguments Scope div_fct [Rfun_scope Rfun_scope R_scope].
 
37
Arguments Scope inv_fct [Rfun_scope R_scope].
 
38
Arguments Scope opp_fct [Rfun_scope R_scope].
 
39
Arguments Scope mult_real_fct [R_scope Rfun_scope R_scope].
 
40
Arguments Scope div_real_fct [R_scope Rfun_scope R_scope].
 
41
Arguments Scope comp [Rfun_scope Rfun_scope R_scope].
 
42
 
 
43
Infix "+" := plus_fct : Rfun_scope.
 
44
Notation "- x" := (opp_fct x) : Rfun_scope.
 
45
Infix "*" := mult_fct : Rfun_scope.
 
46
Infix "-" := minus_fct : Rfun_scope.
 
47
Infix "/" := div_fct : Rfun_scope.
 
48
Notation Local "f1 'o' f2" := (comp f1 f2)
 
49
  (at level 20, right associativity) : Rfun_scope.
 
50
Notation "/ x" := (inv_fct x) : Rfun_scope.
 
51
 
 
52
Definition fct_cte (a x:R) : R := a.
 
53
Definition id (x:R) := x.
 
54
 
 
55
(****************************************************)
 
56
(** *          Variations of functions              *)
 
57
(****************************************************)
 
58
Definition increasing f : Prop := forall x y:R, x <= y -> f x <= f y.
 
59
Definition decreasing f : Prop := forall x y:R, x <= y -> f y <= f x.
 
60
Definition strict_increasing f : Prop := forall x y:R, x < y -> f x < f y.
 
61
Definition strict_decreasing f : Prop := forall x y:R, x < y -> f y < f x.
 
62
Definition constant f : Prop := forall x y:R, f x = f y.
 
63
 
 
64
(**********) 
 
65
Definition no_cond (x:R) : Prop := True.
 
66
 
 
67
(**********)
 
68
Definition constant_D_eq f (D:R -> Prop) (c:R) : Prop :=
 
69
  forall x:R, D x -> f x = c.
 
70
 
 
71
(***************************************************)
 
72
(** *    Definition of continuity as a limit       *)
 
73
(***************************************************)
 
74
 
 
75
(**********)
 
76
Definition continuity_pt f (x0:R) : Prop := continue_in f no_cond x0.
 
77
Definition continuity f : Prop := forall x:R, continuity_pt f x.
 
78
 
 
79
Arguments Scope continuity_pt [Rfun_scope R_scope].
 
80
Arguments Scope continuity [Rfun_scope].
 
81
 
 
82
(**********)
 
83
Lemma continuity_pt_plus :
 
84
  forall f1 f2 (x0:R),
 
85
    continuity_pt f1 x0 -> continuity_pt f2 x0 -> continuity_pt (f1 + f2) x0.
 
86
Proof.
 
87
  unfold continuity_pt, plus_fct in |- *; unfold continue_in in |- *; intros;
 
88
    apply limit_plus; assumption.
 
89
Qed.
 
90
 
 
91
Lemma continuity_pt_opp :
 
92
  forall f (x0:R), continuity_pt f x0 -> continuity_pt (- f) x0.
 
93
Proof.
 
94
  unfold continuity_pt, opp_fct in |- *; unfold continue_in in |- *; intros;
 
95
    apply limit_Ropp; assumption.
 
96
Qed.
 
97
 
 
98
Lemma continuity_pt_minus :
 
99
  forall f1 f2 (x0:R),
 
100
    continuity_pt f1 x0 -> continuity_pt f2 x0 -> continuity_pt (f1 - f2) x0.
 
101
Proof.
 
102
  unfold continuity_pt, minus_fct in |- *; unfold continue_in in |- *; intros;
 
103
    apply limit_minus; assumption.
 
104
Qed.
 
105
 
 
106
Lemma continuity_pt_mult :
 
107
  forall f1 f2 (x0:R),
 
108
    continuity_pt f1 x0 -> continuity_pt f2 x0 -> continuity_pt (f1 * f2) x0.
 
109
Proof.
 
110
  unfold continuity_pt, mult_fct in |- *; unfold continue_in in |- *; intros;
 
111
    apply limit_mul; assumption.
 
112
Qed.
 
113
 
 
114
Lemma continuity_pt_const : forall f (x0:R), constant f -> continuity_pt f x0.
 
115
Proof.
 
116
  unfold constant, continuity_pt in |- *; unfold continue_in in |- *;
 
117
    unfold limit1_in in |- *; unfold limit_in in |- *; 
 
118
      intros; exists 1; split;
 
119
        [ apply Rlt_0_1
 
120
          | intros; generalize (H x x0); intro; rewrite H2; simpl in |- *;
 
121
            rewrite R_dist_eq; assumption ].
 
122
Qed.
 
123
 
 
124
Lemma continuity_pt_scal :
 
125
  forall f (a x0:R),
 
126
    continuity_pt f x0 -> continuity_pt (mult_real_fct a f) x0.
 
127
Proof.
 
128
  unfold continuity_pt, mult_real_fct in |- *; unfold continue_in in |- *;
 
129
    intros; apply (limit_mul (fun x:R => a) f (D_x no_cond x0) a (f x0) x0).
 
130
  unfold limit1_in in |- *; unfold limit_in in |- *; intros; exists 1; split.
 
131
  apply Rlt_0_1.
 
132
  intros; rewrite R_dist_eq; assumption.
 
133
  assumption.
 
134
Qed.
 
135
 
 
136
Lemma continuity_pt_inv :
 
137
  forall f (x0:R), continuity_pt f x0 -> f x0 <> 0 -> continuity_pt (/ f) x0.
 
138
Proof.
 
139
  intros.
 
140
  replace (/ f)%F with (fun x:R => / f x).
 
141
  unfold continuity_pt in |- *; unfold continue_in in |- *; intros;
 
142
    apply limit_inv; assumption.
 
143
  unfold inv_fct in |- *; reflexivity.
 
144
Qed.
 
145
 
 
146
Lemma div_eq_inv : forall f1 f2, (f1 / f2)%F = (f1 * / f2)%F.
 
147
Proof.
 
148
  intros; reflexivity.
 
149
Qed.
 
150
 
 
151
Lemma continuity_pt_div :
 
152
  forall f1 f2 (x0:R),
 
153
    continuity_pt f1 x0 ->
 
154
    continuity_pt f2 x0 -> f2 x0 <> 0 -> continuity_pt (f1 / f2) x0.
 
155
Proof.
 
156
  intros; rewrite (div_eq_inv f1 f2); apply continuity_pt_mult;
 
157
    [ assumption | apply continuity_pt_inv; assumption ].
 
158
Qed.
 
159
 
 
160
Lemma continuity_pt_comp :
 
161
  forall f1 f2 (x:R),
 
162
    continuity_pt f1 x -> continuity_pt f2 (f1 x) -> continuity_pt (f2 o f1) x.
 
163
Proof.
 
164
  unfold continuity_pt in |- *; unfold continue_in in |- *; intros;
 
165
    unfold comp in |- *.
 
166
  cut
 
167
    (limit1_in (fun x0:R => f2 (f1 x0))
 
168
      (Dgf (D_x no_cond x) (D_x no_cond (f1 x)) f1) (
 
169
        f2 (f1 x)) x ->
 
170
      limit1_in (fun x0:R => f2 (f1 x0)) (D_x no_cond x) (f2 (f1 x)) x).
 
171
  intro; apply H1.
 
172
  eapply limit_comp.
 
173
  apply H.
 
174
  apply H0.
 
175
  unfold limit1_in in |- *; unfold limit_in in |- *; unfold dist in |- *;
 
176
    simpl in |- *; unfold R_dist in |- *; intros.
 
177
  assert (H3 := H1 eps H2).
 
178
  elim H3; intros.
 
179
  exists x0.
 
180
  split.
 
181
  elim H4; intros; assumption.
 
182
  intros; case (Req_dec (f1 x) (f1 x1)); intro.
 
183
  rewrite H6; unfold Rminus in |- *; rewrite Rplus_opp_r; rewrite Rabs_R0;
 
184
    assumption.
 
185
  elim H4; intros; apply H8.
 
186
  split.
 
187
  unfold Dgf, D_x, no_cond in |- *.
 
188
  split.
 
189
  split.
 
190
  trivial.
 
191
  elim H5; unfold D_x, no_cond in |- *; intros.
 
192
  elim H9; intros; assumption.
 
193
  split.
 
194
  trivial.
 
195
  assumption.
 
196
  elim H5; intros; assumption.
 
197
Qed.
 
198
 
 
199
(**********) 
 
200
Lemma continuity_plus :
 
201
  forall f1 f2, continuity f1 -> continuity f2 -> continuity (f1 + f2).
 
202
Proof.
 
203
  unfold continuity in |- *; intros;
 
204
    apply (continuity_pt_plus f1 f2 x (H x) (H0 x)).
 
205
Qed.
 
206
 
 
207
Lemma continuity_opp : forall f, continuity f -> continuity (- f).
 
208
Proof.
 
209
  unfold continuity in |- *; intros; apply (continuity_pt_opp f x (H x)).
 
210
Qed.
 
211
 
 
212
Lemma continuity_minus :
 
213
  forall f1 f2, continuity f1 -> continuity f2 -> continuity (f1 - f2).
 
214
Proof.
 
215
  unfold continuity in |- *; intros;
 
216
    apply (continuity_pt_minus f1 f2 x (H x) (H0 x)).
 
217
Qed.
 
218
 
 
219
Lemma continuity_mult :
 
220
  forall f1 f2, continuity f1 -> continuity f2 -> continuity (f1 * f2).
 
221
Proof.
 
222
  unfold continuity in |- *; intros;
 
223
    apply (continuity_pt_mult f1 f2 x (H x) (H0 x)).
 
224
Qed.
 
225
 
 
226
Lemma continuity_const : forall f, constant f -> continuity f.
 
227
Proof.
 
228
  unfold continuity in |- *; intros; apply (continuity_pt_const f x H).
 
229
Qed.
 
230
 
 
231
Lemma continuity_scal :
 
232
  forall f (a:R), continuity f -> continuity (mult_real_fct a f).
 
233
Proof.
 
234
  unfold continuity in |- *; intros; apply (continuity_pt_scal f a x (H x)).
 
235
Qed.
 
236
 
 
237
Lemma continuity_inv :
 
238
  forall f, continuity f -> (forall x:R, f x <> 0) -> continuity (/ f).
 
239
Proof.
 
240
  unfold continuity in |- *; intros; apply (continuity_pt_inv f x (H x) (H0 x)).
 
241
Qed.
 
242
 
 
243
Lemma continuity_div :
 
244
  forall f1 f2,
 
245
    continuity f1 ->
 
246
    continuity f2 -> (forall x:R, f2 x <> 0) -> continuity (f1 / f2).
 
247
Proof.
 
248
  unfold continuity in |- *; intros;
 
249
    apply (continuity_pt_div f1 f2 x (H x) (H0 x) (H1 x)).
 
250
Qed.
 
251
 
 
252
Lemma continuity_comp :
 
253
  forall f1 f2, continuity f1 -> continuity f2 -> continuity (f2 o f1).
 
254
Proof.
 
255
  unfold continuity in |- *; intros.
 
256
  apply (continuity_pt_comp f1 f2 x (H x) (H0 (f1 x))).
 
257
Qed.
 
258
 
 
259
 
 
260
(*****************************************************)
 
261
(** * Derivative's definition using Landau's kernel  *)
 
262
(*****************************************************)
 
263
 
 
264
Definition derivable_pt_lim f (x l:R) : Prop :=
 
265
  forall eps:R,
 
266
    0 < eps ->
 
267
    exists delta : posreal,
 
268
      (forall h:R,
 
269
        h <> 0 -> Rabs h < delta -> Rabs ((f (x + h) - f x) / h - l) < eps).
 
270
 
 
271
Definition derivable_pt_abs f (x l:R) : Prop := derivable_pt_lim f x l.
 
272
 
 
273
Definition derivable_pt f (x:R) := { l:R | derivable_pt_abs f x l }.
 
274
Definition derivable f := forall x:R, derivable_pt f x.
 
275
 
 
276
Definition derive_pt f (x:R) (pr:derivable_pt f x) := proj1_sig pr.
 
277
Definition derive f (pr:derivable f) (x:R) := derive_pt f x (pr x).
 
278
 
 
279
Arguments Scope derivable_pt_lim [Rfun_scope R_scope].
 
280
Arguments Scope derivable_pt_abs [Rfun_scope R_scope R_scope].
 
281
Arguments Scope derivable_pt [Rfun_scope R_scope].
 
282
Arguments Scope derivable [Rfun_scope].
 
283
Arguments Scope derive_pt [Rfun_scope R_scope _].
 
284
Arguments Scope derive [Rfun_scope _].
 
285
 
 
286
Definition antiderivative f (g:R -> R) (a b:R) : Prop :=
 
287
  (forall x:R,
 
288
    a <= x <= b ->  exists pr : derivable_pt g x, f x = derive_pt g x pr) /\
 
289
  a <= b.
 
290
(**************************************)
 
291
(** * Class of differential functions *)
 
292
(**************************************)
 
293
Record Differential : Type := mkDifferential
 
294
  {d1 :> R -> R; cond_diff : derivable d1}.
 
295
 
 
296
Record Differential_D2 : Type := mkDifferential_D2
 
297
  {d2 :> R -> R;
 
298
    cond_D1 : derivable d2;
 
299
    cond_D2 : derivable (derive d2 cond_D1)}.
 
300
 
 
301
(**********)
 
302
Lemma uniqueness_step1 :
 
303
  forall f (x l1 l2:R),
 
304
    limit1_in (fun h:R => (f (x + h) - f x) / h) (fun h:R => h <> 0) l1 0 ->
 
305
    limit1_in (fun h:R => (f (x + h) - f x) / h) (fun h:R => h <> 0) l2 0 ->
 
306
    l1 = l2.
 
307
Proof.
 
308
  intros;
 
309
    apply
 
310
      (single_limit (fun h:R => (f (x + h) - f x) / h) (
 
311
        fun h:R => h <> 0) l1 l2 0); try assumption.
 
312
  unfold adhDa in |- *; intros; exists (alp / 2).
 
313
  split.
 
314
  unfold Rdiv in |- *; apply prod_neq_R0.
 
315
  red in |- *; intro; rewrite H2 in H1; elim (Rlt_irrefl _ H1).
 
316
  apply Rinv_neq_0_compat; discrR.
 
317
  unfold R_dist in |- *; unfold Rminus in |- *; rewrite Ropp_0;
 
318
    rewrite Rplus_0_r; unfold Rdiv in |- *; rewrite Rabs_mult.
 
319
  replace (Rabs (/ 2)) with (/ 2).
 
320
  replace (Rabs alp) with alp.
 
321
  apply Rmult_lt_reg_l with 2.
 
322
  prove_sup0.
 
323
  rewrite (Rmult_comm 2); rewrite Rmult_assoc; rewrite <- Rinv_l_sym;
 
324
    [ idtac | discrR ]; rewrite Rmult_1_r; rewrite double;
 
325
      pattern alp at 1 in |- *; replace alp with (alp + 0); 
 
326
        [ idtac | ring ]; apply Rplus_lt_compat_l; assumption.
 
327
  symmetry  in |- *; apply Rabs_right; left; assumption.
 
328
  symmetry  in |- *; apply Rabs_right; left; change (0 < / 2) in |- *;
 
329
    apply Rinv_0_lt_compat; prove_sup0. 
 
330
Qed.
 
331
 
 
332
Lemma uniqueness_step2 :
 
333
  forall f (x l:R),
 
334
    derivable_pt_lim f x l ->
 
335
    limit1_in (fun h:R => (f (x + h) - f x) / h) (fun h:R => h <> 0) l 0.
 
336
Proof. 
 
337
  unfold derivable_pt_lim in |- *; intros; unfold limit1_in in |- *;
 
338
    unfold limit_in in |- *; intros.
 
339
  assert (H1 := H eps H0).
 
340
  elim H1; intros.
 
341
  exists (pos x0).
 
342
  split.
 
343
  apply (cond_pos x0).
 
344
  simpl in |- *; unfold R_dist in |- *; intros.
 
345
  elim H3; intros.
 
346
  apply H2;
 
347
    [ assumption
 
348
      | unfold Rminus in H5; rewrite Ropp_0 in H5; rewrite Rplus_0_r in H5;
 
349
        assumption ].
 
350
Qed.
 
351
 
 
352
Lemma uniqueness_step3 :
 
353
  forall f (x l:R),
 
354
    limit1_in (fun h:R => (f (x + h) - f x) / h) (fun h:R => h <> 0) l 0 ->
 
355
    derivable_pt_lim f x l.
 
356
Proof.
 
357
  unfold limit1_in, derivable_pt_lim in |- *; unfold limit_in in |- *;
 
358
    unfold dist in |- *; simpl in |- *; intros.
 
359
  elim (H eps H0).
 
360
  intros; elim H1; intros.
 
361
  exists (mkposreal x0 H2).
 
362
  simpl in |- *; intros; unfold R_dist in H3; apply (H3 h).
 
363
  split;
 
364
    [ assumption
 
365
      | unfold Rminus in |- *; rewrite Ropp_0; rewrite Rplus_0_r; assumption ].
 
366
Qed.
 
367
 
 
368
Lemma uniqueness_limite :
 
369
  forall f (x l1 l2:R),
 
370
    derivable_pt_lim f x l1 -> derivable_pt_lim f x l2 -> l1 = l2.
 
371
Proof.
 
372
  intros.
 
373
  assert (H1 := uniqueness_step2 _ _ _ H).
 
374
  assert (H2 := uniqueness_step2 _ _ _ H0).
 
375
  assert (H3 := uniqueness_step1 _ _ _ _ H1 H2).
 
376
  assumption.
 
377
Qed.
 
378
 
 
379
Lemma derive_pt_eq :
 
380
  forall f (x l:R) (pr:derivable_pt f x),
 
381
    derive_pt f x pr = l <-> derivable_pt_lim f x l.
 
382
Proof.
 
383
  intros; split.
 
384
  intro; assert (H1 := proj2_sig pr); unfold derive_pt in H; rewrite H in H1;
 
385
    assumption.
 
386
  intro; assert (H1 := proj2_sig pr); unfold derivable_pt_abs in H1.
 
387
  assert (H2 := uniqueness_limite _ _ _ _ H H1).
 
388
  unfold derive_pt in |- *; unfold derivable_pt_abs in |- *.
 
389
  symmetry  in |- *; assumption.
 
390
Qed.
 
391
 
 
392
(**********)
 
393
Lemma derive_pt_eq_0 :
 
394
  forall f (x l:R) (pr:derivable_pt f x),
 
395
    derivable_pt_lim f x l -> derive_pt f x pr = l.
 
396
Proof.
 
397
  intros; elim (derive_pt_eq f x l pr); intros.
 
398
  apply (H1 H).
 
399
Qed.
 
400
 
 
401
(**********)
 
402
Lemma derive_pt_eq_1 :
 
403
  forall f (x l:R) (pr:derivable_pt f x),
 
404
    derive_pt f x pr = l -> derivable_pt_lim f x l.
 
405
Proof.
 
406
  intros; elim (derive_pt_eq f x l pr); intros.
 
407
  apply (H0 H).
 
408
Qed.
 
409
 
 
410
 
 
411
(**********************************************************************)
 
412
(** * Equivalence of this definition with the one using limit concept *)
 
413
(**********************************************************************)
 
414
Lemma derive_pt_D_in :
 
415
  forall f (df:R -> R) (x:R) (pr:derivable_pt f x),
 
416
    D_in f df no_cond x <-> derive_pt f x pr = df x.
 
417
Proof.
 
418
  intros; split.
 
419
  unfold D_in in |- *; unfold limit1_in in |- *; unfold limit_in in |- *;
 
420
    simpl in |- *; unfold R_dist in |- *; intros.
 
421
  apply derive_pt_eq_0. 
 
422
  unfold derivable_pt_lim in |- *.
 
423
  intros; elim (H eps H0); intros alpha H1; elim H1; intros;
 
424
    exists (mkposreal alpha H2); intros; generalize (H3 (x + h)); 
 
425
      intro; cut (x + h - x = h);
 
426
        [ intro; cut (D_x no_cond x (x + h) /\ Rabs (x + h - x) < alpha);
 
427
          [ intro; generalize (H6 H8); rewrite H7; intro; assumption
 
428
            | split;
 
429
              [ unfold D_x in |- *; split;
 
430
                [ unfold no_cond in |- *; trivial
 
431
                  | apply Rminus_not_eq_right; rewrite H7; assumption ]
 
432
                | rewrite H7; assumption ] ]
 
433
          | ring ].
 
434
  intro.
 
435
  assert (H0 := derive_pt_eq_1 f x (df x) pr H).
 
436
  unfold D_in in |- *; unfold limit1_in in |- *; unfold limit_in in |- *;
 
437
    unfold dist in |- *; simpl in |- *; unfold R_dist in |- *; 
 
438
      intros.
 
439
  elim (H0 eps H1); intros alpha H2; exists (pos alpha); split.
 
440
  apply (cond_pos alpha).
 
441
  intros; elim H3; intros; unfold D_x in H4; elim H4; intros; cut (x0 - x <> 0).
 
442
  intro; generalize (H2 (x0 - x) H8 H5); replace (x + (x0 - x)) with x0.
 
443
  intro; assumption.
 
444
  ring.
 
445
  auto with real.
 
446
Qed.
 
447
 
 
448
Lemma derivable_pt_lim_D_in :
 
449
  forall f (df:R -> R) (x:R),
 
450
    D_in f df no_cond x <-> derivable_pt_lim f x (df x).
 
451
Proof.
 
452
  intros; split.
 
453
  unfold D_in in |- *; unfold limit1_in in |- *; unfold limit_in in |- *;
 
454
    simpl in |- *; unfold R_dist in |- *; intros.
 
455
  unfold derivable_pt_lim in |- *.
 
456
  intros; elim (H eps H0); intros alpha H1; elim H1; intros;
 
457
    exists (mkposreal alpha H2); intros; generalize (H3 (x + h)); 
 
458
      intro; cut (x + h - x = h);
 
459
        [ intro; cut (D_x no_cond x (x + h) /\ Rabs (x + h - x) < alpha);
 
460
          [ intro; generalize (H6 H8); rewrite H7; intro; assumption
 
461
            | split;
 
462
              [ unfold D_x in |- *; split;
 
463
                [ unfold no_cond in |- *; trivial
 
464
                  | apply Rminus_not_eq_right; rewrite H7; assumption ]
 
465
                | rewrite H7; assumption ] ]
 
466
          | ring ].
 
467
  intro.
 
468
  unfold derivable_pt_lim in H.
 
469
  unfold D_in in |- *; unfold limit1_in in |- *; unfold limit_in in |- *;
 
470
    unfold dist in |- *; simpl in |- *; unfold R_dist in |- *; 
 
471
      intros.
 
472
  elim (H eps H0); intros alpha H2; exists (pos alpha); split.
 
473
  apply (cond_pos alpha).
 
474
  intros.
 
475
  elim H1; intros; unfold D_x in H3; elim H3; intros; cut (x0 - x <> 0).
 
476
  intro; generalize (H2 (x0 - x) H7 H4); replace (x + (x0 - x)) with x0.
 
477
  intro; assumption.
 
478
  ring.
 
479
  auto with real.
 
480
Qed.
 
481
 
 
482
 
 
483
(***********************************)
 
484
(** * derivability -> continuity   *)
 
485
(***********************************)
 
486
(**********)
 
487
Lemma derivable_derive :
 
488
  forall f (x:R) (pr:derivable_pt f x),  exists l : R, derive_pt f x pr = l.
 
489
Proof.
 
490
  intros; exists (proj1_sig pr).
 
491
  unfold derive_pt in |- *; reflexivity.
 
492
Qed.
 
493
 
 
494
Theorem derivable_continuous_pt :
 
495
  forall f (x:R), derivable_pt f x -> continuity_pt f x.
 
496
Proof.
 
497
  intros f x X.
 
498
  generalize (derivable_derive f x X); intro.
 
499
  elim H; intros l H1.
 
500
  cut (l = fct_cte l x).
 
501
  intro.
 
502
  rewrite H0 in H1.
 
503
  generalize (derive_pt_D_in f (fct_cte l) x); intro.
 
504
  elim (H2 X); intros.
 
505
  generalize (H4 H1); intro.
 
506
  unfold continuity_pt in |- *.
 
507
  apply (cont_deriv f (fct_cte l) no_cond x H5).
 
508
  unfold fct_cte in |- *; reflexivity.
 
509
Qed.
 
510
 
 
511
Theorem derivable_continuous : forall f, derivable f -> continuity f.
 
512
Proof.
 
513
  unfold derivable, continuity in |- *; intros f X x.
 
514
  apply (derivable_continuous_pt f x (X x)).
 
515
Qed.
 
516
 
 
517
(****************************************************************)
 
518
(** *                    Main rules                             *)
 
519
(****************************************************************)
 
520
 
 
521
Lemma derivable_pt_lim_plus :
 
522
  forall f1 f2 (x l1 l2:R),
 
523
    derivable_pt_lim f1 x l1 ->
 
524
    derivable_pt_lim f2 x l2 -> derivable_pt_lim (f1 + f2) x (l1 + l2).
 
525
  intros.
 
526
  apply uniqueness_step3.
 
527
  assert (H1 := uniqueness_step2 _ _ _ H).
 
528
  assert (H2 := uniqueness_step2 _ _ _ H0).
 
529
  unfold plus_fct in |- *.
 
530
  cut
 
531
    (forall h:R,
 
532
      (f1 (x + h) + f2 (x + h) - (f1 x + f2 x)) / h =
 
533
      (f1 (x + h) - f1 x) / h + (f2 (x + h) - f2 x) / h).
 
534
  intro.
 
535
  generalize
 
536
    (limit_plus (fun h':R => (f1 (x + h') - f1 x) / h')
 
537
      (fun h':R => (f2 (x + h') - f2 x) / h') (fun h:R => h <> 0) l1 l2 0 H1 H2).
 
538
  unfold limit1_in in |- *; unfold limit_in in |- *; unfold dist in |- *;
 
539
    simpl in |- *; unfold R_dist in |- *; intros.
 
540
  elim (H4 eps H5); intros.
 
541
  exists x0.
 
542
  elim H6; intros.
 
543
  split.
 
544
  assumption.
 
545
  intros; rewrite H3; apply H8; assumption.
 
546
  intro; unfold Rdiv in |- *; ring.
 
547
Qed.
 
548
 
 
549
Lemma derivable_pt_lim_opp :
 
550
  forall f (x l:R), derivable_pt_lim f x l -> derivable_pt_lim (- f) x (- l).
 
551
Proof. 
 
552
  intros.
 
553
  apply uniqueness_step3.
 
554
  assert (H1 := uniqueness_step2 _ _ _ H).
 
555
  unfold opp_fct in |- *.
 
556
  cut (forall h:R, (- f (x + h) - - f x) / h = - ((f (x + h) - f x) / h)).
 
557
  intro.
 
558
  generalize
 
559
    (limit_Ropp (fun h:R => (f (x + h) - f x) / h) (fun h:R => h <> 0) l 0 H1).
 
560
  unfold limit1_in in |- *; unfold limit_in in |- *; unfold dist in |- *;
 
561
    simpl in |- *; unfold R_dist in |- *; intros.
 
562
  elim (H2 eps H3); intros.
 
563
  exists x0.
 
564
  elim H4; intros.
 
565
  split.
 
566
  assumption.
 
567
  intros; rewrite H0; apply H6; assumption.
 
568
  intro; unfold Rdiv in |- *; ring.
 
569
Qed.
 
570
 
 
571
Lemma derivable_pt_lim_minus :
 
572
  forall f1 f2 (x l1 l2:R),
 
573
    derivable_pt_lim f1 x l1 ->
 
574
    derivable_pt_lim f2 x l2 -> derivable_pt_lim (f1 - f2) x (l1 - l2).
 
575
Proof.
 
576
  intros.
 
577
  apply uniqueness_step3.
 
578
  assert (H1 := uniqueness_step2 _ _ _ H).
 
579
  assert (H2 := uniqueness_step2 _ _ _ H0).
 
580
  unfold minus_fct in |- *.
 
581
  cut
 
582
    (forall h:R,
 
583
      (f1 (x + h) - f1 x) / h - (f2 (x + h) - f2 x) / h =
 
584
      (f1 (x + h) - f2 (x + h) - (f1 x - f2 x)) / h).
 
585
  intro.
 
586
  generalize
 
587
    (limit_minus (fun h':R => (f1 (x + h') - f1 x) / h')
 
588
      (fun h':R => (f2 (x + h') - f2 x) / h') (fun h:R => h <> 0) l1 l2 0 H1 H2).
 
589
  unfold limit1_in in |- *; unfold limit_in in |- *; unfold dist in |- *;
 
590
    simpl in |- *; unfold R_dist in |- *; intros.
 
591
  elim (H4 eps H5); intros.
 
592
  exists x0.
 
593
  elim H6; intros.
 
594
  split.
 
595
  assumption.
 
596
  intros; rewrite <- H3; apply H8; assumption.
 
597
  intro; unfold Rdiv in |- *; ring.
 
598
Qed.
 
599
 
 
600
Lemma derivable_pt_lim_mult :
 
601
  forall f1 f2 (x l1 l2:R),
 
602
    derivable_pt_lim f1 x l1 ->
 
603
    derivable_pt_lim f2 x l2 ->
 
604
    derivable_pt_lim (f1 * f2) x (l1 * f2 x + f1 x * l2).
 
605
Proof.
 
606
  intros.
 
607
  assert (H1 := derivable_pt_lim_D_in f1 (fun y:R => l1) x).
 
608
  elim H1; intros.
 
609
  assert (H4 := H3 H).
 
610
  assert (H5 := derivable_pt_lim_D_in f2 (fun y:R => l2) x).
 
611
  elim H5; intros.
 
612
  assert (H8 := H7 H0).
 
613
  clear H1 H2 H3 H5 H6 H7.
 
614
  assert
 
615
    (H1 :=
 
616
      derivable_pt_lim_D_in (f1 * f2)%F (fun y:R => l1 * f2 x + f1 x * l2) x).
 
617
  elim H1; intros.
 
618
  clear H1 H3.
 
619
  apply H2.
 
620
  unfold mult_fct in |- *.
 
621
  apply (Dmult no_cond (fun y:R => l1) (fun y:R => l2) f1 f2 x); assumption.
 
622
Qed.
 
623
 
 
624
Lemma derivable_pt_lim_const : forall a x:R, derivable_pt_lim (fct_cte a) x 0.
 
625
Proof.
 
626
  intros; unfold fct_cte, derivable_pt_lim in |- *.
 
627
  intros; exists (mkposreal 1 Rlt_0_1); intros; unfold Rminus in |- *;
 
628
    rewrite Rplus_opp_r; unfold Rdiv in |- *; rewrite Rmult_0_l;
 
629
      rewrite Rplus_opp_r; rewrite Rabs_R0; assumption.
 
630
Qed.
 
631
 
 
632
Lemma derivable_pt_lim_scal :
 
633
  forall f (a x l:R),
 
634
    derivable_pt_lim f x l -> derivable_pt_lim (mult_real_fct a f) x (a * l).
 
635
Proof.
 
636
  intros.
 
637
  assert (H0 := derivable_pt_lim_const a x).
 
638
  replace (mult_real_fct a f) with (fct_cte a * f)%F.
 
639
  replace (a * l) with (0 * f x + a * l); [ idtac | ring ].
 
640
  apply (derivable_pt_lim_mult (fct_cte a) f x 0 l); assumption.
 
641
  unfold mult_real_fct, mult_fct, fct_cte in |- *; reflexivity.
 
642
Qed.
 
643
 
 
644
Lemma derivable_pt_lim_id : forall x:R, derivable_pt_lim id x 1.
 
645
Proof.
 
646
  intro; unfold derivable_pt_lim in |- *.
 
647
  intros eps Heps; exists (mkposreal eps Heps); intros h H1 H2;
 
648
    unfold id in |- *; replace ((x + h - x) / h - 1) with 0.
 
649
  rewrite Rabs_R0; apply Rle_lt_trans with (Rabs h).
 
650
  apply Rabs_pos.
 
651
  assumption.
 
652
  unfold Rminus in |- *; rewrite Rplus_assoc; rewrite (Rplus_comm x);
 
653
    rewrite Rplus_assoc.
 
654
  rewrite Rplus_opp_l; rewrite Rplus_0_r; unfold Rdiv in |- *;
 
655
    rewrite <- Rinv_r_sym.
 
656
  symmetry  in |- *; apply Rplus_opp_r.
 
657
  assumption.
 
658
Qed.
 
659
 
 
660
Lemma derivable_pt_lim_Rsqr : forall x:R, derivable_pt_lim Rsqr x (2 * x).
 
661
Proof.
 
662
  intro; unfold derivable_pt_lim in |- *.
 
663
  unfold Rsqr in |- *; intros eps Heps; exists (mkposreal eps Heps);
 
664
    intros h H1 H2; replace (((x + h) * (x + h) - x * x) / h - 2 * x) with h.
 
665
  assumption.
 
666
  replace ((x + h) * (x + h) - x * x) with (2 * x * h + h * h);
 
667
  [ idtac | ring ].
 
668
  unfold Rdiv in |- *; rewrite Rmult_plus_distr_r.
 
669
  repeat rewrite Rmult_assoc.
 
670
  repeat rewrite <- Rinv_r_sym; [ idtac | assumption ].
 
671
  ring.
 
672
Qed.
 
673
 
 
674
Lemma derivable_pt_lim_comp :
 
675
  forall f1 f2 (x l1 l2:R),
 
676
    derivable_pt_lim f1 x l1 ->
 
677
    derivable_pt_lim f2 (f1 x) l2 -> derivable_pt_lim (f2 o f1) x (l2 * l1).
 
678
Proof.
 
679
  intros; assert (H1 := derivable_pt_lim_D_in f1 (fun y:R => l1) x).
 
680
  elim H1; intros.
 
681
  assert (H4 := H3 H).
 
682
  assert (H5 := derivable_pt_lim_D_in f2 (fun y:R => l2) (f1 x)).
 
683
  elim H5; intros.
 
684
  assert (H8 := H7 H0).
 
685
  clear H1 H2 H3 H5 H6 H7.
 
686
  assert (H1 := derivable_pt_lim_D_in (f2 o f1)%F (fun y:R => l2 * l1) x).
 
687
  elim H1; intros.
 
688
  clear H1 H3; apply H2.
 
689
  unfold comp in |- *;
 
690
    cut
 
691
      (D_in (fun x0:R => f2 (f1 x0)) (fun y:R => l2 * l1)
 
692
        (Dgf no_cond no_cond f1) x ->
 
693
        D_in (fun x0:R => f2 (f1 x0)) (fun y:R => l2 * l1) no_cond x).
 
694
  intro; apply H1.
 
695
  rewrite Rmult_comm;
 
696
    apply (Dcomp no_cond no_cond (fun y:R => l1) (fun y:R => l2) f1 f2 x);
 
697
      assumption.
 
698
  unfold Dgf, D_in, no_cond in |- *; unfold limit1_in in |- *;
 
699
    unfold limit_in in |- *; unfold dist in |- *; simpl in |- *;
 
700
      unfold R_dist in |- *; intros.
 
701
  elim (H1 eps H3); intros.
 
702
  exists x0; intros; split.
 
703
  elim H5; intros; assumption.
 
704
  intros; elim H5; intros; apply H9; split.
 
705
  unfold D_x in |- *; split.
 
706
  split; trivial.
 
707
  elim H6; intros; unfold D_x in H10; elim H10; intros; assumption.
 
708
  elim H6; intros; assumption.
 
709
Qed.
 
710
 
 
711
Lemma derivable_pt_plus :
 
712
  forall f1 f2 (x:R),
 
713
    derivable_pt f1 x -> derivable_pt f2 x -> derivable_pt (f1 + f2) x.
 
714
Proof.
 
715
  unfold derivable_pt in |- *; intros f1 f2 x X X0.
 
716
  elim X; intros.
 
717
  elim X0; intros.
 
718
  exists (x0 + x1).
 
719
  apply derivable_pt_lim_plus; assumption.
 
720
Qed.
 
721
 
 
722
Lemma derivable_pt_opp :
 
723
  forall f (x:R), derivable_pt f x -> derivable_pt (- f) x.
 
724
Proof.
 
725
  unfold derivable_pt in |- *; intros f x X.
 
726
  elim X; intros.
 
727
  exists (- x0).
 
728
  apply derivable_pt_lim_opp; assumption.
 
729
Qed.
 
730
 
 
731
Lemma derivable_pt_minus :
 
732
  forall f1 f2 (x:R),
 
733
    derivable_pt f1 x -> derivable_pt f2 x -> derivable_pt (f1 - f2) x.
 
734
Proof.
 
735
  unfold derivable_pt in |- *; intros f1 f2 x X X0.
 
736
  elim X; intros.
 
737
  elim X0; intros.
 
738
  exists (x0 - x1).
 
739
  apply derivable_pt_lim_minus; assumption.
 
740
Qed.
 
741
 
 
742
Lemma derivable_pt_mult :
 
743
  forall f1 f2 (x:R),
 
744
    derivable_pt f1 x -> derivable_pt f2 x -> derivable_pt (f1 * f2) x.
 
745
Proof.
 
746
  unfold derivable_pt in |- *; intros f1 f2 x X X0.
 
747
  elim X; intros.
 
748
  elim X0; intros.
 
749
  exists (x0 * f2 x + f1 x * x1).
 
750
  apply derivable_pt_lim_mult; assumption.
 
751
Qed.
 
752
 
 
753
Lemma derivable_pt_const : forall a x:R, derivable_pt (fct_cte a) x.
 
754
Proof.
 
755
  intros; unfold derivable_pt in |- *.
 
756
  exists 0.
 
757
  apply derivable_pt_lim_const.
 
758
Qed.
 
759
 
 
760
Lemma derivable_pt_scal :
 
761
  forall f (a x:R), derivable_pt f x -> derivable_pt (mult_real_fct a f) x.
 
762
Proof.
 
763
  unfold derivable_pt in |- *; intros f1 a x X.
 
764
  elim X; intros.
 
765
  exists (a * x0).
 
766
  apply derivable_pt_lim_scal; assumption.
 
767
Qed.
 
768
 
 
769
Lemma derivable_pt_id : forall x:R, derivable_pt id x.
 
770
Proof.
 
771
  unfold derivable_pt in |- *; intro.
 
772
  exists 1.
 
773
  apply derivable_pt_lim_id.
 
774
Qed.
 
775
 
 
776
Lemma derivable_pt_Rsqr : forall x:R, derivable_pt Rsqr x.
 
777
Proof.
 
778
  unfold derivable_pt in |- *; intro; exists (2 * x).
 
779
  apply derivable_pt_lim_Rsqr.
 
780
Qed.
 
781
 
 
782
Lemma derivable_pt_comp :
 
783
  forall f1 f2 (x:R),
 
784
    derivable_pt f1 x -> derivable_pt f2 (f1 x) -> derivable_pt (f2 o f1) x.
 
785
Proof.
 
786
  unfold derivable_pt in |- *; intros f1 f2 x X X0.
 
787
  elim X; intros.
 
788
  elim X0; intros.
 
789
  exists (x1 * x0).
 
790
  apply derivable_pt_lim_comp; assumption.
 
791
Qed.
 
792
 
 
793
Lemma derivable_plus :
 
794
  forall f1 f2, derivable f1 -> derivable f2 -> derivable (f1 + f2).
 
795
Proof.
 
796
  unfold derivable in |- *; intros f1 f2 X X0 x.
 
797
  apply (derivable_pt_plus _ _ x (X _) (X0 _)).
 
798
Qed.
 
799
 
 
800
Lemma derivable_opp : forall f, derivable f -> derivable (- f).
 
801
Proof.
 
802
  unfold derivable in |- *; intros f X x.
 
803
  apply (derivable_pt_opp _ x (X _)).
 
804
Qed.
 
805
 
 
806
Lemma derivable_minus :
 
807
  forall f1 f2, derivable f1 -> derivable f2 -> derivable (f1 - f2).
 
808
Proof.
 
809
  unfold derivable in |- *; intros f1 f2 X X0 x.
 
810
  apply (derivable_pt_minus _ _ x (X _) (X0 _)).
 
811
Qed.
 
812
 
 
813
Lemma derivable_mult :
 
814
  forall f1 f2, derivable f1 -> derivable f2 -> derivable (f1 * f2).
 
815
Proof.
 
816
  unfold derivable in |- *; intros f1 f2 X X0 x.
 
817
  apply (derivable_pt_mult _ _ x (X _) (X0 _)).
 
818
Qed.
 
819
 
 
820
Lemma derivable_const : forall a:R, derivable (fct_cte a).
 
821
Proof.
 
822
  unfold derivable in |- *; intros.
 
823
  apply derivable_pt_const.
 
824
Qed.
 
825
 
 
826
Lemma derivable_scal :
 
827
  forall f (a:R), derivable f -> derivable (mult_real_fct a f).
 
828
Proof.
 
829
  unfold derivable in |- *; intros f a X x.
 
830
  apply (derivable_pt_scal _ a x (X _)).
 
831
Qed.
 
832
 
 
833
Lemma derivable_id : derivable id.
 
834
Proof.
 
835
  unfold derivable in |- *; intro; apply derivable_pt_id.
 
836
Qed.
 
837
 
 
838
Lemma derivable_Rsqr : derivable Rsqr.
 
839
Proof.
 
840
  unfold derivable in |- *; intro; apply derivable_pt_Rsqr.
 
841
Qed.
 
842
 
 
843
Lemma derivable_comp :
 
844
  forall f1 f2, derivable f1 -> derivable f2 -> derivable (f2 o f1).
 
845
Proof.
 
846
  unfold derivable in |- *; intros f1 f2 X X0 x.
 
847
  apply (derivable_pt_comp _ _ x (X _) (X0 _)).
 
848
Qed.
 
849
 
 
850
Lemma derive_pt_plus :
 
851
  forall f1 f2 (x:R) (pr1:derivable_pt f1 x) (pr2:derivable_pt f2 x),
 
852
    derive_pt (f1 + f2) x (derivable_pt_plus _ _ _ pr1 pr2) =
 
853
    derive_pt f1 x pr1 + derive_pt f2 x pr2.
 
854
Proof.
 
855
  intros.
 
856
  assert (H := derivable_derive f1 x pr1).
 
857
  assert (H0 := derivable_derive f2 x pr2).
 
858
  assert
 
859
    (H1 := derivable_derive (f1 + f2)%F x (derivable_pt_plus _ _ _ pr1 pr2)).
 
860
  elim H; clear H; intros l1 H.
 
861
  elim H0; clear H0; intros l2 H0.
 
862
  elim H1; clear H1; intros l H1.
 
863
  rewrite H; rewrite H0; apply derive_pt_eq_0.
 
864
  assert (H3 := proj2_sig pr1).
 
865
  unfold derive_pt in H; rewrite H in H3.
 
866
  assert (H4 := proj2_sig pr2).
 
867
  unfold derive_pt in H0; rewrite H0 in H4.
 
868
  apply derivable_pt_lim_plus; assumption.
 
869
Qed.
 
870
 
 
871
Lemma derive_pt_opp :
 
872
  forall f (x:R) (pr1:derivable_pt f x),
 
873
    derive_pt (- f) x (derivable_pt_opp _ _ pr1) = - derive_pt f x pr1.
 
874
Proof.
 
875
  intros.
 
876
  assert (H := derivable_derive f x pr1).
 
877
  assert (H0 := derivable_derive (- f)%F x (derivable_pt_opp _ _ pr1)).
 
878
  elim H; clear H; intros l1 H.
 
879
  elim H0; clear H0; intros l2 H0.
 
880
  rewrite H; apply derive_pt_eq_0.
 
881
  assert (H3 := proj2_sig pr1).
 
882
  unfold derive_pt in H; rewrite H in H3.
 
883
  apply derivable_pt_lim_opp; assumption.
 
884
Qed.
 
885
 
 
886
Lemma derive_pt_minus :
 
887
  forall f1 f2 (x:R) (pr1:derivable_pt f1 x) (pr2:derivable_pt f2 x),
 
888
    derive_pt (f1 - f2) x (derivable_pt_minus _ _ _ pr1 pr2) =
 
889
    derive_pt f1 x pr1 - derive_pt f2 x pr2.
 
890
Proof.
 
891
  intros.
 
892
  assert (H := derivable_derive f1 x pr1).
 
893
  assert (H0 := derivable_derive f2 x pr2).
 
894
  assert
 
895
    (H1 := derivable_derive (f1 - f2)%F x (derivable_pt_minus _ _ _ pr1 pr2)).
 
896
  elim H; clear H; intros l1 H.
 
897
  elim H0; clear H0; intros l2 H0.
 
898
  elim H1; clear H1; intros l H1.
 
899
  rewrite H; rewrite H0; apply derive_pt_eq_0.
 
900
  assert (H3 := proj2_sig pr1).
 
901
  unfold derive_pt in H; rewrite H in H3.
 
902
  assert (H4 := proj2_sig pr2).
 
903
  unfold derive_pt in H0; rewrite H0 in H4.
 
904
  apply derivable_pt_lim_minus; assumption.
 
905
Qed.
 
906
 
 
907
Lemma derive_pt_mult :
 
908
  forall f1 f2 (x:R) (pr1:derivable_pt f1 x) (pr2:derivable_pt f2 x),
 
909
    derive_pt (f1 * f2) x (derivable_pt_mult _ _ _ pr1 pr2) =
 
910
    derive_pt f1 x pr1 * f2 x + f1 x * derive_pt f2 x pr2.
 
911
Proof.
 
912
  intros.
 
913
  assert (H := derivable_derive f1 x pr1).
 
914
  assert (H0 := derivable_derive f2 x pr2).
 
915
  assert
 
916
    (H1 := derivable_derive (f1 * f2)%F x (derivable_pt_mult _ _ _ pr1 pr2)).
 
917
  elim H; clear H; intros l1 H.
 
918
  elim H0; clear H0; intros l2 H0.
 
919
  elim H1; clear H1; intros l H1.
 
920
  rewrite H; rewrite H0; apply derive_pt_eq_0.
 
921
  assert (H3 := proj2_sig pr1).
 
922
  unfold derive_pt in H; rewrite H in H3.
 
923
  assert (H4 := proj2_sig pr2).
 
924
  unfold derive_pt in H0; rewrite H0 in H4.
 
925
  apply derivable_pt_lim_mult; assumption.
 
926
Qed.
 
927
 
 
928
Lemma derive_pt_const :
 
929
  forall a x:R, derive_pt (fct_cte a) x (derivable_pt_const a x) = 0.
 
930
Proof.
 
931
  intros.
 
932
  apply derive_pt_eq_0.
 
933
  apply derivable_pt_lim_const.
 
934
Qed.
 
935
 
 
936
Lemma derive_pt_scal :
 
937
  forall f (a x:R) (pr:derivable_pt f x),
 
938
    derive_pt (mult_real_fct a f) x (derivable_pt_scal _ _ _ pr) =
 
939
    a * derive_pt f x pr.
 
940
Proof.
 
941
  intros.
 
942
  assert (H := derivable_derive f x pr).
 
943
  assert
 
944
    (H0 := derivable_derive (mult_real_fct a f) x (derivable_pt_scal _ _ _ pr)).
 
945
  elim H; clear H; intros l1 H.
 
946
  elim H0; clear H0; intros l2 H0.
 
947
  rewrite H; apply derive_pt_eq_0.
 
948
  assert (H3 := proj2_sig pr).
 
949
  unfold derive_pt in H; rewrite H in H3.
 
950
  apply derivable_pt_lim_scal; assumption.
 
951
Qed.
 
952
 
 
953
Lemma derive_pt_id : forall x:R, derive_pt id x (derivable_pt_id _) = 1.
 
954
Proof.
 
955
  intros.
 
956
  apply derive_pt_eq_0.
 
957
  apply derivable_pt_lim_id.
 
958
Qed.
 
959
 
 
960
Lemma derive_pt_Rsqr :
 
961
  forall x:R, derive_pt Rsqr x (derivable_pt_Rsqr _) = 2 * x.
 
962
Proof.
 
963
  intros.
 
964
  apply derive_pt_eq_0.
 
965
  apply derivable_pt_lim_Rsqr.
 
966
Qed.
 
967
 
 
968
Lemma derive_pt_comp :
 
969
  forall f1 f2 (x:R) (pr1:derivable_pt f1 x) (pr2:derivable_pt f2 (f1 x)),
 
970
    derive_pt (f2 o f1) x (derivable_pt_comp _ _ _ pr1 pr2) =
 
971
    derive_pt f2 (f1 x) pr2 * derive_pt f1 x pr1.
 
972
Proof.
 
973
  intros.
 
974
  assert (H := derivable_derive f1 x pr1).
 
975
  assert (H0 := derivable_derive f2 (f1 x) pr2).
 
976
  assert
 
977
    (H1 := derivable_derive (f2 o f1)%F x (derivable_pt_comp _ _ _ pr1 pr2)).
 
978
  elim H; clear H; intros l1 H.
 
979
  elim H0; clear H0; intros l2 H0.
 
980
  elim H1; clear H1; intros l H1.
 
981
  rewrite H; rewrite H0; apply derive_pt_eq_0.
 
982
  assert (H3 := proj2_sig pr1).
 
983
  unfold derive_pt in H; rewrite H in H3.
 
984
  assert (H4 := proj2_sig pr2).
 
985
  unfold derive_pt in H0; rewrite H0 in H4.
 
986
  apply derivable_pt_lim_comp; assumption.
 
987
Qed.
 
988
 
 
989
(* Pow *)
 
990
Definition pow_fct (n:nat) (y:R) : R := y ^ n.
 
991
 
 
992
Lemma derivable_pt_lim_pow_pos :
 
993
  forall (x:R) (n:nat),
 
994
    (0 < n)%nat -> derivable_pt_lim (fun y:R => y ^ n) x (INR n * x ^ pred n).
 
995
Proof.
 
996
  intros.
 
997
  induction  n as [| n Hrecn].
 
998
  elim (lt_irrefl _ H).
 
999
  cut (n = 0%nat \/ (0 < n)%nat).
 
1000
  intro; elim H0; intro.
 
1001
  rewrite H1; simpl in |- *.
 
1002
  replace (fun y:R => y * 1) with (id * fct_cte 1)%F.
 
1003
  replace (1 * 1) with (1 * fct_cte 1 x + id x * 0).
 
1004
  apply derivable_pt_lim_mult.
 
1005
  apply derivable_pt_lim_id.
 
1006
  apply derivable_pt_lim_const.
 
1007
  unfold fct_cte, id in |- *; ring.
 
1008
  reflexivity.
 
1009
  replace (fun y:R => y ^ S n) with (fun y:R => y * y ^ n).
 
1010
  replace (pred (S n)) with n; [ idtac | reflexivity ].
 
1011
  replace (fun y:R => y * y ^ n) with (id * (fun y:R => y ^ n))%F.
 
1012
  set (f := fun y:R => y ^ n).
 
1013
  replace (INR (S n) * x ^ n) with (1 * f x + id x * (INR n * x ^ pred n)).
 
1014
  apply derivable_pt_lim_mult.
 
1015
  apply derivable_pt_lim_id.
 
1016
  unfold f in |- *; apply Hrecn; assumption.
 
1017
  unfold f in |- *.
 
1018
  pattern n at 1 5 in |- *; replace n with (S (pred n)).
 
1019
  unfold id in |- *; rewrite S_INR; simpl in |- *.
 
1020
  ring.
 
1021
  symmetry  in |- *; apply S_pred with 0%nat; assumption.
 
1022
  unfold mult_fct, id in |- *; reflexivity.
 
1023
  reflexivity.
 
1024
  inversion H.
 
1025
  left; reflexivity.
 
1026
  right.
 
1027
  apply lt_le_trans with 1%nat.
 
1028
  apply lt_O_Sn.
 
1029
  assumption.
 
1030
Qed.
 
1031
 
 
1032
Lemma derivable_pt_lim_pow :
 
1033
  forall (x:R) (n:nat),
 
1034
    derivable_pt_lim (fun y:R => y ^ n) x (INR n * x ^ pred n).
 
1035
Proof.
 
1036
  intros.
 
1037
  induction  n as [| n Hrecn].
 
1038
  simpl in |- *.
 
1039
  rewrite Rmult_0_l.
 
1040
  replace (fun _:R => 1) with (fct_cte 1);
 
1041
  [ apply derivable_pt_lim_const | reflexivity ].
 
1042
  apply derivable_pt_lim_pow_pos.
 
1043
  apply lt_O_Sn.
 
1044
Qed.
 
1045
 
 
1046
Lemma derivable_pt_pow :
 
1047
  forall (n:nat) (x:R), derivable_pt (fun y:R => y ^ n) x.
 
1048
Proof.
 
1049
  intros; unfold derivable_pt in |- *.
 
1050
  exists (INR n * x ^ pred n).
 
1051
  apply derivable_pt_lim_pow.
 
1052
Qed.
 
1053
 
 
1054
Lemma derivable_pow : forall n:nat, derivable (fun y:R => y ^ n).
 
1055
Proof.
 
1056
  intro; unfold derivable in |- *; intro; apply derivable_pt_pow.
 
1057
Qed.
 
1058
 
 
1059
Lemma derive_pt_pow :
 
1060
  forall (n:nat) (x:R),
 
1061
    derive_pt (fun y:R => y ^ n) x (derivable_pt_pow n x) = INR n * x ^ pred n.
 
1062
Proof.
 
1063
  intros; apply derive_pt_eq_0.
 
1064
  apply derivable_pt_lim_pow.
 
1065
Qed.
 
1066
 
 
1067
Lemma pr_nu :
 
1068
  forall f (x:R) (pr1 pr2:derivable_pt f x),
 
1069
    derive_pt f x pr1 = derive_pt f x pr2. 
 
1070
Proof.
 
1071
  intros.
 
1072
  unfold derivable_pt in pr1.
 
1073
  unfold derivable_pt in pr2.
 
1074
  elim pr1; intros.
 
1075
  elim pr2; intros.
 
1076
  unfold derivable_pt_abs in p.
 
1077
  unfold derivable_pt_abs in p0.
 
1078
  simpl in |- *.
 
1079
  apply (uniqueness_limite f x x0 x1 p p0).
 
1080
Qed.
 
1081
 
 
1082
 
 
1083
(************************************************************)
 
1084
(** *           Local extremum's condition                  *)
 
1085
(************************************************************)
 
1086
 
 
1087
Theorem deriv_maximum :
 
1088
  forall f (a b c:R) (pr:derivable_pt f c),
 
1089
    a < c ->
 
1090
    c < b ->
 
1091
    (forall x:R, a < x -> x < b -> f x <= f c) -> derive_pt f c pr = 0.
 
1092
Proof.
 
1093
  intros; case (Rtotal_order 0 (derive_pt f c pr)); intro.
 
1094
  assert (H3 := derivable_derive f c pr).
 
1095
  elim H3; intros l H4; rewrite H4 in H2.
 
1096
  assert (H5 := derive_pt_eq_1 f c l pr H4).
 
1097
  cut (0 < l / 2);
 
1098
    [ intro
 
1099
      | unfold Rdiv in |- *; apply Rmult_lt_0_compat;
 
1100
        [ assumption | apply Rinv_0_lt_compat; prove_sup0 ] ].
 
1101
  elim (H5 (l / 2) H6); intros delta H7.
 
1102
  cut (0 < (b - c) / 2).
 
1103
  intro; cut (Rmin (delta / 2) ((b - c) / 2) <> 0).
 
1104
  intro; cut (Rabs (Rmin (delta / 2) ((b - c) / 2)) < delta).
 
1105
  intro.
 
1106
  assert (H11 := H7 (Rmin (delta / 2) ((b - c) / 2)) H9 H10).
 
1107
  cut (0 < Rmin (delta / 2) ((b - c) / 2)).
 
1108
  intro; cut (a < c + Rmin (delta / 2) ((b - c) / 2)).
 
1109
  intro; cut (c + Rmin (delta / 2) ((b - c) / 2) < b).
 
1110
  intro; assert (H15 := H1 (c + Rmin (delta / 2) ((b - c) / 2)) H13 H14).
 
1111
  cut
 
1112
    ((f (c + Rmin (delta / 2) ((b - c) / 2)) - f c) /
 
1113
      Rmin (delta / 2) ((b - c) / 2) <= 0).
 
1114
  intro; cut (- l < 0).
 
1115
  intro; unfold Rminus in H11.
 
1116
  cut
 
1117
    ((f (c + Rmin (delta / 2) ((b + - c) / 2)) + - f c) /
 
1118
      Rmin (delta / 2) ((b + - c) / 2) + - l < 0).
 
1119
  intro;
 
1120
    cut
 
1121
      (Rabs
 
1122
        ((f (c + Rmin (delta / 2) ((b + - c) / 2)) + - f c) /
 
1123
          Rmin (delta / 2) ((b + - c) / 2) + - l) < l / 2).
 
1124
  unfold Rabs in |- *;
 
1125
    case
 
1126
    (Rcase_abs
 
1127
      ((f (c + Rmin (delta / 2) ((b + - c) / 2)) + - f c) /
 
1128
        Rmin (delta / 2) ((b + - c) / 2) + - l)); intro.
 
1129
  replace
 
1130
  (-
 
1131
    ((f (c + Rmin (delta / 2) ((b + - c) / 2)) + - f c) /
 
1132
      Rmin (delta / 2) ((b + - c) / 2) + - l)) with
 
1133
  (l +
 
1134
    -
 
1135
    ((f (c + Rmin (delta / 2) ((b + - c) / 2)) + - f c) /
 
1136
      Rmin (delta / 2) ((b + - c) / 2))).
 
1137
  intro;
 
1138
    generalize
 
1139
      (Rplus_lt_compat_l (- l)
 
1140
        (l +
 
1141
          -
 
1142
          ((f (c + Rmin (delta / 2) ((b + - c) / 2)) + - f c) /
 
1143
            Rmin (delta / 2) ((b + - c) / 2))) (l / 2) H19);
 
1144
      repeat rewrite <- Rplus_assoc; rewrite Rplus_opp_l; 
 
1145
        rewrite Rplus_0_l; replace (- l + l / 2) with (- (l / 2)).
 
1146
  intro;
 
1147
    generalize
 
1148
      (Ropp_lt_gt_contravar
 
1149
        (-
 
1150
          ((f (c + Rmin (delta / 2) ((b + - c) / 2)) + - f c) /
 
1151
            Rmin (delta / 2) ((b + - c) / 2))) (- (l / 2)) H20);
 
1152
      repeat rewrite Ropp_involutive; intro;
 
1153
        generalize
 
1154
          (Rlt_trans 0 (l / 2)
 
1155
            ((f (c + Rmin (delta / 2) ((b + - c) / 2)) + - f c) /
 
1156
              Rmin (delta / 2) ((b + - c) / 2)) H6 H21); intro;
 
1157
          elim
 
1158
            (Rlt_irrefl 0
 
1159
              (Rlt_le_trans 0
 
1160
                ((f (c + Rmin (delta / 2) ((b + - c) / 2)) + - f c) /
 
1161
                  Rmin (delta / 2) ((b + - c) / 2)) 0 H22 H16)).
 
1162
  pattern l at 2 in |- *; rewrite double_var.
 
1163
  ring.
 
1164
  ring.
 
1165
  intro.
 
1166
  assert
 
1167
    (H20 :=
 
1168
      Rge_le
 
1169
      ((f (c + Rmin (delta / 2) ((b + - c) / 2)) + - f c) /
 
1170
        Rmin (delta / 2) ((b + - c) / 2) + - l) 0 r).
 
1171
  elim (Rlt_irrefl _ (Rle_lt_trans _ _ _ H20 H18)). 
 
1172
  assumption.
 
1173
  rewrite <- Ropp_0;
 
1174
    replace
 
1175
    ((f (c + Rmin (delta / 2) ((b + - c) / 2)) + - f c) /
 
1176
      Rmin (delta / 2) ((b + - c) / 2) + - l) with
 
1177
    (-
 
1178
      (l +
 
1179
        -
 
1180
        ((f (c + Rmin (delta / 2) ((b + - c) / 2)) - f c) /
 
1181
          Rmin (delta / 2) ((b + - c) / 2)))).
 
1182
  apply Ropp_gt_lt_contravar;
 
1183
    change
 
1184
      (0 <
 
1185
        l +
 
1186
        -
 
1187
        ((f (c + Rmin (delta / 2) ((b + - c) / 2)) - f c) /
 
1188
          Rmin (delta / 2) ((b + - c) / 2))) in |- *; apply Rplus_lt_le_0_compat;
 
1189
      [ assumption
 
1190
        | rewrite <- Ropp_0; apply Ropp_ge_le_contravar; apply Rle_ge; assumption ].
 
1191
  unfold Rminus; ring.
 
1192
  rewrite <- Ropp_0; apply Ropp_lt_gt_contravar; assumption.
 
1193
  replace
 
1194
  ((f (c + Rmin (delta / 2) ((b - c) / 2)) - f c) /
 
1195
    Rmin (delta / 2) ((b - c) / 2)) with
 
1196
  (-
 
1197
    ((f c - f (c + Rmin (delta / 2) ((b - c) / 2))) /
 
1198
      Rmin (delta / 2) ((b - c) / 2))).
 
1199
  rewrite <- Ropp_0; apply Ropp_ge_le_contravar; apply Rle_ge;
 
1200
    unfold Rdiv in |- *; apply Rmult_le_pos;
 
1201
      [ generalize
 
1202
        (Rplus_le_compat_r (- f (c + Rmin (delta * / 2) ((b - c) * / 2)))
 
1203
          (f (c + Rmin (delta * / 2) ((b - c) * / 2))) (
 
1204
            f c) H15); rewrite Rplus_opp_r; intro; assumption
 
1205
        | left; apply Rinv_0_lt_compat; assumption ].
 
1206
  unfold Rdiv in |- *.
 
1207
  rewrite <- Ropp_mult_distr_l_reverse.
 
1208
  repeat rewrite <- (Rmult_comm (/ Rmin (delta * / 2) ((b - c) * / 2))).
 
1209
  apply Rmult_eq_reg_l with (Rmin (delta * / 2) ((b - c) * / 2)).
 
1210
  repeat rewrite <- Rmult_assoc.
 
1211
  rewrite <- Rinv_r_sym.
 
1212
  repeat rewrite Rmult_1_l.
 
1213
  ring.
 
1214
  red in |- *; intro.
 
1215
  unfold Rdiv in H12; rewrite H16 in H12; elim (Rlt_irrefl 0 H12).
 
1216
  red in |- *; intro.
 
1217
  unfold Rdiv in H12; rewrite H16 in H12; elim (Rlt_irrefl 0 H12).
 
1218
  assert (H14 := Rmin_r (delta / 2) ((b - c) / 2)).
 
1219
  assert
 
1220
    (H15 :=
 
1221
      Rplus_le_compat_l c (Rmin (delta / 2) ((b - c) / 2)) ((b - c) / 2) H14).
 
1222
  apply Rle_lt_trans with (c + (b - c) / 2).
 
1223
  assumption.
 
1224
  apply Rmult_lt_reg_l with 2.
 
1225
  prove_sup0.
 
1226
  replace (2 * (c + (b - c) / 2)) with (c + b).
 
1227
  replace (2 * b) with (b + b).
 
1228
  apply Rplus_lt_compat_r; assumption.
 
1229
  ring.
 
1230
  unfold Rdiv in |- *; rewrite Rmult_plus_distr_l.
 
1231
  repeat rewrite (Rmult_comm 2).
 
1232
  rewrite Rmult_assoc; rewrite <- Rinv_l_sym.
 
1233
  rewrite Rmult_1_r.
 
1234
  ring.
 
1235
  discrR.
 
1236
  apply Rlt_trans with c.
 
1237
  assumption.
 
1238
  pattern c at 1 in |- *; rewrite <- (Rplus_0_r c); apply Rplus_lt_compat_l;
 
1239
    assumption.
 
1240
  cut (0 < delta / 2).
 
1241
  intro;
 
1242
    apply
 
1243
      (Rmin_stable_in_posreal (mkposreal (delta / 2) H12)
 
1244
        (mkposreal ((b - c) / 2) H8)).
 
1245
  unfold Rdiv in |- *; apply Rmult_lt_0_compat;
 
1246
    [ apply (cond_pos delta) | apply Rinv_0_lt_compat; prove_sup0 ].
 
1247
  unfold Rabs in |- *; case (Rcase_abs (Rmin (delta / 2) ((b - c) / 2))).
 
1248
  intro.
 
1249
  cut (0 < delta / 2).
 
1250
  intro.
 
1251
  generalize
 
1252
    (Rmin_stable_in_posreal (mkposreal (delta / 2) H10)
 
1253
      (mkposreal ((b - c) / 2) H8)); simpl in |- *; intro;
 
1254
    elim (Rlt_irrefl 0 (Rlt_trans 0 (Rmin (delta / 2) ((b - c) / 2)) 0 H11 r)).
 
1255
  unfold Rdiv in |- *; apply Rmult_lt_0_compat;
 
1256
    [ apply (cond_pos delta) | apply Rinv_0_lt_compat; prove_sup0 ].
 
1257
  intro; apply Rle_lt_trans with (delta / 2).
 
1258
  apply Rmin_l.
 
1259
  unfold Rdiv in |- *; apply Rmult_lt_reg_l with 2.
 
1260
  prove_sup0.
 
1261
  rewrite <- (Rmult_comm (/ 2)); rewrite <- Rmult_assoc; rewrite <- Rinv_r_sym.
 
1262
  rewrite Rmult_1_l.
 
1263
  replace (2 * delta) with (delta + delta). 
 
1264
  pattern delta at 2 in |- *; rewrite <- (Rplus_0_r delta);
 
1265
    apply Rplus_lt_compat_l.
 
1266
  rewrite Rplus_0_r; apply (cond_pos delta).
 
1267
  symmetry  in |- *; apply double.
 
1268
  discrR.
 
1269
  cut (0 < delta / 2).
 
1270
  intro;
 
1271
    generalize
 
1272
      (Rmin_stable_in_posreal (mkposreal (delta / 2) H9)
 
1273
        (mkposreal ((b - c) / 2) H8)); simpl in |- *; 
 
1274
      intro; red in |- *; intro; rewrite H11 in H10; elim (Rlt_irrefl 0 H10).
 
1275
  unfold Rdiv in |- *; apply Rmult_lt_0_compat;
 
1276
    [ apply (cond_pos delta) | apply Rinv_0_lt_compat; prove_sup0 ].
 
1277
  unfold Rdiv in |- *; apply Rmult_lt_0_compat.
 
1278
  generalize (Rplus_lt_compat_r (- c) c b H0); rewrite Rplus_opp_r; intro;
 
1279
    assumption.
 
1280
  apply Rinv_0_lt_compat; prove_sup0.
 
1281
  elim H2; intro.
 
1282
  symmetry  in |- *; assumption.
 
1283
  generalize (derivable_derive f c pr); intro; elim H4; intros l H5.
 
1284
  rewrite H5 in H3; generalize (derive_pt_eq_1 f c l pr H5); intro;
 
1285
    cut (0 < - (l / 2)).
 
1286
  intro; elim (H6 (- (l / 2)) H7); intros delta H9.
 
1287
  cut (0 < (c - a) / 2).
 
1288
  intro; cut (Rmax (- (delta / 2)) ((a - c) / 2) < 0).
 
1289
  intro; cut (Rmax (- (delta / 2)) ((a - c) / 2) <> 0).
 
1290
  intro; cut (Rabs (Rmax (- (delta / 2)) ((a - c) / 2)) < delta).
 
1291
  intro; generalize (H9 (Rmax (- (delta / 2)) ((a - c) / 2)) H11 H12); intro;
 
1292
    cut (a < c + Rmax (- (delta / 2)) ((a - c) / 2)).
 
1293
  cut (c + Rmax (- (delta / 2)) ((a - c) / 2) < b).
 
1294
  intros; generalize (H1 (c + Rmax (- (delta / 2)) ((a - c) / 2)) H15 H14);
 
1295
    intro;
 
1296
      cut
 
1297
        (0 <=
 
1298
          (f (c + Rmax (- (delta / 2)) ((a - c) / 2)) - f c) /
 
1299
          Rmax (- (delta / 2)) ((a - c) / 2)).
 
1300
  intro; cut (0 < - l).
 
1301
  intro; unfold Rminus in H13;
 
1302
    cut
 
1303
      (0 <
 
1304
        (f (c + Rmax (- (delta / 2)) ((a + - c) / 2)) + - f c) /
 
1305
        Rmax (- (delta / 2)) ((a + - c) / 2) + - l).
 
1306
  intro;
 
1307
    cut
 
1308
      (Rabs
 
1309
        ((f (c + Rmax (- (delta / 2)) ((a + - c) / 2)) + - f c) /
 
1310
          Rmax (- (delta / 2)) ((a + - c) / 2) + - l) < 
 
1311
        - (l / 2)).
 
1312
  unfold Rabs in |- *;
 
1313
    case
 
1314
    (Rcase_abs
 
1315
      ((f (c + Rmax (- (delta / 2)) ((a + - c) / 2)) + - f c) /
 
1316
        Rmax (- (delta / 2)) ((a + - c) / 2) + - l)).
 
1317
  intro;
 
1318
    elim
 
1319
      (Rlt_irrefl 0
 
1320
        (Rlt_trans 0
 
1321
          ((f (c + Rmax (- (delta / 2)) ((a + - c) / 2)) + - f c) /
 
1322
            Rmax (- (delta / 2)) ((a + - c) / 2) + - l) 0 H19 r)).
 
1323
  intros;
 
1324
    generalize
 
1325
      (Rplus_lt_compat_r l
 
1326
        ((f (c + Rmax (- (delta / 2)) ((a + - c) / 2)) + - f c) /
 
1327
          Rmax (- (delta / 2)) ((a + - c) / 2) + - l) (
 
1328
            - (l / 2)) H20); repeat rewrite Rplus_assoc; rewrite Rplus_opp_l;
 
1329
      rewrite Rplus_0_r; replace (- (l / 2) + l) with (l / 2).
 
1330
  cut (l / 2 < 0).
 
1331
  intros;
 
1332
    generalize
 
1333
      (Rlt_trans
 
1334
        ((f (c + Rmax (- (delta / 2)) ((a + - c) / 2)) + - f c) /
 
1335
          Rmax (- (delta / 2)) ((a + - c) / 2)) (l / 2) 0 H22 H21); 
 
1336
      intro;
 
1337
        elim
 
1338
          (Rlt_irrefl 0
 
1339
            (Rle_lt_trans 0
 
1340
              ((f (c + Rmax (- (delta / 2)) ((a - c) / 2)) - f c) /
 
1341
                Rmax (- (delta / 2)) ((a - c) / 2)) 0 H17 H23)).
 
1342
  rewrite <- (Ropp_involutive (l / 2)); rewrite <- Ropp_0;
 
1343
    apply Ropp_lt_gt_contravar; assumption.
 
1344
  pattern l at 3 in |- *; rewrite double_var.
 
1345
  ring.
 
1346
  assumption.
 
1347
  apply Rplus_le_lt_0_compat; assumption.
 
1348
  rewrite <- Ropp_0; apply Ropp_lt_gt_contravar; assumption.
 
1349
  unfold Rdiv in |- *;
 
1350
    replace
 
1351
    ((f (c + Rmax (- (delta * / 2)) ((a - c) * / 2)) - f c) *
 
1352
      / Rmax (- (delta * / 2)) ((a - c) * / 2)) with
 
1353
    (- (f (c + Rmax (- (delta * / 2)) ((a - c) * / 2)) - f c) *
 
1354
      / - Rmax (- (delta * / 2)) ((a - c) * / 2)).
 
1355
  apply Rmult_le_pos.
 
1356
  generalize
 
1357
    (Rplus_le_compat_l (- f (c + Rmax (- (delta * / 2)) ((a - c) * / 2)))
 
1358
      (f (c + Rmax (- (delta * / 2)) ((a - c) * / 2))) (
 
1359
        f c) H16); rewrite Rplus_opp_l;
 
1360
    replace (- (f (c + Rmax (- (delta * / 2)) ((a - c) * / 2)) - f c)) with
 
1361
    (- f (c + Rmax (- (delta * / 2)) ((a - c) * / 2)) + f c).
 
1362
  intro; assumption.
 
1363
  ring.
 
1364
  left; apply Rinv_0_lt_compat; rewrite <- Ropp_0; apply Ropp_lt_gt_contravar;
 
1365
    assumption.
 
1366
  unfold Rdiv in |- *.
 
1367
  rewrite <- Ropp_inv_permute.
 
1368
  rewrite Rmult_opp_opp.
 
1369
  reflexivity.
 
1370
  unfold Rdiv in H11; assumption.
 
1371
  generalize (Rplus_lt_compat_l c (Rmax (- (delta / 2)) ((a - c) / 2)) 0 H10);
 
1372
    rewrite Rplus_0_r; intro; apply Rlt_trans with c; 
 
1373
      assumption.
 
1374
  generalize (RmaxLess2 (- (delta / 2)) ((a - c) / 2)); intro;
 
1375
    generalize
 
1376
      (Rplus_le_compat_l c ((a - c) / 2) (Rmax (- (delta / 2)) ((a - c) / 2)) H14);
 
1377
      intro; apply Rlt_le_trans with (c + (a - c) / 2).
 
1378
  apply Rmult_lt_reg_l with 2.
 
1379
  prove_sup0.
 
1380
  replace (2 * (c + (a - c) / 2)) with (a + c).
 
1381
  rewrite double.
 
1382
  apply Rplus_lt_compat_l; assumption.
 
1383
  field; discrR.
 
1384
  assumption.
 
1385
  unfold Rabs in |- *; case (Rcase_abs (Rmax (- (delta / 2)) ((a - c) / 2))).
 
1386
  intro; generalize (RmaxLess1 (- (delta / 2)) ((a - c) / 2)); intro;
 
1387
    generalize
 
1388
      (Ropp_le_ge_contravar (- (delta / 2)) (Rmax (- (delta / 2)) ((a - c) / 2))
 
1389
        H12); rewrite Ropp_involutive; intro;
 
1390
      generalize (Rge_le (delta / 2) (- Rmax (- (delta / 2)) ((a - c) / 2)) H13);
 
1391
        intro; apply Rle_lt_trans with (delta / 2).
 
1392
  assumption.
 
1393
  apply Rmult_lt_reg_l with 2. 
 
1394
  prove_sup0.
 
1395
  unfold Rdiv in |- *; rewrite <- (Rmult_comm (/ 2)); rewrite <- Rmult_assoc;
 
1396
    rewrite <- Rinv_r_sym.
 
1397
  rewrite Rmult_1_l; rewrite double.
 
1398
  pattern delta at 2 in |- *; rewrite <- (Rplus_0_r delta);
 
1399
    apply Rplus_lt_compat_l; rewrite Rplus_0_r; apply (cond_pos delta).
 
1400
  discrR. 
 
1401
  cut (- (delta / 2) < 0).
 
1402
  cut ((a - c) / 2 < 0).
 
1403
  intros;
 
1404
    generalize
 
1405
      (Rmax_stable_in_negreal (mknegreal (- (delta / 2)) H13)
 
1406
        (mknegreal ((a - c) / 2) H12)); simpl in |- *; 
 
1407
      intro; generalize (Rge_le (Rmax (- (delta / 2)) ((a - c) / 2)) 0 r); 
 
1408
        intro;
 
1409
          elim
 
1410
            (Rlt_irrefl 0
 
1411
              (Rle_lt_trans 0 (Rmax (- (delta / 2)) ((a - c) / 2)) 0 H15 H14)).
 
1412
  rewrite <- Ropp_0; rewrite <- (Ropp_involutive ((a - c) / 2));
 
1413
    apply Ropp_lt_gt_contravar; replace (- ((a - c) / 2)) with ((c - a) / 2).
 
1414
  assumption.
 
1415
  unfold Rdiv in |- *.
 
1416
  rewrite <- Ropp_mult_distr_l_reverse. 
 
1417
  rewrite (Ropp_minus_distr a c).
 
1418
  reflexivity.
 
1419
  rewrite <- Ropp_0; apply Ropp_lt_gt_contravar; unfold Rdiv in |- *;
 
1420
    apply Rmult_lt_0_compat;
 
1421
      [ apply (cond_pos delta)
 
1422
        | assert (Hyp : 0 < 2); [ prove_sup0 | apply (Rinv_0_lt_compat 2 Hyp) ] ].
 
1423
  red in |- *; intro; rewrite H11 in H10; elim (Rlt_irrefl 0 H10).
 
1424
  cut ((a - c) / 2 < 0).
 
1425
  intro; cut (- (delta / 2) < 0).
 
1426
  intro;
 
1427
    apply
 
1428
      (Rmax_stable_in_negreal (mknegreal (- (delta / 2)) H11)
 
1429
        (mknegreal ((a - c) / 2) H10)).
 
1430
  rewrite <- Ropp_0; apply Ropp_lt_gt_contravar; unfold Rdiv in |- *;
 
1431
    apply Rmult_lt_0_compat;
 
1432
      [ apply (cond_pos delta)
 
1433
        | assert (Hyp : 0 < 2); [ prove_sup0 | apply (Rinv_0_lt_compat 2 Hyp) ] ].
 
1434
  rewrite <- Ropp_0; rewrite <- (Ropp_involutive ((a - c) / 2));
 
1435
    apply Ropp_lt_gt_contravar; replace (- ((a - c) / 2)) with ((c - a) / 2).
 
1436
  assumption.
 
1437
  unfold Rdiv in |- *.
 
1438
  rewrite <- Ropp_mult_distr_l_reverse. 
 
1439
  rewrite (Ropp_minus_distr a c).
 
1440
  reflexivity.
 
1441
  unfold Rdiv in |- *; apply Rmult_lt_0_compat;
 
1442
    [ generalize (Rplus_lt_compat_r (- a) a c H); rewrite Rplus_opp_r; intro;
 
1443
      assumption
 
1444
      | assert (Hyp : 0 < 2); [ prove_sup0 | apply (Rinv_0_lt_compat 2 Hyp) ] ].
 
1445
  replace (- (l / 2)) with (- l / 2).
 
1446
  unfold Rdiv in |- *; apply Rmult_lt_0_compat.
 
1447
  rewrite <- Ropp_0; apply Ropp_lt_gt_contravar; assumption.
 
1448
  assert (Hyp : 0 < 2); [ prove_sup0 | apply (Rinv_0_lt_compat 2 Hyp) ].
 
1449
  unfold Rdiv in |- *; apply Ropp_mult_distr_l_reverse.
 
1450
Qed.
 
1451
 
 
1452
Theorem deriv_minimum :
 
1453
  forall f (a b c:R) (pr:derivable_pt f c),
 
1454
    a < c ->
 
1455
    c < b ->
 
1456
    (forall x:R, a < x -> x < b -> f c <= f x) -> derive_pt f c pr = 0.
 
1457
Proof.
 
1458
  intros.
 
1459
  rewrite <- (Ropp_involutive (derive_pt f c pr)).
 
1460
  apply Ropp_eq_0_compat.
 
1461
  rewrite <- (derive_pt_opp f c pr).
 
1462
  cut (forall x:R, a < x -> x < b -> (- f)%F x <= (- f)%F c).
 
1463
  intro.
 
1464
  apply (deriv_maximum (- f)%F a b c (derivable_pt_opp _ _ pr) H H0 H2).
 
1465
  intros; unfold opp_fct in |- *; apply Ropp_ge_le_contravar; apply Rle_ge.
 
1466
  apply (H1 x H2 H3).
 
1467
Qed.
 
1468
 
 
1469
Theorem deriv_constant2 :
 
1470
  forall f (a b c:R) (pr:derivable_pt f c),
 
1471
    a < c ->
 
1472
    c < b -> (forall x:R, a < x -> x < b -> f x = f c) -> derive_pt f c pr = 0.
 
1473
Proof.
 
1474
  intros.
 
1475
  eapply deriv_maximum with a b; try assumption.
 
1476
  intros; right; apply (H1 x H2 H3).
 
1477
Qed.
 
1478
 
 
1479
(**********)
 
1480
Lemma nonneg_derivative_0 :
 
1481
  forall f (pr:derivable f),
 
1482
    increasing f -> forall x:R, 0 <= derive_pt f x (pr x).
 
1483
Proof.
 
1484
  intros; unfold increasing in H.
 
1485
  assert (H0 := derivable_derive f x (pr x)).
 
1486
  elim H0; intros l H1.
 
1487
  rewrite H1; case (Rtotal_order 0 l); intro.
 
1488
  left; assumption.
 
1489
  elim H2; intro.
 
1490
  right; assumption.
 
1491
  assert (H4 := derive_pt_eq_1 f x l (pr x) H1).
 
1492
  cut (0 < - (l / 2)).
 
1493
  intro; elim (H4 (- (l / 2)) H5); intros delta H6.
 
1494
  cut (delta / 2 <> 0 /\ 0 < delta / 2 /\ Rabs (delta / 2) < delta).
 
1495
  intro; decompose [and] H7; intros; generalize (H6 (delta / 2) H8 H11);
 
1496
    cut (0 <= (f (x + delta / 2) - f x) / (delta / 2)).
 
1497
  intro; cut (0 <= (f (x + delta / 2) - f x) / (delta / 2) - l).
 
1498
  intro; unfold Rabs in |- *;
 
1499
    case (Rcase_abs ((f (x + delta / 2) - f x) / (delta / 2) - l)).
 
1500
  intro;
 
1501
    elim
 
1502
      (Rlt_irrefl 0
 
1503
        (Rle_lt_trans 0 ((f (x + delta / 2) - f x) / (delta / 2) - l) 0 H12 r)).
 
1504
  intros;
 
1505
    generalize
 
1506
      (Rplus_lt_compat_r l ((f (x + delta / 2) - f x) / (delta / 2) - l)
 
1507
        (- (l / 2)) H13); unfold Rminus in |- *;
 
1508
      replace (- (l / 2) + l) with (l / 2).
 
1509
  rewrite Rplus_assoc; rewrite Rplus_opp_l; rewrite Rplus_0_r; intro;
 
1510
    generalize
 
1511
      (Rle_lt_trans 0 ((f (x + delta / 2) - f x) / (delta / 2)) (l / 2) H9 H14);
 
1512
      intro; cut (l / 2 < 0).
 
1513
  intro; elim (Rlt_irrefl 0 (Rlt_trans 0 (l / 2) 0 H15 H16)).
 
1514
  rewrite <- Ropp_0 in H5;
 
1515
    generalize (Ropp_lt_gt_contravar (-0) (- (l / 2)) H5);
 
1516
      repeat rewrite Ropp_involutive; intro; assumption.
 
1517
  pattern l at 3 in |- *; rewrite double_var.
 
1518
  ring.
 
1519
  unfold Rminus in |- *; apply Rplus_le_le_0_compat.
 
1520
  unfold Rdiv in |- *; apply Rmult_le_pos.
 
1521
  cut (x <= x + delta * / 2).
 
1522
  intro; generalize (H x (x + delta * / 2) H12); intro;
 
1523
    generalize (Rplus_le_compat_l (- f x) (f x) (f (x + delta * / 2)) H13);
 
1524
      rewrite Rplus_opp_l; rewrite Rplus_comm; intro; assumption.
 
1525
  pattern x at 1 in |- *; rewrite <- (Rplus_0_r x); apply Rplus_le_compat_l;
 
1526
    left; assumption.
 
1527
  left; apply Rinv_0_lt_compat; assumption.
 
1528
  left; rewrite <- Ropp_0; apply Ropp_lt_gt_contravar; assumption.
 
1529
  unfold Rdiv in |- *; apply Rmult_le_pos.
 
1530
  cut (x <= x + delta * / 2).
 
1531
  intro; generalize (H x (x + delta * / 2) H9); intro;
 
1532
    generalize (Rplus_le_compat_l (- f x) (f x) (f (x + delta * / 2)) H12);
 
1533
      rewrite Rplus_opp_l; rewrite Rplus_comm; intro; assumption.
 
1534
  pattern x at 1 in |- *; rewrite <- (Rplus_0_r x); apply Rplus_le_compat_l;
 
1535
    left; assumption. 
 
1536
  left; apply Rinv_0_lt_compat; assumption.
 
1537
  split.
 
1538
  unfold Rdiv in |- *; apply prod_neq_R0.
 
1539
  generalize (cond_pos delta); intro; red in |- *; intro H9; rewrite H9 in H7;
 
1540
    elim (Rlt_irrefl 0 H7).
 
1541
  apply Rinv_neq_0_compat; discrR.
 
1542
  split.
 
1543
  unfold Rdiv in |- *; apply Rmult_lt_0_compat;
 
1544
    [ apply (cond_pos delta) | apply Rinv_0_lt_compat; prove_sup0 ].
 
1545
  replace (Rabs (delta / 2)) with (delta / 2).
 
1546
  unfold Rdiv in |- *; apply Rmult_lt_reg_l with 2.
 
1547
  prove_sup0.
 
1548
  rewrite (Rmult_comm 2).
 
1549
  rewrite Rmult_assoc; rewrite <- Rinv_l_sym; [ idtac | discrR ].
 
1550
  rewrite Rmult_1_r.
 
1551
  rewrite double.
 
1552
  pattern (pos delta) at 1 in |- *; rewrite <- Rplus_0_r.
 
1553
  apply Rplus_lt_compat_l; apply (cond_pos delta).
 
1554
  symmetry  in |- *; apply Rabs_right.
 
1555
  left; change (0 < delta / 2) in |- *; unfold Rdiv in |- *;
 
1556
    apply Rmult_lt_0_compat;
 
1557
      [ apply (cond_pos delta) | apply Rinv_0_lt_compat; prove_sup0 ].
 
1558
  unfold Rdiv in |- *; rewrite <- Ropp_mult_distr_l_reverse;
 
1559
    apply Rmult_lt_0_compat.
 
1560
  apply Rplus_lt_reg_r with l.
 
1561
  unfold Rminus in |- *; rewrite Rplus_opp_r; rewrite Rplus_0_r; assumption.
 
1562
  apply Rinv_0_lt_compat; prove_sup0.
 
1563
Qed.