-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHopital.v
3119 lines (2373 loc) · 104 KB
/
Hopital.v
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
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Require Import Reals.
Require Import Lra.
Require Import Rfunction_classes_def.
Require Import Cauchy_lipschitz. (* TODO on importe des trucs qui parlent de Cn *)
Require Import Rextensionality.
Open Scope R_scope.
(*
TODO check, rename, indent, and comment
*)
(*
This file contains a proof of the Hopital's rule.
Due to the huge number of different cases we provide the user with some lemmas corresponding to
the cases of the Hopital's rule
How to use this file ?
There are 4 parameters:
- The limit can be when x -> a+(the lemmas has a suffix : _right) or when x -> a- (the lemmas have a suffix : _left)
(* TODO change the names accordingly *)
- The limit of g is either + infinity, -infinity or 0
- The limit L of (f' / g') is either finite, +infinity or -infinity
********Not supported*********
If you want to reason about limits like x -> + infinity or x -> - infinity, we suggest that you change the variable
x -> 1 / t and then use this file with limits: t -> 0+ or t -> 0-
******************************
So, an example of a specification can be :
"Theorem Hopital_g0_Lfin_right :
a, b \in R,
Hab: a < b
Cf, Cg: f and g continue on [a; b],
Df, Dg: f and g derivable on ]a; b[
Zf: lim_{x -> a+} f = 0
Zg: lim_{x -> a+} g = 0
g_not_0: \forall x \in ]a; b[, g' x <> 0 /\ g x <> 0
Hlimder: lim_{x -> a+} f' / g' = L (with L \in R)
-----------------------------------------------------
lim_{x -> a+} f / g = L"
Exhaustive lemmas usable:
- Hopital_g0_Lfin_right
- Hopital_g0_Lpinf_right
- Hopital_g0_Lninf_right
- Hopital_gpinf_Lfin_right
- Hopital_gpinf_Lpinf_right
- Hopital_gpinf_Lninf_right
- Hopital_gninf_Lfin_right
- Hopital_gninf_Lpinf_right
- Hopital_gninf_Lninf_right
- Hopital_g0_Lfin_left
- Hopital_g0_Lpinf_left
- Hopital_g0_Lninf_left
- Hopital_gpinf_Lfin_left
- Hopital_gpinf_Lpinf_left
- Hopital_gpinf_Lninf_left
- Hopital_gninf_Lfin_left
- Hopital_gninf_Lpinf_left
- Hopital_gninf_Lninf_left
*)
Definition derivable_on_interval a b (Hab : a < b) f :=
forall x, open_interval a b x -> derivable_pt f x.
Section Definitions.
Definition limit_div_pos f (I : R -> Prop) a := forall m, m > 0 ->
exists alp, alp > 0 /\
forall x, I x -> R_dist x a < alp -> m < f x.
Definition limit_div_neg f (I : R -> Prop) a := forall m, m > 0 ->
exists alp, alp > 0 /\
forall x, I x -> R_dist x a < alp -> -m > f x.
Lemma limit_div_Ropp : forall a b g, a < b ->
limit_div_neg g (open_interval a b) a ->
limit_div_pos (fun x : R => - g x) (open_interval a b) a.
Proof.
intros. unfold limit_div_pos, limit_div_neg in *. intros. specialize (H0 m H1).
destruct H0. exists x. split.
now intuition.
intros. destruct H0. specialize (H4 x0 H2 H3). lra.
Qed.
Lemma limit_div_pos_inv : forall f a b, limit_div_neg (fun x => - f x) (open_interval a b) a ->
limit_div_pos f (open_interval a b) a.
Proof.
intros.
unfold limit_div_pos, limit_div_neg in *.
intros m Hm. specialize (H m Hm).
destruct H as [alp [Halp Hsolve]].
exists alp. split. assumption.
intros. specialize (Hsolve x H H0).
lra.
Qed.
Lemma limit_div_neg_inv : forall f a b, limit_div_pos (fun x => - f x) (open_interval a b) a ->
limit_div_neg f (open_interval a b) a.
Proof.
intros.
unfold limit_div_pos, limit_div_neg in *.
intros m Hm. specialize (H m Hm).
destruct H as [alp [Halp Hsolve]].
exists alp. split. assumption.
intros. specialize (Hsolve x H H0).
lra.
Qed.
Lemma limit_div_neg_ext : forall f g (I : R -> Prop) a, (forall x, I x -> f x = g x) ->
limit_div_neg f I a -> limit_div_neg g I a.
Proof.
intros.
unfold limit_div_neg in *.
intros m Hm. specialize (H0 m Hm).
destruct H0 as [alp [Halp Hsolve]].
exists alp. split. assumption.
intros. specialize (Hsolve x H0 H1).
rewrite <- H. apply Hsolve.
apply H0.
Qed.
Lemma limit_div_pos_ext : forall f g (I : R -> Prop) a, (forall x, I x -> f x = g x) ->
limit_div_pos f I a -> limit_div_pos g I a.
Proof.
intros.
unfold limit_div_neg in *.
intros m Hm. specialize (H0 m Hm).
destruct H0 as [alp [Halp Hsolve]].
exists alp. split. assumption.
intros. specialize (Hsolve x H0 H1).
rewrite <- H. apply Hsolve.
apply H0.
Qed.
Lemma limit_div_pos_open : forall a b b' f,
open_interval a b b' -> limit_div_pos f (open_interval a b') a -> limit_div_pos f (open_interval a b) a.
Proof.
intros.
unfold limit_div_pos in *. intros m Hm.
destruct (H0 m Hm) as [alp [Halp Hsolve]].
exists (Rmin alp (b' - a)). split. apply Rmin_Rgt_r. split; destruct H; lra.
intros. assert (x < b').
unfold R_dist in H2. rewrite Rabs_right in H2. replace b' with ((b' - a) + a) by ring.
assert (x - a < b' - a). apply Rlt_le_trans with (Rmin alp (b'- a)). apply H2.
apply Rmin_r. lra. destruct H1; lra.
apply Hsolve. split. apply H1. apply H3. apply Rlt_le_trans with (Rmin alp (b'-a)).
apply H2. apply Rmin_l.
Qed.
Lemma limit_div_neg_open : forall a b b' f,
open_interval a b b' -> limit_div_neg f (open_interval a b') a -> limit_div_neg f (open_interval a b) a.
Proof.
intros.
unfold limit_div_neg in *. intros m Hm.
destruct (H0 m Hm) as [alp [Halp Hsolve]].
exists (Rmin alp (b' - a)). split. apply Rmin_Rgt_r. split; destruct H; lra.
intros. assert (x < b').
unfold R_dist in H2. rewrite Rabs_right in H2. replace b' with ((b' - a) + a) by ring.
assert (x - a < b' - a). apply Rlt_le_trans with (Rmin alp (b'- a)). apply H2.
apply Rmin_r. lra. destruct H1; lra.
apply Hsolve. split. apply H1. apply H3. apply Rlt_le_trans with (Rmin alp (b'-a)).
apply H2. apply Rmin_l.
Qed.
Lemma limit_div_pos_opp : forall a b g, limit_div_pos g (open_interval a b) b ->
limit_div_pos (fun x : R => g (- x)) (open_interval (- b) (- a)) (- b).
Proof.
intros.
unfold limit_div_pos in *.
intros m Hm. destruct (H m Hm) as [alp [Halp Hsolve]].
exists alp. split. apply Halp. intros.
assert (Hopen : open_interval a b (-x)). split; destruct H0; lra.
assert (Hdist : R_dist (-x) b < alp). unfold R_dist in *.
replace (-x - b) with (- (x + b)) by ring.
rewrite Rabs_Ropp. ring_simplify (x -- b) in H1. apply H1.
specialize (Hsolve (-x) Hopen Hdist).
apply Hsolve.
Qed.
Lemma limit_div_neg_opp : forall a b g, limit_div_neg g (open_interval a b) b ->
limit_div_neg (fun x : R => g (- x)) (open_interval (- b) (- a)) (- b).
Proof.
intros.
unfold limit_div_neg in *.
intros m Hm. destruct (H m Hm) as [alp [Halp Hsolve]].
exists alp. split. apply Halp. intros.
assert (Hopen : open_interval a b (-x)). split; destruct H0; lra.
assert (Hdist : R_dist (-x) b < alp). unfold R_dist in *.
replace (-x - b) with (- (x + b)) by ring.
rewrite Rabs_Ropp. ring_simplify (x -- b) in H1. apply H1.
specialize (Hsolve (-x) Hopen Hdist).
apply Hsolve.
Qed.
Lemma limit_div_pos_imp :
forall (f : R -> R) (D D1 : R -> Prop) (l : R),
(forall x0 : R, D1 x0 -> D x0) -> limit_div_pos f D l -> limit_div_pos f D1 l.
Proof.
intros.
unfold limit_div_pos in *.
intros m Hm.
specialize (H0 m Hm).
destruct H0 as [alp [Halp Hsolve]].
exists alp. split.
apply Halp.
intros. assert (D x).
intuition.
specialize (Hsolve x H2 H1). apply Hsolve.
Qed.
Lemma limit_div_neg_imp :
forall (f : R -> R) (D D1 : R -> Prop) (l : R),
(forall x0 : R, D1 x0 -> D x0) -> limit_div_neg f D l -> limit_div_neg f D1 l.
Proof.
intros.
intros m Hm.
specialize (H0 m Hm).
destruct H0 as [alp [Halp Hsolve]].
exists alp. split.
apply Halp.
intros. assert (D x).
intuition.
specialize (Hsolve x H2 H1). apply Hsolve.
Qed.
Lemma limit_div_pos_comp_Ropp :
forall (g : R -> R) (a b : R),
limit_div_pos g (open_interval (-a) (-b)) (-a) ->
limit_div_pos (comp g (fun x => -x)) (open_interval b a) a.
Proof.
intros.
intros m Hm.
specialize (H m Hm).
destruct H as [alp [Halp Hsolve]].
exists alp. split. apply Halp.
intros. specialize (Hsolve (-x)).
apply Hsolve. split; destruct H; lra.
unfold R_dist in *. replace (- x - - a) with (- (x - a)) by ring.
rewrite Rabs_Ropp. apply H0.
Qed.
Lemma limit_div_pos_comp_Ropp_l :
forall (g : R -> R) (a b : R),
limit_div_pos g (open_interval (-a) (-b)) (-b) ->
limit_div_pos (comp g (fun x => -x)) (open_interval b a) b.
Proof.
intros.
intros m Hm.
specialize (H m Hm).
destruct H as [alp [Halp Hsolve]].
exists alp. split. apply Halp.
intros. specialize (Hsolve (-x)).
apply Hsolve. split; destruct H; lra.
unfold R_dist in *. replace (- x - - b) with (- (x - b)) by ring.
rewrite Rabs_Ropp. apply H0.
Qed.
Lemma limit_div_neg_comp_Ropp :
forall (g : R -> R) (a b : R),
limit_div_neg g (open_interval (-a) (-b)) (-a) ->
limit_div_neg (comp g (fun x => -x)) (open_interval b a) a.
Proof.
intros.
intros m Hm.
specialize (H m Hm).
destruct H as [alp [Halp Hsolve]].
exists alp. split. apply Halp.
intros. specialize (Hsolve (-x)).
apply Hsolve. split; destruct H; lra.
unfold R_dist in *. replace (- x - - a) with (- (x - a)) by ring.
rewrite Rabs_Ropp. apply H0.
Qed.
Lemma limit_div_neg_comp_Ropp_l :
forall (g : R -> R) (a b : R),
limit_div_neg g (open_interval (-a) (-b)) (-b) ->
limit_div_neg (comp g (fun x => -x)) (open_interval b a) b.
Proof.
intros.
intros m Hm.
specialize (H m Hm).
destruct H as [alp [Halp Hsolve]].
exists alp. split. apply Halp.
intros. specialize (Hsolve (-x)).
apply Hsolve. split; destruct H; lra.
unfold R_dist in *. replace (- x - - b) with (- (x - b)) by ring.
rewrite Rabs_Ropp. apply H0.
Qed.
End Definitions.
Lemma derive_pt_comp_Ropp : forall a b f x (Df : forall x, open_interval a b x -> derivable_pt f x)
(Df' : forall x, open_interval (-b) (-a) x -> derivable_pt (fun x0 => f (- x0)) x)
(H1 : open_interval (-b) (-a) x) (H2 : open_interval a b (-x)), - derive_pt f (- x) (Df (- x) H2) =
derive_pt (fun x0 : R => f (- x0)) x (Df' x H1).
Proof.
intros.
assert (derivable_pt (comp f (fun x=> Ropp x)) x). reg. apply derivable_pt_opp. reg.
apply Df. apply H2.
assert (Heq : forall x, (fun x0 => f (-x0)) x = (comp f (fun x => Ropp x)) x).
intros. reflexivity.
rewrite (derive_pt_ext (fun x0 => f (-x0)) (comp f (fun x => Ropp x)) Heq x (Df' (x) H1) H).
assert (derivable_pt (fun x => (-x)) x). reg.
assert (derivable_pt f ((fun x => -x) x)). apply Df. apply H2.
pose (p := derivable_pt_comp (fun x => (-x)) f x H0 H3).
rewrite (pr_nu_var _ _ _ H p).
unfold p.
rewrite derive_pt_comp. replace (derive_pt (fun x0 : R => (- x0)%R) x H0) with (-(1%R)).
ring_simplify. apply Ropp_eq_compat. apply pr_nu.
rewrite <- derive_pt_id with x. rewrite <- derive_pt_opp.
unfold id. apply pr_nu.
reflexivity.
Qed.
Section FirstGenHopital.
(*
Theorem Hopital_g0_Lfin_right :
a, b \in R,
Hab: a < b
Cf, Cg: f and g continue on [a; b],
Df, Dg: f and g derivable on ]a; b[
Zf: lim_{x -> a+} f = 0
Zg: lim_{x -> a+} g = 0
g_not_0: \forall x \in ]a; b[, g' x <> 0 /\ g x <> 0
Hlimder: lim_{x -> a+} f' / g' = L (with L \in R)
-----------------------------------------------------
lim_{x -> a+} f / g = L
*)
Variables f g : R -> R.
Variables a b L : R.
Hypothesis Hab : a < b.
Hypotheses (Df : forall x, open_interval a b x -> derivable_pt f x)
(Dg : forall x, open_interval a b x -> derivable_pt g x).
Hypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)
(Cg : forall x, a <= x <= b -> continuity_pt g x).
Hypothesis (Zf : limit1_in f (open_interval a b) 0 a).
Hypothesis (Zg : limit1_in g (open_interval a b) 0 a).
Hypothesis (g_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0 /\ g x <> 0).
Hypothesis (Hlimder : forall eps, eps > 0 ->
exists alp,
alp > 0 /\
(forall x (Hopen : open_interval a b x), R_dist x a < alp ->
R_dist (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen)) L < eps)).
Lemma limit_open : forall f a b,
limit1_in f (D_x no_cond a) (f a) a -> limit1_in f (open_interval a b) (f a) a.
Proof.
clear Hlimder Zf Zg. unfold limit1_in in *. unfold limit_in in *. intros. specialize (H eps H0).
destruct H as [alp [Halp H2]]. exists alp. split.
now apply Halp.
intros. apply H2. destruct H. split.
constructor.
now constructor.
unfold open_interval in H. now intro; destruct H; lra.
apply H1.
Qed.
Lemma f_a_zero : f a = 0.
Proof.
assert (forall x (Hclose : a <= x <= b), continuity_pt f x).
intros. apply Cf. now apply Hclose.
unfold continuity_pt in H. unfold continue_in in H. specialize (H a). assert (a <= a <= b) by intuition.
apply H in H0. apply (limit_open f a b) in H0. eapply single_limit; [ | apply H0 | apply Zf ]. unfold adhDa.
intros. exists (a + Rmin ((b - a) / 2) (alp / 2)). assert (H6 : alp / 2 > 0) by lra.
assert ((b - a) > 0) by lra. assert ((b-a) /2 > 0).
apply (Rmult_gt_0_compat (/2)) in H2.
now lra.
now lra.
split.
unfold open_interval. split.
assert (Rmin ((b - a) /2) (alp/2) > 0).
apply Rmin_Rgt_r. now intuition.
now lra.
apply Rle_lt_trans with (a + (b-a) / 2).
apply Rplus_le_compat.
now intuition.
now apply Rmin_l.
assert (b - a - (b - a) / 2 > 0).
field_simplify. now lra.
now lra.
unfold R_dist. rewrite Rabs_right.
ring_simplify. apply Rle_lt_trans with (alp / 2).
now apply Rmin_r.
now lra.
ring_simplify. apply Rle_ge. apply Rmin_glb; intuition.
Qed.
Lemma g_a_zero : g a = 0.
Proof.
assert (forall x (Hclose : a <= x <= b), continuity_pt g x).
intros. apply Cg. now apply Hclose.
unfold continuity_pt in H. unfold continue_in in H. specialize (H a). assert (a <= a <= b) by intuition.
apply H in H0. apply (limit_open g a b) in H0. eapply single_limit; [ | apply H0 | apply Zg ].
unfold adhDa. intros. exists (a + Rmin ((b - a) / 2) (alp / 2)). assert (H6 : alp / 2 > 0) by lra.
assert ((b - a) > 0) by lra. assert ((b-a) /2 > 0).
apply (Rmult_gt_0_compat (/2)) in H2.
now lra.
now lra.
split.
unfold open_interval. split.
assert (Rmin ((b - a) /2) (alp/2) > 0).
apply Rmin_Rgt_r. now intuition.
now lra.
apply Rle_lt_trans with (a + (b-a) / 2).
apply Rplus_le_compat.
now intuition.
now apply Rmin_l.
assert (b - a - (b - a) / 2 > 0).
field_simplify. now lra.
now lra.
unfold R_dist. rewrite Rabs_right.
ring_simplify. apply Rle_lt_trans with (alp / 2).
now apply Rmin_r.
now lra.
ring_simplify. apply Rle_ge. apply Rmin_glb; intuition.
Qed.
Theorem Hopital_g0_Lfin_right : limit1_in (fun x => f x / g x) (open_interval a b) L a.
Proof.
unfold limit1_in, limit_in. intros. specialize (Hlimder eps H). destruct Hlimder as [alp [Halp Hlim]].
exists alp. split.
now assumption.
intros. assert (Hacc2 : forall x, open_interval a b x ->
exists c, exists Hopenc, f x / g x = derive_pt f c (Df c Hopenc) / derive_pt g c (Dg c Hopenc) /\ a < c < x).
generalize MVT. intros. specialize (H1 f g a x0). assert (forall c, a < c < x0 -> derivable_pt f c).
intros. apply Df. unfold open_interval. split.
now intuition.
now apply Rlt_trans with x0; unfold open_interval in H2; intuition.
assert (forall c, a < c < x0 -> derivable_pt g c).
intros. apply Dg. unfold open_interval. split.
now intuition.
now apply Rlt_trans with x0; unfold open_interval in H2; intuition.
specialize (H1 H3 H4). assert (a < x0) by (unfold open_interval in H2; intuition).
assert (forall c : R, a <= c <= x0 -> continuity_pt f c).
intros. apply Cf. split.
now intuition.
unfold open_interval in H2. now apply Rle_trans with x0; intuition.
assert (forall c, a <= c <= x0 -> continuity_pt g c).
intros. apply Cg. split.
now intuition.
unfold open_interval in H2. now apply Rle_trans with x0; intuition.
specialize (H1 H5 H6 H7). destruct H1 as [c [P Hold2]]. exists c. assert (Hopenc : open_interval a b c).
unfold open_interval in *. split.
now apply P.
apply Rlt_trans with x0.
now apply P.
now apply H2.
exists Hopenc. split.
rewrite g_a_zero in Hold2. rewrite f_a_zero in Hold2. do 2 rewrite Rminus_0_r in Hold2.
apply (Rmult_eq_reg_l (g x0)).
rewrite (pr_nu f c _ (H3 c P)). unfold Rdiv. do 2 rewrite <- Rmult_assoc. rewrite Hold2.
rewrite (pr_nu g c _ (Dg c Hopenc)). field. generalize (g_not_0 c Hopenc). generalize (g_not_0 x0 H2).
intros H01 H02. assert (c < b).
now unfold open_interval in Hopenc; destruct Hopenc; assumption.
split.
now apply H02.
now apply H01.
apply g_not_0. now apply H2.
now apply P.
destruct H0. specialize (Hacc2 x H0). destruct Hacc2 as [c [Hopenc Haccc]]. specialize (Hlim c).
simpl in *. unfold R_dist in *. assert (open_interval a b c /\ Rabs (c - a) < alp).
split.
now apply Hopenc.
destruct Haccc. destruct H3. rewrite Rabs_right.
rewrite Rabs_right in H1.
now lra.
now lra.
now lra.
specialize (Hlim Hopenc). destruct H2. specialize (Hlim H3). destruct Haccc. rewrite H4.
apply Hlim.
Qed.
End FirstGenHopital.
Section FirstGenHopital_left.
(*
Theorem Hopital_g0_Lfin_left :
a, b \in R,
Hab: a < b
Cf, Cg: f and g continue on [a; b],
Df, Dg: f and g derivable on ]a; b[
Zf: lim_{x -> b-} f = 0
Zg: lim_{x -> b-} g = 0
g_not_0: \forall x \in ]a; b[, g' x <> 0 /\ g x <> 0
Hlimder: lim_{x -> b-} f' / g' = L (with L \in R)
-----------------------------------------------------
lim_{x -> b-} f / g = L
*)
Variables f g : R -> R.
Variables a b L : R.
Hypothesis Hab : a < b.
Hypotheses (Df : forall x, open_interval a b x -> derivable_pt f x)
(Dg : forall x, open_interval a b x -> derivable_pt g x).
Hypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)
(Cg : forall x, a <= x <= b -> continuity_pt g x).
Hypothesis (Zf : limit1_in f (open_interval a b) 0 b).
Hypothesis (Zg : limit1_in g (open_interval a b) 0 b).
Hypothesis (g_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0 /\ g x <> 0).
Hypothesis (Hlimder : forall eps, eps > 0 ->
exists alp,
alp > 0 /\
(forall x (Hopen : open_interval a b x), R_dist x b < alp ->
R_dist (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen)) L < eps)).
Theorem Hopital_g0_Lfin_left : limit1_in (fun x => f x / g x) (open_interval a b) L b.
Proof.
apply limit1_ext with (comp (fun x => f (-x) / g (-x)) (fun x => -x)).
intros. unfold comp. ring_simplify (--x). now reflexivity.
apply limit1_imp with (Dgf (open_interval a b) (open_interval (-b) (-a)) (fun x => - x)).
intros. unfold Dgf. split.
now apply H.
now destruct H; split; lra.
apply (limit_comp (fun x => - x) (fun x : R => f (- x) / g (- x)) _ _ (-b)).
unfold limit1_in, limit_in. intros. exists eps. split.
now assumption.
intros. destruct H0. unfold dist in *. simpl in *. destruct H0. unfold R_dist in *.
replace (- x -- b) with (- (x - b)) by ring. rewrite Rabs_Ropp. now apply H1.
assert (Df': forall x, open_interval (-b) (-a) x -> derivable_pt (fun x => f (- x)) x).
intros. reg. apply Df. now destruct H; split; lra.
assert (Dg': forall x, open_interval (-b) (-a) x -> derivable_pt (fun x => g (- x)) x).
intros. reg. apply Dg. now destruct H; split; lra.
apply Hopital_g0_Lfin_right with Df' Dg'.
now intuition.
intros. reg. apply Cf. now destruct H; split; lra.
intros. reg. apply Cg. now destruct H; split; lra.
unfold limit1_in, limit_in in *. intros eps Heps. specialize (Zf eps Heps). destruct Zf as [alp [Halp Hsolve]].
exists alp. split.
now assumption.
intros x H. specialize (Hsolve (-x)). assert (H1 : open_interval a b (- x) /\ dist R_met (- x) b < alp).
split.
destruct H. now destruct H; split; lra.
unfold dist in *. simpl in *. destruct H. unfold R_dist in *. replace (-x - b) with (- (x -- b)) by ring.
rewrite Rabs_Ropp. now apply H0.
apply Hsolve. now apply H1.
unfold limit1_in, limit_in in *. intros eps Heps. specialize (Zg eps Heps). destruct Zg as [alp [Halp Hsolve]].
exists alp. split.
now assumption.
intros x H. specialize (Hsolve (-x)). assert (H1 : open_interval a b (- x) /\ dist R_met (- x) b < alp).
split.
destruct H. now destruct H; split; lra.
unfold dist in *. simpl in *. destruct H. unfold R_dist in *. replace (-x - b) with (- (x -- b)) by ring.
rewrite Rabs_Ropp. now apply H0.
apply Hsolve. now apply H1.
intros. assert (Hopen2: open_interval a b (-x)).
now destruct Hopen; split; lra.
destruct (g_not_0 (-x) Hopen2). split.
assert (derive_pt (fun x0 : R => g (- x0)) x (Dg' x Hopen) = - derive_pt g (- x) (Dg (- x) Hopen2)).
reg.
apply Ropp_eq_compat. now apply pr_nu.
apply Dg. now apply Hopen2.
rewrite H1. intro. apply H. replace 0 with (-0) in H2 by ring. apply Ropp_eq_compat in H2.
ring_simplify in H2. now apply H2.
now apply H0.
intros eps Heps. specialize (Hlimder eps Heps). destruct Hlimder as [alp [Halp Hsolve]].
exists alp. split.
now assumption.
intros. assert (open_interval a b (-x)).
now destruct Hopen; split; lra.
assert (R_dist (-x) b < alp).
unfold R_dist in *. replace (- x - b) with (- (x -- b)) by ring. rewrite Rabs_Ropp.
now apply H.
specialize (Hsolve (-x) H0 H1). assert (derive_pt (fun x0 : R => f (- x0)) x (Df' x Hopen) = - derive_pt f (- x) (Df (- x) H0) ).
reg.
apply Ropp_eq_compat. now apply pr_nu.
apply Df. now destruct Hopen; split; lra.
assert (derive_pt (fun x0 : R => g (- x0)) x (Dg' x Hopen) = - derive_pt g (- x) (Dg (- x) H0) ).
reg.
apply Ropp_eq_compat. now apply pr_nu.
apply Dg. now destruct Hopen; split; lra.
rewrite H2. rewrite H3. replace (- derive_pt f (- x) (Df (- x) H0) / - derive_pt g (- x) (Dg (- x) H0)) with
(derive_pt f (- x) (Df (- x) H0) / derive_pt g (- x) (Dg (- x) H0)).
now apply Hsolve.
field. apply g_not_0.
Qed.
End FirstGenHopital_left.
Section SndGenHopital.
(*
Theoreme Hopital_gpinf_Lfin_right:
a, b \in R,
Hab: a < b
Cf, Cg: f and g continue on [a; b],
Df, Dg: f and g derivable on ]a; b[
Zg: lim_{x -> a+} g = +infinity
Hlimder: lim_{x -> a+} f' / g' = L (with L \in R)
g'_not_zero: \forall x \in ]a; b[, g' (x) <> 0
-----------------------------------------------------
lim_{x -> a+} f / g = L
*)
Variables f g : R -> R.
Variables a b L : R.
Hypothesis Hab : a < b.
Hypotheses (Df : forall x, open_interval a b x -> derivable_pt f x)
(Dg : forall x, open_interval a b x -> derivable_pt g x).
Hypotheses (Cf : forall x, a <= x <= b -> continuity_pt f x)
(Cg : forall x, a <= x <= b -> continuity_pt g x).
Hypothesis (Zg : limit_div_pos g (open_interval a b) a).
Hypothesis (g'_not_0 : forall x (Hopen: open_interval a b x), derive_pt g x (Dg x Hopen) <> 0).
Hypothesis (Hlimder : forall eps, eps > 0 ->
exists alp,
alp > 0 /\
(forall x (Hopen : open_interval a b x), R_dist x a < alp ->
R_dist (derive_pt f x (Df x Hopen) / derive_pt g x (Dg x Hopen)) L < eps)).
Lemma open_lemma : forall a b c, a < b -> c > 0 -> open_interval a b (a + Rmin ((b - a) /2) c).
Proof.
intros. assert ((b0 - a0) > 0) by lra. assert ((b0-a0) /2 > 0).
apply (Rmult_gt_0_compat (/2)) in H1.
now lra.
now lra.
split.
assert (Rmin ((b0-a0) /2) c > 0).
now apply Rmin_glb_lt; assumption.
now lra.
apply Rle_lt_trans with (a0 + (b0-a0) /2).
apply Rplus_le_compat_l. now apply Rmin_l.
assert (b0 - a0 - (b0-a0) /2 > 0).
field_simplify. now lra.
lra.
Qed.
Lemma g_not_zero : exists a', open_interval a b a' /\ forall x, open_interval a a' x -> g x <> 0.
Proof.
unfold limit_div_pos in Zg. assert (1 > 0) by lra. specialize (Zg 1 H). destruct Zg as [alp [Halp H3]].
exists (a + Rmin ((b - a) / 2) (alp / 2)). assert (H6 : alp / 2 > 0) by lra.
assert ((b - a) > 0) by lra. assert ((b-a) /2 > 0).
apply (Rmult_gt_0_compat (/2)) in H0.
now lra.
now lra.
split.
unfold open_interval. split.
assert (Rmin ((b-a) /2) (alp / 2) > 0).
now apply Rmin_glb_lt; assumption.
now lra.
apply Rle_lt_trans with (a + (b-a) /2).
apply Rplus_le_compat_l. now apply Rmin_l.
assert (b - a - (b-a) /2 > 0).
field_simplify. now lra.
now lra.
intros. unfold open_interval in H0. assert (g x > 1).
apply H3.
unfold open_interval. unfold open_interval in H2. split.
now apply H2.
apply Rlt_trans with (a + Rmin ((b-a)/2) (alp /2)).
now apply H2.
apply Rle_lt_trans with (a + (b-a) /2).
apply Rplus_le_compat_l. now apply Rmin_l.
assert (b - a - (b-a) /2 > 0).
field_simplify. now lra.
now lra.
unfold R_dist. unfold open_interval in H2. destruct H2. apply Rlt_trans with (alp/2).
apply Rlt_le_trans with (Rmin ((b-a) / 2) (alp /2)).
now rewrite Rabs_right; lra.
now apply Rmin_r.
now lra.
intro. lra.
Qed.
Lemma MVT_unusable : forall a', open_interval a b a' ->
forall x y : R,
open_interval a a' x ->
open_interval a a' y ->
x < y ->
exists c : R,
exists Hopenc : open_interval a b c,
(f y - f x) * derive_pt g c (Dg c Hopenc) =
derive_pt f c (Df c Hopenc) * (g y - g x) /\
x < c < y.
Proof.
intros a' Hopennew. generalize MVT. intros. specialize (H f g x y). assert (forall c, x < c < y -> derivable_pt f c).
intros. apply Df. unfold open_interval in *. split.
now apply Rlt_trans with x ; intuition.
apply Rlt_trans with y ; intuition. now apply Rlt_trans with a'; intuition.
assert (forall c, x < c < y -> derivable_pt g c).
intros. apply Dg. unfold open_interval in *. split.
now apply Rlt_trans with x ; intuition.
apply Rlt_trans with y ; intuition. now apply Rlt_trans with a'; intuition.
specialize (H H3 H4 H2). assert (forall c : R, x <= c <= y -> continuity_pt f c).
intros. apply Cf. unfold open_interval in *. split.
now apply Rle_trans with x; intuition.
apply Rle_trans with y; intuition. now apply Rle_trans with a'; intuition.
assert (forall c : R, x <= c <= y -> continuity_pt g c).
intros. apply Cg. unfold open_interval in *. split.
now apply Rle_trans with x; intuition.
apply Rle_trans with y; intuition. now apply Rle_trans with a'; intuition.
specialize (H H5 H6). destruct H as [c [P Hold2]]. exists c. assert (Hopenc : open_interval a b c).
unfold open_interval in *. destruct P; split.
now apply Rlt_trans with x; intuition.
apply Rlt_trans with y; intuition. now apply Rlt_trans with a'; intuition.
exists Hopenc. split.
rewrite (pr_nu f c _ (H3 c P)). rewrite (pr_nu g c _ (H4 c P)). rewrite <- Hold2.
now ring.
apply P.
Qed.
Theorem Hopital_gpinf_Lfin_right : limit1_in (fun x => f x / g x) (open_interval a b) L a.
Proof.
destruct g_not_zero as [a' [H1 Ha']]. unfold limit1_in, limit_in. intros. assert (Hacc2' : forall x y, open_interval a a' x -> open_interval a a' y -> x < y ->
exists c, exists Hopenc, f x / g x = (1 - (g y / g x)) *
derive_pt f c (Df c Hopenc) / derive_pt g c (Dg c Hopenc) + (f y / g x) /\ x < c < y).
intros. assert (open_interval a b x).
split.
now apply H0.
apply Rlt_trans with a'.
now apply H0.
now apply H1.
assert (open_interval a b y).
split.
now apply H2.
apply Rlt_trans with a'.
now apply H2.
now apply H1.
generalize (MVT_unusable a' H1 x y H0 H2 H3). intros Hacc2'. destruct Hacc2' as [c [Hopenc [Hacc2' H7]]].
exists c. exists Hopenc. split; [ | now intuition]. apply (Rplus_eq_reg_l (- (f y / g x))).
ring_simplify. apply (Rmult_eq_reg_l (g x)).
apply (Rmult_eq_reg_l (derive_pt g c (Dg c Hopenc))).
apply (Rmult_eq_reg_l (-1)).
field_simplify.
field_simplify in Hacc2'. replace (derive_pt g c (Dg c Hopenc) * f y - derive_pt g c (Dg c Hopenc) * f x)
with (f y * derive_pt g c (Dg c Hopenc) - f x * derive_pt g c (Dg c Hopenc)) by ring.
rewrite Hacc2'. now field.
split.
apply Ha'. now apply H0.
now apply (g'_not_0 c Hopenc).
now apply Ha'; assumption.
intro. now lra.
now apply g'_not_0.
now apply Ha'; assumption.
assert (H0: forall eps, eps > 0 ->
exists y, open_interval a a' y /\ forall c (Hopen : open_interval a y c) (Hopenc : open_interval a b c),
R_dist (derive_pt f c (Df c Hopenc) / derive_pt g c (Dg c Hopenc)) L < eps).
intros eps0 Heps0. specialize (Hlimder eps0 Heps0). destruct Hlimder as [alp [Halp Hlimder1]].
exists (a + Rmin ((a'-a) / 2) alp). split.
apply open_lemma.
now apply H1.
now apply Halp.
intros. specialize (Hlimder1 c Hopenc). unfold R_dist in *. apply Hlimder1. destruct Hopen.
apply Rlt_le_trans with (Rmin ((a' - a) / 2) alp).
now rewrite Rabs_right; lra.
now apply Rmin_r.
assert (H15 : forall A eps, eps > 0 -> exists alp,
alp > 0 /\ forall x, open_interval a b x -> R_dist x a < alp -> Rabs (A / g x) < eps).
intros. unfold limit_div_pos in Zg. destruct (Req_dec A 0) as [eq_dec1 | eq_dec2].
subst. exists 1. intuition. unfold Rdiv. rewrite Rmult_0_l. rewrite Rabs_R0. now assumption.
specialize (Zg (Rabs A / eps0)). assert (Rabs A /eps0 > 0).
assert (Rabs A > 0).
apply Rabs_pos_lt. now assumption.
unfold Rdiv. assert (/eps0 > 0).
now apply Rinv_0_lt_compat; assumption.
now apply Rmult_lt_0_compat; assumption.
specialize (Zg H3). destruct Zg as [alp [Halp Zg3]]. exists alp. intuition. unfold Rdiv.
rewrite Rabs_mult. specialize (Zg3 x H4 H5). assert (g x > 0).
apply Rlt_trans with (Rabs A / eps0).
now assumption.
now assumption.
rewrite Rabs_Rinv.
rewrite (Rabs_right (g x)).
apply (Rmult_lt_reg_l (g x)).
now assumption.
apply (Rmult_lt_reg_l (/eps0)).
apply Rinv_0_lt_compat. now apply H2.
field_simplify.
unfold Rdiv. try rewrite Rinv_1. try rewrite Rmult_1_r. now apply Zg3.
intro. now lra.
split.
intro. now lra.
intro. now lra.
now lra.
intro. now lra.
assert (Heps4 : eps / 4 > 0) by lra. assert (bizarre : forall eps L, L >= 0 -> eps > 0 ->
exists eps1, eps1 > 0 /\ eps1 * (L + eps) < eps / 2).
intros. exists (/2 * ((eps0 / 2) * / (L0 + eps0))). split.
apply Rmult_lt_0_compat.
now lra.
apply Rmult_lt_0_compat.
now lra.
apply Rinv_0_lt_compat. now lra.
field_simplify.
now lra.
intro. now lra.
specialize (H0 (eps/4) Heps4). destruct H0 as [y [open H0]]. specialize (Hlimder eps H).
destruct Hlimder as [alp1 [Halp1 Hlim2]]. generalize (H15 (f y) (eps/4) Heps4).
intros H16. destruct H16 as [alp2 [Halp2 Hlim3]]. specialize (bizarre eps (Rabs L)).
assert (Hb1: Rabs L >= 0) by (apply Rle_ge; apply Rabs_pos). specialize (bizarre Hb1 H).
destruct bizarre as [eps1 [Heps1 HepsL4]]. specialize (H15 (g y) eps1 Heps1). destruct H15 as [alp3 [Halp3 Hlim4]].
pose (alp_alp := Rmin (Rmin alp1 alp2) alp3). pose (alp := Rmin (Rmin alp_alp (a' - a)) (y - a)).
exists alp. split.
apply Rmin_pos.
apply Rmin_pos.
apply Rmin_pos.
now apply Rmin_pos; assumption.
now assumption.
unfold open_interval in H1. destruct H1. now lra.
unfold open_interval in open. destruct open. now lra.
intros. specialize (Hacc2' x y). assert (open_interval a a' x).
unfold dist in H2. simpl in H2. unfold R_dist in H2. split.
now apply H2.
assert (Rabs (x - a) < Rabs (a' - a)).
rewrite (Rabs_right (a' - a)).
unfold alp in H2. apply Rlt_le_trans with (Rmin (Rmin alp_alp (a' - a)) (y - a)).
now intuition.
apply Rle_trans with (Rmin alp_alp (a' - a)).
now apply Rmin_l.
now apply Rmin_r.
destruct H1. now lra.
do 2 rewrite Rabs_right in H3.
now lra.