src/HOL/Library/Extended_Real.thy
author paulson <lp15@cam.ac.uk>
Tue, 02 May 2017 14:34:06 +0100
changeset 65680 378a2f11bec9
parent 64272 f76b6dda2e56
child 66936 cf8d8fc23891
permissions -rw-r--r--
Simplification of some proofs. Also key lemmas using !! rather than ! in premises
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
62626
de25474ce728 Contractible sets. Also removal of obsolete theorems and refactoring
paulson <lp15@cam.ac.uk>
parents: 62390
diff changeset
    15
text \<open>This should be part of @{theory Extended_Nat} or @{theory Order_Continuity}, but then the
de25474ce728 Contractible sets. Also removal of obsolete theorems and refactoring
paulson <lp15@cam.ac.uk>
parents: 62390
diff changeset
    16
AFP-entry \<open>Jinja_Thread\<close> fails, as it does overload certain named from @{theory Complex_Main}.\<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
    17
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
    18
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
    19
  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
    20
  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
    21
  unfolding incseq_def by (auto intro: sum_mono)
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
    22
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
    23
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
    24
  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
    25
  assumes "\<And>i. 0 \<le> f i"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
    26
  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
    27
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
    28
  fix n
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
    29
  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
    30
    using assms by (rule add_left_mono)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
    31
  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
    32
    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
    33
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
    34
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    35
lemma continuous_at_left_imp_sup_continuous:
62378
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
    36
  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
    37
  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
    38
  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
    39
  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
    40
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
    41
  fix M :: "nat \<Rightarrow> 'a" assume "incseq M" then show "f (SUP i. M i) = (SUP i. f (M i))"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    42
    using continuous_at_Sup_mono[OF assms, of "range M"] by simp
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    43
qed
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    44
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    45
lemma sup_continuous_at_left:
62378
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
    46
  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
    47
    '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
    48
  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
    49
  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
    50
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
    51
  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
    52
    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
    53
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
    54
  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
    55
  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
    56
    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
    57
  proof (intro tendsto_at_left_sequentially[of bot])
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
    58
    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
    59
    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
    60
      by (rule LIMSEQ_unique) (intro LIMSEQ_SUP S)
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
    61
    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
    62
      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
    63
      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
    64
  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
    65
qed
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    66
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    67
lemma sup_continuous_iff_at_left:
62378
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
    68
  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
    69
    '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
    70
  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
    71
  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
    72
    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
    73
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    74
lemma continuous_at_right_imp_inf_continuous:
62378
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
    75
  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
    76
  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
    77
  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
    78
  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
    79
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
    80
  fix M :: "nat \<Rightarrow> 'a" assume "decseq M" then show "f (INF i. M i) = (INF i. f (M i))"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    81
    using continuous_at_Inf_mono[OF assms, of "range M"] by simp
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    82
qed
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    83
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    84
lemma inf_continuous_at_right:
62378
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
    85
  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
    86
    '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
    87
  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
    88
  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
    89
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
    90
  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
    91
    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
    92
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
    93
  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
    94
  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
    95
    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
    96
  proof (intro tendsto_at_right_sequentially[of _ top])
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
    97
    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
    98
    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
    99
      by (rule LIMSEQ_unique) (intro LIMSEQ_INF S)
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
   100
    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
   101
      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
   102
      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
   103
  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
   104
qed
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   105
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
   106
lemma inf_continuous_iff_at_right:
62378
85ed00c1fe7c generalize more theorems to support enat and ennreal
hoelzl
parents: 62376
diff changeset
   107
  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
   108
    '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
   109
  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
   110
  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
   111
    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
   112
59115
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   113
instantiation enat :: linorder_topology
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   114
begin
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   115
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   116
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
   117
  "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
   118
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   119
instance
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   120
  proof qed (rule open_enat_def)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   121
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   122
end
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
lemma open_enat: "open {enat n}"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   125
proof (cases n)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   126
  case 0
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   127
  then have "{enat n} = {..< eSuc 0}"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   128
    by (auto simp: enat_0)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   129
  then show ?thesis
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   130
    by simp
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   131
next
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   132
  case (Suc n')
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   133
  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
   134
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   135
    apply (case_tac x)
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
    done
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   138
  then show ?thesis
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   139
    by simp
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   140
qed
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   141
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   142
lemma open_enat_iff:
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   143
  fixes A :: "enat set"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   144
  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
   145
proof safe
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   146
  assume "\<infinity> \<notin> A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   147
  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
   148
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   149
    apply (case_tac x)
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
    done
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   152
  moreover have "open \<dots>"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   153
    by (auto intro: open_enat)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   154
  ultimately show "open A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   155
    by simp
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   156
next
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   157
  fix n assume "{enat n <..} \<subseteq> A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   158
  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
   159
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   160
    apply (case_tac x)
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
    done
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   163
  moreover have "open \<dots>"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   164
    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
   165
  ultimately show "open A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   166
    by simp
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   167
next
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   168
  assume "open A" "\<infinity> \<in> A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   169
  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
   170
    unfolding open_enat_def by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   171
  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
   172
  proof induction
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   173
    case (Int A B)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   174
    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
   175
      by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   176
    then have "{enat (max n m) <..} \<subseteq> A \<inter> B"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   177
      by (auto simp add: subset_eq Ball_def max_def enat_ord_code(1)[symmetric] simp del: enat_ord_code(1))
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   178
    then show ?case
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   179
      by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   180
  next
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   181
    case (UN K)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   182
    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
   183
      by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   184
    with UN.IH[OF this] show ?case
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
  qed auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   187
qed
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   188
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   189
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
   190
proof auto
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   191
  show "nhds \<infinity> = (INF i. principal {enat i..})"
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   192
    unfolding nhds_def
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   193
    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
   194
    apply (auto intro!: INF_lower Ioi_le_Ico) []
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   195
    subgoal for x i
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   196
      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
   197
    done
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   198
  show "nhds (enat i) = principal {enat i}" for i
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   199
    by (simp add: nhds_discrete_open open_enat)
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   200
qed
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   201
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   202
instance enat :: topological_comm_monoid_add
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   203
proof
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   204
  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
   205
    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
   206
  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
   207
    by (metis add.commute)
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   208
  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
   209
    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
   210
                      filterlim_principal principal_prod_principal eventually_principal)
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   211
    subgoal for i
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   212
      by (auto intro!: eventually_INF1[of i] simp: eventually_principal)
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   213
    subgoal for j 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
    done
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
   218
qed
59115
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   219
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   220
text \<open>
63680
6e1e8b5abbfa more symbols;
wenzelm
parents: 63627
diff changeset
   221
  For more lemmas about the extended real numbers see
6e1e8b5abbfa more symbols;
wenzelm
parents: 63627
diff changeset
   222
  \<^file>\<open>~~/src/HOL/Analysis/Extended_Real_Limits.thy\<close>.
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   223
\<close>
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   224
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   225
subsection \<open>Definition and basic properties\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   226
58310
91ea607a34d8 updated news
blanchet
parents: 58249
diff changeset
   227
datatype ereal = ereal real | PInfty | MInfty
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   228
63099
af0e964aad7b Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents: 63092
diff changeset
   229
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
   230
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   231
instantiation ereal :: uminus
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   232
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   233
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   234
fun uminus_ereal where
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   235
  "- (ereal r) = ereal (- r)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   236
| "- PInfty = MInfty"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   237
| "- MInfty = PInfty"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   238
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   239
instance ..
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   240
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   241
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   242
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   243
instantiation ereal :: infinity
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   244
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   245
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   246
definition "(\<infinity>::ereal) = PInfty"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   247
instance ..
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   248
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   249
end
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   250
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   251
declare [[coercion "ereal :: real \<Rightarrow> ereal"]]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   252
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   253
lemma ereal_uminus_uminus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   254
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   255
  shows "- (- a) = a"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   256
  by (cases a) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   257
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   258
lemma
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   259
  shows PInfty_eq_infinity[simp]: "PInfty = \<infinity>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   260
    and MInfty_eq_minfinity[simp]: "MInfty = - \<infinity>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   261
    and MInfty_neq_PInfty[simp]: "\<infinity> \<noteq> - (\<infinity>::ereal)" "- \<infinity> \<noteq> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   262
    and MInfty_neq_ereal[simp]: "ereal r \<noteq> - \<infinity>" "- \<infinity> \<noteq> ereal r"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   263
    and PInfty_neq_ereal[simp]: "ereal r \<noteq> \<infinity>" "\<infinity> \<noteq> ereal r"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   264
    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
   265
    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
   266
  by (simp_all add: infinity_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   267
43933
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   268
declare
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   269
  PInfty_eq_infinity[code_post]
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   270
  MInfty_eq_minfinity[code_post]
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   271
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   272
lemma [code_unfold]:
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   273
  "\<infinity> = PInfty"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   274
  "- PInfty = MInfty"
43933
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   275
  by simp_all
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   276
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   277
lemma inj_ereal[simp]: "inj_on ereal A"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   278
  unfolding inj_on_def by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   279
55913
c1409c103b77 proper UTF-8;
wenzelm
parents: 54863
diff changeset
   280
lemma ereal_cases[cases type: ereal]:
c1409c103b77 proper UTF-8;
wenzelm
parents: 54863
diff changeset
   281
  obtains (real) r where "x = ereal r"
c1409c103b77 proper UTF-8;
wenzelm
parents: 54863
diff changeset
   282
    | (PInf) "x = \<infinity>"
c1409c103b77 proper UTF-8;
wenzelm
parents: 54863
diff changeset
   283
    | (MInf) "x = -\<infinity>"
63092
a949b2a5f51d eliminated use of empty "assms";
wenzelm
parents: 63060
diff changeset
   284
  by (cases x) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   285
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   286
lemmas ereal2_cases = ereal_cases[case_product ereal_cases]
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   287
lemmas ereal3_cases = ereal2_cases[case_product ereal_cases]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   288
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 57025
diff changeset
   289
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
   290
  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
   291
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 57025
diff changeset
   292
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
   293
  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
   294
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   295
lemma ereal_uminus_eq_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   296
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   297
  shows "-a = -b \<longleftrightarrow> a = b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   298
  by (cases rule: ereal2_cases[of a b]) simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   299
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
   300
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
   301
  "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
   302
| "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
   303
| "real_of_ereal (-\<infinity>) = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   304
  by (auto intro: ereal_cases)
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   305
termination by standard (rule wf_empty)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   306
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   307
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
   308
  "real_of_ereal (- x :: ereal) = - (real_of_ereal x)"
58042
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   309
  by (cases x) simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   310
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   311
lemma range_ereal[simp]: "range ereal = UNIV - {\<infinity>, -\<infinity>}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   312
proof safe
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   313
  fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   314
  assume "x \<notin> range ereal" "x \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   315
  then show "x = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   316
    by (cases x) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   317
qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   318
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   319
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
   320
proof safe
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   321
  fix x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   322
  show "x \<in> range uminus"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   323
    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
   324
qed auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   325
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   326
instantiation ereal :: abs
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   327
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   328
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   329
function abs_ereal where
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   330
  "\<bar>ereal r\<bar> = ereal \<bar>r\<bar>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   331
| "\<bar>-\<infinity>\<bar> = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   332
| "\<bar>\<infinity>\<bar> = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   333
by (auto intro: ereal_cases)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   334
termination proof qed (rule wf_empty)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   335
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   336
instance ..
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   337
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   338
end
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   339
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   340
lemma abs_eq_infinity_cases[elim!]:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   341
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   342
  assumes "\<bar>x\<bar> = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   343
  obtains "x = \<infinity>" | "x = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   344
  using assms by (cases x) auto
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   345
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   346
lemma abs_neq_infinity_cases[elim!]:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   347
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   348
  assumes "\<bar>x\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   349
  obtains r where "x = ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   350
  using assms by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   351
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   352
lemma abs_ereal_uminus[simp]:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   353
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   354
  shows "\<bar>- x\<bar> = \<bar>x\<bar>"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   355
  by (cases x) auto
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   356
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   357
lemma ereal_infinity_cases:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   358
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   359
  shows "a \<noteq> \<infinity> \<Longrightarrow> a \<noteq> -\<infinity> \<Longrightarrow> \<bar>a\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   360
  by auto
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   361
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   362
subsubsection "Addition"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   363
54408
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 53873
diff changeset
   364
instantiation ereal :: "{one,comm_monoid_add,zero_neq_one}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   365
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   366
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   367
definition "0 = ereal 0"
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   368
definition "1 = ereal 1"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   369
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   370
function plus_ereal where
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   371
  "ereal r + ereal p = ereal (r + p)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   372
| "\<infinity> + a = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   373
| "a + \<infinity> = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   374
| "ereal r + -\<infinity> = - \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   375
| "-\<infinity> + ereal p = -(\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   376
| "-\<infinity> + -\<infinity> = -(\<infinity>::ereal)"
61166
5976fe402824 renamed method "goals" to "goal_cases" to emphasize its meaning;
wenzelm
parents: 61120
diff changeset
   377
proof goal_cases
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   378
  case prems: (1 P x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   379
  then obtain a b where "x = (a, b)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   380
    by (cases x) auto
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   381
  with prems show P
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   382
   by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   383
qed auto
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   384
termination by standard (rule wf_empty)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   385
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   386
lemma Infty_neq_0[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   387
  "(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   388
  "-(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> -(\<infinity>::ereal)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   389
  by (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   390
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   391
lemma ereal_eq_0[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   392
  "ereal r = 0 \<longleftrightarrow> r = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   393
  "0 = ereal r \<longleftrightarrow> r = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   394
  unfolding zero_ereal_def by simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   395
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   396
lemma ereal_eq_1[simp]:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   397
  "ereal r = 1 \<longleftrightarrow> r = 1"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   398
  "1 = ereal r \<longleftrightarrow> r = 1"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   399
  unfolding one_ereal_def by simp_all
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   400
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   401
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   402
proof
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   403
  fix a b c :: ereal
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   404
  show "0 + a = a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   405
    by (cases a) (simp_all add: zero_ereal_def)
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   406
  show "a + b = b + a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   407
    by (cases rule: ereal2_cases[of a b]) simp_all
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   408
  show "a + b + c = a + (b + c)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   409
    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
   410
  show "0 \<noteq> (1::ereal)"
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 53873
diff changeset
   411
    by (simp add: one_ereal_def zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   412
qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   413
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   414
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   415
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   416
lemma ereal_0_plus [simp]: "ereal 0 + x = x"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   417
  and plus_ereal_0 [simp]: "x + ereal 0 = x"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   418
by(simp_all add: zero_ereal_def[symmetric])
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   419
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   420
instance ereal :: numeral ..
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   421
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
   422
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
   423
  unfolding zero_ereal_def by simp
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   424
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   425
lemma abs_ereal_zero[simp]: "\<bar>0\<bar> = (0::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   426
  unfolding zero_ereal_def abs_ereal.simps by simp
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   427
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   428
lemma ereal_uminus_zero[simp]: "- 0 = (0::ereal)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   429
  by (simp add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   430
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   431
lemma ereal_uminus_zero_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   432
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   433
  shows "-a = 0 \<longleftrightarrow> a = 0"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   434
  by (cases a) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   435
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   436
lemma ereal_plus_eq_PInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   437
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   438
  shows "a + b = \<infinity> \<longleftrightarrow> a = \<infinity> \<or> b = \<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   439
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   440
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   441
lemma ereal_plus_eq_MInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   442
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   443
  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
   444
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   445
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   446
lemma ereal_add_cancel_left:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   447
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   448
  assumes "a \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   449
  shows "a + b = a + c \<longleftrightarrow> a = \<infinity> \<or> b = c"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   450
  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
   451
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   452
lemma ereal_add_cancel_right:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   453
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   454
  assumes "a \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   455
  shows "b + a = c + a \<longleftrightarrow> a = \<infinity> \<or> b = c"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   456
  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
   457
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
   458
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
   459
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   460
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   461
lemma real_of_ereal_add:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   462
  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
   463
  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
   464
    (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
   465
  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
   466
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   467
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   468
subsubsection "Linear order on @{typ ereal}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   469
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   470
instantiation ereal :: linorder
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   471
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   472
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   473
function less_ereal
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   474
where
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   475
  "   ereal x < ereal y     \<longleftrightarrow> x < y"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   476
| "(\<infinity>::ereal) < a           \<longleftrightarrow> False"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   477
| "         a < -(\<infinity>::ereal) \<longleftrightarrow> False"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   478
| "ereal x    < \<infinity>           \<longleftrightarrow> True"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   479
| "        -\<infinity> < ereal r     \<longleftrightarrow> True"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   480
| "        -\<infinity> < (\<infinity>::ereal) \<longleftrightarrow> True"
61166
5976fe402824 renamed method "goals" to "goal_cases" to emphasize its meaning;
wenzelm
parents: 61120
diff changeset
   481
proof goal_cases
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   482
  case prems: (1 P x)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
   483
  then obtain a b where "x = (a,b)" by (cases x) auto
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   484
  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
   485
qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   486
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   487
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   488
definition "x \<le> (y::ereal) \<longleftrightarrow> x < y \<or> x = y"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   489
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   490
lemma ereal_infty_less[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   491
  fixes x :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   492
  shows "x < \<infinity> \<longleftrightarrow> (x \<noteq> \<infinity>)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   493
    "-\<infinity> < x \<longleftrightarrow> (x \<noteq> -\<infinity>)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   494
  by (cases x, simp_all) (cases x, simp_all)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   495
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   496
lemma ereal_infty_less_eq[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   497
  fixes x :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   498
  shows "\<infinity> \<le> x \<longleftrightarrow> x = \<infinity>"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   499
    and "x \<le> -\<infinity> \<longleftrightarrow> x = -\<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   500
  by (auto simp add: less_eq_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   501
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   502
lemma ereal_less[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   503
  "ereal r < 0 \<longleftrightarrow> (r < 0)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   504
  "0 < ereal r \<longleftrightarrow> (0 < r)"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   505
  "ereal r < 1 \<longleftrightarrow> (r < 1)"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   506
  "1 < ereal r \<longleftrightarrow> (1 < r)"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   507
  "0 < (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   508
  "-(\<infinity>::ereal) < 0"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   509
  by (simp_all add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   510
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   511
lemma ereal_less_eq[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   512
  "x \<le> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   513
  "-(\<infinity>::ereal) \<le> x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   514
  "ereal r \<le> ereal p \<longleftrightarrow> r \<le> p"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   515
  "ereal r \<le> 0 \<longleftrightarrow> r \<le> 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   516
  "0 \<le> ereal r \<longleftrightarrow> 0 \<le> r"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   517
  "ereal r \<le> 1 \<longleftrightarrow> r \<le> 1"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   518
  "1 \<le> ereal r \<longleftrightarrow> 1 \<le> r"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   519
  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
   520
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   521
lemma ereal_infty_less_eq2:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   522
  "a \<le> b \<Longrightarrow> a = \<infinity> \<Longrightarrow> b = (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   523
  "a \<le> b \<Longrightarrow> b = -\<infinity> \<Longrightarrow> a = -(\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   524
  by simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   525
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   526
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   527
proof
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   528
  fix x y z :: ereal
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   529
  show "x \<le> x"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   530
    by (cases x) simp_all
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   531
  show "x < y \<longleftrightarrow> x \<le> y \<and> \<not> y \<le> x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   532
    by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   533
  show "x \<le> y \<or> y \<le> x "
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   534
    by (cases rule: ereal2_cases[of x y]) auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   535
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   536
    assume "x \<le> y" "y \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   537
    then show "x = y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   538
      by (cases rule: ereal2_cases[of x y]) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   539
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   540
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   541
    assume "x \<le> y" "y \<le> z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   542
    then show "x \<le> z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   543
      by (cases rule: ereal3_cases[of x y z]) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   544
  }
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   545
qed
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   546
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   547
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   548
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
   549
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
   550
  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
   551
53216
ad2e09c30aa8 renamed inner_dense_linorder to dense_linorder
hoelzl
parents: 52729
diff changeset
   552
instance ereal :: dense_linorder
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   553
  by standard (blast dest: ereal_dense2)
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
   554
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
   555
instance ereal :: ordered_comm_monoid_add
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   556
proof
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   557
  fix a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   558
  assume "a \<le> b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   559
  then show "c + a \<le> c + b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   560
    by (cases rule: ereal3_cases[of a b c]) auto
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   561
qed
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   562
62648
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
   563
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
   564
  by (simp add: zero_ereal_def)
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
   565
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   566
lemma real_of_ereal_positive_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   567
  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
   568
  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
   569
  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
   570
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   571
lemma ereal_MInfty_lessI[intro, simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   572
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   573
  shows "a \<noteq> -\<infinity> \<Longrightarrow> -\<infinity> < a"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   574
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   575
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   576
lemma ereal_less_PInfty[intro, simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   577
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   578
  shows "a \<noteq> \<infinity> \<Longrightarrow> a < \<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   579
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   580
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   581
lemma ereal_less_ereal_Ex:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   582
  fixes a b :: ereal
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   583
  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
   584
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   585
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   586
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
   587
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   588
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   589
  then show ?thesis
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
   590
    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
   591
qed simp_all
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   592
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   593
lemma ereal_add_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   594
  fixes a b c d :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   595
  assumes "a \<le> b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   596
    and "c \<le> d"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   597
  shows "a + c \<le> b + d"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   598
  using assms
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   599
  apply (cases a)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   600
  apply (cases rule: ereal3_cases[of b c d], auto)
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   601
  apply (cases rule: ereal3_cases[of b c d], auto)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   602
  done
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   603
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   604
lemma ereal_minus_le_minus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   605
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   606
  shows "- a \<le> - b \<longleftrightarrow> b \<le> a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   607
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   608
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   609
lemma ereal_minus_less_minus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   610
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   611
  shows "- a < - b \<longleftrightarrow> b < a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   612
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   613
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   614
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
   615
  "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
   616
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   617
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   618
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
   619
  "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
   620
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   621
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   622
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
   623
  "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
   624
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   625
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   626
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
   627
  "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
   628
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   629
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   630
lemma real_of_ereal_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   631
  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
   632
  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
   633
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   634
lemmas real_of_ereal_ord_simps =
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   635
  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
   636
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   637
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
   638
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   639
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   640
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
   641
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   642
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   643
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
   644
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   645
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   646
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
   647
  fixes x y :: ereal
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   648
  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
   649
by(cases x y rule: ereal2_cases)(simp_all)
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   650
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
   651
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
   652
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   653
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
   654
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
   655
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   656
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   657
lemma zero_less_real_of_ereal:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   658
  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
   659
  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
   660
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   661
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   662
lemma ereal_0_le_uminus_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   663
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   664
  shows "0 \<le> - a \<longleftrightarrow> a \<le> 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   665
  by (cases rule: ereal2_cases[of a]) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   666
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   667
lemma ereal_uminus_le_0_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   668
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   669
  shows "- a \<le> 0 \<longleftrightarrow> 0 \<le> a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   670
  by (cases rule: ereal2_cases[of a]) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   671
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   672
lemma ereal_add_strict_mono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   673
  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
   674
  assumes "a \<le> b"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   675
    and "0 \<le> a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   676
    and "a \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   677
    and "c < d"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   678
  shows "a + c < b + d"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   679
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   680
  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
   681
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   682
lemma ereal_less_add:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   683
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   684
  shows "\<bar>a\<bar> \<noteq> \<infinity> \<Longrightarrow> c < b \<Longrightarrow> a + c < a + b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   685
  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
   686
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   687
lemma ereal_add_nonneg_eq_0_iff:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   688
  fixes a b :: ereal
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   689
  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
   690
  by (cases a b rule: ereal2_cases) auto
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   691
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   692
lemma ereal_uminus_eq_reorder: "- a = b \<longleftrightarrow> a = (-b::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   693
  by auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   694
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   695
lemma ereal_uminus_less_reorder: "- a < b \<longleftrightarrow> -b < (a::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   696
  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
   697
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
   698
lemma ereal_less_uminus_reorder: "a < - b \<longleftrightarrow> b < - (a::ereal)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
   699
  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
   700
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   701
lemma ereal_uminus_le_reorder: "- a \<le> b \<longleftrightarrow> -b \<le> (a::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   702
  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
   703
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   704
lemmas ereal_uminus_reorder =
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   705
  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
   706
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   707
lemma ereal_bot:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   708
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   709
  assumes "\<And>B. x \<le> ereal B"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   710
  shows "x = - \<infinity>"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   711
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   712
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   713
  with assms[of "r - 1"] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   714
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   715
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   716
  case PInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   717
  with assms[of 0] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   718
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   719
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   720
  case MInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   721
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   722
    by simp
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   723
qed
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_top:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   726
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   727
  assumes "\<And>B. x \<ge> ereal B"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   728
  shows "x = \<infinity>"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   729
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   730
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   731
  with assms[of "r + 1"] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   732
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   733
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   734
  case MInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   735
  with assms[of 0] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   736
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   737
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   738
  case PInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   739
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   740
    by simp
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   741
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   742
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   743
lemma
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   744
  shows ereal_max[simp]: "ereal (max x y) = max (ereal x) (ereal y)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   745
    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
   746
  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
   747
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   748
lemma ereal_max_0: "max 0 (ereal r) = ereal (max 0 r)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   749
  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
   750
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   751
lemma
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   752
  fixes f :: "nat \<Rightarrow> ereal"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   753
  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
   754
    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
   755
  unfolding decseq_def incseq_def by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   756
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   757
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
   758
  unfolding incseq_def by auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   759
56537
01caba82e1d2 made ereal_add_nonneg_nonneg a simp rule
nipkow
parents: 56536
diff changeset
   760
lemma ereal_add_nonneg_nonneg[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   761
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   762
  shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a + b"
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   763
  using add_mono[of 0 a 0 b] by simp
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   764
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   765
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
   766
proof (cases "finite A")
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   767
  case True
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   768
  then show ?thesis by induct auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   769
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   770
  case False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   771
  then show ?thesis by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   772
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   773
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63680
diff changeset
   774
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
   775
  by (induction xs) simp_all
af0e964aad7b Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents: 63092
diff changeset
   776
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   777
lemma sum_Pinfty:
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   778
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   779
  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
   780
proof safe
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   781
  assume *: "sum f P = \<infinity>"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   782
  show "finite P"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   783
  proof (rule ccontr)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   784
    assume "\<not> finite P"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   785
    with * show False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   786
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   787
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   788
  show "\<exists>i\<in>P. f i = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   789
  proof (rule ccontr)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   790
    assume "\<not> ?thesis"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   791
    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
   792
      by auto
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   793
    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
   794
      by induct auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   795
    with * show False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   796
      by auto
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
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   799
  fix i
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   800
  assume "finite P" and "i \<in> P" and "f i = \<infinity>"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   801
  then show "sum f P = \<infinity>"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   802
  proof induct
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   803
    case (insert x A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   804
    show ?case using insert by (cases "x = i") auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   805
  qed simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   806
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   807
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   808
lemma sum_Inf:
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   809
  fixes f :: "'a \<Rightarrow> ereal"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   810
  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
   811
proof
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   812
  assume *: "\<bar>sum f A\<bar> = \<infinity>"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   813
  have "finite A"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   814
    by (rule ccontr) (insert *, auto)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   815
  moreover have "\<exists>i\<in>A. \<bar>f i\<bar> = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   816
  proof (rule ccontr)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   817
    assume "\<not> ?thesis"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   818
    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
   819
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   820
    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
   821
    with * show False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   822
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   823
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   824
  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
   825
    by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   826
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   827
  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
   828
  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
   829
    by auto
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   830
  then show "\<bar>sum f A\<bar> = \<infinity>"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   831
  proof induct
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   832
    case (insert j A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   833
    then show ?case
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   834
      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
   835
  qed simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   836
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   837
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   838
lemma sum_real_of_ereal:
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   839
  fixes f :: "'i \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   840
  assumes "\<And>x. x \<in> S \<Longrightarrow> \<bar>f x\<bar> \<noteq> \<infinity>"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   841
  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
   842
proof -
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   843
  have "\<forall>x\<in>S. \<exists>r. f x = ereal r"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   844
  proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   845
    fix x
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   846
    assume "x \<in> S"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   847
    from assms[OF this] show "\<exists>r. f x = ereal r"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   848
      by (cases "f x") auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   849
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   850
  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
   851
  then show ?thesis
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   852
    by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   853
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   854
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   855
lemma sum_ereal_0:
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   856
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   857
  assumes "finite A"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   858
    and "\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   859
  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
   860
proof
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   861
  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
   862
  proof (induction A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   863
    case (insert a A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   864
    then have "f a = 0 \<and> (\<Sum>a\<in>A. f a) = 0"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
   865
      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
   866
    with insert show ?case
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   867
      by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   868
  qed simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   869
qed auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   870
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   871
subsubsection "Multiplication"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   872
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   873
instantiation ereal :: "{comm_monoid_mult,sgn}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   874
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   875
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   876
function sgn_ereal :: "ereal \<Rightarrow> ereal" where
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   877
  "sgn (ereal r) = ereal (sgn r)"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   878
| "sgn (\<infinity>::ereal) = 1"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   879
| "sgn (-\<infinity>::ereal) = -1"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   880
by (auto intro: ereal_cases)
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   881
termination by standard (rule wf_empty)
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   882
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   883
function times_ereal where
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   884
  "ereal r * ereal p = ereal (r * p)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   885
| "ereal r * \<infinity> = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   886
| "\<infinity> * ereal r = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   887
| "ereal r * -\<infinity> = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   888
| "-\<infinity> * ereal r = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   889
| "(\<infinity>::ereal) * \<infinity> = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   890
| "-(\<infinity>::ereal) * \<infinity> = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   891
| "(\<infinity>::ereal) * -\<infinity> = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   892
| "-(\<infinity>::ereal) * -\<infinity> = \<infinity>"
61166
5976fe402824 renamed method "goals" to "goal_cases" to emphasize its meaning;
wenzelm
parents: 61120
diff changeset
   893
proof goal_cases
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   894
  case prems: (1 P x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   895
  then obtain a b where "x = (a, b)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   896
    by (cases x) auto
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   897
  with prems show P
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   898
    by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   899
qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   900
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   901
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   902
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   903
proof
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   904
  fix a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   905
  show "1 * a = a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   906
    by (cases a) (simp_all add: one_ereal_def)
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   907
  show "a * b = b * a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   908
    by (cases rule: ereal2_cases[of a b]) simp_all
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   909
  show "a * b * c = a * (b * c)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   910
    by (cases rule: ereal3_cases[of a b c])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   911
       (simp_all add: zero_ereal_def zero_less_mult_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   912
qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   913
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   914
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   915
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
   916
lemma [simp]:
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   917
  shows ereal_1_times: "ereal 1 * x = x"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   918
  and times_ereal_1: "x * ereal 1 = x"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   919
by(simp_all add: one_ereal_def[symmetric])
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   920
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   921
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
   922
  by (simp add: one_ereal_def zero_ereal_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   923
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
   924
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
   925
  unfolding one_ereal_def by simp
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
   926
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   927
lemma real_of_ereal_le_1:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   928
  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
   929
  shows "a \<le> 1 \<Longrightarrow> real_of_ereal a \<le> 1"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   930
  by (cases a) (auto simp: one_ereal_def)
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   931
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   932
lemma abs_ereal_one[simp]: "\<bar>1\<bar> = (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   933
  unfolding one_ereal_def by simp
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   934
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   935
lemma ereal_mult_zero[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   936
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   937
  shows "a * 0 = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   938
  by (cases a) (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   939
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   940
lemma ereal_zero_mult[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   941
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   942
  shows "0 * a = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   943
  by (cases a) (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   944
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   945
lemma ereal_m1_less_0[simp]: "-(1::ereal) < 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   946
  by (simp add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   947
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   948
lemma ereal_times[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   949
  "1 \<noteq> (\<infinity>::ereal)" "(\<infinity>::ereal) \<noteq> 1"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   950
  "1 \<noteq> -(\<infinity>::ereal)" "-(\<infinity>::ereal) \<noteq> 1"
61120
65082457c117 tuned proofs;
wenzelm
parents: 60772
diff changeset
   951
  by (auto simp: one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   952
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   953
lemma ereal_plus_1[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   954
  "1 + ereal r = ereal (r + 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   955
  "ereal r + 1 = ereal (r + 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   956
  "1 + -(\<infinity>::ereal) = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   957
  "-(\<infinity>::ereal) + 1 = -\<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   958
  unfolding one_ereal_def by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   959
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   960
lemma ereal_zero_times[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   961
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   962
  shows "a * b = 0 \<longleftrightarrow> a = 0 \<or> b = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   963
  by (cases rule: ereal2_cases[of a b]) auto
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_mult_eq_PInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   966
  "a * b = (\<infinity>::ereal) \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   967
    (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
   968
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   969
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   970
lemma ereal_mult_eq_MInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   971
  "a * b = -(\<infinity>::ereal) \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   972
    (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
   973
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   974
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   975
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
   976
  by (cases x y rule: ereal2_cases) (auto simp: abs_mult)
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   977
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   978
lemma ereal_0_less_1[simp]: "0 < (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   979
  by (simp_all add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   980
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   981
lemma ereal_mult_minus_left[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   982
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   983
  shows "-a * b = - (a * b)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   984
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   985
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   986
lemma ereal_mult_minus_right[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   987
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   988
  shows "a * -b = - (a * b)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   989
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   990
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   991
lemma ereal_mult_infty[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   992
  "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
   993
  by (cases a) auto
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_infty_mult[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   996
  "(\<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
   997
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   998
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   999
lemma ereal_mult_strict_right_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1000
  assumes "a < b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1001
    and "0 < c"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1002
    and "c < (\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1003
  shows "a * c < b * c"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1004
  using assms
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1005
  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
  1006
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1007
lemma ereal_mult_strict_left_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1008
  "a < b \<Longrightarrow> 0 < c \<Longrightarrow> c < (\<infinity>::ereal) \<Longrightarrow> c * a < c * b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1009
  using ereal_mult_strict_right_mono
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57447
diff changeset
  1010
  by (simp add: mult.commute[of c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1011
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1012
lemma ereal_mult_right_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1013
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1014
  shows "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * c"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1015
  apply (cases "c = 0")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1016
  apply simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1017
  apply (cases rule: ereal3_cases[of a b c])
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1018
  apply (auto simp: zero_le_mult_iff)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1019
  done
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1020
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1021
lemma ereal_mult_left_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1022
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1023
  shows "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> c * a \<le> c * b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1024
  using ereal_mult_right_mono
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57447
diff changeset
  1025
  by (simp add: mult.commute[of c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1026
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1027
lemma zero_less_one_ereal[simp]: "0 \<le> (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1028
  by (simp add: one_ereal_def zero_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1029
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1030
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
  1031
  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
  1032
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1033
lemma ereal_right_distrib:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1034
  fixes r a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1035
  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
  1036
  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
  1037
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1038
lemma ereal_left_distrib:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1039
  fixes r a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1040
  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
  1041
  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
  1042
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1043
lemma ereal_mult_le_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1044
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1045
  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
  1046
  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
  1047
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1048
lemma ereal_zero_le_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1049
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1050
  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
  1051
  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
  1052
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1053
lemma ereal_mult_less_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1054
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1055
  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
  1056
  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
  1057
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1058
lemma ereal_zero_less_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1059
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1060
  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
  1061
  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
  1062
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1063
lemma ereal_left_mult_cong:
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1064
  fixes a b c :: ereal
59002
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1065
  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
  1066
  by (cases "c = 0") simp_all
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1067
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
  1068
lemma ereal_right_mult_cong:
59002
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1069
  fixes a b c :: ereal
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1070
  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
  1071
  by (cases "c = 0") simp_all
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1072
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1073
lemma ereal_distrib:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1074
  fixes a b c :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1075
  assumes "a \<noteq> \<infinity> \<or> b \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1076
    and "a \<noteq> -\<infinity> \<or> b \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1077
    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
  1078
  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
  1079
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1080
  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
  1081
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1082
lemma numeral_eq_ereal [simp]: "numeral w = ereal (numeral w)"
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1083
  apply (induct w rule: num_induct)
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1084
  apply (simp only: numeral_One one_ereal_def)
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1085
  apply (simp only: numeral_inc ereal_plus_1)
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1086
  done
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1087
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1088
lemma distrib_left_ereal_nn:
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1089
  "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
  1090
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
  1091
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1092
lemma sum_ereal_right_distrib:
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1093
  fixes f :: "'a \<Rightarrow> ereal"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1094
  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
  1095
  by (induct A rule: infinite_finite_induct)  (auto simp: ereal_right_distrib sum_nonneg)
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1096
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1097
lemma sum_ereal_left_distrib:
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1098
  "(\<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
  1099
  using sum_ereal_right_distrib[of A f r] by (simp add: mult_ac)
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1100
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1101
lemma sum_distrib_right_ereal:
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  1102
  "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
  1103
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
  1104
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1105
lemma ereal_le_epsilon:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1106
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1107
  assumes "\<forall>e. 0 < e \<longrightarrow> x \<le> y + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1108
  shows "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1109
proof -
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1110
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1111
    assume a: "\<exists>r. y = ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1112
    then obtain r where r_def: "y = ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1113
      by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1114
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1115
      assume "x = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1116
      then have ?thesis by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1117
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1118
    moreover
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1119
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1120
      assume "x \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1121
      then obtain p where p_def: "x = ereal p"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1122
      using a assms[rule_format, of 1]
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1123
        by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1124
      {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1125
        fix e
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1126
        have "0 < e \<longrightarrow> p \<le> r + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1127
          using assms[rule_format, of "ereal e"] p_def r_def by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1128
      }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1129
      then have "p \<le> r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1130
        apply (subst field_le_epsilon)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1131
        apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1132
        done
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1133
      then have ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1134
        using r_def p_def by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1135
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1136
    ultimately have ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1137
      by blast
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1138
  }
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1139
  moreover
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1140
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1141
    assume "y = -\<infinity> | y = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1142
    then have ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1143
      using assms[rule_format, of 1] by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1144
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1145
  ultimately show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1146
    by (cases y) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1147
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1148
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1149
lemma ereal_le_epsilon2:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1150
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1151
  assumes "\<forall>e. 0 < e \<longrightarrow> x \<le> y + ereal e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1152
  shows "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1153
proof -
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1154
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1155
    fix e :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1156
    assume "e > 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1157
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1158
      assume "e = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1159
      then have "x \<le> y + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1160
        by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1161
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1162
    moreover
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1163
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1164
      assume "e \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1165
      then obtain r where "e = ereal r"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1166
        using \<open>e > 0\<close> by (cases e) auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1167
      then have "x \<le> y + e"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1168
        using assms[rule_format, of r] \<open>e>0\<close> by auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1169
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1170
    ultimately have "x \<le> y + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1171
      by blast
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1172
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1173
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1174
    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
  1175
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1176
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1177
lemma ereal_le_real:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1178
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1179
  assumes "\<forall>z. x \<le> ereal z \<longrightarrow> y \<le> ereal z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1180
  shows "y \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1181
  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
  1182
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1183
lemma prod_ereal_0:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1184
  fixes f :: "'a \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1185
  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
  1186
proof (cases "finite A")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1187
  case True
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1188
  then show ?thesis by (induct A) auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1189
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1190
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1191
  then show ?thesis by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1192
qed
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1193
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1194
lemma prod_ereal_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1195
  fixes f :: "'a \<Rightarrow> ereal"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1196
  assumes pos: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1197
  shows "0 \<le> (\<Prod>i\<in>I. f i)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1198
proof (cases "finite I")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1199
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1200
  from this pos show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1201
    by induct auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1202
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1203
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1204
  then show ?thesis by simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1205
qed
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1206
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1207
lemma prod_PInf:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1208
  fixes f :: "'a \<Rightarrow> ereal"
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1209
  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
  1210
  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
  1211
proof (cases "finite I")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1212
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1213
  from this assms show ?thesis
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1214
  proof (induct I)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1215
    case (insert i I)
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1216
    then have pos: "0 \<le> f i" "0 \<le> prod f I"
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1217
      by (auto intro!: prod_ereal_pos)
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1218
    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
  1219
      by auto
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1220
    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
  1221
      using prod_ereal_pos[of I f] pos
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1222
      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
  1223
    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
  1224
      using insert by (auto simp: prod_ereal_0)
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1225
    finally show ?case .
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1226
  qed simp
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1227
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1228
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1229
  then show ?thesis by simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1230
qed
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1231
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  1232
lemma prod_ereal: "(\<Prod>i\<in>A. ereal (f i)) = ereal (prod f A)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1233
proof (cases "finite A")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1234
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1235
  then show ?thesis
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1236
    by induct (auto simp: one_ereal_def)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1237
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1238
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1239
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1240
    by (simp add: one_ereal_def)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1241
qed
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1242
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1243
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1244
subsubsection \<open>Power\<close>
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1245
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1246
lemma ereal_power[simp]: "(ereal x) ^ n = ereal (x^n)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1247
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1248
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1249
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
  1250
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1251
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1252
lemma ereal_power_uminus[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1253
  fixes x :: ereal
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1254
  shows "(- x) ^ n = (if even n then x ^ n else - (x^n))"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1255
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1256
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1257
lemma ereal_power_numeral[simp]:
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1258
  "(numeral num :: ereal) ^ n = ereal (numeral num ^ n)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1259
  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
  1260
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1261
lemma zero_le_power_ereal[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1262
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1263
  assumes "0 \<le> a"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1264
  shows "0 \<le> a ^ n"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1265
  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
  1266
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1267
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1268
subsubsection \<open>Subtraction\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1269
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1270
lemma ereal_minus_minus_image[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1271
  fixes S :: "ereal set"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1272
  shows "uminus ` uminus ` S = S"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1273
  by (auto simp: image_iff)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1274
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1275
lemma ereal_uminus_lessThan[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1276
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1277
  shows "uminus ` {..<a} = {-a<..}"
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1278
proof -
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1279
  {
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1280
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1281
    assume "-a < x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1282
    then have "- x < - (- a)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1283
      by (simp del: ereal_uminus_uminus)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1284
    then have "- x < a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1285
      by simp
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1286
  }
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1287
  then show ?thesis
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1288
    by force
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1289
qed
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1290
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1291
lemma ereal_uminus_greaterThan[simp]: "uminus ` {(a::ereal)<..} = {..<-a}"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1292
  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
  1293
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1294
instantiation ereal :: minus
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1295
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1296
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1297
definition "x - y = x + -(y::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1298
instance ..
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1299
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1300
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1301
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1302
lemma ereal_minus[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1303
  "ereal r - ereal p = ereal (r - p)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1304
  "-\<infinity> - ereal r = -\<infinity>"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1305
  "ereal r - \<infinity> = -\<infinity>"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1306
  "(\<infinity>::ereal) - x = \<infinity>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1307
  "-(\<infinity>::ereal) - \<infinity> = -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1308
  "x - -y = x + y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1309
  "x - 0 = x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1310
  "0 - x = -x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1311
  by (simp_all add: minus_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1312
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1313
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
  1314
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1315
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1316
lemma ereal_eq_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1317
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1318
  shows "x = z - y \<longleftrightarrow>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1319
    (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x + y = z) \<and>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1320
    (y = -\<infinity> \<longrightarrow> x = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1321
    (y = \<infinity> \<longrightarrow> z = \<infinity> \<longrightarrow> x = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1322
    (y = \<infinity> \<longrightarrow> z \<noteq> \<infinity> \<longrightarrow> x = -\<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1323
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1324
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1325
lemma ereal_eq_minus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1326
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1327
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x = z - y \<longleftrightarrow> x + y = z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1328
  by (auto simp: ereal_eq_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1329
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1330
lemma ereal_less_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1331
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1332
  shows "x < z - y \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1333
    (y = \<infinity> \<longrightarrow> z = \<infinity> \<and> x \<noteq> \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1334
    (y = -\<infinity> \<longrightarrow> x \<noteq> \<infinity>) \<and>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1335
    (\<bar>y\<bar> \<noteq> \<infinity>\<longrightarrow> x + y < z)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1336
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1337
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1338
lemma ereal_less_minus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1339
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1340
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x < z - y \<longleftrightarrow> x + y < z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1341
  by (auto simp: ereal_less_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1342
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1343
lemma ereal_le_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1344
  fixes x y z :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1345
  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
  1346
  by (cases rule: ereal3_cases[of x y z]) auto
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
lemma ereal_le_minus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1349
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1350
  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
  1351
  by (auto simp: ereal_le_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1352
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1353
lemma ereal_minus_less_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1354
  fixes x y z :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1355
  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
  1356
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1357
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1358
lemma ereal_minus_less:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1359
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1360
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x - y < z \<longleftrightarrow> x < z + y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1361
  by (auto simp: ereal_minus_less_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1362
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1363
lemma ereal_minus_le_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1364
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1365
  shows "x - y \<le> z \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1366
    (y = -\<infinity> \<longrightarrow> z = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1367
    (y = \<infinity> \<longrightarrow> x = \<infinity> \<longrightarrow> z = \<infinity>) \<and>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1368
    (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x \<le> z + y)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1369
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1370
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1371
lemma ereal_minus_le:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1372
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1373
  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
  1374
  by (auto simp: ereal_minus_le_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1375
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1376
lemma ereal_minus_eq_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1377
  fixes a b c :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1378
  shows "a - b = a - c \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1379
    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
  1380
  by (cases rule: ereal3_cases[of a b c]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1381
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1382
lemma ereal_add_le_add_iff:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1383
  fixes a b c :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1384
  shows "c + a \<le> c + b \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1385
    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
  1386
  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
  1387
59023
4999a616336c register pmf as BNF
Andreas Lochbihler
parents: 59002
diff changeset
  1388
lemma ereal_add_le_add_iff2:
4999a616336c register pmf as BNF
Andreas Lochbihler
parents: 59002
diff changeset
  1389
  fixes a b c :: ereal
4999a616336c register pmf as BNF
Andreas Lochbihler
parents: 59002
diff changeset
  1390
  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
  1391
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
  1392
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1393
lemma ereal_mult_le_mult_iff:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1394
  fixes a b c :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1395
  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
  1396
  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
  1397
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1398
lemma ereal_minus_mono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1399
  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
  1400
  shows "A - C \<le> B - D"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1401
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1402
  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
  1403
62648
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
  1404
lemma ereal_mono_minus_cancel:
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
  1405
  fixes a b c :: ereal
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
  1406
  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
  1407
  by (cases a b c rule: ereal3_cases) auto
ee48e0b4f669 more stuff for extended nonnegative real numbers
hoelzl
parents: 62626
diff changeset
  1408
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1409
lemma real_of_ereal_minus:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1410
  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
  1411
  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
  1412
  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
  1413
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
  1414
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
  1415
by(subst real_of_ereal_minus) auto
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1416
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1417
lemma ereal_diff_positive:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1418
  fixes a b :: ereal shows "a \<le> b \<Longrightarrow> 0 \<le> b - a"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1419
  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
  1420
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1421
lemma ereal_between:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1422
  fixes x e :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1423
  assumes "\<bar>x\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1424
    and "0 < e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1425
  shows "x - e < x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1426
    and "x < x + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1427
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1428
  apply (cases x, cases e)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1429
  apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1430
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1431
  apply (cases x, cases e)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1432
  apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1433
  done
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1434
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1435
lemma ereal_minus_eq_PInfty_iff:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1436
  fixes x y :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1437
  shows "x - y = \<infinity> \<longleftrightarrow> y = -\<infinity> \<or> x = \<infinity>"
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1438
  by (cases x y rule: ereal2_cases) simp_all
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1439
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1440
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
  1441
  fixes x y z :: ereal
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1442
  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
  1443
by(cases x y z rule: ereal3_cases) simp_all
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1444
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1445
lemma ereal_diff_add_assoc2:
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1446
  fixes x y z :: ereal
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1447
  shows "x + y - z = x - z + y"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1448
by(cases x y z rule: ereal3_cases) simp_all
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1449
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1450
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
  1451
by(cases x y rule: ereal2_cases) simp_all
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1452
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
  1453
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
  1454
  fixes x y :: ereal
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1455
  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
  1456
by(cases x y rule: ereal2_cases) simp_all
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1457
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1458
lemma ediff_le_self [simp]: "x - y \<le> (x :: enat)"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1459
by(cases x y rule: enat.exhaust[case_product enat.exhaust]) simp_all
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1460
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1461
subsubsection \<open>Division\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1462
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1463
instantiation ereal :: inverse
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1464
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1465
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1466
function inverse_ereal where
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1467
  "inverse (ereal r) = (if r = 0 then \<infinity> else ereal (inverse r))"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1468
| "inverse (\<infinity>::ereal) = 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1469
| "inverse (-\<infinity>::ereal) = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1470
  by (auto intro: ereal_cases)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1471
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1472
60429
d3d1e185cd63 uniform _ div _ as infix syntax for ring division
haftmann
parents: 60352
diff changeset
  1473
definition "x div y = x * inverse (y :: ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1474
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1475
instance ..
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1476
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1477
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1478
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1479
lemma real_of_ereal_inverse[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1480
  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
  1481
  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
  1482
  by (cases a) (auto simp: inverse_eq_divide)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1483
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1484
lemma ereal_inverse[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1485
  "inverse (0::ereal) = \<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1486
  "inverse (1::ereal) = 1"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1487
  by (simp_all add: one_ereal_def zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1488
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1489
lemma ereal_divide[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1490
  "ereal r / ereal p = (if p = 0 then ereal r * \<infinity> else ereal (r / p))"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1491
  unfolding divide_ereal_def by (auto simp: divide_real_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1492
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1493
lemma ereal_divide_same[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1494
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1495
  shows "x / x = (if \<bar>x\<bar> = \<infinity> \<or> x = 0 then 0 else 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1496
  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
  1497
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1498
lemma ereal_inv_inv[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1499
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1500
  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
  1501
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1502
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1503
lemma ereal_inverse_minus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1504
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1505
  shows "inverse (- x) = (if x = 0 then \<infinity> else -inverse x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1506
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1507
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1508
lemma ereal_uminus_divide[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1509
  fixes x y :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1510
  shows "- x / y = - (x / y)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1511
  unfolding divide_ereal_def by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1512
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1513
lemma ereal_divide_Infty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1514
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1515
  shows "x / \<infinity> = 0" "x / -\<infinity> = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1516
  unfolding divide_ereal_def by simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1517
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1518
lemma ereal_divide_one[simp]: "x / 1 = (x::ereal)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1519
  unfolding divide_ereal_def by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1520
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1521
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
  1522
  unfolding divide_ereal_def by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1523
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1524
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
  1525
  by (cases x) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1526
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1527
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
  1528
by(cases x) simp_all
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1529
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1530
lemma zero_le_divide_ereal[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1531
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1532
  assumes "0 \<le> a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1533
    and "0 \<le> b"
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1534
  shows "0 \<le> a / b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1535
  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
  1536
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1537
lemma ereal_le_divide_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1538
  fixes x y z :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1539
  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
  1540
  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
  1541
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1542
lemma ereal_divide_le_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1543
  fixes x y z :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1544
  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
  1545
  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
  1546
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1547
lemma ereal_le_divide_neg:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1548
  fixes x y z :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1549
  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
  1550
  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
  1551
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1552
lemma ereal_divide_le_neg:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1553
  fixes x y z :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1554
  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
  1555
  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
  1556
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1557
lemma ereal_inverse_antimono_strict:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1558
  fixes x y :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1559
  shows "0 \<le> x \<Longrightarrow> x < y \<Longrightarrow> inverse y < inverse x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1560
  by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1561
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1562
lemma ereal_inverse_antimono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1563
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1564
  shows "0 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> inverse y \<le> inverse x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1565
  by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1566
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1567
lemma inverse_inverse_Pinfty_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1568
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1569
  shows "inverse x = \<infinity> \<longleftrightarrow> x = 0"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1570
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1571
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1572
lemma ereal_inverse_eq_0:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1573
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1574
  shows "inverse x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1575
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1576
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1577
lemma ereal_0_gt_inverse:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1578
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1579
  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
  1580
  by (cases x) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1581
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1582
lemma ereal_inverse_le_0_iff:
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1583
  fixes x :: ereal
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1584
  shows "inverse x \<le> 0 \<longleftrightarrow> x < 0 \<or> x = \<infinity>"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1585
  by(cases x) auto
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1586
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1587
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
  1588
by(cases x y rule: ereal2_cases) simp_all
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1589
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1590
lemma ereal_mult_less_right:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1591
  fixes a b c :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1592
  assumes "b * a < c * a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1593
    and "0 < a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1594
    and "a < \<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1595
  shows "b < c"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1596
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1597
  by (cases rule: ereal3_cases[of a b c])
62390
842917225d56 more canonical names
nipkow
parents: 62378
diff changeset
  1598
     (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
  1599
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1600
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
  1601
  by (cases a b rule: ereal2_cases) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1602
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1603
lemma ereal_power_divide:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1604
  fixes x y :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1605
  shows "y \<noteq> 0 \<Longrightarrow> (x / y) ^ n = x^n / y^n"
58787
af9eb5e566dd eliminated redundancies;
haftmann
parents: 58310
diff changeset
  1606
  by (cases rule: ereal2_cases [of x y])
af9eb5e566dd eliminated redundancies;
haftmann
parents: 58310
diff changeset
  1607
     (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
  1608
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1609
lemma ereal_le_mult_one_interval:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1610
  fixes x y :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1611
  assumes y: "y \<noteq> -\<infinity>"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1612
  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
  1613
  shows "x \<le> y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1614
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1615
  case PInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1616
  with z[of "1 / 2"] show "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1617
    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
  1618
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1619
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1620
  note r = this
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1621
  show "x \<le> y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1622
  proof (cases y)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1623
    case (real p)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1624
    note p = this
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1625
    have "r \<le> p"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1626
    proof (rule field_le_mult_one_interval)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1627
      fix z :: real
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1628
      assume "0 < z" and "z < 1"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1629
      with z[of "ereal z"] show "z * r \<le> p"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1630
        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
  1631
    qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1632
    then show "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1633
      using p r by simp
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1634
  qed (insert y, simp_all)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1635
qed simp
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1636
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1637
lemma ereal_divide_right_mono[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1638
  fixes x y z :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1639
  assumes "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1640
    and "0 < z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1641
  shows "x / z \<le> y / z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1642
  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
  1643
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1644
lemma ereal_divide_left_mono[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1645
  fixes x y z :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1646
  assumes "y \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1647
    and "0 < z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1648
    and "0 < x * y"
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1649
  shows "z / x \<le> z / y"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1650
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1651
  by (cases x y z rule: ereal3_cases)
62390
842917225d56 more canonical names
nipkow
parents: 62378
diff changeset
  1652
     (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
  1653
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1654
lemma ereal_divide_zero_left[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1655
  fixes a :: ereal
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1656
  shows "0 / a = 0"
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1657
  by (cases a) (auto simp: zero_ereal_def)
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1658
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1659
lemma ereal_times_divide_eq_left[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1660
  fixes a b c :: ereal
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1661
  shows "b / c * a = b * a / c"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1662
  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
  1663
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1664
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
  1665
  by (cases a b c rule: ereal3_cases)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1666
     (auto simp: field_simps zero_less_mult_iff)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1667
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  1668
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
  1669
  by (cases z) simp_all
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  1670
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  1671
lemma ereal_inverse_mult:
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents: 61976
diff changeset
  1672
  "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
  1673
  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
  1674
62369
acfc4ad7b76a instantiate topologies for nat, int and enat
hoelzl
parents: 62343
diff changeset
  1675
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1676
subsection "Complete lattice"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1677
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1678
instantiation ereal :: lattice
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1679
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1680
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1681
definition [simp]: "sup x y = (max x y :: ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1682
definition [simp]: "inf x y = (min x y :: ereal)"
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
  1683
instance by standard simp_all
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1684
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1685
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1686
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1687
instantiation ereal :: complete_lattice
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1688
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1689
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1690
definition "bot = (-\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1691
definition "top = (\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1692
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1693
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
  1694
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
  1695
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1696
lemma ereal_complete_Sup:
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1697
  fixes S :: "ereal set"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1698
  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
  1699
proof (cases "\<exists>x. \<forall>a\<in>S. a \<le> ereal x")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1700
  case True
63060
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  1701
  then obtain y where y: "a \<le> ereal y" if "a\<in>S" for a
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1702
    by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1703
  then have "\<infinity> \<notin> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1704
    by force
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1705
  show ?thesis
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1706
  proof (cases "S \<noteq> {-\<infinity>} \<and> S \<noteq> {}")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1707
    case True
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1708
    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
  1709
      by auto
63060
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  1710
    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
  1711
    proof (atomize_elim, rule complete_real)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1712
      show "\<exists>x. x \<in> ereal -` S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1713
        using x by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1714
      show "\<exists>z. \<forall>x\<in>ereal -` S. x \<le> z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1715
        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
  1716
    qed
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1717
    show ?thesis
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1718
    proof (safe intro!: exI[of _ "ereal s"])
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1719
      fix y
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1720
      assume "y \<in> S"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1721
      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
  1722
        by (cases y) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1723
    next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1724
      fix z
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1725
      assume "\<forall>y\<in>S. y \<le> z"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1726
      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
  1727
        by (cases z) (auto intro!: s)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1728
    qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1729
  next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1730
    case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1731
    then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1732
      by (auto intro!: exI[of _ "-\<infinity>"])
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1733
  qed
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1734
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1735
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1736
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1737
    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
  1738
qed
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1739
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1740
lemma ereal_complete_uminus_eq:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1741
  fixes S :: "ereal set"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1742
  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
  1743
     \<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
  1744
  by simp (metis ereal_minus_le_minus ereal_uminus_uminus)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1745
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1746
lemma ereal_complete_Inf:
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1747
  "\<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
  1748
  using ereal_complete_Sup[of "uminus ` S"]
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1749
  unfolding ereal_complete_uminus_eq
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1750
  by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1751
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1752
instance
52729
412c9e0381a1 factored syntactic type classes for bot and top (by Alessandro Coglio)
haftmann
parents: 51775
diff changeset
  1753
proof
412c9e0381a1 factored syntactic type classes for bot and top (by Alessandro Coglio)
haftmann
parents: 51775
diff changeset
  1754
  show "Sup {} = (bot::ereal)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1755
    apply (auto simp: bot_ereal_def Sup_ereal_def)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1756
    apply (rule some1_equality)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1757
    apply (metis ereal_bot ereal_less_eq(2))
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1758
    apply (metis ereal_less_eq(2))
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1759
    done
52729
412c9e0381a1 factored syntactic type classes for bot and top (by Alessandro Coglio)
haftmann
parents: 51775
diff changeset
  1760
  show "Inf {} = (top::ereal)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1761
    apply (auto simp: top_ereal_def Inf_ereal_def)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1762
    apply (rule some1_equality)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1763
    apply (metis ereal_top ereal_less_eq(1))
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1764
    apply (metis ereal_less_eq(1))
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1765
    done
52729
412c9e0381a1 factored syntactic type classes for bot and top (by Alessandro Coglio)
haftmann
parents: 51775
diff changeset
  1766
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
  1767
  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
  1768
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1769
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1770
43941
481566bc20e4 ereal is a complete_linorder instance
haftmann
parents: 43933
diff changeset
  1771
instance ereal :: complete_linorder ..
481566bc20e4 ereal is a complete_linorder instance
haftmann
parents: 43933
diff changeset
  1772
51775
408d937c9486 revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
hoelzl
parents: 51774
diff changeset
  1773
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
  1774
proof
408d937c9486 revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
hoelzl
parents: 51774
diff changeset
  1775
  show "\<exists>a b::ereal. a \<noteq> b"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1776
    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
  1777
qed
60720
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1778
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1779
subsubsection "Topological space"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1780
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1781
instantiation ereal :: linear_continuum_topology
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1782
begin
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1783
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1784
definition "open_ereal" :: "ereal set \<Rightarrow> bool" where
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1785
  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
  1786
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1787
instance
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
  1788
  by standard (simp add: open_ereal_generated)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1789
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1790
end
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1791
60720
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1792
lemma continuous_on_ereal[continuous_intros]:
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1793
  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
  1794
  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
  1795
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  1796
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
  1797
  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
  1798
  by (simp add: continuous_on_eq_continuous_at)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1799
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  1800
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
  1801
  apply (rule tendsto_compose[where g=uminus])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1802
  apply (auto intro!: order_tendstoI simp: eventually_at_topological)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1803
  apply (rule_tac x="{..< -a}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1804
  apply (auto split: ereal.split simp: ereal_less_uminus_reorder) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1805
  apply (rule_tac x="{- a <..}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1806
  apply (auto split: ereal.split simp: ereal_uminus_reorder) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1807
  done
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1808
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  1809
lemma at_infty_ereal_eq_at_top: "at \<infinity> = filtermap ereal at_top"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  1810
  unfolding filter_eq_iff eventually_at_filter eventually_at_top_linorder eventually_filtermap
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  1811
    top_ereal_def[symmetric]
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  1812
  apply (subst eventually_nhds_top[of 0])
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  1813
  apply (auto simp: top_ereal_def less_le ereal_all_split ereal_ex_split)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  1814
  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
  1815
  done
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61188
diff changeset
  1816
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  1817
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
  1818
  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
  1819
  by auto
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1820
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1821
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
  1822
  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
  1823
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1824
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
  1825
  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
  1826
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1827
lemma tendsto_cmult_ereal[tendsto_intros, simp, intro]:
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  1828
  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
  1829
proof -
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1830
  { fix c :: ereal assume "0 < c" "c < \<infinity>"
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  1831
    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
  1832
      apply (intro tendsto_compose[OF _ f])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1833
      apply (auto intro!: order_tendstoI simp: eventually_at_topological)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1834
      apply (rule_tac x="{a/c <..}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1835
      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
  1836
      apply (rule_tac x="{..< a/c}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1837
      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
  1838
      done }
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1839
  note * = this
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1840
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1841
  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
  1842
    using c by (cases c) auto
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1843
  then show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1844
  proof (elim disjE conjE)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1845
    assume "- \<infinity> < c" "c < 0"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1846
    then have "0 < - c" "- c < \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1847
      by (auto simp: ereal_uminus_reorder ereal_less_uminus_reorder[of 0])
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  1848
    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
  1849
      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
  1850
    from tendsto_uminus_ereal[OF this] show ?thesis
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1851
      by simp
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1852
  qed (auto intro!: *)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1853
qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1854
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1855
lemma tendsto_cmult_ereal_not_0[tendsto_intros, simp, intro]:
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  1856
  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
  1857
proof cases
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1858
  assume "\<bar>c\<bar> = \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1859
  show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1860
  proof (rule filterlim_cong[THEN iffD1, OF refl refl _ tendsto_const])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1861
    have "0 < x \<or> x < 0"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1862
      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
  1863
    then show "eventually (\<lambda>x'. c * x = c * f x') F"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1864
    proof
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1865
      assume "0 < x" from order_tendstoD(1)[OF f this] show ?thesis
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1866
        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
  1867
    next
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1868
      assume "x < 0" from order_tendstoD(2)[OF f this] show ?thesis
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1869
        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
  1870
    qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1871
  qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1872
qed (rule tendsto_cmult_ereal[OF _ f])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1873
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1874
lemma tendsto_cadd_ereal[tendsto_intros, simp, intro]:
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  1875
  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
  1876
  apply (intro tendsto_compose[OF _ f])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1877
  apply (auto intro!: order_tendstoI simp: eventually_at_topological)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1878
  apply (rule_tac x="{a - y <..}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1879
  apply (auto split: ereal.split simp: ereal_minus_less_iff c) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1880
  apply (rule_tac x="{..< a - y}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1881
  apply (auto split: ereal.split simp: ereal_less_minus_iff c) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1882
  done
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1883
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1884
lemma tendsto_add_left_ereal[tendsto_intros, simp, intro]:
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  1885
  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
  1886
  apply (intro tendsto_compose[OF _ f])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1887
  apply (auto intro!: order_tendstoI simp: eventually_at_topological)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1888
  apply (rule_tac x="{a - y <..}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1889
  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
  1890
  apply (rule_tac x="{..< a - y}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1891
  apply (auto split: ereal.split simp: ereal_less_minus_iff c) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1892
  done
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1893
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1894
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
  1895
  unfolding continuous_def by auto
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1896
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1897
lemma ereal_Sup:
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1898
  assumes *: "\<bar>SUP a:A. ereal a\<bar> \<noteq> \<infinity>"
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1899
  shows "ereal (Sup A) = (SUP a:A. ereal a)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1900
proof (rule continuous_at_Sup_mono)
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1901
  obtain r where r: "ereal r = (SUP a:A. ereal a)" "A \<noteq> {}"
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1902
    using * by (force simp: bot_ereal_def)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1903
  then show "bdd_above A" "A \<noteq> {}"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1904
    by (auto intro!: SUP_upper bdd_aboveI[of _ r] simp add: ereal_less_eq(3)[symmetric] simp del: ereal_less_eq)
60762
bf0c76ccee8d new material for multivariate analysis, etc.
paulson
parents: 60720
diff changeset
  1905
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
  1906
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1907
lemma ereal_SUP: "\<bar>SUP a:A. ereal (f a)\<bar> \<noteq> \<infinity> \<Longrightarrow> ereal (SUP a:A. f a) = (SUP a:A. ereal (f a))"
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1908
  using ereal_Sup[of "f`A"] by auto
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1909
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1910
lemma ereal_Inf:
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1911
  assumes *: "\<bar>INF a:A. ereal a\<bar> \<noteq> \<infinity>"
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1912
  shows "ereal (Inf A) = (INF a:A. ereal a)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1913
proof (rule continuous_at_Inf_mono)
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1914
  obtain r where r: "ereal r = (INF a:A. ereal a)" "A \<noteq> {}"
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1915
    using * by (force simp: top_ereal_def)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1916
  then show "bdd_below A" "A \<noteq> {}"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1917
    by (auto intro!: INF_lower bdd_belowI[of _ r] simp add: ereal_less_eq(3)[symmetric] simp del: ereal_less_eq)
60762
bf0c76ccee8d new material for multivariate analysis, etc.
paulson
parents: 60720
diff changeset
  1918
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
  1919
62083
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  1920
lemma ereal_Inf':
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  1921
  assumes *: "bdd_below A" "A \<noteq> {}"
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  1922
  shows "ereal (Inf A) = (INF a:A. ereal a)"
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  1923
proof (rule ereal_Inf)
63060
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  1924
  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
  1925
    by (auto simp: bdd_below_def)
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  1926
  then have "l \<le> (INF x:A. ereal x)" "(INF x:A. ereal x) \<le> u"
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  1927
    by (auto intro!: INF_greatest INF_lower)
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  1928
  then show "\<bar>INF a:A. ereal a\<bar> \<noteq> \<infinity>"
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  1929
    by auto
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  1930
qed
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 62049
diff changeset
  1931
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1932
lemma ereal_INF: "\<bar>INF a:A. ereal (f a)\<bar> \<noteq> \<infinity> \<Longrightarrow> ereal (INF a:A. f a) = (INF a:A. ereal (f a))"
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1933
  using ereal_Inf[of "f`A"] by auto
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1934
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1935
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
  1936
  by (auto intro!: SUP_eqI
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1937
           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
  1938
           intro!: complete_lattice_class.Inf_lower2)
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1939
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1940
lemma ereal_SUP_uminus_eq:
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1941
  fixes f :: "'a \<Rightarrow> ereal"
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1942
  shows "(SUP x:S. uminus (f x)) = - (INF x:S. f x)"
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1943
  using ereal_Sup_uminus_image_eq [of "f ` S"] by (simp add: comp_def)
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1944
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1945
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
  1946
  by (auto intro!: inj_onI)
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1947
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1948
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
  1949
  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
  1950
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1951
lemma ereal_INF_uminus_eq:
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1952
  fixes f :: "'a \<Rightarrow> ereal"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1953
  shows "(INF x:S. - f x) = - (SUP x:S. f x)"
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1954
  using ereal_Inf_uminus_image_eq [of "f ` S"] by (simp add: comp_def)
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1955
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1956
lemma ereal_SUP_uminus:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1957
  fixes f :: "'a \<Rightarrow> ereal"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1958
  shows "(SUP i : R. - f i) = - (INF i : R. f i)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1959
  using ereal_Sup_uminus_image_eq[of "f`R"]
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1960
  by (simp add: image_image)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1961
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1962
lemma ereal_SUP_not_infty:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1963
  fixes f :: "_ \<Rightarrow> ereal"
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1964
  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>SUPREMUM A f\<bar> \<noteq> \<infinity>"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1965
  using SUP_upper2[of _ A l f] SUP_least[of A f u]
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1966
  by (cases "SUPREMUM A f") auto
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1967
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1968
lemma ereal_INF_not_infty:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1969
  fixes f :: "_ \<Rightarrow> ereal"
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1970
  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>INFIMUM A f\<bar> \<noteq> \<infinity>"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1971
  using INF_lower2[of _ A f u] INF_greatest[of A l f]
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1972
  by (cases "INFIMUM A f") auto
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1973
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1974
lemma ereal_image_uminus_shift:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1975
  fixes X Y :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1976
  shows "uminus ` X = Y \<longleftrightarrow> X = uminus ` Y"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1977
proof
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1978
  assume "uminus ` X = Y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1979
  then have "uminus ` uminus ` X = uminus ` Y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1980
    by (simp add: inj_image_eq_iff)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1981
  then show "X = uminus ` Y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1982
    by (simp add: image_image)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1983
qed (simp add: image_image)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1984
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1985
lemma Sup_eq_MInfty:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1986
  fixes S :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1987
  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
  1988
  unfolding bot_ereal_def[symmetric] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1989
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1990
lemma Inf_eq_PInfty:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1991
  fixes S :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1992
  shows "Inf S = \<infinity> \<longleftrightarrow> S = {} \<or> S = {\<infinity>}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1993
  using Sup_eq_MInfty[of "uminus`S"]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1994
  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
  1995
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1996
lemma Inf_eq_MInfty:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1997
  fixes S :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1998
  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
  1999
  unfolding bot_ereal_def[symmetric] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2000
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2001
lemma Sup_eq_PInfty:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2002
  fixes S :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2003
  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
  2004
  unfolding top_ereal_def[symmetric] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2005
60771
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  2006
lemma not_MInfty_nonneg[simp]: "0 \<le> (x::ereal) \<Longrightarrow> x \<noteq> - \<infinity>"
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  2007
  by auto
8558e4a37b48 reorganized Extended_Real
hoelzl
parents: 60762
diff changeset
  2008
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2009
lemma Sup_ereal_close:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2010
  fixes e :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2011
  assumes "0 < e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2012
    and S: "\<bar>Sup S\<bar> \<noteq> \<infinity>" "S \<noteq> {}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2013
  shows "\<exists>x\<in>S. Sup S - e < x"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  2014
  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
  2015
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2016
lemma Inf_ereal_close:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2017
  fixes e :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2018
  assumes "\<bar>Inf X\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2019
    and "0 < e"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2020
  shows "\<exists>x\<in>X. x < Inf X + e"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2021
proof (rule Inf_less_iff[THEN iffD1])
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2022
  show "Inf X < Inf X + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2023
    using assms by (cases e) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2024
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2025
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  2026
lemma SUP_PInfty:
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2027
  "(\<And>n::nat. \<exists>i\<in>A. ereal (real n) \<le> f i) \<Longrightarrow> (SUP i:A. f i :: ereal) = \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2028
  unfolding top_ereal_def[symmetric] SUP_eq_top_iff
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2029
  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
  2030
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2031
lemma SUP_nat_Infty: "(SUP i::nat. ereal (real i)) = \<infinity>"
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  2032
  by (rule SUP_PInfty) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2033
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2034
lemma SUP_ereal_add_left:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2035
  assumes "I \<noteq> {}" "c \<noteq> -\<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2036
  shows "(SUP i:I. f i + c :: ereal) = (SUP i:I. f i) + c"
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2037
proof (cases "(SUP i:I. f i) = - \<infinity>")
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2038
  case True
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2039
  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
  2040
    unfolding Sup_eq_MInfty by auto
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2041
  with True show ?thesis
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2042
    by (cases c) (auto simp: \<open>I \<noteq> {}\<close>)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2043
next
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2044
  case False
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2045
  then show ?thesis
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2046
    by (subst continuous_at_Sup_mono[where f="\<lambda>x. x + c"])
60762
bf0c76ccee8d new material for multivariate analysis, etc.
paulson
parents: 60720
diff changeset
  2047
       (auto simp: continuous_at_imp_continuous_at_within continuous_at mono_def ereal_add_mono \<open>I \<noteq> {}\<close> \<open>c \<noteq> -\<infinity>\<close>)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2048
qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2049
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2050
lemma SUP_ereal_add_right:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2051
  fixes c :: ereal
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2052
  shows "I \<noteq> {} \<Longrightarrow> c \<noteq> -\<infinity> \<Longrightarrow> (SUP i:I. c + f i) = c + (SUP i:I. f i)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2053
  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
  2054
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2055
lemma SUP_ereal_minus_right:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2056
  assumes "I \<noteq> {}" "c \<noteq> -\<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2057
  shows "(SUP i:I. c - f i :: ereal) = c - (INF i:I. f i)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2058
  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
  2059
  by (simp add: ereal_SUP_uminus minus_ereal_def)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2060
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2061
lemma SUP_ereal_minus_left:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2062
  assumes "I \<noteq> {}" "c \<noteq> \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2063
  shows "(SUP i:I. f i - c:: ereal) = (SUP i:I. f i) - c"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2064
  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
  2065
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2066
lemma INF_ereal_minus_right:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2067
  assumes "I \<noteq> {}" and "\<bar>c\<bar> \<noteq> \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2068
  shows "(INF i:I. c - f i) = c - (SUP i:I. f i::ereal)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2069
proof -
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2070
  { fix b have "(-c) + b = - (c - b)"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2071
      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
  2072
  note * = this
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2073
  show ?thesis
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2074
    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
  2075
    by (auto simp add: * ereal_SUP_uminus_eq)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2076
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2077
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2078
lemma SUP_ereal_le_addI:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2079
  fixes f :: "'i \<Rightarrow> ereal"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2080
  assumes "\<And>i. f i + y \<le> z" and "y \<noteq> -\<infinity>"
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  2081
  shows "SUPREMUM UNIV f + y \<le> z"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2082
  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
  2083
  by (rule SUP_least assms)+
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2084
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2085
lemma SUP_combine:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2086
  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
  2087
  assumes mono: "\<And>a b c d. a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> f a c \<le> f b d"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2088
  shows "(SUP i:UNIV. SUP j:UNIV. f i j) = (SUP i. f i i)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2089
proof (rule antisym)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2090
  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
  2091
    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
  2092
  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
  2093
    by (rule SUP_least SUP_upper2 UNIV_I mono order_refl)+
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2094
qed
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  2095
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2096
lemma SUP_ereal_add:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2097
  fixes f g :: "nat \<Rightarrow> ereal"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2098
  assumes inc: "incseq f" "incseq g"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2099
    and pos: "\<And>i. f i \<noteq> -\<infinity>" "\<And>i. g i \<noteq> -\<infinity>"
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  2100
  shows "(SUP i. f i + g i) = SUPREMUM UNIV f + SUPREMUM UNIV g"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2101
  apply (subst SUP_ereal_add_left[symmetric, OF UNIV_not_empty])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2102
  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
  2103
  apply (subst (2) add.commute)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2104
  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
  2105
  apply (subst (2) add.commute)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2106
  apply (rule SUP_combine[symmetric] ereal_add_mono inc[THEN monoD] | assumption)+
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2107
  done
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2108
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
  2109
lemma INF_eq_minf: "(INF i:I. f i::ereal) \<noteq> -\<infinity> \<longleftrightarrow> (\<exists>b>-\<infinity>. \<forall>i\<in>I. b \<le> f 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
  2110
  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
  2111
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
  2112
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
  2113
  assumes "I \<noteq> {}" "c \<noteq> -\<infinity>" "\<And>x. x \<in> I \<Longrightarrow> 0 \<le> f x"
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
  2114
  shows "(INF i:I. f i + c :: ereal) = (INF i:I. f i) + c"
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
  2115
proof -
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
  2116
  have "(INF i:I. f i) \<noteq> -\<infinity>"
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
  2117
    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
  2118
  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
  2119
    by (subst continuous_at_Inf_mono[where f="\<lambda>x. x + c"])
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
  2120
       (auto simp: mono_def ereal_add_mono \<open>I \<noteq> {}\<close> \<open>c \<noteq> -\<infinity>\<close> continuous_at_imp_continuous_at_within continuous_at)
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
  2121
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
  2122
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
  2123
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
  2124
  assumes "I \<noteq> {}" "c \<noteq> -\<infinity>" "\<And>x. x \<in> I \<Longrightarrow> 0 \<le> f x"
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
  2125
  shows "(INF i:I. c + f i :: ereal) = c + (INF i:I. f 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
  2126
  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
  2127
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
  2128
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
  2129
  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
  2130
  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
  2131
  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"
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
  2132
  shows "(INF i:I. f i + g i) = (INF i:I. f i) + (INF i:I. 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
  2133
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
  2134
  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
  2135
    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
  2136
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
  2137
  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
  2138
  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
  2139
  proof (rule antisym)
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
  2140
    show "(INF i:I. f i) + (INF i:I. g i) \<le> (INF i:I. f i + 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
  2141
      by (rule INF_greatest; intro ereal_add_mono INF_lower)
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
  2142
  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
  2143
    have "(INF i:I. f i + g i) \<le> (INF i:I. (INF j:I. f i + g j))"
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
  2144
      using directed by (intro INF_greatest) (blast intro: INF_lower2)
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
  2145
    also have "\<dots> = (INF i:I. f i + (INF i:I. 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
  2146
      using nonneg by (intro INF_cong refl INF_ereal_add_right \<open>I \<noteq> {}\<close>) (auto simp: INF_eq_minf intro!: exI[of _ 0])
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
  2147
    also have "\<dots> = (INF i:I. f i) + (INF i:I. 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
  2148
      using nonneg by (intro INF_ereal_add_left \<open>I \<noteq> {}\<close>) (auto simp: INF_eq_minf intro!: exI[of _ 0])
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
  2149
    finally show "(INF i:I. f i + g i) \<le> (INF i:I. f i) + (INF i:I. 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
  2150
  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
  2151
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
  2152
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2153
lemma INF_ereal_add:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2154
  fixes f :: "nat \<Rightarrow> ereal"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2155
  assumes "decseq f" "decseq g"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2156
    and fin: "\<And>i. f i \<noteq> \<infinity>" "\<And>i. g i \<noteq> \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2157
  shows "(INF i. f i + g i) = INFIMUM UNIV f + INFIMUM UNIV g"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2158
proof -
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2159
  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
  2160
    using assms unfolding INF_less_iff by auto
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2161
  { fix a b :: ereal assume "a \<noteq> \<infinity>" "b \<noteq> \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2162
    then have "- ((- a) + (- b)) = a + b"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2163
      by (cases a b rule: ereal2_cases) auto }
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2164
  note * = this
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2165
  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
  2166
    by (simp add: fin *)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2167
  also have "\<dots> = INFIMUM UNIV f + INFIMUM UNIV g"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2168
    unfolding ereal_INF_uminus_eq
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2169
    using assms INF_less
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2170
    by (subst SUP_ereal_add) (auto simp: ereal_SUP_uminus fin *)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2171
  finally show ?thesis .
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2172
qed
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  2173
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2174
lemma SUP_ereal_add_pos:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2175
  fixes f g :: "nat \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2176
  assumes inc: "incseq f" "incseq g"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2177
    and pos: "\<And>i. 0 \<le> f i" "\<And>i. 0 \<le> g i"
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  2178
  shows "(SUP i. f i + g i) = SUPREMUM UNIV f + SUPREMUM UNIV g"
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2179
proof (intro SUP_ereal_add inc)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2180
  fix i
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2181
  show "f i \<noteq> -\<infinity>" "g i \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2182
    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
  2183
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2184
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  2185
lemma SUP_ereal_sum:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2186
  fixes f g :: "'a \<Rightarrow> nat \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2187
  assumes "\<And>n. n \<in> A \<Longrightarrow> incseq (f n)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2188
    and pos: "\<And>n i. n \<in> A \<Longrightarrow> 0 \<le> f n i"
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  2189
  shows "(SUP i. \<Sum>n\<in>A. f n i) = (\<Sum>n\<in>A. SUPREMUM UNIV (f n))"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2190
proof (cases "finite A")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2191
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2192
  then show ?thesis using assms
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63968
diff changeset
  2193
    by induct (auto simp: incseq_sumI2 sum_nonneg SUP_ereal_add_pos)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2194
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2195
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2196
  then show ?thesis by simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2197
qed
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2198
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2199
lemma SUP_ereal_mult_left:
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2200
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2201
  assumes "I \<noteq> {}"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2202
  assumes f: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" and c: "0 \<le> c"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2203
  shows "(SUP i:I. c * f i) = c * (SUP i:I. f i)"
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2204
proof (cases "(SUP i: I. f i) = 0")
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2205
  case True
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2206
  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
  2207
    by (metis SUP_upper f antisym)
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2208
  with True show ?thesis
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2209
    by simp
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2210
next
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2211
  case False
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63225
diff changeset
  2212
  then show ?thesis
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2213
    by (subst continuous_at_Sup_mono[where f="\<lambda>x. c * x"])
60762
bf0c76ccee8d new material for multivariate analysis, etc.
paulson
parents: 60720
diff changeset
  2214
       (auto simp: mono_def continuous_at continuous_at_imp_continuous_at_within \<open>I \<noteq> {}\<close>
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2215
             intro!: ereal_mult_left_mono c)
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2216
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2217
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
  2218
lemma countable_approach:
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2219
  fixes x :: ereal
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2220
  assumes "x \<noteq> -\<infinity>"
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2221
  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
  2222
proof (cases x)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2223
  case (real r)
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2224
  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
  2225
    by (intro tendsto_intros LIMSEQ_inverse_real_of_nat)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2226
  ultimately show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2227
    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
  2228
next
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2229
  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
  2230
    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
  2231
qed (simp add: assms)
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2232
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2233
lemma Sup_countable_SUP:
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2234
  assumes "A \<noteq> {}"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2235
  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
  2236
proof cases
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2237
  assume "Sup A = -\<infinity>"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2238
  with \<open>A \<noteq> {}\<close> have "A = {-\<infinity>}"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2239
    by (auto simp: Sup_eq_MInfty)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2240
  then show ?thesis
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2241
    by (auto intro!: exI[of _ "\<lambda>_. -\<infinity>"] simp: bot_ereal_def)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2242
next
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2243
  assume "Sup A \<noteq> -\<infinity>"
63060
293ede07b775 some uses of 'obtain' with structure statement;
wenzelm
parents: 63040
diff changeset
  2244
  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
  2245
    by (auto dest: countable_approach)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2246
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2247
  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
  2248
  proof (rule dependent_nat_choice)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2249
    show "\<exists>x. x \<in> A \<and> l 0 \<le> x"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2250
      using l[of 0] by (auto simp: less_Sup_iff)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2251
  next
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2252
    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
  2253
    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
  2254
      by (auto simp: less_Sup_iff)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2255
    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
  2256
      by (auto intro!: exI[of _ "max x y"] split: split_max)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2257
  qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2258
  then guess f .. note f = this
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2259
  then have "range f \<subseteq> A" "incseq f"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2260
    by (auto simp: incseq_Suc_iff)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2261
  moreover
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2262
  have "(SUP i. f i) = Sup A"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2263
  proof (rule tendsto_unique)
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2264
    show "f \<longlonglongrightarrow> (SUP i. f i)"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2265
      by (rule LIMSEQ_SUP \<open>incseq f\<close>)+
61969
e01015e49041 more symbols;
wenzelm
parents: 61945
diff changeset
  2266
    show "f \<longlonglongrightarrow> Sup A"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2267
      using l f
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2268
      by (intro tendsto_sandwich[OF _ _ l_Sup tendsto_const])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2269
         (auto simp: Sup_upper)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2270
  qed simp
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2271
  ultimately show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2272
    by auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2273
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2274
63940
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2275
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
  2276
  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
  2277
proof -
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2278
  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
  2279
    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
  2280
  then show ?thesis
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2281
    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
  2282
       (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
  2283
qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63918
diff changeset
  2284
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2285
lemma SUP_countable_SUP:
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  2286
  "A \<noteq> {} \<Longrightarrow> \<exists>f::nat \<Rightarrow> ereal. range f \<subseteq> g`A \<and> SUPREMUM A g = SUPREMUM UNIV f"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2287
  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
  2288
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2289
subsection "Relation to @{typ enat}"
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2290
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2291
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
  2292
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2293
declare [[coercion "ereal_of_enat :: enat \<Rightarrow> ereal"]]
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2294
declare [[coercion "(\<lambda>n. ereal (real n)) :: nat \<Rightarrow> ereal"]]
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2295
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2296
lemma ereal_of_enat_simps[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2297
  "ereal_of_enat (enat n) = ereal n"
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2298
  "ereal_of_enat \<infinity> = \<infinity>"
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2299
  by (simp_all add: ereal_of_enat_def)
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2300
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2301
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
  2302
  by (cases m n rule: enat2_cases) auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2303
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2304
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
  2305
  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
  2306
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2307
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
  2308
by (cases n) (auto)
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2309
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2310
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
  2311
  by (cases n) auto
50819
5601ae592679 added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents: 50104
diff changeset
  2312
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2313
lemma ereal_of_enat_ge_zero_cancel_iff[simp]: "0 \<le> ereal_of_enat n \<longleftrightarrow> 0 \<le> n"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2314
  by (cases n) (auto simp: enat_0[symmetric])
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2315
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2316
lemma ereal_of_enat_gt_zero_cancel_iff[simp]: "0 < ereal_of_enat n \<longleftrightarrow> 0 < n"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2317
  by (cases n) (auto simp: enat_0[symmetric])
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2318
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2319
lemma ereal_of_enat_zero[simp]: "ereal_of_enat 0 = 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2320
  by (auto simp: enat_0[symmetric])
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2321
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2322
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
  2323
  by (cases n) auto
5601ae592679 added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents: 50104
diff changeset
  2324
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2325
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
  2326
  by (cases m n rule: enat2_cases) auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2327
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2328
lemma ereal_of_enat_sub:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2329
  assumes "n \<le> m"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2330
  shows "ereal_of_enat (m - n) = ereal_of_enat m - ereal_of_enat n "
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2331
  using assms by (cases m n rule: enat2_cases) auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2332
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2333
lemma ereal_of_enat_mult:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2334
  "ereal_of_enat (m * n) = ereal_of_enat m * ereal_of_enat n"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2335
  by (cases m n rule: enat2_cases) auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2336
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2337
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
  2338
lemmas ereal_of_enat_pushout = ereal_of_enat_pushin[symmetric]
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2339
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  2340
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
  2341
by(cases n) simp_all
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  2342
60637
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2343
lemma ereal_of_enat_Sup:
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2344
  assumes "A \<noteq> {}" shows "ereal_of_enat (Sup A) = (SUP a : A. ereal_of_enat a)"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2345
proof (intro antisym mono_Sup)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2346
  show "ereal_of_enat (Sup A) \<le> (SUP a : A. ereal_of_enat a)"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2347
  proof cases
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2348
    assume "finite A"
61188
b34551d94934 isabelle update_cartouches;
wenzelm
parents: 61166
diff changeset
  2349
    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
  2350
      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
  2351
    then show ?thesis
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2352
      by (auto intro: SUP_upper)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2353
  next
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2354
    assume "\<not> finite A"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2355
    have [simp]: "(SUP a : A. ereal_of_enat a) = top"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2356
      unfolding SUP_eq_top_iff
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2357
    proof safe
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2358
      fix x :: ereal assume "x < top"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2359
      then obtain n :: nat where "x < n"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2360
        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
  2361
      obtain a where "a \<in> A - enat ` {.. n}"
61188
b34551d94934 isabelle update_cartouches;
wenzelm
parents: 61166
diff changeset
  2362
        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
  2363
      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
  2364
        by (auto simp: image_iff Ball_def)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2365
           (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
  2366
      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
  2367
        by (auto intro!: bexI[of _ a])
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2368
    qed
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2369
    show ?thesis
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2370
      by simp
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2371
  qed
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2372
qed (simp add: mono_def)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2373
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2374
lemma ereal_of_enat_SUP:
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2375
  "A \<noteq> {} \<Longrightarrow> ereal_of_enat (SUP a:A. f a) = (SUP a : A. ereal_of_enat (f a))"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2376
  using ereal_of_enat_Sup[of "f`A"] by auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2377
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2378
subsection "Limits on @{typ ereal}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2379
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2380
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
  2381
  unfolding open_ereal_generated
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2382
proof (induct rule: generate_topology.induct)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2383
  case (Int A B)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2384
  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
  2385
    by auto
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2386
  with Int show ?case
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2387
    by (intro exI[of _ "max x z"]) fastforce
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2388
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2389
  case (Basis S)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2390
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2391
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2392
    have "x \<noteq> \<infinity> \<Longrightarrow> \<exists>t. x \<le> ereal t"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2393
      by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2394
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2395
  moreover note Basis
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2396
  ultimately show ?case
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2397
    by (auto split: ereal.split)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2398
qed (fastforce simp add: vimage_Union)+
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2399
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2400
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
  2401
  unfolding open_ereal_generated
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2402
proof (induct rule: generate_topology.induct)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2403
  case (Int A B)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2404
  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
  2405
    by auto
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2406
  with Int show ?case
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2407
    by (intro exI[of _ "min x z"]) fastforce
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2408
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2409
  case (Basis S)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2410
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2411
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2412
    have "x \<noteq> - \<infinity> \<Longrightarrow> \<exists>t. ereal t \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2413
      by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2414
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2415
  moreover note Basis
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2416
  ultimately show ?case
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2417
    by (auto split: ereal.split)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2418
qed (fastforce simp add: vimage_Union)+
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2419
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2420
lemma open_ereal_vimage: "open S \<Longrightarrow> open (ereal -` S)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2421
  by (intro open_vimage continuous_intros)
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2422
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2423
lemma open_ereal: "open S \<Longrightarrow> open (ereal ` S)"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2424
  unfolding open_generated_order[where 'a=real]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2425
proof (induct rule: generate_topology.induct)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2426
  case (Basis S)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2427
  moreover {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2428
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2429
    have "ereal ` {..< x} = { -\<infinity> <..< ereal x }"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2430
      apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2431
      apply (case_tac xa)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2432
      apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2433
      done
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2434
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2435
  moreover {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2436
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2437
    have "ereal ` {x <..} = { ereal x <..< \<infinity> }"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2438
      apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2439
      apply (case_tac xa)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2440
      apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2441
      done
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2442
  }
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2443
  ultimately show ?case
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2444
     by auto
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2445
qed (auto simp add: image_Union image_Int)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2446
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2447
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2448
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
  2449
  fixes x :: ereal
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2450
  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
  2451
  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
  2452
proof -
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
  2453
  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
  2454
    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