6 |
6 |
7 theory Extended_Reals |
7 theory Extended_Reals |
8 imports Topology_Euclidean_Space |
8 imports Topology_Euclidean_Space |
9 begin |
9 begin |
10 |
10 |
|
11 lemma (in complete_lattice) atLeast_eq_UNIV_iff: "{x..} = UNIV \<longleftrightarrow> x = bot" |
|
12 proof |
|
13 assume "{x..} = UNIV" |
|
14 show "x = bot" |
|
15 proof (rule ccontr) |
|
16 assume "x \<noteq> bot" then have "bot \<notin> {x..}" by (simp add: le_less) |
|
17 then show False using `{x..} = UNIV` by simp |
|
18 qed |
|
19 qed auto |
|
20 |
|
21 lemma SUPR_pair: |
|
22 "(SUP i : A. SUP j : B. f i j) = (SUP p : A \<times> B. f (fst p) (snd p))" |
|
23 by (rule antisym) (auto intro!: SUP_leI le_SUPI_trans) |
|
24 |
|
25 lemma INFI_pair: |
|
26 "(INF i : A. INF j : B. f i j) = (INF p : A \<times> B. f (fst p) (snd p))" |
|
27 by (rule antisym) (auto intro!: le_INFI INF_leI_trans) |
|
28 |
11 subsection {* Definition and basic properties *} |
29 subsection {* Definition and basic properties *} |
12 |
30 |
13 datatype extreal = extreal real | PInfty | MInfty |
31 datatype extreal = extreal real | PInfty | MInfty |
14 |
32 |
15 notation (xsymbols) |
33 notation (xsymbols) |
16 PInfty ("\<infinity>") |
34 PInfty ("\<infinity>") |
17 |
35 |
18 notation (HTML output) |
36 notation (HTML output) |
19 PInfty ("\<infinity>") |
37 PInfty ("\<infinity>") |
|
38 |
|
39 declare [[coercion "extreal :: real \<Rightarrow> extreal"]] |
20 |
40 |
21 instantiation extreal :: uminus |
41 instantiation extreal :: uminus |
22 begin |
42 begin |
23 fun uminus_extreal where |
43 fun uminus_extreal where |
24 "- (extreal r) = extreal (- r)" |
44 "- (extreal r) = extreal (- r)" |
338 lemma extreal_dense2: |
382 lemma extreal_dense2: |
339 fixes x y :: extreal assumes "x < y" |
383 fixes x y :: extreal assumes "x < y" |
340 shows "EX z. x < extreal z & extreal z < y" |
384 shows "EX z. x < extreal z & extreal z < y" |
341 by (metis extreal_dense[OF `x < y`] extreal_cases less_extreal.simps(2,3)) |
385 by (metis extreal_dense[OF `x < y`] extreal_cases less_extreal.simps(2,3)) |
342 |
386 |
|
387 lemma extreal_add_strict_mono: |
|
388 fixes a b c d :: extreal |
|
389 assumes "a = b" "0 \<le> a" "a \<noteq> \<infinity>" "c < d" |
|
390 shows "a + c < b + d" |
|
391 using assms by (cases rule: extreal3_cases[case_product extreal_cases, of a b c d]) auto |
|
392 |
|
393 lemma extreal_less_add: "\<bar>a\<bar> \<noteq> \<infinity> \<Longrightarrow> c < b \<Longrightarrow> a + c < a + b" |
|
394 by (cases rule: extreal2_cases[of b c]) auto |
|
395 |
|
396 lemma extreal_uminus_eq_reorder: "- a = b \<longleftrightarrow> a = (-b::extreal)" by auto |
|
397 |
|
398 lemma extreal_uminus_less_reorder: "- a < b \<longleftrightarrow> -b < (a::extreal)" |
|
399 by (subst (3) extreal_uminus_uminus[symmetric]) (simp only: extreal_minus_less_minus) |
|
400 |
|
401 lemma extreal_uminus_le_reorder: "- a \<le> b \<longleftrightarrow> -b \<le> (a::extreal)" |
|
402 by (subst (3) extreal_uminus_uminus[symmetric]) (simp only: extreal_minus_le_minus) |
|
403 |
|
404 lemmas extreal_uminus_reorder = |
|
405 extreal_uminus_eq_reorder extreal_uminus_less_reorder extreal_uminus_le_reorder |
|
406 |
|
407 lemma extreal_bot: |
|
408 fixes x :: extreal assumes "\<And>B. x \<le> extreal B" shows "x = - \<infinity>" |
|
409 proof (cases x) |
|
410 case (real r) with assms[of "r - 1"] show ?thesis by auto |
|
411 next case PInf with assms[of 0] show ?thesis by auto |
|
412 next case MInf then show ?thesis by simp |
|
413 qed |
|
414 |
|
415 lemma extreal_top: |
|
416 fixes x :: extreal assumes "\<And>B. x \<ge> extreal B" shows "x = \<infinity>" |
|
417 proof (cases x) |
|
418 case (real r) with assms[of "r + 1"] show ?thesis by auto |
|
419 next case MInf with assms[of 0] show ?thesis by auto |
|
420 next case PInf then show ?thesis by simp |
|
421 qed |
|
422 |
|
423 lemma |
|
424 shows extreal_max[simp]: "extreal (max x y) = max (extreal x) (extreal y)" |
|
425 and extreal_min[simp]: "extreal (min x y) = min (extreal x) (extreal y)" |
|
426 by (simp_all add: min_def max_def) |
|
427 |
|
428 lemma extreal_max_0: "max 0 (extreal r) = extreal (max 0 r)" |
|
429 by (auto simp: zero_extreal_def) |
|
430 |
343 lemma |
431 lemma |
344 fixes f :: "nat \<Rightarrow> extreal" |
432 fixes f :: "nat \<Rightarrow> extreal" |
345 shows incseq_uminus[simp]: "incseq (\<lambda>x. - f x) \<longleftrightarrow> decseq f" |
433 shows incseq_uminus[simp]: "incseq (\<lambda>x. - f x) \<longleftrightarrow> decseq f" |
346 and decseq_uminus[simp]: "decseq (\<lambda>x. - f x) \<longleftrightarrow> incseq f" |
434 and decseq_uminus[simp]: "decseq (\<lambda>x. - f x) \<longleftrightarrow> incseq f" |
347 unfolding decseq_def incseq_def by auto |
435 unfolding decseq_def incseq_def by auto |
348 |
436 |
349 lemma incseqD: "\<And>i j. incseq f \<Longrightarrow> i \<le> j \<Longrightarrow> f i \<le> f j" |
|
350 by (auto simp: incseq_def) |
|
351 |
|
352 lemma extreal_add_nonneg_nonneg: |
437 lemma extreal_add_nonneg_nonneg: |
353 fixes a b :: extreal shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a + b" |
438 fixes a b :: extreal shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a + b" |
354 using add_mono[of 0 a 0 b] by simp |
439 using add_mono[of 0 a 0 b] by simp |
355 |
440 |
356 lemma image_eqD: "f ` A = B \<Longrightarrow> (\<forall>x\<in>A. f x \<in> B)" |
441 lemma image_eqD: "f ` A = B \<Longrightarrow> (\<forall>x\<in>A. f x \<in> B)" |
357 by auto |
442 by auto |
358 |
443 |
359 lemma incseq_setsumI: |
444 lemma incseq_setsumI: |
360 fixes f :: "nat \<Rightarrow> extreal" |
445 fixes f :: "nat \<Rightarrow> 'a::{comm_monoid_add, ordered_ab_semigroup_add}" |
361 assumes "\<And>i. 0 \<le> f i" |
446 assumes "\<And>i. 0 \<le> f i" |
362 shows "incseq (\<lambda>i. setsum f {..< i})" |
447 shows "incseq (\<lambda>i. setsum f {..< i})" |
363 proof (intro incseq_SucI) |
448 proof (intro incseq_SucI) |
364 fix n have "setsum f {..< n} + 0 \<le> setsum f {..<n} + f n" |
449 fix n have "setsum f {..< n} + 0 \<le> setsum f {..<n} + f n" |
365 using assms by (rule add_left_mono) |
450 using assms by (rule add_left_mono) |
366 then show "setsum f {..< n} \<le> setsum f {..< Suc n}" |
451 then show "setsum f {..< n} \<le> setsum f {..< Suc n}" |
367 by auto |
452 by auto |
368 qed |
453 qed |
|
454 |
|
455 lemma incseq_setsumI2: |
|
456 fixes f :: "'i \<Rightarrow> nat \<Rightarrow> 'a::{comm_monoid_add, ordered_ab_semigroup_add}" |
|
457 assumes "\<And>n. n \<in> A \<Longrightarrow> incseq (f n)" |
|
458 shows "incseq (\<lambda>i. \<Sum>n\<in>A. f n i)" |
|
459 using assms unfolding incseq_def by (auto intro: setsum_mono) |
369 |
460 |
370 subsubsection "Multiplication" |
461 subsubsection "Multiplication" |
371 |
462 |
372 instantiation extreal :: "{comm_monoid_mult, sgn}" |
463 instantiation extreal :: "{comm_monoid_mult, sgn}" |
373 begin |
464 begin |
502 using extreal_mult_right_mono by (simp add: mult_commute[of c]) |
593 using extreal_mult_right_mono by (simp add: mult_commute[of c]) |
503 |
594 |
504 lemma zero_less_one_extreal[simp]: "0 \<le> (1::extreal)" |
595 lemma zero_less_one_extreal[simp]: "0 \<le> (1::extreal)" |
505 by (simp add: one_extreal_def zero_extreal_def) |
596 by (simp add: one_extreal_def zero_extreal_def) |
506 |
597 |
507 lemma extreal_distrib_right: |
598 lemma extreal_0_le_mult[simp]: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a * (b :: extreal)" |
|
599 by (cases rule: extreal2_cases[of a b]) (auto simp: mult_nonneg_nonneg) |
|
600 |
|
601 lemma extreal_right_distrib: |
|
602 fixes r a b :: extreal shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> r * (a + b) = r * a + r * b" |
|
603 by (cases rule: extreal3_cases[of r a b]) (simp_all add: field_simps) |
|
604 |
|
605 lemma extreal_left_distrib: |
|
606 fixes r a b :: extreal shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> (a + b) * r = a * r + b * r" |
|
607 by (cases rule: extreal3_cases[of r a b]) (simp_all add: field_simps) |
|
608 |
|
609 lemma extreal_mult_le_0_iff: |
|
610 fixes a b :: extreal |
|
611 shows "a * b \<le> 0 \<longleftrightarrow> (0 \<le> a \<and> b \<le> 0) \<or> (a \<le> 0 \<and> 0 \<le> b)" |
|
612 by (cases rule: extreal2_cases[of a b]) (simp_all add: mult_le_0_iff) |
|
613 |
|
614 lemma extreal_zero_le_0_iff: |
|
615 fixes a b :: extreal |
|
616 shows "0 \<le> a * b \<longleftrightarrow> (0 \<le> a \<and> 0 \<le> b) \<or> (a \<le> 0 \<and> b \<le> 0)" |
|
617 by (cases rule: extreal2_cases[of a b]) (simp_all add: zero_le_mult_iff) |
|
618 |
|
619 lemma extreal_mult_less_0_iff: |
|
620 fixes a b :: extreal |
|
621 shows "a * b < 0 \<longleftrightarrow> (0 < a \<and> b < 0) \<or> (a < 0 \<and> 0 < b)" |
|
622 by (cases rule: extreal2_cases[of a b]) (simp_all add: mult_less_0_iff) |
|
623 |
|
624 lemma extreal_zero_less_0_iff: |
|
625 fixes a b :: extreal |
|
626 shows "0 < a * b \<longleftrightarrow> (0 < a \<and> 0 < b) \<or> (a < 0 \<and> b < 0)" |
|
627 by (cases rule: extreal2_cases[of a b]) (simp_all add: zero_less_mult_iff) |
|
628 |
|
629 lemma extreal_distrib: |
508 fixes a b c :: extreal |
630 fixes a b c :: extreal |
509 shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> c * (a + b) = c * a + c * b" |
631 assumes "a \<noteq> \<infinity> \<or> b \<noteq> -\<infinity>" "a \<noteq> -\<infinity> \<or> b \<noteq> \<infinity>" "\<bar>c\<bar> \<noteq> \<infinity>" |
510 by (cases rule: extreal3_cases[of a b c]) |
632 shows "(a + b) * c = a * c + b * c" |
511 (simp_all add: field_simps) |
633 using assms |
|
634 by (cases rule: extreal3_cases[of a b c]) (simp_all add: field_simps) |
|
635 |
|
636 lemma extreal_le_epsilon: |
|
637 fixes x y :: extreal |
|
638 assumes "ALL e. 0 < e --> x <= y + e" |
|
639 shows "x <= y" |
|
640 proof- |
|
641 { assume a: "EX r. y = extreal r" |
|
642 from this obtain r where r_def: "y = extreal r" by auto |
|
643 { assume "x=(-\<infinity>)" hence ?thesis by auto } |
|
644 moreover |
|
645 { assume "~(x=(-\<infinity>))" |
|
646 from this obtain p where p_def: "x = extreal p" |
|
647 using a assms[rule_format, of 1] by (cases x) auto |
|
648 { fix e have "0 < e --> p <= r + e" |
|
649 using assms[rule_format, of "extreal e"] p_def r_def by auto } |
|
650 hence "p <= r" apply (subst field_le_epsilon) by auto |
|
651 hence ?thesis using r_def p_def by auto |
|
652 } ultimately have ?thesis by blast |
|
653 } |
|
654 moreover |
|
655 { assume "y=(-\<infinity>) | y=\<infinity>" hence ?thesis |
|
656 using assms[rule_format, of 1] by (cases x) auto |
|
657 } ultimately show ?thesis by (cases y) auto |
|
658 qed |
|
659 |
|
660 |
|
661 lemma extreal_le_epsilon2: |
|
662 fixes x y :: extreal |
|
663 assumes "ALL e. 0 < e --> x <= y + extreal e" |
|
664 shows "x <= y" |
|
665 proof- |
|
666 { fix e :: extreal assume "e>0" |
|
667 { assume "e=\<infinity>" hence "x<=y+e" by auto } |
|
668 moreover |
|
669 { assume "e~=\<infinity>" |
|
670 from this obtain r where "e = extreal r" using `e>0` apply (cases e) by auto |
|
671 hence "x<=y+e" using assms[rule_format, of r] `e>0` by auto |
|
672 } ultimately have "x<=y+e" by blast |
|
673 } from this show ?thesis using extreal_le_epsilon by auto |
|
674 qed |
|
675 |
|
676 lemma extreal_le_real: |
|
677 fixes x y :: extreal |
|
678 assumes "ALL z. x <= extreal z --> y <= extreal z" |
|
679 shows "y <= x" |
|
680 by (metis assms extreal.exhaust extreal_bot extreal_less_eq(1) |
|
681 extreal_less_eq(2) order_refl uminus_extreal.simps(2)) |
|
682 |
|
683 lemma extreal_le_extreal: |
|
684 fixes x y :: extreal |
|
685 assumes "\<And>B. B < x \<Longrightarrow> B <= y" |
|
686 shows "x <= y" |
|
687 by (metis assms extreal_dense leD linorder_le_less_linear) |
|
688 |
|
689 lemma extreal_ge_extreal: |
|
690 fixes x y :: extreal |
|
691 assumes "ALL B. B>x --> B >= y" |
|
692 shows "x >= y" |
|
693 by (metis assms extreal_dense leD linorder_le_less_linear) |
512 |
694 |
513 subsubsection {* Power *} |
695 subsubsection {* Power *} |
514 |
696 |
515 instantiation extreal :: power |
697 instantiation extreal :: power |
516 begin |
698 begin |
649 |
840 |
650 lemma extreal_mult_le_mult_iff: |
841 lemma extreal_mult_le_mult_iff: |
651 "\<bar>c\<bar> \<noteq> \<infinity> \<Longrightarrow> c * a \<le> c * b \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)" |
842 "\<bar>c\<bar> \<noteq> \<infinity> \<Longrightarrow> c * a \<le> c * b \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)" |
652 by (cases rule: extreal3_cases[of a b c]) (simp_all add: mult_le_cancel_left) |
843 by (cases rule: extreal3_cases[of a b c]) (simp_all add: mult_le_cancel_left) |
653 |
844 |
|
845 lemma extreal_minus_mono: |
|
846 fixes A B C D :: extreal assumes "A \<le> B" "D \<le> C" |
|
847 shows "A - C \<le> B - D" |
|
848 using assms |
|
849 by (cases rule: extreal3_cases[case_product extreal_cases, of A B C D]) simp_all |
|
850 |
|
851 lemma real_of_extreal_minus: |
|
852 "real (a - b) = (if \<bar>a\<bar> = \<infinity> \<or> \<bar>b\<bar> = \<infinity> then 0 else real a - real b)" |
|
853 by (cases rule: extreal2_cases[of a b]) auto |
|
854 |
|
855 lemma extreal_diff_positive: |
|
856 fixes a b :: extreal shows "a \<le> b \<Longrightarrow> 0 \<le> b - a" |
|
857 by (cases rule: extreal2_cases[of a b]) auto |
|
858 |
654 lemma extreal_between: |
859 lemma extreal_between: |
655 fixes x e :: extreal |
860 fixes x e :: extreal |
656 assumes "\<bar>x\<bar> \<noteq> \<infinity>" "0 < e" |
861 assumes "\<bar>x\<bar> \<noteq> \<infinity>" "0 < e" |
657 shows "x - e < x" "x < x + e" |
862 shows "x - e < x" "x < x + e" |
658 using assms apply (cases x, cases e) apply auto |
863 using assms apply (cases x, cases e) apply auto |
659 using assms by (cases x, cases e) auto |
864 using assms by (cases x, cases e) auto |
660 |
865 |
661 lemma extreal_distrib: |
|
662 fixes a b c :: extreal |
|
663 assumes "a \<noteq> \<infinity> \<or> b \<noteq> -\<infinity>" "a \<noteq> -\<infinity> \<or> b \<noteq> \<infinity>" "\<bar>c\<bar> \<noteq> \<infinity>" |
|
664 shows "(a + b) * c = a * c + b * c" |
|
665 using assms |
|
666 by (cases rule: extreal3_cases[of a b c]) (simp_all add: field_simps) |
|
667 |
|
668 subsubsection {* Division *} |
866 subsubsection {* Division *} |
669 |
867 |
670 instantiation extreal :: inverse |
868 instantiation extreal :: inverse |
671 begin |
869 begin |
672 |
870 |
723 lemma zero_le_divide_extreal[simp]: |
921 lemma zero_le_divide_extreal[simp]: |
724 fixes a :: extreal assumes "0 \<le> a" "0 \<le> b" |
922 fixes a :: extreal assumes "0 \<le> a" "0 \<le> b" |
725 shows "0 \<le> a / b" |
923 shows "0 \<le> a / b" |
726 using assms by (cases rule: extreal2_cases[of a b]) (auto simp: zero_le_divide_iff) |
924 using assms by (cases rule: extreal2_cases[of a b]) (auto simp: zero_le_divide_iff) |
727 |
925 |
728 lemma extreal_mult_le_0_iff: |
|
729 fixes a b :: extreal |
|
730 shows "a * b \<le> 0 \<longleftrightarrow> (0 \<le> a \<and> b \<le> 0) \<or> (a \<le> 0 \<and> 0 \<le> b)" |
|
731 by (cases rule: extreal2_cases[of a b]) (simp_all add: mult_le_0_iff) |
|
732 |
|
733 lemma extreal_zero_le_0_iff: |
|
734 fixes a b :: extreal |
|
735 shows "0 \<le> a * b \<longleftrightarrow> (0 \<le> a \<and> 0 \<le> b) \<or> (a \<le> 0 \<and> b \<le> 0)" |
|
736 by (cases rule: extreal2_cases[of a b]) (simp_all add: zero_le_mult_iff) |
|
737 |
|
738 lemma extreal_mult_less_0_iff: |
|
739 fixes a b :: extreal |
|
740 shows "a * b < 0 \<longleftrightarrow> (0 < a \<and> b < 0) \<or> (a < 0 \<and> 0 < b)" |
|
741 by (cases rule: extreal2_cases[of a b]) (simp_all add: mult_less_0_iff) |
|
742 |
|
743 lemma extreal_zero_less_0_iff: |
|
744 fixes a b :: extreal |
|
745 shows "0 < a * b \<longleftrightarrow> (0 < a \<and> 0 < b) \<or> (a < 0 \<and> b < 0)" |
|
746 by (cases rule: extreal2_cases[of a b]) (simp_all add: zero_less_mult_iff) |
|
747 |
|
748 lemma extreal_le_divide_pos: |
926 lemma extreal_le_divide_pos: |
749 "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y \<le> z / x \<longleftrightarrow> x * y \<le> z" |
927 "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y \<le> z / x \<longleftrightarrow> x * y \<le> z" |
750 by (cases rule: extreal3_cases[of x y z]) (auto simp: field_simps) |
928 by (cases rule: extreal3_cases[of x y z]) (auto simp: field_simps) |
751 |
929 |
752 lemma extreal_divide_le_pos: |
930 lemma extreal_divide_le_pos: |
775 "inverse x = \<infinity> \<longleftrightarrow> x = 0" |
953 "inverse x = \<infinity> \<longleftrightarrow> x = 0" |
776 by (cases x) auto |
954 by (cases x) auto |
777 |
955 |
778 lemma extreal_inverse_eq_0: |
956 lemma extreal_inverse_eq_0: |
779 "inverse x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity>" |
957 "inverse x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity>" |
|
958 by (cases x) auto |
|
959 |
|
960 lemma extreal_0_gt_inverse: |
|
961 fixes x :: extreal shows "0 < inverse x \<longleftrightarrow> x \<noteq> \<infinity> \<and> 0 \<le> x" |
780 by (cases x) auto |
962 by (cases x) auto |
781 |
963 |
782 lemma extreal_mult_less_right: |
964 lemma extreal_mult_less_right: |
783 assumes "b * a < c * a" "0 < a" "a < \<infinity>" |
965 assumes "b * a < c * a" "0 < a" "a < \<infinity>" |
784 shows "b < c" |
966 shows "b < c" |
785 using assms |
967 using assms |
786 by (cases rule: extreal3_cases[of a b c]) |
968 by (cases rule: extreal3_cases[of a b c]) |
787 (auto split: split_if_asm simp: zero_less_mult_iff zero_le_mult_iff) |
969 (auto split: split_if_asm simp: zero_less_mult_iff zero_le_mult_iff) |
788 |
970 |
789 lemma zero_le_power_extreal[simp]: |
971 lemma extreal_power_divide: |
790 fixes a :: extreal assumes "0 \<le> a" |
972 "y \<noteq> 0 \<Longrightarrow> (x / y :: extreal) ^ n = x^n / y^n" |
791 shows "0 \<le> a ^ n" |
973 by (cases rule: extreal2_cases[of x y]) |
792 using assms by (induct n) (auto simp: extreal_zero_le_0_iff) |
974 (auto simp: one_extreal_def zero_extreal_def power_divide not_le |
|
975 power_less_zero_eq zero_le_power_iff) |
|
976 |
|
977 lemma extreal_le_mult_one_interval: |
|
978 fixes x y :: extreal |
|
979 assumes y: "y \<noteq> -\<infinity>" |
|
980 assumes z: "\<And>z. \<lbrakk> 0 < z ; z < 1 \<rbrakk> \<Longrightarrow> z * x \<le> y" |
|
981 shows "x \<le> y" |
|
982 proof (cases x) |
|
983 case PInf with z[of "1 / 2"] show "x \<le> y" by (simp add: one_extreal_def) |
|
984 next |
|
985 case (real r) note r = this |
|
986 show "x \<le> y" |
|
987 proof (cases y) |
|
988 case (real p) note p = this |
|
989 have "r \<le> p" |
|
990 proof (rule field_le_mult_one_interval) |
|
991 fix z :: real assume "0 < z" and "z < 1" |
|
992 with z[of "extreal z"] |
|
993 show "z * r \<le> p" using p r by (auto simp: zero_le_mult_iff one_extreal_def) |
|
994 qed |
|
995 then show "x \<le> y" using p r by simp |
|
996 qed (insert y, simp_all) |
|
997 qed simp |
793 |
998 |
794 subsection "Complete lattice" |
999 subsection "Complete lattice" |
795 |
|
796 lemma extreal_bot: |
|
797 fixes x :: extreal assumes "\<And>B. x \<le> extreal B" shows "x = - \<infinity>" |
|
798 proof (cases x) |
|
799 case (real r) with assms[of "r - 1"] show ?thesis by auto |
|
800 next case PInf with assms[of 0] show ?thesis by auto |
|
801 next case MInf then show ?thesis by simp |
|
802 qed |
|
803 |
|
804 lemma extreal_top: |
|
805 fixes x :: extreal assumes "\<And>B. x \<ge> extreal B" shows "x = \<infinity>" |
|
806 proof (cases x) |
|
807 case (real r) with assms[of "r + 1"] show ?thesis by auto |
|
808 next case MInf with assms[of 0] show ?thesis by auto |
|
809 next case PInf then show ?thesis by simp |
|
810 qed |
|
811 |
1000 |
812 instantiation extreal :: lattice |
1001 instantiation extreal :: lattice |
813 begin |
1002 begin |
814 definition [simp]: "sup x y = (max x y :: extreal)" |
1003 definition [simp]: "sup x y = (max x y :: extreal)" |
815 definition [simp]: "inf x y = (min x y :: extreal)" |
1004 definition [simp]: "inf x y = (min x y :: extreal)" |
1208 then have "g j + SUPR UNIV f \<le> y" by (simp add: ac_simps) } |
1407 then have "g j + SUPR UNIV f \<le> y" by (simp add: ac_simps) } |
1209 then have "SUPR UNIV g + SUPR UNIV f \<le> y" |
1408 then have "SUPR UNIV g + SUPR UNIV f \<le> y" |
1210 using f by (rule SUP_extreal_le_addI) |
1409 using f by (rule SUP_extreal_le_addI) |
1211 then show "SUPR UNIV f + SUPR UNIV g \<le> y" by (simp add: ac_simps) |
1410 then show "SUPR UNIV f + SUPR UNIV g \<le> y" by (simp add: ac_simps) |
1212 qed (auto intro!: add_mono le_SUPI) |
1411 qed (auto intro!: add_mono le_SUPI) |
|
1412 |
|
1413 lemma SUPR_extreal_add_pos: |
|
1414 fixes f g :: "nat \<Rightarrow> extreal" |
|
1415 assumes inc: "incseq f" "incseq g" and pos: "\<And>i. 0 \<le> f i" "\<And>i. 0 \<le> g i" |
|
1416 shows "(SUP i. f i + g i) = SUPR UNIV f + SUPR UNIV g" |
|
1417 proof (intro SUPR_extreal_add inc) |
|
1418 fix i show "f i \<noteq> -\<infinity>" "g i \<noteq> -\<infinity>" using pos[of i] by auto |
|
1419 qed |
|
1420 |
|
1421 lemma SUPR_extreal_setsum: |
|
1422 fixes f g :: "'a \<Rightarrow> nat \<Rightarrow> extreal" |
|
1423 assumes "\<And>n. n \<in> A \<Longrightarrow> incseq (f n)" and pos: "\<And>n i. n \<in> A \<Longrightarrow> 0 \<le> f n i" |
|
1424 shows "(SUP i. \<Sum>n\<in>A. f n i) = (\<Sum>n\<in>A. SUPR UNIV (f n))" |
|
1425 proof cases |
|
1426 assume "finite A" then show ?thesis using assms |
|
1427 by induct (auto simp: incseq_setsumI2 setsum_nonneg SUPR_extreal_add_pos) |
|
1428 qed simp |
1213 |
1429 |
1214 lemma SUPR_extreal_cmult: |
1430 lemma SUPR_extreal_cmult: |
1215 fixes f :: "nat \<Rightarrow> extreal" assumes "\<And>i. 0 \<le> f i" "0 \<le> c" |
1431 fixes f :: "nat \<Rightarrow> extreal" assumes "\<And>i. 0 \<le> f i" "0 \<le> c" |
1216 shows "(SUP i. c * f i) = c * SUPR UNIV f" |
1432 shows "(SUP i. c * f i) = c * SUPR UNIV f" |
1217 proof (rule extreal_SUPI) |
1433 proof (rule extreal_SUPI) |
1241 moreover assume "\<not> (0 < c \<and> c \<noteq> \<infinity>)" |
1457 moreover assume "\<not> (0 < c \<and> c \<noteq> \<infinity>)" |
1242 ultimately show ?thesis using * `0 \<le> c` by auto |
1458 ultimately show ?thesis using * `0 \<le> c` by auto |
1243 qed |
1459 qed |
1244 qed |
1460 qed |
1245 |
1461 |
|
1462 lemma SUP_PInfty: |
|
1463 fixes f :: "'a \<Rightarrow> extreal" |
|
1464 assumes "\<And>n::nat. \<exists>i\<in>A. extreal (real n) \<le> f i" |
|
1465 shows "(SUP i:A. f i) = \<infinity>" |
|
1466 unfolding SUPR_def Sup_eq_top_iff[where 'a=extreal, unfolded top_extreal_def] |
|
1467 apply simp |
|
1468 proof safe |
|
1469 fix x assume "x \<noteq> \<infinity>" |
|
1470 show "\<exists>i\<in>A. x < f i" |
|
1471 proof (cases x) |
|
1472 case PInf with `x \<noteq> \<infinity>` show ?thesis by simp |
|
1473 next |
|
1474 case MInf with assms[of "0"] show ?thesis by force |
|
1475 next |
|
1476 case (real r) |
|
1477 with less_PInf_Ex_of_nat[of x] obtain n :: nat where "x < extreal (real n)" by auto |
|
1478 moreover from assms[of n] guess i .. |
|
1479 ultimately show ?thesis |
|
1480 by (auto intro!: bexI[of _ i]) |
|
1481 qed |
|
1482 qed |
|
1483 |
|
1484 lemma Sup_countable_SUPR: |
|
1485 assumes "A \<noteq> {}" |
|
1486 shows "\<exists>f::nat \<Rightarrow> extreal. range f \<subseteq> A \<and> Sup A = SUPR UNIV f" |
|
1487 proof (cases "Sup A") |
|
1488 case (real r) |
|
1489 have "\<forall>n::nat. \<exists>x. x \<in> A \<and> Sup A < x + 1 / extreal (real n)" |
|
1490 proof |
|
1491 fix n ::nat have "\<exists>x\<in>A. Sup A - 1 / extreal (real n) < x" |
|
1492 using assms real by (intro Sup_extreal_close) (auto simp: one_extreal_def) |
|
1493 then guess x .. |
|
1494 then show "\<exists>x. x \<in> A \<and> Sup A < x + 1 / extreal (real n)" |
|
1495 by (auto intro!: exI[of _ x] simp: extreal_minus_less_iff) |
|
1496 qed |
|
1497 from choice[OF this] guess f .. note f = this |
|
1498 have "SUPR UNIV f = Sup A" |
|
1499 proof (rule extreal_SUPI) |
|
1500 fix i show "f i \<le> Sup A" using f |
|
1501 by (auto intro!: complete_lattice_class.Sup_upper) |
|
1502 next |
|
1503 fix y assume bound: "\<And>i. i \<in> UNIV \<Longrightarrow> f i \<le> y" |
|
1504 show "Sup A \<le> y" |
|
1505 proof (rule extreal_le_epsilon, intro allI impI) |
|
1506 fix e :: extreal assume "0 < e" |
|
1507 show "Sup A \<le> y + e" |
|
1508 proof (cases e) |
|
1509 case (real r) |
|
1510 hence "0 < r" using `0 < e` by auto |
|
1511 then obtain n ::nat where *: "1 / real n < r" "0 < n" |
|
1512 using ex_inverse_of_nat_less by (auto simp: real_eq_of_nat inverse_eq_divide) |
|
1513 have "Sup A \<le> f n + 1 / extreal (real n)" using f[THEN spec, of n] by auto |
|
1514 also have "1 / extreal (real n) \<le> e" using real * by (auto simp: one_extreal_def ) |
|
1515 with bound have "f n + 1 / extreal (real n) \<le> y + e" by (rule add_mono) simp |
|
1516 finally show "Sup A \<le> y + e" . |
|
1517 qed (insert `0 < e`, auto) |
|
1518 qed |
|
1519 qed |
|
1520 with f show ?thesis by (auto intro!: exI[of _ f]) |
|
1521 next |
|
1522 case PInf |
|
1523 from `A \<noteq> {}` obtain x where "x \<in> A" by auto |
|
1524 show ?thesis |
|
1525 proof cases |
|
1526 assume "\<infinity> \<in> A" |
|
1527 moreover then have "\<infinity> \<le> Sup A" by (intro complete_lattice_class.Sup_upper) |
|
1528 ultimately show ?thesis by (auto intro!: exI[of _ "\<lambda>x. \<infinity>"]) |
|
1529 next |
|
1530 assume "\<infinity> \<notin> A" |
|
1531 have "\<exists>x\<in>A. 0 \<le> x" |
|
1532 by (metis Infty_neq_0 PInf complete_lattice_class.Sup_least extreal_infty_less_eq2 linorder_linear) |
|
1533 then obtain x where "x \<in> A" "0 \<le> x" by auto |
|
1534 have "\<forall>n::nat. \<exists>f. f \<in> A \<and> x + extreal (real n) \<le> f" |
|
1535 proof (rule ccontr) |
|
1536 assume "\<not> ?thesis" |
|
1537 then have "\<exists>n::nat. Sup A \<le> x + extreal (real n)" |
|
1538 by (simp add: Sup_le_iff not_le less_imp_le Ball_def) (metis less_imp_le) |
|
1539 then show False using `x \<in> A` `\<infinity> \<notin> A` PInf |
|
1540 by(cases x) auto |
|
1541 qed |
|
1542 from choice[OF this] guess f .. note f = this |
|
1543 have "SUPR UNIV f = \<infinity>" |
|
1544 proof (rule SUP_PInfty) |
|
1545 fix n :: nat show "\<exists>i\<in>UNIV. extreal (real n) \<le> f i" |
|
1546 using f[THEN spec, of n] `0 \<le> x` |
|
1547 by (cases rule: extreal2_cases[of "f n" x]) (auto intro!: exI[of _ n]) |
|
1548 qed |
|
1549 then show ?thesis using f PInf by (auto intro!: exI[of _ f]) |
|
1550 qed |
|
1551 next |
|
1552 case MInf |
|
1553 with `A \<noteq> {}` have "A = {-\<infinity>}" by (auto simp: Sup_eq_MInfty) |
|
1554 then show ?thesis using MInf by (auto intro!: exI[of _ "\<lambda>x. -\<infinity>"]) |
|
1555 qed |
|
1556 |
|
1557 lemma SUPR_countable_SUPR: |
|
1558 "A \<noteq> {} \<Longrightarrow> \<exists>f::nat \<Rightarrow> extreal. range f \<subseteq> g`A \<and> SUPR A g = SUPR UNIV f" |
|
1559 using Sup_countable_SUPR[of "g`A"] by (auto simp: SUPR_def) |
|
1560 |
|
1561 |
|
1562 lemma Sup_extreal_cadd: |
|
1563 fixes A :: "extreal set" assumes "A \<noteq> {}" and "a \<noteq> -\<infinity>" |
|
1564 shows "Sup ((\<lambda>x. a + x) ` A) = a + Sup A" |
|
1565 proof (rule antisym) |
|
1566 have *: "\<And>a::extreal. \<And>A. Sup ((\<lambda>x. a + x) ` A) \<le> a + Sup A" |
|
1567 by (auto intro!: add_mono complete_lattice_class.Sup_least complete_lattice_class.Sup_upper) |
|
1568 then show "Sup ((\<lambda>x. a + x) ` A) \<le> a + Sup A" . |
|
1569 show "a + Sup A \<le> Sup ((\<lambda>x. a + x) ` A)" |
|
1570 proof (cases a) |
|
1571 case PInf with `A \<noteq> {}` show ?thesis by (auto simp: image_constant) |
|
1572 next |
|
1573 case (real r) |
|
1574 then have **: "op + (- a) ` op + a ` A = A" |
|
1575 by (auto simp: image_iff ac_simps zero_extreal_def[symmetric]) |
|
1576 from *[of "-a" "(\<lambda>x. a + x) ` A"] real show ?thesis unfolding ** |
|
1577 by (cases rule: extreal2_cases[of "Sup A" "Sup (op + a ` A)"]) auto |
|
1578 qed (insert `a \<noteq> -\<infinity>`, auto) |
|
1579 qed |
|
1580 |
|
1581 lemma Sup_extreal_cminus: |
|
1582 fixes A :: "extreal set" assumes "A \<noteq> {}" and "a \<noteq> -\<infinity>" |
|
1583 shows "Sup ((\<lambda>x. a - x) ` A) = a - Inf A" |
|
1584 using Sup_extreal_cadd[of "uminus ` A" a] assms |
|
1585 by (simp add: comp_def image_image minus_extreal_def |
|
1586 extreal_Sup_uminus_image_eq) |
|
1587 |
|
1588 lemma SUPR_extreal_cminus: |
|
1589 fixes A assumes "A \<noteq> {}" and "a \<noteq> -\<infinity>" |
|
1590 shows "(SUP x:A. a - f x) = a - (INF x:A. f x)" |
|
1591 using Sup_extreal_cminus[of "f`A" a] assms |
|
1592 unfolding SUPR_def INFI_def image_image by auto |
|
1593 |
|
1594 lemma Inf_extreal_cminus: |
|
1595 fixes A :: "extreal set" assumes "A \<noteq> {}" and "\<bar>a\<bar> \<noteq> \<infinity>" |
|
1596 shows "Inf ((\<lambda>x. a - x) ` A) = a - Sup A" |
|
1597 proof - |
|
1598 { fix x have "-a - -x = -(a - x)" using assms by (cases x) auto } |
|
1599 moreover then have "(\<lambda>x. -a - x)`uminus`A = uminus ` (\<lambda>x. a - x) ` A" |
|
1600 by (auto simp: image_image) |
|
1601 ultimately show ?thesis |
|
1602 using Sup_extreal_cminus[of "uminus ` A" "-a"] assms |
|
1603 by (auto simp add: extreal_Sup_uminus_image_eq extreal_Inf_uminus_image_eq) |
|
1604 qed |
|
1605 |
|
1606 lemma INFI_extreal_cminus: |
|
1607 fixes A assumes "A \<noteq> {}" and "\<bar>a\<bar> \<noteq> \<infinity>" |
|
1608 shows "(INF x:A. a - f x) = a - (SUP x:A. f x)" |
|
1609 using Inf_extreal_cminus[of "f`A" a] assms |
|
1610 unfolding SUPR_def INFI_def image_image |
|
1611 by auto |
|
1612 |
1246 subsection "Limits on @{typ extreal}" |
1613 subsection "Limits on @{typ extreal}" |
1247 |
1614 |
1248 subsubsection "Topological space" |
1615 subsubsection "Topological space" |
1249 |
|
1250 lemma |
|
1251 shows extreal_max[simp]: "extreal (max x y) = max (extreal x) (extreal y)" |
|
1252 and extreal_min[simp]: "extreal (min x y) = min (extreal x) (extreal y)" |
|
1253 by (simp_all add: min_def max_def) |
|
1254 |
1616 |
1255 instantiation extreal :: topological_space |
1617 instantiation extreal :: topological_space |
1256 begin |
1618 begin |
1257 |
1619 |
1258 definition "open A \<longleftrightarrow> open (extreal -` A) |
1620 definition "open A \<longleftrightarrow> open (extreal -` A) |
1537 moreover |
1888 moreover |
1538 { assume "(-\<infinity>) : S" hence "(- S)={}" using lhs extreal_open_closed_aux[of "-S"] by auto } |
1889 { assume "(-\<infinity>) : S" hence "(- S)={}" using lhs extreal_open_closed_aux[of "-S"] by auto } |
1539 ultimately have "S = {} | S = UNIV" by auto |
1890 ultimately have "S = {} | S = UNIV" by auto |
1540 } thus ?thesis by auto |
1891 } thus ?thesis by auto |
1541 qed |
1892 qed |
1542 |
|
1543 |
|
1544 lemma extreal_le_epsilon: |
|
1545 fixes x y :: extreal |
|
1546 assumes "ALL e. 0 < e --> x <= y + e" |
|
1547 shows "x <= y" |
|
1548 proof- |
|
1549 { assume a: "EX r. y = extreal r" |
|
1550 from this obtain r where r_def: "y = extreal r" by auto |
|
1551 { assume "x=(-\<infinity>)" hence ?thesis by auto } |
|
1552 moreover |
|
1553 { assume "~(x=(-\<infinity>))" |
|
1554 from this obtain p where p_def: "x = extreal p" |
|
1555 using a assms[rule_format, of 1] by (cases x) auto |
|
1556 { fix e have "0 < e --> p <= r + e" |
|
1557 using assms[rule_format, of "extreal e"] p_def r_def by auto } |
|
1558 hence "p <= r" apply (subst field_le_epsilon) by auto |
|
1559 hence ?thesis using r_def p_def by auto |
|
1560 } ultimately have ?thesis by blast |
|
1561 } |
|
1562 moreover |
|
1563 { assume "y=(-\<infinity>) | y=\<infinity>" hence ?thesis |
|
1564 using assms[rule_format, of 1] by (cases x) auto |
|
1565 } ultimately show ?thesis by (cases y) auto |
|
1566 qed |
|
1567 |
|
1568 |
|
1569 lemma extreal_le_epsilon2: |
|
1570 fixes x y :: extreal |
|
1571 assumes "ALL e. 0 < e --> x <= y + extreal e" |
|
1572 shows "x <= y" |
|
1573 proof- |
|
1574 { fix e :: extreal assume "e>0" |
|
1575 { assume "e=\<infinity>" hence "x<=y+e" by auto } |
|
1576 moreover |
|
1577 { assume "e~=\<infinity>" |
|
1578 from this obtain r where "e = extreal r" using `e>0` apply (cases e) by auto |
|
1579 hence "x<=y+e" using assms[rule_format, of r] `e>0` by auto |
|
1580 } ultimately have "x<=y+e" by blast |
|
1581 } from this show ?thesis using extreal_le_epsilon by auto |
|
1582 qed |
|
1583 |
|
1584 lemma extreal_le_real: |
|
1585 fixes x y :: extreal |
|
1586 assumes "ALL z. x <= extreal z --> y <= extreal z" |
|
1587 shows "y <= x" |
|
1588 by (metis assms extreal.exhaust extreal_bot extreal_less_eq(1) |
|
1589 extreal_less_eq(2) order_refl uminus_extreal.simps(2)) |
|
1590 |
|
1591 lemma extreal_le_extreal: |
|
1592 fixes x y :: extreal |
|
1593 assumes "\<And>B. B < x \<Longrightarrow> B <= y" |
|
1594 shows "x <= y" |
|
1595 by (metis assms extreal_dense leD linorder_le_less_linear) |
|
1596 |
|
1597 |
|
1598 lemma extreal_ge_extreal: |
|
1599 fixes x y :: extreal |
|
1600 assumes "ALL B. B>x --> B >= y" |
|
1601 shows "x >= y" |
|
1602 by (metis assms extreal_dense leD linorder_le_less_linear) |
|
1603 |
1893 |
1604 |
1894 |
1605 instance extreal :: t2_space |
1895 instance extreal :: t2_space |
1606 proof |
1896 proof |
1607 fix x y :: extreal assume "x ~= y" |
1897 fix x y :: extreal assume "x ~= y" |
3188 then have "\<forall>i\<in>A. \<exists>r. f i = extreal r" by auto |
3492 then have "\<forall>i\<in>A. \<exists>r. f i = extreal r" by auto |
3189 from bchoice[OF this] * assms show "\<forall>i\<in>A. f i = 0" |
3493 from bchoice[OF this] * assms show "\<forall>i\<in>A. f i = 0" |
3190 using setsum_nonneg_eq_0_iff[of A "\<lambda>i. real (f i)"] by auto |
3494 using setsum_nonneg_eq_0_iff[of A "\<lambda>i. real (f i)"] by auto |
3191 qed (rule setsum_0') |
3495 qed (rule setsum_0') |
3192 |
3496 |
|
3497 |
3193 lemma setsum_extreal_right_distrib: |
3498 lemma setsum_extreal_right_distrib: |
3194 fixes f :: "'a \<Rightarrow> extreal" assumes "\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i" "0 \<le> r" |
3499 fixes f :: "'a \<Rightarrow> extreal" assumes "\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i" |
3195 shows "r * setsum f A = (\<Sum>n\<in>A. r * f n)" |
3500 shows "r * setsum f A = (\<Sum>n\<in>A. r * f n)" |
3196 proof cases |
3501 proof cases |
3197 assume "finite A" then show ?thesis using assms |
3502 assume "finite A" then show ?thesis using assms |
3198 by induct (auto simp: extreal_distrib_right setsum_nonneg) |
3503 by induct (auto simp: extreal_right_distrib setsum_nonneg) |
|
3504 qed simp |
|
3505 |
|
3506 lemma setsum_real_of_extreal: |
|
3507 assumes "\<And>x. x \<in> A \<Longrightarrow> \<bar>f x\<bar> \<noteq> \<infinity>" |
|
3508 shows "real (\<Sum>x\<in>A. f x) = (\<Sum>x\<in>A. real (f x))" |
|
3509 proof cases |
|
3510 assume "finite A" from this assms show ?thesis |
|
3511 proof induct |
|
3512 case (insert a A) then show ?case |
|
3513 by (simp add: real_of_extreal_add setsum_Inf) |
|
3514 qed simp |
3199 qed simp |
3515 qed simp |
3200 |
3516 |
3201 lemma sums_extreal_positive: |
3517 lemma sums_extreal_positive: |
3202 fixes f :: "nat \<Rightarrow> extreal" assumes "\<And>i. 0 \<le> f i" shows "f sums (SUP n. \<Sum>i<n. f i)" |
3518 fixes f :: "nat \<Rightarrow> extreal" assumes "\<And>i. 0 \<le> f i" shows "f sums (SUP n. \<Sum>i<n. f i)" |
3203 proof - |
3519 proof - |
3205 using extreal_add_mono[OF _ assms] by (auto intro!: incseq_SucI) |
3521 using extreal_add_mono[OF _ assms] by (auto intro!: incseq_SucI) |
3206 from LIMSEQ_extreal_SUPR[OF this] |
3522 from LIMSEQ_extreal_SUPR[OF this] |
3207 show ?thesis unfolding sums_def by (simp add: atLeast0LessThan) |
3523 show ?thesis unfolding sums_def by (simp add: atLeast0LessThan) |
3208 qed |
3524 qed |
3209 |
3525 |
3210 lemma summable_extreal: |
3526 lemma summable_extreal_pos: |
3211 fixes f :: "nat \<Rightarrow> extreal" assumes "\<And>i. 0 \<le> f i" shows "summable f" |
3527 fixes f :: "nat \<Rightarrow> extreal" assumes "\<And>i. 0 \<le> f i" shows "summable f" |
3212 using sums_extreal_positive[of f, OF assms] unfolding summable_def by auto |
3528 using sums_extreal_positive[of f, OF assms] unfolding summable_def by auto |
3213 |
3529 |
3214 lemma suminf_extreal_eq_SUPR: |
3530 lemma suminf_extreal_eq_SUPR: |
3215 fixes f :: "nat \<Rightarrow> extreal" assumes "\<And>i. 0 \<le> f i" |
3531 fixes f :: "nat \<Rightarrow> extreal" assumes "\<And>i. 0 \<le> f i" |
3216 shows "(\<Sum>x. f x) = (SUP n. \<Sum>i<n. f i)" |
3532 shows "(\<Sum>x. f x) = (SUP n. \<Sum>i<n. f i)" |
3217 using sums_extreal_positive[of f, OF assms, THEN sums_unique] by simp |
3533 using sums_extreal_positive[of f, OF assms, THEN sums_unique] by simp |
3218 |
3534 |
3219 lemma suminf_extreal: |
3535 lemma sums_extreal: |
3220 "(\<lambda>x. extreal (f x)) sums extreal x \<longleftrightarrow> f sums x" |
3536 "(\<lambda>x. extreal (f x)) sums extreal x \<longleftrightarrow> f sums x" |
3221 unfolding sums_def by simp |
3537 unfolding sums_def by simp |
3222 |
3538 |
3223 lemma suminf_bound: |
3539 lemma suminf_bound: |
3224 fixes f :: "nat \<Rightarrow> extreal" |
3540 fixes f :: "nat \<Rightarrow> extreal" |
3225 assumes "\<forall>N. (\<Sum>n<N. f n) \<le> x" and pos: "\<And>n. 0 \<le> f n" |
3541 assumes "\<forall>N. (\<Sum>n<N. f n) \<le> x" and pos: "\<And>n. 0 \<le> f n" |
3226 shows "suminf f \<le> x" |
3542 shows "suminf f \<le> x" |
3227 proof (rule Lim_bounded_extreal) |
3543 proof (rule Lim_bounded_extreal) |
3228 have "summable f" using pos[THEN summable_extreal] . |
3544 have "summable f" using pos[THEN summable_extreal_pos] . |
3229 then show "(\<lambda>N. \<Sum>n<N. f n) ----> suminf f" |
3545 then show "(\<lambda>N. \<Sum>n<N. f n) ----> suminf f" |
3230 by (auto dest!: summable_sums simp: sums_def atLeast0LessThan) |
3546 by (auto dest!: summable_sums simp: sums_def atLeast0LessThan) |
3231 show "\<forall>n\<ge>0. setsum f {..<n} \<le> x" |
3547 show "\<forall>n\<ge>0. setsum f {..<n} \<le> x" |
3232 using assms by auto |
3548 using assms by auto |
3233 qed |
3549 qed |
3281 also have "... \<le> suminf g" using `\<And>N. 0 \<le> g N` by (rule suminf_upper) |
3600 also have "... \<le> suminf g" using `\<And>N. 0 \<le> g N` by (rule suminf_upper) |
3282 finally show "setsum f {..<n} \<le> suminf g" . |
3601 finally show "setsum f {..<n} \<le> suminf g" . |
3283 qed (rule assms(2)) |
3602 qed (rule assms(2)) |
3284 |
3603 |
3285 lemma suminf_half_series_extreal: "(\<Sum>n. (1/2 :: extreal)^Suc n) = 1" |
3604 lemma suminf_half_series_extreal: "(\<Sum>n. (1/2 :: extreal)^Suc n) = 1" |
3286 using suminf_extreal[THEN iffD2, OF power_half_series, THEN sums_unique, symmetric] |
3605 using sums_extreal[THEN iffD2, OF power_half_series, THEN sums_unique, symmetric] |
3287 by (simp add: one_extreal_def) |
3606 by (simp add: one_extreal_def) |
3288 |
3607 |
3289 lemma suminf_add_extreal: |
3608 lemma suminf_add_extreal: |
3290 fixes f g :: "nat \<Rightarrow> extreal" |
3609 fixes f g :: "nat \<Rightarrow> extreal" |
3291 assumes "\<And>i. 0 \<le> f i" "\<And>i. 0 \<le> g i" |
3610 assumes "\<And>i. 0 \<le> f i" "\<And>i. 0 \<le> g i" |
3292 shows "(\<Sum>i. f i + g i) = suminf f + suminf g" |
3611 shows "(\<Sum>i. f i + g i) = suminf f + suminf g" |
3293 apply (subst (1 2 3) suminf_extreal_eq_SUPR) |
3612 apply (subst (1 2 3) suminf_extreal_eq_SUPR) |
3294 unfolding setsum_addf |
3613 unfolding setsum_addf |
3295 by (intro assms extreal_add_nonneg_nonneg SUPR_extreal_add incseq_setsumI setsum_nonneg ballI)+ |
3614 by (intro assms extreal_add_nonneg_nonneg SUPR_extreal_add_pos incseq_setsumI setsum_nonneg ballI)+ |
3296 |
3615 |
3297 lemma suminf_cmult_extreal: |
3616 lemma suminf_cmult_extreal: |
3298 fixes f g :: "nat \<Rightarrow> extreal" |
3617 fixes f g :: "nat \<Rightarrow> extreal" |
3299 assumes "\<And>i. 0 \<le> f i" "0 \<le> a" |
3618 assumes "\<And>i. 0 \<le> f i" "0 \<le> a" |
3300 shows "(\<Sum>i. a * f i) = a * suminf f" |
3619 shows "(\<Sum>i. a * f i) = a * suminf f" |
3301 by (auto simp: setsum_extreal_right_distrib[symmetric] assms |
3620 by (auto simp: setsum_extreal_right_distrib[symmetric] assms |
3302 extreal_zero_le_0_iff setsum_nonneg suminf_extreal_eq_SUPR |
3621 extreal_zero_le_0_iff setsum_nonneg suminf_extreal_eq_SUPR |
3303 intro!: SUPR_extreal_cmult ) |
3622 intro!: SUPR_extreal_cmult ) |
3304 |
3623 |
|
3624 lemma suminf_PInfty: |
|
3625 assumes "\<And>i. 0 \<le> f i" "suminf f \<noteq> \<infinity>" |
|
3626 shows "f i \<noteq> \<infinity>" |
|
3627 proof - |
|
3628 from suminf_upper[of f "Suc i", OF assms(1)] assms(2) |
|
3629 have "(\<Sum>i<Suc i. f i) \<noteq> \<infinity>" by auto |
|
3630 then show ?thesis |
|
3631 unfolding setsum_Pinfty by simp |
|
3632 qed |
|
3633 |
|
3634 lemma suminf_PInfty_fun: |
|
3635 assumes "\<And>i. 0 \<le> f i" "suminf f \<noteq> \<infinity>" |
|
3636 shows "\<exists>f'. f = (\<lambda>x. extreal (f' x))" |
|
3637 proof - |
|
3638 have "\<forall>i. \<exists>r. f i = extreal r" |
|
3639 proof |
|
3640 fix i show "\<exists>r. f i = extreal r" |
|
3641 using suminf_PInfty[OF assms] assms(1)[of i] by (cases "f i") auto |
|
3642 qed |
|
3643 from choice[OF this] show ?thesis by auto |
|
3644 qed |
|
3645 |
|
3646 lemma summable_extreal: |
|
3647 assumes "\<And>i. 0 \<le> f i" "(\<Sum>i. extreal (f i)) \<noteq> \<infinity>" |
|
3648 shows "summable f" |
|
3649 proof - |
|
3650 have "0 \<le> (\<Sum>i. extreal (f i))" |
|
3651 using assms by (intro suminf_0_le) auto |
|
3652 with assms obtain r where r: "(\<Sum>i. extreal (f i)) = extreal r" |
|
3653 by (cases "\<Sum>i. extreal (f i)") auto |
|
3654 from summable_extreal_pos[of "\<lambda>x. extreal (f x)"] |
|
3655 have "summable (\<lambda>x. extreal (f x))" using assms by auto |
|
3656 from summable_sums[OF this] |
|
3657 have "(\<lambda>x. extreal (f x)) sums (\<Sum>x. extreal (f x))" by auto |
|
3658 then show "summable f" |
|
3659 unfolding r sums_extreal summable_def .. |
|
3660 qed |
|
3661 |
|
3662 lemma suminf_extreal: |
|
3663 assumes "\<And>i. 0 \<le> f i" "(\<Sum>i. extreal (f i)) \<noteq> \<infinity>" |
|
3664 shows "(\<Sum>i. extreal (f i)) = extreal (suminf f)" |
|
3665 proof (rule sums_unique[symmetric]) |
|
3666 from summable_extreal[OF assms] |
|
3667 show "(\<lambda>x. extreal (f x)) sums (extreal (suminf f))" |
|
3668 unfolding sums_extreal using assms by (intro summable_sums summable_extreal) |
|
3669 qed |
|
3670 |
|
3671 lemma suminf_extreal_minus: |
|
3672 fixes f g :: "nat \<Rightarrow> extreal" |
|
3673 assumes ord: "\<And>i. g i \<le> f i" "\<And>i. 0 \<le> g i" and fin: "suminf f \<noteq> \<infinity>" "suminf g \<noteq> \<infinity>" |
|
3674 shows "(\<Sum>i. f i - g i) = suminf f - suminf g" |
|
3675 proof - |
|
3676 { fix i have "0 \<le> f i" using ord[of i] by auto } |
|
3677 moreover |
|
3678 from suminf_PInfty_fun[OF `\<And>i. 0 \<le> f i` fin(1)] guess f' .. note this[simp] |
|
3679 from suminf_PInfty_fun[OF `\<And>i. 0 \<le> g i` fin(2)] guess g' .. note this[simp] |
|
3680 { fix i have "0 \<le> f i - g i" using ord[of i] by (auto simp: extreal_le_minus_iff) } |
|
3681 moreover |
|
3682 have "suminf (\<lambda>i. f i - g i) \<le> suminf f" |
|
3683 using assms by (auto intro!: suminf_le_pos simp: field_simps) |
|
3684 then have "suminf (\<lambda>i. f i - g i) \<noteq> \<infinity>" using fin by auto |
|
3685 ultimately show ?thesis using assms `\<And>i. 0 \<le> f i` |
|
3686 apply simp |
|
3687 by (subst (1 2 3) suminf_extreal) |
|
3688 (auto intro!: suminf_diff[symmetric] summable_extreal) |
|
3689 qed |
|
3690 |
|
3691 lemma suminf_extreal_PInf[simp]: |
|
3692 "(\<Sum>x. \<infinity>) = \<infinity>" |
|
3693 proof - |
|
3694 have "(\<Sum>i<Suc 0. \<infinity>) \<le> (\<Sum>x. \<infinity>)" by (rule suminf_upper) auto |
|
3695 then show ?thesis by simp |
|
3696 qed |
|
3697 |
|
3698 lemma summable_real_of_extreal: |
|
3699 assumes f: "\<And>i. 0 \<le> f i" and fin: "(\<Sum>i. f i) \<noteq> \<infinity>" |
|
3700 shows "summable (\<lambda>i. real (f i))" |
|
3701 proof (rule summable_def[THEN iffD2]) |
|
3702 have "0 \<le> (\<Sum>i. f i)" using assms by (auto intro: suminf_0_le) |
|
3703 with fin obtain r where r: "extreal r = (\<Sum>i. f i)" by (cases "(\<Sum>i. f i)") auto |
|
3704 { fix i have "f i \<noteq> \<infinity>" using f by (intro suminf_PInfty[OF _ fin]) auto |
|
3705 then have "\<bar>f i\<bar> \<noteq> \<infinity>" using f[of i] by auto } |
|
3706 note fin = this |
|
3707 have "(\<lambda>i. extreal (real (f i))) sums (\<Sum>i. extreal (real (f i)))" |
|
3708 using f by (auto intro!: summable_extreal_pos summable_sums simp: extreal_le_real_iff zero_extreal_def) |
|
3709 also have "\<dots> = extreal r" using fin r by (auto simp: extreal_real) |
|
3710 finally show "\<exists>r. (\<lambda>i. real (f i)) sums r" by (auto simp: sums_extreal) |
|
3711 qed |
|
3712 |
3305 end |
3713 end |