forked from AbsInt/CompCert
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ImproperRInt.v
724 lines (666 loc) · 25.8 KB
/
ImproperRInt.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
(*
This develops a definition of improper Riemann integration, in
which the limits of integration can be elements of Rbar instead of
R (i.e. can be +/- infty).
The definition starts with the integral RInt/is_RInt/ex_RInt from
Coquelicot. Then we define *upper* improper Riemann integrals
(UIRInt, is_UIRInt, ex_UIRInt) where the lower bound of integration
is a real, but the upper is allowed to be an Rbar. This is done by
taking a limit of RInt, where the limit variable is the upper bound
of the integral.
Then, we define "full" improper integrals (IRInt, is_IRInt) where
both bounds of integration can be in Rbar. This is done by taking
limits of UIRint as the *lower* bound of integration tends to an
element of Rbar.
*)
From Coq Require Import Reals Psatz ssreflect ssrbool Utf8.
From mathcomp Require Import eqtype seq.
From Coquelicot Require Import Markov Rcomplements Lub Lim_seq SF_seq Continuity Hierarchy RInt RInt_analysis Derive.
From Coquelicot Require Export Rbar.
Require Import RealsExt RIntExt.
Section Upper_IRInt.
Definition is_finite_dec (x : Rbar) : { is_finite x } + {~ is_finite x}.
Proof.
destruct x.
- left; econstructor; eauto.
- right; inversion 1.
- right; inversion 1.
Defined.
Definition is_UIRInt (f: R -> R) (a: R) (b: Rbar) (If: R) :=
(forall (t : R), Rle a t -> Rbar_lt t b -> ex_RInt f a t) /\ is_left_lim (RInt f a) b If.
Definition ex_UIRInt (f : R -> R) (a: R) (b : Rbar) :=
exists If : R, is_UIRInt f a b If.
Definition UIRInt (f: R -> R) (a : R) (b : Rbar) : R :=
real (LeftLim (RInt f a) b).
Lemma UIRInt_correct f a b :
ex_UIRInt f a b -> is_UIRInt f a b (UIRInt f a b).
Proof.
rewrite /ex_UIRInt/is_UIRInt/UIRInt.
intros (v&Hex&Hlim).
split; first done.
rewrite /UIRInt.
apply LeftLim_correct'. econstructor; eauto.
Qed.
Lemma is_UIRInt_unique f a b v :
is_UIRInt f a b v -> UIRInt f a b = v.
Proof.
rewrite /ex_UIRInt/is_UIRInt/UIRInt.
intros (Hex&His). rewrite /UIRInt.
erewrite is_left_lim_unique; eauto. simpl; done.
Qed.
Lemma Rbar_lt_interval_finite a b x :
Rbar_lt a x ->
Rbar_lt x b ->
∃ r, x = Finite r.
Proof.
destruct a, x, b => //=; eauto.
Qed.
Lemma is_UIRInt_ext (f g : R → R) (a : R) (b : Rbar) (l: R) :
Rbar_lt a b ->
(∀ x, a < x /\ Rbar_lt x b -> f x = g x) ->
is_UIRInt f a b l ->
is_UIRInt g a b l.
Proof.
intros Hlt Hext (Hex&His).
split.
{ intros. eapply ex_RInt_ext; last eapply Hex; eauto.
{ rewrite Rmin_left //. rewrite Rmax_right //. intros. apply Hext. split; first nra.
eapply (Rbar_le_lt_trans _ t); auto. simpl; nra.
}
}
eapply is_left_lim_ext_loc; last eassumption.
eapply Rbar_at_left_interval; eauto.
intros x Hlt1 Hlt2.
edestruct (Rbar_lt_interval_finite a b x) as (r&->); eauto.
eapply RInt_ext; eauto.
simpl.
simpl in Hlt1.
rewrite Rmin_left //.
rewrite Rmax_right //.
intros. apply Hext.
{ split; first nra. eapply Rbar_lt_trans; eauto. simpl. nra. }
{ nra. }
{ nra. }
Qed.
Lemma ex_UIRInt_ext (f g : R → R) (a : R) (b : Rbar) (l: R) :
Rbar_lt a b ->
(∀ x, a < x /\ Rbar_lt x b -> f x = g x) ->
ex_UIRInt f a b ->
ex_UIRInt g a b.
Proof.
intros Hlt Hext (Hex&His).
eexists. eapply is_UIRInt_ext; eauto.
Qed.
Lemma UIRInt_ext (f g : R → R) (a : R) (b : Rbar) :
Rbar_lt a b ->
(∀ x, a < x /\ Rbar_lt x b -> f x = g x) ->
UIRInt f a b = UIRInt g a b.
Proof.
intros Hlt Hext. rewrite /UIRInt.
f_equal.
apply LeftLim_ext_loc.
{ destruct b; try congruence; try inversion Hlt. }
apply (Rbar_at_left_interval a b); auto.
simpl. intros.
edestruct (Rbar_lt_interval_finite a b x) as (r&->); eauto.
eapply RInt_ext. rewrite /=. rewrite Rmin_left; last nra.
rewrite Rmax_right; last nra. intros.
symmetry. apply Hext; split; first nra.
eapply (Rbar_lt_trans x r); simpl; intuition eauto.
Qed.
Lemma is_UIRInt_upper_finite_RInt_1 f a (b: R) v :
a < b ->
is_RInt f a b v -> is_UIRInt f a b v.
Proof.
intros Hlt His. split.
* intros t Hle1 Hl2. apply: (ex_RInt_Chasles_1 _ _ _ b); eauto.
{ split; first eauto. simpl in Hl2. nra. }
{ econstructor; eauto. }
* rewrite -(is_RInt_unique _ _ _ _ His).
apply: is_RInt_upper_bound_left_lim; eauto.
Qed.
Lemma ex_UIRInt_upper_finite_RInt f a (b: R) :
a < b ->
ex_RInt f a b -> ex_UIRInt f a b.
Proof. intros ? (?&?). eexists. eapply is_UIRInt_upper_finite_RInt_1; eauto. Qed.
Lemma is_RInt_upper_finite_UIRInt f a (b: R) v :
a < b ->
ex_RInt f a b ->
is_UIRInt f a b v -> is_RInt f a b v.
Proof.
intros Hlt (v'&His) Hisu.
cut (v = v').
{ intros ->. auto. }
eapply is_UIRInt_upper_finite_RInt_1 in His; auto.
apply is_UIRInt_unique in His.
apply is_UIRInt_unique in Hisu.
congruence.
Qed.
Lemma RInt_upper_finite_UIRInt f a (b: R) :
a < b ->
ex_RInt f a b ->
RInt f a b = UIRInt f a b.
Proof.
intros. apply is_RInt_unique.
apply is_RInt_upper_finite_UIRInt; auto.
apply UIRInt_correct.
apply ex_UIRInt_upper_finite_RInt; auto.
Qed.
Lemma ex_UIRInt_Chasles_1
: ∀ f (a : R) (b c : Rbar), Rbar_lt a b ∧ Rbar_le b c → ex_UIRInt f a c → ex_UIRInt f a b.
Proof.
intros f a b c (Hle1&Hle2) Hex.
destruct (Rbar_le_lt_or_eq_dec b c) as [Hlt|Heq]; eauto; last first.
{ subst. eauto. }
destruct b as [r | |]; try (simpl in Hle1, Hlt; intuition; done).
apply ex_UIRInt_upper_finite_RInt; auto.
destruct Hex as (v&His).
destruct His as (Hex&Hlim).
apply Hex; eauto. simpl in Hle1. nra.
Qed.
Lemma ex_UIRInt_Chasles_2
: ∀ f (a b : R) (c : Rbar), Rbar_le a b ∧ Rbar_lt b c → ex_UIRInt f a c → ex_UIRInt f b c.
Proof.
intros f a b c (Hle1&Hle2) Hex.
destruct (Rbar_le_lt_or_eq_dec a b) as [Hlt|Heq]; eauto; last first.
{ inversion Heq; subst. eauto. }
destruct Hex as (v&His).
destruct His as (Hex&Hlim).
exists (v + (-RInt f a b)). split.
{ intros. apply: ex_RInt_Chasles_2; eauto. eapply Hex; eauto. simpl in Hle1. etransitivity; eauto. }
eapply (is_left_lim_ext_loc (λ x, RInt f a x + (-RInt f a b))).
{ eapply Rbar_at_left_interval; eauto. intros x Hlt1 Hlt2.
rewrite -(RInt_Chasles f a b x).
{ rewrite /plus//=. nra. }
{ eapply Hex; eauto. }
{ destruct x as [x' | |]; try (simpl in Hlt1, Hlt2; try intuition; done).
apply: ex_RInt_Chasles_2; try eapply Hex; eauto.
{ simpl in Hle1, Hlt1. split; simpl; try nra. }
simpl in Hlt, Hlt1. simpl. nra. }
}
apply is_left_lim_plus'; auto.
apply is_left_lim_const. intros ->. apply Hle2.
Qed.
Lemma is_UIRInt_scal:
∀ (f : R → R) (a : R) (b: Rbar) (k : R) (If : R),
Rbar_lt a b ->
is_UIRInt f a b If → is_UIRInt (λ y : R, scal k (f y)) a b (scal k If).
Proof.
intros f a b k If Hle (Hex&His).
split.
{ intros. apply: ex_RInt_scal; auto. }
eapply (is_left_lim_ext_loc (λ y, scal k (RInt f a y))).
{ apply (Rbar_at_left_interval a); auto.
intros x Hlt1 Hlt2.
destruct x as [x' | |]; simpl in *; try (inversion Hltt; done); try (destruct b; inversion Hlt1; done).
intros; auto. rewrite RInt_scal //. eapply Hex; eauto.
nra.
}
by apply (is_left_lim_scal_l (λ x, RInt f a x) k b If).
Qed.
Lemma ex_UIRInt_scal:
∀ (f : R → R) (a : R) (b: Rbar) (k : R),
Rbar_lt a b ->
ex_UIRInt f a b → ex_UIRInt (λ y : R, scal k (f y)) a b.
Proof.
intros f a b k Hlt (v&Hex). eexists. apply is_UIRInt_scal; eauto.
Qed.
Lemma UIRInt_scal:
∀ (f : R → R) (a : R) (b: Rbar) (k : R),
Rbar_lt a b ->
ex_UIRInt f a b ->
UIRInt (λ y : R, scal k (f y)) a b = (scal k (UIRInt f a b)).
Proof.
intros f a b k Hlt Hex.
apply is_UIRInt_unique, is_UIRInt_scal; auto.
apply UIRInt_correct; auto.
Qed.
Lemma is_UIRInt_comp (f : R → R) (g dg : R → R) (a : R) (b : Rbar) (glim : Rbar) :
Rbar_lt a b ->
(∀ (x : R), Rbar_le a x /\ Rbar_lt x b → continuous f (g x)) →
(∀ (x : R), Rbar_le a x /\ Rbar_lt x b → is_derive g x (dg x) ∧ continuous dg x) →
(* This should follow if g is is monotone locally to b *)
Rbar_at_left b (λ y : Rbar, Rbar_lt (g y) glim) ->
is_left_lim g b glim ->
ex_UIRInt f (g a) glim ->
is_UIRInt (fun y => scal (dg y) (f (g y))) a b (UIRInt f (g a) glim).
Proof.
intros Hlt Hcontinuous Hdiff Hatlt Hlim Hex.
rewrite /ex_UIRInt/is_UIRInt/UIRInt.
split.
{ intros t Hle1 Hlt2. eexists. apply: is_RInt_comp'; auto.
** intros x (Hle1'&Hl2'). apply Hcontinuous.
split; auto. simpl in Hlt2. simpl. destruct b; try eauto. nra.
** intros x. intros (Hle1'&Hl2'). apply Hdiff.
split; auto. simpl in Hlt2. simpl. destruct b; try eauto. nra.
}
eapply (is_left_lim_ext_loc (λ b, RInt f (g a) (g b))).
{
eapply Rbar_at_left_interval; eauto.
intros x Hltx1 Hltx2.
symmetry.
assert (∃ r, x = Finite r) as (r&->).
{ destruct x, b; simpl in *; try intuition; try eexists; eauto. }
simpl in Hltx1.
apply RInt_comp'; auto.
{ apply Rlt_le. auto. }
** intros y (Hle1'&Hl2'). apply Hcontinuous.
split; auto. eapply Rbar_le_lt_trans; eauto. simpl in *; eauto.
** intros y (Hle1'&Hl2'). apply Hdiff.
split; auto. eapply Rbar_le_lt_trans; eauto. simpl in *; eauto.
}
apply UIRInt_correct in Hex.
destruct Hex as (?&Hlim').
eapply (is_left_lim_comp (λ x, RInt f (g a) x) g b); eauto.
Qed.
Lemma is_UIRInt_comp_noncont (f : R → R) (g dg : R → R) (a : R) (b : Rbar) (glim : Rbar) :
Rbar_lt a b ->
(forall (x y : R), Rbar_le a x /\ x <= y /\ Rbar_lt y b -> g x <= g y) ->
(∀ (x : R), Rbar_le a x /\ Rbar_lt x b → is_derive g x (dg x) ∧ continuous dg x) →
(* This should follow if g is is monotone locally to b *)
Rbar_at_left b (λ y : Rbar, Rbar_lt (g y) glim) ->
is_left_lim g b glim ->
ex_UIRInt f (g a) glim ->
is_UIRInt (fun y => scal (dg y) (f (g y))) a b (UIRInt f (g a) glim).
Proof.
intros Hlt Hmono Hdiff Hatlt Hlim Hex.
rewrite /ex_UIRInt/is_UIRInt/UIRInt.
assert (Hltlim: ∀ r, a <= r -> Rbar_lt r b -> Rbar_lt (g r) glim).
{
intros t Hlt1 Hlt2.
destruct b as [r' | |]; try (simpl in Hlt2; intuition).
* edestruct (Rbar_at_left_witness_above r' t) as (z&Hz1&Hz2); eauto.
eapply Rbar_le_lt_trans; last eapply Hz2.
apply Hmono; simpl. nra.
* edestruct (Rbar_at_left_witness_above_p_infty t) as (z&Hz1&Hz2); eauto.
eapply Rbar_le_lt_trans; last eapply Hz2.
apply Hmono; simpl. nra.
}
split.
{ intros t Hle1 Hlt2. eexists. apply: is_RInt_comp_noncont; auto.
** rewrite /ex_UIRInt in Hex. destruct Hex as (?&(Hex&?)). eapply Hex; eauto.
{ apply Hmono. split; auto. reflexivity. }
** intros x y. rewrite Rmin_left // Rmax_right //. intros. apply Hmono; try nra.
simpl in Hlt2. intuition; simpl; try nra. destruct b; try eauto; try nra.
** intros x. rewrite Rmin_left // Rmax_right //. intros. apply Hdiff; try nra.
split; first by (simpl; nra). simpl in Hlt2. simpl. destruct b; try intuition; nra.
}
eapply (is_left_lim_ext_loc (λ b, RInt f (g a) (g b))).
{
eapply Rbar_at_left_interval; eauto.
intros x Hltx1 Hltx2.
symmetry.
assert (∃ r, x = Finite r) as (r&->).
{ destruct x, b; simpl in *; try intuition; try eexists; eauto. }
simpl in Hltx1.
apply RInt_comp'_noncont; auto.
{ apply Rlt_le. auto. }
** rewrite /ex_UIRInt in Hex. destruct Hex as (?&(Hex&?)). eapply Hex; eauto.
{ apply Hmono. split; auto. reflexivity. split; auto. clear -Hltx1. left. auto. }
** eapply Hltlim; eauto. left; auto.
** intros x y ?. apply Hmono; try nra.
intuition; try done. eapply Rbar_le_lt_trans; eauto. simpl. auto.
** intros y (Hle1'&Hl2'). apply Hdiff.
split; auto. eapply Rbar_le_lt_trans; eauto. simpl in *; eauto.
}
apply UIRInt_correct in Hex.
destruct Hex as (?&Hlim').
eapply (is_left_lim_comp (λ x, RInt f (g a) x) g b); eauto.
Qed.
Lemma UIRInt_comp_noncont (f : R → R) (g dg : R → R) (a : R) (b : Rbar) (glim : Rbar) :
Rbar_lt a b ->
(forall (x y : R), Rbar_le a x /\ x <= y /\ Rbar_lt y b -> g x <= g y) ->
(∀ (x : R), Rbar_le a x /\ Rbar_lt x b → is_derive g x (dg x) ∧ continuous dg x) →
(* This should follow if g is is monotone locally to b *)
Rbar_at_left b (λ y : Rbar, Rbar_lt (g y) glim) ->
is_left_lim g b glim ->
ex_UIRInt f (g a) glim ->
UIRInt (fun y => scal (dg y) (f (g y))) a b = UIRInt f (g a) glim.
Proof.
intros. apply is_UIRInt_unique, is_UIRInt_comp_noncont; eauto.
Qed.
Lemma UIRInt_comp (f : R → R) (g dg : R → R) (a : R) (b : Rbar) (glim : Rbar) :
Rbar_lt a b ->
(∀ (x : R), Rbar_le a x /\ Rbar_lt x b → continuous f (g x)) →
(∀ (x : R), Rbar_le a x /\ Rbar_lt x b → is_derive g x (dg x) ∧ continuous dg x) →
(* This should follow if g is is monotone locally to b *)
Rbar_at_left b (λ y : Rbar, Rbar_lt (g y) glim) ->
is_left_lim g b glim ->
ex_UIRInt f (g a) glim ->
UIRInt (fun y => scal (dg y) (f (g y))) a b = UIRInt f (g a) glim.
Proof.
intros. apply is_UIRInt_unique, is_UIRInt_comp; eauto.
Qed.
Lemma is_UIRInt_lower_bound_right_lim : ∀ (a b : R) (f : R → R) (v : R),
a < b → is_UIRInt f a b v → is_right_lim (λ x, UIRInt f x b) a (UIRInt f a b).
Proof.
Abort.
End Upper_IRInt.
Section IRInt.
Definition is_IRInt (f: R -> R) (a: Rbar) (b: Rbar) (If: R) :=
(forall (t : R), Rbar_lt a t -> Rbar_lt t b -> ex_UIRInt f t b) /\ is_right_lim (λ x, UIRInt f x b) a If.
Definition ex_IRInt (f : R -> R) (a: Rbar) (b : Rbar) :=
exists If : R, is_IRInt f a b If.
Definition IRInt (f: R -> R) (a : Rbar) (b : Rbar) : R :=
real (RightLim (λ x, UIRInt f x b) a).
Lemma IRInt_correct f a b :
ex_IRInt f a b -> is_IRInt f a b (IRInt f a b).
Proof.
rewrite /ex_IRInt/is_IRInt/IRInt.
intros (v&Hex&Hlim).
split; first done.
apply RightLim_correct'. econstructor; eauto.
Qed.
Lemma is_IRInt_unique f a b v :
is_IRInt f a b v -> IRInt f a b = v.
Proof.
rewrite /ex_IRInt/is_IRInt/IRInt.
intros (Hex&His).
erewrite is_right_lim_unique; eauto. simpl; done.
Qed.
Lemma is_IRInt_ext (f g : R → R) (a : Rbar) (b : Rbar) (l: R) :
Rbar_lt a b ->
(∀ x : R, Rbar_lt a x /\ Rbar_lt x b -> f x = g x) ->
is_IRInt f a b l ->
is_IRInt g a b l.
Proof.
intros Hlt Hext (Hex&His).
split.
{ intros. eapply ex_UIRInt_ext; last eapply Hex; eauto.
{ intros. apply Hext. split; intuition auto.
eapply (Rbar_lt_trans _ t); auto. }
}
eapply is_right_lim_ext_loc; last eassumption.
eapply Rbar_at_right_interval; eauto.
intros x Hlt1 Hlt2.
edestruct (Rbar_lt_interval_finite a b x) as (r&->); eauto.
eapply UIRInt_ext; eauto.
simpl in Hlt1.
intros. apply Hext.
{ split; intuition auto. eapply Rbar_lt_trans; eauto. }
Qed.
Lemma ex_IRInt_ext (f g : R → R) (a : Rbar) (b : Rbar) (l: R) :
Rbar_lt a b ->
(∀ x : R, Rbar_lt a x /\ Rbar_lt x b -> f x = g x) ->
ex_IRInt f a b ->
ex_IRInt g a b.
Proof.
intros Hlt Hext (Hex&His).
eexists. eapply is_IRInt_ext; try eassumption.
Qed.
Lemma IRInt_ext (f g : R → R) (a : Rbar) (b : Rbar) :
Rbar_lt a b ->
(∀ x : R, Rbar_lt a x /\ Rbar_lt x b -> f x = g x) ->
IRInt f a b = IRInt g a b.
Proof.
intros Hlt Hext. rewrite /IRInt.
f_equal.
apply RightLim_ext_loc.
{ destruct a; try congruence; try inversion Hlt. }
apply (Rbar_at_right_interval a b); auto.
simpl. intros.
edestruct (Rbar_lt_interval_finite a b x) as (r&->); eauto.
eapply UIRInt_ext; auto. intros.
symmetry. eapply Hext; split.
{ eapply (Rbar_lt_trans a r x); intuition. }
{ intuition. }
Qed.
Lemma is_IRInt_finite_RInt_1 f (a b : R) v :
Rbar_lt a b ->
is_RInt f a b v -> is_IRInt f a b v.
Proof.
intros Hlt His. split.
* intros t Hle1 Hl2.
apply: (ex_UIRInt_Chasles_1 _ _ b).
{ split; first eauto. reflexivity. }
{ eapply (ex_UIRInt_Chasles_2 f a); eauto.
{ split; auto. apply Rbar_lt_le. auto. }
eapply ex_UIRInt_upper_finite_RInt; eauto.
eexists; eauto. }
* rewrite -(is_RInt_unique _ _ _ _ His).
eapply is_right_lim_ext_loc; last eapply is_RInt_lower_bound_right_lim; eauto.
eapply Rbar_at_right_interval; eauto.
unfold Rbar_lt. intros [r| |]; simpl; try intuition. eapply RInt_upper_finite_UIRInt; eauto.
eapply ex_RInt_Chasles_2; last by (eexists; eauto).
nra.
Qed.
Lemma is_RInt_finite_IRInt f a (b: R) v :
a < b ->
ex_RInt f a b ->
is_IRInt f a b v -> is_RInt f a b v.
Proof.
intros Hlt (v'&His) Hisu.
cut (v = v').
{ intros ->. auto. }
eapply is_IRInt_finite_RInt_1 in His; auto.
apply is_IRInt_unique in His.
apply is_IRInt_unique in Hisu.
congruence.
Qed.
Lemma is_IRInt_scal:
∀ (f : R → R) (a : Rbar) (b: Rbar) (k : R) (If : R),
Rbar_lt a b ->
is_IRInt f a b If → is_IRInt (λ y : R, scal k (f y)) a b (scal k If).
Proof.
intros f a b k If Hle (Hex&His).
split.
{ intros. apply: ex_UIRInt_scal; auto. }
eapply (is_right_lim_ext_loc (λ y, scal k (UIRInt f y b))).
{
edestruct (Rbar_interval_inhabited) as (y&?&?); eauto.
apply (Rbar_at_right_interval a y); auto.
intros x Hlt1 Hlt2.
assert (∃ r', x = Finite r') as (x'&->).
{ destruct x; eauto. inversion Hlt2. destruct a; inversion Hlt1. }
intros; auto. rewrite UIRInt_scal //; eauto.
{ eapply Rbar_lt_trans; eauto. }
{ eapply Hex; eauto. eapply Rbar_lt_trans; eauto. }
}
by apply (is_right_lim_scal_l (λ x, UIRInt f x b) k a If).
Qed.
Lemma ex_IRInt_scal:
∀ (f : R → R) (a : Rbar) (b: Rbar) (k : R),
Rbar_lt a b ->
ex_IRInt f a b → ex_IRInt (λ y : R, scal k (f y)) a b.
Proof.
intros f a b k Hlt (v&Hex). eexists. apply is_IRInt_scal; eauto.
Qed.
Lemma IRInt_scal:
∀ (f : R → R) (a : Rbar) (b: Rbar) (k : R),
Rbar_lt a b ->
ex_IRInt f a b ->
IRInt (λ y : R, scal k (f y)) a b = (scal k (IRInt f a b)).
Proof.
intros f a b k Hlt Hex.
apply is_IRInt_unique, is_IRInt_scal; auto.
apply IRInt_correct; auto.
Qed.
Lemma is_IRInt_comp (f : R → R) (g dg : R → R) (a b : Rbar) (gla glb : Rbar) :
Rbar_lt a b ->
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → Rbar_lt gla (g x) /\ Rbar_lt (g x) glb) →
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → continuous f (g x)) →
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → is_derive g x (dg x) ∧ continuous dg x) →
(* This should follow if g is is monotone locally to a and b *)
Rbar_at_right a (λ y : Rbar, Rbar_lt gla (g y)) ->
Rbar_at_left b (λ y : Rbar, Rbar_lt (g y) glb) ->
is_right_lim g a gla ->
is_left_lim g b glb ->
ex_IRInt f gla glb ->
is_IRInt (fun y => scal (dg y) (f (g y))) a b (IRInt f gla glb).
Proof.
intros Hlt Hgrange Hcontinuous Hdiff Hata Hatb Hlima Hlimb Hex.
rewrite /ex_IRInt/is_IRInt/IRInt.
split.
{ intros t Hlt1 Hlt2. eexists. apply: is_UIRInt_comp; eauto.
** intros x (Hle1'&Hlt2'). apply Hcontinuous.
split; auto. eapply Rbar_lt_le_trans; eauto.
** intros x. intros (Hle1'&Hlt2'). apply Hdiff.
split; auto. eapply Rbar_lt_le_trans; eauto.
** destruct Hex as (?&Hex'&?). eapply Hex'; eauto; eapply Hgrange; eauto.
}
eapply (is_right_lim_ext_loc (λ r, UIRInt f (g r) glb)).
{
eapply Rbar_at_right_interval; eauto.
intros x Hltx1 Hltx2.
symmetry.
assert (∃ r, x = Finite r) as (r&->).
{ destruct x, a, b; simpl in *; try intuition; try eexists; eauto. }
erewrite UIRInt_comp; eauto.
** intros y (Hle1'&Hl2'). apply Hcontinuous.
split; auto. eapply Rbar_lt_le_trans; eauto.
** intros y (Hle1'&Hl2'). apply Hdiff.
split; auto. eapply Rbar_lt_le_trans; eauto.
** destruct Hex as (?&Hex'&?). eapply Hex'; eauto; eapply Hgrange; eauto.
}
apply IRInt_correct in Hex.
destruct Hex as (?&Hlim').
eapply (is_right_lim_comp (λ x, UIRInt f x glb) g a); eauto.
Qed.
Lemma is_IRInt_comp_noncont (f : R → R) (g dg : R → R) (a b : Rbar) (gla glb : Rbar) :
Rbar_lt a b ->
(∀ (x y : R), Rbar_lt a x /\ x <= y /\ Rbar_lt y b -> g x <= g y) ->
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → Rbar_lt gla (g x) /\ Rbar_lt (g x) glb) →
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → is_derive g x (dg x) ∧ continuous dg x) →
(* This should follow if g is is monotone locally to a and b *)
Rbar_at_right a (λ y : Rbar, Rbar_lt gla (g y)) ->
Rbar_at_left b (λ y : Rbar, Rbar_lt (g y) glb) ->
is_right_lim g a gla ->
is_left_lim g b glb ->
ex_IRInt f gla glb ->
is_IRInt (fun y => scal (dg y) (f (g y))) a b (IRInt f gla glb).
Proof.
intros Hlt Hmono Hgrange Hdiff Hata Hatb Hlima Hlimb Hex.
rewrite /ex_IRInt/is_IRInt/IRInt.
split.
{ intros t Hlt1 Hlt2. eexists. apply: is_UIRInt_comp_noncont; eauto.
** intros x y (Hle1'&Hle2'&Hlt3'). apply Hmono.
split; auto. eapply Rbar_lt_le_trans; eauto.
** intros x. intros (Hle1'&Hlt2'). apply Hdiff.
split; auto. eapply Rbar_lt_le_trans; eauto.
** destruct Hex as (?&Hex'&?). eapply Hex'; eauto; eapply Hgrange; eauto.
}
eapply (is_right_lim_ext_loc (λ r, UIRInt f (g r) glb)).
{
eapply Rbar_at_right_interval; eauto.
intros x Hltx1 Hltx2.
symmetry.
assert (∃ r, x = Finite r) as (r&->).
{ destruct x, a, b; simpl in *; try intuition; try eexists; eauto. }
erewrite UIRInt_comp_noncont; eauto.
** intros x y (Hle1'&Hle2'&Hlt3'). apply Hmono.
split; auto. eapply Rbar_lt_le_trans; eauto.
** intros y (Hle1'&Hl2'). apply Hdiff.
split; auto. eapply Rbar_lt_le_trans; eauto.
** destruct Hex as (?&Hex'&?). eapply Hex'; eauto; eapply Hgrange; eauto.
}
apply IRInt_correct in Hex.
destruct Hex as (?&Hlim').
eapply (is_right_lim_comp (λ x, UIRInt f x glb) g a); eauto.
Qed.
Lemma is_IRInt_comp_noncont_strict (f : R → R) (g dg : R → R) (a b : Rbar) (gla glb : Rbar) :
Rbar_lt a b ->
(∀ (x y : R), Rbar_lt a x /\ x < y /\ Rbar_lt y b -> g x < g y) ->
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → Rbar_lt gla (g x) /\ Rbar_lt (g x) glb) →
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → is_derive g x (dg x) ∧ continuous dg x) →
is_right_lim g a gla ->
is_left_lim g b glb ->
ex_IRInt f gla glb ->
is_IRInt (fun y => scal (dg y) (f (g y))) a b (IRInt f gla glb).
Proof.
intros Hlt Hmono Hgrange Hdiff Hlima Hlimb Hex.
assert (Hatb: Rbar_at_left b (λ y : Rbar, Rbar_lt (g y) glb)).
{ eapply Rbar_at_left_strict_monotone'; eauto.
intros. eapply Hmono; intuition; eauto.
}
assert (Hata: Rbar_at_right a (λ y : Rbar, Rbar_lt gla (g y))).
{ eapply Rbar_at_right_strict_monotone'; eauto.
}
eapply is_IRInt_comp_noncont; eauto. intros.
destruct (Req_EM_T x y).
{ subst. reflexivity. }
left. apply Hmono.
intuition. nra.
Qed.
Lemma IRInt_comp (f : R → R) (g dg : R → R) (a b : Rbar) (gla glb : Rbar) :
Rbar_lt a b ->
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → Rbar_lt gla (g x) /\ Rbar_lt (g x) glb) →
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → continuous f (g x)) →
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → is_derive g x (dg x) ∧ continuous dg x) →
(* This should follow if g is is monotone locally to a and b *)
Rbar_at_right a (λ y : Rbar, Rbar_lt gla (g y)) ->
Rbar_at_left b (λ y : Rbar, Rbar_lt (g y) glb) ->
is_right_lim g a gla ->
is_left_lim g b glb ->
ex_IRInt f gla glb ->
IRInt (fun y => scal (dg y) (f (g y))) a b = (IRInt f gla glb).
Proof.
intros. apply is_IRInt_unique, is_IRInt_comp; eauto.
Qed.
Lemma IRInt_comp_noncont (f : R → R) (g dg : R → R) (a b : Rbar) (gla glb : Rbar) :
Rbar_lt a b ->
(∀ (x y : R), Rbar_lt a x /\ x <= y /\ Rbar_lt y b -> g x <= g y) ->
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → Rbar_lt gla (g x) /\ Rbar_lt (g x) glb) →
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → is_derive g x (dg x) ∧ continuous dg x) →
(* This should follow if g is is monotone locally to a and b *)
Rbar_at_right a (λ y : Rbar, Rbar_lt gla (g y)) ->
Rbar_at_left b (λ y : Rbar, Rbar_lt (g y) glb) ->
is_right_lim g a gla ->
is_left_lim g b glb ->
ex_IRInt f gla glb ->
IRInt (fun y => scal (dg y) (f (g y))) a b = (IRInt f gla glb).
Proof.
intros. apply is_IRInt_unique, is_IRInt_comp_noncont; eauto.
Qed.
Lemma IRInt_comp_noncont_strict (f : R → R) (g dg : R → R) (a b : Rbar) (gla glb : Rbar) :
Rbar_lt a b ->
(∀ (x y : R), Rbar_lt a x /\ x < y /\ Rbar_lt y b -> g x < g y) ->
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → Rbar_lt gla (g x) /\ Rbar_lt (g x) glb) →
(∀ (x : R), Rbar_lt a x /\ Rbar_lt x b → is_derive g x (dg x) ∧ continuous dg x) →
is_right_lim g a gla ->
is_left_lim g b glb ->
ex_IRInt f gla glb ->
IRInt (fun y => scal (dg y) (f (g y))) a b = (IRInt f gla glb).
Proof.
intros. apply is_IRInt_unique, is_IRInt_comp_noncont_strict; eauto.
Qed.
End IRInt.
Require Import Coquelicot.AutoDerive.
Lemma LowerBound_reparam_lb_right_lim a : is_right_lim (λ y : R, exp y + a) m_infty a.
Proof.
replace a with (0 + a) at 1; last nra.
apply (is_right_lim_plus' exp (λ _, a)).
* apply is_lim_right_lim; first congruence.
apply ElemFct.is_lim_exp_m.
* apply is_right_lim_const; congruence.
Qed.
Lemma LowerBound_reparam_ub_left_lim a : is_left_lim (λ y : R, exp y + a) p_infty p_infty.
Proof.
apply (is_left_lim_plus exp (λ _, a) p_infty p_infty a p_infty).
{ apply is_lim_left_lim; first congruence.
apply ElemFct.is_lim_exp_p. }
{ apply is_left_lim_const; congruence. }
constructor.
Qed.
Lemma LowerBounded_reparam_full f a :
(∀ (x : R), a < x → continuous f x) →
ex_IRInt f a p_infty ->
is_IRInt (fun y => exp y * f (exp(y) + a)) m_infty p_infty (IRInt f a p_infty).
Proof.
intros Hcont Hex.
apply (is_IRInt_comp f (λ x, exp x + a) exp); try (done).
- intros x Hrange0. simpl. split; auto. cut (0 < exp x); first nra. apply exp_pos.
- intros x Hrange0. simpl. apply Hcont. cut (0 < exp x); first nra. apply exp_pos.
- intros x Hrange0. split.
{ auto_derive; auto; nra. }
{ apply ElemFct.continuous_exp. }
- apply (Rbar_at_right_strict_monotone a m_infty (λ y, exp y + a)); try done.
{ intros x y (?&?) Hltm. cut (exp x < exp y); first by nra.
by apply exp_increasing. }
apply LowerBound_reparam_lb_right_lim.
- apply (Rbar_at_left_strict_monotone a p_infty (λ y, exp y + a)); try done.
{ intros x y (?&?) Hltm. cut (exp x < exp y); first by nra.
by apply exp_increasing. }
apply LowerBound_reparam_ub_left_lim.
- apply LowerBound_reparam_lb_right_lim.
- apply LowerBound_reparam_ub_left_lim.
Qed.