summaryrefslogtreecommitdiff
path: root/theories/Reals/Ranalysis3.v
blob: 4e88714d61129624021d990b31fec1375b5cc204 (plain)
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
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
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
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
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
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
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
651
652
653
654
655
656
657
658
659
660
661
662
663
664
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
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
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
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
(************************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
(* <O___,, *   INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2016     *)
(*   \VV/  **************************************************************)
(*    //   *      This file is distributed under the terms of the       *)
(*         *       GNU Lesser General Public License Version 2.1        *)
(************************************************************************)

Require Import Rbase.
Require Import Rfunctions.
Require Import Ranalysis1.
Require Import Ranalysis2.
Local Open Scope R_scope.

(** Division *)
Theorem derivable_pt_lim_div :
  forall (f1 f2:R -> R) (x l1 l2:R),
    derivable_pt_lim f1 x l1 ->
    derivable_pt_lim f2 x l2 ->
    f2 x <> 0 ->
    derivable_pt_lim (f1 / f2) x ((l1 * f2 x - l2 * f1 x) / Rsqr (f2 x)).
Proof.
  intros f1 f2 x l1 l2 H H0 H1.
  cut (derivable_pt f2 x);
    [ intro X | unfold derivable_pt; exists l2; exact H0 ].
  assert (H2 := continuous_neq_0 _ _ (derivable_continuous_pt _ _ X) H1).
  elim H2; clear H2; intros eps_f2 H2.
  unfold div_fct.
  assert (H3 := derivable_continuous_pt _ _ X).
  unfold continuity_pt in H3; unfold continue_in in H3; unfold limit1_in in H3;
    unfold limit_in in H3; unfold dist in H3.
  simpl in H3; unfold R_dist in H3.
  elim (H3 (Rabs (f2 x) / 2));
    [ idtac
      | unfold Rdiv; change (0 < Rabs (f2 x) * / 2);
        apply Rmult_lt_0_compat;
          [ apply Rabs_pos_lt; assumption | apply Rinv_0_lt_compat; prove_sup0 ] ].
  clear H3; intros alp_f2 H3.
  cut
    (forall x0:R,
      Rabs (x0 - x) < alp_f2 -> Rabs (f2 x0 - f2 x) < Rabs (f2 x) / 2).
  intro H4.
  cut (forall a:R, Rabs (a - x) < alp_f2 -> Rabs (f2 x) / 2 < Rabs (f2 a)).
  intro H5.
  cut
    (forall a:R,
      Rabs a < Rmin eps_f2 alp_f2 -> / Rabs (f2 (x + a)) < 2 / Rabs (f2 x)).
  intro Maj.
  unfold derivable_pt_lim; intros.
  elim (H (Rabs (eps * f2 x / 8)));
    [ idtac
      | unfold Rdiv; change (0 < Rabs (eps * f2 x * / 8));
        apply Rabs_pos_lt; repeat apply prod_neq_R0;
          [ red; intro H7; rewrite H7 in H6; elim (Rlt_irrefl _ H6)
            | assumption
            | apply Rinv_neq_0_compat; discrR ] ].
  intros alp_f1d H7.
  case (Req_dec (f1 x) 0); intro.
  case (Req_dec l1 0); intro.
(***********************************)
(*              First case         *)
(*           (f1 x)=0  l1 =0       *)
(***********************************)
  cut (0 < Rmin eps_f2 (Rmin alp_f2 alp_f1d));
    [ intro
      | repeat apply Rmin_pos;
        [ apply (cond_pos eps_f2)
          | elim H3; intros; assumption
          | apply (cond_pos alp_f1d) ] ].
  exists (mkposreal (Rmin eps_f2 (Rmin alp_f2 alp_f1d)) H10).
  simpl; intros.
  assert (H13 := Rlt_le_trans _ _ _ H12 (Rmin_r _ _)).
  assert (H14 := Rlt_le_trans _ _ _ H12 (Rmin_l _ _)).
  assert (H15 := Rlt_le_trans _ _ _ H13 (Rmin_r _ _)).
  assert (H16 := Rlt_le_trans _ _ _ H13 (Rmin_l _ _)).
  assert (H17 := H7 _ H11 H15).
  rewrite formule; [ idtac | assumption | assumption | apply H2; apply H14 ].
  apply Rle_lt_trans with
    (Rabs (/ f2 (x + h) * ((f1 (x + h) - f1 x) / h - l1)) +
      Rabs (l1 / (f2 x * f2 (x + h)) * (f2 x - f2 (x + h))) +
      Rabs (f1 x / (f2 x * f2 (x + h)) * ((f2 (x + h) - f2 x) / h - l2)) +
      Rabs (l2 * f1 x / (Rsqr (f2 x) * f2 (x + h)) * (f2 (x + h) - f2 x))).
  unfold Rminus.
  rewrite <-
    (Rabs_Ropp (f1 x / (f2 x * f2 (x + h)) * ((f2 (x + h) + - f2 x) / h + - l2)))
    .
  apply Rabs_4.
  repeat rewrite Rabs_mult.
  apply Rlt_le_trans with (eps / 4 + eps / 4 + eps / 4 + eps / 4).
  cut (Rabs (/ f2 (x + h)) * Rabs ((f1 (x + h) - f1 x) / h - l1) < eps / 4).
  cut (Rabs (l1 / (f2 x * f2 (x + h))) * Rabs (f2 x - f2 (x + h)) < eps / 4).
  cut
    (Rabs (f1 x / (f2 x * f2 (x + h))) * Rabs ((f2 (x + h) - f2 x) / h - l2) <
      eps / 4).
  cut
    (Rabs (l2 * f1 x / (Rsqr (f2 x) * f2 (x + h))) * Rabs (f2 (x + h) - f2 x) <
      eps / 4).
  intros.
  apply Rlt_4; assumption.
  rewrite H8.
  unfold Rdiv; repeat rewrite Rmult_0_r || rewrite Rmult_0_l.
  rewrite Rabs_R0; rewrite Rmult_0_l.
  apply Rmult_lt_0_compat; [ assumption | apply Rinv_0_lt_compat; prove_sup ].
  rewrite H8.
  unfold Rdiv; repeat rewrite Rmult_0_r || rewrite Rmult_0_l.
  rewrite Rabs_R0; rewrite Rmult_0_l.
  apply Rmult_lt_0_compat; [ assumption | apply Rinv_0_lt_compat; prove_sup ].
  rewrite H9.
  unfold Rdiv; repeat rewrite Rmult_0_r || rewrite Rmult_0_l.
  rewrite Rabs_R0; rewrite Rmult_0_l.
  apply Rmult_lt_0_compat; [ assumption | apply Rinv_0_lt_compat; prove_sup ].
  rewrite <- Rabs_mult.
  apply (maj_term1 x h eps l1 alp_f2 eps_f2 alp_f1d f1 f2);
    try assumption || apply H2.
  apply H14.
  apply Rmin_2; assumption.
  right; symmetry ; apply quadruple_var.
(***********************************)
(*           Second case           *)
(*           (f1 x)=0  l1<>0       *)
(***********************************)
  assert (H10 := derivable_continuous_pt _ _ X).
  unfold continuity_pt in H10.
  unfold continue_in in H10.
  unfold limit1_in in H10.
  unfold limit_in in H10.
  unfold dist in H10.
  simpl in H10.
  unfold R_dist in H10.
  elim (H10 (Rabs (eps * Rsqr (f2 x) / (8 * l1)))).
  clear H10; intros alp_f2t2 H10.
  cut
    (forall a:R,
      Rabs a < alp_f2t2 ->
      Rabs (f2 (x + a) - f2 x) < Rabs (eps * Rsqr (f2 x) / (8 * l1))).
  intro H11.
  cut (0 < Rmin (Rmin eps_f2 alp_f1d) (Rmin alp_f2 alp_f2t2)).
  intro.
  exists (mkposreal (Rmin (Rmin eps_f2 alp_f1d) (Rmin alp_f2 alp_f2t2)) H12).
  simpl.
  intros.
  assert (H15 := Rlt_le_trans _ _ _ H14 (Rmin_r _ _)).
  assert (H16 := Rlt_le_trans _ _ _ H14 (Rmin_l _ _)).
  assert (H17 := Rlt_le_trans _ _ _ H15 (Rmin_l _ _)).
  assert (H18 := Rlt_le_trans _ _ _ H15 (Rmin_r _ _)).
  assert (H19 := Rlt_le_trans _ _ _ H16 (Rmin_l _ _)).
  assert (H20 := Rlt_le_trans _ _ _ H16 (Rmin_r _ _)).
  clear H14 H15 H16.
  rewrite formule; try assumption.
  apply Rle_lt_trans with
    (Rabs (/ f2 (x + h) * ((f1 (x + h) - f1 x) / h - l1)) +
      Rabs (l1 / (f2 x * f2 (x + h)) * (f2 x - f2 (x + h))) +
      Rabs (f1 x / (f2 x * f2 (x + h)) * ((f2 (x + h) - f2 x) / h - l2)) +
      Rabs (l2 * f1 x / (Rsqr (f2 x) * f2 (x + h)) * (f2 (x + h) - f2 x))).
  unfold Rminus.
  rewrite <-
    (Rabs_Ropp (f1 x / (f2 x * f2 (x + h)) * ((f2 (x + h) + - f2 x) / h + - l2)))
    .
  apply Rabs_4.
  repeat rewrite Rabs_mult.
  apply Rlt_le_trans with (eps / 4 + eps / 4 + eps / 4 + eps / 4).
  cut (Rabs (/ f2 (x + h)) * Rabs ((f1 (x + h) - f1 x) / h - l1) < eps / 4).
  cut (Rabs (l1 / (f2 x * f2 (x + h))) * Rabs (f2 x - f2 (x + h)) < eps / 4).
  cut
    (Rabs (f1 x / (f2 x * f2 (x + h))) * Rabs ((f2 (x + h) - f2 x) / h - l2) <
      eps / 4).
  cut
    (Rabs (l2 * f1 x / (Rsqr (f2 x) * f2 (x + h))) * Rabs (f2 (x + h) - f2 x) <
      eps / 4).
  intros.
  apply Rlt_4; assumption.
  rewrite H8.
  unfold Rdiv; repeat rewrite Rmult_0_r || rewrite Rmult_0_l.
  rewrite Rabs_R0; rewrite Rmult_0_l.
  apply Rmult_lt_0_compat; [ assumption | apply Rinv_0_lt_compat; prove_sup ].
  rewrite H8.
  unfold Rdiv; repeat rewrite Rmult_0_r || rewrite Rmult_0_l.
  rewrite Rabs_R0; rewrite Rmult_0_l.
  apply Rmult_lt_0_compat; [ assumption | apply Rinv_0_lt_compat; prove_sup ].
  rewrite <- Rabs_mult.
  apply (maj_term2 x h eps l1 alp_f2 alp_f2t2 eps_f2 f2); try assumption.
  apply H2; assumption.
  apply Rmin_2; assumption.
  rewrite <- Rabs_mult.
  apply (maj_term1 x h eps l1 alp_f2 eps_f2 alp_f1d f1 f2); try assumption.
  apply H2; assumption.
  apply Rmin_2; assumption.
  right; symmetry ; apply quadruple_var.
  apply H2; assumption.
  repeat apply Rmin_pos.
  apply (cond_pos eps_f2).
  apply (cond_pos alp_f1d).
  elim H3; intros; assumption.
  elim H10; intros; assumption.
  intros.
  elim H10; intros.
  case (Req_dec a 0); intro.
  rewrite H14; rewrite Rplus_0_r.
  unfold Rminus; rewrite Rplus_opp_r.
  rewrite Rabs_R0.
  apply Rabs_pos_lt.
  unfold Rdiv, Rsqr; repeat rewrite Rmult_assoc.
  repeat apply prod_neq_R0; try assumption.
  red; intro; rewrite H15 in H6; elim (Rlt_irrefl _ H6).
  apply Rinv_neq_0_compat; repeat apply prod_neq_R0; discrR || assumption.
  apply H13.
  split.
  apply D_x_no_cond; assumption.
  replace (x + a - x) with a; [ assumption | ring ].
  change (0 < Rabs (eps * Rsqr (f2 x) / (8 * l1))).
  apply Rabs_pos_lt; unfold Rdiv, Rsqr; repeat rewrite Rmult_assoc;
    repeat apply prod_neq_R0.
  red; intro; rewrite H11 in H6; elim (Rlt_irrefl _ H6).
  assumption.
  assumption.
  apply Rinv_neq_0_compat; repeat apply prod_neq_R0;
    [ discrR | discrR | discrR | assumption ].
(***********************************)
(*        Third case               *)
(*     (f1 x)<>0  l1=0  l2=0       *)
(***********************************)
  case (Req_dec l1 0); intro.
  case (Req_dec l2 0); intro.
  elim (H0 (Rabs (Rsqr (f2 x) * eps / (8 * f1 x))));
    [ idtac
      | apply Rabs_pos_lt; unfold Rdiv, Rsqr; repeat rewrite Rmult_assoc;
        repeat apply prod_neq_R0;
          [ assumption
            | assumption
            | red; intro; rewrite H11 in H6; elim (Rlt_irrefl _ H6)
            | apply Rinv_neq_0_compat; repeat apply prod_neq_R0; discrR || assumption ] ].
  intros alp_f2d H12.
  cut (0 < Rmin (Rmin eps_f2 alp_f2) (Rmin alp_f1d alp_f2d)).
  intro.
  exists (mkposreal (Rmin (Rmin eps_f2 alp_f2) (Rmin alp_f1d alp_f2d)) H11).
  simpl.
  intros.
  assert (H15 := Rlt_le_trans _ _ _ H14 (Rmin_l _ _)).
  assert (H16 := Rlt_le_trans _ _ _ H14 (Rmin_r _ _)).
  assert (H17 := Rlt_le_trans _ _ _ H15 (Rmin_l _ _)).
  assert (H18 := Rlt_le_trans _ _ _ H15 (Rmin_r _ _)).
  assert (H19 := Rlt_le_trans _ _ _ H16 (Rmin_l _ _)).
  assert (H20 := Rlt_le_trans _ _ _ H16 (Rmin_r _ _)).
  clear H15 H16.
  rewrite formule; try assumption.
  apply Rle_lt_trans with
    (Rabs (/ f2 (x + h) * ((f1 (x + h) - f1 x) / h - l1)) +
      Rabs (l1 / (f2 x * f2 (x + h)) * (f2 x - f2 (x + h))) +
      Rabs (f1 x / (f2 x * f2 (x + h)) * ((f2 (x + h) - f2 x) / h - l2)) +
      Rabs (l2 * f1 x / (Rsqr (f2 x) * f2 (x + h)) * (f2 (x + h) - f2 x))).
  unfold Rminus.
  rewrite <-
    (Rabs_Ropp (f1 x / (f2 x * f2 (x + h)) * ((f2 (x + h) + - f2 x) / h + - l2)))
    .
  apply Rabs_4.
  repeat rewrite Rabs_mult.
  apply Rlt_le_trans with (eps / 4 + eps / 4 + eps / 4 + eps / 4).
  cut (Rabs (/ f2 (x + h)) * Rabs ((f1 (x + h) - f1 x) / h - l1) < eps / 4).
  cut (Rabs (l1 / (f2 x * f2 (x + h))) * Rabs (f2 x - f2 (x + h)) < eps / 4).
  cut
    (Rabs (f1 x / (f2 x * f2 (x + h))) * Rabs ((f2 (x + h) - f2 x) / h - l2) <
      eps / 4).
  cut
    (Rabs (l2 * f1 x / (Rsqr (f2 x) * f2 (x + h))) * Rabs (f2 (x + h) - f2 x) <
      eps / 4).
  intros.
  apply Rlt_4; assumption.
  rewrite H10.
  unfold Rdiv; repeat rewrite Rmult_0_r || rewrite Rmult_0_l.
  rewrite Rabs_R0; rewrite Rmult_0_l.
  apply Rmult_lt_0_compat; [ assumption | apply Rinv_0_lt_compat; prove_sup ].
  rewrite <- Rabs_mult.
  apply (maj_term3 x h eps l2 alp_f2 eps_f2 alp_f2d f1 f2); try assumption.
  apply H2; assumption.
  apply Rmin_2; assumption.
  rewrite H9.
  unfold Rdiv; repeat rewrite Rmult_0_r || rewrite Rmult_0_l.
  rewrite Rabs_R0; rewrite Rmult_0_l.
  apply Rmult_lt_0_compat; [ assumption | apply Rinv_0_lt_compat; prove_sup ].
  rewrite <- Rabs_mult.
  apply (maj_term1 x h eps l1 alp_f2 eps_f2 alp_f1d f1 f2); assumption || idtac.
  apply H2; assumption.
  apply Rmin_2; assumption.
  right; symmetry ; apply quadruple_var.
  apply H2; assumption.
  repeat apply Rmin_pos.
  apply (cond_pos eps_f2).
  elim H3; intros; assumption.
  apply (cond_pos alp_f1d).
  apply (cond_pos alp_f2d).
(***********************************)
(*      Fourth case                *)
(*    (f1 x)<>0  l1=0  l2<>0       *)
(***********************************)
  elim (H0 (Rabs (Rsqr (f2 x) * eps / (8 * f1 x))));
    [ idtac
      | apply Rabs_pos_lt; unfold Rsqr, Rdiv;
        repeat rewrite Rinv_mult_distr; repeat apply prod_neq_R0;
          try assumption || discrR ].
  intros alp_f2d H11.
  assert (H12 := derivable_continuous_pt _ _ X).
  unfold continuity_pt in H12.
  unfold continue_in in H12.
  unfold limit1_in in H12.
  unfold limit_in in H12.
  unfold dist in H12.
  simpl in H12.
  unfold R_dist in H12.
  elim (H12 (Rabs (Rsqr (f2 x) * f2 x * eps / (8 * f1 x * l2)))).
  intros alp_f2c H13.
  cut (0 < Rmin (Rmin eps_f2 alp_f2) (Rmin alp_f1d (Rmin alp_f2d alp_f2c))).
  intro.
  exists
    (mkposreal (Rmin (Rmin eps_f2 alp_f2) (Rmin alp_f1d (Rmin alp_f2d alp_f2c)))
      H14).
  simpl; intros.
  assert (H17 := Rlt_le_trans _ _ _ H16 (Rmin_l _ _)).
  assert (H18 := Rlt_le_trans _ _ _ H16 (Rmin_r _ _)).
  assert (H19 := Rlt_le_trans _ _ _ H18 (Rmin_r _ _)).
  assert (H20 := Rlt_le_trans _ _ _ H19 (Rmin_l _ _)).
  assert (H21 := Rlt_le_trans _ _ _ H19 (Rmin_r _ _)).
  assert (H22 := Rlt_le_trans _ _ _ H18 (Rmin_l _ _)).
  assert (H23 := Rlt_le_trans _ _ _ H17 (Rmin_l _ _)).
  assert (H24 := Rlt_le_trans _ _ _ H17 (Rmin_r _ _)).
  clear H16 H17 H18 H19.
  cut
    (forall a:R,
      Rabs a < alp_f2c ->
      Rabs (f2 (x + a) - f2 x) <
      Rabs (Rsqr (f2 x) * f2 x * eps / (8 * f1 x * l2))).
  intro.
  rewrite formule; try assumption.
  apply Rle_lt_trans with
    (Rabs (/ f2 (x + h) * ((f1 (x + h) - f1 x) / h - l1)) +
      Rabs (l1 / (f2 x * f2 (x + h)) * (f2 x - f2 (x + h))) +
      Rabs (f1 x / (f2 x * f2 (x + h)) * ((f2 (x + h) - f2 x) / h - l2)) +
      Rabs (l2 * f1 x / (Rsqr (f2 x) * f2 (x + h)) * (f2 (x + h) - f2 x))).
  unfold Rminus.
  rewrite <-
    (Rabs_Ropp (f1 x / (f2 x * f2 (x + h)) * ((f2 (x + h) + - f2 x) / h + - l2)))
    .
  apply Rabs_4.
  repeat rewrite Rabs_mult.
  apply Rlt_le_trans with (eps / 4 + eps / 4 + eps / 4 + eps / 4).
  cut (Rabs (/ f2 (x + h)) * Rabs ((f1 (x + h) - f1 x) / h - l1) < eps / 4).
  cut (Rabs (l1 / (f2 x * f2 (x + h))) * Rabs (f2 x - f2 (x + h)) < eps / 4).
  cut
    (Rabs (f1 x / (f2 x * f2 (x + h))) * Rabs ((f2 (x + h) - f2 x) / h - l2) <
      eps / 4).
  cut
    (Rabs (l2 * f1 x / (Rsqr (f2 x) * f2 (x + h))) * Rabs (f2 (x + h) - f2 x) <
      eps / 4).
  intros.
  apply Rlt_4; assumption.
  rewrite <- Rabs_mult.
  apply (maj_term4 x h eps l2 alp_f2 alp_f2c eps_f2 f1 f2); try assumption.
  apply H2; assumption.
  apply Rmin_2; assumption.
  rewrite <- Rabs_mult.
  apply (maj_term3 x h eps l2 alp_f2 eps_f2 alp_f2d f1 f2); try assumption.
  apply H2; assumption.
  apply Rmin_2; assumption.
  rewrite H9.
  unfold Rdiv; repeat rewrite Rmult_0_r || rewrite Rmult_0_l.
  rewrite Rabs_R0; rewrite Rmult_0_l.
  apply Rmult_lt_0_compat; [ assumption | apply Rinv_0_lt_compat; prove_sup ].
  rewrite <- Rabs_mult.
  apply (maj_term1 x h eps l1 alp_f2 eps_f2 alp_f1d f1 f2); try assumption.
  apply H2; assumption.
  apply Rmin_2; assumption.
  right; symmetry ; apply quadruple_var.
  apply H2; assumption.
  intros.
  case (Req_dec a 0); intro.
  rewrite H17; rewrite Rplus_0_r.
  unfold Rminus; rewrite Rplus_opp_r; rewrite Rabs_R0.
  apply Rabs_pos_lt.
  unfold Rdiv, Rsqr.
  repeat rewrite Rinv_mult_distr; try assumption.
  repeat apply prod_neq_R0; try assumption.
  red; intro H18; rewrite H18 in H6; elim (Rlt_irrefl _ H6).
  apply Rinv_neq_0_compat; discrR.
  apply Rinv_neq_0_compat; discrR.
  apply Rinv_neq_0_compat; discrR.
  apply Rinv_neq_0_compat; assumption.
  apply Rinv_neq_0_compat; assumption.
  discrR.
  discrR.
  discrR.
  discrR.
  discrR.
  apply prod_neq_R0; [ discrR | assumption ].
  elim H13; intros.
  apply H19.
  split.
  apply D_x_no_cond; assumption.
  replace (x + a - x) with a; [ assumption | ring ].
  repeat apply Rmin_pos.
  apply (cond_pos eps_f2).
  elim H3; intros; assumption.
  apply (cond_pos alp_f1d).
  apply (cond_pos alp_f2d).
  elim H13; intros; assumption.
  change (0 < Rabs (Rsqr (f2 x) * f2 x * eps / (8 * f1 x * l2))).
  apply Rabs_pos_lt.
  unfold Rsqr, Rdiv.
  repeat rewrite Rinv_mult_distr; try assumption || discrR.
  repeat apply prod_neq_R0; try assumption.
  red; intro H13; rewrite H13 in H6; elim (Rlt_irrefl _ H6).
  apply Rinv_neq_0_compat; discrR.
  apply Rinv_neq_0_compat; discrR.
  apply Rinv_neq_0_compat; discrR.
  apply Rinv_neq_0_compat; assumption.
  apply Rinv_neq_0_compat; assumption.
  apply prod_neq_R0; [ discrR | assumption ].
  red; intro H11; rewrite H11 in H6; elim (Rlt_irrefl _ H6).
  apply Rinv_neq_0_compat; discrR.
  apply Rinv_neq_0_compat; discrR.
  apply Rinv_neq_0_compat; discrR.
  apply Rinv_neq_0_compat; assumption.
(***********************************)
(*         Fifth case              *)
(*    (f1 x)<>0  l1<>0  l2=0       *)
(***********************************)
  case (Req_dec l2 0); intro.
  assert (H11 := derivable_continuous_pt _ _ X).
  unfold continuity_pt in H11.
  unfold continue_in in H11.
  unfold limit1_in in H11.
  unfold limit_in in H11.
  unfold dist in H11.
  simpl in H11.
  unfold R_dist in H11.
  elim (H11 (Rabs (eps * Rsqr (f2 x) / (8 * l1)))).
  clear H11; intros alp_f2t2 H11.
  elim (H0 (Rabs (Rsqr (f2 x) * eps / (8 * f1 x)))).
  intros alp_f2d H12.
  cut (0 < Rmin (Rmin eps_f2 alp_f2) (Rmin alp_f1d (Rmin alp_f2d alp_f2t2))).
  intro.
  exists
    (mkposreal
      (Rmin (Rmin eps_f2 alp_f2) (Rmin alp_f1d (Rmin alp_f2d alp_f2t2))) H13).
  simpl.
  intros.
  cut
    (forall a:R,
      Rabs a < alp_f2t2 ->
      Rabs (f2 (x + a) - f2 x) < Rabs (eps * Rsqr (f2 x) / (8 * l1))).
  intro.
  assert (H17 := Rlt_le_trans _ _ _ H15 (Rmin_l _ _)).
  assert (H18 := Rlt_le_trans _ _ _ H15 (Rmin_r _ _)).
  assert (H19 := Rlt_le_trans _ _ _ H17 (Rmin_r _ _)).
  assert (H20 := Rlt_le_trans _ _ _ H17 (Rmin_l _ _)).
  assert (H21 := Rlt_le_trans _ _ _ H18 (Rmin_r _ _)).
  assert (H22 := Rlt_le_trans _ _ _ H18 (Rmin_l _ _)).
  assert (H23 := Rlt_le_trans _ _ _ H21 (Rmin_l _ _)).
  assert (H24 := Rlt_le_trans _ _ _ H21 (Rmin_r _ _)).
  clear H15 H17 H18 H21.
  rewrite formule; try assumption.
  apply Rle_lt_trans with
    (Rabs (/ f2 (x + h) * ((f1 (x + h) - f1 x) / h - l1)) +
      Rabs (l1 / (f2 x * f2 (x + h)) * (f2 x - f2 (x + h))) +
      Rabs (f1 x / (f2 x * f2 (x + h)) * ((f2 (x + h) - f2 x) / h - l2)) +
      Rabs (l2 * f1 x / (Rsqr (f2 x) * f2 (x + h)) * (f2 (x + h) - f2 x))).
  unfold Rminus.
  rewrite <-
    (Rabs_Ropp (f1 x / (f2 x * f2 (x + h)) * ((f2 (x + h) + - f2 x) / h + - l2)))
    .
  apply Rabs_4.
  repeat rewrite Rabs_mult.
  apply Rlt_le_trans with (eps / 4 + eps / 4 + eps / 4 + eps / 4).
  cut (Rabs (/ f2 (x + h)) * Rabs ((f1 (x + h) - f1 x) / h - l1) < eps / 4).
  cut (Rabs (l1 / (f2 x * f2 (x + h))) * Rabs (f2 x - f2 (x + h)) < eps / 4).
  cut
    (Rabs (f1 x / (f2 x * f2 (x + h))) * Rabs ((f2 (x + h) - f2 x) / h - l2) <
      eps / 4).
  cut
    (Rabs (l2 * f1 x / (Rsqr (f2 x) * f2 (x + h))) * Rabs (f2 (x + h) - f2 x) <
      eps / 4).
  intros.
  apply Rlt_4; assumption.
  rewrite H10.
  unfold Rdiv; repeat rewrite Rmult_0_r || rewrite Rmult_0_l.
  rewrite Rabs_R0; rewrite Rmult_0_l.
  apply Rmult_lt_0_compat; [ assumption | apply Rinv_0_lt_compat; prove_sup ].
  rewrite <- Rabs_mult.
  apply (maj_term3 x h eps l2 alp_f2 eps_f2 alp_f2d f1 f2); try assumption.
  apply H2; assumption.
  apply Rmin_2; assumption.
  rewrite <- Rabs_mult.
  apply (maj_term2 x h eps l1 alp_f2 alp_f2t2 eps_f2 f2); try assumption.
  apply H2; assumption.
  apply Rmin_2; assumption.
  rewrite <- Rabs_mult.
  apply (maj_term1 x h eps l1 alp_f2 eps_f2 alp_f1d f1 f2); try assumption.
  apply H2; assumption.
  apply Rmin_2; assumption.
  right; symmetry ; apply quadruple_var.
  apply H2; assumption.
  intros.
  case (Req_dec a 0); intro.
  rewrite H17; rewrite Rplus_0_r; unfold Rminus; rewrite Rplus_opp_r;
    rewrite Rabs_R0.
  apply Rabs_pos_lt.
  unfold Rdiv; rewrite Rinv_mult_distr; try discrR || assumption.
  unfold Rsqr.
  repeat apply prod_neq_R0;
    assumption ||
      (apply Rinv_neq_0_compat; assumption) ||
        (apply Rinv_neq_0_compat; discrR) ||
          (red; intro H18; rewrite H18 in H6; elim (Rlt_irrefl _ H6)).
  elim H11; intros.
  apply H19.
  split.
  apply D_x_no_cond; assumption.
  replace (x + a - x) with a; [ assumption | ring ].
  repeat apply Rmin_pos.
  apply (cond_pos eps_f2).
  elim H3; intros; assumption.
  apply (cond_pos alp_f1d).
  apply (cond_pos alp_f2d).
  elim H11; intros; assumption.
  apply Rabs_pos_lt.
  unfold Rdiv, Rsqr; rewrite Rinv_mult_distr; try discrR || assumption.
  repeat apply prod_neq_R0;
    assumption ||
      (apply Rinv_neq_0_compat; assumption) ||
        (apply Rinv_neq_0_compat; discrR) ||
          (red; intro H12; rewrite H12 in H6; elim (Rlt_irrefl _ H6)).
  change (0 < Rabs (eps * Rsqr (f2 x) / (8 * l1))).
  apply Rabs_pos_lt.
  unfold Rdiv, Rsqr; rewrite Rinv_mult_distr; try discrR || assumption.
  repeat apply prod_neq_R0;
    assumption ||
      (apply Rinv_neq_0_compat; assumption) ||
        (apply Rinv_neq_0_compat; discrR) ||
          (red; intro H12; rewrite H12 in H6; elim (Rlt_irrefl _ H6)).
(***********************************)
(*       Sixth case                *)
(*    (f1 x)<>0  l1<>0  l2<>0      *)
(***********************************)
  elim (H0 (Rabs (Rsqr (f2 x) * eps / (8 * f1 x)))).
  intros alp_f2d H11.
  assert (H12 := derivable_continuous_pt _ _ X).
  unfold continuity_pt in H12.
  unfold continue_in in H12.
  unfold limit1_in in H12.
  unfold limit_in in H12.
  unfold dist in H12.
  simpl in H12.
  unfold R_dist in H12.
  elim (H12 (Rabs (Rsqr (f2 x) * f2 x * eps / (8 * f1 x * l2)))).
  intros alp_f2c H13.
  elim (H12 (Rabs (eps * Rsqr (f2 x) / (8 * l1)))).
  intros alp_f2t2 H14.
  cut
    (0 <
      Rmin (Rmin (Rmin eps_f2 alp_f2) (Rmin alp_f1d alp_f2d))
      (Rmin alp_f2c alp_f2t2)).
  intro.
  exists
    (mkposreal
      (Rmin (Rmin (Rmin eps_f2 alp_f2) (Rmin alp_f1d alp_f2d))
        (Rmin alp_f2c alp_f2t2)) H15).
  simpl.
  intros.
  assert (H18 := Rlt_le_trans _ _ _ H17 (Rmin_l _ _)).
  assert (H19 := Rlt_le_trans _ _ _ H17 (Rmin_r _ _)).
  assert (H20 := Rlt_le_trans _ _ _ H18 (Rmin_l _ _)).
  assert (H21 := Rlt_le_trans _ _ _ H18 (Rmin_r _ _)).
  assert (H22 := Rlt_le_trans _ _ _ H19 (Rmin_l _ _)).
  assert (H23 := Rlt_le_trans _ _ _ H19 (Rmin_r _ _)).
  assert (H24 := Rlt_le_trans _ _ _ H20 (Rmin_l _ _)).
  assert (H25 := Rlt_le_trans _ _ _ H20 (Rmin_r _ _)).
  assert (H26 := Rlt_le_trans _ _ _ H21 (Rmin_l _ _)).
  assert (H27 := Rlt_le_trans _ _ _ H21 (Rmin_r _ _)).
  clear H17 H18 H19 H20 H21.
  cut
    (forall a:R,
      Rabs a < alp_f2t2 ->
      Rabs (f2 (x + a) - f2 x) < Rabs (eps * Rsqr (f2 x) / (8 * l1))).
  cut
    (forall a:R,
      Rabs a < alp_f2c ->
      Rabs (f2 (x + a) - f2 x) <
      Rabs (Rsqr (f2 x) * f2 x * eps / (8 * f1 x * l2))).
  intros.
  rewrite formule; try assumption.
  apply Rle_lt_trans with
    (Rabs (/ f2 (x + h) * ((f1 (x + h) - f1 x) / h - l1)) +
      Rabs (l1 / (f2 x * f2 (x + h)) * (f2 x - f2 (x + h))) +
      Rabs (f1 x / (f2 x * f2 (x + h)) * ((f2 (x + h) - f2 x) / h - l2)) +
      Rabs (l2 * f1 x / (Rsqr (f2 x) * f2 (x + h)) * (f2 (x + h) - f2 x))).
  unfold Rminus.
  rewrite <-
    (Rabs_Ropp (f1 x / (f2 x * f2 (x + h)) * ((f2 (x + h) + - f2 x) / h + - l2)))
    .
  apply Rabs_4.
  repeat rewrite Rabs_mult.
  apply Rlt_le_trans with (eps / 4 + eps / 4 + eps / 4 + eps / 4).
  cut (Rabs (/ f2 (x + h)) * Rabs ((f1 (x + h) - f1 x) / h - l1) < eps / 4).
  cut (Rabs (l1 / (f2 x * f2 (x + h))) * Rabs (f2 x - f2 (x + h)) < eps / 4).
  cut
    (Rabs (f1 x / (f2 x * f2 (x + h))) * Rabs ((f2 (x + h) - f2 x) / h - l2) <
      eps / 4).
  cut
    (Rabs (l2 * f1 x / (Rsqr (f2 x) * f2 (x + h))) * Rabs (f2 (x + h) - f2 x) <
      eps / 4).
  intros.
  apply Rlt_4; assumption.
  rewrite <- Rabs_mult.
  apply (maj_term4 x h eps l2 alp_f2 alp_f2c eps_f2 f1 f2); try assumption.
  apply H2; assumption.
  apply Rmin_2; assumption.
  rewrite <- Rabs_mult.
  apply (maj_term3 x h eps l2 alp_f2 eps_f2 alp_f2d f1 f2); try assumption.
  apply H2; assumption.
  apply Rmin_2; assumption.
  rewrite <- Rabs_mult.
  apply (maj_term2 x h eps l1 alp_f2 alp_f2t2 eps_f2 f2); try assumption.
  apply H2; assumption.
  apply Rmin_2; assumption.
  rewrite <- Rabs_mult.
  apply (maj_term1 x h eps l1 alp_f2 eps_f2 alp_f1d f1 f2); try assumption.
  apply H2; assumption.
  apply Rmin_2; assumption.
  right; symmetry ; apply quadruple_var.
  apply H2; assumption.
  intros.
  case (Req_dec a 0); intro.
  rewrite H18; rewrite Rplus_0_r; unfold Rminus; rewrite Rplus_opp_r;
    rewrite Rabs_R0; apply Rabs_pos_lt.
  unfold Rdiv, Rsqr; rewrite Rinv_mult_distr.
  repeat apply prod_neq_R0;
    assumption ||
      (apply Rinv_neq_0_compat; assumption) ||
        (apply Rinv_neq_0_compat; discrR) ||
          (red; intro H28; rewrite H28 in H6; elim (Rlt_irrefl _ H6)).
  apply prod_neq_R0; [ discrR | assumption ].
  apply prod_neq_R0; [ discrR | assumption ].
  assumption.
  elim H13; intros.
  apply H20.
  split.
  apply D_x_no_cond; assumption.
  replace (x + a - x) with a; [ assumption | ring ].
  intros.
  case (Req_dec a 0); intro.
  rewrite H18; rewrite Rplus_0_r; unfold Rminus; rewrite Rplus_opp_r;
    rewrite Rabs_R0; apply Rabs_pos_lt.
  unfold Rdiv, Rsqr; rewrite Rinv_mult_distr.
  repeat apply prod_neq_R0;
    assumption ||
      (apply Rinv_neq_0_compat; assumption) ||
        (apply Rinv_neq_0_compat; discrR) ||
          (red; intro H28; rewrite H28 in H6; elim (Rlt_irrefl _ H6)).
  discrR.
  assumption.
  elim H14; intros.
  apply H20.
  split.
  unfold D_x, no_cond; split.
  trivial.
  apply Rminus_not_eq_right.
  replace (x + a - x) with a; [ assumption | ring ].
  replace (x + a - x) with a; [ assumption | ring ].
  repeat apply Rmin_pos.
  apply (cond_pos eps_f2).
  elim H3; intros; assumption.
  apply (cond_pos alp_f1d).
  apply (cond_pos alp_f2d).
  elim H13; intros; assumption.
  elim H14; intros; assumption.
  change (0 < Rabs (eps * Rsqr (f2 x) / (8 * l1))); apply Rabs_pos_lt.
  unfold Rdiv, Rsqr; rewrite Rinv_mult_distr; try discrR || assumption.
  repeat apply prod_neq_R0;
    assumption ||
      (apply Rinv_neq_0_compat; assumption) ||
        (apply Rinv_neq_0_compat; discrR) ||
          (red; intro H14; rewrite H14 in H6; elim (Rlt_irrefl _ H6)).
  change (0 < Rabs (Rsqr (f2 x) * f2 x * eps / (8 * f1 x * l2)));
    apply Rabs_pos_lt.
  unfold Rdiv, Rsqr; rewrite Rinv_mult_distr.
  repeat apply prod_neq_R0;
    assumption ||
      (apply Rinv_neq_0_compat; assumption) ||
        (apply Rinv_neq_0_compat; discrR) ||
          (red; intro H13; rewrite H13 in H6; elim (Rlt_irrefl _ H6)).
  apply prod_neq_R0; [ discrR | assumption ].
  apply prod_neq_R0; [ discrR | assumption ].
  assumption.
  apply Rabs_pos_lt.
  unfold Rdiv, Rsqr; rewrite Rinv_mult_distr;
    [ idtac | discrR | assumption ].
  repeat apply prod_neq_R0;
    assumption ||
      (apply Rinv_neq_0_compat; assumption) ||
        (apply Rinv_neq_0_compat; discrR) ||
          (red; intro H11; rewrite H11 in H6; elim (Rlt_irrefl _ H6)).
  intros.
  unfold Rdiv.
  apply Rmult_lt_reg_l with (Rabs (f2 (x + a))).
  apply Rabs_pos_lt; apply H2.
  apply Rlt_le_trans with (Rmin eps_f2 alp_f2).
  assumption.
  apply Rmin_l.
  rewrite <- Rinv_r_sym.
  apply Rmult_lt_reg_l with (Rabs (f2 x)).
  apply Rabs_pos_lt; assumption.
  rewrite Rmult_1_r.
  rewrite (Rmult_comm (Rabs (f2 x))).
  repeat rewrite Rmult_assoc.
  rewrite <- Rinv_l_sym.
  rewrite Rmult_1_r.
  apply Rmult_lt_reg_l with (/ 2).
  apply Rinv_0_lt_compat; prove_sup0.
  repeat rewrite (Rmult_comm (/ 2)).
  repeat rewrite Rmult_assoc.
  rewrite <- Rinv_r_sym.
  rewrite Rmult_1_r.
  unfold Rdiv in H5; apply H5.
  replace (x + a - x) with a.
  assert (H7 := Rlt_le_trans _ _ _ H6 (Rmin_r _ _)); assumption.
  ring.
  discrR.
  apply Rabs_no_R0; assumption.
  apply Rabs_no_R0; apply H2.
  assert (H7 := Rlt_le_trans _ _ _ H6 (Rmin_l _ _)); assumption.
  intros.
  assert (H6 := H4 a H5).
  rewrite <- (Rabs_Ropp (f2 a - f2 x)) in H6.
  rewrite Ropp_minus_distr in H6.
  assert (H7 := Rle_lt_trans _ _ _ (Rabs_triang_inv _ _) H6).
  apply Rplus_lt_reg_l with (- Rabs (f2 a) + Rabs (f2 x) / 2).
  rewrite Rplus_assoc.
  rewrite <- double_var.
  do 2 rewrite (Rplus_comm (- Rabs (f2 a))).
  rewrite Rplus_assoc; rewrite Rplus_opp_l; rewrite Rplus_0_r.
  unfold Rminus in H7; assumption.
  intros.
  case (Req_dec x x0); intro.
  rewrite <- H5; unfold Rminus; rewrite Rplus_opp_r; rewrite Rabs_R0;
    unfold Rdiv; apply Rmult_lt_0_compat;
      [ apply Rabs_pos_lt; assumption | apply Rinv_0_lt_compat; prove_sup0 ].
  elim H3; intros.
  apply H7.
  split.
  unfold D_x, no_cond; split.
  trivial.
  assumption.
  assumption.
Qed.

Lemma derivable_pt_div :
  forall (f1 f2:R -> R) (x:R),
    derivable_pt f1 x ->
    derivable_pt f2 x -> f2 x <> 0 -> derivable_pt (f1 / f2) x.
Proof.
  unfold derivable_pt.
  intros f1 f2 x X X0 H.
  elim X; intros.
  elim X0; intros.
  exists ((x0 * f2 x - x1 * f1 x) / Rsqr (f2 x)).
  apply derivable_pt_lim_div; assumption.
Qed.

Lemma derivable_div :
  forall f1 f2:R -> R,
    derivable f1 ->
    derivable f2 -> (forall x:R, f2 x <> 0) -> derivable (f1 / f2).
Proof.
  unfold derivable; intros f1 f2 X X0 H x.
  apply (derivable_pt_div _ _ _ (X x) (X0 x) (H x)).
Qed.

Lemma derive_pt_div :
  forall (f1 f2:R -> R) (x:R) (pr1:derivable_pt f1 x)
    (pr2:derivable_pt f2 x) (na:f2 x <> 0),
    derive_pt (f1 / f2) x (derivable_pt_div _ _ _ pr1 pr2 na) =
    (derive_pt f1 x pr1 * f2 x - derive_pt f2 x pr2 * f1 x) / Rsqr (f2 x).
Proof.
  intros.
  assert (H := derivable_derive f1 x pr1).
  assert (H0 := derivable_derive f2 x pr2).
  assert
    (H1 := derivable_derive (f1 / f2)%F x (derivable_pt_div _ _ _ pr1 pr2 na)).
  elim H; clear H; intros l1 H.
  elim H0; clear H0; intros l2 H0.
  elim H1; clear H1; intros l H1.
  rewrite H; rewrite H0; apply derive_pt_eq_0.
  assert (H3 := proj2_sig pr1).
  unfold derive_pt in H; rewrite H in H3.
  assert (H4 := proj2_sig pr2).
  unfold derive_pt in H0; rewrite H0 in H4.
  apply derivable_pt_lim_div; assumption.
Qed.