src/HOL/Library/Extended_Real.thy
author haftmann
Tue, 05 Mar 2019 07:00:21 +0000
changeset 69861 62e47f06d22c
parent 69661 a03a63b81f44
child 70365 4df0628e8545
permissions -rw-r--r--
avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
     1
(*  Title:      HOL/Library/Extended_Real.thy
41983
2dc6e382a58b standardized headers;
wenzelm
parents: 41980
diff changeset
     2
    Author:     Johannes Hölzl, TU München
2dc6e382a58b standardized headers;
wenzelm
parents: 41980
diff changeset
     3
    Author:     Robert Himmelmann, TU München
2dc6e382a58b standardized headers;
wenzelm
parents: 41980
diff changeset
     4
    Author:     Armin Heller, TU München
2dc6e382a58b standardized headers;
wenzelm
parents: 41980
diff changeset
     5
    Author:     Bogdan Grechuk, University of Edinburgh
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
     6
    Author:     Manuel Eberl, TU München
41983
2dc6e382a58b standardized headers;
wenzelm
parents: 41980
diff changeset
     7
*)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
     8
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
     9
section \<open>Extended real number line\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    10
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    11
theory Extended_Real
60636
ee18efe9b246 add named theorems order_continuous_intros; lfp/gfp_funpow; bounded variant for lfp/gfp transfer
hoelzl
parents: 60580
diff changeset
    12
imports Complex_Main Extended_Nat Liminf_Limsup
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    13
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    14
68484
59793df7f853 clarified document antiquotation @{theory};
wenzelm
parents: 68406
diff changeset
    15
text \<open>
69593
3dda49e08b9d isabelle update -u control_cartouches;
wenzelm
parents: 69313
diff changeset
    16
  This should be part of \<^theory>\<open>HOL-Library.Extended_Nat\<close> or \<^theory>\<open>HOL-Library.Order_Continuity\<close>, but then the AFP-entry \<open>Jinja_Thread\<close> fails, as it does overload
3dda49e08b9d isabelle update -u control_cartouches;
wenzelm
parents: 69313
diff changeset
    17
  certain named from \<^theory>\<open>Complex_Main\<close>.
68484
59793df7f853 clarified document antiquotation @{theory};
wenzelm
parents: 68406
diff changeset
    18
\<close>
62376
85f38d5f8807 Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents: 62371
diff changeset
    19
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
    20
lemma incseq_sumI2:
62376
85f38d5f8807 Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents: 62371
diff changeset
    21
  fixes f :: "'i \<Rightarrow> nat \<Rightarrow> 'a::ordered_comm_monoid_add"
85f38d5f8807 Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents: 62371
diff changeset
    22
  shows "(\<And>n. n \<in> A \<Longrightarrow> mono (f n)) \<Longrightarrow> mono (\<lambda>i. \<Sum>n\<in>A. f n i)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
    23
  unfolding incseq_def by (auto intro: sum_mono)
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
    24
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
    25
lemma incseq_sumI:
62376
85f38d5f8807 Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents: 62371
diff changeset
    26
  fixes f :: "nat \<Rightarrow> 'a::ordered_comm_monoid_add"
85f38d5f8807 Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents: 62371
diff changeset
    27
  assumes "\<And>i. 0 \<le> f i"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
    28
  shows "incseq (\<lambda>i. sum f {..< i})"
62376
85f38d5f8807 Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents: 62371
diff changeset
    29
proof (intro incseq_SucI)
85f38d5f8807 Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents: 62371
diff changeset
    30
  fix n
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
    31
  have "sum f {..< n} + 0 \<le> sum f {..<n} + f n"
62376
85f38d5f8807 Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents: 62371
diff changeset
    32
    using assms by (rule add_left_mono)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
    33
  then show "sum f {..< n} \<le> sum f {..< Suc n}"
62376
85f38d5f8807 Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents: 62371
diff changeset
    34
    by auto
85f38d5f8807 Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents: 62371
diff changeset
    35
qed
85f38d5f8807 Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents: 62371
diff changeset
    36
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    37
lemma continuous_at_left_imp_sup_continuous:
62378
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
    38
  fixes f :: "'a::{complete_linorder, linorder_topology} \<Rightarrow> 'b::{complete_linorder, linorder_topology}"
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    39
  assumes "mono f" "\<And>x. continuous (at_left x) f"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    40
  shows "sup_continuous f"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    41
  unfolding sup_continuous_def
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    42
proof safe
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    43
  fix M :: "nat \<Rightarrow> 'a" assume "incseq M" then show "f (SUP i. M i) = (SUP i. f (M i))"
69861
62e47f06d22c avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
haftmann
parents: 69661
diff changeset
    44
    using continuous_at_Sup_mono [OF assms, of "range M"] by (simp add: image_comp)
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    45
qed
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    46
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    47
lemma sup_continuous_at_left:
62378
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
    48
  fixes f :: "'a::{complete_linorder, linorder_topology, first_countable_topology} \<Rightarrow>
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
    49
    'b::{complete_linorder, linorder_topology}"
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    50
  assumes f: "sup_continuous f"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    51
  shows "continuous (at_left x) f"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    52
proof cases
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    53
  assume "x = bot" then show ?thesis
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    54
    by (simp add: trivial_limit_at_left_bot)
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    55
next
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
    56
  assume x: "x \<noteq> bot"
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    57
  show ?thesis
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    58
    unfolding continuous_within
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    59
  proof (intro tendsto_at_left_sequentially[of bot])
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
    60
    fix S :: "nat \<Rightarrow> 'a" assume S: "incseq S" and S_x: "S \<longlonglongrightarrow> x"
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    61
    from S_x have x_eq: "x = (SUP i. S i)"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    62
      by (rule LIMSEQ_unique) (intro LIMSEQ_SUP S)
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
    63
    show "(\<lambda>n. f (S n)) \<longlonglongrightarrow> f x"
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    64
      unfolding x_eq sup_continuousD[OF f S]
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    65
      using S sup_continuous_mono[OF f] by (intro LIMSEQ_SUP) (auto simp: mono_def)
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    66
  qed (insert x, auto simp: bot_less)
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    67
qed
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    68
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    69
lemma sup_continuous_iff_at_left:
62378
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
    70
  fixes f :: "'a::{complete_linorder, linorder_topology, first_countable_topology} \<Rightarrow>
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
    71
    'b::{complete_linorder, linorder_topology}"
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    72
  shows "sup_continuous f \<longleftrightarrow> (\<forall>x. continuous (at_left x) f) \<and> mono f"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    73
  using sup_continuous_at_left[of f] continuous_at_left_imp_sup_continuous[of f]
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    74
    sup_continuous_mono[of f] by auto
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
    75
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    76
lemma continuous_at_right_imp_inf_continuous:
62378
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
    77
  fixes f :: "'a::{complete_linorder, linorder_topology} \<Rightarrow> 'b::{complete_linorder, linorder_topology}"
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    78
  assumes "mono f" "\<And>x. continuous (at_right x) f"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    79
  shows "inf_continuous f"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    80
  unfolding inf_continuous_def
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    81
proof safe
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    82
  fix M :: "nat \<Rightarrow> 'a" assume "decseq M" then show "f (INF i. M i) = (INF i. f (M i))"
69861
62e47f06d22c avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
haftmann
parents: 69661
diff changeset
    83
    using continuous_at_Inf_mono [OF assms, of "range M"] by (simp add: image_comp)
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    84
qed
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    85
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    86
lemma inf_continuous_at_right:
62378
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
    87
  fixes f :: "'a::{complete_linorder, linorder_topology, first_countable_topology} \<Rightarrow>
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
    88
    'b::{complete_linorder, linorder_topology}"
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    89
  assumes f: "inf_continuous f"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    90
  shows "continuous (at_right x) f"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    91
proof cases
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    92
  assume "x = top" then show ?thesis
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    93
    by (simp add: trivial_limit_at_right_top)
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    94
next
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
    95
  assume x: "x \<noteq> top"
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    96
  show ?thesis
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    97
    unfolding continuous_within
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    98
  proof (intro tendsto_at_right_sequentially[of _ top])
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
    99
    fix S :: "nat \<Rightarrow> 'a" assume S: "decseq S" and S_x: "S \<longlonglongrightarrow> x"
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   100
    from S_x have x_eq: "x = (INF i. S i)"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   101
      by (rule LIMSEQ_unique) (intro LIMSEQ_INF S)
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
   102
    show "(\<lambda>n. f (S n)) \<longlonglongrightarrow> f x"
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   103
      unfolding x_eq inf_continuousD[OF f S]
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   104
      using S inf_continuous_mono[OF f] by (intro LIMSEQ_INF) (auto simp: mono_def antimono_def)
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   105
  qed (insert x, auto simp: less_top)
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   106
qed
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   107
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   108
lemma inf_continuous_iff_at_right:
62378
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
   109
  fixes f :: "'a::{complete_linorder, linorder_topology, first_countable_topology} \<Rightarrow>
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
   110
    'b::{complete_linorder, linorder_topology}"
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   111
  shows "inf_continuous f \<longleftrightarrow> (\<forall>x. continuous (at_right x) f) \<and> mono f"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   112
  using inf_continuous_at_right[of f] continuous_at_right_imp_inf_continuous[of f]
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   113
    inf_continuous_mono[of f] by auto
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   114
59115
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   115
instantiation enat :: linorder_topology
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   116
begin
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   117
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   118
definition open_enat :: "enat set \<Rightarrow> bool" where
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   119
  "open_enat = generate_topology (range lessThan \<union> range greaterThan)"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   120
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   121
instance
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   122
  proof qed (rule open_enat_def)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   123
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   124
end
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   125
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   126
lemma open_enat: "open {enat n}"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   127
proof (cases n)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   128
  case 0
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   129
  then have "{enat n} = {..< eSuc 0}"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   130
    by (auto simp: enat_0)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   131
  then show ?thesis
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   132
    by simp
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   133
next
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   134
  case (Suc n')
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   135
  then have "{enat n} = {enat n' <..< enat (Suc n)}"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   136
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   137
    apply (case_tac x)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   138
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   139
    done
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   140
  then show ?thesis
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   141
    by simp
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   142
qed
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   143
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   144
lemma open_enat_iff:
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   145
  fixes A :: "enat set"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   146
  shows "open A \<longleftrightarrow> (\<infinity> \<in> A \<longrightarrow> (\<exists>n::nat. {n <..} \<subseteq> A))"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   147
proof safe
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   148
  assume "\<infinity> \<notin> A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   149
  then have "A = (\<Union>n\<in>{n. enat n \<in> A}. {enat n})"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   150
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   151
    apply (case_tac x)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   152
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   153
    done
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   154
  moreover have "open \<dots>"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   155
    by (auto intro: open_enat)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   156
  ultimately show "open A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   157
    by simp
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   158
next
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   159
  fix n assume "{enat n <..} \<subseteq> A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   160
  then have "A = (\<Union>n\<in>{n. enat n \<in> A}. {enat n}) \<union> {enat n <..}"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   161
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   162
    apply (case_tac x)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   163
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   164
    done
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   165
  moreover have "open \<dots>"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   166
    by (intro open_Un open_UN ballI open_enat open_greaterThan)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   167
  ultimately show "open A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   168
    by simp
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   169
next
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   170
  assume "open A" "\<infinity> \<in> A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   171
  then have "generate_topology (range lessThan \<union> range greaterThan) A" "\<infinity> \<in> A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   172
    unfolding open_enat_def by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   173
  then show "\<exists>n::nat. {n <..} \<subseteq> A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   174
  proof induction
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   175
    case (Int A B)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   176
    then obtain n m where "{enat n<..} \<subseteq> A" "{enat m<..} \<subseteq> B"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   177
      by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   178
    then have "{enat (max n m) <..} \<subseteq> A \<inter> B"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 68356
diff changeset
   179
      by (auto simp add: subset_eq Ball_def max_def simp flip: enat_ord_code(1))
59115
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   180
    then show ?case
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   181
      by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   182
  next
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   183
    case (UN K)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   184
    then obtain k where "k \<in> K" "\<infinity> \<in> k"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   185
      by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   186
    with UN.IH[OF this] show ?case
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   187
      by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   188
  qed auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   189
qed
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   190
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   191
lemma nhds_enat: "nhds x = (if x = \<infinity> then INF i. principal {enat i..} else principal {x})"
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   192
proof auto
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   193
  show "nhds \<infinity> = (INF i. principal {enat i..})"
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   194
    unfolding nhds_def
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   195
    apply (auto intro!: antisym INF_greatest simp add: open_enat_iff cong: rev_conj_cong)
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   196
    apply (auto intro!: INF_lower Ioi_le_Ico) []
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   197
    subgoal for x i
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   198
      by (auto intro!: INF_lower2[of "Suc i"] simp: subset_eq Ball_def eSuc_enat Suc_ile_eq)
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   199
    done
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   200
  show "nhds (enat i) = principal {enat i}" for i
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   201
    by (simp add: nhds_discrete_open open_enat)
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   202
qed
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   203
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   204
instance enat :: topological_comm_monoid_add
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   205
proof
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   206
  have [simp]: "enat i \<le> aa \<Longrightarrow> enat i \<le> aa + ba" for aa ba i
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   207
    by (rule order_trans[OF _ add_mono[of aa aa 0 ba]]) auto
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   208
  then have [simp]: "enat i \<le> ba \<Longrightarrow> enat i \<le> aa + ba" for aa ba i
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   209
    by (metis add.commute)
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   210
  fix a b :: enat show "((\<lambda>x. fst x + snd x) \<longlongrightarrow> a + b) (nhds a \<times>\<^sub>F nhds b)"
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   211
    apply (auto simp: nhds_enat filterlim_INF prod_filter_INF1 prod_filter_INF2
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   212
                      filterlim_principal principal_prod_principal eventually_principal)
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   213
    subgoal for i
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   214
      by (auto intro!: eventually_INF1[of i] simp: eventually_principal)
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   215
    subgoal for j i
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   216
      by (auto intro!: eventually_INF1[of i] simp: eventually_principal)
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   217
    subgoal for j i
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   218
      by (auto intro!: eventually_INF1[of i] simp: eventually_principal)
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   219
    done
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   220
qed
59115
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   221
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   222
text \<open>
63680
6e1e8b5abbfa more symbols;
wenzelm
parents: 63627
diff changeset
   223
  For more lemmas about the extended real numbers see
6e1e8b5abbfa more symbols;
wenzelm
parents: 63627
diff changeset
   224
  \<^file>\<open>~~/src/HOL/Analysis/Extended_Real_Limits.thy\<close>.
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   225
\<close>
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   226
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   227
subsection \<open>Definition and basic properties\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   228
58310
91ea607a34d8 updated news
blanchet
parents: 58249
diff changeset
   229
datatype ereal = ereal real | PInfty | MInfty
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   230
63099
af0e964aad7b Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents: 63092
diff changeset
   231
lemma ereal_cong: "x = y \<Longrightarrow> ereal x = ereal y" by simp
af0e964aad7b Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents: 63092
diff changeset
   232
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   233
instantiation ereal :: uminus
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   234
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   235
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   236
fun uminus_ereal where
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   237
  "- (ereal r) = ereal (- r)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   238
| "- PInfty = MInfty"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   239
| "- MInfty = PInfty"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   240
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   241
instance ..
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   242
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   243
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   244
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   245
instantiation ereal :: infinity
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   246
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   247
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   248
definition "(\<infinity>::ereal) = PInfty"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   249
instance ..
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   250
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   251
end
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   252
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   253
declare [[coercion "ereal :: real \<Rightarrow> ereal"]]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   254
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   255
lemma ereal_uminus_uminus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   256
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   257
  shows "- (- a) = a"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   258
  by (cases a) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   259
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   260
lemma
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   261
  shows PInfty_eq_infinity[simp]: "PInfty = \<infinity>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   262
    and MInfty_eq_minfinity[simp]: "MInfty = - \<infinity>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   263
    and MInfty_neq_PInfty[simp]: "\<infinity> \<noteq> - (\<infinity>::ereal)" "- \<infinity> \<noteq> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   264
    and MInfty_neq_ereal[simp]: "ereal r \<noteq> - \<infinity>" "- \<infinity> \<noteq> ereal r"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   265
    and PInfty_neq_ereal[simp]: "ereal r \<noteq> \<infinity>" "\<infinity> \<noteq> ereal r"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   266
    and PInfty_cases[simp]: "(case \<infinity> of ereal r \<Rightarrow> f r | PInfty \<Rightarrow> y | MInfty \<Rightarrow> z) = y"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   267
    and MInfty_cases[simp]: "(case - \<infinity> of ereal r \<Rightarrow> f r | PInfty \<Rightarrow> y | MInfty \<Rightarrow> z) = z"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   268
  by (simp_all add: infinity_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   269
43933
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   270
declare
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   271
  PInfty_eq_infinity[code_post]
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   272
  MInfty_eq_minfinity[code_post]
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   273
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   274
lemma [code_unfold]:
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   275
  "\<infinity> = PInfty"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   276
  "- PInfty = MInfty"
43933
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   277
  by simp_all
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   278
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   279
lemma inj_ereal[simp]: "inj_on ereal A"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   280
  unfolding inj_on_def by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   281
55913
c1409c103b77 proper UTF-8;
wenzelm
parents: 54863
diff changeset
   282
lemma ereal_cases[cases type: ereal]:
c1409c103b77 proper UTF-8;
wenzelm
parents: 54863
diff changeset
   283
  obtains (real) r where "x = ereal r"
c1409c103b77 proper UTF-8;
wenzelm
parents: 54863
diff changeset
   284
    | (PInf) "x = \<infinity>"
c1409c103b77 proper UTF-8;
wenzelm
parents: 54863
diff changeset
   285
    | (MInf) "x = -\<infinity>"
63092
a949b2a5f51d eliminated use of empty "assms";
wenzelm
parents: 63060
diff changeset
   286
  by (cases x) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   287
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   288
lemmas ereal2_cases = ereal_cases[case_product ereal_cases]
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   289
lemmas ereal3_cases = ereal2_cases[case_product ereal_cases]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   290
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 57025
diff changeset
   291
lemma ereal_all_split: "\<And>P. (\<forall>x::ereal. P x) \<longleftrightarrow> P \<infinity> \<and> (\<forall>x. P (ereal x)) \<and> P (-\<infinity>)"
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 57025
diff changeset
   292
  by (metis ereal_cases)
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 57025
diff changeset
   293
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 57025
diff changeset
   294
lemma ereal_ex_split: "\<And>P. (\<exists>x::ereal. P x) \<longleftrightarrow> P \<infinity> \<or> (\<exists>x. P (ereal x)) \<or> P (-\<infinity>)"
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 57025
diff changeset
   295
  by (metis ereal_cases)
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 57025
diff changeset
   296
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   297
lemma ereal_uminus_eq_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   298
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   299
  shows "-a = -b \<longleftrightarrow> a = b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   300
  by (cases rule: ereal2_cases[of a b]) simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   301
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   302
function real_of_ereal :: "ereal \<Rightarrow> real" where
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   303
  "real_of_ereal (ereal r) = r"
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   304
| "real_of_ereal \<infinity> = 0"
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   305
| "real_of_ereal (-\<infinity>) = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   306
  by (auto intro: ereal_cases)
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   307
termination by standard (rule wf_empty)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   308
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   309
lemma real_of_ereal[simp]:
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   310
  "real_of_ereal (- x :: ereal) = - (real_of_ereal x)"
58042
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   311
  by (cases x) simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   312
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   313
lemma range_ereal[simp]: "range ereal = UNIV - {\<infinity>, -\<infinity>}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   314
proof safe
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   315
  fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   316
  assume "x \<notin> range ereal" "x \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   317
  then show "x = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   318
    by (cases x) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   319
qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   320
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   321
lemma ereal_range_uminus[simp]: "range uminus = (UNIV::ereal set)"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   322
proof safe
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   323
  fix x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   324
  show "x \<in> range uminus"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   325
    by (intro image_eqI[of _ _ "-x"]) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   326
qed auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   327
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   328
instantiation ereal :: abs
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   329
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   330
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   331
function abs_ereal where
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   332
  "\<bar>ereal r\<bar> = ereal \<bar>r\<bar>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   333
| "\<bar>-\<infinity>\<bar> = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   334
| "\<bar>\<infinity>\<bar> = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   335
by (auto intro: ereal_cases)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   336
termination proof qed (rule wf_empty)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   337
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   338
instance ..
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   339
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   340
end
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   341
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   342
lemma abs_eq_infinity_cases[elim!]:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   343
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   344
  assumes "\<bar>x\<bar> = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   345
  obtains "x = \<infinity>" | "x = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   346
  using assms by (cases x) auto
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   347
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   348
lemma abs_neq_infinity_cases[elim!]:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   349
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   350
  assumes "\<bar>x\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   351
  obtains r where "x = ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   352
  using assms by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   353
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   354
lemma abs_ereal_uminus[simp]:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   355
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   356
  shows "\<bar>- x\<bar> = \<bar>x\<bar>"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   357
  by (cases x) auto
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   358
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   359
lemma ereal_infinity_cases:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   360
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   361
  shows "a \<noteq> \<infinity> \<Longrightarrow> a \<noteq> -\<infinity> \<Longrightarrow> \<bar>a\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   362
  by auto
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   363
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   364
subsubsection "Addition"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   365
54408
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 53873
diff changeset
   366
instantiation ereal :: "{one,comm_monoid_add,zero_neq_one}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   367
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   368
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   369
definition "0 = ereal 0"
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   370
definition "1 = ereal 1"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   371
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   372
function plus_ereal where
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   373
  "ereal r + ereal p = ereal (r + p)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   374
| "\<infinity> + a = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   375
| "a + \<infinity> = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   376
| "ereal r + -\<infinity> = - \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   377
| "-\<infinity> + ereal p = -(\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   378
| "-\<infinity> + -\<infinity> = -(\<infinity>::ereal)"
61166
5976fe402824 renamed method "goals" to "goal_cases" to emphasize its meaning;
wenzelm
parents: 61120
diff changeset
   379
proof goal_cases
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   380
  case prems: (1 P x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   381
  then obtain a b where "x = (a, b)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   382
    by (cases x) auto
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   383
  with prems show P
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   384
   by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   385
qed auto
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   386
termination by standard (rule wf_empty)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   387
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   388
lemma Infty_neq_0[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   389
  "(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   390
  "-(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> -(\<infinity>::ereal)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   391
  by (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   392
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   393
lemma ereal_eq_0[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   394
  "ereal r = 0 \<longleftrightarrow> r = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   395
  "0 = ereal r \<longleftrightarrow> r = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   396
  unfolding zero_ereal_def by simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   397
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   398
lemma ereal_eq_1[simp]:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   399
  "ereal r = 1 \<longleftrightarrow> r = 1"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   400
  "1 = ereal r \<longleftrightarrow> r = 1"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   401
  unfolding one_ereal_def by simp_all
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   402
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   403
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   404
proof
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   405
  fix a b c :: ereal
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   406
  show "0 + a = a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   407
    by (cases a) (simp_all add: zero_ereal_def)
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   408
  show "a + b = b + a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   409
    by (cases rule: ereal2_cases[of a b]) simp_all
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   410
  show "a + b + c = a + (b + c)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   411
    by (cases rule: ereal3_cases[of a b c]) simp_all
54408
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 53873
diff changeset
   412
  show "0 \<noteq> (1::ereal)"
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 53873
diff changeset
   413
    by (simp add: one_ereal_def zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   414
qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   415
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   416
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   417
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   418
lemma ereal_0_plus [simp]: "ereal 0 + x = x"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   419
  and plus_ereal_0 [simp]: "x + ereal 0 = x"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 68356
diff changeset
   420
by(simp_all flip: zero_ereal_def)
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   421
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   422
instance ereal :: numeral ..
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   423
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   424
lemma real_of_ereal_0[simp]: "real_of_ereal (0::ereal) = 0"
58042
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   425
  unfolding zero_ereal_def by simp
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   426
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   427
lemma abs_ereal_zero[simp]: "\<bar>0\<bar> = (0::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   428
  unfolding zero_ereal_def abs_ereal.simps by simp
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   429
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   430
lemma ereal_uminus_zero[simp]: "- 0 = (0::ereal)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   431
  by (simp add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   432
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   433
lemma ereal_uminus_zero_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   434
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   435
  shows "-a = 0 \<longleftrightarrow> a = 0"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   436
  by (cases a) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   437
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   438
lemma ereal_plus_eq_PInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   439
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   440
  shows "a + b = \<infinity> \<longleftrightarrow> a = \<infinity> \<or> b = \<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   441
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   442
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   443
lemma ereal_plus_eq_MInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   444
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   445
  shows "a + b = -\<infinity> \<longleftrightarrow> (a = -\<infinity> \<or> b = -\<infinity>) \<and> a \<noteq> \<infinity> \<and> b \<noteq> \<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   446
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   447
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   448
lemma ereal_add_cancel_left:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   449
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   450
  assumes "a \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   451
  shows "a + b = a + c \<longleftrightarrow> a = \<infinity> \<or> b = c"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   452
  using assms by (cases rule: ereal3_cases[of a b c]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   453
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   454
lemma ereal_add_cancel_right:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   455
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   456
  assumes "a \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   457
  shows "b + a = c + a \<longleftrightarrow> a = \<infinity> \<or> b = c"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   458
  using assms by (cases rule: ereal3_cases[of a b c]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   459
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   460
lemma ereal_real: "ereal (real_of_ereal x) = (if \<bar>x\<bar> = \<infinity> then 0 else x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   461
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   462
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   463
lemma real_of_ereal_add:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   464
  fixes a b :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   465
  shows "real_of_ereal (a + b) =
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   466
    (if (\<bar>a\<bar> = \<infinity>) \<and> (\<bar>b\<bar> = \<infinity>) \<or> (\<bar>a\<bar> \<noteq> \<infinity>) \<and> (\<bar>b\<bar> \<noteq> \<infinity>) then real_of_ereal a + real_of_ereal b else 0)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   467
  by (cases rule: ereal2_cases[of a b]) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   468
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   469
69593
3dda49e08b9d isabelle update -u control_cartouches;
wenzelm
parents: 69313
diff changeset
   470
subsubsection "Linear order on \<^typ>\<open>ereal\<close>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   471
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   472
instantiation ereal :: linorder
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   473
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   474
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   475
function less_ereal
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   476
where
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   477
  "   ereal x < ereal y     \<longleftrightarrow> x < y"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   478
| "(\<infinity>::ereal) < a           \<longleftrightarrow> False"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   479
| "         a < -(\<infinity>::ereal) \<longleftrightarrow> False"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   480
| "ereal x    < \<infinity>           \<longleftrightarrow> True"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   481
| "        -\<infinity> < ereal r     \<longleftrightarrow> True"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   482
| "        -\<infinity> < (\<infinity>::ereal) \<longleftrightarrow> True"
61166
5976fe402824 renamed method "goals" to "goal_cases" to emphasize its meaning;
wenzelm
parents: 61120
diff changeset
   483
proof goal_cases
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   484
  case prems: (1 P x)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
   485
  then obtain a b where "x = (a,b)" by (cases x) auto
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   486
  with prems show P by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   487
qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   488
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   489
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   490
definition "x \<le> (y::ereal) \<longleftrightarrow> x < y \<or> x = y"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   491
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   492
lemma ereal_infty_less[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   493
  fixes x :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   494
  shows "x < \<infinity> \<longleftrightarrow> (x \<noteq> \<infinity>)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   495
    "-\<infinity> < x \<longleftrightarrow> (x \<noteq> -\<infinity>)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   496
  by (cases x, simp_all) (cases x, simp_all)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   497
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   498
lemma ereal_infty_less_eq[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   499
  fixes x :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   500
  shows "\<infinity> \<le> x \<longleftrightarrow> x = \<infinity>"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   501
    and "x \<le> -\<infinity> \<longleftrightarrow> x = -\<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   502
  by (auto simp add: less_eq_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   503
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   504
lemma ereal_less[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   505
  "ereal r < 0 \<longleftrightarrow> (r < 0)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   506
  "0 < ereal r \<longleftrightarrow> (0 < r)"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   507
  "ereal r < 1 \<longleftrightarrow> (r < 1)"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   508
  "1 < ereal r \<longleftrightarrow> (1 < r)"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   509
  "0 < (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   510
  "-(\<infinity>::ereal) < 0"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   511
  by (simp_all add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   512
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   513
lemma ereal_less_eq[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   514
  "x \<le> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   515
  "-(\<infinity>::ereal) \<le> x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   516
  "ereal r \<le> ereal p \<longleftrightarrow> r \<le> p"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   517
  "ereal r \<le> 0 \<longleftrightarrow> r \<le> 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   518
  "0 \<le> ereal r \<longleftrightarrow> 0 \<le> r"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   519
  "ereal r \<le> 1 \<longleftrightarrow> r \<le> 1"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   520
  "1 \<le> ereal r \<longleftrightarrow> 1 \<le> r"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   521
  by (auto simp add: less_eq_ereal_def zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   522
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   523
lemma ereal_infty_less_eq2:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   524
  "a \<le> b \<Longrightarrow> a = \<infinity> \<Longrightarrow> b = (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   525
  "a \<le> b \<Longrightarrow> b = -\<infinity> \<Longrightarrow> a = -(\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   526
  by simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   527
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   528
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   529
proof
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   530
  fix x y z :: ereal
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   531
  show "x \<le> x"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   532
    by (cases x) simp_all
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   533
  show "x < y \<longleftrightarrow> x \<le> y \<and> \<not> y \<le> x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   534
    by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   535
  show "x \<le> y \<or> y \<le> x "
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   536
    by (cases rule: ereal2_cases[of x y]) auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   537
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   538
    assume "x \<le> y" "y \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   539
    then show "x = y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   540
      by (cases rule: ereal2_cases[of x y]) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   541
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   542
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   543
    assume "x \<le> y" "y \<le> z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   544
    then show "x \<le> z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   545
      by (cases rule: ereal3_cases[of x y z]) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   546
  }
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   547
qed
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   548
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   549
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   550
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
   551
lemma ereal_dense2: "x < y \<Longrightarrow> \<exists>z. x < ereal z \<and> ereal z < y"
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
   552
  using lt_ex gt_ex dense by (cases x y rule: ereal2_cases) auto
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
   553
53216
ad2e09c30aa8 renamed inner_dense_linorder to dense_linorder
hoelzl
parents: 52729
diff changeset
   554
instance ereal :: dense_linorder
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   555
  by standard (blast dest: ereal_dense2)
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
   556
62376
85f38d5f8807 Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents: 62371
diff changeset
   557
instance ereal :: ordered_comm_monoid_add
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   558
proof
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   559
  fix a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   560
  assume "a \<le> b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   561
  then show "c + a \<le> c + b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   562
    by (cases rule: ereal3_cases[of a b c]) auto
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   563
qed
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   564
62648
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
   565
lemma ereal_one_not_less_zero_ereal[simp]: "\<not> 1 < (0::ereal)"
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
   566
  by (simp add: zero_ereal_def)
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
   567
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   568
lemma real_of_ereal_positive_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   569
  fixes x y :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   570
  shows "0 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<noteq> \<infinity> \<Longrightarrow> real_of_ereal x \<le> real_of_ereal y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   571
  by (cases rule: ereal2_cases[of x y]) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   572
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   573
lemma ereal_MInfty_lessI[intro, simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   574
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   575
  shows "a \<noteq> -\<infinity> \<Longrightarrow> -\<infinity> < a"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   576
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   577
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   578
lemma ereal_less_PInfty[intro, simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   579
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   580
  shows "a \<noteq> \<infinity> \<Longrightarrow> a < \<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   581
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   582
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   583
lemma ereal_less_ereal_Ex:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   584
  fixes a b :: ereal
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   585
  shows "x < ereal r \<longleftrightarrow> x = -\<infinity> \<or> (\<exists>p. p < r \<and> x = ereal p)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   586
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   587
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   588
lemma less_PInf_Ex_of_nat: "x \<noteq> \<infinity> \<longleftrightarrow> (\<exists>n::nat. x < ereal (real n))"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   589
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   590
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   591
  then show ?thesis
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
   592
    using reals_Archimedean2[of r] by simp
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   593
qed simp_all
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   594
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   595
lemma ereal_add_strict_mono2:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   596
  fixes a b c d :: ereal
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   597
  assumes "a < b"
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   598
    and "c < d"
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   599
  shows "a + c < b + d"
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   600
using assms
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   601
apply (cases a)
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   602
apply (cases rule: ereal3_cases[of b c d], auto)
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   603
apply (cases rule: ereal3_cases[of b c d], auto)
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   604
done
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   605
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   606
lemma ereal_minus_le_minus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   607
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   608
  shows "- a \<le> - b \<longleftrightarrow> b \<le> a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   609
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   610
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   611
lemma ereal_minus_less_minus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   612
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   613
  shows "- a < - b \<longleftrightarrow> b < a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   614
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   615
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   616
lemma ereal_le_real_iff:
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   617
  "x \<le> real_of_ereal y \<longleftrightarrow> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> ereal x \<le> y) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> x \<le> 0)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   618
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   619
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   620
lemma real_le_ereal_iff:
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   621
  "real_of_ereal y \<le> x \<longleftrightarrow> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> y \<le> ereal x) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> 0 \<le> x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   622
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   623
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   624
lemma ereal_less_real_iff:
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   625
  "x < real_of_ereal y \<longleftrightarrow> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> ereal x < y) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> x < 0)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   626
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   627
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   628
lemma real_less_ereal_iff:
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   629
  "real_of_ereal y < x \<longleftrightarrow> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> y < ereal x) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> 0 < x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   630
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   631
68356
46d5a9f428e1 more formal comments;
wenzelm
parents: 68095
diff changeset
   632
text \<open>
46d5a9f428e1 more formal comments;
wenzelm
parents: 68095
diff changeset
   633
  To help with inferences like \<^prop>\<open>a < ereal x \<Longrightarrow> x < y \<Longrightarrow> a < ereal y\<close>,
68095
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   634
  where x and y are real.
68356
46d5a9f428e1 more formal comments;
wenzelm
parents: 68095
diff changeset
   635
\<close>
68095
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   636
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   637
lemma le_ereal_le: "a \<le> ereal x \<Longrightarrow> x \<le> y \<Longrightarrow> a \<le> ereal y"
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   638
  using ereal_less_eq(3) order.trans by blast
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   639
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   640
lemma le_ereal_less: "a \<le> ereal x \<Longrightarrow> x < y \<Longrightarrow> a < ereal y"
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   641
  by (simp add: le_less_trans)
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   642
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   643
lemma less_ereal_le: "a < ereal x \<Longrightarrow> x \<le> y \<Longrightarrow> a < ereal y"
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   644
  using ereal_less_ereal_Ex by auto
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   645
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   646
lemma ereal_le_le: "ereal y \<le> a \<Longrightarrow> x \<le> y \<Longrightarrow> ereal x \<le> a"
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   647
  by (simp add: order_subst2)
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   648
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   649
lemma ereal_le_less: "ereal y \<le> a \<Longrightarrow> x < y \<Longrightarrow> ereal x < a"
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   650
  by (simp add: dual_order.strict_trans1)
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   651
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   652
lemma ereal_less_le: "ereal y < a \<Longrightarrow> x \<le> y \<Longrightarrow> ereal x < a"
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   653
  using ereal_less_eq(3) le_less_trans by blast
4fa3e63ecc7e starting to tidy up Interval_Integral.thy
paulson <lp15@cam.ac.uk>
parents: 67727
diff changeset
   654
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   655
lemma real_of_ereal_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   656
  fixes x :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   657
  shows "0 \<le> x \<Longrightarrow> 0 \<le> real_of_ereal x" by (cases x) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   658
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   659
lemmas real_of_ereal_ord_simps =
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   660
  ereal_le_real_iff real_le_ereal_iff ereal_less_real_iff real_less_ereal_iff
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   661
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   662
lemma abs_ereal_ge0[simp]: "0 \<le> x \<Longrightarrow> \<bar>x :: ereal\<bar> = x"
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   663
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   664
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   665
lemma abs_ereal_less0[simp]: "x < 0 \<Longrightarrow> \<bar>x :: ereal\<bar> = -x"
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   666
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   667
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   668
lemma abs_ereal_pos[simp]: "0 \<le> \<bar>x :: ereal\<bar>"
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   669
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   670
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   671
lemma ereal_abs_leI:
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
   672
  fixes x y :: ereal
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   673
  shows "\<lbrakk> x \<le> y; -x \<le> y \<rbrakk> \<Longrightarrow> \<bar>x\<bar> \<le> y"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   674
by(cases x y rule: ereal2_cases)(simp_all)
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   675
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   676
lemma ereal_abs_add:
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   677
  fixes a b::ereal
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   678
  shows "abs(a+b) \<le> abs a + abs b"
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   679
by (cases rule: ereal2_cases[of a b]) (auto)
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
   680
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   681
lemma real_of_ereal_le_0[simp]: "real_of_ereal (x :: ereal) \<le> 0 \<longleftrightarrow> x \<le> 0 \<or> x = \<infinity>"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   682
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   683
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   684
lemma abs_real_of_ereal[simp]: "\<bar>real_of_ereal (x :: ereal)\<bar> = real_of_ereal \<bar>x\<bar>"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   685
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   686
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   687
lemma zero_less_real_of_ereal:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   688
  fixes x :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   689
  shows "0 < real_of_ereal x \<longleftrightarrow> 0 < x \<and> x \<noteq> \<infinity>"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   690
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   691
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   692
lemma ereal_0_le_uminus_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   693
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   694
  shows "0 \<le> - a \<longleftrightarrow> a \<le> 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   695
  by (cases rule: ereal2_cases[of a]) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   696
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   697
lemma ereal_uminus_le_0_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   698
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   699
  shows "- a \<le> 0 \<longleftrightarrow> 0 \<le> a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   700
  by (cases rule: ereal2_cases[of a]) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   701
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   702
lemma ereal_add_strict_mono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   703
  fixes a b c d :: ereal
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
   704
  assumes "a \<le> b"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   705
    and "0 \<le> a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   706
    and "a \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   707
    and "c < d"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   708
  shows "a + c < b + d"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   709
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   710
  by (cases rule: ereal3_cases[case_product ereal_cases, of a b c d]) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   711
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   712
lemma ereal_less_add:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   713
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   714
  shows "\<bar>a\<bar> \<noteq> \<infinity> \<Longrightarrow> c < b \<Longrightarrow> a + c < a + b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   715
  by (cases rule: ereal2_cases[of b c]) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   716
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   717
lemma ereal_add_nonneg_eq_0_iff:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   718
  fixes a b :: ereal
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   719
  shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> a + b = 0 \<longleftrightarrow> a = 0 \<and> b = 0"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   720
  by (cases a b rule: ereal2_cases) auto
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   721
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   722
lemma ereal_uminus_eq_reorder: "- a = b \<longleftrightarrow> a = (-b::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   723
  by auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   724
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   725
lemma ereal_uminus_less_reorder: "- a < b \<longleftrightarrow> -b < (a::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   726
  by (subst (3) ereal_uminus_uminus[symmetric]) (simp only: ereal_minus_less_minus)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   727
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
   728
lemma ereal_less_uminus_reorder: "a < - b \<longleftrightarrow> b < - (a::ereal)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
   729
  by (subst (3) ereal_uminus_uminus[symmetric]) (simp only: ereal_minus_less_minus)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
   730
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   731
lemma ereal_uminus_le_reorder: "- a \<le> b \<longleftrightarrow> -b \<le> (a::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   732
  by (subst (3) ereal_uminus_uminus[symmetric]) (simp only: ereal_minus_le_minus)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   733
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   734
lemmas ereal_uminus_reorder =
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   735
  ereal_uminus_eq_reorder ereal_uminus_less_reorder ereal_uminus_le_reorder
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   736
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   737
lemma ereal_bot:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   738
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   739
  assumes "\<And>B. x \<le> ereal B"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   740
  shows "x = - \<infinity>"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   741
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   742
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   743
  with assms[of "r - 1"] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   744
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   745
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   746
  case PInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   747
  with assms[of 0] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   748
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   749
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   750
  case MInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   751
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   752
    by simp
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   753
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   754
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   755
lemma ereal_top:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   756
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   757
  assumes "\<And>B. x \<ge> ereal B"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   758
  shows "x = \<infinity>"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   759
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   760
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   761
  with assms[of "r + 1"] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   762
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   763
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   764
  case MInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   765
  with assms[of 0] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   766
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   767
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   768
  case PInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   769
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   770
    by simp
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   771
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   772
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   773
lemma
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   774
  shows ereal_max[simp]: "ereal (max x y) = max (ereal x) (ereal y)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   775
    and ereal_min[simp]: "ereal (min x y) = min (ereal x) (ereal y)"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   776
  by (simp_all add: min_def max_def)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   777
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   778
lemma ereal_max_0: "max 0 (ereal r) = ereal (max 0 r)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   779
  by (auto simp: zero_ereal_def)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   780
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   781
lemma
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   782
  fixes f :: "nat \<Rightarrow> ereal"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   783
  shows ereal_incseq_uminus[simp]: "incseq (\<lambda>x. - f x) \<longleftrightarrow> decseq f"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   784
    and ereal_decseq_uminus[simp]: "decseq (\<lambda>x. - f x) \<longleftrightarrow> incseq f"
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   785
  unfolding decseq_def incseq_def by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   786
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   787
lemma incseq_ereal: "incseq f \<Longrightarrow> incseq (\<lambda>x. ereal (f x))"
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   788
  unfolding incseq_def by auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   789
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   790
lemma sum_ereal[simp]: "(\<Sum>x\<in>A. ereal (f x)) = ereal (\<Sum>x\<in>A. f x)"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   791
proof (cases "finite A")
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   792
  case True
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   793
  then show ?thesis by induct auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   794
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   795
  case False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   796
  then show ?thesis by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   797
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   798
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63680
diff changeset
   799
lemma sum_list_ereal [simp]: "sum_list (map (\<lambda>x. ereal (f x)) xs) = ereal (sum_list (map f xs))"
63099
af0e964aad7b Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents: 63092
diff changeset
   800
  by (induction xs) simp_all
af0e964aad7b Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents: 63092
diff changeset
   801
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   802
lemma sum_Pinfty:
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   803
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   804
  shows "(\<Sum>x\<in>P. f x) = \<infinity> \<longleftrightarrow> finite P \<and> (\<exists>i\<in>P. f i = \<infinity>)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   805
proof safe
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   806
  assume *: "sum f P = \<infinity>"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   807
  show "finite P"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   808
  proof (rule ccontr)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   809
    assume "\<not> finite P"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   810
    with * show False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   811
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   812
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   813
  show "\<exists>i\<in>P. f i = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   814
  proof (rule ccontr)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   815
    assume "\<not> ?thesis"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   816
    then have "\<And>i. i \<in> P \<Longrightarrow> f i \<noteq> \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   817
      by auto
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   818
    with \<open>finite P\<close> have "sum f P \<noteq> \<infinity>"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   819
      by induct auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   820
    with * show False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   821
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   822
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   823
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   824
  fix i
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   825
  assume "finite P" and "i \<in> P" and "f i = \<infinity>"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   826
  then show "sum f P = \<infinity>"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   827
  proof induct
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   828
    case (insert x A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   829
    show ?case using insert by (cases "x = i") auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   830
  qed simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   831
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   832
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   833
lemma sum_Inf:
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   834
  fixes f :: "'a \<Rightarrow> ereal"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   835
  shows "\<bar>sum f A\<bar> = \<infinity> \<longleftrightarrow> finite A \<and> (\<exists>i\<in>A. \<bar>f i\<bar> = \<infinity>)"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   836
proof
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   837
  assume *: "\<bar>sum f A\<bar> = \<infinity>"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   838
  have "finite A"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   839
    by (rule ccontr) (insert *, auto)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   840
  moreover have "\<exists>i\<in>A. \<bar>f i\<bar> = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   841
  proof (rule ccontr)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   842
    assume "\<not> ?thesis"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   843
    then have "\<forall>i\<in>A. \<exists>r. f i = ereal r"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   844
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   845
    from bchoice[OF this] obtain r where "\<forall>x\<in>A. f x = ereal (r x)" ..
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   846
    with * show False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   847
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   848
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   849
  ultimately show "finite A \<and> (\<exists>i\<in>A. \<bar>f i\<bar> = \<infinity>)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   850
    by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   851
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   852
  assume "finite A \<and> (\<exists>i\<in>A. \<bar>f i\<bar> = \<infinity>)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   853
  then obtain i where "finite A" "i \<in> A" and "\<bar>f i\<bar> = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   854
    by auto
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   855
  then show "\<bar>sum f A\<bar> = \<infinity>"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   856
  proof induct
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   857
    case (insert j A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   858
    then show ?case
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   859
      by (cases rule: ereal3_cases[of "f i" "f j" "sum f A"]) auto
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   860
  qed simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   861
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   862
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   863
lemma sum_real_of_ereal:
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   864
  fixes f :: "'i \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   865
  assumes "\<And>x. x \<in> S \<Longrightarrow> \<bar>f x\<bar> \<noteq> \<infinity>"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   866
  shows "(\<Sum>x\<in>S. real_of_ereal (f x)) = real_of_ereal (sum f S)"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   867
proof -
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   868
  have "\<forall>x\<in>S. \<exists>r. f x = ereal r"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   869
  proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   870
    fix x
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   871
    assume "x \<in> S"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   872
    from assms[OF this] show "\<exists>r. f x = ereal r"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   873
      by (cases "f x") auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   874
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   875
  from bchoice[OF this] obtain r where "\<forall>x\<in>S. f x = ereal (r x)" ..
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   876
  then show ?thesis
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   877
    by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   878
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   879
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   880
lemma sum_ereal_0:
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   881
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   882
  assumes "finite A"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   883
    and "\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   884
  shows "(\<Sum>x\<in>A. f x) = 0 \<longleftrightarrow> (\<forall>i\<in>A. f i = 0)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   885
proof
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   886
  assume "sum f A = 0" with assms show "\<forall>i\<in>A. f i = 0"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   887
  proof (induction A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   888
    case (insert a A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   889
    then have "f a = 0 \<and> (\<Sum>a\<in>A. f a) = 0"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   890
      by (subst ereal_add_nonneg_eq_0_iff[symmetric]) (simp_all add: sum_nonneg)
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   891
    with insert show ?case
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   892
      by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   893
  qed simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   894
qed auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   895
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   896
subsubsection "Multiplication"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   897
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   898
instantiation ereal :: "{comm_monoid_mult,sgn}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   899
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   900
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   901
function sgn_ereal :: "ereal \<Rightarrow> ereal" where
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   902
  "sgn (ereal r) = ereal (sgn r)"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   903
| "sgn (\<infinity>::ereal) = 1"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   904
| "sgn (-\<infinity>::ereal) = -1"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   905
by (auto intro: ereal_cases)
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   906
termination by standard (rule wf_empty)
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   907
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   908
function times_ereal where
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   909
  "ereal r * ereal p = ereal (r * p)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   910
| "ereal r * \<infinity> = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   911
| "\<infinity> * ereal r = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   912
| "ereal r * -\<infinity> = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   913
| "-\<infinity> * ereal r = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   914
| "(\<infinity>::ereal) * \<infinity> = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   915
| "-(\<infinity>::ereal) * \<infinity> = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   916
| "(\<infinity>::ereal) * -\<infinity> = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   917
| "-(\<infinity>::ereal) * -\<infinity> = \<infinity>"
61166
5976fe402824 renamed method "goals" to "goal_cases" to emphasize its meaning;
wenzelm
parents: 61120
diff changeset
   918
proof goal_cases
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   919
  case prems: (1 P x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   920
  then obtain a b where "x = (a, b)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   921
    by (cases x) auto
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   922
  with prems show P
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   923
    by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   924
qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   925
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   926
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   927
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   928
proof
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   929
  fix a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   930
  show "1 * a = a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   931
    by (cases a) (simp_all add: one_ereal_def)
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   932
  show "a * b = b * a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   933
    by (cases rule: ereal2_cases[of a b]) simp_all
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   934
  show "a * b * c = a * (b * c)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   935
    by (cases rule: ereal3_cases[of a b c])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   936
       (simp_all add: zero_ereal_def zero_less_mult_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   937
qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   938
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   939
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   940
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
   941
lemma [simp]:
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   942
  shows ereal_1_times: "ereal 1 * x = x"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   943
  and times_ereal_1: "x * ereal 1 = x"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 68356
diff changeset
   944
by(simp_all flip: one_ereal_def)
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   945
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   946
lemma one_not_le_zero_ereal[simp]: "\<not> (1 \<le> (0::ereal))"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   947
  by (simp add: one_ereal_def zero_ereal_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   948
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   949
lemma real_ereal_1[simp]: "real_of_ereal (1::ereal) = 1"
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
   950
  unfolding one_ereal_def by simp
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
   951
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   952
lemma real_of_ereal_le_1:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   953
  fixes a :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   954
  shows "a \<le> 1 \<Longrightarrow> real_of_ereal a \<le> 1"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   955
  by (cases a) (auto simp: one_ereal_def)
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   956
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   957
lemma abs_ereal_one[simp]: "\<bar>1\<bar> = (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   958
  unfolding one_ereal_def by simp
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   959
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   960
lemma ereal_mult_zero[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   961
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   962
  shows "a * 0 = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   963
  by (cases a) (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   964
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   965
lemma ereal_zero_mult[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   966
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   967
  shows "0 * a = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   968
  by (cases a) (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   969
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   970
lemma ereal_m1_less_0[simp]: "-(1::ereal) < 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   971
  by (simp add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   972
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   973
lemma ereal_times[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   974
  "1 \<noteq> (\<infinity>::ereal)" "(\<infinity>::ereal) \<noteq> 1"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   975
  "1 \<noteq> -(\<infinity>::ereal)" "-(\<infinity>::ereal) \<noteq> 1"
61120
65082457c117 tuned proofs;
wenzelm
parents: 60772
diff changeset
   976
  by (auto simp: one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   977
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   978
lemma ereal_plus_1[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   979
  "1 + ereal r = ereal (r + 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   980
  "ereal r + 1 = ereal (r + 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   981
  "1 + -(\<infinity>::ereal) = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   982
  "-(\<infinity>::ereal) + 1 = -\<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   983
  unfolding one_ereal_def by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   984
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   985
lemma ereal_zero_times[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   986
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   987
  shows "a * b = 0 \<longleftrightarrow> a = 0 \<or> b = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   988
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   989
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   990
lemma ereal_mult_eq_PInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   991
  "a * b = (\<infinity>::ereal) \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   992
    (a = \<infinity> \<and> b > 0) \<or> (a > 0 \<and> b = \<infinity>) \<or> (a = -\<infinity> \<and> b < 0) \<or> (a < 0 \<and> b = -\<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   993
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   994
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   995
lemma ereal_mult_eq_MInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   996
  "a * b = -(\<infinity>::ereal) \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   997
    (a = \<infinity> \<and> b < 0) \<or> (a < 0 \<and> b = \<infinity>) \<or> (a = -\<infinity> \<and> b > 0) \<or> (a > 0 \<and> b = -\<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   998
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   999
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1000
lemma ereal_abs_mult: "\<bar>x * y :: ereal\<bar> = \<bar>x\<bar> * \<bar>y\<bar>"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1001
  by (cases x y rule: ereal2_cases) (auto simp: abs_mult)
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1002
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1003
lemma ereal_0_less_1[simp]: "0 < (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1004
  by (simp_all add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1005
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1006
lemma ereal_mult_minus_left[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1007
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1008
  shows "-a * b = - (a * b)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1009
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1010
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1011
lemma ereal_mult_minus_right[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1012
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1013
  shows "a * -b = - (a * b)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1014
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1015
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1016
lemma ereal_mult_infty[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1017
  "a * (\<infinity>::ereal) = (if a = 0 then 0 else if 0 < a then \<infinity> else - \<infinity>)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1018
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1019
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1020
lemma ereal_infty_mult[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1021
  "(\<infinity>::ereal) * a = (if a = 0 then 0 else if 0 < a then \<infinity> else - \<infinity>)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1022
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1023
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1024
lemma ereal_mult_strict_right_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1025
  assumes "a < b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1026
    and "0 < c"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1027
    and "c < (\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1028
  shows "a * c < b * c"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1029
  using assms
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1030
  by (cases rule: ereal3_cases[of a b c]) (auto simp: zero_le_mult_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1031
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1032
lemma ereal_mult_strict_left_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1033
  "a < b \<Longrightarrow> 0 < c \<Longrightarrow> c < (\<infinity>::ereal) \<Longrightarrow> c * a < c * b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1034
  using ereal_mult_strict_right_mono
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57447
diff changeset
  1035
  by (simp add: mult.commute[of c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1036
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1037
lemma ereal_mult_right_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1038
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1039
  shows "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * c"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1040
  apply (cases "c = 0")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1041
  apply simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1042
  apply (cases rule: ereal3_cases[of a b c])
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1043
  apply (auto simp: zero_le_mult_iff)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1044
  done
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1045
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1046
lemma ereal_mult_left_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1047
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1048
  shows "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> c * a \<le> c * b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1049
  using ereal_mult_right_mono
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57447
diff changeset
  1050
  by (simp add: mult.commute[of c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1051
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1052
lemma ereal_mult_mono:
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1053
  fixes a b c d::ereal
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1054
  assumes "b \<ge> 0" "c \<ge> 0" "a \<le> b" "c \<le> d"
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1055
  shows "a * c \<le> b * d"
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1056
by (metis ereal_mult_right_mono mult.commute order_trans assms)
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1057
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1058
lemma ereal_mult_mono':
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1059
  fixes a b c d::ereal
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1060
  assumes "a \<ge> 0" "c \<ge> 0" "a \<le> b" "c \<le> d"
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1061
  shows "a * c \<le> b * d"
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1062
by (metis ereal_mult_right_mono mult.commute order_trans assms)
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1063
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1064
lemma ereal_mult_mono_strict:
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1065
  fixes a b c d::ereal
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1066
  assumes "b > 0" "c > 0" "a < b" "c < d"
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1067
  shows "a * c < b * d"
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1068
proof -
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1069
  have "c < \<infinity>" using \<open>c < d\<close> by auto
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1070
  then have "a * c < b * c" by (metis ereal_mult_strict_left_mono[OF assms(3) assms(2)] mult.commute)
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1071
  moreover have "b * c \<le> b * d" using assms(2) assms(4) by (simp add: assms(1) ereal_mult_left_mono less_imp_le)
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1072
  ultimately show ?thesis by simp
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1073
qed
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1074
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1075
lemma ereal_mult_mono_strict':
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1076
  fixes a b c d::ereal
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1077
  assumes "a > 0" "c > 0" "a < b" "c < d"
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1078
  shows "a * c < b * d"
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1079
apply (rule ereal_mult_mono_strict, auto simp add: assms) using assms by auto
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1080
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1081
lemma zero_less_one_ereal[simp]: "0 \<le> (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1082
  by (simp add: one_ereal_def zero_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1083
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1084
lemma ereal_0_le_mult[simp]: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a * (b :: ereal)"
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56248
diff changeset
  1085
  by (cases rule: ereal2_cases[of a b]) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1086
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1087
lemma ereal_right_distrib:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1088
  fixes r a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1089
  shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> r * (a + b) = r * a + r * b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1090
  by (cases rule: ereal3_cases[of r a b]) (simp_all add: field_simps)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1091
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1092
lemma ereal_left_distrib:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1093
  fixes r a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1094
  shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> (a + b) * r = a * r + b * r"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1095
  by (cases rule: ereal3_cases[of r a b]) (simp_all add: field_simps)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1096
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1097
lemma ereal_mult_le_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1098
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1099
  shows "a * b \<le> 0 \<longleftrightarrow> (0 \<le> a \<and> b \<le> 0) \<or> (a \<le> 0 \<and> 0 \<le> b)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1100
  by (cases rule: ereal2_cases[of a b]) (simp_all add: mult_le_0_iff)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1101
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1102
lemma ereal_zero_le_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1103
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1104
  shows "0 \<le> a * b \<longleftrightarrow> (0 \<le> a \<and> 0 \<le> b) \<or> (a \<le> 0 \<and> b \<le> 0)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1105
  by (cases rule: ereal2_cases[of a b]) (simp_all add: zero_le_mult_iff)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1106
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1107
lemma ereal_mult_less_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1108
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1109
  shows "a * b < 0 \<longleftrightarrow> (0 < a \<and> b < 0) \<or> (a < 0 \<and> 0 < b)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1110
  by (cases rule: ereal2_cases[of a b]) (simp_all add: mult_less_0_iff)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1111
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1112
lemma ereal_zero_less_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1113
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1114
  shows "0 < a * b \<longleftrightarrow> (0 < a \<and> 0 < b) \<or> (a < 0 \<and> b < 0)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1115
  by (cases rule: ereal2_cases[of a b]) (simp_all add: zero_less_mult_iff)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1116
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1117
lemma ereal_left_mult_cong:
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1118
  fixes a b c :: ereal
59002
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1119
  shows  "c = d \<Longrightarrow> (d \<noteq> 0 \<Longrightarrow> a = b) \<Longrightarrow> a * c = b * d"
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1120
  by (cases "c = 0") simp_all
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1121
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
  1122
lemma ereal_right_mult_cong:
59002
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1123
  fixes a b c :: ereal
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1124
  shows "c = d \<Longrightarrow> (d \<noteq> 0 \<Longrightarrow> a = b) \<Longrightarrow> c * a = d * b"
59002
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1125
  by (cases "c = 0") simp_all
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1126
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1127
lemma ereal_distrib:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1128
  fixes a b c :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1129
  assumes "a \<noteq> \<infinity> \<or> b \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1130
    and "a \<noteq> -\<infinity> \<or> b \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1131
    and "\<bar>c\<bar> \<noteq> \<infinity>"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1132
  shows "(a + b) * c = a * c + b * c"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1133
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1134
  by (cases rule: ereal3_cases[of a b c]) (simp_all add: field_simps)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1135
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1136
lemma numeral_eq_ereal [simp]: "numeral w = ereal (numeral w)"
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1137
  apply (induct w rule: num_induct)
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1138
  apply (simp only: numeral_One one_ereal_def)
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1139
  apply (simp only: numeral_inc ereal_plus_1)
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1140
  done
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1141
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1142
lemma distrib_left_ereal_nn:
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1143
  "c \<ge> 0 \<Longrightarrow> (x + y) * ereal c = x * ereal c + y * ereal c"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1144
by(cases x y rule: ereal2_cases)(simp_all add: ring_distribs)
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1145
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1146
lemma sum_ereal_right_distrib:
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1147
  fixes f :: "'a \<Rightarrow> ereal"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1148
  shows "(\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i) \<Longrightarrow> r * sum f A = (\<Sum>n\<in>A. r * f n)"
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1149
  by (induct A rule: infinite_finite_induct)  (auto simp: ereal_right_distrib sum_nonneg)
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1150
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1151
lemma sum_ereal_left_distrib:
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1152
  "(\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i) \<Longrightarrow> sum f A * r = (\<Sum>n\<in>A. f n * r :: ereal)"
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1153
  using sum_ereal_right_distrib[of A f r] by (simp add: mult_ac)
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1154
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1155
lemma sum_distrib_right_ereal:
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1156
  "c \<ge> 0 \<Longrightarrow> sum f A * ereal c = (\<Sum>x\<in>A. f x * c :: ereal)"
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1157
by(subst sum_comp_morphism[where h="\<lambda>x. x * ereal c", symmetric])(simp_all add: distrib_left_ereal_nn)
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1158
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1159
lemma ereal_le_epsilon:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1160
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1161
  assumes "\<forall>e. 0 < e \<longrightarrow> x \<le> y + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1162
  shows "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1163
proof -
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1164
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1165
    assume a: "\<exists>r. y = ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1166
    then obtain r where r_def: "y = ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1167
      by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1168
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1169
      assume "x = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1170
      then have ?thesis by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1171
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1172
    moreover
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1173
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1174
      assume "x \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1175
      then obtain p where p_def: "x = ereal p"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1176
      using a assms[rule_format, of 1]
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1177
        by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1178
      {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1179
        fix e
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1180
        have "0 < e \<longrightarrow> p \<le> r + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1181
          using assms[rule_format, of "ereal e"] p_def r_def by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1182
      }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1183
      then have "p \<le> r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1184
        apply (subst field_le_epsilon)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1185
        apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1186
        done
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1187
      then have ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1188
        using r_def p_def by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1189
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1190
    ultimately have ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1191
      by blast
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1192
  }
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1193
  moreover
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1194
  {
67091
1393c2340eec more symbols;
wenzelm
parents: 66936
diff changeset
  1195
    assume "y = -\<infinity> \<or> y = \<infinity>"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1196
    then have ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1197
      using assms[rule_format, of 1] by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1198
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1199
  ultimately show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1200
    by (cases y) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1201
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1202
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1203
lemma ereal_le_epsilon2:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1204
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1205
  assumes "\<forall>e. 0 < e \<longrightarrow> x \<le> y + ereal e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1206
  shows "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1207
proof -
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1208
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1209
    fix e :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1210
    assume "e > 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1211
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1212
      assume "e = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1213
      then have "x \<le> y + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1214
        by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1215
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1216
    moreover
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1217
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1218
      assume "e \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1219
      then obtain r where "e = ereal r"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1220
        using \<open>e > 0\<close> by (cases e) auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1221
      then have "x \<le> y + e"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1222
        using assms[rule_format, of r] \<open>e>0\<close> by auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1223
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1224
    ultimately have "x \<le> y + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1225
      by blast
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1226
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1227
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1228
    using ereal_le_epsilon by auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1229
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1230
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1231
lemma ereal_le_real:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1232
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1233
  assumes "\<forall>z. x \<le> ereal z \<longrightarrow> y \<le> ereal z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1234
  shows "y \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1235
  by (metis assms ereal_bot ereal_cases ereal_infty_less_eq(2) ereal_less_eq(1) linorder_le_cases)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1236
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1237
lemma prod_ereal_0:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1238
  fixes f :: "'a \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1239
  shows "(\<Prod>i\<in>A. f i) = 0 \<longleftrightarrow> finite A \<and> (\<exists>i\<in>A. f i = 0)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1240
proof (cases "finite A")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1241
  case True
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1242
  then show ?thesis by (induct A) auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1243
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1244
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1245
  then show ?thesis by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1246
qed
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1247
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1248
lemma prod_ereal_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1249
  fixes f :: "'a \<Rightarrow> ereal"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1250
  assumes pos: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1251
  shows "0 \<le> (\<Prod>i\<in>I. f i)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1252
proof (cases "finite I")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1253
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1254
  from this pos show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1255
    by induct auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1256
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1257
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1258
  then show ?thesis by simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1259
qed
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1260
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1261
lemma prod_PInf:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1262
  fixes f :: "'a \<Rightarrow> ereal"
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1263
  assumes "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1264
  shows "(\<Prod>i\<in>I. f i) = \<infinity> \<longleftrightarrow> finite I \<and> (\<exists>i\<in>I. f i = \<infinity>) \<and> (\<forall>i\<in>I. f i \<noteq> 0)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1265
proof (cases "finite I")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1266
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1267
  from this assms show ?thesis
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1268
  proof (induct I)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1269
    case (insert i I)
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1270
    then have pos: "0 \<le> f i" "0 \<le> prod f I"
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1271
      by (auto intro!: prod_ereal_pos)
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1272
    from insert have "(\<Prod>j\<in>insert i I. f j) = \<infinity> \<longleftrightarrow> prod f I * f i = \<infinity>"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1273
      by auto
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1274
    also have "\<dots> \<longleftrightarrow> (prod f I = \<infinity> \<or> f i = \<infinity>) \<and> f i \<noteq> 0 \<and> prod f I \<noteq> 0"
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1275
      using prod_ereal_pos[of I f] pos
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1276
      by (cases rule: ereal2_cases[of "f i" "prod f I"]) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1277
    also have "\<dots> \<longleftrightarrow> finite (insert i I) \<and> (\<exists>j\<in>insert i I. f j = \<infinity>) \<and> (\<forall>j\<in>insert i I. f j \<noteq> 0)"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1278
      using insert by (auto simp: prod_ereal_0)
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1279
    finally show ?case .
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1280
  qed simp
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1281
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1282
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1283
  then show ?thesis by simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1284
qed
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1285
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1286
lemma prod_ereal: "(\<Prod>i\<in>A. ereal (f i)) = ereal (prod f A)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1287
proof (cases "finite A")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1288
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1289
  then show ?thesis
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1290
    by induct (auto simp: one_ereal_def)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1291
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1292
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1293
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1294
    by (simp add: one_ereal_def)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1295
qed
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1296
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1297
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1298
subsubsection \<open>Power\<close>
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1299
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1300
lemma ereal_power[simp]: "(ereal x) ^ n = ereal (x^n)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1301
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1302
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1303
lemma ereal_power_PInf[simp]: "(\<infinity>::ereal) ^ n = (if n = 0 then 1 else \<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1304
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1305
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1306
lemma ereal_power_uminus[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1307
  fixes x :: ereal
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1308
  shows "(- x) ^ n = (if even n then x ^ n else - (x^n))"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1309
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1310
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1311
lemma ereal_power_numeral[simp]:
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1312
  "(numeral num :: ereal) ^ n = ereal (numeral num ^ n)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1313
  by (induct n) (auto simp: one_ereal_def)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1314
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1315
lemma zero_le_power_ereal[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1316
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1317
  assumes "0 \<le> a"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1318
  shows "0 \<le> a ^ n"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1319
  using assms by (induct n) (auto simp: ereal_zero_le_0_iff)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1320
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1321
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1322
subsubsection \<open>Subtraction\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1323
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1324
lemma ereal_minus_minus_image[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1325
  fixes S :: "ereal set"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1326
  shows "uminus ` uminus ` S = S"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1327
  by (auto simp: image_iff)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1328
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1329
lemma ereal_uminus_lessThan[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1330
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1331
  shows "uminus ` {..<a} = {-a<..}"
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1332
proof -
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1333
  {
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1334
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1335
    assume "-a < x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1336
    then have "- x < - (- a)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1337
      by (simp del: ereal_uminus_uminus)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1338
    then have "- x < a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1339
      by simp
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1340
  }
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1341
  then show ?thesis
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1342
    by force
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1343
qed
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1344
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1345
lemma ereal_uminus_greaterThan[simp]: "uminus ` {(a::ereal)<..} = {..<-a}"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1346
  by (metis ereal_uminus_lessThan ereal_uminus_uminus ereal_minus_minus_image)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1347
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1348
instantiation ereal :: minus
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1349
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1350
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1351
definition "x - y = x + -(y::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1352
instance ..
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1353
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1354
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1355
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1356
lemma ereal_minus[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1357
  "ereal r - ereal p = ereal (r - p)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1358
  "-\<infinity> - ereal r = -\<infinity>"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1359
  "ereal r - \<infinity> = -\<infinity>"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1360
  "(\<infinity>::ereal) - x = \<infinity>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1361
  "-(\<infinity>::ereal) - \<infinity> = -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1362
  "x - -y = x + y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1363
  "x - 0 = x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1364
  "0 - x = -x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1365
  by (simp_all add: minus_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1366
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1367
lemma ereal_x_minus_x[simp]: "x - x = (if \<bar>x\<bar> = \<infinity> then \<infinity> else 0::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1368
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1369
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1370
lemma ereal_eq_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1371
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1372
  shows "x = z - y \<longleftrightarrow>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1373
    (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x + y = z) \<and>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1374
    (y = -\<infinity> \<longrightarrow> x = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1375
    (y = \<infinity> \<longrightarrow> z = \<infinity> \<longrightarrow> x = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1376
    (y = \<infinity> \<longrightarrow> z \<noteq> \<infinity> \<longrightarrow> x = -\<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1377
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1378
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1379
lemma ereal_eq_minus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1380
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1381
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x = z - y \<longleftrightarrow> x + y = z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1382
  by (auto simp: ereal_eq_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1383
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1384
lemma ereal_less_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1385
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1386
  shows "x < z - y \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1387
    (y = \<infinity> \<longrightarrow> z = \<infinity> \<and> x \<noteq> \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1388
    (y = -\<infinity> \<longrightarrow> x \<noteq> \<infinity>) \<and>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1389
    (\<bar>y\<bar> \<noteq> \<infinity>\<longrightarrow> x + y < z)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1390
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1391
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1392
lemma ereal_less_minus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1393
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1394
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x < z - y \<longleftrightarrow> x + y < z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1395
  by (auto simp: ereal_less_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1396
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1397
lemma ereal_le_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1398
  fixes x y z :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1399
  shows "x \<le> z - y \<longleftrightarrow> (y = \<infinity> \<longrightarrow> z \<noteq> \<infinity> \<longrightarrow> x = -\<infinity>) \<and> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x + y \<le> z)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1400
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1401
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1402
lemma ereal_le_minus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1403
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1404
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x \<le> z - y \<longleftrightarrow> x + y \<le> z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1405
  by (auto simp: ereal_le_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1406
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1407
lemma ereal_minus_less_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1408
  fixes x y z :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1409
  shows "x - y < z \<longleftrightarrow> y \<noteq> -\<infinity> \<and> (y = \<infinity> \<longrightarrow> x \<noteq> \<infinity> \<and> z \<noteq> -\<infinity>) \<and> (y \<noteq> \<infinity> \<longrightarrow> x < z + y)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1410
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1411
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1412
lemma ereal_minus_less:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1413
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1414
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x - y < z \<longleftrightarrow> x < z + y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1415
  by (auto simp: ereal_minus_less_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1416
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1417
lemma ereal_minus_le_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1418
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1419
  shows "x - y \<le> z \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1420
    (y = -\<infinity> \<longrightarrow> z = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1421
    (y = \<infinity> \<longrightarrow> x = \<infinity> \<longrightarrow> z = \<infinity>) \<and>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1422
    (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x \<le> z + y)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1423
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1424
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1425
lemma ereal_minus_le:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1426
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1427
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x - y \<le> z \<longleftrightarrow> x \<le> z + y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1428
  by (auto simp: ereal_minus_le_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1429
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1430
lemma ereal_minus_eq_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1431
  fixes a b c :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1432
  shows "a - b = a - c \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1433
    b = c \<or> a = \<infinity> \<or> (a = -\<infinity> \<and> b \<noteq> -\<infinity> \<and> c \<noteq> -\<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1434
  by (cases rule: ereal3_cases[of a b c]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1435
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1436
lemma ereal_add_le_add_iff:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1437
  fixes a b c :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1438
  shows "c + a \<le> c + b \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1439
    a \<le> b \<or> c = \<infinity> \<or> (c = -\<infinity> \<and> a \<noteq> \<infinity> \<and> b \<noteq> \<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1440
  by (cases rule: ereal3_cases[of a b c]) (simp_all add: field_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1441
59023
4999a616336c register pmf as BNF
Andreas Lochbihler
parents: 59002
diff changeset
  1442
lemma ereal_add_le_add_iff2:
4999a616336c register pmf as BNF
Andreas Lochbihler
parents: 59002
diff changeset
  1443
  fixes a b c :: ereal
4999a616336c register pmf as BNF
Andreas Lochbihler
parents: 59002
diff changeset
  1444
  shows "a + c \<le> b + c \<longleftrightarrow> a \<le> b \<or> c = \<infinity> \<or> (c = -\<infinity> \<and> a \<noteq> \<infinity> \<and> b \<noteq> \<infinity>)"
4999a616336c register pmf as BNF
Andreas Lochbihler
parents: 59002
diff changeset
  1445
by(cases rule: ereal3_cases[of a b c])(simp_all add: field_simps)
4999a616336c register pmf as BNF
Andreas Lochbihler
parents: 59002
diff changeset
  1446
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1447
lemma ereal_mult_le_mult_iff:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1448
  fixes a b c :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1449
  shows "\<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)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1450
  by (cases rule: ereal3_cases[of a b c]) (simp_all add: mult_le_cancel_left)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1451
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1452
lemma ereal_minus_mono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1453
  fixes A B C D :: ereal assumes "A \<le> B" "D \<le> C"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1454
  shows "A - C \<le> B - D"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1455
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1456
  by (cases rule: ereal3_cases[case_product ereal_cases, of A B C D]) simp_all
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1457
62648
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
  1458
lemma ereal_mono_minus_cancel:
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
  1459
  fixes a b c :: ereal
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
  1460
  shows "c - a \<le> c - b \<Longrightarrow> 0 \<le> c \<Longrightarrow> c < \<infinity> \<Longrightarrow> b \<le> a"
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
  1461
  by (cases a b c rule: ereal3_cases) auto
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
  1462
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1463
lemma real_of_ereal_minus:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1464
  fixes a b :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  1465
  shows "real_of_ereal (a - b) = (if \<bar>a\<bar> = \<infinity> \<or> \<bar>b\<bar> = \<infinity> then 0 else real_of_ereal a - real_of_ereal b)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1466
  by (cases rule: ereal2_cases[of a b]) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1467
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  1468
lemma real_of_ereal_minus': "\<bar>x\<bar> = \<infinity> \<longleftrightarrow> \<bar>y\<bar> = \<infinity> \<Longrightarrow> real_of_ereal x - real_of_ereal y = real_of_ereal (x - y :: ereal)"
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1469
by(subst real_of_ereal_minus) auto
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1470
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1471
lemma ereal_diff_positive:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1472
  fixes a b :: ereal shows "a \<le> b \<Longrightarrow> 0 \<le> b - a"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1473
  by (cases rule: ereal2_cases[of a b]) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1474
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1475
lemma ereal_between:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1476
  fixes x e :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1477
  assumes "\<bar>x\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1478
    and "0 < e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1479
  shows "x - e < x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1480
    and "x < x + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1481
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1482
  apply (cases x, cases e)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1483
  apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1484
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1485
  apply (cases x, cases e)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1486
  apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1487
  done
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1488
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1489
lemma ereal_minus_eq_PInfty_iff:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1490
  fixes x y :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1491
  shows "x - y = \<infinity> \<longleftrightarrow> y = -\<infinity> \<or> x = \<infinity>"
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1492
  by (cases x y rule: ereal2_cases) simp_all
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1493
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1494
lemma ereal_diff_add_eq_diff_diff_swap:
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
  1495
  fixes x y z :: ereal
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1496
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x - (y + z) = x - y - z"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1497
by(cases x y z rule: ereal3_cases) simp_all
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1498
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1499
lemma ereal_diff_add_assoc2:
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1500
  fixes x y z :: ereal
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1501
  shows "x + y - z = x - z + y"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1502
by(cases x y z rule: ereal3_cases) simp_all
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1503
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1504
lemma ereal_add_uminus_conv_diff: fixes x y z :: ereal shows "- x + y = y - x"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1505
by(cases x y rule: ereal2_cases) simp_all
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1506
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
  1507
lemma ereal_minus_diff_eq:
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
  1508
  fixes x y :: ereal
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1509
  shows "\<lbrakk> x = \<infinity> \<longrightarrow> y \<noteq> \<infinity>; x = -\<infinity> \<longrightarrow> y \<noteq> - \<infinity> \<rbrakk> \<Longrightarrow> - (x - y) = y - x"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1510
by(cases x y rule: ereal2_cases) simp_all
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1511
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1512
lemma ediff_le_self [simp]: "x - y \<le> (x :: enat)"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1513
by(cases x y rule: enat.exhaust[case_product enat.exhaust]) simp_all
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1514
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1515
lemma ereal_abs_diff:
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1516
  fixes a b::ereal
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1517
  shows "abs(a-b) \<le> abs a + abs b"
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1518
by (cases rule: ereal2_cases[of a b]) (auto)
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1519
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  1520
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1521
subsubsection \<open>Division\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1522
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1523
instantiation ereal :: inverse
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1524
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1525
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1526
function inverse_ereal where
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1527
  "inverse (ereal r) = (if r = 0 then \<infinity> else ereal (inverse r))"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1528
| "inverse (\<infinity>::ereal) = 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1529
| "inverse (-\<infinity>::ereal) = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1530
  by (auto intro: ereal_cases)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1531
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1532
60429
d3d1e185cd63 uniform _ div _ as infix syntax for ring division
haftmann
parents: 60352
diff changeset
  1533
definition "x div y = x * inverse (y :: ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1534
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1535
instance ..
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1536
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1537
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1538
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1539
lemma real_of_ereal_inverse[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1540
  fixes a :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  1541
  shows "real_of_ereal (inverse a) = 1 / real_of_ereal a"
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1542
  by (cases a) (auto simp: inverse_eq_divide)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1543
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1544
lemma ereal_inverse[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1545
  "inverse (0::ereal) = \<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1546
  "inverse (1::ereal) = 1"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1547
  by (simp_all add: one_ereal_def zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1548
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1549
lemma ereal_divide[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1550
  "ereal r / ereal p = (if p = 0 then ereal r * \<infinity> else ereal (r / p))"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1551
  unfolding divide_ereal_def by (auto simp: divide_real_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1552
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1553
lemma ereal_divide_same[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1554
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1555
  shows "x / x = (if \<bar>x\<bar> = \<infinity> \<or> x = 0 then 0 else 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1556
  by (cases x) (simp_all add: divide_real_def divide_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1557
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1558
lemma ereal_inv_inv[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1559
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1560
  shows "inverse (inverse x) = (if x \<noteq> -\<infinity> then x else \<infinity>)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1561
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1562
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1563
lemma ereal_inverse_minus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1564
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1565
  shows "inverse (- x) = (if x = 0 then \<infinity> else -inverse x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1566
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1567
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1568
lemma ereal_uminus_divide[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1569
  fixes x y :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1570
  shows "- x / y = - (x / y)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1571
  unfolding divide_ereal_def by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1572
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1573
lemma ereal_divide_Infty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1574
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1575
  shows "x / \<infinity> = 0" "x / -\<infinity> = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1576
  unfolding divide_ereal_def by simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1577
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1578
lemma ereal_divide_one[simp]: "x / 1 = (x::ereal)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1579
  unfolding divide_ereal_def by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1580
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1581
lemma ereal_divide_ereal[simp]: "\<infinity> / ereal r = (if 0 \<le> r then \<infinity> else -\<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1582
  unfolding divide_ereal_def by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1583
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1584
lemma ereal_inverse_nonneg_iff: "0 \<le> inverse (x :: ereal) \<longleftrightarrow> 0 \<le> x \<or> x = -\<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1585
  by (cases x) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1586
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1587
lemma inverse_ereal_ge0I: "0 \<le> (x :: ereal) \<Longrightarrow> 0 \<le> inverse x"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1588
by(cases x) simp_all
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1589
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1590
lemma zero_le_divide_ereal[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1591
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1592
  assumes "0 \<le> a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1593
    and "0 \<le> b"
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1594
  shows "0 \<le> a / b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1595
  using assms by (cases rule: ereal2_cases[of a b]) (auto simp: zero_le_divide_iff)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1596
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1597
lemma ereal_le_divide_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1598
  fixes x y z :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1599
  shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y \<le> z / x \<longleftrightarrow> x * y \<le> z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1600
  by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1601
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1602
lemma ereal_divide_le_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1603
  fixes x y z :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1604
  shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> z / x \<le> y \<longleftrightarrow> z \<le> x * y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1605
  by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1606
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1607
lemma ereal_le_divide_neg:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1608
  fixes x y z :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1609
  shows "x < 0 \<Longrightarrow> x \<noteq> -\<infinity> \<Longrightarrow> y \<le> z / x \<longleftrightarrow> z \<le> x * y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1610
  by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1611
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1612
lemma ereal_divide_le_neg:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1613
  fixes x y z :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1614
  shows "x < 0 \<Longrightarrow> x \<noteq> -\<infinity> \<Longrightarrow> z / x \<le> y \<longleftrightarrow> x * y \<le> z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1615
  by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1616
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1617
lemma ereal_inverse_antimono_strict:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1618
  fixes x y :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1619
  shows "0 \<le> x \<Longrightarrow> x < y \<Longrightarrow> inverse y < inverse x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1620
  by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1621
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1622
lemma ereal_inverse_antimono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1623
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1624
  shows "0 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> inverse y \<le> inverse x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1625
  by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1626
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1627
lemma inverse_inverse_Pinfty_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1628
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1629
  shows "inverse x = \<infinity> \<longleftrightarrow> x = 0"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1630
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1631
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1632
lemma ereal_inverse_eq_0:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1633
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1634
  shows "inverse x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1635
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1636
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1637
lemma ereal_0_gt_inverse:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1638
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1639
  shows "0 < inverse x \<longleftrightarrow> x \<noteq> \<infinity> \<and> 0 \<le> x"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1640
  by (cases x) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1641
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1642
lemma ereal_inverse_le_0_iff:
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1643
  fixes x :: ereal
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1644
  shows "inverse x \<le> 0 \<longleftrightarrow> x < 0 \<or> x = \<infinity>"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1645
  by(cases x) auto
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1646
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1647
lemma ereal_divide_eq_0_iff: "x / y = 0 \<longleftrightarrow> x = 0 \<or> \<bar>y :: ereal\<bar> = \<infinity>"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1648
by(cases x y rule: ereal2_cases) simp_all
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1649
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1650
lemma ereal_mult_less_right:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1651
  fixes a b c :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1652
  assumes "b * a < c * a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1653
    and "0 < a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1654
    and "a < \<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1655
  shows "b < c"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1656
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1657
  by (cases rule: ereal3_cases[of a b c])
62390
842917225d56 more canonical names
nipkow
parents: 62378
diff changeset
  1658
     (auto split: if_split_asm simp: zero_less_mult_iff zero_le_mult_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1659
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1660
lemma ereal_mult_divide: fixes a b :: ereal shows "0 < b \<Longrightarrow> b < \<infinity> \<Longrightarrow> b * (a / b) = a"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1661
  by (cases a b rule: ereal2_cases) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1662
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1663
lemma ereal_power_divide:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1664
  fixes x y :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1665
  shows "y \<noteq> 0 \<Longrightarrow> (x / y) ^ n = x^n / y^n"
58787
af9eb5e566dd eliminated redundancies;
haftmann
parents: 58310
diff changeset
  1666
  by (cases rule: ereal2_cases [of x y])
af9eb5e566dd eliminated redundancies;
haftmann
parents: 58310
diff changeset
  1667
     (auto simp: one_ereal_def zero_ereal_def power_divide zero_le_power_eq)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1668
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1669
lemma ereal_le_mult_one_interval:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1670
  fixes x y :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1671
  assumes y: "y \<noteq> -\<infinity>"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1672
  assumes z: "\<And>z. 0 < z \<Longrightarrow> z < 1 \<Longrightarrow> z * x \<le> y"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1673
  shows "x \<le> y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1674
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1675
  case PInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1676
  with z[of "1 / 2"] show "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1677
    by (simp add: one_ereal_def)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1678
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1679
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1680
  note r = this
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1681
  show "x \<le> y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1682
  proof (cases y)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1683
    case (real p)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1684
    note p = this
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1685
    have "r \<le> p"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1686
    proof (rule field_le_mult_one_interval)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1687
      fix z :: real
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1688
      assume "0 < z" and "z < 1"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1689
      with z[of "ereal z"] show "z * r \<le> p"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1690
        using p r by (auto simp: zero_le_mult_iff one_ereal_def)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1691
    qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1692
    then show "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1693
      using p r by simp
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1694
  qed (insert y, simp_all)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1695
qed simp
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1696
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1697
lemma ereal_divide_right_mono[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1698
  fixes x y z :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1699
  assumes "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1700
    and "0 < z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1701
  shows "x / z \<le> y / z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1702
  using assms by (cases x y z rule: ereal3_cases) (auto intro: divide_right_mono)
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1703
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1704
lemma ereal_divide_left_mono[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1705
  fixes x y z :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1706
  assumes "y \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1707
    and "0 < z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1708
    and "0 < x * y"
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1709
  shows "z / x \<le> z / y"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1710
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1711
  by (cases x y z rule: ereal3_cases)
62390
842917225d56 more canonical names
nipkow
parents: 62378
diff changeset
  1712
     (auto intro: divide_left_mono simp: field_simps zero_less_mult_iff mult_less_0_iff split: if_split_asm)
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1713
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1714
lemma ereal_divide_zero_left[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1715
  fixes a :: ereal
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1716
  shows "0 / a = 0"
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1717
  by (cases a) (auto simp: zero_ereal_def)
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1718
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1719
lemma ereal_times_divide_eq_left[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1720
  fixes a b c :: ereal
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1721
  shows "b / c * a = b * a / c"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1722
  by (cases a b c rule: ereal3_cases) (auto simp: field_simps zero_less_mult_iff mult_less_0_iff)
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1723
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1724
lemma ereal_times_divide_eq: "a * (b / c :: ereal) = a * b / c"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1725
  by (cases a b c rule: ereal3_cases)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1726
     (auto simp: field_simps zero_less_mult_iff)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1727
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  1728
lemma ereal_inverse_real: "\<bar>z\<bar> \<noteq> \<infinity> \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> ereal (inverse (real_of_ereal z)) = inverse z"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  1729
  by (cases z) simp_all
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  1730
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  1731
lemma ereal_inverse_mult:
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  1732
  "a \<noteq> 0 \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> inverse (a * (b::ereal)) = inverse a * inverse b"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  1733
  by (cases a; cases b) auto
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  1734
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  1735
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1736
subsection "Complete lattice"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1737
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1738
instantiation ereal :: lattice
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1739
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1740
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1741
definition [simp]: "sup x y = (max x y :: ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1742
definition [simp]: "inf x y = (min x y :: ereal)"
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
  1743
instance by standard simp_all
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1744
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1745
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1746
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1747
instantiation ereal :: complete_lattice
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1748
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1749
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1750
definition "bot = (-\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1751
definition "top = (\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1752
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1753
definition "Sup S = (SOME x :: ereal. (\<forall>y\<in>S. y \<le> x) \<and> (\<forall>z. (\<forall>y\<in>S. y \<le> z) \<longrightarrow> x \<le> z))"
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1754
definition "Inf S = (SOME x :: ereal. (\<forall>y\<in>S. x \<le> y) \<and> (\<forall>z. (\<forall>y\<in>S. z \<le> y) \<longrightarrow> z \<le> x))"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1755
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1756
lemma ereal_complete_Sup:
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1757
  fixes S :: "ereal set"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1758
  shows "\<exists>x. (\<forall>y\<in>S. y \<le> x) \<and> (\<forall>z. (\<forall>y\<in>S. y \<le> z) \<longrightarrow> x \<le> z)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1759
proof (cases "\<exists>x. \<forall>a\<in>S. a \<le> ereal x")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1760
  case True
63060
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  1761
  then obtain y where y: "a \<le> ereal y" if "a\<in>S" for a
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1762
    by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1763
  then have "\<infinity> \<notin> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1764
    by force
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1765
  show ?thesis
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1766
  proof (cases "S \<noteq> {-\<infinity>} \<and> S \<noteq> {}")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1767
    case True
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1768
    with \<open>\<infinity> \<notin> S\<close> obtain x where x: "x \<in> S" "\<bar>x\<bar> \<noteq> \<infinity>"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1769
      by auto
63060
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  1770
    obtain s where s: "\<forall>x\<in>ereal -` S. x \<le> s" "(\<forall>x\<in>ereal -` S. x \<le> z) \<Longrightarrow> s \<le> z" for z
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1771
    proof (atomize_elim, rule complete_real)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1772
      show "\<exists>x. x \<in> ereal -` S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1773
        using x by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1774
      show "\<exists>z. \<forall>x\<in>ereal -` S. x \<le> z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1775
        by (auto dest: y intro!: exI[of _ y])
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1776
    qed
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1777
    show ?thesis
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1778
    proof (safe intro!: exI[of _ "ereal s"])
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1779
      fix y
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1780
      assume "y \<in> S"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1781
      with s \<open>\<infinity> \<notin> S\<close> show "y \<le> ereal s"
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1782
        by (cases y) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1783
    next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1784
      fix z
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1785
      assume "\<forall>y\<in>S. y \<le> z"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1786
      with \<open>S \<noteq> {-\<infinity>} \<and> S \<noteq> {}\<close> show "ereal s \<le> z"
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1787
        by (cases z) (auto intro!: s)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1788
    qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1789
  next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1790
    case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1791
    then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1792
      by (auto intro!: exI[of _ "-\<infinity>"])
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1793
  qed
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1794
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1795
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1796
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1797
    by (fastforce intro!: exI[of _ \<infinity>] ereal_top intro: order_trans dest: less_imp_le simp: not_le)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1798
qed
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1799
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1800
lemma ereal_complete_uminus_eq:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1801
  fixes S :: "ereal set"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1802
  shows "(\<forall>y\<in>uminus`S. y \<le> x) \<and> (\<forall>z. (\<forall>y\<in>uminus`S. y \<le> z) \<longrightarrow> x \<le> z)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1803
     \<longleftrightarrow> (\<forall>y\<in>S. -x \<le> y) \<and> (\<forall>z. (\<forall>y\<in>S. z \<le> y) \<longrightarrow> z \<le> -x)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1804
  by simp (metis ereal_minus_le_minus ereal_uminus_uminus)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1805
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1806
lemma ereal_complete_Inf:
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1807
  "\<exists>x. (\<forall>y\<in>S::ereal set. x \<le> y) \<and> (\<forall>z. (\<forall>y\<in>S. z \<le> y) \<longrightarrow> z \<le> x)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1808
  using ereal_complete_Sup[of "uminus ` S"]
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1809
  unfolding ereal_complete_uminus_eq
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1810
  by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1811
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1812
instance
52729
412c9e0381a1 factored syntactic type classes for bot and top (by Alessandro Coglio)
haftmann
parents: 51775
diff changeset
  1813
proof
412c9e0381a1 factored syntactic type classes for bot and top (by Alessandro Coglio)
haftmann
parents: 51775
diff changeset
  1814
  show "Sup {} = (bot::ereal)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1815
    apply (auto simp: bot_ereal_def Sup_ereal_def)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1816
    apply (rule some1_equality)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1817
    apply (metis ereal_bot ereal_less_eq(2))
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1818
    apply (metis ereal_less_eq(2))
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1819
    done
52729
412c9e0381a1 factored syntactic type classes for bot and top (by Alessandro Coglio)
haftmann
parents: 51775
diff changeset
  1820
  show "Inf {} = (top::ereal)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1821
    apply (auto simp: top_ereal_def Inf_ereal_def)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1822
    apply (rule some1_equality)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1823
    apply (metis ereal_top ereal_less_eq(1))
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1824
    apply (metis ereal_less_eq(1))
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1825
    done
52729
412c9e0381a1 factored syntactic type classes for bot and top (by Alessandro Coglio)
haftmann
parents: 51775
diff changeset
  1826
qed (auto intro: someI2_ex ereal_complete_Sup ereal_complete_Inf
412c9e0381a1 factored syntactic type classes for bot and top (by Alessandro Coglio)
haftmann
parents: 51775
diff changeset
  1827
  simp: Sup_ereal_def Inf_ereal_def bot_ereal_def top_ereal_def)
43941
481566bc20e4 ereal is a complete_linorder instance
haftmann
parents: 43933
diff changeset
  1828
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1829
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1830
43941
481566bc20e4 ereal is a complete_linorder instance
haftmann
parents: 43933
diff changeset
  1831
instance ereal :: complete_linorder ..
481566bc20e4 ereal is a complete_linorder instance
haftmann
parents: 43933
diff changeset
  1832
51775
408d937c9486 revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
hoelzl
parents: 51774
diff changeset
  1833
instance ereal :: linear_continuum
408d937c9486 revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
hoelzl
parents: 51774
diff changeset
  1834
proof
408d937c9486 revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
hoelzl
parents: 51774
diff changeset
  1835
  show "\<exists>a b::ereal. a \<noteq> b"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1836
    using zero_neq_one by blast
51775
408d937c9486 revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
hoelzl
parents: 51774
diff changeset
  1837
qed
60720
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1838
67452
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1839
lemma min_PInf [simp]: "min (\<infinity>::ereal) x = x"
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1840
by (metis min_top top_ereal_def)
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1841
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1842
lemma min_PInf2 [simp]: "min x (\<infinity>::ereal) = x"
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1843
by (metis min_top2 top_ereal_def)
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1844
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1845
lemma max_PInf [simp]: "max (\<infinity>::ereal) x = \<infinity>"
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1846
by (metis max_top top_ereal_def)
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1847
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1848
lemma max_PInf2 [simp]: "max x (\<infinity>::ereal) = \<infinity>"
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1849
by (metis max_top2 top_ereal_def)
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1850
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1851
lemma min_MInf [simp]: "min (-\<infinity>::ereal) x = -\<infinity>"
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1852
by (metis min_bot bot_ereal_def)
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1853
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1854
lemma min_MInf2 [simp]: "min x (-\<infinity>::ereal) = -\<infinity>"
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1855
by (metis min_bot2 bot_ereal_def)
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1856
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1857
lemma max_MInf [simp]: "max (-\<infinity>::ereal) x = x"
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1858
by (metis max_bot bot_ereal_def)
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1859
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1860
lemma max_MInf2 [simp]: "max x (-\<infinity>::ereal) = x"
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1861
by (metis max_bot2 bot_ereal_def)
aab817885622 more lemmas by Gouezele
nipkow
parents: 67408
diff changeset
  1862
67685
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1863
subsection \<open>Extended real intervals\<close>
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1864
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1865
lemma real_greaterThanLessThan_infinity_eq:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1866
  "real_of_ereal ` {N::ereal<..<\<infinity>} =
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1867
    (if N = \<infinity> then {} else if N = -\<infinity> then UNIV else {real_of_ereal N<..})"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1868
proof -
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1869
  {
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1870
    fix x::real
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1871
    have "x \<in> real_of_ereal ` {- \<infinity><..<\<infinity>::ereal}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1872
      by (auto intro!: image_eqI[where x="ereal x"])
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1873
  } moreover {
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1874
    fix x::ereal
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1875
    assume "N \<noteq> - \<infinity>" "N < x" "x \<noteq> \<infinity>"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1876
    then have "real_of_ereal N < real_of_ereal x"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1877
      by (cases N; cases x; simp)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1878
  } moreover {
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1879
    fix x::real
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1880
    assume "N \<noteq> \<infinity>" "real_of_ereal N < x"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1881
    then have "x \<in> real_of_ereal ` {N<..<\<infinity>}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1882
      by (cases N) (auto intro!: image_eqI[where x="ereal x"])
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1883
  } ultimately show ?thesis by auto
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1884
qed
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1885
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1886
lemma real_greaterThanLessThan_minus_infinity_eq:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1887
  "real_of_ereal ` {-\<infinity><..<N::ereal} =
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1888
    (if N = \<infinity> then UNIV else if N = -\<infinity> then {} else {..<real_of_ereal N})"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1889
proof -
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1890
  have "real_of_ereal ` {-\<infinity><..<N::ereal} = uminus ` real_of_ereal ` {-N<..<\<infinity>}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1891
    by (auto simp: ereal_uminus_less_reorder intro!: image_eqI[where x="-x" for x])
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1892
  also note real_greaterThanLessThan_infinity_eq
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1893
  finally show ?thesis by (auto intro!: image_eqI[where x="-x" for x])
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1894
qed
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1895
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1896
lemma real_greaterThanLessThan_inter:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1897
  "real_of_ereal ` {N<..<M::ereal} = real_of_ereal ` {-\<infinity><..<M} \<inter> real_of_ereal ` {N<..<\<infinity>}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1898
  apply safe
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1899
  subgoal by force
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1900
  subgoal by force
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1901
  subgoal for x y z
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1902
    by (cases y; cases z) (auto intro!: image_eqI[where x=z] simp: )
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1903
  done
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1904
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1905
lemma real_atLeastGreaterThan_eq: "real_of_ereal ` {N<..<M::ereal} =
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1906
   (if N = \<infinity> then {} else
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1907
   if N = -\<infinity> then
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1908
    (if M = \<infinity> then UNIV
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1909
    else if M = -\<infinity> then {}
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1910
    else {..< real_of_ereal M})
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1911
  else if M = - \<infinity> then {}
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1912
  else if M = \<infinity> then {real_of_ereal N<..}
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1913
  else {real_of_ereal N <..< real_of_ereal M})"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1914
  apply (subst real_greaterThanLessThan_inter)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1915
  apply (subst real_greaterThanLessThan_minus_infinity_eq)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1916
  apply (subst real_greaterThanLessThan_infinity_eq)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1917
  apply auto
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1918
  done
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1919
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1920
lemma real_image_ereal_ivl:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1921
  fixes a b::ereal
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1922
  shows
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1923
  "real_of_ereal ` {a<..<b} =
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1924
  (if a < b then (if a = - \<infinity> then if b = \<infinity> then UNIV else {..<real_of_ereal b}
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1925
  else if b = \<infinity> then {real_of_ereal a<..} else {real_of_ereal a <..< real_of_ereal b}) else {})"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1926
  by (cases a; cases b; simp add: real_atLeastGreaterThan_eq not_less)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1927
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1928
lemma fixes a b c::ereal
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1929
  shows not_inftyI: "a < b \<Longrightarrow> b < c \<Longrightarrow> abs b \<noteq> \<infinity>"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1930
  by force
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1931
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1932
lemma
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1933
  interval_neqs:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1934
  fixes r s t::real
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1935
  shows "{r<..<s} \<noteq> {t<..}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1936
    and "{r<..<s} \<noteq> {..<t}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1937
    and "{r<..<ra} \<noteq> UNIV"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1938
    and "{r<..} \<noteq> {..<s}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1939
    and "{r<..} \<noteq> UNIV"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1940
    and "{..<r} \<noteq> UNIV"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1941
    and "{} \<noteq> {r<..}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1942
    and "{} \<noteq> {..<r}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1943
  subgoal
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1944
    by (metis dual_order.strict_trans greaterThanLessThan_iff greaterThan_iff gt_ex not_le order_refl)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1945
  subgoal
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1946
    by (metis (no_types, hide_lams) greaterThanLessThan_empty_iff greaterThanLessThan_iff gt_ex
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1947
        lessThan_iff minus_minus neg_less_iff_less not_less order_less_irrefl)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1948
  subgoal by force
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1949
  subgoal
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1950
    by (metis greaterThanLessThan_empty_iff greaterThanLessThan_eq greaterThan_iff inf.idem
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1951
        lessThan_iff lessThan_non_empty less_irrefl not_le)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1952
  subgoal by force
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1953
  subgoal by force
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1954
  subgoal using greaterThan_non_empty by blast
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1955
  subgoal using lessThan_non_empty by blast
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1956
  done
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1957
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1958
lemma greaterThanLessThan_eq_iff:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1959
  fixes r s t u::real
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1960
  shows "({r<..<s} = {t<..<u}) = (r \<ge> s \<and> u \<le> t \<or> r = t \<and> s = u)"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1961
  by (metis cInf_greaterThanLessThan cSup_greaterThanLessThan greaterThanLessThan_empty_iff not_le)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1962
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1963
lemma real_of_ereal_image_greaterThanLessThan_iff:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1964
  "real_of_ereal ` {a <..< b} = real_of_ereal ` {c <..< d} \<longleftrightarrow> (a \<ge> b \<and> c \<ge> d \<or> a = c \<and> b = d)"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1965
  unfolding real_atLeastGreaterThan_eq
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1966
  by (cases a; cases b; cases c; cases d;
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1967
    simp add: greaterThanLessThan_eq_iff interval_neqs interval_neqs[symmetric])
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1968
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1969
lemma uminus_image_real_of_ereal_image_greaterThanLessThan:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1970
  "uminus ` real_of_ereal ` {l <..< u} = real_of_ereal ` {-u <..< -l}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1971
  by (force simp: algebra_simps ereal_less_uminus_reorder
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1972
    ereal_uminus_less_reorder intro: image_eqI[where x="-x" for x])
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1973
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1974
lemma add_image_real_of_ereal_image_greaterThanLessThan:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1975
  "(+) c ` real_of_ereal ` {l <..< u} = real_of_ereal ` {c + l <..< c + u}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1976
  apply safe
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1977
  subgoal for x
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1978
    using ereal_less_add[of c]
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1979
    by (force simp: real_of_ereal_add add.commute)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1980
  subgoal for _ x
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1981
    by (force simp: add.commute real_of_ereal_minus ereal_minus_less ereal_less_minus
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1982
      intro: image_eqI[where x="x - c"])
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1983
  done
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1984
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1985
lemma add2_image_real_of_ereal_image_greaterThanLessThan:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1986
  "(\<lambda>x. x + c) ` real_of_ereal ` {l <..< u} = real_of_ereal ` {l + c <..< u + c}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1987
  using add_image_real_of_ereal_image_greaterThanLessThan[of c l u]
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1988
  by (metis add.commute image_cong)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1989
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1990
lemma minus_image_real_of_ereal_image_greaterThanLessThan:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1991
  "(-) c ` real_of_ereal ` {l <..< u} = real_of_ereal ` {c - u <..< c - l}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1992
  (is "?l = ?r")
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1993
proof -
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1994
  have "?l = (+) c ` uminus ` real_of_ereal ` {l <..< u}" by auto
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1995
  also note uminus_image_real_of_ereal_image_greaterThanLessThan
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1996
  also note add_image_real_of_ereal_image_greaterThanLessThan
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1997
  finally show ?thesis by (simp add: minus_ereal_def)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1998
qed
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  1999
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2000
lemma real_ereal_bound_lemma_up:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2001
  assumes "s \<in> real_of_ereal ` {a<..<b}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2002
  assumes "t \<notin> real_of_ereal ` {a<..<b}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2003
  assumes "s \<le> t"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2004
  shows "b \<noteq> \<infinity>"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2005
  using assms
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2006
  apply (cases b)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2007
  subgoal by force
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2008
  subgoal by (metis PInfty_neq_ereal(2) assms dual_order.strict_trans1 ereal_infty_less(1)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2009
    ereal_less_ereal_Ex greaterThanLessThan_empty_iff greaterThanLessThan_iff greaterThan_iff
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2010
    image_eqI less_imp_le linordered_field_no_ub not_less order_trans
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2011
    real_greaterThanLessThan_infinity_eq real_image_ereal_ivl real_of_ereal.simps(1))
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2012
  subgoal by force
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2013
  done
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2014
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2015
lemma real_ereal_bound_lemma_down:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2016
  assumes "s \<in> real_of_ereal ` {a<..<b}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2017
  assumes "t \<notin> real_of_ereal ` {a<..<b}"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2018
  assumes "t \<le> s"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2019
  shows "a \<noteq> - \<infinity>"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2020
  using assms
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2021
  apply (cases b)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2022
  subgoal
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2023
    apply safe
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2024
    using assms(1)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2025
    apply (auto simp: real_greaterThanLessThan_minus_infinity_eq)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2026
    done
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2027
  subgoal by (auto simp: real_greaterThanLessThan_minus_infinity_eq)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2028
  subgoal by auto
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2029
  done
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2030
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2031
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2032
subsection "Topological space"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2033
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2034
instantiation ereal :: linear_continuum_topology
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2035
begin
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2036
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2037
definition "open_ereal" :: "ereal set \<Rightarrow> bool" where
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2038
  open_ereal_generated: "open_ereal = generate_topology (range lessThan \<union> range greaterThan)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2039
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2040
instance
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
  2041
  by standard (simp add: open_ereal_generated)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2042
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2043
end
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2044
60720
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  2045
lemma continuous_on_ereal[continuous_intros]:
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  2046
  assumes f: "continuous_on s f" shows "continuous_on s (\<lambda>x. ereal (f x))"
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
  2047
  by (rule continuous_on_compose2 [OF continuous_onI_mono[of ereal UNIV] f]) auto
60720
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  2048
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2049
lemma tendsto_ereal[tendsto_intros, simp, intro]: "(f \<longlongrightarrow> x) F \<Longrightarrow> ((\<lambda>x. ereal (f x)) \<longlongrightarrow> ereal x) F"
60720
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  2050
  using isCont_tendsto_compose[of x ereal f F] continuous_on_ereal[of UNIV "\<lambda>x. x"]
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  2051
  by (simp add: continuous_on_eq_continuous_at)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2052
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2053
lemma tendsto_uminus_ereal[tendsto_intros, simp, intro]: "(f \<longlongrightarrow> x) F \<Longrightarrow> ((\<lambda>x. - f x::ereal) \<longlongrightarrow> - x) F"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2054
  apply (rule tendsto_compose[where g=uminus])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2055
  apply (auto intro!: order_tendstoI simp: eventually_at_topological)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2056
  apply (rule_tac x="{..< -a}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2057
  apply (auto split: ereal.split simp: ereal_less_uminus_reorder) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2058
  apply (rule_tac x="{- a <..}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2059
  apply (auto split: ereal.split simp: ereal_uminus_reorder) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2060
  done
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2061
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  2062
lemma at_infty_ereal_eq_at_top: "at \<infinity> = filtermap ereal at_top"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  2063
  unfolding filter_eq_iff eventually_at_filter eventually_at_top_linorder eventually_filtermap
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  2064
    top_ereal_def[symmetric]
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  2065
  apply (subst eventually_nhds_top[of 0])
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  2066
  apply (auto simp: top_ereal_def less_le ereal_all_split ereal_ex_split)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  2067
  apply (metis PInfty_neq_ereal(2) ereal_less_eq(3) ereal_top le_cases order_trans)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  2068
  done
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  2069
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2070
lemma ereal_Lim_uminus: "(f \<longlongrightarrow> f0) net \<longleftrightarrow> ((\<lambda>x. - f x::ereal) \<longlongrightarrow> - f0) net"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2071
  using tendsto_uminus_ereal[of f f0 net] tendsto_uminus_ereal[of "\<lambda>x. - f x" "- f0" net]
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2072
  by auto
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2073
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2074
lemma ereal_divide_less_iff: "0 < (c::ereal) \<Longrightarrow> c < \<infinity> \<Longrightarrow> a / c < b \<longleftrightarrow> a < b * c"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2075
  by (cases a b c rule: ereal3_cases) (auto simp: field_simps)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2076
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2077
lemma ereal_less_divide_iff: "0 < (c::ereal) \<Longrightarrow> c < \<infinity> \<Longrightarrow> a < b / c \<longleftrightarrow> a * c < b"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2078
  by (cases a b c rule: ereal3_cases) (auto simp: field_simps)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2079
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2080
lemma tendsto_cmult_ereal[tendsto_intros, simp, intro]:
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2081
  assumes c: "\<bar>c\<bar> \<noteq> \<infinity>" and f: "(f \<longlongrightarrow> x) F" shows "((\<lambda>x. c * f x::ereal) \<longlongrightarrow> c * x) F"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2082
proof -
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2083
  { fix c :: ereal assume "0 < c" "c < \<infinity>"
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2084
    then have "((\<lambda>x. c * f x::ereal) \<longlongrightarrow> c * x) F"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2085
      apply (intro tendsto_compose[OF _ f])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2086
      apply (auto intro!: order_tendstoI simp: eventually_at_topological)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2087
      apply (rule_tac x="{a/c <..}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2088
      apply (auto split: ereal.split simp: ereal_divide_less_iff mult.commute) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2089
      apply (rule_tac x="{..< a/c}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2090
      apply (auto split: ereal.split simp: ereal_less_divide_iff mult.commute) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2091
      done }
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2092
  note * = this
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2093
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2094
  have "((0 < c \<and> c < \<infinity>) \<or> (-\<infinity> < c \<and> c < 0) \<or> c = 0)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2095
    using c by (cases c) auto
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2096
  then show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2097
  proof (elim disjE conjE)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2098
    assume "- \<infinity> < c" "c < 0"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2099
    then have "0 < - c" "- c < \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2100
      by (auto simp: ereal_uminus_reorder ereal_less_uminus_reorder[of 0])
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2101
    then have "((\<lambda>x. (- c) * f x) \<longlongrightarrow> (- c) * x) F"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2102
      by (rule *)
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
  2103
    from tendsto_uminus_ereal[OF this] show ?thesis
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2104
      by simp
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2105
  qed (auto intro!: *)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2106
qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2107
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2108
lemma tendsto_cmult_ereal_not_0[tendsto_intros, simp, intro]:
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2109
  assumes "x \<noteq> 0" and f: "(f \<longlongrightarrow> x) F" shows "((\<lambda>x. c * f x::ereal) \<longlongrightarrow> c * x) F"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2110
proof cases
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2111
  assume "\<bar>c\<bar> = \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2112
  show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2113
  proof (rule filterlim_cong[THEN iffD1, OF refl refl _ tendsto_const])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2114
    have "0 < x \<or> x < 0"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2115
      using \<open>x \<noteq> 0\<close> by (auto simp add: neq_iff)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2116
    then show "eventually (\<lambda>x'. c * x = c * f x') F"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2117
    proof
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2118
      assume "0 < x" from order_tendstoD(1)[OF f this] show ?thesis
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2119
        by eventually_elim (insert \<open>0<x\<close> \<open>\<bar>c\<bar> = \<infinity>\<close>, auto)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2120
    next
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2121
      assume "x < 0" from order_tendstoD(2)[OF f this] show ?thesis
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2122
        by eventually_elim (insert \<open>x<0\<close> \<open>\<bar>c\<bar> = \<infinity>\<close>, auto)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2123
    qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2124
  qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2125
qed (rule tendsto_cmult_ereal[OF _ f])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2126
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2127
lemma tendsto_cadd_ereal[tendsto_intros, simp, intro]:
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2128
  assumes c: "y \<noteq> - \<infinity>" "x \<noteq> - \<infinity>" and f: "(f \<longlongrightarrow> x) F" shows "((\<lambda>x. f x + y::ereal) \<longlongrightarrow> x + y) F"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2129
  apply (intro tendsto_compose[OF _ f])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2130
  apply (auto intro!: order_tendstoI simp: eventually_at_topological)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2131
  apply (rule_tac x="{a - y <..}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2132
  apply (auto split: ereal.split simp: ereal_minus_less_iff c) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2133
  apply (rule_tac x="{..< a - y}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2134
  apply (auto split: ereal.split simp: ereal_less_minus_iff c) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2135
  done
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2136
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2137
lemma tendsto_add_left_ereal[tendsto_intros, simp, intro]:
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2138
  assumes c: "\<bar>y\<bar> \<noteq> \<infinity>" and f: "(f \<longlongrightarrow> x) F" shows "((\<lambda>x. f x + y::ereal) \<longlongrightarrow> x + y) F"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2139
  apply (intro tendsto_compose[OF _ f])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2140
  apply (auto intro!: order_tendstoI simp: eventually_at_topological)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2141
  apply (rule_tac x="{a - y <..}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2142
  apply (insert c, auto split: ereal.split simp: ereal_minus_less_iff) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2143
  apply (rule_tac x="{..< a - y}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2144
  apply (auto split: ereal.split simp: ereal_less_minus_iff c) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2145
  done
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2146
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2147
lemma continuous_at_ereal[continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. ereal (f x))"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2148
  unfolding continuous_def by auto
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2149
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  2150
lemma ereal_Sup:
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2151
  assumes *: "\<bar>SUP a\<in>A. ereal a\<bar> \<noteq> \<infinity>"
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2152
  shows "ereal (Sup A) = (SUP a\<in>A. ereal a)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2153
proof (rule continuous_at_Sup_mono)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2154
  obtain r where r: "ereal r = (SUP a\<in>A. ereal a)" "A \<noteq> {}"
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  2155
    using * by (force simp: bot_ereal_def)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2156
  then show "bdd_above A" "A \<noteq> {}"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 68356
diff changeset
  2157
    by (auto intro!: SUP_upper bdd_aboveI[of _ r] simp flip: ereal_less_eq)
60762
bf0c76ccee8d new material for multivariate analysis, etc.
paulson
parents: 60720
diff changeset
  2158
qed (auto simp: mono_def continuous_at_imp_continuous_at_within continuous_at_ereal)
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  2159
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2160
lemma ereal_SUP: "\<bar>SUP a\<in>A. ereal (f a)\<bar> \<noteq> \<infinity> \<Longrightarrow> ereal (SUP a\<in>A. f a) = (SUP a\<in>A. ereal (f a))"
69861
62e47f06d22c avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
haftmann
parents: 69661
diff changeset
  2161
  by (simp add: ereal_Sup image_comp)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2162
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  2163
lemma ereal_Inf:
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2164
  assumes *: "\<bar>INF a\<in>A. ereal a\<bar> \<noteq> \<infinity>"
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2165
  shows "ereal (Inf A) = (INF a\<in>A. ereal a)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2166
proof (rule continuous_at_Inf_mono)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2167
  obtain r where r: "ereal r = (INF a\<in>A. ereal a)" "A \<noteq> {}"
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  2168
    using * by (force simp: top_ereal_def)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2169
  then show "bdd_below A" "A \<noteq> {}"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 68356
diff changeset
  2170
    by (auto intro!: INF_lower bdd_belowI[of _ r] simp flip: ereal_less_eq)
60762
bf0c76ccee8d new material for multivariate analysis, etc.
paulson
parents: 60720
diff changeset
  2171
qed (auto simp: mono_def continuous_at_imp_continuous_at_within continuous_at_ereal)
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  2172
62083
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  2173
lemma ereal_Inf':
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  2174
  assumes *: "bdd_below A" "A \<noteq> {}"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2175
  shows "ereal (Inf A) = (INF a\<in>A. ereal a)"
62083
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  2176
proof (rule ereal_Inf)
63060
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  2177
  from * obtain l u where "x \<in> A \<Longrightarrow> l \<le> x" "u \<in> A" for x
62083
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  2178
    by (auto simp: bdd_below_def)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2179
  then have "l \<le> (INF x\<in>A. ereal x)" "(INF x\<in>A. ereal x) \<le> u"
62083
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  2180
    by (auto intro!: INF_greatest INF_lower)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2181
  then show "\<bar>INF a\<in>A. ereal a\<bar> \<noteq> \<infinity>"
62083
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  2182
    by auto
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  2183
qed
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  2184
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2185
lemma ereal_INF: "\<bar>INF a\<in>A. ereal (f a)\<bar> \<noteq> \<infinity> \<Longrightarrow> ereal (INF a\<in>A. f a) = (INF a\<in>A. ereal (f a))"
69861
62e47f06d22c avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
haftmann
parents: 69661
diff changeset
  2186
  by (simp add: ereal_Inf image_comp)
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  2187
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2188
lemma ereal_Sup_uminus_image_eq: "Sup (uminus ` S::ereal set) = - Inf S"
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  2189
  by (auto intro!: SUP_eqI
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2190
           simp: Ball_def[symmetric] ereal_uminus_le_reorder le_Inf_iff
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2191
           intro!: complete_lattice_class.Inf_lower2)
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2192
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  2193
lemma ereal_SUP_uminus_eq:
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  2194
  fixes f :: "'a \<Rightarrow> ereal"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2195
  shows "(SUP x\<in>S. uminus (f x)) = - (INF x\<in>S. f x)"
69861
62e47f06d22c avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
haftmann
parents: 69661
diff changeset
  2196
  using ereal_Sup_uminus_image_eq [of "f ` S"] by (simp add: image_comp)
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  2197
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2198
lemma ereal_inj_on_uminus[intro, simp]: "inj_on uminus (A :: ereal set)"
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2199
  by (auto intro!: inj_onI)
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2200
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2201
lemma ereal_Inf_uminus_image_eq: "Inf (uminus ` S::ereal set) = - Sup S"
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2202
  using ereal_Sup_uminus_image_eq[of "uminus ` S"] by simp
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2203
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  2204
lemma ereal_INF_uminus_eq:
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  2205
  fixes f :: "'a \<Rightarrow> ereal"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2206
  shows "(INF x\<in>S. - f x) = - (SUP x\<in>S. f x)"
69861
62e47f06d22c avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
haftmann
parents: 69661
diff changeset
  2207
  using ereal_Inf_uminus_image_eq [of "f ` S"] by (simp add: image_comp)
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  2208
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2209
lemma ereal_SUP_uminus:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2210
  fixes f :: "'a \<Rightarrow> ereal"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2211
  shows "(SUP i \<in> R. - f i) = - (INF i \<in> R. f i)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2212
  using ereal_Sup_uminus_image_eq[of "f`R"]
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2213
  by (simp add: image_image)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2214
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  2215
lemma ereal_SUP_not_infty:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  2216
  fixes f :: "_ \<Rightarrow> ereal"
69313
b021008c5397 removed legacy input syntax
haftmann
parents: 69260
diff changeset
  2217
  shows "A \<noteq> {} \<Longrightarrow> l \<noteq> -\<infinity> \<Longrightarrow> u \<noteq> \<infinity> \<Longrightarrow> \<forall>a\<in>A. l \<le> f a \<and> f a \<le> u \<Longrightarrow> \<bar>Sup (f ` A)\<bar> \<noteq> \<infinity>"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  2218
  using SUP_upper2[of _ A l f] SUP_least[of A f u]
69313
b021008c5397 removed legacy input syntax
haftmann
parents: 69260
diff changeset
  2219
  by (cases "Sup (f ` A)") auto
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  2220
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  2221
lemma ereal_INF_not_infty:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  2222
  fixes f :: "_ \<Rightarrow> ereal"
69313
b021008c5397 removed legacy input syntax
haftmann
parents: 69260
diff changeset
  2223
  shows "A \<noteq> {} \<Longrightarrow> l \<noteq> -\<infinity> \<Longrightarrow> u \<noteq> \<infinity> \<Longrightarrow> \<forall>a\<in>A. l \<le> f a \<and> f a \<le> u \<Longrightarrow> \<bar>Inf (f ` A)\<bar> \<noteq> \<infinity>"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  2224
  using INF_lower2[of _ A f u] INF_greatest[of A l f]
69313
b021008c5397 removed legacy input syntax
haftmann
parents: 69260
diff changeset
  2225
  by (cases "Inf (f ` A)") auto
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  2226
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2227
lemma ereal_image_uminus_shift:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2228
  fixes X Y :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2229
  shows "uminus ` X = Y \<longleftrightarrow> X = uminus ` Y"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2230
proof
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2231
  assume "uminus ` X = Y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2232
  then have "uminus ` uminus ` X = uminus ` Y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2233
    by (simp add: inj_image_eq_iff)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2234
  then show "X = uminus ` Y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2235
    by (simp add: image_image)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2236
qed (simp add: image_image)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2237
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2238
lemma Sup_eq_MInfty:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2239
  fixes S :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2240
  shows "Sup S = -\<infinity> \<longleftrightarrow> S = {} \<or> S = {-\<infinity>}"
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2241
  unfolding bot_ereal_def[symmetric] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2242
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2243
lemma Inf_eq_PInfty:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2244
  fixes S :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2245
  shows "Inf S = \<infinity> \<longleftrightarrow> S = {} \<or> S = {\<infinity>}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2246
  using Sup_eq_MInfty[of "uminus`S"]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2247
  unfolding ereal_Sup_uminus_image_eq ereal_image_uminus_shift by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2248
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2249
lemma Inf_eq_MInfty:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2250
  fixes S :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2251
  shows "-\<infinity> \<in> S \<Longrightarrow> Inf S = -\<infinity>"
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2252
  unfolding bot_ereal_def[symmetric] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2253
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2254
lemma Sup_eq_PInfty:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2255
  fixes S :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2256
  shows "\<infinity> \<in> S \<Longrightarrow> Sup S = \<infinity>"
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2257
  unfolding top_ereal_def[symmetric] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2258
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  2259
lemma not_MInfty_nonneg[simp]: "0 \<le> (x::ereal) \<Longrightarrow> x \<noteq> - \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  2260
  by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  2261
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2262
lemma Sup_ereal_close:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2263
  fixes e :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2264
  assumes "0 < e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2265
    and S: "\<bar>Sup S\<bar> \<noteq> \<infinity>" "S \<noteq> {}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2266
  shows "\<exists>x\<in>S. Sup S - e < x"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  2267
  using assms by (cases e) (auto intro!: less_Sup_iff[THEN iffD1])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2268
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2269
lemma Inf_ereal_close:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2270
  fixes e :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2271
  assumes "\<bar>Inf X\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2272
    and "0 < e"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2273
  shows "\<exists>x\<in>X. x < Inf X + e"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2274
proof (rule Inf_less_iff[THEN iffD1])
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2275
  show "Inf X < Inf X + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2276
    using assms by (cases e) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2277
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2278
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  2279
lemma SUP_PInfty:
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2280
  "(\<And>n::nat. \<exists>i\<in>A. ereal (real n) \<le> f i) \<Longrightarrow> (SUP i\<in>A. f i :: ereal) = \<infinity>"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2281
  unfolding top_ereal_def[symmetric] SUP_eq_top_iff
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2282
  by (metis MInfty_neq_PInfty(2) PInfty_neq_ereal(2) less_PInf_Ex_of_nat less_ereal.elims(2) less_le_trans)
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  2283
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2284
lemma SUP_nat_Infty: "(SUP i. ereal (real i)) = \<infinity>"
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  2285
  by (rule SUP_PInfty) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2286
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2287
lemma SUP_ereal_add_left:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2288
  assumes "I \<noteq> {}" "c \<noteq> -\<infinity>"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2289
  shows "(SUP i\<in>I. f i + c :: ereal) = (SUP i\<in>I. f i) + c"
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2290
proof (cases "(SUP i\<in>I. f i) = - \<infinity>")
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2291
  case True
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2292
  then have "\<And>i. i \<in> I \<Longrightarrow> f i = -\<infinity>"
62343
24106dc44def prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents: 62101
diff changeset
  2293
    unfolding Sup_eq_MInfty by auto
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2294
  with True show ?thesis
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2295
    by (cases c) (auto simp: \<open>I \<noteq> {}\<close>)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2296
next
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2297
  case False
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2298
  then show ?thesis
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2299
    by (subst continuous_at_Sup_mono[where f="\<lambda>x. x + c"])
69861
62e47f06d22c avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
haftmann
parents: 69661
diff changeset
  2300
      (auto simp: continuous_at_imp_continuous_at_within continuous_at mono_def add_mono \<open>I \<noteq> {}\<close>
62e47f06d22c avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
haftmann
parents: 69661
diff changeset
  2301
      \<open>c \<noteq> -\<infinity>\<close> image_comp)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2302
qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2303
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2304
lemma SUP_ereal_add_right:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2305
  fixes c :: ereal
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2306
  shows "I \<noteq> {} \<Longrightarrow> c \<noteq> -\<infinity> \<Longrightarrow> (SUP i\<in>I. c + f i) = c + (SUP i\<in>I. f i)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2307
  using SUP_ereal_add_left[of I c f] by (simp add: add.commute)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2308
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2309
lemma SUP_ereal_minus_right:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2310
  assumes "I \<noteq> {}" "c \<noteq> -\<infinity>"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2311
  shows "(SUP i\<in>I. c - f i :: ereal) = c - (INF i\<in>I. f i)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2312
  using SUP_ereal_add_right[OF assms, of "\<lambda>i. - f i"]
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2313
  by (simp add: ereal_SUP_uminus minus_ereal_def)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2314
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2315
lemma SUP_ereal_minus_left:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2316
  assumes "I \<noteq> {}" "c \<noteq> \<infinity>"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2317
  shows "(SUP i\<in>I. f i - c:: ereal) = (SUP i\<in>I. f i) - c"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2318
  using SUP_ereal_add_left[OF \<open>I \<noteq> {}\<close>, of "-c" f] by (simp add: \<open>c \<noteq> \<infinity>\<close> minus_ereal_def)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2319
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2320
lemma INF_ereal_minus_right:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2321
  assumes "I \<noteq> {}" and "\<bar>c\<bar> \<noteq> \<infinity>"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2322
  shows "(INF i\<in>I. c - f i) = c - (SUP i\<in>I. f i::ereal)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2323
proof -
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2324
  { fix b have "(-c) + b = - (c - b)"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2325
      using \<open>\<bar>c\<bar> \<noteq> \<infinity>\<close> by (cases c b rule: ereal2_cases) auto }
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2326
  note * = this
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2327
  show ?thesis
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2328
    using SUP_ereal_add_right[OF \<open>I \<noteq> {}\<close>, of "-c" f] \<open>\<bar>c\<bar> \<noteq> \<infinity>\<close>
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2329
    by (auto simp add: * ereal_SUP_uminus_eq)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2330
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2331
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2332
lemma SUP_ereal_le_addI:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2333
  fixes f :: "'i \<Rightarrow> ereal"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2334
  assumes "\<And>i. f i + y \<le> z" and "y \<noteq> -\<infinity>"
69313
b021008c5397 removed legacy input syntax
haftmann
parents: 69260
diff changeset
  2335
  shows "Sup (f ` UNIV) + y \<le> z"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2336
  unfolding SUP_ereal_add_left[OF UNIV_not_empty \<open>y \<noteq> -\<infinity>\<close>, symmetric]
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2337
  by (rule SUP_least assms)+
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2338
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2339
lemma SUP_combine:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2340
  fixes f :: "'a::semilattice_sup \<Rightarrow> 'a::semilattice_sup \<Rightarrow> 'b::complete_lattice"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2341
  assumes mono: "\<And>a b c d. a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> f a c \<le> f b d"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2342
  shows "(SUP i\<in>UNIV. SUP j\<in>UNIV. f i j) = (SUP i. f i i)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2343
proof (rule antisym)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2344
  show "(SUP i j. f i j) \<le> (SUP i. f i i)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2345
    by (rule SUP_least SUP_upper2[where i="sup i j" for i j] UNIV_I mono sup_ge1 sup_ge2)+
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2346
  show "(SUP i. f i i) \<le> (SUP i j. f i j)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2347
    by (rule SUP_least SUP_upper2 UNIV_I mono order_refl)+
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2348
qed
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  2349
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2350
lemma SUP_ereal_add:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2351
  fixes f g :: "nat \<Rightarrow> ereal"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2352
  assumes inc: "incseq f" "incseq g"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2353
    and pos: "\<And>i. f i \<noteq> -\<infinity>" "\<And>i. g i \<noteq> -\<infinity>"
69313
b021008c5397 removed legacy input syntax
haftmann
parents: 69260
diff changeset
  2354
  shows "(SUP i. f i + g i) = Sup (f ` UNIV) + Sup (g ` UNIV)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2355
  apply (subst SUP_ereal_add_left[symmetric, OF UNIV_not_empty])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2356
  apply (metis SUP_upper UNIV_I assms(4) ereal_infty_less_eq(2))
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2357
  apply (subst (2) add.commute)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2358
  apply (subst SUP_ereal_add_left[symmetric, OF UNIV_not_empty assms(3)])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2359
  apply (subst (2) add.commute)
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  2360
  apply (rule SUP_combine[symmetric] add_mono inc[THEN monoD] | assumption)+
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2361
  done
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2362
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2363
lemma INF_eq_minf: "(INF i\<in>I. f i::ereal) \<noteq> -\<infinity> \<longleftrightarrow> (\<exists>b>-\<infinity>. \<forall>i\<in>I. b \<le> f i)"
63968
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2364
  unfolding bot_ereal_def[symmetric] INF_eq_bot_iff by (auto simp: not_less)
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2365
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2366
lemma INF_ereal_add_left:
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2367
  assumes "I \<noteq> {}" "c \<noteq> -\<infinity>" "\<And>x. x \<in> I \<Longrightarrow> 0 \<le> f x"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2368
  shows "(INF i\<in>I. f i + c :: ereal) = (INF i\<in>I. f i) + c"
63968
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2369
proof -
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2370
  have "(INF i\<in>I. f i) \<noteq> -\<infinity>"
63968
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2371
    unfolding INF_eq_minf using assms by (intro exI[of _ 0]) auto
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2372
  then show ?thesis
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2373
    by (subst continuous_at_Inf_mono[where f="\<lambda>x. x + c"])
69861
62e47f06d22c avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
haftmann
parents: 69661
diff changeset
  2374
       (auto simp: mono_def add_mono \<open>I \<noteq> {}\<close> \<open>c \<noteq> -\<infinity>\<close> continuous_at_imp_continuous_at_within
62e47f06d22c avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
haftmann
parents: 69661
diff changeset
  2375
        continuous_at image_comp)
63968
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2376
qed
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2377
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2378
lemma INF_ereal_add_right:
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2379
  assumes "I \<noteq> {}" "c \<noteq> -\<infinity>" "\<And>x. x \<in> I \<Longrightarrow> 0 \<le> f x"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2380
  shows "(INF i\<in>I. c + f i :: ereal) = c + (INF i\<in>I. f i)"
63968
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2381
  using INF_ereal_add_left[OF assms] by (simp add: ac_simps)
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2382
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2383
lemma INF_ereal_add_directed:
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2384
  fixes f g :: "'a \<Rightarrow> ereal"
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2385
  assumes nonneg: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> g i"
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2386
  assumes directed: "\<And>i j. i \<in> I \<Longrightarrow> j \<in> I \<Longrightarrow> \<exists>k\<in>I. f i + g j \<ge> f k + g k"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2387
  shows "(INF i\<in>I. f i + g i) = (INF i\<in>I. f i) + (INF i\<in>I. g i)"
63968
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2388
proof cases
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2389
  assume "I = {}" then show ?thesis
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2390
    by (simp add: top_ereal_def)
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2391
next
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2392
  assume "I \<noteq> {}"
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2393
  show ?thesis
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2394
  proof (rule antisym)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2395
    show "(INF i\<in>I. f i) + (INF i\<in>I. g i) \<le> (INF i\<in>I. f i + g i)"
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  2396
      by (rule INF_greatest; intro add_mono INF_lower)
63968
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2397
  next
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2398
    have "(INF i\<in>I. f i + g i) \<le> (INF i\<in>I. (INF j\<in>I. f i + g j))"
63968
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2399
      using directed by (intro INF_greatest) (blast intro: INF_lower2)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2400
    also have "\<dots> = (INF i\<in>I. f i + (INF i\<in>I. g i))"
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69593
diff changeset
  2401
      using nonneg \<open>I \<noteq> {}\<close> by (auto simp: INF_ereal_add_right)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2402
    also have "\<dots> = (INF i\<in>I. f i) + (INF i\<in>I. g i)"
63968
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2403
      using nonneg by (intro INF_ereal_add_left \<open>I \<noteq> {}\<close>) (auto simp: INF_eq_minf intro!: exI[of _ 0])
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2404
    finally show "(INF i\<in>I. f i + g i) \<le> (INF i\<in>I. f i) + (INF i\<in>I. g i)" .
63968
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2405
  qed
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2406
qed
4359400adfe7 HOL-Analysis: the image of a negligible set under a Lipschitz continuous function is negligible (based on HOL Light proof ported by L. C. Paulson)
hoelzl
parents: 63952
diff changeset
  2407
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2408
lemma INF_ereal_add:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2409
  fixes f :: "nat \<Rightarrow> ereal"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2410
  assumes "decseq f" "decseq g"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2411
    and fin: "\<And>i. f i \<noteq> \<infinity>" "\<And>i. g i \<noteq> \<infinity>"
69313
b021008c5397 removed legacy input syntax
haftmann
parents: 69260
diff changeset
  2412
  shows "(INF i. f i + g i) = Inf (f ` UNIV) + Inf (g ` UNIV)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2413
proof -
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2414
  have INF_less: "(INF i. f i) < \<infinity>" "(INF i. g i) < \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2415
    using assms unfolding INF_less_iff by auto
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2416
  { fix a b :: ereal assume "a \<noteq> \<infinity>" "b \<noteq> \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2417
    then have "- ((- a) + (- b)) = a + b"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2418
      by (cases a b rule: ereal2_cases) auto }
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2419
  note * = this
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2420
  have "(INF i. f i + g i) = (INF i. - ((- f i) + (- g i)))"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2421
    by (simp add: fin *)
69313
b021008c5397 removed legacy input syntax
haftmann
parents: 69260
diff changeset
  2422
  also have "\<dots> = Inf (f ` UNIV) + Inf (g ` UNIV)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2423
    unfolding ereal_INF_uminus_eq
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2424
    using assms INF_less
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2425
    by (subst SUP_ereal_add) (auto simp: ereal_SUP_uminus fin *)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2426
  finally show ?thesis .
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2427
qed
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  2428
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2429
lemma SUP_ereal_add_pos:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2430
  fixes f g :: "nat \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2431
  assumes inc: "incseq f" "incseq g"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2432
    and pos: "\<And>i. 0 \<le> f i" "\<And>i. 0 \<le> g i"
69313
b021008c5397 removed legacy input syntax
haftmann
parents: 69260
diff changeset
  2433
  shows "(SUP i. f i + g i) = Sup (f ` UNIV) + Sup (g ` UNIV)"
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2434
proof (intro SUP_ereal_add inc)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2435
  fix i
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2436
  show "f i \<noteq> -\<infinity>" "g i \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2437
    using pos[of i] by auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2438
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2439
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  2440
lemma SUP_ereal_sum:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2441
  fixes f g :: "'a \<Rightarrow> nat \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2442
  assumes "\<And>n. n \<in> A \<Longrightarrow> incseq (f n)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2443
    and pos: "\<And>n i. n \<in> A \<Longrightarrow> 0 \<le> f n i"
69313
b021008c5397 removed legacy input syntax
haftmann
parents: 69260
diff changeset
  2444
  shows "(SUP i. \<Sum>n\<in>A. f n i) = (\<Sum>n\<in>A. Sup ((f n) ` UNIV))"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2445
proof (cases "finite A")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2446
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2447
  then show ?thesis using assms
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  2448
    by induct (auto simp: incseq_sumI2 sum_nonneg SUP_ereal_add_pos)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2449
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2450
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2451
  then show ?thesis by simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2452
qed
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2453
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2454
lemma SUP_ereal_mult_left:
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2455
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2456
  assumes "I \<noteq> {}"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2457
  assumes f: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" and c: "0 \<le> c"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2458
  shows "(SUP i\<in>I. c * f i) = c * (SUP i\<in>I. f i)"
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2459
proof (cases "(SUP i \<in> I. f i) = 0")
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2460
  case True
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2461
  then have "\<And>i. i \<in> I \<Longrightarrow> f i = 0"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2462
    by (metis SUP_upper f antisym)
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2463
  with True show ?thesis
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2464
    by simp
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2465
next
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2466
  case False
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2467
  then show ?thesis
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2468
    by (subst continuous_at_Sup_mono[where f="\<lambda>x. c * x"])
69861
62e47f06d22c avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
haftmann
parents: 69661
diff changeset
  2469
       (auto simp: mono_def continuous_at continuous_at_imp_continuous_at_within \<open>I \<noteq> {}\<close> image_comp
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2470
             intro!: ereal_mult_left_mono c)
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2471
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2472
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
  2473
lemma countable_approach:
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2474
  fixes x :: ereal
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2475
  assumes "x \<noteq> -\<infinity>"
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2476
  shows "\<exists>f. incseq f \<and> (\<forall>i::nat. f i < x) \<and> (f \<longlonglongrightarrow> x)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2477
proof (cases x)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2478
  case (real r)
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2479
  moreover have "(\<lambda>n. r - inverse (real (Suc n))) \<longlonglongrightarrow> r - 0"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2480
    by (intro tendsto_intros LIMSEQ_inverse_real_of_nat)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2481
  ultimately show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2482
    by (intro exI[of _ "\<lambda>n. x - inverse (Suc n)"]) (auto simp: incseq_def)
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
  2483
next
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2484
  case PInf with LIMSEQ_SUP[of "\<lambda>n::nat. ereal (real n)"] show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2485
    by (intro exI[of _ "\<lambda>n. ereal (real n)"]) (auto simp: incseq_def SUP_nat_Infty)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2486
qed (simp add: assms)
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2487
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2488
lemma Sup_countable_SUP:
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2489
  assumes "A \<noteq> {}"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2490
  shows "\<exists>f::nat \<Rightarrow> ereal. incseq f \<and> range f \<subseteq> A \<and> Sup A = (SUP i. f i)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2491
proof cases
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2492
  assume "Sup A = -\<infinity>"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2493
  with \<open>A \<noteq> {}\<close> have "A = {-\<infinity>}"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2494
    by (auto simp: Sup_eq_MInfty)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2495
  then show ?thesis
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2496
    by (auto intro!: exI[of _ "\<lambda>_. -\<infinity>"] simp: bot_ereal_def)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2497
next
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2498
  assume "Sup A \<noteq> -\<infinity>"
63060
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  2499
  then obtain l where "incseq l" and l: "l i < Sup A" and l_Sup: "l \<longlonglongrightarrow> Sup A" for i :: nat
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2500
    by (auto dest: countable_approach)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2501
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2502
  have "\<exists>f. \<forall>n. (f n \<in> A \<and> l n \<le> f n) \<and> (f n \<le> f (Suc n))"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2503
  proof (rule dependent_nat_choice)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2504
    show "\<exists>x. x \<in> A \<and> l 0 \<le> x"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2505
      using l[of 0] by (auto simp: less_Sup_iff)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2506
  next
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2507
    fix x n assume "x \<in> A \<and> l n \<le> x"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2508
    moreover from l[of "Suc n"] obtain y where "y \<in> A" "l (Suc n) < y"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2509
      by (auto simp: less_Sup_iff)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2510
    ultimately show "\<exists>y. (y \<in> A \<and> l (Suc n) \<le> y) \<and> x \<le> y"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2511
      by (auto intro!: exI[of _ "max x y"] split: split_max)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2512
  qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2513
  then guess f .. note f = this
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2514
  then have "range f \<subseteq> A" "incseq f"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2515
    by (auto simp: incseq_Suc_iff)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2516
  moreover
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2517
  have "(SUP i. f i) = Sup A"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2518
  proof (rule tendsto_unique)
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2519
    show "f \<longlonglongrightarrow> (SUP i. f i)"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2520
      by (rule LIMSEQ_SUP \<open>incseq f\<close>)+
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2521
    show "f \<longlonglongrightarrow> Sup A"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2522
      using l f
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2523
      by (intro tendsto_sandwich[OF _ _ l_Sup tendsto_const])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2524
         (auto simp: Sup_upper)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2525
  qed simp
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2526
  ultimately show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2527
    by auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2528
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2529
63940
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2530
lemma Inf_countable_INF:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2531
  assumes "A \<noteq> {}" shows "\<exists>f::nat \<Rightarrow> ereal. decseq f \<and> range f \<subseteq> A \<and> Inf A = (INF i. f i)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2532
proof -
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2533
  obtain f where "incseq f" "range f \<subseteq> uminus`A" "Sup (uminus`A) = (SUP i. f i)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2534
    using Sup_countable_SUP[of "uminus ` A"] \<open>A \<noteq> {}\<close> by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2535
  then show ?thesis
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2536
    by (intro exI[of _ "\<lambda>x. - f x"])
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2537
       (auto simp: ereal_Sup_uminus_image_eq ereal_INF_uminus_eq eq_commute[of "- _"])
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2538
qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2539
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2540
lemma SUP_countable_SUP:
69313
b021008c5397 removed legacy input syntax
haftmann
parents: 69260
diff changeset
  2541
  "A \<noteq> {} \<Longrightarrow> \<exists>f::nat \<Rightarrow> ereal. range f \<subseteq> g`A \<and> Sup (g ` A) = Sup (f ` UNIV)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2542
  using Sup_countable_SUP [of "g`A"] by auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  2543
69593
3dda49e08b9d isabelle update -u control_cartouches;
wenzelm
parents: 69313
diff changeset
  2544
subsection "Relation to \<^typ>\<open>enat\<close>"
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2545
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2546
definition "ereal_of_enat n = (case n of enat n \<Rightarrow> ereal (real n) | \<infinity> \<Rightarrow> \<infinity>)"
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2547
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2548
declare [[coercion "ereal_of_enat :: enat \<Rightarrow> ereal"]]
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2549
declare [[coercion "(\<lambda>n. ereal (real n)) :: nat \<Rightarrow> ereal"]]
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2550
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2551
lemma ereal_of_enat_simps[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2552
  "ereal_of_enat (enat n) = ereal n"
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2553
  "ereal_of_enat \<infinity> = \<infinity>"
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2554
  by (simp_all add: ereal_of_enat_def)
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2555
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2556
lemma ereal_of_enat_le_iff[simp]: "ereal_of_enat m \<le> ereal_of_enat n \<longleftrightarrow> m \<le> n"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2557
  by (cases m n rule: enat2_cases) auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2558
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2559
lemma ereal_of_enat_less_iff[simp]: "ereal_of_enat m < ereal_of_enat n \<longleftrightarrow> m < n"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2560
  by (cases m n rule: enat2_cases) auto
50819
5601ae592679 added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents: 50104
diff changeset
  2561
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2562
lemma numeral_le_ereal_of_enat_iff[simp]: "numeral m \<le> ereal_of_enat n \<longleftrightarrow> numeral m \<le> n"
59587
8ea7b22525cb Removed the obsolete functions "natfloor" and "natceiling"
nipkow
parents: 59452
diff changeset
  2563
by (cases n) (auto)
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2564
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2565
lemma numeral_less_ereal_of_enat_iff[simp]: "numeral m < ereal_of_enat n \<longleftrightarrow> numeral m < n"
56889
48a745e1bde7 avoid the Complex constructor, use the more natural Re/Im view; moved csqrt to Complex.
hoelzl
parents: 56537
diff changeset
  2566
  by (cases n) auto
50819
5601ae592679 added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents: 50104
diff changeset
  2567
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2568
lemma ereal_of_enat_ge_zero_cancel_iff[simp]: "0 \<le> ereal_of_enat n \<longleftrightarrow> 0 \<le> n"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 68356
diff changeset
  2569
  by (cases n) (auto simp flip: enat_0)
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2570
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2571
lemma ereal_of_enat_gt_zero_cancel_iff[simp]: "0 < ereal_of_enat n \<longleftrightarrow> 0 < n"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 68356
diff changeset
  2572
  by (cases n) (auto simp flip: enat_0)
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2573
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2574
lemma ereal_of_enat_zero[simp]: "ereal_of_enat 0 = 0"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 68356
diff changeset
  2575
  by (auto simp flip: enat_0)
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2576
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2577
lemma ereal_of_enat_inf[simp]: "ereal_of_enat n = \<infinity> \<longleftrightarrow> n = \<infinity>"
50819
5601ae592679 added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents: 50104
diff changeset
  2578
  by (cases n) auto
5601ae592679 added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents: 50104
diff changeset
  2579
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2580
lemma ereal_of_enat_add: "ereal_of_enat (m + n) = ereal_of_enat m + ereal_of_enat n"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2581
  by (cases m n rule: enat2_cases) auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2582
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2583
lemma ereal_of_enat_sub:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2584
  assumes "n \<le> m"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2585
  shows "ereal_of_enat (m - n) = ereal_of_enat m - ereal_of_enat n "
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2586
  using assms by (cases m n rule: enat2_cases) auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2587
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2588
lemma ereal_of_enat_mult:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2589
  "ereal_of_enat (m * n) = ereal_of_enat m * ereal_of_enat n"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2590
  by (cases m n rule: enat2_cases) auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2591
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2592
lemmas ereal_of_enat_pushin = ereal_of_enat_add ereal_of_enat_sub ereal_of_enat_mult
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2593
lemmas ereal_of_enat_pushout = ereal_of_enat_pushin[symmetric]
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2594
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  2595
lemma ereal_of_enat_nonneg: "ereal_of_enat n \<ge> 0"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  2596
by(cases n) simp_all
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  2597
60637
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2598
lemma ereal_of_enat_Sup:
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2599
  assumes "A \<noteq> {}" shows "ereal_of_enat (Sup A) = (SUP a \<in> A. ereal_of_enat a)"
60637
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2600
proof (intro antisym mono_Sup)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2601
  show "ereal_of_enat (Sup A) \<le> (SUP a \<in> A. ereal_of_enat a)"
60637
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2602
  proof cases
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2603
    assume "finite A"
61188
b34551d94934 isabelle update_cartouches;
wenzelm
parents: 61166
diff changeset
  2604
    with \<open>A \<noteq> {}\<close> obtain a where "a \<in> A" "ereal_of_enat (Sup A) = ereal_of_enat a"
60637
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2605
      using Max_in[of A] by (auto simp: Sup_enat_def simp del: Max_in)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2606
    then show ?thesis
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2607
      by (auto intro: SUP_upper)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2608
  next
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2609
    assume "\<not> finite A"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2610
    have [simp]: "(SUP a \<in> A. ereal_of_enat a) = top"
60637
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2611
      unfolding SUP_eq_top_iff
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2612
    proof safe
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2613
      fix x :: ereal assume "x < top"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2614
      then obtain n :: nat where "x < n"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2615
        using less_PInf_Ex_of_nat top_ereal_def by auto
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2616
      obtain a where "a \<in> A - enat ` {.. n}"
61188
b34551d94934 isabelle update_cartouches;
wenzelm
parents: 61166
diff changeset
  2617
        by (metis \<open>\<not> finite A\<close> all_not_in_conv finite_Diff2 finite_atMost finite_imageI finite.emptyI)
60637
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2618
      then have "a \<in> A" "ereal n \<le> ereal_of_enat a"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2619
        by (auto simp: image_iff Ball_def)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2620
           (metis enat_iless enat_ord_simps(1) ereal_of_enat_less_iff ereal_of_enat_simps(1) less_le not_less)
61188
b34551d94934 isabelle update_cartouches;
wenzelm
parents: 61166
diff changeset
  2621
      with \<open>x < n\<close> show "\<exists>i\<in>A. x < ereal_of_enat i"
60637
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2622
        by (auto intro!: bexI[of _ a])
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2623
    qed
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2624
    show ?thesis
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2625
      by simp
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2626
  qed
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2627
qed (simp add: mono_def)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2628
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2629
lemma ereal_of_enat_SUP:
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  2630
  "A \<noteq> {} \<Longrightarrow> ereal_of_enat (SUP a\<in>A. f a) = (SUP a \<in> A. ereal_of_enat (f a))"
69861
62e47f06d22c avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
haftmann
parents: 69661
diff changeset
  2631
  by (simp add: ereal_of_enat_Sup image_comp)
62e47f06d22c avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
haftmann
parents: 69661
diff changeset
  2632
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2633
69593
3dda49e08b9d isabelle update -u control_cartouches;
wenzelm
parents: 69313
diff changeset
  2634
subsection "Limits on \<^typ>\<open>ereal\<close>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2635
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2636
lemma open_PInfty: "open A \<Longrightarrow> \<infinity> \<in> A \<Longrightarrow> (\<exists>x. {ereal x<..} \<subseteq> A)"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2637
  unfolding open_ereal_generated
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2638
proof (induct rule: generate_topology.induct)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2639
  case (Int A B)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2640
  then obtain x z where "\<infinity> \<in> A \<Longrightarrow> {ereal x <..} \<subseteq> A" "\<infinity> \<in> B \<Longrightarrow> {ereal z <..} \<subseteq> B"
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2641
    by auto
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2642
  with Int show ?case
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2643
    by (intro exI[of _ "max x z"]) fastforce
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2644
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2645
  case (Basis S)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2646
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2647
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2648
    have "x \<noteq> \<infinity> \<Longrightarrow> \<exists>t. x \<le> ereal t"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2649
      by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2650
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2651
  moreover note Basis
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2652
  ultimately show ?case
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2653
    by (auto split: ereal.split)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2654
qed (fastforce simp add: vimage_Union)+
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2655
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2656
lemma open_MInfty: "open A \<Longrightarrow> -\<infinity> \<in> A \<Longrightarrow> (\<exists>x. {..<ereal x} \<subseteq> A)"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2657
  unfolding open_ereal_generated
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2658
proof (induct rule: generate_topology.induct)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2659
  case (Int A B)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2660
  then obtain x z where "-\<infinity> \<in> A \<Longrightarrow> {..< ereal x} \<subseteq> A" "-\<infinity> \<in> B \<Longrightarrow> {..< ereal z} \<subseteq> B"
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2661
    by auto
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2662
  with Int show ?case
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2663
    by (intro exI[of _ "min x z"]) fastforce
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2664
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2665
  case (Basis S)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2666
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2667
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2668
    have "x \<noteq> - \<infinity> \<Longrightarrow> \<exists>t. ereal t \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2669
      by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2670
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2671
  moreover note Basis
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2672
  ultimately show ?case
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2673
    by (auto split: ereal.split)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2674
qed (fastforce simp add: vimage_Union)+
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2675
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2676
lemma open_ereal_vimage: "open S \<Longrightarrow> open (ereal -` S)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2677
  by (intro open_vimage continuous_intros)
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2678
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2679
lemma open_ereal: "open S \<Longrightarrow> open (ereal ` S)"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2680
  unfolding open_generated_order[where 'a=real]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2681
proof (induct rule: generate_topology.induct)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2682
  case (Basis S)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2683
  moreover {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2684
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2685
    have "ereal ` {..< x} = { -\<infinity> <..< ereal x }"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2686
      apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2687
      apply (case_tac xa)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2688
      apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2689
      done
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2690
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2691
  moreover {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2692
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2693
    have "ereal ` {x <..} = { ereal x <..< \<infinity> }"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2694
      apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2695
      apply (case_tac xa)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2696
      apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2697
      done
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2698
  }
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2699
  ultimately show ?case
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2700
     by auto
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2701
qed (auto simp add: image_Union image_Int)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2702
67685
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2703
lemma open_image_real_of_ereal:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2704
  fixes X::"ereal set"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2705
  assumes "open X"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2706
  assumes "\<infinity> \<notin> X"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2707
  assumes "-\<infinity> \<notin> X"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2708
  shows "open (real_of_ereal ` X)"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2709
proof -
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2710
  have "real_of_ereal ` X = ereal -` X"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2711
    apply safe
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2712
    subgoal by (metis assms(2) assms(3) real_of_ereal.elims vimageI)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2713
    subgoal using image_iff by fastforce
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2714
    done
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2715
  thus ?thesis
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2716
    by (auto intro!: open_ereal_vimage assms)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67452
diff changeset
  2717
qed
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2718
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2719
lemma eventually_finite:
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2720
  fixes x :: ereal
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2721
  assumes "\<bar>x\<bar> \<noteq> \<infinity>" "(f \<longlongrightarrow> x) F"
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2722
  shows "eventually (\<lambda>x. \<bar>f x\<bar> \<noteq> \<infinity>) F"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2723
proof -
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2724
  have "(f \<longlongrightarrow> ereal (real_of_ereal x)) F"
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2725
    using assms by (cases x) auto
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2726
  then have "eventually (\<lambda>x. f x \<in> ereal ` UNIV) F"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2727
    by (rule topological_tendstoD) (auto intro: open_ereal)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2728
  also have "(\<lambda>x. f x \<in> ereal ` UNIV) = (\<lambda>x. \<bar>f x\<bar> \<noteq> \<infinity>)"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2729
    by auto
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2730
  finally show ?thesis .
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2731
qed
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2732
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2733
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2734
lemma open_ereal_def:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2735
  "open A \<longleftrightarrow> open (ereal -` A) \<and> (\<infinity> \<in> A \<longrightarrow> (\<exists>x. {ereal x <..} \<subseteq> A)) \<and> (-\<infinity> \<in> A \<longrightarrow> (\<exists>x. {..<ereal x} \<subseteq> A))"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2736
  (is "open A \<longleftrightarrow> ?rhs")
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2737
proof
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2738
  assume "open A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2739
  then show ?rhs
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2740
    using open_PInfty open_MInfty open_ereal_vimage by auto
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2741
next
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2742
  assume "?rhs"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2743
  then obtain x y where A: "open (ereal -` A)" "\<infinity> \<in> A \<Longrightarrow> {ereal x<..} \<subseteq> A" "-\<infinity> \<in> A \<Longrightarrow> {..< ereal y} \<subseteq> A"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2744
    by auto
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2745
  have *: "A = ereal ` (ereal -` A) \<union> (if \<infinity> \<in> A then {ereal x<..} else {}) \<union> (if -\<infinity> \<in> A then {..< ereal y} else {})"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2746
    using A(2,3) by auto
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2747
  from open_ereal[OF A(1)] show "open A"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2748
    by (subst *) (auto simp: open_Un)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2749
qed
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2750
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2751
lemma open_PInfty2:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2752
  assumes "open A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2753
    and "\<infinity> \<in> A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2754
  obtains x where "{ereal x<..} \<subseteq> A"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2755
  using open_PInfty[OF assms] by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2756
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2757
lemma open_MInfty2:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2758
  assumes "open A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2759
    and "-\<infinity> \<in> A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2760
  obtains x where "{..<ereal x} \<subseteq> A"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2761
  using open_MInfty[OF assms] by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2762
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2763
lemma ereal_openE:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2764
  assumes "open A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2765
  obtains x y where "open (ereal -` A)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2766
    and "\<infinity> \<in> A \<Longrightarrow> {ereal x<..} \<subseteq> A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2767
    and "-\<infinity> \<in> A \<Longrightarrow> {..<ereal y} \<subseteq> A"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2768
  using assms open_ereal_def by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2769
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2770
lemmas open_ereal_lessThan = open_lessThan[where 'a=ereal]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2771
lemmas open_ereal_greaterThan = open_greaterThan[where 'a=ereal]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2772
lemmas ereal_open_greaterThanLessThan = open_greaterThanLessThan[where 'a=ereal]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2773
lemmas closed_ereal_atLeast = closed_atLeast[where 'a=ereal]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2774
lemmas closed_ereal_atMost = closed_atMost[where 'a=ereal]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2775
lemmas closed_ereal_atLeastAtMost = closed_atLeastAtMost[where 'a=ereal]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2776
lemmas closed_ereal_singleton = closed_singleton[where 'a=ereal]
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2777
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2778
lemma ereal_open_cont_interval:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2779
  fixes S :: "ereal set"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2780
  assumes "open S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2781
    and "x \<in> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2782
    and "\<bar>x\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2783
  obtains e where "e > 0" and "{x-e <..< x+e} \<subseteq> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2784
proof -
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2785
  from \<open>open S\<close>
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2786
  have "open (ereal -` S)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2787
    by (rule ereal_openE)
63060
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  2788
  then obtain e where "e > 0" and e: "dist y (real_of_ereal x) < e \<Longrightarrow> ereal y \<in> S" for y
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
  2789
    using assms unfolding open_dist by force
41975
d47eabd80e59 simplified definition of open_extreal
hoelzl
parents: 41974
diff changeset
  2790
  show thesis
d47eabd80e59 simplified definition of open_extreal
hoelzl
parents: 41974
diff changeset
  2791
  proof (intro that subsetI)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2792
    show "0 < ereal e"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2793
      using \<open>0 < e\<close> by auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2794
    fix y
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2795
    assume "y \<in> {x - ereal e<..<x + ereal e}"
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  2796
    with assms obtain t where "y = ereal t" "dist t (real_of_ereal x) < e"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2797
      by (cases y) (auto simp: dist_real_def)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2798
    then show "y \<in> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2799
      using e[of t] by auto
41975
d47eabd80e59 simplified definition of open_extreal
hoelzl
parents: 41974
diff changeset
  2800
  qed
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2801
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2802
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2803
lemma ereal_open_cont_interval2:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2804
  fixes S :: "ereal set"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2805
  assumes "open S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2806
    and "x \<in> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2807
    and x: "\<bar>x\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2808
  obtains a b where "a < x" and "x < b" and "{a <..< b} \<subseteq> S"
53381
355a4cac5440 tuned proofs -- less guessing;
wenzelm
parents: 53374
diff changeset
  2809
proof -
355a4cac5440 tuned proofs -- less guessing;
wenzelm
parents: 53374
diff changeset
  2810
  obtain e where "0 < e" "{x - e<..<x + e} \<subseteq> S"
355a4cac5440 tuned proofs -- less guessing;
wenzelm
parents: 53374
diff changeset
  2811
    using assms by (rule ereal_open_cont_interval)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2812
  with that[of "x - e" "x + e"] ereal_between[OF x, of e]
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2813
  show thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2814
    by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2815
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2816
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2817
subsubsection \<open>Convergent sequences\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2818
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2819
lemma lim_real_of_ereal[simp]:
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2820
  assumes lim: "(f \<longlongrightarrow> ereal x) net"
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2821
  shows "((\<lambda>x. real_of_ereal (f x)) \<longlongrightarrow> x) net"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2822
proof (intro topological_tendstoI)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2823
  fix S
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2824
  assume "open S" and "x \<in> S"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2825
  then have S: "open S" "ereal x \<in> ereal ` S"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2826
    by (simp_all add: inj_image_mem_iff)
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  2827
  show "eventually (\<lambda>x. real_of_ereal (f x) \<in> S) net"
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61806
diff changeset
  2828
    by (auto intro: eventually_mono [OF lim[THEN topological_tendstoD, OF open_ereal, OF S]])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2829
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2830
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2831
lemma lim_ereal[simp]: "((\<lambda>n. ereal (f n)) \<longlongrightarrow> ereal x) net \<longleftrightarrow> (f \<longlongrightarrow> x) net"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2832
  by (auto dest!: lim_real_of_ereal)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2833
61880
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61810
diff changeset
  2834
lemma convergent_real_imp_convergent_ereal:
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61810
diff changeset
  2835
  assumes "convergent a"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61810
diff changeset
  2836
  shows "convergent (\<lambda>n. ereal (a n))" and "lim (\<lambda>n. ereal (a n)) = ereal (lim a)"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61810
diff changeset
  2837
proof -
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2838
  from assms obtain L where L: "a \<longlonglongrightarrow> L" unfolding convergent_def ..
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2839
  hence lim: "(\<lambda>n. ereal (a n)) \<longlonglongrightarrow> ereal L" using lim_ereal by auto
61880
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61810
diff changeset
  2840
  thus "convergent (\<lambda>n. ereal (a n))" unfolding convergent_def ..
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61810
diff changeset
  2841
  thus "lim (\<lambda>n. ereal (a n)) = ereal (lim a)" using lim L limI by metis
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61810
diff changeset
  2842
qed
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61810
diff changeset
  2843
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2844
lemma tendsto_PInfty: "(f \<longlongrightarrow> \<infinity>) F \<longleftrightarrow> (\<forall>r. eventually (\<lambda>x. ereal r < f x) F)"
51022
78de6c7e8a58 replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
hoelzl
parents: 51000
diff changeset
  2845
proof -
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2846
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2847
    fix l :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2848
    assume "\<forall>r. eventually (\<lambda>x. ereal r < f x) F"
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  2849
    from this[THEN spec, of "real_of_ereal l"] have "l \<noteq> \<infinity> \<Longrightarrow> eventually (\<lambda>x. l < f x) F"
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61806
diff changeset
  2850
      by (cases l) (auto elim: eventually_mono)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2851
  }
51022
78de6c7e8a58 replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
hoelzl
parents: 51000
diff changeset
  2852
  then show ?thesis
78de6c7e8a58 replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
hoelzl
parents: 51000
diff changeset
  2853
    by (auto simp: order_tendsto_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2854
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2855
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2856
lemma tendsto_PInfty': "(f \<longlongrightarrow> \<infinity>) F = (\<forall>r>c. eventually (\<lambda>x. ereal r < f x) F)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2857
proof (subst tendsto_PInfty, intro iffI allI impI)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2858
  assume A: "\<forall>r>c. eventually (\<lambda>x. ereal r < f x) F"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2859
  fix r :: real
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2860
  from A have A: "eventually (\<lambda>x. ereal r < f x) F" if "r > c" for r using that by blast
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2861
  show "eventually (\<lambda>x. ereal r < f x) F"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2862
  proof (cases "r > c")
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2863
    case False
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2864
    hence B: "ereal r \<le> ereal (c + 1)" by simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2865
    have "c < c + 1" by simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2866
    from A[OF this] show "eventually (\<lambda>x. ereal r < f x) F"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2867
      by eventually_elim (rule le_less_trans[OF B])
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2868
  qed (simp add: A)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2869
qed simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2870
57025
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
  2871
lemma tendsto_PInfty_eq_at_top:
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2872
  "((\<lambda>z. ereal (f z)) \<longlongrightarrow> \<infinity>) F \<longleftrightarrow> (LIM z F. f z :> at_top)"
57025
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
  2873
  unfolding tendsto_PInfty filterlim_at_top_dense by simp
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
  2874
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2875
lemma tendsto_MInfty: "(f \<longlongrightarrow> -\<infinity>) F \<longleftrightarrow> (\<forall>r. eventually (\<lambda>x. f x < ereal r) F)"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2876
  unfolding tendsto_def
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2877
proof safe
53381
355a4cac5440 tuned proofs -- less guessing;
wenzelm
parents: 53374
diff changeset
  2878
  fix S :: "ereal set"
355a4cac5440 tuned proofs -- less guessing;
wenzelm
parents: 53374
diff changeset
  2879
  assume "open S" "-\<infinity> \<in> S"
355a4cac5440 tuned proofs -- less guessing;
wenzelm
parents: 53374
diff changeset
  2880
  from open_MInfty[OF this] obtain B where "{..<ereal B} \<subseteq> S" ..
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2881
  moreover
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2882
  assume "\<forall>r::real. eventually (\<lambda>z. f z < r) F"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2883
  then have "eventually (\<lambda>z. f z \<in> {..< B}) F"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2884
    by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2885
  ultimately show "eventually (\<lambda>z. f z \<in> S) F"
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61806
diff changeset
  2886
    by (auto elim!: eventually_mono)
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2887
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2888
  fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2889
  assume "\<forall>S. open S \<longrightarrow> -\<infinity> \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) F"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2890
  from this[rule_format, of "{..< ereal x}"] show "eventually (\<lambda>y. f y < ereal x) F"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2891
    by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2892
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2893
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2894
lemma tendsto_MInfty': "(f \<longlongrightarrow> -\<infinity>) F = (\<forall>r<c. eventually (\<lambda>x. ereal r > f x) F)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2895
proof (subst tendsto_MInfty, intro iffI allI impI)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2896
  assume A: "\<forall>r<c. eventually (\<lambda>x. ereal r > f x) F"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2897
  fix r :: real
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2898
  from A have A: "eventually (\<lambda>x. ereal r > f x) F" if "r < c" for r using that by blast
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2899
  show "eventually (\<lambda>x. ereal r > f x) F"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2900
  proof (cases "r < c")
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2901
    case False
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2902
    hence B: "ereal r \<ge> ereal (c - 1)" by simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2903
    have "c > c - 1" by simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2904
    from A[OF this] show "eventually (\<lambda>x. ereal r > f x) F"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2905
      by eventually_elim (erule less_le_trans[OF _ B])
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2906
  qed (simp add: A)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2907
qed simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2908
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2909
lemma Lim_PInfty: "f \<longlonglongrightarrow> \<infinity> \<longleftrightarrow> (\<forall>B. \<exists>N. \<forall>n\<ge>N. f n \<ge> ereal B)"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2910
  unfolding tendsto_PInfty eventually_sequentially
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2911
proof safe
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2912
  fix r
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2913
  assume "\<forall>r. \<exists>N. \<forall>n\<ge>N. ereal r \<le> f n"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2914
  then obtain N where "\<forall>n\<ge>N. ereal (r + 1) \<le> f n"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2915
    by blast
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2916
  moreover have "ereal r < ereal (r + 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2917
    by auto
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2918
  ultimately show "\<exists>N. \<forall>n\<ge>N. ereal r < f n"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2919
    by (blast intro: less_le_trans)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2920
qed (blast intro: less_imp_le)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2921
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2922
lemma Lim_MInfty: "f \<longlonglongrightarrow> -\<infinity> \<longleftrightarrow> (\<forall>B. \<exists>N. \<forall>n\<ge>N. ereal B \<ge> f n)"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2923
  unfolding tendsto_MInfty eventually_sequentially
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2924
proof safe
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2925
  fix r
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2926
  assume "\<forall>r. \<exists>N. \<forall>n\<ge>N. f n \<le> ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2927
  then obtain N where "\<forall>n\<ge>N. f n \<le> ereal (r - 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2928
    by blast
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2929
  moreover have "ereal (r - 1) < ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2930
    by auto
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2931
  ultimately show "\<exists>N. \<forall>n\<ge>N. f n < ereal r"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2932
    by (blast intro: le_less_trans)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2933
qed (blast intro: less_imp_le)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2934
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2935
lemma Lim_bounded_PInfty: "f \<longlonglongrightarrow> l \<Longrightarrow> (\<And>n. f n \<le> ereal B) \<Longrightarrow> l \<noteq> \<infinity>"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2936
  using LIMSEQ_le_const2[of f l "ereal B"] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2937
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2938
lemma Lim_bounded_MInfty: "f \<longlonglongrightarrow> l \<Longrightarrow> (\<And>n. ereal B \<le> f n) \<Longrightarrow> l \<noteq> -\<infinity>"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2939
  using LIMSEQ_le_const[of f l "ereal B"] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2940
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2941
lemma tendsto_zero_erealI:
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2942
  assumes "\<And>e. e > 0 \<Longrightarrow> eventually (\<lambda>x. \<bar>f x\<bar> < ereal e) F"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2943
  shows   "(f \<longlongrightarrow> 0) F"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2944
proof (subst filterlim_cong[OF refl refl])
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2945
  from assms[OF zero_less_one] show "eventually (\<lambda>x. f x = ereal (real_of_ereal (f x))) F"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2946
    by eventually_elim (auto simp: ereal_real)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2947
  hence "eventually (\<lambda>x. abs (real_of_ereal (f x)) < e) F" if "e > 0" for e using assms[OF that]
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2948
    by eventually_elim (simp add: real_less_ereal_iff that)
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  2949
  hence "((\<lambda>x. real_of_ereal (f x)) \<longlongrightarrow> 0) F" unfolding tendsto_iff
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2950
    by (auto simp: tendsto_iff dist_real_def)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2951
  thus "((\<lambda>x. ereal (real_of_ereal (f x))) \<longlongrightarrow> 0) F" by (simp add: zero_ereal_def)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2952
qed
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  2953
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2954
lemma tendsto_explicit:
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2955
  "f \<longlonglongrightarrow> f0 \<longleftrightarrow> (\<forall>S. open S \<longrightarrow> f0 \<in> S \<longrightarrow> (\<exists>N. \<forall>n\<ge>N. f n \<in> S))"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2956
  unfolding tendsto_def eventually_sequentially by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2957
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2958
lemma Lim_bounded_PInfty2: "f \<longlonglongrightarrow> l \<Longrightarrow> \<forall>n\<ge>N. f n \<le> ereal B \<Longrightarrow> l \<noteq> \<infinity>"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2959
  using LIMSEQ_le_const2[of f l "ereal B"] by fastforce
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2960
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2961
lemma real_of_ereal_mult[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2962
  fixes a b :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  2963
  shows "real_of_ereal (a * b) = real_of_ereal a * real_of_ereal b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2964
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2965
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2966
lemma real_of_ereal_eq_0:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2967
  fixes x :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  2968
  shows "real_of_ereal x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity> \<or> x = 0"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2969
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2970
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2971
lemma tendsto_ereal_realD:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2972
  fixes f :: "'a \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2973
  assumes "x \<noteq> 0"
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2974
    and tendsto: "((\<lambda>x. ereal (real_of_ereal (f x))) \<longlongrightarrow> x) net"
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2975
  shows "(f \<longlongrightarrow> x) net"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2976
proof (intro topological_tendstoI)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2977
  fix S
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2978
  assume S: "open S" "x \<in> S"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2979
  with \<open>x \<noteq> 0\<close> have "open (S - {0})" "x \<in> S - {0}"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2980
    by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2981
  from tendsto[THEN topological_tendstoD, OF this]
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2982
  show "eventually (\<lambda>x. f x \<in> S) net"
44142
8e27e0177518 avoid warnings about duplicate rules
huffman
parents: 43943
diff changeset
  2983
    by (rule eventually_rev_mp) (auto simp: ereal_real)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2984
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2985
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2986
lemma tendsto_ereal_realI:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2987
  fixes f :: "'a \<Rightarrow> ereal"
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2988
  assumes x: "\<bar>x\<bar> \<noteq> \<infinity>" and tendsto: "(f \<longlongrightarrow> x) net"
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2989
  shows "((\<lambda>x. ereal (real_of_ereal (f x))) \<longlongrightarrow> x) net"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2990
proof (intro topological_tendstoI)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2991
  fix S
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2992
  assume "open S" and "x \<in> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2993
  with x have "open (S - {\<infinity>, -\<infinity>})" "x \<in> S - {\<infinity>, -\<infinity>}"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2994
    by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2995
  from tendsto[THEN topological_tendstoD, OF this]
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  2996
  show "eventually (\<lambda>x. ereal (real_of_ereal (f x)) \<in> S) net"
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61806
diff changeset
  2997
    by (elim eventually_mono) (auto simp: ereal_real)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2998
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2999
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3000
lemma ereal_mult_cancel_left:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3001
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3002
  shows "a * b = a * c \<longleftrightarrow> (\<bar>a\<bar> = \<infinity> \<and> 0 < b * c) \<or> a = 0 \<or> b = c"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3003
  by (cases rule: ereal3_cases[of a b c]) (simp_all add: zero_less_mult_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3004
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3005
lemma tendsto_add_ereal:
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3006
  fixes x y :: ereal
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3007
  assumes x: "\<bar>x\<bar> \<noteq> \<infinity>" and y: "\<bar>y\<bar> \<noteq> \<infinity>"
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3008
  assumes f: "(f \<longlongrightarrow> x) F" and g: "(g \<longlongrightarrow> y) F"
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3009
  shows "((\<lambda>x. f x + g x) \<longlongrightarrow> x + y) F"
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3010
proof -
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3011
  from x obtain r where x': "x = ereal r" by (cases x) auto
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3012
  with f have "((\<lambda>i. real_of_ereal (f i)) \<longlongrightarrow> r) F" by simp
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3013
  moreover
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3014
  from y obtain p where y': "y = ereal p" by (cases y) auto
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3015
  with g have "((\<lambda>i. real_of_ereal (g i)) \<longlongrightarrow> p) F" by simp
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3016
  ultimately have "((\<lambda>i. real_of_ereal (f i) + real_of_ereal (g i)) \<longlongrightarrow> r + p) F"
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3017
    by (rule tendsto_add)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3018
  moreover
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3019
  from eventually_finite[OF x f] eventually_finite[OF y g]
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  3020
  have "eventually (\<lambda>x. f x + g x = ereal (real_of_ereal (f x) + real_of_ereal (g x))) F"
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3021
    by eventually_elim auto
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3022
  ultimately show ?thesis
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3023
    by (simp add: x' y' cong: filterlim_cong)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3024
qed
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  3025
62371
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3026
lemma tendsto_add_ereal_nonneg:
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3027
  fixes x y :: "ereal"
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3028
  assumes "x \<noteq> -\<infinity>" "y \<noteq> -\<infinity>" "(f \<longlongrightarrow> x) F" "(g \<longlongrightarrow> y) F"
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3029
  shows "((\<lambda>x. f x + g x) \<longlongrightarrow> x + y) F"
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3030
proof cases
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3031
  assume "x = \<infinity> \<or> y = \<infinity>"
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3032
  moreover
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3033
  { fix y :: ereal and f g :: "'a \<Rightarrow> ereal" assume "y \<noteq> -\<infinity>" "(f \<longlongrightarrow> \<infinity>) F" "(g \<longlongrightarrow> y) F"
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3034
    then obtain y' where "-\<infinity> < y'" "y' < y"
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3035
      using dense[of "-\<infinity>" y] by auto
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3036
    have "((\<lambda>x. f x + g x) \<longlongrightarrow> \<infinity>) F"
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3037
    proof (rule tendsto_sandwich)
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3038
      have "\<forall>\<^sub>F x in F. y' < g x"
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3039
        using order_tendstoD(1)[OF \<open>(g \<longlongrightarrow> y) F\<close> \<open>y' < y\<close>] by auto
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3040
      then show "\<forall>\<^sub>F x in F. f x + y' \<le> f x + g x"
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3041
        by eventually_elim (auto intro!: add_mono)
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3042
      show "\<forall>\<^sub>F n in F. f n + g n \<le> \<infinity>" "((\<lambda>n. \<infinity>) \<longlongrightarrow> \<infinity>) F"
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3043
        by auto
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3044
      show "((\<lambda>x. f x + y') \<longlongrightarrow> \<infinity>) F"
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3045
        using tendsto_cadd_ereal[of y' \<infinity> f F] \<open>(f \<longlongrightarrow> \<infinity>) F\<close> \<open>-\<infinity> < y'\<close> by auto
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3046
    qed }
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3047
  note this[of y f g] this[of x g f]
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3048
  ultimately show ?thesis
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3049
    using assms by (auto simp: add_ac)
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3050
next
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3051
  assume "\<not> (x = \<infinity> \<or> y = \<infinity>)"
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3052
  with assms tendsto_add_ereal[of x y f F g]
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3053
  show ?thesis
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3054
    by auto
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3055
qed
7c288c0c7300 add tendsto_add_ereal_nonneg
hoelzl
parents: 62369
diff changeset
  3056
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3057
lemma ereal_inj_affinity:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  3058
  fixes m t :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3059
  assumes "\<bar>m\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3060
    and "m \<noteq> 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3061
    and "\<bar>t\<bar> \<noteq> \<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3062
  shows "inj_on (\<lambda>x. m * x + t) A"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3063
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3064
  by (cases rule: ereal2_cases[of m t])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3065
     (auto intro!: inj_onI simp: ereal_add_cancel_right ereal_mult_cancel_left)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3066
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3067
lemma ereal_PInfty_eq_plus[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  3068
  fixes a b :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3069
  shows "\<infinity> = a + b \<longleftrightarrow> a = \<infinity> \<or> b = \<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3070
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3071
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3072
lemma ereal_MInfty_eq_plus[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  3073
  fixes a b :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3074
  shows "-\<infinity> = a + b \<longleftrightarrow> (a = -\<infinity> \<and> b \<noteq> \<infinity>) \<or> (b = -\<infinity> \<and> a \<noteq> \<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3075
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3076
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3077
lemma ereal_less_divide_pos:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  3078
  fixes x y :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  3079
  shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y < z / x \<longleftrightarrow> x * y < z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3080
  by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3081
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3082
lemma ereal_divide_less_pos:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  3083
  fixes x y z :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  3084
  shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y / x < z \<longleftrightarrow> y < x * z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3085
  by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3086
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3087
lemma ereal_divide_eq:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  3088
  fixes a b c :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  3089
  shows "b \<noteq> 0 \<Longrightarrow> \<bar>b\<bar> \<noteq> \<infinity> \<Longrightarrow> a / b = c \<longleftrightarrow> a = b * c"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3090
  by (cases rule: ereal3_cases[of a b c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3091
     (simp_all add: field_simps)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3092
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  3093
lemma ereal_inverse_not_MInfty[simp]: "inverse (a::ereal) \<noteq> -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3094
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3095
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3096
lemma ereal_mult_m1[simp]: "x * ereal (-1) = -x"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3097
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3098
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3099
lemma ereal_real':
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3100
  assumes "\<bar>x\<bar> \<noteq> \<infinity>"
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  3101
  shows "ereal (real_of_ereal x) = x"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  3102
  using assms by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3103
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  3104
lemma real_ereal_id: "real_of_ereal \<circ> ereal = id"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3105
proof -
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3106
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3107
    fix x
67091
1393c2340eec more symbols;
wenzelm
parents: 66936
diff changeset
  3108
    have "(real_of_ereal \<circ> ereal) x = id x"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3109
      by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3110
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3111
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3112
    using ext by blast
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3113
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3114
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  3115
lemma open_image_ereal: "open(UNIV-{ \<infinity> , (-\<infinity> :: ereal)})"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3116
  by (metis range_ereal open_ereal open_UNIV)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3117
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3118
lemma ereal_le_distrib:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3119
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3120
  shows "c * (a + b) \<le> c * a + c * b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3121
  by (cases rule: ereal3_cases[of a b c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3122
     (auto simp add: field_simps not_le mult_le_0_iff mult_less_0_iff)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3123
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  3124
lemma ereal_pos_distrib:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3125
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3126
  assumes "0 \<le> c"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3127
    and "c \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3128
  shows "c * (a + b) = c * a + c * b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3129
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3130
  by (cases rule: ereal3_cases[of a b c])
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3131
    (auto simp add: field_simps not_le mult_le_0_iff mult_less_0_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  3132
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3133
lemma ereal_LimI_finite:
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3134
  fixes x :: ereal
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3135
  assumes "\<bar>x\<bar> \<noteq> \<infinity>"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3136
    and "\<And>r. 0 < r \<Longrightarrow> \<exists>N. \<forall>n\<ge>N. u n < x + r \<and> x < u n + r"
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3137
  shows "u \<longlonglongrightarrow> x"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3138
proof (rule topological_tendstoI, unfold eventually_sequentially)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3139
  obtain rx where rx: "x = ereal rx"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3140
    using assms by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3141
  fix S
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3142
  assume "open S" and "x \<in> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3143
  then have "open (ereal -` S)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3144
    unfolding open_ereal_def by auto
63060
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  3145
  with \<open>x \<in> S\<close> obtain r where "0 < r" and dist: "dist y rx < r \<Longrightarrow> ereal y \<in> S" for y
62101
26c0a70f78a3 add uniform spaces
hoelzl
parents: 62083
diff changeset
  3146
    unfolding open_dist rx by auto
63060
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  3147
  then obtain n
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  3148
    where upper: "u N < x + ereal r"
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  3149
      and lower: "x < u N + ereal r"
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  3150
      if "n \<le> N" for N
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3151
    using assms(2)[of "ereal r"] by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3152
  show "\<exists>N. \<forall>n\<ge>N. u n \<in> S"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3153
  proof (safe intro!: exI[of _ n])
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3154
    fix N
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3155
    assume "n \<le> N"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  3156
    from upper[OF this] lower[OF this] assms \<open>0 < r\<close>
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3157
    have "u N \<notin> {\<infinity>,(-\<infinity>)}"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3158
      by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3159
    then obtain ra where ra_def: "(u N) = ereal ra"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3160
      by (cases "u N") auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3161
    then have "rx < ra + r" and "ra < rx + r"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  3162
      using rx assms \<open>0 < r\<close> lower[OF \<open>n \<le> N\<close>] upper[OF \<open>n \<le> N\<close>]
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3163
      by auto
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  3164
    then have "dist (real_of_ereal (u N)) rx < r"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3165
      using rx ra_def
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3166
      by (auto simp: dist_real_def abs_diff_less_iff field_simps)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3167
    from dist[OF this] show "u N \<in> S"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  3168
      using \<open>u N  \<notin> {\<infinity>, -\<infinity>}\<close>
62390
842917225d56 more canonical names
nipkow
parents: 62378
diff changeset
  3169
      by (auto simp: ereal_real split: if_split_asm)
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3170
  qed
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3171
qed
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3172
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3173
lemma tendsto_obtains_N:
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3174
  assumes "f \<longlonglongrightarrow> f0"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3175
  assumes "open S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3176
    and "f0 \<in> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3177
  obtains N where "\<forall>n\<ge>N. f n \<in> S"
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  3178
  using assms using tendsto_def
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3179
  using tendsto_explicit[of f f0] assms by auto
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3180
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3181
lemma ereal_LimI_finite_iff:
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3182
  fixes x :: ereal
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3183
  assumes "\<bar>x\<bar> \<noteq> \<infinity>"
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3184
  shows "u \<longlonglongrightarrow> x \<longleftrightarrow> (\<forall>r. 0 < r \<longrightarrow> (\<exists>N. \<forall>n\<ge>N. u n < x + r \<and> x < u n + r))"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3185
  (is "?lhs \<longleftrightarrow> ?rhs")
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3186
proof
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3187
  assume lim: "u \<longlonglongrightarrow> x"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3188
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3189
    fix r :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3190
    assume "r > 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3191
    then obtain N where "\<forall>n\<ge>N. u n \<in> {x - r <..< x + r}"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3192
       apply (subst tendsto_obtains_N[of u x "{x - r <..< x + r}"])
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  3193
       using lim ereal_between[of x r] assms \<open>r > 0\<close>
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3194
       apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3195
       done
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3196
    then have "\<exists>N. \<forall>n\<ge>N. u n < x + r \<and> x < u n + r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3197
      using ereal_minus_less[of r x]
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3198
      by (cases r) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3199
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3200
  then show ?rhs
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3201
    by auto
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3202
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3203
  assume ?rhs
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3204
  then show "u \<longlonglongrightarrow> x"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3205
    using ereal_LimI_finite[of x] assms by auto
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3206
qed
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3207
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  3208
lemma ereal_Limsup_uminus:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3209
  fixes f :: "'a \<Rightarrow> ereal"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3210
  shows "Limsup net (\<lambda>x. - (f x)) = - Liminf net f"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  3211
  unfolding Limsup_def Liminf_def ereal_SUP_uminus ereal_INF_uminus_eq ..
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3212
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  3213
lemma liminf_bounded_iff:
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  3214
  fixes x :: "nat \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3215
  shows "C \<le> liminf x \<longleftrightarrow> (\<forall>B<C. \<exists>N. \<forall>n\<ge>N. B < x n)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3216
  (is "?lhs \<longleftrightarrow> ?rhs")
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  3217
  unfolding le_Liminf_iff eventually_sequentially ..
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  3218
59679
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3219
lemma Liminf_add_le:
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3220
  fixes f g :: "_ \<Rightarrow> ereal"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3221
  assumes F: "F \<noteq> bot"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3222
  assumes ev: "eventually (\<lambda>x. 0 \<le> f x) F" "eventually (\<lambda>x. 0 \<le> g x) F"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3223
  shows "Liminf F f + Liminf F g \<le> Liminf F (\<lambda>x. f x + g x)"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3224
  unfolding Liminf_def
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3225
proof (subst SUP_ereal_add_left[symmetric])
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3226
  let ?F = "{P. eventually P F}"
69313
b021008c5397 removed legacy input syntax
haftmann
parents: 69260
diff changeset
  3227
  let ?INF = "\<lambda>P g. Inf (g ` (Collect P))"
59679
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3228
  show "?F \<noteq> {}"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3229
    by (auto intro: eventually_True)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3230
  show "(SUP P\<in>?F. ?INF P g) \<noteq> - \<infinity>"
59679
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3231
    unfolding bot_ereal_def[symmetric] SUP_bot_conv INF_eq_bot_iff
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3232
    by (auto intro!: exI[of _ 0] ev simp: bot_ereal_def)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3233
  have "(SUP P\<in>?F. ?INF P f + (SUP P\<in>?F. ?INF P g)) \<le> (SUP P\<in>?F. (SUP P'\<in>?F. ?INF P f + ?INF P' g))"
59679
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3234
  proof (safe intro!: SUP_mono bexI[of _ "\<lambda>x. P x \<and> 0 \<le> f x" for P])
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3235
    fix P let ?P' = "\<lambda>x. P x \<and> 0 \<le> f x"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3236
    assume "eventually P F"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3237
    with ev show "eventually ?P' F"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3238
      by eventually_elim auto
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3239
    have "?INF P f + (SUP P\<in>?F. ?INF P g) \<le> ?INF ?P' f + (SUP P\<in>?F. ?INF P g)"
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  3240
      by (intro add_mono INF_mono) auto
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3241
    also have "\<dots> = (SUP P'\<in>?F. ?INF ?P' f + ?INF P' g)"
59679
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3242
    proof (rule SUP_ereal_add_right[symmetric])
69313
b021008c5397 removed legacy input syntax
haftmann
parents: 69260
diff changeset
  3243
      show "Inf (f ` {x. P x \<and> 0 \<le> f x}) \<noteq> - \<infinity>"
59679
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3244
        unfolding bot_ereal_def[symmetric] INF_eq_bot_iff
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3245
        by (auto intro!: exI[of _ 0] ev simp: bot_ereal_def)
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3246
    qed fact
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3247
    finally show "?INF P f + (SUP P\<in>?F. ?INF P g) \<le> (SUP P'\<in>?F. ?INF ?P' f + ?INF P' g)" .
59679
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3248
  qed
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3249
  also have "\<dots> \<le> (SUP P\<in>?F. INF x\<in>Collect P. f x + g x)"
59679
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3250
  proof (safe intro!: SUP_least)
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3251
    fix P Q assume *: "eventually P F" "eventually Q F"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3252
    show "?INF P f + ?INF Q g \<le> (SUP P\<in>?F. INF x\<in>Collect P. f x + g x)"
59679
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3253
    proof (rule SUP_upper2)
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3254
      show "(\<lambda>x. P x \<and> Q x) \<in> ?F"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3255
        using * by (auto simp: eventually_conj)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3256
      show "?INF P f + ?INF Q g \<le> (INF x\<in>{x. P x \<and> Q x}. f x + g x)"
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  3257
        by (intro INF_greatest add_mono) (auto intro: INF_lower)
59679
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3258
    qed
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3259
  qed
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3260
  finally show "(SUP P\<in>?F. ?INF P f + (SUP P\<in>?F. ?INF P g)) \<le> (SUP P\<in>?F. INF x\<in>Collect P. f x + g x)" .
59679
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3261
qed
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  3262
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3263
lemma Sup_ereal_mult_right':
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3264
  assumes nonempty: "Y \<noteq> {}"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3265
  and x: "x \<ge> 0"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3266
  shows "(SUP i\<in>Y. f i) * ereal x = (SUP i\<in>Y. f i * ereal x)" (is "?lhs = ?rhs")
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3267
proof(cases "x = 0")
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3268
  case True thus ?thesis by(auto simp add: nonempty zero_ereal_def[symmetric])
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3269
next
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3270
  case False
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3271
  show ?thesis
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3272
  proof(rule antisym)
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3273
    show "?rhs \<le> ?lhs"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3274
      by(rule SUP_least)(simp add: ereal_mult_right_mono SUP_upper x)
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3275
  next
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3276
    have "?lhs / ereal x = (SUP i\<in>Y. f i) * (ereal x / ereal x)" by(simp only: ereal_times_divide_eq)
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3277
    also have "\<dots> = (SUP i\<in>Y. f i)" using False by simp
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3278
    also have "\<dots> \<le> ?rhs / x"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3279
    proof(rule SUP_least)
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3280
      fix i
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3281
      assume "i \<in> Y"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3282
      have "f i = f i * (ereal x / ereal x)" using False by simp
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3283
      also have "\<dots> = f i * x / x" by(simp only: ereal_times_divide_eq)
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3284
      also from \<open>i \<in> Y\<close> have "f i * x \<le> ?rhs" by(rule SUP_upper)
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3285
      hence "f i * x / x \<le> ?rhs / x" using x False by simp
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3286
      finally show "f i \<le> ?rhs / x" .
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3287
    qed
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3288
    finally have "(?lhs / x) * x \<le> (?rhs / x) * x"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3289
      by(rule ereal_mult_right_mono)(simp add: x)
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3290
    also have "\<dots> = ?rhs" using False ereal_divide_eq mult.commute by force
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3291
    also have "(?lhs / x) * x = ?lhs" using False ereal_divide_eq mult.commute by force
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3292
    finally show "?lhs \<le> ?rhs" .
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3293
  qed
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  3294
qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  3295
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  3296
lemma Sup_ereal_mult_left':
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3297
  "\<lbrakk> Y \<noteq> {}; x \<ge> 0 \<rbrakk> \<Longrightarrow> ereal x * (SUP i\<in>Y. f i) = (SUP i\<in>Y. ereal x * f i)"
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  3298
by(subst (1 2) mult.commute)(rule Sup_ereal_mult_right')
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  3299
60637
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3300
lemma sup_continuous_add[order_continuous_intros]:
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3301
  fixes f g :: "'a::complete_lattice \<Rightarrow> ereal"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3302
  assumes nn: "\<And>x. 0 \<le> f x" "\<And>x. 0 \<le> g x" and cont: "sup_continuous f" "sup_continuous g"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3303
  shows "sup_continuous (\<lambda>x. f x + g x)"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3304
  unfolding sup_continuous_def
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3305
proof safe
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3306
  fix M :: "nat \<Rightarrow> 'a" assume "incseq M"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3307
  then show "f (SUP i. M i) + g (SUP i. M i) = (SUP i. f (M i) + g (M i))"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3308
    using SUP_ereal_add_pos[of "\<lambda>i. f (M i)" "\<lambda>i. g (M i)"] nn
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3309
      cont[THEN sup_continuous_mono] cont[THEN sup_continuousD]
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3310
    by (auto simp: mono_def)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3311
qed
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3312
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3313
lemma sup_continuous_mult_right[order_continuous_intros]:
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3314
  "0 \<le> c \<Longrightarrow> c < \<infinity> \<Longrightarrow> sup_continuous f \<Longrightarrow> sup_continuous (\<lambda>x. f x * c :: ereal)"
60636
ee18efe9b246 add named theorems order_continuous_intros; lfp/gfp_funpow; bounded variant for lfp/gfp transfer
hoelzl
parents: 60580
diff changeset
  3315
  by (cases c) (auto simp: sup_continuous_def fun_eq_iff Sup_ereal_mult_right')
ee18efe9b246 add named theorems order_continuous_intros; lfp/gfp_funpow; bounded variant for lfp/gfp transfer
hoelzl
parents: 60580
diff changeset
  3316
60637
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3317
lemma sup_continuous_mult_left[order_continuous_intros]:
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3318
  "0 \<le> c \<Longrightarrow> c < \<infinity> \<Longrightarrow> sup_continuous f \<Longrightarrow> sup_continuous (\<lambda>x. c * f x :: ereal)"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3319
  using sup_continuous_mult_right[of c f] by (simp add: mult_ac)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3320
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3321
lemma sup_continuous_ereal_of_enat[order_continuous_intros]:
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3322
  assumes f: "sup_continuous f" shows "sup_continuous (\<lambda>x. ereal_of_enat (f x))"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3323
  by (rule sup_continuous_compose[OF _ f])
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3324
     (auto simp: sup_continuous_def ereal_of_enat_SUP)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  3325
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3326
subsubsection \<open>Sums\<close>
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3327
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3328
lemma sums_ereal_positive:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3329
  fixes f :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3330
  assumes "\<And>i. 0 \<le> f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3331
  shows "f sums (SUP n. \<Sum>i<n. f i)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3332
proof -
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3333
  have "incseq (\<lambda>i. \<Sum>j=0..<i. f j)"
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  3334
    using add_mono[OF _ assms]
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3335
    by (auto intro!: incseq_SucI)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3336
  from LIMSEQ_SUP[OF this]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3337
  show ?thesis unfolding sums_def
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3338
    by (simp add: atLeast0LessThan)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3339
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3340
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3341
lemma summable_ereal_pos:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3342
  fixes f :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3343
  assumes "\<And>i. 0 \<le> f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3344
  shows "summable f"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3345
  using sums_ereal_positive[of f, OF assms]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3346
  unfolding summable_def
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3347
  by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3348
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3349
lemma sums_ereal: "(\<lambda>x. ereal (f x)) sums ereal x \<longleftrightarrow> f sums x"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3350
  unfolding sums_def by simp
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3351
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3352
lemma suminf_ereal_eq_SUP:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3353
  fixes f :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3354
  assumes "\<And>i. 0 \<le> f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3355
  shows "(\<Sum>x. f x) = (SUP n. \<Sum>i<n. f i)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3356
  using sums_ereal_positive[of f, OF assms, THEN sums_unique]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3357
  by simp
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3358
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3359
lemma suminf_bound:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3360
  fixes f :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3361
  assumes "\<forall>N. (\<Sum>n<N. f n) \<le> x"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3362
    and pos: "\<And>n. 0 \<le> f n"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3363
  shows "suminf f \<le> x"
68532
f8b98d31ad45 Incorporating new/strengthened proofs from Library and AFP entries
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
  3364
proof (rule Lim_bounded)
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3365
  have "summable f" using pos[THEN summable_ereal_pos] .
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3366
  then show "(\<lambda>N. \<Sum>n<N. f n) \<longlonglongrightarrow> suminf f"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3367
    by (auto dest!: summable_sums simp: sums_def atLeast0LessThan)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3368
  show "\<forall>n\<ge>0. sum f {..<n} \<le> x"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3369
    using assms by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3370
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3371
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3372
lemma suminf_bound_add:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3373
  fixes f :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3374
  assumes "\<forall>N. (\<Sum>n<N. f n) + y \<le> x"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3375
    and pos: "\<And>n. 0 \<le> f n"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3376
    and "y \<noteq> -\<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3377
  shows "suminf f + y \<le> x"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3378
proof (cases y)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3379
  case (real r)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3380
  then have "\<forall>N. (\<Sum>n<N. f n) \<le> x - y"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3381
    using assms by (simp add: ereal_le_minus)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3382
  then have "(\<Sum> n. f n) \<le> x - y"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3383
    using pos by (rule suminf_bound)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3384
  then show "(\<Sum> n. f n) + y \<le> x"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3385
    using assms real by (simp add: ereal_le_minus)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3386
qed (insert assms, auto)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3387
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3388
lemma suminf_upper:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3389
  fixes f :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3390
  assumes "\<And>n. 0 \<le> f n"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3391
  shows "(\<Sum>n<N. f n) \<le> (\<Sum>n. f n)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3392
  unfolding suminf_ereal_eq_SUP [OF assms]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3393
  by (auto intro: complete_lattice_class.SUP_upper)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3394
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3395
lemma suminf_0_le:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3396
  fixes f :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3397
  assumes "\<And>n. 0 \<le> f n"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3398
  shows "0 \<le> (\<Sum>n. f n)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3399
  using suminf_upper[of f 0, OF assms]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3400
  by simp
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3401
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3402
lemma suminf_le_pos:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3403
  fixes f g :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3404
  assumes "\<And>N. f N \<le> g N"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3405
    and "\<And>N. 0 \<le> f N"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3406
  shows "suminf f \<le> suminf g"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3407
proof (safe intro!: suminf_bound)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3408
  fix n
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3409
  {
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3410
    fix N
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3411
    have "0 \<le> g N"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3412
      using assms(2,1)[of N] by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3413
  }
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3414
  have "sum f {..<n} \<le> sum g {..<n}"
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3415
    using assms by (auto intro: sum_mono)
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3416
  also have "\<dots> \<le> suminf g"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3417
    using \<open>\<And>N. 0 \<le> g N\<close>
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3418
    by (rule suminf_upper)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3419
  finally show "sum f {..<n} \<le> suminf g" .
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3420
qed (rule assms(2))
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3421
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3422
lemma suminf_half_series_ereal: "(\<Sum>n. (1/2 :: ereal) ^ Suc n) = 1"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3423
  using sums_ereal[THEN iffD2, OF power_half_series, THEN sums_unique, symmetric]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3424
  by (simp add: one_ereal_def)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3425
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3426
lemma suminf_add_ereal:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3427
  fixes f g :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3428
  assumes "\<And>i. 0 \<le> f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3429
    and "\<And>i. 0 \<le> g i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3430
  shows "(\<Sum>i. f i + g i) = suminf f + suminf g"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3431
  apply (subst (1 2 3) suminf_ereal_eq_SUP)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3432
  unfolding sum.distrib
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  3433
  apply (intro assms add_nonneg_nonneg SUP_ereal_add_pos incseq_sumI sum_nonneg ballI)+
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3434
  done
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3435
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3436
lemma suminf_cmult_ereal:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3437
  fixes f g :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3438
  assumes "\<And>i. 0 \<le> f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3439
    and "0 \<le> a"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3440
  shows "(\<Sum>i. a * f i) = a * suminf f"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3441
  by (auto simp: sum_ereal_right_distrib[symmetric] assms
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3442
       ereal_zero_le_0_iff sum_nonneg suminf_ereal_eq_SUP
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3443
       intro!: SUP_ereal_mult_left)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3444
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3445
lemma suminf_PInfty:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3446
  fixes f :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3447
  assumes "\<And>i. 0 \<le> f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3448
    and "suminf f \<noteq> \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3449
  shows "f i \<noteq> \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3450
proof -
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3451
  from suminf_upper[of f "Suc i", OF assms(1)] assms(2)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3452
  have "(\<Sum>i<Suc i. f i) \<noteq> \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3453
    by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3454
  then show ?thesis
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3455
    unfolding sum_Pinfty by simp
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3456
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3457
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3458
lemma suminf_PInfty_fun:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3459
  assumes "\<And>i. 0 \<le> f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3460
    and "suminf f \<noteq> \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3461
  shows "\<exists>f'. f = (\<lambda>x. ereal (f' x))"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3462
proof -
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3463
  have "\<forall>i. \<exists>r. f i = ereal r"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3464
  proof
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3465
    fix i
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3466
    show "\<exists>r. f i = ereal r"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3467
      using suminf_PInfty[OF assms] assms(1)[of i]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3468
      by (cases "f i") auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3469
  qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3470
  from choice[OF this] show ?thesis
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3471
    by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3472
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3473
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3474
lemma summable_ereal:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3475
  assumes "\<And>i. 0 \<le> f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3476
    and "(\<Sum>i. ereal (f i)) \<noteq> \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3477
  shows "summable f"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3478
proof -
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3479
  have "0 \<le> (\<Sum>i. ereal (f i))"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3480
    using assms by (intro suminf_0_le) auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3481
  with assms obtain r where r: "(\<Sum>i. ereal (f i)) = ereal r"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3482
    by (cases "\<Sum>i. ereal (f i)") auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3483
  from summable_ereal_pos[of "\<lambda>x. ereal (f x)"]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3484
  have "summable (\<lambda>x. ereal (f x))"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3485
    using assms by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3486
  from summable_sums[OF this]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3487
  have "(\<lambda>x. ereal (f x)) sums (\<Sum>x. ereal (f x))"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3488
    by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3489
  then show "summable f"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3490
    unfolding r sums_ereal summable_def ..
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3491
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3492
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3493
lemma suminf_ereal:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3494
  assumes "\<And>i. 0 \<le> f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3495
    and "(\<Sum>i. ereal (f i)) \<noteq> \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3496
  shows "(\<Sum>i. ereal (f i)) = ereal (suminf f)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3497
proof (rule sums_unique[symmetric])
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3498
  from summable_ereal[OF assms]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3499
  show "(\<lambda>x. ereal (f x)) sums (ereal (suminf f))"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3500
    unfolding sums_ereal
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3501
    using assms
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3502
    by (intro summable_sums summable_ereal)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3503
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3504
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3505
lemma suminf_ereal_minus:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3506
  fixes f g :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3507
  assumes ord: "\<And>i. g i \<le> f i" "\<And>i. 0 \<le> g i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3508
    and fin: "suminf f \<noteq> \<infinity>" "suminf g \<noteq> \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3509
  shows "(\<Sum>i. f i - g i) = suminf f - suminf g"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3510
proof -
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3511
  {
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3512
    fix i
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3513
    have "0 \<le> f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3514
      using ord[of i] by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3515
  }
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3516
  moreover
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3517
  from suminf_PInfty_fun[OF \<open>\<And>i. 0 \<le> f i\<close> fin(1)] obtain f' where [simp]: "f = (\<lambda>x. ereal (f' x))" ..
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3518
  from suminf_PInfty_fun[OF \<open>\<And>i. 0 \<le> g i\<close> fin(2)] obtain g' where [simp]: "g = (\<lambda>x. ereal (g' x))" ..
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3519
  {
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3520
    fix i
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3521
    have "0 \<le> f i - g i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3522
      using ord[of i] by (auto simp: ereal_le_minus_iff)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3523
  }
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3524
  moreover
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3525
  have "suminf (\<lambda>i. f i - g i) \<le> suminf f"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3526
    using assms by (auto intro!: suminf_le_pos simp: field_simps)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3527
  then have "suminf (\<lambda>i. f i - g i) \<noteq> \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3528
    using fin by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3529
  ultimately show ?thesis
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3530
    using assms \<open>\<And>i. 0 \<le> f i\<close>
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3531
    apply simp
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3532
    apply (subst (1 2 3) suminf_ereal)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3533
    apply (auto intro!: suminf_diff[symmetric] summable_ereal)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3534
    done
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3535
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3536
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3537
lemma suminf_ereal_PInf [simp]: "(\<Sum>x. \<infinity>::ereal) = \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3538
proof -
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3539
  have "(\<Sum>i<Suc 0. \<infinity>) \<le> (\<Sum>x. \<infinity>::ereal)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3540
    by (rule suminf_upper) auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3541
  then show ?thesis
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3542
    by simp
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3543
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3544
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3545
lemma summable_real_of_ereal:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3546
  fixes f :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3547
  assumes f: "\<And>i. 0 \<le> f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3548
    and fin: "(\<Sum>i. f i) \<noteq> \<infinity>"
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  3549
  shows "summable (\<lambda>i. real_of_ereal (f i))"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3550
proof (rule summable_def[THEN iffD2])
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3551
  have "0 \<le> (\<Sum>i. f i)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3552
    using assms by (auto intro: suminf_0_le)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3553
  with fin obtain r where r: "ereal r = (\<Sum>i. f i)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3554
    by (cases "(\<Sum>i. f i)") auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3555
  {
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3556
    fix i
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3557
    have "f i \<noteq> \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3558
      using f by (intro suminf_PInfty[OF _ fin]) auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3559
    then have "\<bar>f i\<bar> \<noteq> \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3560
      using f[of i] by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3561
  }
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3562
  note fin = this
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  3563
  have "(\<lambda>i. ereal (real_of_ereal (f i))) sums (\<Sum>i. ereal (real_of_ereal (f i)))"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3564
    using f
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3565
    by (auto intro!: summable_ereal_pos simp: ereal_le_real_iff zero_ereal_def)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3566
  also have "\<dots> = ereal r"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3567
    using fin r by (auto simp: ereal_real)
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  3568
  finally show "\<exists>r. (\<lambda>i. real_of_ereal (f i)) sums r"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3569
    by (auto simp: sums_ereal)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3570
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3571
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3572
lemma suminf_SUP_eq:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3573
  fixes f :: "nat \<Rightarrow> nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3574
  assumes "\<And>i. incseq (\<lambda>n. f n i)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3575
    and "\<And>n i. 0 \<le> f n i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3576
  shows "(\<Sum>i. SUP n. f n i) = (SUP n. \<Sum>i. f n i)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3577
proof -
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3578
  {
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3579
    fix n :: nat
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3580
    have "(\<Sum>i<n. SUP k. f k i) = (SUP k. \<Sum>i<n. f k i)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3581
      using assms
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3582
      by (auto intro!: SUP_ereal_sum [symmetric])
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3583
  }
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3584
  note * = this
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3585
  show ?thesis
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3586
    using assms
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3587
    apply (subst (1 2) suminf_ereal_eq_SUP)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3588
    unfolding *
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3589
    apply (auto intro!: SUP_upper2)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3590
    apply (subst SUP_commute)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3591
    apply rule
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3592
    done
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3593
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3594
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3595
lemma suminf_sum_ereal:
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3596
  fixes f :: "_ \<Rightarrow> _ \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3597
  assumes nonneg: "\<And>i a. a \<in> A \<Longrightarrow> 0 \<le> f i a"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3598
  shows "(\<Sum>i. \<Sum>a\<in>A. f i a) = (\<Sum>a\<in>A. \<Sum>i. f i a)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3599
proof (cases "finite A")
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3600
  case True
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3601
  then show ?thesis
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3602
    using nonneg
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3603
    by induct (simp_all add: suminf_add_ereal sum_nonneg)
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3604
next
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3605
  case False
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3606
  then show ?thesis by simp
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3607
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3608
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3609
lemma suminf_ereal_eq_0:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3610
  fixes f :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3611
  assumes nneg: "\<And>i. 0 \<le> f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3612
  shows "(\<Sum>i. f i) = 0 \<longleftrightarrow> (\<forall>i. f i = 0)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3613
proof
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3614
  assume "(\<Sum>i. f i) = 0"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3615
  {
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3616
    fix i
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3617
    assume "f i \<noteq> 0"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3618
    with nneg have "0 < f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3619
      by (auto simp: less_le)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3620
    also have "f i = (\<Sum>j. if j = i then f i else 0)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3621
      by (subst suminf_finite[where N="{i}"]) auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3622
    also have "\<dots> \<le> (\<Sum>i. f i)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3623
      using nneg
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3624
      by (auto intro!: suminf_le_pos)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3625
    finally have False
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3626
      using \<open>(\<Sum>i. f i) = 0\<close> by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3627
  }
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3628
  then show "\<forall>i. f i = 0"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3629
    by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3630
qed simp
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3631
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3632
lemma suminf_ereal_offset_le:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3633
  fixes f :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3634
  assumes f: "\<And>i. 0 \<le> f i"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3635
  shows "(\<Sum>i. f (i + k)) \<le> suminf f"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3636
proof -
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3637
  have "(\<lambda>n. \<Sum>i<n. f (i + k)) \<longlonglongrightarrow> (\<Sum>i. f (i + k))"
66936
cf8d8fc23891 tuned some proofs and added some lemmas
haftmann
parents: 65680
diff changeset
  3638
    using summable_sums[OF summable_ereal_pos]
cf8d8fc23891 tuned some proofs and added some lemmas
haftmann
parents: 65680
diff changeset
  3639
    by (simp add: sums_def atLeast0LessThan f)
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3640
  moreover have "(\<lambda>n. \<Sum>i<n. f i) \<longlonglongrightarrow> (\<Sum>i. f i)"
66936
cf8d8fc23891 tuned some proofs and added some lemmas
haftmann
parents: 65680
diff changeset
  3641
    using summable_sums[OF summable_ereal_pos]
cf8d8fc23891 tuned some proofs and added some lemmas
haftmann
parents: 65680
diff changeset
  3642
    by (simp add: sums_def atLeast0LessThan f)
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3643
  then have "(\<lambda>n. \<Sum>i<n + k. f i) \<longlonglongrightarrow> (\<Sum>i. f i)"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3644
    by (rule LIMSEQ_ignore_initial_segment)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3645
  ultimately show ?thesis
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3646
  proof (rule LIMSEQ_le, safe intro!: exI[of _ k])
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3647
    fix n assume "k \<le> n"
66936
cf8d8fc23891 tuned some proofs and added some lemmas
haftmann
parents: 65680
diff changeset
  3648
    have "(\<Sum>i<n. f (i + k)) = (\<Sum>i<n. (f \<circ> plus k) i)"
cf8d8fc23891 tuned some proofs and added some lemmas
haftmann
parents: 65680
diff changeset
  3649
      by (simp add: ac_simps)
cf8d8fc23891 tuned some proofs and added some lemmas
haftmann
parents: 65680
diff changeset
  3650
    also have "\<dots> = (\<Sum>i\<in>(plus k) ` {..<n}. f i)"
cf8d8fc23891 tuned some proofs and added some lemmas
haftmann
parents: 65680
diff changeset
  3651
      by (rule sum.reindex [symmetric]) simp
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3652
    also have "\<dots> \<le> sum f {..<n + k}"
65680
378a2f11bec9 Simplification of some proofs. Also key lemmas using !! rather than ! in premises
paulson <lp15@cam.ac.uk>
parents: 64272
diff changeset
  3653
      by (intro sum_mono2) (auto simp: f)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3654
    finally show "(\<Sum>i<n. f (i + k)) \<le> sum f {..<n + k}" .
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3655
  qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3656
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3657
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3658
lemma sums_suminf_ereal: "f sums x \<Longrightarrow> (\<Sum>i. ereal (f i)) = ereal x"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3659
  by (metis sums_ereal sums_unique)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3660
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3661
lemma suminf_ereal': "summable f \<Longrightarrow> (\<Sum>i. ereal (f i)) = ereal (\<Sum>i. f i)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3662
  by (metis sums_ereal sums_unique summable_def)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3663
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3664
lemma suminf_ereal_finite: "summable f \<Longrightarrow> (\<Sum>i. ereal (f i)) \<noteq> \<infinity>"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 68356
diff changeset
  3665
  by (auto simp: summable_def simp flip: sums_ereal sums_unique)
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3666
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3667
lemma suminf_ereal_finite_neg:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3668
  assumes "summable f"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3669
  shows "(\<Sum>x. ereal (f x)) \<noteq> -\<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3670
proof-
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3671
  from assms obtain x where "f sums x" by blast
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3672
  hence "(\<lambda>x. ereal (f x)) sums ereal x" by (simp add: sums_ereal)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3673
  from sums_unique[OF this] have "(\<Sum>x. ereal (f x)) = ereal x" ..
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3674
  thus "(\<Sum>x. ereal (f x)) \<noteq> -\<infinity>" by simp_all
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3675
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3676
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3677
lemma SUP_ereal_add_directed:
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3678
  fixes f g :: "'a \<Rightarrow> ereal"
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3679
  assumes nonneg: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> g i"
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3680
  assumes directed: "\<And>i j. i \<in> I \<Longrightarrow> j \<in> I \<Longrightarrow> \<exists>k\<in>I. f i + g j \<le> f k + g k"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3681
  shows "(SUP i\<in>I. f i + g i) = (SUP i\<in>I. f i) + (SUP i\<in>I. g i)"
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3682
proof cases
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3683
  assume "I = {}" then show ?thesis
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3684
    by (simp add: bot_ereal_def)
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3685
next
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3686
  assume "I \<noteq> {}"
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3687
  show ?thesis
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3688
  proof (rule antisym)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3689
    show "(SUP i\<in>I. f i + g i) \<le> (SUP i\<in>I. f i) + (SUP i\<in>I. g i)"
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  3690
      by (rule SUP_least; intro add_mono SUP_upper)
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3691
  next
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3692
    have "bot < (SUP i\<in>I. g i)"
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3693
      using \<open>I \<noteq> {}\<close> nonneg(2) by (auto simp: bot_ereal_def less_SUP_iff)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3694
    then have "(SUP i\<in>I. f i) + (SUP i\<in>I. g i) = (SUP i\<in>I. f i + (SUP i\<in>I. g i))"
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3695
      by (intro SUP_ereal_add_left[symmetric] \<open>I \<noteq> {}\<close>) auto
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3696
    also have "\<dots> = (SUP i\<in>I. (SUP j\<in>I. f i + g j))"
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69593
diff changeset
  3697
      using nonneg(1) \<open>I \<noteq> {}\<close> by (simp add: SUP_ereal_add_right)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3698
    also have "\<dots> \<le> (SUP i\<in>I. f i + g i)"
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3699
      using directed by (intro SUP_least) (blast intro: SUP_upper2)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3700
    finally show "(SUP i\<in>I. f i) + (SUP i\<in>I. g i) \<le> (SUP i\<in>I. f i + g i)" .
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3701
  qed
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3702
qed
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3703
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3704
lemma SUP_ereal_sum_directed:
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3705
  fixes f g :: "'a \<Rightarrow> 'b \<Rightarrow> ereal"
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3706
  assumes "I \<noteq> {}"
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3707
  assumes directed: "\<And>N i j. N \<subseteq> A \<Longrightarrow> i \<in> I \<Longrightarrow> j \<in> I \<Longrightarrow> \<exists>k\<in>I. \<forall>n\<in>N. f n i \<le> f n k \<and> f n j \<le> f n k"
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3708
  assumes nonneg: "\<And>n i. i \<in> I \<Longrightarrow> n \<in> A \<Longrightarrow> 0 \<le> f n i"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3709
  shows "(SUP i\<in>I. \<Sum>n\<in>A. f n i) = (\<Sum>n\<in>A. SUP i\<in>I. f n i)"
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3710
proof -
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3711
  have "N \<subseteq> A \<Longrightarrow> (SUP i\<in>I. \<Sum>n\<in>N. f n i) = (\<Sum>n\<in>N. SUP i\<in>I. f n i)" for N
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3712
  proof (induction N rule: infinite_finite_induct)
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3713
    case (insert n N)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3714
    moreover have "(SUP i\<in>I. f n i + (\<Sum>l\<in>N. f l i)) = (SUP i\<in>I. f n i) + (SUP i\<in>I. \<Sum>l\<in>N. f l i)"
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3715
    proof (rule SUP_ereal_add_directed)
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3716
      fix i assume "i \<in> I" then show "0 \<le> f n i" "0 \<le> (\<Sum>l\<in>N. f l i)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3717
        using insert by (auto intro!: sum_nonneg nonneg)
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3718
    next
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3719
      fix i j assume "i \<in> I" "j \<in> I"
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3720
      from directed[OF \<open>insert n N \<subseteq> A\<close> this] guess k ..
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
  3721
      then show "\<exists>k\<in>I. f n i + (\<Sum>l\<in>N. f l j) \<le> f n k + (\<Sum>l\<in>N. f l k)"
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  3722
        by (intro bexI[of _ k]) (auto intro!: add_mono sum_mono)
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3723
    qed
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3724
    ultimately show ?case
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3725
      by simp
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3726
  qed (simp_all add: SUP_constant \<open>I \<noteq> {}\<close>)
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3727
  from this[of A] show ?thesis by simp
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3728
qed
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3729
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3730
lemma suminf_SUP_eq_directed:
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3731
  fixes f :: "_ \<Rightarrow> nat \<Rightarrow> ereal"
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3732
  assumes "I \<noteq> {}"
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3733
  assumes directed: "\<And>N i j. i \<in> I \<Longrightarrow> j \<in> I \<Longrightarrow> finite N \<Longrightarrow> \<exists>k\<in>I. \<forall>n\<in>N. f i n \<le> f k n \<and> f j n \<le> f k n"
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3734
  assumes nonneg: "\<And>n i. 0 \<le> f n i"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3735
  shows "(\<Sum>i. SUP n\<in>I. f n i) = (SUP n\<in>I. \<Sum>i. f n i)"
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3736
proof (subst (1 2) suminf_ereal_eq_SUP)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3737
  show "\<And>n i. 0 \<le> f n i" "\<And>i. 0 \<le> (SUP n\<in>I. f n i)"
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3738
    using \<open>I \<noteq> {}\<close> nonneg by (auto intro: SUP_upper2)
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  3739
  show "(SUP n. \<Sum>i<n. SUP n\<in>I. f n i) = (SUP n\<in>I. SUP j. \<Sum>i<j. f n i)"
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3740
    apply (subst SUP_commute)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  3741
    apply (subst SUP_ereal_sum_directed)
60772
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3742
    apply (auto intro!: assms simp: finite_subset)
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3743
    done
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3744
qed
a0cfa9050fa8 Measures form a CCPO
hoelzl
parents: 60771
diff changeset
  3745
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3746
lemma ereal_dense3:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3747
  fixes x y :: ereal
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3748
  shows "x < y \<Longrightarrow> \<exists>r::rat. x < real_of_rat r \<and> real_of_rat r < y"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3749
proof (cases x y rule: ereal2_cases, simp_all)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3750
  fix r q :: real
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3751
  assume "r < q"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3752
  from Rats_dense_in_real[OF this] show "\<exists>x. r < real_of_rat x \<and> real_of_rat x < q"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3753
    by (fastforce simp: Rats_def)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3754
next
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3755
  fix r :: real
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3756
  show "\<exists>x. r < real_of_rat x" "\<exists>x. real_of_rat x < r"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3757
    using gt_ex[of r] lt_ex[of r] Rats_dense_in_real
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3758
    by (auto simp: Rats_def)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3759
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3760
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3761
lemma continuous_within_ereal[intro, simp]: "x \<in> A \<Longrightarrow> continuous (at x within A) ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3762
  using continuous_on_eq_continuous_within[of A ereal]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3763
  by (auto intro: continuous_on_ereal continuous_on_id)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3764
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3765
lemma ereal_open_uminus:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3766
  fixes S :: "ereal set"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3767
  assumes "open S"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3768
  shows "open (uminus ` S)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3769
  using \<open>open S\<close>[unfolded open_generated_order]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3770
proof induct
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3771
  have "range uminus = (UNIV :: ereal set)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3772
    by (auto simp: image_iff ereal_uminus_eq_reorder)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3773
  then show "open (range uminus :: ereal set)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3774
    by simp
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3775
qed (auto simp add: image_Union image_Int)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3776
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3777
lemma ereal_uminus_complement:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3778
  fixes S :: "ereal set"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3779
  shows "uminus ` (- S) = - uminus ` S"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3780
  by (auto intro!: bij_image_Compl_eq surjI[of _ uminus] simp: bij_betw_def)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3781
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3782
lemma ereal_closed_uminus:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3783
  fixes S :: "ereal set"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3784
  assumes "closed S"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3785
  shows "closed (uminus ` S)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3786
  using assms
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3787
  unfolding closed_def ereal_uminus_complement[symmetric]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3788
  by (rule ereal_open_uminus)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3789
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3790
lemma ereal_open_affinity_pos:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3791
  fixes S :: "ereal set"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3792
  assumes "open S"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3793
    and m: "m \<noteq> \<infinity>" "0 < m"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3794
    and t: "\<bar>t\<bar> \<noteq> \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3795
  shows "open ((\<lambda>x. m * x + t) ` S)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3796
proof -
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3797
  have "open ((\<lambda>x. inverse m * (x + -t)) -` S)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3798
    using m t
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3799
    apply (intro open_vimage \<open>open S\<close>)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3800
    apply (intro continuous_at_imp_continuous_on ballI tendsto_cmult_ereal continuous_at[THEN iffD2]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3801
                 tendsto_ident_at tendsto_add_left_ereal)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3802
    apply auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3803
    done
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3804
  also have "(\<lambda>x. inverse m * (x + -t)) -` S = (\<lambda>x. (x - t) / m) -` S"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 68356
diff changeset
  3805
    using m t by (auto simp: divide_ereal_def mult.commute minus_ereal_def
6beb45f6cf67 utilize 'flip'
nipkow
parents: 68356
diff changeset
  3806
                       simp flip: uminus_ereal.simps)
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3807
  also have "(\<lambda>x. (x - t) / m) -` S = (\<lambda>x. m * x + t) ` S"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3808
    using m t
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3809
    by (simp add: set_eq_iff image_iff)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3810
       (metis abs_ereal_less0 abs_ereal_uminus ereal_divide_eq ereal_eq_minus ereal_minus(7,8)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3811
              ereal_minus_less_minus ereal_mult_eq_PInfty ereal_uminus_uminus ereal_zero_mult)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3812
  finally show ?thesis .
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3813
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3814
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3815
lemma ereal_open_affinity:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3816
  fixes S :: "ereal set"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3817
  assumes "open S"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3818
    and m: "\<bar>m\<bar> \<noteq> \<infinity>" "m \<noteq> 0"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3819
    and t: "\<bar>t\<bar> \<noteq> \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3820
  shows "open ((\<lambda>x. m * x + t) ` S)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3821
proof cases
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3822
  assume "0 < m"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3823
  then show ?thesis
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3824
    using ereal_open_affinity_pos[OF \<open>open S\<close> _ _ t, of m] m
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3825
    by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3826
next
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3827
  assume "\<not> 0 < m" then
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3828
  have "0 < -m"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3829
    using \<open>m \<noteq> 0\<close>
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3830
    by (cases m) auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3831
  then have m: "-m \<noteq> \<infinity>" "0 < -m"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3832
    using \<open>\<bar>m\<bar> \<noteq> \<infinity>\<close>
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3833
    by (auto simp: ereal_uminus_eq_reorder)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3834
  from ereal_open_affinity_pos[OF ereal_open_uminus[OF \<open>open S\<close>] m t] show ?thesis
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3835
    unfolding image_image by simp
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3836
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3837
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3838
lemma open_uminus_iff:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3839
  fixes S :: "ereal set"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3840
  shows "open (uminus ` S) \<longleftrightarrow> open S"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3841
  using ereal_open_uminus[of S] ereal_open_uminus[of "uminus ` S"]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3842
  by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3843
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3844
lemma ereal_Liminf_uminus:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3845
  fixes f :: "'a \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3846
  shows "Liminf net (\<lambda>x. - (f x)) = - Limsup net f"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3847
  using ereal_Limsup_uminus[of _ "(\<lambda>x. - (f x))"] by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3848
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3849
lemma Liminf_PInfty:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3850
  fixes f :: "'a \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3851
  assumes "\<not> trivial_limit net"
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3852
  shows "(f \<longlongrightarrow> \<infinity>) net \<longleftrightarrow> Liminf net f = \<infinity>"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3853
  unfolding tendsto_iff_Liminf_eq_Limsup[OF assms]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3854
  using Liminf_le_Limsup[OF assms, of f]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3855
  by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3856
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3857
lemma Limsup_MInfty:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3858
  fixes f :: "'a \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3859
  assumes "\<not> trivial_limit net"
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3860
  shows "(f \<longlongrightarrow> -\<infinity>) net \<longleftrightarrow> Limsup net f = -\<infinity>"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3861
  unfolding tendsto_iff_Liminf_eq_Limsup[OF assms]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3862
  using Liminf_le_Limsup[OF assms, of f]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3863
  by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3864
63145
703edebd1d92 isabelle update_cartouches -c -t;
wenzelm
parents: 63099
diff changeset
  3865
lemma convergent_ereal: \<comment> \<open>RENAME\<close>
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3866
  fixes X :: "nat \<Rightarrow> 'a :: {complete_linorder,linorder_topology}"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3867
  shows "convergent X \<longleftrightarrow> limsup X = liminf X"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3868
  using tendsto_iff_Liminf_eq_Limsup[of sequentially]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3869
  by (auto simp: convergent_def)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3870
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3871
lemma limsup_le_liminf_real:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3872
  fixes X :: "nat \<Rightarrow> real" and L :: real
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3873
  assumes 1: "limsup X \<le> L" and 2: "L \<le> liminf X"
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3874
  shows "X \<longlonglongrightarrow> L"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3875
proof -
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3876
  from 1 2 have "limsup X \<le> liminf X" by auto
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
  3877
  hence 3: "limsup X = liminf X"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3878
    apply (subst eq_iff, rule conjI)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3879
    by (rule Liminf_le_Limsup, auto)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3880
  hence 4: "convergent (\<lambda>n. ereal (X n))"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3881
    by (subst convergent_ereal)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3882
  hence "limsup X = lim (\<lambda>n. ereal(X n))"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3883
    by (rule convergent_limsup_cl)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3884
  also from 1 2 3 have "limsup X = L" by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3885
  finally have "lim (\<lambda>n. ereal(X n)) = L" ..
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3886
  hence "(\<lambda>n. ereal (X n)) \<longlonglongrightarrow> L"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3887
    apply (elim subst)
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
  3888
    by (subst convergent_LIMSEQ_iff [symmetric], rule 4)
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3889
  thus ?thesis by simp
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3890
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3891
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3892
lemma liminf_PInfty:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3893
  fixes X :: "nat \<Rightarrow> ereal"
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3894
  shows "X \<longlonglongrightarrow> \<infinity> \<longleftrightarrow> liminf X = \<infinity>"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3895
  by (metis Liminf_PInfty trivial_limit_sequentially)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3896
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3897
lemma limsup_MInfty:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3898
  fixes X :: "nat \<Rightarrow> ereal"
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3899
  shows "X \<longlonglongrightarrow> -\<infinity> \<longleftrightarrow> limsup X = -\<infinity>"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3900
  by (metis Limsup_MInfty trivial_limit_sequentially)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3901
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3902
lemma SUP_eq_LIMSEQ:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3903
  assumes "mono f"
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3904
  shows "(SUP n. ereal (f n)) = ereal x \<longleftrightarrow> f \<longlonglongrightarrow> x"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3905
proof
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3906
  have inc: "incseq (\<lambda>i. ereal (f i))"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3907
    using \<open>mono f\<close> unfolding mono_def incseq_def by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3908
  {
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3909
    assume "f \<longlonglongrightarrow> x"
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3910
    then have "(\<lambda>i. ereal (f i)) \<longlonglongrightarrow> ereal x"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3911
      by auto
68532
f8b98d31ad45 Incorporating new/strengthened proofs from Library and AFP entries
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
  3912
    from SUP_Lim[OF inc this] show "(SUP n. ereal (f n)) = ereal x" .
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3913
  next
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3914
    assume "(SUP n. ereal (f n)) = ereal x"
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  3915
    with LIMSEQ_SUP[OF inc] show "f \<longlonglongrightarrow> x" by auto
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3916
  }
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3917
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3918
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3919
lemma liminf_ereal_cminus:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3920
  fixes f :: "nat \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3921
  assumes "c \<noteq> -\<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3922
  shows "liminf (\<lambda>x. c - f x) = c - limsup f"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3923
proof (cases c)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3924
  case PInf
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3925
  then show ?thesis
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3926
    by (simp add: Liminf_const)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3927
next
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3928
  case (real r)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3929
  then show ?thesis
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3930
    unfolding liminf_SUP_INF limsup_INF_SUP
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3931
    apply (subst INF_ereal_minus_right)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3932
    apply auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3933
    apply (subst SUP_ereal_minus_right)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3934
    apply auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3935
    done
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3936
qed (insert \<open>c \<noteq> -\<infinity>\<close>, simp)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3937
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3938
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3939
subsubsection \<open>Continuity\<close>
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3940
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3941
lemma continuous_at_of_ereal:
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  3942
  "\<bar>x0 :: ereal\<bar> \<noteq> \<infinity> \<Longrightarrow> continuous (at x0) real_of_ereal"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3943
  unfolding continuous_at
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3944
  by (rule lim_real_of_ereal) (simp add: ereal_real)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3945
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3946
lemma nhds_ereal: "nhds (ereal r) = filtermap ereal (nhds r)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3947
  by (simp add: filtermap_nhds_open_map open_ereal continuous_at_of_ereal)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3948
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3949
lemma at_ereal: "at (ereal r) = filtermap ereal (at r)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3950
  by (simp add: filter_eq_iff eventually_at_filter nhds_ereal eventually_filtermap)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3951
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3952
lemma at_left_ereal: "at_left (ereal r) = filtermap ereal (at_left r)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3953
  by (simp add: filter_eq_iff eventually_at_filter nhds_ereal eventually_filtermap)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3954
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3955
lemma at_right_ereal: "at_right (ereal r) = filtermap ereal (at_right r)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3956
  by (simp add: filter_eq_iff eventually_at_filter nhds_ereal eventually_filtermap)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3957
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3958
lemma
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3959
  shows at_left_PInf: "at_left \<infinity> = filtermap ereal at_top"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3960
    and at_right_MInf: "at_right (-\<infinity>) = filtermap ereal at_bot"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3961
  unfolding filter_eq_iff eventually_filtermap eventually_at_top_dense eventually_at_bot_dense
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3962
    eventually_at_left[OF ereal_less(5)] eventually_at_right[OF ereal_less(6)]
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3963
  by (auto simp add: ereal_all_split ereal_ex_split)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3964
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3965
lemma ereal_tendsto_simps1:
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3966
  "((f \<circ> real_of_ereal) \<longlongrightarrow> y) (at_left (ereal x)) \<longleftrightarrow> (f \<longlongrightarrow> y) (at_left x)"
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3967
  "((f \<circ> real_of_ereal) \<longlongrightarrow> y) (at_right (ereal x)) \<longleftrightarrow> (f \<longlongrightarrow> y) (at_right x)"
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3968
  "((f \<circ> real_of_ereal) \<longlongrightarrow> y) (at_left (\<infinity>::ereal)) \<longleftrightarrow> (f \<longlongrightarrow> y) at_top"
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3969
  "((f \<circ> real_of_ereal) \<longlongrightarrow> y) (at_right (-\<infinity>::ereal)) \<longleftrightarrow> (f \<longlongrightarrow> y) at_bot"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3970
  unfolding tendsto_compose_filtermap at_left_ereal at_right_ereal at_left_PInf at_right_MInf
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3971
  by (auto simp: filtermap_filtermap filtermap_ident)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3972
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3973
lemma ereal_tendsto_simps2:
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3974
  "((ereal \<circ> f) \<longlongrightarrow> ereal a) F \<longleftrightarrow> (f \<longlongrightarrow> a) F"
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3975
  "((ereal \<circ> f) \<longlongrightarrow> \<infinity>) F \<longleftrightarrow> (LIM x F. f x :> at_top)"
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3976
  "((ereal \<circ> f) \<longlongrightarrow> -\<infinity>) F \<longleftrightarrow> (LIM x F. f x :> at_bot)"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3977
  unfolding tendsto_PInfty filterlim_at_top_dense tendsto_MInfty filterlim_at_bot_dense
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3978
  using lim_ereal by (simp_all add: comp_def)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  3979
61976
3a27957ac658 more symbols;
wenzelm
parents: 61973
diff changeset
  3980
lemma inverse_infty_ereal_tendsto_0: "inverse \<midarrow>\<infinity>\<rightarrow> (0::ereal)"
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3981
proof -
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  3982
  have **: "((\<lambda>x. ereal (inverse x)) \<longlongrightarrow> ereal 0) at_infinity"
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3983
    by (intro tendsto_intros tendsto_inverse_0)
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
  3984
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3985
  show ?thesis
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3986
    by (simp add: at_infty_ereal_eq_at_top tendsto_compose_filtermap[symmetric] comp_def)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3987
       (auto simp: eventually_at_top_linorder exI[of _ 1] zero_ereal_def at_top_le_at_infinity
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3988
             intro!: filterlim_mono_eventually[OF **])
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3989
qed
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3990
61738
c4f6031f1310 New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
paulson <lp15@cam.ac.uk>
parents: 61631
diff changeset
  3991
lemma inverse_ereal_tendsto_pos:
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3992
  fixes x :: ereal assumes "0 < x"
61976
3a27957ac658 more symbols;
wenzelm
parents: 61973
diff changeset
  3993
  shows "inverse \<midarrow>x\<rightarrow> inverse x"
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3994
proof (cases x)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3995
  case (real r)
61976
3a27957ac658 more symbols;
wenzelm
parents: 61973
diff changeset
  3996
  with \<open>0 < x\<close> have **: "(\<lambda>x. ereal (inverse x)) \<midarrow>r\<rightarrow> ereal (inverse r)"
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3997
    by (auto intro!: tendsto_inverse)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3998
  from real \<open>0 < x\<close> show ?thesis
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  3999
    by (auto simp: at_ereal tendsto_compose_filtermap[symmetric] eventually_at_filter
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  4000
             intro!: Lim_transform_eventually[OF _ **] t1_space_nhds)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  4001
qed (insert \<open>0 < x\<close>, auto intro!: inverse_infty_ereal_tendsto_0)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  4002
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  4003
lemma inverse_ereal_tendsto_at_right_0: "(inverse \<longlongrightarrow> \<infinity>) (at_right (0::ereal))"
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  4004
  unfolding tendsto_compose_filtermap[symmetric] at_right_ereal zero_ereal_def
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  4005
  by (subst filterlim_cong[OF refl refl, where g="\<lambda>x. ereal (inverse x)"])
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  4006
     (auto simp: eventually_at_filter tendsto_PInfty_eq_at_top filterlim_inverse_at_top_right)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  4007
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4008
lemmas ereal_tendsto_simps = ereal_tendsto_simps1 ereal_tendsto_simps2
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4009
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4010
lemma continuous_at_iff_ereal:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4011
  fixes f :: "'a::t2_space \<Rightarrow> real"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4012
  shows "continuous (at x0 within s) f \<longleftrightarrow> continuous (at x0 within s) (ereal \<circ> f)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4013
  unfolding continuous_within comp_def lim_ereal ..
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4014
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4015
lemma continuous_on_iff_ereal:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4016
  fixes f :: "'a::t2_space => real"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4017
  assumes "open A"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4018
  shows "continuous_on A f \<longleftrightarrow> continuous_on A (ereal \<circ> f)"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4019
  unfolding continuous_on_def comp_def lim_ereal ..
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4020
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  4021
lemma continuous_on_real: "continuous_on (UNIV - {\<infinity>, -\<infinity>::ereal}) real_of_ereal"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4022
  using continuous_at_of_ereal continuous_on_eq_continuous_at open_image_ereal
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4023
  by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4024
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4025
lemma continuous_on_iff_real:
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4026
  fixes f :: "'a::t2_space \<Rightarrow> ereal"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4027
  assumes *: "\<And>x. x \<in> A \<Longrightarrow> \<bar>f x\<bar> \<noteq> \<infinity>"
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  4028
  shows "continuous_on A f \<longleftrightarrow> continuous_on A (real_of_ereal \<circ> f)"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4029
proof -
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4030
  have "f ` A \<subseteq> UNIV - {\<infinity>, -\<infinity>}"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4031
    using assms by force
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  4032
  then have *: "continuous_on (f ` A) real_of_ereal"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4033
    using continuous_on_real by (simp add: continuous_on_subset)
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  4034
  have **: "continuous_on ((real_of_ereal \<circ> f) ` A) ereal"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4035
    by (intro continuous_on_ereal continuous_on_id)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4036
  {
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4037
    assume "continuous_on A f"
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  4038
    then have "continuous_on A (real_of_ereal \<circ> f)"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4039
      apply (subst continuous_on_compose)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4040
      using *
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4041
      apply auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4042
      done
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4043
  }
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4044
  moreover
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4045
  {
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  4046
    assume "continuous_on A (real_of_ereal \<circ> f)"
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  4047
    then have "continuous_on A (ereal \<circ> (real_of_ereal \<circ> f))"
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4048
      apply (subst continuous_on_compose)
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4049
      using **
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4050
      apply auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4051
      done
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4052
    then have "continuous_on A f"
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  4053
      apply (subst continuous_on_cong[of _ A _ "ereal \<circ> (real_of_ereal \<circ> f)"])
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4054
      using assms ereal_real
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4055
      apply auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4056
      done
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4057
  }
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4058
  ultimately show ?thesis
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4059
    by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4060
qed
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4061
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4062
lemma continuous_uminus_ereal [continuous_intros]: "continuous_on (A :: ereal set) uminus"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4063
  unfolding continuous_on_def
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4064
  by (intro ballI tendsto_uminus_ereal[of "\<lambda>x. x::ereal"]) simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4065
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4066
lemma ereal_uminus_atMost [simp]: "uminus ` {..(a::ereal)} = {-a..}"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4067
proof (intro equalityI subsetI)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4068
  fix x :: ereal assume "x \<in> {-a..}"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4069
  hence "-(-x) \<in> uminus ` {..a}" by (intro imageI) (simp add: ereal_uminus_le_reorder)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4070
  thus "x \<in> uminus ` {..a}" by simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4071
qed auto
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4072
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4073
lemma continuous_on_inverse_ereal [continuous_intros]:
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4074
  "continuous_on {0::ereal ..} inverse"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4075
  unfolding continuous_on_def
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4076
proof clarsimp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4077
  fix x :: ereal assume "0 \<le> x"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4078
  moreover have "at 0 within {0 ..} = at_right (0::ereal)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4079
    by (auto simp: filter_eq_iff eventually_at_filter le_less)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4080
  moreover have "at x within {0 ..} = at x" if "0 < x"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4081
    using that by (intro at_within_nhd[of _ "{0<..}"]) auto
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4082
  ultimately show "(inverse \<longlongrightarrow> inverse x) (at x within {0..})"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4083
    by (auto simp: le_less inverse_ereal_tendsto_at_right_0 inverse_ereal_tendsto_pos)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4084
qed
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4085
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4086
lemma continuous_inverse_ereal_nonpos: "continuous_on ({..<0} :: ereal set) inverse"
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4087
proof (subst continuous_on_cong[OF refl])
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4088
  have "continuous_on {(0::ereal)<..} inverse"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4089
    by (rule continuous_on_subset[OF continuous_on_inverse_ereal]) auto
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4090
  thus "continuous_on {..<(0::ereal)} (uminus \<circ> inverse \<circ> uminus)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4091
    by (intro continuous_intros) simp_all
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4092
qed simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4093
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4094
lemma tendsto_inverse_ereal:
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4095
  assumes "(f \<longlongrightarrow> (c :: ereal)) F"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4096
  assumes "eventually (\<lambda>x. f x \<ge> 0) F"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4097
  shows   "((\<lambda>x. inverse (f x)) \<longlongrightarrow> inverse c) F"
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4098
  by (cases "F = bot")
63952
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 63940
diff changeset
  4099
     (auto intro!: tendsto_lowerbound assms
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4100
                   continuous_on_tendsto_compose[OF continuous_on_inverse_ereal])
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4101
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4102
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4103
subsubsection \<open>liminf and limsup\<close>
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4104
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4105
lemma Limsup_ereal_mult_right:
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4106
  assumes "F \<noteq> bot" "(c::real) \<ge> 0"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4107
  shows   "Limsup F (\<lambda>n. f n * ereal c) = Limsup F f * ereal c"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4108
proof (rule Limsup_compose_continuous_mono)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4109
  from assms show "continuous_on UNIV (\<lambda>a. a * ereal c)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4110
    using tendsto_cmult_ereal[of "ereal c" "\<lambda>x. x" ]
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4111
    by (force simp: continuous_on_def mult_ac)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4112
qed (insert assms, auto simp: mono_def ereal_mult_right_mono)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4113
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4114
lemma Liminf_ereal_mult_right:
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4115
  assumes "F \<noteq> bot" "(c::real) \<ge> 0"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4116
  shows   "Liminf F (\<lambda>n. f n * ereal c) = Liminf F f * ereal c"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4117
proof (rule Liminf_compose_continuous_mono)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4118
  from assms show "continuous_on UNIV (\<lambda>a. a * ereal c)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4119
    using tendsto_cmult_ereal[of "ereal c" "\<lambda>x. x" ]
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4120
    by (force simp: continuous_on_def mult_ac)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4121
qed (insert assms, auto simp: mono_def ereal_mult_right_mono)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4122
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4123
lemma Limsup_ereal_mult_left:
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4124
  assumes "F \<noteq> bot" "(c::real) \<ge> 0"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4125
  shows   "Limsup F (\<lambda>n. ereal c * f n) = ereal c * Limsup F f"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4126
  using Limsup_ereal_mult_right[OF assms] by (subst (1 2) mult.commute)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4127
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4128
lemma limsup_ereal_mult_right:
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4129
  "(c::real) \<ge> 0 \<Longrightarrow> limsup (\<lambda>n. f n * ereal c) = limsup f * ereal c"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4130
  by (rule Limsup_ereal_mult_right) simp_all
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4131
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4132
lemma limsup_ereal_mult_left:
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4133
  "(c::real) \<ge> 0 \<Longrightarrow> limsup (\<lambda>n. ereal c * f n) = ereal c * limsup f"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4134
  by (subst (1 2) mult.commute, rule limsup_ereal_mult_right) simp_all
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4135
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4136
lemma Limsup_add_ereal_right:
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4137
  "F \<noteq> bot \<Longrightarrow> abs c \<noteq> \<infinity> \<Longrightarrow> Limsup F (\<lambda>n. g n + (c :: ereal)) = Limsup F g + c"
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  4138
  by (rule Limsup_compose_continuous_mono) (auto simp: mono_def add_mono continuous_on_def)
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4139
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4140
lemma Limsup_add_ereal_left:
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4141
  "F \<noteq> bot \<Longrightarrow> abs c \<noteq> \<infinity> \<Longrightarrow> Limsup F (\<lambda>n. (c :: ereal) + g n) = c + Limsup F g"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4142
  by (subst (1 2) add.commute) (rule Limsup_add_ereal_right)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4143
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4144
lemma Liminf_add_ereal_right:
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4145
  "F \<noteq> bot \<Longrightarrow> abs c \<noteq> \<infinity> \<Longrightarrow> Liminf F (\<lambda>n. g n + (c :: ereal)) = Liminf F g + c"
68752
f221bc388ad0 (re)moved lemmas
nipkow
parents: 68532
diff changeset
  4146
  by (rule Liminf_compose_continuous_mono) (auto simp: mono_def add_mono continuous_on_def)
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4147
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4148
lemma Liminf_add_ereal_left:
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4149
  "F \<noteq> bot \<Longrightarrow> abs c \<noteq> \<infinity> \<Longrightarrow> Liminf F (\<lambda>n. (c :: ereal) + g n) = c + Liminf F g"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4150
  by (subst (1 2) add.commute) (rule Liminf_add_ereal_right)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4151
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4152
lemma
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4153
  assumes "F \<noteq> bot"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4154
  assumes nonneg: "eventually (\<lambda>x. f x \<ge> (0::ereal)) F"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4155
  shows   Liminf_inverse_ereal: "Liminf F (\<lambda>x. inverse (f x)) = inverse (Limsup F f)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4156
  and     Limsup_inverse_ereal: "Limsup F (\<lambda>x. inverse (f x)) = inverse (Liminf F f)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4157
proof -
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62975
diff changeset
  4158
  define inv where [abs_def]: "inv x = (if x \<le> 0 then \<infinity> else inverse x)" for x :: ereal
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4159
  have "continuous_on ({..0} \<union> {0..}) inv" unfolding inv_def
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4160
    by (intro continuous_on_If) (auto intro!: continuous_intros)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4161
  also have "{..0} \<union> {0..} = (UNIV :: ereal set)" by auto
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4162
  finally have cont: "continuous_on UNIV inv" .
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4163
  have antimono: "antimono inv" unfolding inv_def antimono_def
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4164
    by (auto intro!: ereal_inverse_antimono)
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  4165
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4166
  have "Liminf F (\<lambda>x. inverse (f x)) = Liminf F (\<lambda>x. inv (f x))" using nonneg
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4167
    by (auto intro!: Liminf_eq elim!: eventually_mono simp: inv_def)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4168
  also have "... = inv (Limsup F f)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4169
    by (simp add: assms(1) Liminf_compose_continuous_antimono[OF cont antimono])
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4170
  also from assms have "Limsup F f \<ge> 0" by (intro le_Limsup) simp_all
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4171
  hence "inv (Limsup F f) = inverse (Limsup F f)" by (simp add: inv_def)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4172
  finally show "Liminf F (\<lambda>x. inverse (f x)) = inverse (Limsup F f)" .
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4173
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4174
  have "Limsup F (\<lambda>x. inverse (f x)) = Limsup F (\<lambda>x. inv (f x))" using nonneg
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4175
    by (auto intro!: Limsup_eq elim!: eventually_mono simp: inv_def)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4176
  also have "... = inv (Liminf F f)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4177
    by (simp add: assms(1) Limsup_compose_continuous_antimono[OF cont antimono])
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4178
  also from assms have "Liminf F f \<ge> 0" by (intro Liminf_bounded) simp_all
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4179
  hence "inv (Liminf F f) = inverse (Liminf F f)" by (simp add: inv_def)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4180
  finally show "Limsup F (\<lambda>x. inverse (f x)) = inverse (Liminf F f)" .
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  4181
qed
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  4182
63225
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4183
lemma ereal_diff_le_mono_left: "\<lbrakk> x \<le> z; 0 \<le> y \<rbrakk> \<Longrightarrow> x - y \<le> (z :: ereal)"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4184
by(cases x y z rule: ereal3_cases) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4185
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4186
lemma neg_0_less_iff_less_erea [simp]: "0 < - a \<longleftrightarrow> (a :: ereal) < 0"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4187
by(cases a) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4188
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4189
lemma not_infty_ereal: "\<bar>x\<bar> \<noteq> \<infinity> \<longleftrightarrow> (\<exists>x'. x = ereal x')"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4190
by(cases x) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4191
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4192
lemma neq_PInf_trans: fixes x y :: ereal shows "\<lbrakk> y \<noteq> \<infinity>; x \<le> y \<rbrakk> \<Longrightarrow> x \<noteq> \<infinity>"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4193
by auto
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4194
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4195
lemma mult_2_ereal: "ereal 2 * x = x + x"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4196
by(cases x) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4197
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4198
lemma ereal_diff_le_self: "0 \<le> y \<Longrightarrow> x - y \<le> (x :: ereal)"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4199
by(cases x y rule: ereal2_cases) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4200
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4201
lemma ereal_le_add_self: "0 \<le> y \<Longrightarrow> x \<le> x + (y :: ereal)"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4202
by(cases x y rule: ereal2_cases) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4203
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4204
lemma ereal_le_add_self2: "0 \<le> y \<Longrightarrow> x \<le> y + (x :: ereal)"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4205
by(cases x y rule: ereal2_cases) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4206
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4207
lemma ereal_le_add_mono1: "\<lbrakk> x \<le> y; 0 \<le> (z :: ereal) \<rbrakk> \<Longrightarrow> x \<le> y + z"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4208
using add_mono by fastforce
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4209
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4210
lemma ereal_le_add_mono2: "\<lbrakk> x \<le> z; 0 \<le> (y :: ereal) \<rbrakk> \<Longrightarrow> x \<le> y + z"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4211
using add_mono by fastforce
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4212
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4213
lemma ereal_diff_nonpos:
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4214
  fixes a b :: ereal shows "\<lbrakk> a \<le> b; a = \<infinity> \<Longrightarrow> b \<noteq> \<infinity>; a = -\<infinity> \<Longrightarrow> b \<noteq> -\<infinity> \<rbrakk> \<Longrightarrow> a - b \<le> 0"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4215
  by (cases rule: ereal2_cases[of a b]) auto
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4216
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4217
lemma minus_ereal_0 [simp]: "x - ereal 0 = x"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 68356
diff changeset
  4218
by(simp flip: zero_ereal_def)
63225
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4219
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4220
lemma ereal_diff_eq_0_iff: fixes a b :: ereal
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4221
  shows "(\<bar>a\<bar> = \<infinity> \<Longrightarrow> \<bar>b\<bar> \<noteq> \<infinity>) \<Longrightarrow> a - b = 0 \<longleftrightarrow> a = b"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4222
by(cases a b rule: ereal2_cases) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4223
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4224
lemma SUP_ereal_eq_0_iff_nonneg:
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4225
  fixes f :: "_ \<Rightarrow> ereal" and A
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4226
  assumes nonneg: "\<forall>x\<in>A. f x \<ge> 0"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4227
  and A:"A \<noteq> {}"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  4228
  shows "(SUP x\<in>A. f x) = 0 \<longleftrightarrow> (\<forall>x\<in>A. f x = 0)" (is "?lhs \<longleftrightarrow> ?rhs")
63225
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4229
proof(intro iffI ballI)
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4230
  fix x
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4231
  assume "?lhs" "x \<in> A"
69260
0a9688695a1b removed relics of ASCII syntax for indexed big operators
haftmann
parents: 68752
diff changeset
  4232
  from \<open>x \<in> A\<close> have "f x \<le> (SUP x\<in>A. f x)" by(rule SUP_upper)
63225
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4233
  with \<open>?lhs\<close> show "f x = 0" using nonneg \<open>x \<in> A\<close> by auto
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69593
diff changeset
  4234
qed (simp add: A)
63225
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4235
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4236
lemma ereal_divide_le_posI:
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4237
  fixes x y z :: ereal
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4238
  shows "x > 0 \<Longrightarrow> z \<noteq> - \<infinity> \<Longrightarrow> z \<le> x * y \<Longrightarrow> z / x \<le> y"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4239
by (cases rule: ereal3_cases[of x y z])(auto simp: field_simps split: if_split_asm)
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4240
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4241
lemma add_diff_eq_ereal: fixes x y z :: ereal
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4242
  shows "x + (y - z) = x + y - z"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4243
by(cases x y z rule: ereal3_cases) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4244
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4245
lemma ereal_diff_gr0:
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4246
  fixes a b :: ereal shows "a < b \<Longrightarrow> 0 < b - a"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4247
  by (cases rule: ereal2_cases[of a b]) auto
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4248
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4249
lemma ereal_minus_minus: fixes x y z :: ereal shows
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4250
  "(\<bar>y\<bar> = \<infinity> \<Longrightarrow> \<bar>z\<bar> \<noteq> \<infinity>) \<Longrightarrow> x - (y - z) = x + z - y"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4251
by(cases x y z rule: ereal3_cases) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4252
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4253
lemma diff_add_eq_ereal: fixes a b c :: ereal shows "a - b + c = a + c - b"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4254
by(cases a b c rule: ereal3_cases) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4255
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4256
lemma diff_diff_commute_ereal: fixes x y z :: ereal shows "x - y - z = x - z - y"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4257
by(cases x y z rule: ereal3_cases) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4258
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4259
lemma ereal_diff_eq_MInfty_iff: fixes x y :: ereal shows "x - y = -\<infinity> \<longleftrightarrow> x = -\<infinity> \<and> y \<noteq> -\<infinity> \<or> y = \<infinity> \<and> \<bar>x\<bar> \<noteq> \<infinity>"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4260
by(cases x y rule: ereal2_cases) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4261
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4262
lemma ereal_diff_add_inverse: fixes x y :: ereal shows "\<bar>x\<bar> \<noteq> \<infinity> \<Longrightarrow> x + y - x = y"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4263
by(cases x y rule: ereal2_cases) simp_all
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4264
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4265
lemma tendsto_diff_ereal:
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4266
  fixes x y :: ereal
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4267
  assumes x: "\<bar>x\<bar> \<noteq> \<infinity>" and y: "\<bar>y\<bar> \<noteq> \<infinity>"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4268
  assumes f: "(f \<longlongrightarrow> x) F" and g: "(g \<longlongrightarrow> y) F"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4269
  shows "((\<lambda>x. f x - g x) \<longlongrightarrow> x - y) F"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4270
proof -
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4271
  from x obtain r where x': "x = ereal r" by (cases x) auto
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4272
  with f have "((\<lambda>i. real_of_ereal (f i)) \<longlongrightarrow> r) F" by simp
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4273
  moreover
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4274
  from y obtain p where y': "y = ereal p" by (cases y) auto
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4275
  with g have "((\<lambda>i. real_of_ereal (g i)) \<longlongrightarrow> p) F" by simp
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4276
  ultimately have "((\<lambda>i. real_of_ereal (f i) - real_of_ereal (g i)) \<longlongrightarrow> r - p) F"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4277
    by (rule tendsto_diff)
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4278
  moreover
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4279
  from eventually_finite[OF x f] eventually_finite[OF y g]
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4280
  have "eventually (\<lambda>x. f x - g x = ereal (real_of_ereal (f x) - real_of_ereal (g x))) F"
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4281
    by eventually_elim auto
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4282
  ultimately show ?thesis
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4283
    by (simp add: x' y' cong: filterlim_cong)
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4284
qed
19d2be0e5e9f move ennreal and ereal theorems from MFMC_Countable
hoelzl
parents: 63145
diff changeset
  4285
67727
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67685
diff changeset
  4286
lemma continuous_on_diff_ereal:
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67685
diff changeset
  4287
  "continuous_on A f \<Longrightarrow> continuous_on A g \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> \<bar>f x\<bar> \<noteq> \<infinity>) \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> \<bar>g x\<bar> \<noteq> \<infinity>) \<Longrightarrow> continuous_on A (\<lambda>z. f z - g z::ereal)"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67685
diff changeset
  4288
  apply (auto simp: continuous_on_def)
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67685
diff changeset
  4289
  apply (intro tendsto_diff_ereal)
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67685
diff changeset
  4290
  apply metis+
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67685
diff changeset
  4291
  done
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67685
diff changeset
  4292
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67685
diff changeset
  4293
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  4294
subsubsection \<open>Tests for code generator\<close>
43933
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
  4295
67408
4a4c14b24800 prefer formal comments;
wenzelm
parents: 67091
diff changeset
  4296
text \<open>A small list of simple arithmetic expressions.\<close>
43933
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
  4297
56927
4044a7d1720f hardcoded nbe and sml into value command
haftmann
parents: 56889
diff changeset
  4298
value "- \<infinity> :: ereal"
4044a7d1720f hardcoded nbe and sml into value command
haftmann
parents: 56889
diff changeset
  4299
value "\<bar>-\<infinity>\<bar> :: ereal"
4044a7d1720f hardcoded nbe and sml into value command
haftmann
parents: 56889
diff changeset
  4300
value "4 + 5 / 4 - ereal 2 :: ereal"
4044a7d1720f hardcoded nbe and sml into value command
haftmann
parents: 56889
diff changeset
  4301
value "ereal 3 < \<infinity>"
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
  4302
value "real_of_ereal (\<infinity>::ereal) = 0"
43933
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
  4303
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  4304
end