src/HOL/Library/Extended_Real.thy
author paulson
Mon, 20 Jul 2015 23:12:50 +0100
changeset 60762 bf0c76ccee8d
parent 60720 8c99fa3b7c44
child 60771 8558e4a37b48
permissions -rw-r--r--
new material for multivariate analysis, etc.
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
2dc6e382a58b standardized headers;
wenzelm
parents: 41980
diff changeset
     6
*)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
     7
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
     8
section \<open>Extended real number line\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
     9
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    10
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
    11
imports Complex_Main Extended_Nat Liminf_Limsup
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    12
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    13
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
    14
text \<open>
51022
78de6c7e8a58 replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
hoelzl
parents: 51000
diff changeset
    15
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    16
This should be part of @{theory Extended_Nat} or @{theory Order_Continuity}, but then the
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    17
AFP-entry @{text "Jinja_Thread"} fails, as it does overload certain named from @{theory Complex_Main}.
59115
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
    18
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
    19
\<close>
59115
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
    20
60172
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    21
lemma continuous_at_left_imp_sup_continuous:
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    22
  fixes f :: "'a \<Rightarrow> 'a::{complete_linorder, linorder_topology}"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    23
  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
    24
  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
    25
  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
    26
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
    27
  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
    28
    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
    29
qed
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    30
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    31
lemma sup_continuous_at_left:
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    32
  fixes f :: "'a \<Rightarrow> 'a::{complete_linorder, linorder_topology, first_countable_topology}"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    33
  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
    34
  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
    35
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
    36
  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
    37
    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
    38
next
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    39
  assume x: "x \<noteq> bot" 
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    40
  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
    41
    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
    42
  proof (intro tendsto_at_left_sequentially[of bot])
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    43
    fix S :: "nat \<Rightarrow> 'a" assume S: "incseq S" and S_x: "S ----> x"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    44
    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
    45
      by (rule LIMSEQ_unique) (intro LIMSEQ_SUP S)
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    46
    show "(\<lambda>n. f (S n)) ----> f x"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    47
      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
    48
      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
    49
  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
    50
qed
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    51
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    52
lemma sup_continuous_iff_at_left:
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    53
  fixes f :: "'a \<Rightarrow> 'a::{complete_linorder, linorder_topology, first_countable_topology}"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    54
  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
    55
  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
    56
    sup_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
    57
  
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    58
lemma continuous_at_right_imp_inf_continuous:
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    59
  fixes f :: "'a \<Rightarrow> 'a::{complete_linorder, linorder_topology}"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    60
  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
    61
  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
    62
  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
    63
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
    64
  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
    65
    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
    66
qed
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    67
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    68
lemma inf_continuous_at_right:
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    69
  fixes f :: "'a \<Rightarrow> 'a::{complete_linorder, linorder_topology, first_countable_topology}"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    70
  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
    71
  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
    72
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
    73
  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
    74
    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
    75
next
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    76
  assume x: "x \<noteq> top" 
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    77
  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
    78
    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
    79
  proof (intro tendsto_at_right_sequentially[of _ top])
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 S :: "nat \<Rightarrow> 'a" assume S: "decseq S" and S_x: "S ----> x"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    81
    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
    82
      by (rule LIMSEQ_unique) (intro LIMSEQ_INF S)
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    83
    show "(\<lambda>n. f (S n)) ----> f x"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    84
      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
    85
      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
    86
  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
    87
qed
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    88
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    89
lemma inf_continuous_iff_at_right:
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    90
  fixes f :: "'a \<Rightarrow> 'a::{complete_linorder, linorder_topology, first_countable_topology}"
423273355b55 rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
hoelzl
parents: 60060
diff changeset
    91
  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
    92
  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
    93
    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
    94
59115
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
    95
instantiation enat :: linorder_topology
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
    96
begin
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
    97
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
    98
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
    99
  "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
   100
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   101
instance
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   102
  proof qed (rule open_enat_def)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   103
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   104
end
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   105
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   106
lemma open_enat: "open {enat n}"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   107
proof (cases n)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   108
  case 0
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   109
  then have "{enat n} = {..< eSuc 0}"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   110
    by (auto simp: enat_0)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   111
  then show ?thesis
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   112
    by simp
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   113
next
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   114
  case (Suc n')
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   115
  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
   116
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   117
    apply (case_tac x)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   118
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   119
    done
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   120
  then show ?thesis
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   121
    by simp
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   122
qed
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_iff:
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   125
  fixes A :: "enat set"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   126
  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
   127
proof safe
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   128
  assume "\<infinity> \<notin> A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   129
  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
   130
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   131
    apply (case_tac x)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   132
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   133
    done
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   134
  moreover have "open \<dots>"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   135
    by (auto intro: open_enat)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   136
  ultimately show "open A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   137
    by simp
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   138
next
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   139
  fix n assume "{enat n <..} \<subseteq> A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   140
  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
   141
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   142
    apply (case_tac x)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   143
    apply auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   144
    done
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   145
  moreover have "open \<dots>"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   146
    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
   147
  ultimately show "open A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   148
    by simp
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   149
next
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   150
  assume "open A" "\<infinity> \<in> A"
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   151
  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
   152
    unfolding open_enat_def by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   153
  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
   154
  proof induction
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   155
    case (Int A B)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   156
    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
   157
      by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   158
    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
   159
      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
   160
    then show ?case
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   161
      by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   162
  next
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   163
    case (UN K)
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   164
    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
   165
      by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   166
    with UN.IH[OF this] show ?case
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   167
      by auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   168
  qed auto
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   169
qed
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   170
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   171
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   172
text \<open>
59115
f65ac77f7e07 move topology on enat to Extended_Real, otherwise Jinja_Threads fails
hoelzl
parents: 59023
diff changeset
   173
51022
78de6c7e8a58 replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
hoelzl
parents: 51000
diff changeset
   174
For more lemmas about the extended real numbers go to
78de6c7e8a58 replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
hoelzl
parents: 51000
diff changeset
   175
  @{file "~~/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy"}
78de6c7e8a58 replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
hoelzl
parents: 51000
diff changeset
   176
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   177
\<close>
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   178
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   179
subsection \<open>Definition and basic properties\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   180
58310
91ea607a34d8 updated news
blanchet
parents: 58249
diff changeset
   181
datatype ereal = ereal real | PInfty | MInfty
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   182
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   183
instantiation ereal :: uminus
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   184
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   185
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   186
fun uminus_ereal where
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   187
  "- (ereal r) = ereal (- r)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   188
| "- PInfty = MInfty"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   189
| "- MInfty = PInfty"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   190
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   191
instance ..
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   192
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   193
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   194
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   195
instantiation ereal :: infinity
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   196
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   197
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   198
definition "(\<infinity>::ereal) = PInfty"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   199
instance ..
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   200
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   201
end
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   202
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   203
declare [[coercion "ereal :: real \<Rightarrow> ereal"]]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   204
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   205
lemma ereal_uminus_uminus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   206
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   207
  shows "- (- a) = a"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   208
  by (cases a) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   209
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   210
lemma
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   211
  shows PInfty_eq_infinity[simp]: "PInfty = \<infinity>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   212
    and MInfty_eq_minfinity[simp]: "MInfty = - \<infinity>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   213
    and MInfty_neq_PInfty[simp]: "\<infinity> \<noteq> - (\<infinity>::ereal)" "- \<infinity> \<noteq> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   214
    and MInfty_neq_ereal[simp]: "ereal r \<noteq> - \<infinity>" "- \<infinity> \<noteq> ereal r"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   215
    and PInfty_neq_ereal[simp]: "ereal r \<noteq> \<infinity>" "\<infinity> \<noteq> ereal r"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   216
    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
   217
    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
   218
  by (simp_all add: infinity_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   219
43933
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   220
declare
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   221
  PInfty_eq_infinity[code_post]
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   222
  MInfty_eq_minfinity[code_post]
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   223
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   224
lemma [code_unfold]:
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   225
  "\<infinity> = PInfty"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   226
  "- PInfty = MInfty"
43933
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   227
  by simp_all
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
   228
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   229
lemma inj_ereal[simp]: "inj_on ereal A"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   230
  unfolding inj_on_def by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   231
55913
c1409c103b77 proper UTF-8;
wenzelm
parents: 54863
diff changeset
   232
lemma ereal_cases[cases type: ereal]:
c1409c103b77 proper UTF-8;
wenzelm
parents: 54863
diff changeset
   233
  obtains (real) r where "x = ereal r"
c1409c103b77 proper UTF-8;
wenzelm
parents: 54863
diff changeset
   234
    | (PInf) "x = \<infinity>"
c1409c103b77 proper UTF-8;
wenzelm
parents: 54863
diff changeset
   235
    | (MInf) "x = -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   236
  using assms by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   237
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   238
lemmas ereal2_cases = ereal_cases[case_product ereal_cases]
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   239
lemmas ereal3_cases = ereal2_cases[case_product ereal_cases]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   240
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 57025
diff changeset
   241
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
   242
  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
   243
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 57025
diff changeset
   244
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
   245
  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
   246
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   247
lemma ereal_uminus_eq_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   248
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   249
  shows "-a = -b \<longleftrightarrow> a = b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   250
  by (cases rule: ereal2_cases[of a b]) simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   251
58042
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   252
instantiation ereal :: real_of
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   253
begin
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   254
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   255
function real_ereal :: "ereal \<Rightarrow> real" where
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   256
  "real_ereal (ereal r) = r"
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   257
| "real_ereal \<infinity> = 0"
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   258
| "real_ereal (-\<infinity>) = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   259
  by (auto intro: ereal_cases)
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   260
termination by standard (rule wf_empty)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   261
58042
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   262
instance ..
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   263
end
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   264
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   265
lemma real_of_ereal[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   266
  "real (- x :: ereal) = - (real x)"
58042
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   267
  by (cases x) simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   268
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   269
lemma range_ereal[simp]: "range ereal = UNIV - {\<infinity>, -\<infinity>}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   270
proof safe
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   271
  fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   272
  assume "x \<notin> range ereal" "x \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   273
  then show "x = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   274
    by (cases x) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   275
qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   276
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   277
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
   278
proof safe
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   279
  fix x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   280
  show "x \<in> range uminus"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   281
    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
   282
qed auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   283
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   284
instantiation ereal :: abs
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   285
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   286
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   287
function abs_ereal where
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   288
  "\<bar>ereal r\<bar> = ereal \<bar>r\<bar>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   289
| "\<bar>-\<infinity>\<bar> = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   290
| "\<bar>\<infinity>\<bar> = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   291
by (auto intro: ereal_cases)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   292
termination proof qed (rule wf_empty)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   293
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   294
instance ..
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   295
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   296
end
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   297
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   298
lemma abs_eq_infinity_cases[elim!]:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   299
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   300
  assumes "\<bar>x\<bar> = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   301
  obtains "x = \<infinity>" | "x = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   302
  using assms by (cases x) auto
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   303
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   304
lemma abs_neq_infinity_cases[elim!]:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   305
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   306
  assumes "\<bar>x\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   307
  obtains r where "x = ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   308
  using assms by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   309
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   310
lemma abs_ereal_uminus[simp]:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   311
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   312
  shows "\<bar>- x\<bar> = \<bar>x\<bar>"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   313
  by (cases x) auto
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   314
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   315
lemma ereal_infinity_cases:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   316
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   317
  shows "a \<noteq> \<infinity> \<Longrightarrow> a \<noteq> -\<infinity> \<Longrightarrow> \<bar>a\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   318
  by auto
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   319
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
   320
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   321
subsubsection "Addition"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   322
54408
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 53873
diff changeset
   323
instantiation ereal :: "{one,comm_monoid_add,zero_neq_one}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   324
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   325
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   326
definition "0 = ereal 0"
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   327
definition "1 = ereal 1"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   328
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   329
function plus_ereal where
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   330
  "ereal r + ereal p = ereal (r + p)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   331
| "\<infinity> + a = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   332
| "a + \<infinity> = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   333
| "ereal r + -\<infinity> = - \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   334
| "-\<infinity> + ereal p = -(\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   335
| "-\<infinity> + -\<infinity> = -(\<infinity>::ereal)"
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   336
proof goals
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   337
  case prems: (1 P x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   338
  then obtain a b where "x = (a, b)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   339
    by (cases x) auto
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   340
  with prems show P
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   341
   by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   342
qed auto
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   343
termination by standard (rule wf_empty)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   344
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   345
lemma Infty_neq_0[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   346
  "(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   347
  "-(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> -(\<infinity>::ereal)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   348
  by (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   349
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   350
lemma ereal_eq_0[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   351
  "ereal r = 0 \<longleftrightarrow> r = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   352
  "0 = ereal r \<longleftrightarrow> r = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   353
  unfolding zero_ereal_def by simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   354
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   355
lemma ereal_eq_1[simp]:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   356
  "ereal r = 1 \<longleftrightarrow> r = 1"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   357
  "1 = ereal r \<longleftrightarrow> r = 1"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   358
  unfolding one_ereal_def by simp_all
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   359
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   360
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   361
proof
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   362
  fix a b c :: ereal
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   363
  show "0 + a = a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   364
    by (cases a) (simp_all add: zero_ereal_def)
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   365
  show "a + b = b + a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   366
    by (cases rule: ereal2_cases[of a b]) simp_all
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   367
  show "a + b + c = a + (b + c)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   368
    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
   369
  show "0 \<noteq> (1::ereal)"
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 53873
diff changeset
   370
    by (simp add: one_ereal_def zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   371
qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   372
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   373
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   374
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   375
lemma ereal_0_plus [simp]: "ereal 0 + x = x"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   376
  and plus_ereal_0 [simp]: "x + ereal 0 = x"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   377
by(simp_all add: zero_ereal_def[symmetric])
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   378
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   379
instance ereal :: numeral ..
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   380
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   381
lemma real_of_ereal_0[simp]: "real (0::ereal) = 0"
58042
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   382
  unfolding zero_ereal_def by simp
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   383
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   384
lemma abs_ereal_zero[simp]: "\<bar>0\<bar> = (0::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   385
  unfolding zero_ereal_def abs_ereal.simps by simp
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   386
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   387
lemma ereal_uminus_zero[simp]: "- 0 = (0::ereal)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   388
  by (simp add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   389
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   390
lemma ereal_uminus_zero_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   391
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   392
  shows "-a = 0 \<longleftrightarrow> a = 0"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   393
  by (cases a) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   394
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   395
lemma ereal_plus_eq_PInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   396
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   397
  shows "a + b = \<infinity> \<longleftrightarrow> a = \<infinity> \<or> b = \<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   398
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   399
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   400
lemma ereal_plus_eq_MInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   401
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   402
  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
   403
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   404
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   405
lemma ereal_add_cancel_left:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   406
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   407
  assumes "a \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   408
  shows "a + b = a + c \<longleftrightarrow> a = \<infinity> \<or> b = c"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   409
  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
   410
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   411
lemma ereal_add_cancel_right:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   412
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   413
  assumes "a \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   414
  shows "b + a = c + a \<longleftrightarrow> a = \<infinity> \<or> b = c"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   415
  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
   416
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   417
lemma ereal_real: "ereal (real x) = (if \<bar>x\<bar> = \<infinity> then 0 else x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   418
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   419
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   420
lemma real_of_ereal_add:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   421
  fixes a b :: ereal
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   422
  shows "real (a + b) =
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   423
    (if (\<bar>a\<bar> = \<infinity>) \<and> (\<bar>b\<bar> = \<infinity>) \<or> (\<bar>a\<bar> \<noteq> \<infinity>) \<and> (\<bar>b\<bar> \<noteq> \<infinity>) then real a + real b else 0)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   424
  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
   425
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   426
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   427
subsubsection "Linear order on @{typ ereal}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   428
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   429
instantiation ereal :: linorder
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   430
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   431
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   432
function less_ereal
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   433
where
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   434
  "   ereal x < ereal y     \<longleftrightarrow> x < y"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   435
| "(\<infinity>::ereal) < a           \<longleftrightarrow> False"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   436
| "         a < -(\<infinity>::ereal) \<longleftrightarrow> False"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   437
| "ereal x    < \<infinity>           \<longleftrightarrow> True"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   438
| "        -\<infinity> < ereal r     \<longleftrightarrow> True"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   439
| "        -\<infinity> < (\<infinity>::ereal) \<longleftrightarrow> True"
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   440
proof goals
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   441
  case prems: (1 P x)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
   442
  then obtain a b where "x = (a,b)" by (cases x) auto
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   443
  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
   444
qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   445
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   446
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   447
definition "x \<le> (y::ereal) \<longleftrightarrow> x < y \<or> x = y"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   448
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   449
lemma ereal_infty_less[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   450
  fixes x :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   451
  shows "x < \<infinity> \<longleftrightarrow> (x \<noteq> \<infinity>)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   452
    "-\<infinity> < x \<longleftrightarrow> (x \<noteq> -\<infinity>)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   453
  by (cases x, simp_all) (cases x, simp_all)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   454
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   455
lemma ereal_infty_less_eq[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   456
  fixes x :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   457
  shows "\<infinity> \<le> x \<longleftrightarrow> x = \<infinity>"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   458
    and "x \<le> -\<infinity> \<longleftrightarrow> x = -\<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   459
  by (auto simp add: less_eq_ereal_def)
41973
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 ereal_less[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   462
  "ereal r < 0 \<longleftrightarrow> (r < 0)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   463
  "0 < ereal r \<longleftrightarrow> (0 < r)"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   464
  "ereal r < 1 \<longleftrightarrow> (r < 1)"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   465
  "1 < ereal r \<longleftrightarrow> (1 < r)"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   466
  "0 < (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   467
  "-(\<infinity>::ereal) < 0"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   468
  by (simp_all add: zero_ereal_def one_ereal_def)
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
lemma ereal_less_eq[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   471
  "x \<le> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   472
  "-(\<infinity>::ereal) \<le> x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   473
  "ereal r \<le> ereal p \<longleftrightarrow> r \<le> p"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   474
  "ereal r \<le> 0 \<longleftrightarrow> r \<le> 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   475
  "0 \<le> ereal r \<longleftrightarrow> 0 \<le> r"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   476
  "ereal r \<le> 1 \<longleftrightarrow> r \<le> 1"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   477
  "1 \<le> ereal r \<longleftrightarrow> 1 \<le> r"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   478
  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
   479
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   480
lemma ereal_infty_less_eq2:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   481
  "a \<le> b \<Longrightarrow> a = \<infinity> \<Longrightarrow> b = (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   482
  "a \<le> b \<Longrightarrow> b = -\<infinity> \<Longrightarrow> a = -(\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   483
  by simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   484
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   485
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   486
proof
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   487
  fix x y z :: ereal
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   488
  show "x \<le> x"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   489
    by (cases x) simp_all
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   490
  show "x < y \<longleftrightarrow> x \<le> y \<and> \<not> y \<le> x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   491
    by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   492
  show "x \<le> y \<or> y \<le> x "
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   493
    by (cases rule: ereal2_cases[of x y]) auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   494
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   495
    assume "x \<le> y" "y \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   496
    then show "x = y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   497
      by (cases rule: ereal2_cases[of x y]) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   498
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   499
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   500
    assume "x \<le> y" "y \<le> z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   501
    then show "x \<le> z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   502
      by (cases rule: ereal3_cases[of x y z]) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   503
  }
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   504
qed
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   505
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   506
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   507
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
   508
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
   509
  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
   510
53216
ad2e09c30aa8 renamed inner_dense_linorder to dense_linorder
hoelzl
parents: 52729
diff changeset
   511
instance ereal :: dense_linorder
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   512
  by standard (blast dest: ereal_dense2)
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
   513
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   514
instance ereal :: ordered_ab_semigroup_add
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   515
proof
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   516
  fix a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   517
  assume "a \<le> b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   518
  then show "c + a \<le> c + b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   519
    by (cases rule: ereal3_cases[of a b c]) auto
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   520
qed
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   521
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   522
lemma real_of_ereal_positive_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   523
  fixes x y :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   524
  shows "0 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<noteq> \<infinity> \<Longrightarrow> real x \<le> real y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   525
  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
   526
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   527
lemma ereal_MInfty_lessI[intro, simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   528
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   529
  shows "a \<noteq> -\<infinity> \<Longrightarrow> -\<infinity> < a"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   530
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   531
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   532
lemma ereal_less_PInfty[intro, simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   533
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   534
  shows "a \<noteq> \<infinity> \<Longrightarrow> a < \<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   535
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   536
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   537
lemma ereal_less_ereal_Ex:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   538
  fixes a b :: ereal
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   539
  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
   540
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   541
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   542
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
   543
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   544
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   545
  then show ?thesis
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
   546
    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
   547
qed simp_all
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   548
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   549
lemma ereal_add_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   550
  fixes a b c d :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   551
  assumes "a \<le> b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   552
    and "c \<le> d"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   553
  shows "a + c \<le> b + d"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   554
  using assms
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   555
  apply (cases a)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   556
  apply (cases rule: ereal3_cases[of b c d], auto)
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   557
  apply (cases rule: ereal3_cases[of b c d], auto)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   558
  done
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   559
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   560
lemma ereal_minus_le_minus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   561
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   562
  shows "- a \<le> - b \<longleftrightarrow> b \<le> a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   563
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   564
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   565
lemma ereal_minus_less_minus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   566
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   567
  shows "- a < - b \<longleftrightarrow> b < a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   568
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   569
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   570
lemma ereal_le_real_iff:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   571
  "x \<le> real 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
   572
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   573
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   574
lemma real_le_ereal_iff:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   575
  "real 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
   576
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   577
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   578
lemma ereal_less_real_iff:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   579
  "x < real 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
   580
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   581
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   582
lemma real_less_ereal_iff:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   583
  "real 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
   584
  by (cases y) 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 real_of_ereal_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   587
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   588
  shows "0 \<le> x \<Longrightarrow> 0 \<le> real x" by (cases x) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   589
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   590
lemmas real_of_ereal_ord_simps =
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   591
  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
   592
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   593
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
   594
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   595
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   596
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
   597
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   598
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   599
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
   600
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   601
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   602
lemma real_of_ereal_le_0[simp]: "real (x :: ereal) \<le> 0 \<longleftrightarrow> x \<le> 0 \<or> x = \<infinity>"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   603
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   604
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   605
lemma abs_real_of_ereal[simp]: "\<bar>real (x :: ereal)\<bar> = real \<bar>x\<bar>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   606
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   607
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   608
lemma zero_less_real_of_ereal:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   609
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   610
  shows "0 < real x \<longleftrightarrow> 0 < x \<and> x \<noteq> \<infinity>"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   611
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   612
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   613
lemma ereal_0_le_uminus_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   614
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   615
  shows "0 \<le> - a \<longleftrightarrow> a \<le> 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   616
  by (cases rule: ereal2_cases[of a]) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   617
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   618
lemma ereal_uminus_le_0_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   619
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   620
  shows "- a \<le> 0 \<longleftrightarrow> 0 \<le> a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   621
  by (cases rule: ereal2_cases[of a]) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   622
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   623
lemma ereal_add_strict_mono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   624
  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
   625
  assumes "a \<le> b"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   626
    and "0 \<le> a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   627
    and "a \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   628
    and "c < d"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   629
  shows "a + c < b + d"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   630
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   631
  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
   632
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   633
lemma ereal_less_add:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   634
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   635
  shows "\<bar>a\<bar> \<noteq> \<infinity> \<Longrightarrow> c < b \<Longrightarrow> a + c < a + b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   636
  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
   637
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   638
lemma ereal_add_nonneg_eq_0_iff:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   639
  fixes a b :: ereal
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   640
  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
   641
  by (cases a b rule: ereal2_cases) auto
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   642
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   643
lemma ereal_uminus_eq_reorder: "- a = b \<longleftrightarrow> a = (-b::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   644
  by auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   645
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   646
lemma ereal_uminus_less_reorder: "- a < b \<longleftrightarrow> -b < (a::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   647
  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
   648
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
   649
lemma ereal_less_uminus_reorder: "a < - b \<longleftrightarrow> b < - (a::ereal)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
   650
  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
   651
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   652
lemma ereal_uminus_le_reorder: "- a \<le> b \<longleftrightarrow> -b \<le> (a::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   653
  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
   654
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   655
lemmas ereal_uminus_reorder =
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   656
  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
   657
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   658
lemma ereal_bot:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   659
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   660
  assumes "\<And>B. x \<le> ereal B"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   661
  shows "x = - \<infinity>"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   662
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   663
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   664
  with assms[of "r - 1"] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   665
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   666
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   667
  case PInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   668
  with assms[of 0] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   669
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   670
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   671
  case MInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   672
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   673
    by simp
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   674
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   675
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   676
lemma ereal_top:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   677
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   678
  assumes "\<And>B. x \<ge> ereal B"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   679
  shows "x = \<infinity>"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   680
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   681
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   682
  with assms[of "r + 1"] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   683
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   684
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   685
  case MInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   686
  with assms[of 0] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   687
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   688
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   689
  case PInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   690
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   691
    by simp
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   692
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   693
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   694
lemma
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   695
  shows ereal_max[simp]: "ereal (max x y) = max (ereal x) (ereal y)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   696
    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
   697
  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
   698
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   699
lemma ereal_max_0: "max 0 (ereal r) = ereal (max 0 r)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   700
  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
   701
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   702
lemma
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   703
  fixes f :: "nat \<Rightarrow> ereal"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   704
  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
   705
    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
   706
  unfolding decseq_def incseq_def by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   707
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   708
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
   709
  unfolding incseq_def by auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   710
56537
01caba82e1d2 made ereal_add_nonneg_nonneg a simp rule
nipkow
parents: 56536
diff changeset
   711
lemma ereal_add_nonneg_nonneg[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   712
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   713
  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
   714
  using add_mono[of 0 a 0 b] by simp
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   715
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   716
lemma image_eqD: "f ` A = B \<Longrightarrow> \<forall>x\<in>A. f x \<in> B"
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   717
  by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   718
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   719
lemma incseq_setsumI:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   720
  fixes f :: "nat \<Rightarrow> 'a::{comm_monoid_add,ordered_ab_semigroup_add}"
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   721
  assumes "\<And>i. 0 \<le> f i"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   722
  shows "incseq (\<lambda>i. setsum f {..< i})"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   723
proof (intro incseq_SucI)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   724
  fix n
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   725
  have "setsum f {..< n} + 0 \<le> setsum f {..<n} + f n"
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   726
    using assms by (rule add_left_mono)
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   727
  then show "setsum f {..< n} \<le> setsum f {..< Suc n}"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   728
    by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   729
qed
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   730
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   731
lemma incseq_setsumI2:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   732
  fixes f :: "'i \<Rightarrow> nat \<Rightarrow> 'a::{comm_monoid_add,ordered_ab_semigroup_add}"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   733
  assumes "\<And>n. n \<in> A \<Longrightarrow> incseq (f n)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   734
  shows "incseq (\<lambda>i. \<Sum>n\<in>A. f n i)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   735
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   736
  unfolding incseq_def by (auto intro: setsum_mono)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   737
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   738
lemma setsum_ereal[simp]: "(\<Sum>x\<in>A. ereal (f x)) = ereal (\<Sum>x\<in>A. f x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   739
proof (cases "finite A")
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   740
  case True
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   741
  then show ?thesis by induct auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   742
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   743
  case False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   744
  then show ?thesis by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   745
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   746
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   747
lemma setsum_Pinfty:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   748
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   749
  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
   750
proof safe
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   751
  assume *: "setsum f P = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   752
  show "finite P"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   753
  proof (rule ccontr)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   754
    assume "\<not> finite P"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   755
    with * show False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   756
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   757
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   758
  show "\<exists>i\<in>P. f i = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   759
  proof (rule ccontr)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   760
    assume "\<not> ?thesis"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   761
    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
   762
      by auto
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   763
    with \<open>finite P\<close> have "setsum f P \<noteq> \<infinity>"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   764
      by induct auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   765
    with * show False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   766
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   767
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   768
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   769
  fix i
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   770
  assume "finite P" and "i \<in> P" and "f i = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   771
  then show "setsum f P = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   772
  proof induct
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   773
    case (insert x A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   774
    show ?case using insert by (cases "x = i") auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   775
  qed simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   776
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   777
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   778
lemma setsum_Inf:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   779
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   780
  shows "\<bar>setsum f A\<bar> = \<infinity> \<longleftrightarrow> 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
   781
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   782
  assume *: "\<bar>setsum f A\<bar> = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   783
  have "finite A"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   784
    by (rule ccontr) (insert *, auto)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   785
  moreover have "\<exists>i\<in>A. \<bar>f i\<bar> = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   786
  proof (rule ccontr)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   787
    assume "\<not> ?thesis"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   788
    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
   789
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   790
    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
   791
    with * show False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   792
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   793
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   794
  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
   795
    by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   796
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   797
  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
   798
  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
   799
    by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   800
  then show "\<bar>setsum f A\<bar> = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   801
  proof induct
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   802
    case (insert j A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   803
    then show ?case
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   804
      by (cases rule: ereal3_cases[of "f i" "f j" "setsum f A"]) 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
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   808
lemma setsum_real_of_ereal:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   809
  fixes f :: "'i \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   810
  assumes "\<And>x. x \<in> S \<Longrightarrow> \<bar>f x\<bar> \<noteq> \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   811
  shows "(\<Sum>x\<in>S. real (f x)) = real (setsum f S)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   812
proof -
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   813
  have "\<forall>x\<in>S. \<exists>r. f x = ereal r"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   814
  proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   815
    fix x
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   816
    assume "x \<in> S"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   817
    from assms[OF this] show "\<exists>r. f x = ereal r"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   818
      by (cases "f x") auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   819
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   820
  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
   821
  then show ?thesis
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   822
    by simp
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
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   825
lemma setsum_ereal_0:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   826
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   827
  assumes "finite A"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   828
    and "\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   829
  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
   830
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   831
  assume "setsum f A = 0" with assms show "\<forall>i\<in>A. f i = 0"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   832
  proof (induction A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   833
    case (insert a A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   834
    then have "f a = 0 \<and> (\<Sum>a\<in>A. f a) = 0"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   835
      by (subst ereal_add_nonneg_eq_0_iff[symmetric]) (simp_all add: setsum_nonneg)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   836
    with insert show ?case
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   837
      by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   838
  qed simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   839
qed auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   840
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   841
subsubsection "Multiplication"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   842
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   843
instantiation ereal :: "{comm_monoid_mult,sgn}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   844
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   845
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   846
function sgn_ereal :: "ereal \<Rightarrow> ereal" where
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   847
  "sgn (ereal r) = ereal (sgn r)"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   848
| "sgn (\<infinity>::ereal) = 1"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   849
| "sgn (-\<infinity>::ereal) = -1"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   850
by (auto intro: ereal_cases)
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   851
termination by standard (rule wf_empty)
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   852
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   853
function times_ereal where
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   854
  "ereal r * ereal p = ereal (r * p)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   855
| "ereal r * \<infinity> = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   856
| "\<infinity> * ereal r = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   857
| "ereal r * -\<infinity> = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   858
| "-\<infinity> * ereal r = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   859
| "(\<infinity>::ereal) * \<infinity> = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   860
| "-(\<infinity>::ereal) * \<infinity> = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   861
| "(\<infinity>::ereal) * -\<infinity> = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   862
| "-(\<infinity>::ereal) * -\<infinity> = \<infinity>"
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   863
proof goals
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   864
  case prems: (1 P x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   865
  then obtain a b where "x = (a, b)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   866
    by (cases x) auto
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   867
  with prems show P
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   868
    by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   869
qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   870
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   871
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   872
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   873
proof
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   874
  fix a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   875
  show "1 * a = a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   876
    by (cases a) (simp_all add: one_ereal_def)
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   877
  show "a * b = b * a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   878
    by (cases rule: ereal2_cases[of a b]) simp_all
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   879
  show "a * b * c = a * (b * c)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   880
    by (cases rule: ereal3_cases[of a b c])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   881
       (simp_all add: zero_ereal_def zero_less_mult_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   882
qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   883
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   884
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   885
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   886
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
   887
  by (simp add: one_ereal_def zero_ereal_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   888
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
   889
lemma real_ereal_1[simp]: "real (1::ereal) = 1"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
   890
  unfolding one_ereal_def by simp
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
   891
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   892
lemma real_of_ereal_le_1:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   893
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   894
  shows "a \<le> 1 \<Longrightarrow> real a \<le> 1"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   895
  by (cases a) (auto simp: one_ereal_def)
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   896
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   897
lemma abs_ereal_one[simp]: "\<bar>1\<bar> = (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   898
  unfolding one_ereal_def by simp
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   899
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   900
lemma ereal_mult_zero[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   901
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   902
  shows "a * 0 = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   903
  by (cases a) (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   904
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   905
lemma ereal_zero_mult[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   906
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   907
  shows "0 * a = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   908
  by (cases a) (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   909
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   910
lemma ereal_m1_less_0[simp]: "-(1::ereal) < 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   911
  by (simp add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   912
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   913
lemma ereal_times[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   914
  "1 \<noteq> (\<infinity>::ereal)" "(\<infinity>::ereal) \<noteq> 1"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   915
  "1 \<noteq> -(\<infinity>::ereal)" "-(\<infinity>::ereal) \<noteq> 1"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   916
  by (auto simp add: times_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   917
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   918
lemma ereal_plus_1[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   919
  "1 + ereal r = ereal (r + 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   920
  "ereal r + 1 = ereal (r + 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   921
  "1 + -(\<infinity>::ereal) = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   922
  "-(\<infinity>::ereal) + 1 = -\<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   923
  unfolding one_ereal_def by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   924
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   925
lemma ereal_zero_times[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   926
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   927
  shows "a * b = 0 \<longleftrightarrow> a = 0 \<or> b = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   928
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   929
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   930
lemma ereal_mult_eq_PInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   931
  "a * b = (\<infinity>::ereal) \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   932
    (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
   933
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   934
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   935
lemma ereal_mult_eq_MInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   936
  "a * b = -(\<infinity>::ereal) \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   937
    (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
   938
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   939
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   940
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
   941
  by (cases x y rule: ereal2_cases) (auto simp: abs_mult)
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   942
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   943
lemma ereal_0_less_1[simp]: "0 < (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   944
  by (simp_all add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   945
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   946
lemma ereal_mult_minus_left[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   947
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   948
  shows "-a * b = - (a * b)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   949
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   950
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   951
lemma ereal_mult_minus_right[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   952
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   953
  shows "a * -b = - (a * b)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   954
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   955
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   956
lemma ereal_mult_infty[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   957
  "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
   958
  by (cases a) auto
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_infty_mult[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   961
  "(\<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
   962
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   963
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   964
lemma ereal_mult_strict_right_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   965
  assumes "a < b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   966
    and "0 < c"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   967
    and "c < (\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   968
  shows "a * c < b * c"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   969
  using assms
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   970
  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
   971
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   972
lemma ereal_mult_strict_left_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   973
  "a < b \<Longrightarrow> 0 < c \<Longrightarrow> c < (\<infinity>::ereal) \<Longrightarrow> c * a < c * b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   974
  using ereal_mult_strict_right_mono
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57447
diff changeset
   975
  by (simp add: mult.commute[of c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   976
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   977
lemma ereal_mult_right_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   978
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   979
  shows "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * c"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   980
  using assms
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   981
  apply (cases "c = 0")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   982
  apply simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   983
  apply (cases rule: ereal3_cases[of a b c])
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   984
  apply (auto simp: zero_le_mult_iff)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   985
  done
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   986
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   987
lemma ereal_mult_left_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   988
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   989
  shows "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> c * a \<le> c * b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   990
  using ereal_mult_right_mono
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57447
diff changeset
   991
  by (simp add: mult.commute[of c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   992
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   993
lemma zero_less_one_ereal[simp]: "0 \<le> (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   994
  by (simp add: one_ereal_def zero_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   995
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   996
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
   997
  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
   998
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   999
lemma ereal_right_distrib:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1000
  fixes r a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1001
  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
  1002
  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
  1003
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1004
lemma ereal_left_distrib:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1005
  fixes r a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1006
  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
  1007
  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
  1008
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1009
lemma ereal_mult_le_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1010
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1011
  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
  1012
  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
  1013
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1014
lemma ereal_zero_le_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1015
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1016
  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
  1017
  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
  1018
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1019
lemma ereal_mult_less_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1020
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1021
  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
  1022
  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
  1023
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1024
lemma ereal_zero_less_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1025
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1026
  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
  1027
  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
  1028
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1029
lemma ereal_left_mult_cong:
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1030
  fixes a b c :: ereal
59002
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1031
  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
  1032
  by (cases "c = 0") simp_all
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1033
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1034
lemma ereal_right_mult_cong: 
59002
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1035
  fixes a b c :: ereal
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1036
  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
  1037
  by (cases "c = 0") simp_all
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1038
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1039
lemma ereal_distrib:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1040
  fixes a b c :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1041
  assumes "a \<noteq> \<infinity> \<or> b \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1042
    and "a \<noteq> -\<infinity> \<or> b \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1043
    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
  1044
  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
  1045
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1046
  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
  1047
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1048
lemma numeral_eq_ereal [simp]: "numeral w = ereal (numeral w)"
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1049
  apply (induct w rule: num_induct)
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1050
  apply (simp only: numeral_One one_ereal_def)
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1051
  apply (simp only: numeral_inc ereal_plus_1)
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1052
  done
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1053
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1054
lemma setsum_ereal_right_distrib:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1055
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1056
  shows "(\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i) \<Longrightarrow> r * setsum f A = (\<Sum>n\<in>A. r * f n)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1057
  by (induct A rule: infinite_finite_induct)  (auto simp: ereal_right_distrib setsum_nonneg)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1058
59002
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1059
lemma setsum_ereal_left_distrib:
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1060
  "(\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i) \<Longrightarrow> setsum f A * r = (\<Sum>n\<in>A. f n * r :: ereal)"
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1061
  using setsum_ereal_right_distrib[of A f r] by (simp add: mult_ac)
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1062
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1063
lemma ereal_le_epsilon:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1064
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1065
  assumes "\<forall>e. 0 < e \<longrightarrow> x \<le> y + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1066
  shows "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1067
proof -
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1068
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1069
    assume a: "\<exists>r. y = ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1070
    then obtain r where r_def: "y = ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1071
      by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1072
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1073
      assume "x = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1074
      then have ?thesis by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1075
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1076
    moreover
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1077
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1078
      assume "x \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1079
      then obtain p where p_def: "x = ereal p"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1080
      using a assms[rule_format, of 1]
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1081
        by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1082
      {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1083
        fix e
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1084
        have "0 < e \<longrightarrow> p \<le> r + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1085
          using assms[rule_format, of "ereal e"] p_def r_def by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1086
      }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1087
      then have "p \<le> r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1088
        apply (subst field_le_epsilon)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1089
        apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1090
        done
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1091
      then have ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1092
        using r_def p_def by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1093
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1094
    ultimately have ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1095
      by blast
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1096
  }
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1097
  moreover
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1098
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1099
    assume "y = -\<infinity> | y = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1100
    then have ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1101
      using assms[rule_format, of 1] by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1102
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1103
  ultimately show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1104
    by (cases y) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1105
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1106
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1107
lemma ereal_le_epsilon2:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1108
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1109
  assumes "\<forall>e. 0 < e \<longrightarrow> x \<le> y + ereal e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1110
  shows "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1111
proof -
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1112
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1113
    fix e :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1114
    assume "e > 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1115
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1116
      assume "e = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1117
      then have "x \<le> y + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1118
        by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1119
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1120
    moreover
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1121
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1122
      assume "e \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1123
      then obtain r where "e = ereal r"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1124
        using \<open>e > 0\<close> by (cases e) auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1125
      then have "x \<le> y + e"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1126
        using assms[rule_format, of r] \<open>e>0\<close> by auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1127
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1128
    ultimately have "x \<le> y + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1129
      by blast
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1130
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1131
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1132
    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
  1133
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1134
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1135
lemma ereal_le_real:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1136
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1137
  assumes "\<forall>z. x \<le> ereal z \<longrightarrow> y \<le> ereal z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1138
  shows "y \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1139
  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
  1140
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1141
lemma setprod_ereal_0:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1142
  fixes f :: "'a \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1143
  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
  1144
proof (cases "finite A")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1145
  case True
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1146
  then show ?thesis by (induct A) auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1147
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1148
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1149
  then show ?thesis by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1150
qed
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1151
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1152
lemma setprod_ereal_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1153
  fixes f :: "'a \<Rightarrow> ereal"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1154
  assumes pos: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1155
  shows "0 \<le> (\<Prod>i\<in>I. f i)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1156
proof (cases "finite I")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1157
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1158
  from this pos show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1159
    by induct auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1160
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1161
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1162
  then show ?thesis by simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1163
qed
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1164
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1165
lemma setprod_PInf:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1166
  fixes f :: "'a \<Rightarrow> ereal"
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1167
  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
  1168
  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
  1169
proof (cases "finite I")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1170
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1171
  from this assms show ?thesis
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1172
  proof (induct I)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1173
    case (insert i I)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1174
    then have pos: "0 \<le> f i" "0 \<le> setprod f I"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1175
      by (auto intro!: setprod_ereal_pos)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1176
    from insert have "(\<Prod>j\<in>insert i I. f j) = \<infinity> \<longleftrightarrow> setprod f I * f i = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1177
      by auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1178
    also have "\<dots> \<longleftrightarrow> (setprod f I = \<infinity> \<or> f i = \<infinity>) \<and> f i \<noteq> 0 \<and> setprod f I \<noteq> 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1179
      using setprod_ereal_pos[of I f] pos
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1180
      by (cases rule: ereal2_cases[of "f i" "setprod f I"]) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1181
    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)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1182
      using insert by (auto simp: setprod_ereal_0)
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1183
    finally show ?case .
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1184
  qed simp
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1185
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1186
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1187
  then show ?thesis by simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1188
qed
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1189
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1190
lemma setprod_ereal: "(\<Prod>i\<in>A. ereal (f i)) = ereal (setprod f A)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1191
proof (cases "finite A")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1192
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1193
  then show ?thesis
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1194
    by induct (auto simp: one_ereal_def)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1195
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1196
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1197
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1198
    by (simp add: one_ereal_def)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1199
qed
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1200
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1201
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1202
subsubsection \<open>Power\<close>
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1203
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1204
lemma ereal_power[simp]: "(ereal x) ^ n = ereal (x^n)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1205
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1206
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1207
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
  1208
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1209
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1210
lemma ereal_power_uminus[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1211
  fixes x :: ereal
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1212
  shows "(- x) ^ n = (if even n then x ^ n else - (x^n))"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1213
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1214
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1215
lemma ereal_power_numeral[simp]:
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1216
  "(numeral num :: ereal) ^ n = ereal (numeral num ^ n)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1217
  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
  1218
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1219
lemma zero_le_power_ereal[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1220
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1221
  assumes "0 \<le> a"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1222
  shows "0 \<le> a ^ n"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1223
  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
  1224
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1225
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1226
subsubsection \<open>Subtraction\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1227
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1228
lemma ereal_minus_minus_image[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1229
  fixes S :: "ereal set"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1230
  shows "uminus ` uminus ` S = S"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1231
  by (auto simp: image_iff)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1232
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1233
lemma ereal_uminus_lessThan[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1234
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1235
  shows "uminus ` {..<a} = {-a<..}"
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1236
proof -
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1237
  {
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1238
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1239
    assume "-a < x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1240
    then have "- x < - (- a)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1241
      by (simp del: ereal_uminus_uminus)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1242
    then have "- x < a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1243
      by simp
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1244
  }
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1245
  then show ?thesis
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1246
    by force
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1247
qed
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1248
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1249
lemma ereal_uminus_greaterThan[simp]: "uminus ` {(a::ereal)<..} = {..<-a}"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1250
  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
  1251
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1252
instantiation ereal :: minus
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1253
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1254
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1255
definition "x - y = x + -(y::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1256
instance ..
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1257
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1258
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1259
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1260
lemma ereal_minus[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1261
  "ereal r - ereal p = ereal (r - p)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1262
  "-\<infinity> - ereal r = -\<infinity>"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1263
  "ereal r - \<infinity> = -\<infinity>"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1264
  "(\<infinity>::ereal) - x = \<infinity>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1265
  "-(\<infinity>::ereal) - \<infinity> = -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1266
  "x - -y = x + y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1267
  "x - 0 = x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1268
  "0 - x = -x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1269
  by (simp_all add: minus_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1270
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1271
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
  1272
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1273
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1274
lemma ereal_eq_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1275
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1276
  shows "x = z - y \<longleftrightarrow>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1277
    (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x + y = z) \<and>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1278
    (y = -\<infinity> \<longrightarrow> x = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1279
    (y = \<infinity> \<longrightarrow> z = \<infinity> \<longrightarrow> x = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1280
    (y = \<infinity> \<longrightarrow> z \<noteq> \<infinity> \<longrightarrow> x = -\<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1281
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1282
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1283
lemma ereal_eq_minus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1284
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1285
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x = z - y \<longleftrightarrow> x + y = z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1286
  by (auto simp: ereal_eq_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1287
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1288
lemma ereal_less_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1289
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1290
  shows "x < z - y \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1291
    (y = \<infinity> \<longrightarrow> z = \<infinity> \<and> x \<noteq> \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1292
    (y = -\<infinity> \<longrightarrow> x \<noteq> \<infinity>) \<and>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1293
    (\<bar>y\<bar> \<noteq> \<infinity>\<longrightarrow> x + y < z)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1294
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1295
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1296
lemma ereal_less_minus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1297
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1298
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x < z - y \<longleftrightarrow> x + y < z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1299
  by (auto simp: ereal_less_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1300
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1301
lemma ereal_le_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1302
  fixes x y z :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1303
  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
  1304
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1305
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1306
lemma ereal_le_minus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1307
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1308
  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
  1309
  by (auto simp: ereal_le_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1310
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1311
lemma ereal_minus_less_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1312
  fixes x y z :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1313
  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
  1314
  by (cases rule: ereal3_cases[of x y z]) auto
41973
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_minus_less:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1317
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1318
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x - y < z \<longleftrightarrow> x < z + y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1319
  by (auto simp: ereal_minus_less_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1320
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1321
lemma ereal_minus_le_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1322
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1323
  shows "x - y \<le> z \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1324
    (y = -\<infinity> \<longrightarrow> z = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1325
    (y = \<infinity> \<longrightarrow> x = \<infinity> \<longrightarrow> z = \<infinity>) \<and>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1326
    (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x \<le> z + y)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1327
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1328
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1329
lemma ereal_minus_le:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1330
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1331
  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
  1332
  by (auto simp: ereal_minus_le_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1333
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1334
lemma ereal_minus_eq_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1335
  fixes a b c :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1336
  shows "a - b = a - c \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1337
    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
  1338
  by (cases rule: ereal3_cases[of a b c]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1339
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1340
lemma ereal_add_le_add_iff:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1341
  fixes a b c :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1342
  shows "c + a \<le> c + b \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1343
    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
  1344
  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
  1345
59023
4999a616336c register pmf as BNF
Andreas Lochbihler
parents: 59002
diff changeset
  1346
lemma ereal_add_le_add_iff2:
4999a616336c register pmf as BNF
Andreas Lochbihler
parents: 59002
diff changeset
  1347
  fixes a b c :: ereal
4999a616336c register pmf as BNF
Andreas Lochbihler
parents: 59002
diff changeset
  1348
  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
  1349
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
  1350
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1351
lemma ereal_mult_le_mult_iff:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1352
  fixes a b c :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1353
  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
  1354
  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
  1355
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1356
lemma ereal_minus_mono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1357
  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
  1358
  shows "A - C \<le> B - D"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1359
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1360
  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
  1361
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1362
lemma real_of_ereal_minus:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1363
  fixes a b :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1364
  shows "real (a - b) = (if \<bar>a\<bar> = \<infinity> \<or> \<bar>b\<bar> = \<infinity> then 0 else real a - real b)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1365
  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
  1366
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1367
lemma real_of_ereal_minus': "\<bar>x\<bar> = \<infinity> \<longleftrightarrow> \<bar>y\<bar> = \<infinity> \<Longrightarrow> real x - real y = real (x - y :: ereal)"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1368
by(subst real_of_ereal_minus) auto
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1369
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1370
lemma ereal_diff_positive:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1371
  fixes a b :: ereal shows "a \<le> b \<Longrightarrow> 0 \<le> b - a"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1372
  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
  1373
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1374
lemma ereal_between:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1375
  fixes x e :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1376
  assumes "\<bar>x\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1377
    and "0 < e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1378
  shows "x - e < x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1379
    and "x < x + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1380
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1381
  apply (cases x, cases e)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1382
  apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1383
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1384
  apply (cases x, cases e)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1385
  apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1386
  done
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1387
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1388
lemma ereal_minus_eq_PInfty_iff:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1389
  fixes x y :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1390
  shows "x - y = \<infinity> \<longleftrightarrow> y = -\<infinity> \<or> x = \<infinity>"
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1391
  by (cases x y rule: ereal2_cases) simp_all
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1392
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1393
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1394
subsubsection \<open>Division\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1395
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1396
instantiation ereal :: inverse
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1397
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1398
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1399
function inverse_ereal where
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1400
  "inverse (ereal r) = (if r = 0 then \<infinity> else ereal (inverse r))"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1401
| "inverse (\<infinity>::ereal) = 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1402
| "inverse (-\<infinity>::ereal) = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1403
  by (auto intro: ereal_cases)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1404
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1405
60429
d3d1e185cd63 uniform _ div _ as infix syntax for ring division
haftmann
parents: 60352
diff changeset
  1406
definition "x div y = x * inverse (y :: ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1407
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
  1408
instance ..
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1409
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1410
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1411
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1412
lemma real_of_ereal_inverse[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1413
  fixes a :: ereal
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1414
  shows "real (inverse a) = 1 / real a"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1415
  by (cases a) (auto simp: inverse_eq_divide)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1416
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1417
lemma ereal_inverse[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1418
  "inverse (0::ereal) = \<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1419
  "inverse (1::ereal) = 1"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1420
  by (simp_all add: one_ereal_def zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1421
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1422
lemma ereal_divide[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1423
  "ereal r / ereal p = (if p = 0 then ereal r * \<infinity> else ereal (r / p))"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1424
  unfolding divide_ereal_def by (auto simp: divide_real_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1425
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1426
lemma ereal_divide_same[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1427
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1428
  shows "x / x = (if \<bar>x\<bar> = \<infinity> \<or> x = 0 then 0 else 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1429
  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
  1430
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1431
lemma ereal_inv_inv[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1432
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1433
  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
  1434
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1435
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1436
lemma ereal_inverse_minus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1437
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1438
  shows "inverse (- x) = (if x = 0 then \<infinity> else -inverse x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1439
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1440
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1441
lemma ereal_uminus_divide[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1442
  fixes x y :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1443
  shows "- x / y = - (x / y)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1444
  unfolding divide_ereal_def by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1445
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1446
lemma ereal_divide_Infty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1447
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1448
  shows "x / \<infinity> = 0" "x / -\<infinity> = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1449
  unfolding divide_ereal_def by simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1450
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1451
lemma ereal_divide_one[simp]: "x / 1 = (x::ereal)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1452
  unfolding divide_ereal_def by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1453
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1454
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
  1455
  unfolding divide_ereal_def by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1456
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1457
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
  1458
  by (cases x) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1459
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1460
lemma zero_le_divide_ereal[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1461
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1462
  assumes "0 \<le> a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1463
    and "0 \<le> b"
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1464
  shows "0 \<le> a / b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1465
  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
  1466
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1467
lemma ereal_le_divide_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1468
  fixes x y z :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1469
  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
  1470
  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
  1471
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1472
lemma ereal_divide_le_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1473
  fixes x y z :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1474
  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
  1475
  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
  1476
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1477
lemma ereal_le_divide_neg:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1478
  fixes x y z :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1479
  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
  1480
  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
  1481
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1482
lemma ereal_divide_le_neg:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1483
  fixes x y z :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1484
  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
  1485
  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
  1486
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1487
lemma ereal_inverse_antimono_strict:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1488
  fixes x y :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1489
  shows "0 \<le> x \<Longrightarrow> x < y \<Longrightarrow> inverse y < inverse x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1490
  by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1491
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1492
lemma ereal_inverse_antimono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1493
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1494
  shows "0 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> inverse y \<le> inverse x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1495
  by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1496
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1497
lemma inverse_inverse_Pinfty_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1498
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1499
  shows "inverse x = \<infinity> \<longleftrightarrow> x = 0"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1500
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1501
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1502
lemma ereal_inverse_eq_0:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1503
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1504
  shows "inverse x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1505
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1506
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1507
lemma ereal_0_gt_inverse:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1508
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1509
  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
  1510
  by (cases x) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1511
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1512
lemma ereal_inverse_le_0_iff:
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1513
  fixes x :: ereal
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1514
  shows "inverse x \<le> 0 \<longleftrightarrow> x < 0 \<or> x = \<infinity>"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1515
  by(cases x) auto
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1516
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1517
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
  1518
by(cases x y rule: ereal2_cases) simp_all
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  1519
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1520
lemma ereal_mult_less_right:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1521
  fixes a b c :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1522
  assumes "b * a < c * a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1523
    and "0 < a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1524
    and "a < \<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1525
  shows "b < c"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1526
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1527
  by (cases rule: ereal3_cases[of a b c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1528
     (auto split: split_if_asm simp: zero_less_mult_iff zero_le_mult_iff)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1529
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1530
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
  1531
  by (cases a b rule: ereal2_cases) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1532
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1533
lemma ereal_power_divide:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1534
  fixes x y :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1535
  shows "y \<noteq> 0 \<Longrightarrow> (x / y) ^ n = x^n / y^n"
58787
af9eb5e566dd eliminated redundancies;
haftmann
parents: 58310
diff changeset
  1536
  by (cases rule: ereal2_cases [of x y])
af9eb5e566dd eliminated redundancies;
haftmann
parents: 58310
diff changeset
  1537
     (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
  1538
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1539
lemma ereal_le_mult_one_interval:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1540
  fixes x y :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1541
  assumes y: "y \<noteq> -\<infinity>"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1542
  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
  1543
  shows "x \<le> y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1544
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1545
  case PInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1546
  with z[of "1 / 2"] show "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1547
    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
  1548
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1549
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1550
  note r = this
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1551
  show "x \<le> y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1552
  proof (cases y)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1553
    case (real p)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1554
    note p = this
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1555
    have "r \<le> p"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1556
    proof (rule field_le_mult_one_interval)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1557
      fix z :: real
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1558
      assume "0 < z" and "z < 1"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1559
      with z[of "ereal z"] show "z * r \<le> p"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1560
        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
  1561
    qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1562
    then show "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1563
      using p r by simp
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1564
  qed (insert y, simp_all)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1565
qed simp
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1566
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1567
lemma ereal_divide_right_mono[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1568
  fixes x y z :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1569
  assumes "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1570
    and "0 < z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1571
  shows "x / z \<le> y / z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1572
  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
  1573
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1574
lemma ereal_divide_left_mono[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1575
  fixes x y z :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1576
  assumes "y \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1577
    and "0 < z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1578
    and "0 < x * y"
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1579
  shows "z / x \<le> z / y"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1580
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1581
  by (cases x y z rule: ereal3_cases)
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1582
     (auto intro: divide_left_mono simp: field_simps zero_less_mult_iff mult_less_0_iff split: split_if_asm)
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1583
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1584
lemma ereal_divide_zero_left[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1585
  fixes a :: ereal
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1586
  shows "0 / a = 0"
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1587
  by (cases a) (auto simp: zero_ereal_def)
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1588
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1589
lemma ereal_times_divide_eq_left[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1590
  fixes a b c :: ereal
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  1591
  shows "b / c * a = b * a / c"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1592
  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
  1593
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1594
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
  1595
  by (cases a b c rule: ereal3_cases)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1596
     (auto simp: field_simps zero_less_mult_iff)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1597
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1598
subsection "Complete lattice"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1599
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1600
instantiation ereal :: lattice
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1601
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1602
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1603
definition [simp]: "sup x y = (max x y :: ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1604
definition [simp]: "inf x y = (min x y :: ereal)"
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
  1605
instance by standard simp_all
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1606
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1607
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1608
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1609
instantiation ereal :: complete_lattice
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1610
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1611
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1612
definition "bot = (-\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1613
definition "top = (\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1614
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1615
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
  1616
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
  1617
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1618
lemma ereal_complete_Sup:
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1619
  fixes S :: "ereal set"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1620
  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
  1621
proof (cases "\<exists>x. \<forall>a\<in>S. a \<le> ereal x")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1622
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1623
  then obtain y where y: "\<And>a. a\<in>S \<Longrightarrow> a \<le> ereal y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1624
    by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1625
  then have "\<infinity> \<notin> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1626
    by force
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1627
  show ?thesis
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1628
  proof (cases "S \<noteq> {-\<infinity>} \<and> S \<noteq> {}")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1629
    case True
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1630
    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
  1631
      by auto
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1632
    obtain s where s: "\<forall>x\<in>ereal -` S. x \<le> s" "\<And>z. (\<forall>x\<in>ereal -` S. x \<le> z) \<Longrightarrow> s \<le> z"
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1633
    proof (atomize_elim, rule complete_real)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1634
      show "\<exists>x. x \<in> ereal -` S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1635
        using x by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1636
      show "\<exists>z. \<forall>x\<in>ereal -` S. x \<le> z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1637
        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
  1638
    qed
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1639
    show ?thesis
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1640
    proof (safe intro!: exI[of _ "ereal s"])
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1641
      fix y
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1642
      assume "y \<in> S"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1643
      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
  1644
        by (cases y) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1645
    next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1646
      fix z
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1647
      assume "\<forall>y\<in>S. y \<le> z"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1648
      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
  1649
        by (cases z) (auto intro!: s)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1650
    qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1651
  next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1652
    case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1653
    then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1654
      by (auto intro!: exI[of _ "-\<infinity>"])
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1655
  qed
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1656
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1657
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1658
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1659
    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
  1660
qed
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1661
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1662
lemma ereal_complete_uminus_eq:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1663
  fixes S :: "ereal set"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1664
  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
  1665
     \<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
  1666
  by simp (metis ereal_minus_le_minus ereal_uminus_uminus)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1667
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1668
lemma ereal_complete_Inf:
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1669
  "\<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
  1670
  using ereal_complete_Sup[of "uminus ` S"]
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1671
  unfolding ereal_complete_uminus_eq
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1672
  by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1673
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1674
instance
52729
412c9e0381a1 factored syntactic type classes for bot and top (by Alessandro Coglio)
haftmann
parents: 51775
diff changeset
  1675
proof
412c9e0381a1 factored syntactic type classes for bot and top (by Alessandro Coglio)
haftmann
parents: 51775
diff changeset
  1676
  show "Sup {} = (bot::ereal)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1677
    apply (auto simp: bot_ereal_def Sup_ereal_def)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1678
    apply (rule some1_equality)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1679
    apply (metis ereal_bot ereal_less_eq(2))
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1680
    apply (metis ereal_less_eq(2))
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1681
    done
52729
412c9e0381a1 factored syntactic type classes for bot and top (by Alessandro Coglio)
haftmann
parents: 51775
diff changeset
  1682
  show "Inf {} = (top::ereal)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1683
    apply (auto simp: top_ereal_def Inf_ereal_def)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1684
    apply (rule some1_equality)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1685
    apply (metis ereal_top ereal_less_eq(1))
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1686
    apply (metis ereal_less_eq(1))
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1687
    done
52729
412c9e0381a1 factored syntactic type classes for bot and top (by Alessandro Coglio)
haftmann
parents: 51775
diff changeset
  1688
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
  1689
  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
  1690
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1691
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1692
43941
481566bc20e4 ereal is a complete_linorder instance
haftmann
parents: 43933
diff changeset
  1693
instance ereal :: complete_linorder ..
481566bc20e4 ereal is a complete_linorder instance
haftmann
parents: 43933
diff changeset
  1694
51775
408d937c9486 revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
hoelzl
parents: 51774
diff changeset
  1695
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
  1696
proof
408d937c9486 revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
hoelzl
parents: 51774
diff changeset
  1697
  show "\<exists>a b::ereal. a \<noteq> b"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1698
    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
  1699
qed
60720
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1700
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1701
subsubsection "Topological space"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1702
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1703
instantiation ereal :: linear_continuum_topology
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1704
begin
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1705
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1706
definition "open_ereal" :: "ereal set \<Rightarrow> bool" where
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1707
  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
  1708
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1709
instance
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
  1710
  by standard (simp add: open_ereal_generated)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1711
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1712
end
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1713
60720
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1714
lemma continuous_on_compose': 
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1715
  "continuous_on s f \<Longrightarrow> continuous_on t g \<Longrightarrow> f`s \<subseteq> t \<Longrightarrow> continuous_on s (\<lambda>x. g (f x))"
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1716
  using continuous_on_compose[of s f g] continuous_on_subset[of t g "f`s"] by auto
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1717
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1718
lemma continuous_on_ereal[continuous_intros]:
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1719
  assumes f: "continuous_on s f" shows "continuous_on s (\<lambda>x. ereal (f x))"
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1720
  by (rule continuous_on_compose'[OF f continuous_onI_mono[of ereal UNIV]]) auto
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1721
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1722
lemma tendsto_ereal[tendsto_intros, simp, intro]: "(f ---> x) F \<Longrightarrow> ((\<lambda>x. ereal (f x)) ---> ereal x) F"
60720
8c99fa3b7c44 add continuous_onI_mono
hoelzl
parents: 60679
diff changeset
  1723
  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
  1724
  by (simp add: continuous_on_eq_continuous_at)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1725
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1726
lemma tendsto_uminus_ereal[tendsto_intros, simp, intro]: "(f ---> x) F \<Longrightarrow> ((\<lambda>x. - f x::ereal) ---> - x) F"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1727
  apply (rule tendsto_compose[where g=uminus])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1728
  apply (auto intro!: order_tendstoI simp: eventually_at_topological)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1729
  apply (rule_tac x="{..< -a}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1730
  apply (auto split: ereal.split simp: ereal_less_uminus_reorder) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1731
  apply (rule_tac x="{- a <..}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1732
  apply (auto split: ereal.split simp: ereal_uminus_reorder) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1733
  done
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1734
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1735
lemma ereal_Lim_uminus: "(f ---> f0) net \<longleftrightarrow> ((\<lambda>x. - f x::ereal) ---> - f0) net"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1736
  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
  1737
  by auto
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1738
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1739
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
  1740
  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
  1741
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1742
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
  1743
  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
  1744
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1745
lemma tendsto_cmult_ereal[tendsto_intros, simp, intro]:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1746
  assumes c: "\<bar>c\<bar> \<noteq> \<infinity>" and f: "(f ---> x) F" shows "((\<lambda>x. c * f x::ereal) ---> c * x) F"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1747
proof -
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1748
  { fix c :: ereal assume "0 < c" "c < \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1749
    then have "((\<lambda>x. c * f x::ereal) ---> c * x) F"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1750
      apply (intro tendsto_compose[OF _ f])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1751
      apply (auto intro!: order_tendstoI simp: eventually_at_topological)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1752
      apply (rule_tac x="{a/c <..}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1753
      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
  1754
      apply (rule_tac x="{..< a/c}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1755
      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
  1756
      done }
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1757
  note * = this
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1758
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1759
  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
  1760
    using c by (cases c) auto
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1761
  then show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1762
  proof (elim disjE conjE)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1763
    assume "- \<infinity> < c" "c < 0"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1764
    then have "0 < - c" "- c < \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1765
      by (auto simp: ereal_uminus_reorder ereal_less_uminus_reorder[of 0])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1766
    then have "((\<lambda>x. (- c) * f x) ---> (- c) * x) F"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1767
      by (rule *)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1768
    from tendsto_uminus_ereal[OF this] show ?thesis 
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1769
      by simp
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1770
  qed (auto intro!: *)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1771
qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1772
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1773
lemma tendsto_cmult_ereal_not_0[tendsto_intros, simp, intro]:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1774
  assumes "x \<noteq> 0" and f: "(f ---> x) F" shows "((\<lambda>x. c * f x::ereal) ---> c * x) F"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1775
proof cases
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1776
  assume "\<bar>c\<bar> = \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1777
  show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1778
  proof (rule filterlim_cong[THEN iffD1, OF refl refl _ tendsto_const])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1779
    have "0 < x \<or> x < 0"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1780
      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
  1781
    then show "eventually (\<lambda>x'. c * x = c * f x') F"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1782
    proof
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1783
      assume "0 < x" from order_tendstoD(1)[OF f this] show ?thesis
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1784
        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
  1785
    next
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1786
      assume "x < 0" from order_tendstoD(2)[OF f this] show ?thesis
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1787
        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
  1788
    qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1789
  qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1790
qed (rule tendsto_cmult_ereal[OF _ f])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1791
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1792
lemma tendsto_cadd_ereal[tendsto_intros, simp, intro]:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1793
  assumes c: "y \<noteq> - \<infinity>" "x \<noteq> - \<infinity>" and f: "(f ---> x) F" shows "((\<lambda>x. f x + y::ereal) ---> x + y) F"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1794
  apply (intro tendsto_compose[OF _ f])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1795
  apply (auto intro!: order_tendstoI simp: eventually_at_topological)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1796
  apply (rule_tac x="{a - y <..}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1797
  apply (auto split: ereal.split simp: ereal_minus_less_iff c) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1798
  apply (rule_tac x="{..< a - y}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1799
  apply (auto split: ereal.split simp: ereal_less_minus_iff c) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1800
  done
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1801
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1802
lemma tendsto_add_left_ereal[tendsto_intros, simp, intro]:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1803
  assumes c: "\<bar>y\<bar> \<noteq> \<infinity>" and f: "(f ---> x) F" shows "((\<lambda>x. f x + y::ereal) ---> x + y) F"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1804
  apply (intro tendsto_compose[OF _ f])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1805
  apply (auto intro!: order_tendstoI simp: eventually_at_topological)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1806
  apply (rule_tac x="{a - y <..}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1807
  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
  1808
  apply (rule_tac x="{..< a - y}" in exI)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1809
  apply (auto split: ereal.split simp: ereal_less_minus_iff c) []
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1810
  done
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1811
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1812
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
  1813
  unfolding continuous_def by auto
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1814
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1815
lemma ereal_Sup:
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1816
  assumes *: "\<bar>SUP a:A. ereal a\<bar> \<noteq> \<infinity>"
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1817
  shows "ereal (Sup A) = (SUP a:A. ereal a)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1818
proof (rule continuous_at_Sup_mono)
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1819
  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
  1820
    using * by (force simp: bot_ereal_def)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1821
  then show "bdd_above A" "A \<noteq> {}"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1822
    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
  1823
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
  1824
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1825
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
  1826
  using ereal_Sup[of "f`A"] by auto
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1827
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1828
lemma ereal_Inf:
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1829
  assumes *: "\<bar>INF a:A. ereal a\<bar> \<noteq> \<infinity>"
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1830
  shows "ereal (Inf A) = (INF a:A. ereal a)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1831
proof (rule continuous_at_Inf_mono)
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1832
  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
  1833
    using * by (force simp: top_ereal_def)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1834
  then show "bdd_below A" "A \<noteq> {}"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1835
    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
  1836
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
  1837
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1838
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
  1839
  using ereal_Inf[of "f`A"] by auto
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1840
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1841
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
  1842
  by (auto intro!: SUP_eqI
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1843
           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
  1844
           intro!: complete_lattice_class.Inf_lower2)
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1845
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1846
lemma ereal_SUP_uminus_eq:
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1847
  fixes f :: "'a \<Rightarrow> ereal"
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1848
  shows "(SUP x:S. uminus (f x)) = - (INF x:S. f x)"
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1849
  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
  1850
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1851
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
  1852
  by (auto intro!: inj_onI)
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1853
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  1854
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
  1855
  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
  1856
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1857
lemma ereal_INF_uminus_eq:
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1858
  fixes f :: "'a \<Rightarrow> ereal"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1859
  shows "(INF x:S. - f x) = - (SUP x:S. f x)"
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55913
diff changeset
  1860
  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
  1861
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1862
lemma ereal_SUP_uminus:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1863
  fixes f :: "'a \<Rightarrow> ereal"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1864
  shows "(SUP i : R. - f i) = - (INF i : R. f i)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1865
  using ereal_Sup_uminus_image_eq[of "f`R"]
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1866
  by (simp add: image_image)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1867
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1868
lemma ereal_SUP_not_infty:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1869
  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
  1870
  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
  1871
  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
  1872
  by (cases "SUPREMUM A f") auto
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1873
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1874
lemma ereal_INF_not_infty:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1875
  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
  1876
  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
  1877
  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
  1878
  by (cases "INFIMUM A f") auto
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
  1879
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1880
lemma ereal_image_uminus_shift:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1881
  fixes X Y :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1882
  shows "uminus ` X = Y \<longleftrightarrow> X = uminus ` Y"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1883
proof
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1884
  assume "uminus ` X = Y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1885
  then have "uminus ` uminus ` X = uminus ` Y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1886
    by (simp add: inj_image_eq_iff)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1887
  then show "X = uminus ` Y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1888
    by (simp add: image_image)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1889
qed (simp add: image_image)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1890
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1891
lemma Sup_eq_MInfty:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1892
  fixes S :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1893
  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
  1894
  unfolding bot_ereal_def[symmetric] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1895
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1896
lemma Inf_eq_PInfty:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1897
  fixes S :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1898
  shows "Inf S = \<infinity> \<longleftrightarrow> S = {} \<or> S = {\<infinity>}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1899
  using Sup_eq_MInfty[of "uminus`S"]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1900
  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
  1901
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1902
lemma Inf_eq_MInfty:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1903
  fixes S :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1904
  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
  1905
  unfolding bot_ereal_def[symmetric] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1906
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1907
lemma Sup_eq_PInfty:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1908
  fixes S :: "ereal set"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1909
  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
  1910
  unfolding top_ereal_def[symmetric] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1911
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1912
lemma Sup_ereal_close:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1913
  fixes e :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1914
  assumes "0 < e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1915
    and S: "\<bar>Sup S\<bar> \<noteq> \<infinity>" "S \<noteq> {}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1916
  shows "\<exists>x\<in>S. Sup S - e < x"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1917
  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
  1918
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1919
lemma Inf_ereal_close:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1920
  fixes e :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1921
  assumes "\<bar>Inf X\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1922
    and "0 < e"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1923
  shows "\<exists>x\<in>X. x < Inf X + e"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1924
proof (rule Inf_less_iff[THEN iffD1])
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1925
  show "Inf X < Inf X + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1926
    using assms by (cases e) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1927
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1928
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1929
lemma SUP_PInfty:
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1930
  "(\<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
  1931
  unfolding top_ereal_def[symmetric] SUP_eq_top_iff
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1932
  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
  1933
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1934
lemma SUP_nat_Infty: "(SUP i::nat. ereal (real i)) = \<infinity>"
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59115
diff changeset
  1935
  by (rule SUP_PInfty) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1936
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1937
lemma SUP_ereal_add_left:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1938
  assumes "I \<noteq> {}" "c \<noteq> -\<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1939
  shows "(SUP i:I. f i + c :: ereal) = (SUP i:I. f i) + c"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1940
proof cases
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1941
  assume "(SUP i:I. f i) = - \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1942
  moreover then have "\<And>i. i \<in> I \<Longrightarrow> f i = -\<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1943
    unfolding Sup_eq_MInfty Sup_image_eq[symmetric] by auto
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1944
  ultimately show ?thesis
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1945
    by (cases c) (auto simp: \<open>I \<noteq> {}\<close>)
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1946
next
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1947
  assume "(SUP i:I. f i) \<noteq> - \<infinity>" then show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1948
    unfolding Sup_image_eq[symmetric]
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1949
    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
  1950
       (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
  1951
qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1952
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1953
lemma SUP_ereal_add_right:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1954
  fixes c :: ereal
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1955
  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
  1956
  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
  1957
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1958
lemma SUP_ereal_minus_right:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1959
  assumes "I \<noteq> {}" "c \<noteq> -\<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1960
  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
  1961
  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
  1962
  by (simp add: ereal_SUP_uminus minus_ereal_def)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1963
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1964
lemma SUP_ereal_minus_left:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1965
  assumes "I \<noteq> {}" "c \<noteq> \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1966
  shows "(SUP i:I. f i - c:: ereal) = (SUP i:I. f i) - c"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1967
  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
  1968
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1969
lemma INF_ereal_minus_right:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1970
  assumes "I \<noteq> {}" and "\<bar>c\<bar> \<noteq> \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1971
  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
  1972
proof -
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1973
  { fix b have "(-c) + b = - (c - b)"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1974
      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
  1975
  note * = this
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1976
  show ?thesis
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1977
    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
  1978
    by (auto simp add: * ereal_SUP_uminus_eq)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1979
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1980
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1981
lemma SUP_ereal_le_addI:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1982
  fixes f :: "'i \<Rightarrow> ereal"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1983
  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
  1984
  shows "SUPREMUM UNIV f + y \<le> z"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1985
  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
  1986
  by (rule SUP_least assms)+
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1987
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1988
lemma SUP_combine:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1989
  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
  1990
  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
  1991
  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
  1992
proof (rule antisym)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1993
  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
  1994
    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
  1995
  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
  1996
    by (rule SUP_least SUP_upper2 UNIV_I mono order_refl)+
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  1997
qed
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1998
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  1999
lemma SUP_ereal_add:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2000
  fixes f g :: "nat \<Rightarrow> ereal"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2001
  assumes inc: "incseq f" "incseq g"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2002
    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
  2003
  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
  2004
  apply (subst SUP_ereal_add_left[symmetric, OF UNIV_not_empty])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2005
  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
  2006
  apply (subst (2) add.commute)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2007
  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
  2008
  apply (subst (2) add.commute)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2009
  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
  2010
  done
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2011
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2012
lemma INF_ereal_add:
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2013
  fixes f :: "nat \<Rightarrow> ereal"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2014
  assumes "decseq f" "decseq g"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2015
    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
  2016
  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
  2017
proof -
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2018
  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
  2019
    using assms unfolding INF_less_iff by auto
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2020
  { fix a b :: ereal assume "a \<noteq> \<infinity>" "b \<noteq> \<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2021
    then have "- ((- a) + (- b)) = a + b"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2022
      by (cases a b rule: ereal2_cases) auto }
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2023
  note * = this
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2024
  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
  2025
    by (simp add: fin *)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2026
  also have "\<dots> = INFIMUM UNIV f + INFIMUM UNIV g"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2027
    unfolding ereal_INF_uminus_eq
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2028
    using assms INF_less
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2029
    by (subst SUP_ereal_add) (auto simp: ereal_SUP_uminus fin *)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2030
  finally show ?thesis .
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2031
qed
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  2032
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2033
lemma SUP_ereal_add_pos:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2034
  fixes f g :: "nat \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2035
  assumes inc: "incseq f" "incseq g"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2036
    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
  2037
  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
  2038
proof (intro SUP_ereal_add inc)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2039
  fix i
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2040
  show "f i \<noteq> -\<infinity>" "g i \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2041
    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
  2042
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2043
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2044
lemma SUP_ereal_setsum:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2045
  fixes f g :: "'a \<Rightarrow> nat \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2046
  assumes "\<And>n. n \<in> A \<Longrightarrow> incseq (f n)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2047
    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
  2048
  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
  2049
proof (cases "finite A")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2050
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2051
  then show ?thesis using assms
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2052
    by induct (auto simp: incseq_setsumI2 setsum_nonneg SUP_ereal_add_pos)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2053
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2054
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2055
  then show ?thesis by simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2056
qed
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2057
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2058
lemma SUP_ereal_mult_left:
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2059
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2060
  assumes "I \<noteq> {}"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2061
  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
  2062
  shows "(SUP i:I. c * f i) = c * (SUP i:I. f i)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2063
proof cases
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2064
  assume "(SUP i: I. f i) = 0"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2065
  moreover then have "\<And>i. i \<in> I \<Longrightarrow> f i = 0"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2066
    by (metis SUP_upper f antisym)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2067
  ultimately show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2068
    by simp
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2069
next
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2070
  assume "(SUP i:I. f i) \<noteq> 0" then show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2071
    unfolding SUP_def
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2072
    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
  2073
       (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
  2074
             intro!: ereal_mult_left_mono c)
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2075
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2076
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2077
lemma countable_approach: 
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2078
  fixes x :: ereal
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2079
  assumes "x \<noteq> -\<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2080
  shows "\<exists>f. incseq f \<and> (\<forall>i::nat. f i < x) \<and> (f ----> x)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2081
proof (cases x)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2082
  case (real r)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2083
  moreover have "(\<lambda>n. r - inverse (real (Suc n))) ----> r - 0"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2084
    by (intro tendsto_intros LIMSEQ_inverse_real_of_nat)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2085
  ultimately show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2086
    by (intro exI[of _ "\<lambda>n. x - inverse (Suc n)"]) (auto simp: incseq_def)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2087
next 
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2088
  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
  2089
    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
  2090
qed (simp add: assms)
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  2091
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2092
lemma Sup_countable_SUP:
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2093
  assumes "A \<noteq> {}"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2094
  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
  2095
proof cases
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2096
  assume "Sup A = -\<infinity>"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2097
  with \<open>A \<noteq> {}\<close> have "A = {-\<infinity>}"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2098
    by (auto simp: Sup_eq_MInfty)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2099
  then show ?thesis
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2100
    by (auto intro!: exI[of _ "\<lambda>_. -\<infinity>"] simp: bot_ereal_def)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2101
next
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2102
  assume "Sup A \<noteq> -\<infinity>"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2103
  then obtain l where "incseq l" and l: "\<And>i::nat. l i < Sup A" and l_Sup: "l ----> Sup A"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2104
    by (auto dest: countable_approach)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2105
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2106
  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
  2107
  proof (rule dependent_nat_choice)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2108
    show "\<exists>x. x \<in> A \<and> l 0 \<le> x"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2109
      using l[of 0] by (auto simp: less_Sup_iff)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2110
  next
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2111
    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
  2112
    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
  2113
      by (auto simp: less_Sup_iff)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2114
    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
  2115
      by (auto intro!: exI[of _ "max x y"] split: split_max)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2116
  qed
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2117
  then guess f .. note f = this
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2118
  then have "range f \<subseteq> A" "incseq f"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2119
    by (auto simp: incseq_Suc_iff)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2120
  moreover
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2121
  have "(SUP i. f i) = Sup A"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2122
  proof (rule tendsto_unique)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2123
    show "f ----> (SUP i. f i)"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2124
      by (rule LIMSEQ_SUP \<open>incseq f\<close>)+
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2125
    show "f ----> Sup A"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2126
      using l f
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2127
      by (intro tendsto_sandwich[OF _ _ l_Sup tendsto_const])
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2128
         (auto simp: Sup_upper)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2129
  qed simp
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2130
  ultimately show ?thesis
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2131
    by auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2132
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  2133
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
  2134
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
  2135
  "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
  2136
  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
  2137
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2138
subsection "Relation to @{typ enat}"
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2139
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2140
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
  2141
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2142
declare [[coercion "ereal_of_enat :: enat \<Rightarrow> ereal"]]
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2143
declare [[coercion "(\<lambda>n. ereal (real n)) :: nat \<Rightarrow> ereal"]]
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2144
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2145
lemma ereal_of_enat_simps[simp]:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2146
  "ereal_of_enat (enat n) = ereal n"
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2147
  "ereal_of_enat \<infinity> = \<infinity>"
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2148
  by (simp_all add: ereal_of_enat_def)
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2149
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2150
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
  2151
  by (cases m n rule: enat2_cases) auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2152
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2153
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
  2154
  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
  2155
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2156
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
  2157
by (cases n) (auto)
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2158
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2159
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
  2160
  by (cases n) auto
50819
5601ae592679 added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents: 50104
diff changeset
  2161
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2162
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
  2163
  by (cases n) (auto simp: enat_0[symmetric])
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2164
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2165
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
  2166
  by (cases n) (auto simp: enat_0[symmetric])
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2167
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2168
lemma ereal_of_enat_zero[simp]: "ereal_of_enat 0 = 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2169
  by (auto simp: enat_0[symmetric])
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2170
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2171
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
  2172
  by (cases n) auto
5601ae592679 added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents: 50104
diff changeset
  2173
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2174
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
  2175
  by (cases m n rule: enat2_cases) auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2176
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2177
lemma ereal_of_enat_sub:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2178
  assumes "n \<le> m"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2179
  shows "ereal_of_enat (m - n) = ereal_of_enat m - ereal_of_enat n "
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2180
  using assms by (cases m n rule: enat2_cases) auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2181
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2182
lemma ereal_of_enat_mult:
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2183
  "ereal_of_enat (m * n) = ereal_of_enat m * ereal_of_enat n"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2184
  by (cases m n rule: enat2_cases) auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2185
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2186
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
  2187
lemmas ereal_of_enat_pushout = ereal_of_enat_pushin[symmetric]
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2188
60637
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2189
lemma ereal_of_enat_Sup:
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2190
  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
  2191
proof (intro antisym mono_Sup)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2192
  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
  2193
  proof cases
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2194
    assume "finite A"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2195
    with `A \<noteq> {}` obtain a where "a \<in> A" "ereal_of_enat (Sup A) = ereal_of_enat a"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2196
      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
  2197
    then show ?thesis
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2198
      by (auto intro: SUP_upper)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2199
  next
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2200
    assume "\<not> finite A"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2201
    have [simp]: "(SUP a : A. ereal_of_enat a) = top"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2202
      unfolding SUP_eq_top_iff
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2203
    proof safe
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2204
      fix x :: ereal assume "x < top"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2205
      then obtain n :: nat where "x < n"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2206
        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
  2207
      obtain a where "a \<in> A - enat ` {.. n}"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2208
        by (metis `\<not> finite A` all_not_in_conv finite_Diff2 finite_atMost finite_imageI finite.emptyI)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2209
      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
  2210
        by (auto simp: image_iff Ball_def)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2211
           (metis enat_iless enat_ord_simps(1) ereal_of_enat_less_iff ereal_of_enat_simps(1) less_le not_less)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2212
      with `x < n` show "\<exists>i\<in>A. x < ereal_of_enat i"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2213
        by (auto intro!: bexI[of _ a])
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2214
    qed
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2215
    show ?thesis
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2216
      by simp
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2217
  qed
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2218
qed (simp add: mono_def)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2219
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2220
lemma ereal_of_enat_SUP:
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2221
  "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
  2222
  using ereal_of_enat_Sup[of "f`A"] by auto
45934
9321cd2572fe add simp rules for enat and ereal
noschinl
parents: 45769
diff changeset
  2223
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2224
subsection "Limits on @{typ ereal}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2225
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2226
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
  2227
  unfolding open_ereal_generated
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2228
proof (induct rule: generate_topology.induct)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2229
  case (Int A B)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2230
  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
  2231
    by auto
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2232
  with Int show ?case
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2233
    by (intro exI[of _ "max x z"]) fastforce
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2234
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2235
  case (Basis S)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2236
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2237
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2238
    have "x \<noteq> \<infinity> \<Longrightarrow> \<exists>t. x \<le> ereal t"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2239
      by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2240
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2241
  moreover note Basis
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2242
  ultimately show ?case
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2243
    by (auto split: ereal.split)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2244
qed (fastforce simp add: vimage_Union)+
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2245
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2246
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
  2247
  unfolding open_ereal_generated
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2248
proof (induct rule: generate_topology.induct)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2249
  case (Int A B)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2250
  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
  2251
    by auto
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
  2252
  with Int show ?case
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2253
    by (intro exI[of _ "min x z"]) fastforce
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2254
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2255
  case (Basis S)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2256
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2257
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2258
    have "x \<noteq> - \<infinity> \<Longrightarrow> \<exists>t. ereal t \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2259
      by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2260
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2261
  moreover note Basis
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2262
  ultimately show ?case
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2263
    by (auto split: ereal.split)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2264
qed (fastforce simp add: vimage_Union)+
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2265
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2266
lemma open_ereal_vimage: "open S \<Longrightarrow> open (ereal -` S)"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2267
  by (intro open_vimage continuous_intros)
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2268
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2269
lemma open_ereal: "open S \<Longrightarrow> open (ereal ` S)"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2270
  unfolding open_generated_order[where 'a=real]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2271
proof (induct rule: generate_topology.induct)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2272
  case (Basis S)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2273
  moreover {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2274
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2275
    have "ereal ` {..< x} = { -\<infinity> <..< ereal x }"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2276
      apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2277
      apply (case_tac xa)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2278
      apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2279
      done
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2280
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2281
  moreover {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2282
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2283
    have "ereal ` {x <..} = { ereal x <..< \<infinity> }"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2284
      apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2285
      apply (case_tac xa)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2286
      apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2287
      done
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2288
  }
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2289
  ultimately show ?case
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2290
     by auto
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2291
qed (auto simp add: image_Union image_Int)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2292
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2293
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2294
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
  2295
  fixes x :: ereal
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2296
  assumes "\<bar>x\<bar> \<noteq> \<infinity>" "(f ---> x) F"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2297
  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
  2298
proof -
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2299
  have "(f ---> ereal (real x)) F"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2300
    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
  2301
  then have "eventually (\<lambda>x. f x \<in> ereal ` UNIV) F"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2302
    by (rule topological_tendstoD) (auto intro: open_ereal)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2303
  also have "(\<lambda>x. f x \<in> ereal ` UNIV) = (\<lambda>x. \<bar>f x\<bar> \<noteq> \<infinity>)"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2304
    by auto
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2305
  finally show ?thesis .
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2306
qed
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2307
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2308
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2309
lemma open_ereal_def:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2310
  "open A \<longleftrightarrow> open (ereal -` A) \<and> (\<infinity> \<in> A \<longrightarrow> (\<exists>x. {ereal x <..} \<subseteq> A)) \<and> (-\<infinity> \<in> A \<longrightarrow> (\<exists>x. {..<ereal x} \<subseteq> A))"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2311
  (is "open A \<longleftrightarrow> ?rhs")
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2312
proof
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2313
  assume "open A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2314
  then show ?rhs
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2315
    using open_PInfty open_MInfty open_ereal_vimage by auto
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2316
next
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2317
  assume "?rhs"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2318
  then obtain x y where A: "open (ereal -` A)" "\<infinity> \<in> A \<Longrightarrow> {ereal x<..} \<subseteq> A" "-\<infinity> \<in> A \<Longrightarrow> {..< ereal y} \<subseteq> A"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2319
    by auto
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2320
  have *: "A = ereal ` (ereal -` A) \<union> (if \<infinity> \<in> A then {ereal x<..} else {}) \<union> (if -\<infinity> \<in> A then {..< ereal y} else {})"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2321
    using A(2,3) by auto
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2322
  from open_ereal[OF A(1)] show "open A"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2323
    by (subst *) (auto simp: open_Un)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2324
qed
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2325
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2326
lemma open_PInfty2:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2327
  assumes "open A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2328
    and "\<infinity> \<in> A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2329
  obtains x where "{ereal x<..} \<subseteq> A"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2330
  using open_PInfty[OF assms] by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2331
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2332
lemma open_MInfty2:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2333
  assumes "open A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2334
    and "-\<infinity> \<in> A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2335
  obtains x where "{..<ereal x} \<subseteq> A"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2336
  using open_MInfty[OF assms] by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2337
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2338
lemma ereal_openE:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2339
  assumes "open A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2340
  obtains x y where "open (ereal -` A)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2341
    and "\<infinity> \<in> A \<Longrightarrow> {ereal x<..} \<subseteq> A"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2342
    and "-\<infinity> \<in> A \<Longrightarrow> {..<ereal y} \<subseteq> A"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2343
  using assms open_ereal_def by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2344
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2345
lemmas open_ereal_lessThan = open_lessThan[where 'a=ereal]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2346
lemmas open_ereal_greaterThan = open_greaterThan[where 'a=ereal]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2347
lemmas ereal_open_greaterThanLessThan = open_greaterThanLessThan[where 'a=ereal]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2348
lemmas closed_ereal_atLeast = closed_atLeast[where 'a=ereal]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2349
lemmas closed_ereal_atMost = closed_atMost[where 'a=ereal]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2350
lemmas closed_ereal_atLeastAtMost = closed_atLeastAtMost[where 'a=ereal]
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2351
lemmas closed_ereal_singleton = closed_singleton[where 'a=ereal]
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2352
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2353
lemma ereal_open_cont_interval:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2354
  fixes S :: "ereal set"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2355
  assumes "open S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2356
    and "x \<in> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2357
    and "\<bar>x\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2358
  obtains e where "e > 0" and "{x-e <..< x+e} \<subseteq> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2359
proof -
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2360
  from \<open>open S\<close>
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2361
  have "open (ereal -` S)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2362
    by (rule ereal_openE)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2363
  then obtain e where "e > 0" and e: "\<And>y. dist y (real x) < e \<Longrightarrow> ereal y \<in> S"
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
  2364
    using assms unfolding open_dist by force
41975
d47eabd80e59 simplified definition of open_extreal
hoelzl
parents: 41974
diff changeset
  2365
  show thesis
d47eabd80e59 simplified definition of open_extreal
hoelzl
parents: 41974
diff changeset
  2366
  proof (intro that subsetI)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2367
    show "0 < ereal e"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2368
      using \<open>0 < e\<close> by auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2369
    fix y
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2370
    assume "y \<in> {x - ereal e<..<x + ereal e}"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2371
    with assms obtain t where "y = ereal t" "dist t (real x) < e"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2372
      by (cases y) (auto simp: dist_real_def)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2373
    then show "y \<in> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2374
      using e[of t] by auto
41975
d47eabd80e59 simplified definition of open_extreal
hoelzl
parents: 41974
diff changeset
  2375
  qed
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2376
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2377
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2378
lemma ereal_open_cont_interval2:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2379
  fixes S :: "ereal set"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2380
  assumes "open S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2381
    and "x \<in> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2382
    and x: "\<bar>x\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2383
  obtains a b where "a < x" and "x < b" and "{a <..< b} \<subseteq> S"
53381
355a4cac5440 tuned proofs -- less guessing;
wenzelm
parents: 53374
diff changeset
  2384
proof -
355a4cac5440 tuned proofs -- less guessing;
wenzelm
parents: 53374
diff changeset
  2385
  obtain e where "0 < e" "{x - e<..<x + e} \<subseteq> S"
355a4cac5440 tuned proofs -- less guessing;
wenzelm
parents: 53374
diff changeset
  2386
    using assms by (rule ereal_open_cont_interval)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2387
  with that[of "x - e" "x + e"] ereal_between[OF x, of e]
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2388
  show thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2389
    by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2390
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2391
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2392
subsubsection \<open>Convergent sequences\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2393
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2394
lemma lim_real_of_ereal[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2395
  assumes lim: "(f ---> ereal x) net"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2396
  shows "((\<lambda>x. real (f x)) ---> x) net"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2397
proof (intro topological_tendstoI)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2398
  fix S
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2399
  assume "open S" and "x \<in> S"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2400
  then have S: "open S" "ereal x \<in> ereal ` S"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2401
    by (simp_all add: inj_image_mem_iff)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2402
  have "\<forall>x. f x \<in> ereal ` S \<longrightarrow> real (f x) \<in> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2403
    by auto
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2404
  from this lim[THEN topological_tendstoD, OF open_ereal, OF S]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2405
  show "eventually (\<lambda>x. real (f x) \<in> S) net"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2406
    by (rule eventually_mono)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2407
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2408
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2409
lemma lim_ereal[simp]: "((\<lambda>n. ereal (f n)) ---> ereal x) net \<longleftrightarrow> (f ---> x) net"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2410
  by (auto dest!: lim_real_of_ereal)
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2411
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2412
lemma tendsto_PInfty: "(f ---> \<infinity>) F \<longleftrightarrow> (\<forall>r. eventually (\<lambda>x. ereal r < f x) F)"
51022
78de6c7e8a58 replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
hoelzl
parents: 51000
diff changeset
  2413
proof -
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2414
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2415
    fix l :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2416
    assume "\<forall>r. eventually (\<lambda>x. ereal r < f x) F"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2417
    from this[THEN spec, of "real l"] have "l \<noteq> \<infinity> \<Longrightarrow> eventually (\<lambda>x. l < f x) F"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2418
      by (cases l) (auto elim: eventually_elim1)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2419
  }
51022
78de6c7e8a58 replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
hoelzl
parents: 51000
diff changeset
  2420
  then show ?thesis
78de6c7e8a58 replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
hoelzl
parents: 51000
diff changeset
  2421
    by (auto simp: order_tendsto_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2422
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2423
57025
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
  2424
lemma tendsto_PInfty_eq_at_top:
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
  2425
  "((\<lambda>z. ereal (f z)) ---> \<infinity>) F \<longleftrightarrow> (LIM z F. f z :> at_top)"
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
  2426
  unfolding tendsto_PInfty filterlim_at_top_dense by simp
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
  2427
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2428
lemma tendsto_MInfty: "(f ---> -\<infinity>) F \<longleftrightarrow> (\<forall>r. eventually (\<lambda>x. f x < ereal r) F)"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2429
  unfolding tendsto_def
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2430
proof safe
53381
355a4cac5440 tuned proofs -- less guessing;
wenzelm
parents: 53374
diff changeset
  2431
  fix S :: "ereal set"
355a4cac5440 tuned proofs -- less guessing;
wenzelm
parents: 53374
diff changeset
  2432
  assume "open S" "-\<infinity> \<in> S"
355a4cac5440 tuned proofs -- less guessing;
wenzelm
parents: 53374
diff changeset
  2433
  from open_MInfty[OF this] obtain B where "{..<ereal B} \<subseteq> S" ..
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2434
  moreover
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2435
  assume "\<forall>r::real. eventually (\<lambda>z. f z < r) F"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2436
  then have "eventually (\<lambda>z. f z \<in> {..< B}) F"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2437
    by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2438
  ultimately show "eventually (\<lambda>z. f z \<in> S) F"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2439
    by (auto elim!: eventually_elim1)
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2440
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2441
  fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2442
  assume "\<forall>S. open S \<longrightarrow> -\<infinity> \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) F"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2443
  from this[rule_format, of "{..< ereal x}"] show "eventually (\<lambda>y. f y < ereal x) F"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2444
    by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2445
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2446
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2447
lemma Lim_PInfty: "f ----> \<infinity> \<longleftrightarrow> (\<forall>B. \<exists>N. \<forall>n\<ge>N. f n \<ge> ereal B)"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2448
  unfolding tendsto_PInfty eventually_sequentially
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2449
proof safe
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2450
  fix r
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2451
  assume "\<forall>r. \<exists>N. \<forall>n\<ge>N. ereal r \<le> f n"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2452
  then obtain N where "\<forall>n\<ge>N. ereal (r + 1) \<le> f n"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2453
    by blast
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2454
  moreover have "ereal r < ereal (r + 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2455
    by auto
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2456
  ultimately show "\<exists>N. \<forall>n\<ge>N. ereal r < f n"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2457
    by (blast intro: less_le_trans)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2458
qed (blast intro: less_imp_le)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2459
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2460
lemma Lim_MInfty: "f ----> -\<infinity> \<longleftrightarrow> (\<forall>B. \<exists>N. \<forall>n\<ge>N. ereal B \<ge> f n)"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2461
  unfolding tendsto_MInfty eventually_sequentially
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2462
proof safe
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2463
  fix r
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2464
  assume "\<forall>r. \<exists>N. \<forall>n\<ge>N. f n \<le> ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2465
  then obtain N where "\<forall>n\<ge>N. f n \<le> ereal (r - 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2466
    by blast
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2467
  moreover have "ereal (r - 1) < ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2468
    by auto
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2469
  ultimately show "\<exists>N. \<forall>n\<ge>N. f n < ereal r"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2470
    by (blast intro: le_less_trans)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2471
qed (blast intro: less_imp_le)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2472
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2473
lemma Lim_bounded_PInfty: "f ----> l \<Longrightarrow> (\<And>n. f n \<le> ereal B) \<Longrightarrow> l \<noteq> \<infinity>"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2474
  using LIMSEQ_le_const2[of f l "ereal B"] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2475
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2476
lemma Lim_bounded_MInfty: "f ----> l \<Longrightarrow> (\<And>n. ereal B \<le> f n) \<Longrightarrow> l \<noteq> -\<infinity>"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2477
  using LIMSEQ_le_const[of f l "ereal B"] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2478
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2479
lemma tendsto_explicit:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2480
  "f ----> f0 \<longleftrightarrow> (\<forall>S. open S \<longrightarrow> f0 \<in> S \<longrightarrow> (\<exists>N. \<forall>n\<ge>N. f n \<in> S))"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2481
  unfolding tendsto_def eventually_sequentially by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2482
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2483
lemma Lim_bounded_PInfty2: "f ----> l \<Longrightarrow> \<forall>n\<ge>N. f n \<le> ereal B \<Longrightarrow> l \<noteq> \<infinity>"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2484
  using LIMSEQ_le_const2[of f l "ereal B"] by fastforce
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2485
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2486
lemma Lim_bounded_ereal: "f ----> (l :: 'a::linorder_topology) \<Longrightarrow> \<forall>n\<ge>M. f n \<le> C \<Longrightarrow> l \<le> C"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2487
  by (intro LIMSEQ_le_const2) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2488
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
  2489
lemma Lim_bounded2_ereal:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2490
  assumes lim:"f ----> (l :: 'a::linorder_topology)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2491
    and ge: "\<forall>n\<ge>N. f n \<ge> C"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2492
  shows "l \<ge> C"
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
  2493
  using ge
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
  2494
  by (intro tendsto_le[OF trivial_limit_sequentially lim tendsto_const])
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
  2495
     (auto simp: eventually_sequentially)
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
  2496
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2497
lemma real_of_ereal_mult[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2498
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2499
  shows "real (a * b) = real a * real b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2500
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2501
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2502
lemma real_of_ereal_eq_0:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2503
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2504
  shows "real x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity> \<or> x = 0"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2505
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2506
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2507
lemma tendsto_ereal_realD:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2508
  fixes f :: "'a \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2509
  assumes "x \<noteq> 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2510
    and tendsto: "((\<lambda>x. ereal (real (f x))) ---> x) net"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2511
  shows "(f ---> x) net"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2512
proof (intro topological_tendstoI)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2513
  fix S
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2514
  assume S: "open S" "x \<in> S"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2515
  with \<open>x \<noteq> 0\<close> have "open (S - {0})" "x \<in> S - {0}"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2516
    by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2517
  from tendsto[THEN topological_tendstoD, OF this]
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2518
  show "eventually (\<lambda>x. f x \<in> S) net"
44142
8e27e0177518 avoid warnings about duplicate rules
huffman
parents: 43943
diff changeset
  2519
    by (rule eventually_rev_mp) (auto simp: ereal_real)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2520
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2521
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2522
lemma tendsto_ereal_realI:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2523
  fixes f :: "'a \<Rightarrow> ereal"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  2524
  assumes x: "\<bar>x\<bar> \<noteq> \<infinity>" and tendsto: "(f ---> x) net"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2525
  shows "((\<lambda>x. ereal (real (f x))) ---> x) net"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2526
proof (intro topological_tendstoI)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2527
  fix S
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2528
  assume "open S" and "x \<in> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2529
  with x have "open (S - {\<infinity>, -\<infinity>})" "x \<in> S - {\<infinity>, -\<infinity>}"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2530
    by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2531
  from tendsto[THEN topological_tendstoD, OF this]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2532
  show "eventually (\<lambda>x. ereal (real (f x)) \<in> S) net"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2533
    by (elim eventually_elim1) (auto simp: ereal_real)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2534
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2535
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2536
lemma ereal_mult_cancel_left:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2537
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2538
  shows "a * b = a * c \<longleftrightarrow> (\<bar>a\<bar> = \<infinity> \<and> 0 < b * c) \<or> a = 0 \<or> b = c"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2539
  by (cases rule: ereal3_cases[of a b c]) (simp_all add: zero_less_mult_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2540
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2541
lemma tendsto_add_ereal:
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2542
  fixes x y :: ereal
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2543
  assumes x: "\<bar>x\<bar> \<noteq> \<infinity>" and y: "\<bar>y\<bar> \<noteq> \<infinity>"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2544
  assumes f: "(f ---> x) F" and g: "(g ---> y) F"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2545
  shows "((\<lambda>x. f x + g x) ---> x + y) F"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2546
proof -
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2547
  from x obtain r where x': "x = ereal r" 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
  2548
  with f have "((\<lambda>i. real (f i)) ---> r) F" by simp
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2549
  moreover
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2550
  from y obtain p where y': "y = ereal p" by (cases y) auto
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2551
  with g have "((\<lambda>i. real (g i)) ---> p) F" by simp
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2552
  ultimately have "((\<lambda>i. real (f i) + real (g i)) ---> r + p) F"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2553
    by (rule tendsto_add)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2554
  moreover
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2555
  from eventually_finite[OF x f] eventually_finite[OF y g]
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2556
  have "eventually (\<lambda>x. f x + g x = ereal (real (f x) + real (g x))) F"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2557
    by eventually_elim auto
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2558
  ultimately show ?thesis
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2559
    by (simp add: x' y' cong: filterlim_cong)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2560
qed
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56927
diff changeset
  2561
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2562
lemma ereal_inj_affinity:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2563
  fixes m t :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2564
  assumes "\<bar>m\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2565
    and "m \<noteq> 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2566
    and "\<bar>t\<bar> \<noteq> \<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2567
  shows "inj_on (\<lambda>x. m * x + t) A"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2568
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2569
  by (cases rule: ereal2_cases[of m t])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2570
     (auto intro!: inj_onI simp: ereal_add_cancel_right ereal_mult_cancel_left)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2571
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2572
lemma ereal_PInfty_eq_plus[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2573
  fixes a b :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2574
  shows "\<infinity> = a + b \<longleftrightarrow> a = \<infinity> \<or> b = \<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2575
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2576
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2577
lemma ereal_MInfty_eq_plus[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2578
  fixes a b :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2579
  shows "-\<infinity> = a + b \<longleftrightarrow> (a = -\<infinity> \<and> b \<noteq> \<infinity>) \<or> (b = -\<infinity> \<and> a \<noteq> \<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2580
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2581
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2582
lemma ereal_less_divide_pos:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2583
  fixes x y :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2584
  shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y < z / x \<longleftrightarrow> x * y < z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2585
  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
  2586
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2587
lemma ereal_divide_less_pos:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2588
  fixes x y z :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2589
  shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y / x < z \<longleftrightarrow> y < x * z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2590
  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
  2591
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2592
lemma ereal_divide_eq:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2593
  fixes a b c :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2594
  shows "b \<noteq> 0 \<Longrightarrow> \<bar>b\<bar> \<noteq> \<infinity> \<Longrightarrow> a / b = c \<longleftrightarrow> a = b * c"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2595
  by (cases rule: ereal3_cases[of a b c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2596
     (simp_all add: field_simps)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2597
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2598
lemma ereal_inverse_not_MInfty[simp]: "inverse (a::ereal) \<noteq> -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2599
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2600
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2601
lemma ereal_mult_m1[simp]: "x * ereal (-1) = -x"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2602
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2603
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2604
lemma ereal_real':
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2605
  assumes "\<bar>x\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2606
  shows "ereal (real x) = x"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  2607
  using assms by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2608
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2609
lemma real_ereal_id: "real \<circ> ereal = id"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2610
proof -
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2611
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2612
    fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2613
    have "(real o ereal) x = id x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2614
      by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2615
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2616
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2617
    using ext by blast
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2618
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2619
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  2620
lemma open_image_ereal: "open(UNIV-{ \<infinity> , (-\<infinity> :: ereal)})"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2621
  by (metis range_ereal open_ereal open_UNIV)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2622
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2623
lemma ereal_le_distrib:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2624
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2625
  shows "c * (a + b) \<le> c * a + c * b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2626
  by (cases rule: ereal3_cases[of a b c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2627
     (auto simp add: field_simps not_le mult_le_0_iff mult_less_0_iff)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2628
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2629
lemma ereal_pos_distrib:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2630
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2631
  assumes "0 \<le> c"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2632
    and "c \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2633
  shows "c * (a + b) = c * a + c * b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2634
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2635
  by (cases rule: ereal3_cases[of a b c])
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2636
    (auto simp add: field_simps not_le mult_le_0_iff mult_less_0_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2637
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2638
lemma ereal_max_mono: "(a::ereal) \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> max a c \<le> max b d"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2639
  by (metis sup_ereal_def sup_mono)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2640
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2641
lemma ereal_max_least: "(a::ereal) \<le> x \<Longrightarrow> c \<le> x \<Longrightarrow> max a c \<le> x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  2642
  by (metis sup_ereal_def sup_least)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2643
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2644
lemma ereal_LimI_finite:
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2645
  fixes x :: ereal
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2646
  assumes "\<bar>x\<bar> \<noteq> \<infinity>"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2647
    and "\<And>r. 0 < r \<Longrightarrow> \<exists>N. \<forall>n\<ge>N. u n < x + r \<and> x < u n + r"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2648
  shows "u ----> x"
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2649
proof (rule topological_tendstoI, unfold eventually_sequentially)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2650
  obtain rx where rx: "x = ereal rx"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2651
    using assms by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2652
  fix S
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2653
  assume "open S" and "x \<in> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2654
  then have "open (ereal -` S)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2655
    unfolding open_ereal_def by auto
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2656
  with \<open>x \<in> S\<close> obtain r where "0 < r" and dist: "\<And>y. dist y rx < r \<Longrightarrow> ereal y \<in> S"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2657
    unfolding open_real_def rx by auto
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2658
  then obtain n where
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2659
    upper: "\<And>N. n \<le> N \<Longrightarrow> u N < x + ereal r" and
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2660
    lower: "\<And>N. n \<le> N \<Longrightarrow> x < u N + ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2661
    using assms(2)[of "ereal r"] by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2662
  show "\<exists>N. \<forall>n\<ge>N. u n \<in> S"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2663
  proof (safe intro!: exI[of _ n])
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2664
    fix N
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2665
    assume "n \<le> N"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2666
    from upper[OF this] lower[OF this] assms \<open>0 < r\<close>
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2667
    have "u N \<notin> {\<infinity>,(-\<infinity>)}"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2668
      by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2669
    then obtain ra where ra_def: "(u N) = ereal ra"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2670
      by (cases "u N") auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2671
    then have "rx < ra + r" and "ra < rx + r"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2672
      using rx assms \<open>0 < r\<close> lower[OF \<open>n \<le> N\<close>] upper[OF \<open>n \<le> N\<close>]
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2673
      by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2674
    then have "dist (real (u N)) rx < r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2675
      using rx ra_def
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2676
      by (auto simp: dist_real_def abs_diff_less_iff field_simps)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2677
    from dist[OF this] show "u N \<in> S"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2678
      using \<open>u N  \<notin> {\<infinity>, -\<infinity>}\<close>
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2679
      by (auto simp: ereal_real split: split_if_asm)
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2680
  qed
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2681
qed
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2682
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2683
lemma tendsto_obtains_N:
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2684
  assumes "f ----> f0"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2685
  assumes "open S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2686
    and "f0 \<in> S"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2687
  obtains N where "\<forall>n\<ge>N. f n \<in> S"
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
  2688
  using assms using tendsto_def
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2689
  using tendsto_explicit[of f f0] assms by auto
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2690
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2691
lemma ereal_LimI_finite_iff:
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2692
  fixes x :: ereal
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2693
  assumes "\<bar>x\<bar> \<noteq> \<infinity>"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2694
  shows "u ----> x \<longleftrightarrow> (\<forall>r. 0 < r \<longrightarrow> (\<exists>N. \<forall>n\<ge>N. u n < x + r \<and> x < u n + r))"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2695
  (is "?lhs \<longleftrightarrow> ?rhs")
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2696
proof
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2697
  assume lim: "u ----> x"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2698
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2699
    fix r :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2700
    assume "r > 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2701
    then obtain N where "\<forall>n\<ge>N. u n \<in> {x - r <..< x + r}"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2702
       apply (subst tendsto_obtains_N[of u x "{x - r <..< x + r}"])
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2703
       using lim ereal_between[of x r] assms \<open>r > 0\<close>
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2704
       apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2705
       done
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2706
    then have "\<exists>N. \<forall>n\<ge>N. u n < x + r \<and> x < u n + r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2707
      using ereal_minus_less[of r x]
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2708
      by (cases r) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2709
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2710
  then show ?rhs
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2711
    by auto
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2712
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2713
  assume ?rhs
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2714
  then show "u ----> x"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2715
    using ereal_LimI_finite[of x] assms by auto
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2716
qed
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2717
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  2718
lemma ereal_Limsup_uminus:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2719
  fixes f :: "'a \<Rightarrow> ereal"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2720
  shows "Limsup net (\<lambda>x. - (f x)) = - Liminf net f"
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
  2721
  unfolding Limsup_def Liminf_def ereal_SUP_uminus ereal_INF_uminus_eq ..
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2722
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  2723
lemma liminf_bounded_iff:
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  2724
  fixes x :: "nat \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2725
  shows "C \<le> liminf x \<longleftrightarrow> (\<forall>B<C. \<exists>N. \<forall>n\<ge>N. B < x n)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2726
  (is "?lhs \<longleftrightarrow> ?rhs")
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  2727
  unfolding le_Liminf_iff eventually_sequentially ..
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50819
diff changeset
  2728
59679
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2729
lemma Liminf_add_le:
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2730
  fixes f g :: "_ \<Rightarrow> ereal"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2731
  assumes F: "F \<noteq> bot"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2732
  assumes ev: "eventually (\<lambda>x. 0 \<le> f x) F" "eventually (\<lambda>x. 0 \<le> g x) F"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2733
  shows "Liminf F f + Liminf F g \<le> Liminf F (\<lambda>x. f x + g x)"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2734
  unfolding Liminf_def
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2735
proof (subst SUP_ereal_add_left[symmetric])
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2736
  let ?F = "{P. eventually P F}"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2737
  let ?INF = "\<lambda>P g. INFIMUM (Collect P) g"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2738
  show "?F \<noteq> {}"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2739
    by (auto intro: eventually_True)
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2740
  show "(SUP P:?F. ?INF P g) \<noteq> - \<infinity>"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2741
    unfolding bot_ereal_def[symmetric] SUP_bot_conv INF_eq_bot_iff
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2742
    by (auto intro!: exI[of _ 0] ev simp: bot_ereal_def)
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2743
  have "(SUP P:?F. ?INF P f + (SUP P:?F. ?INF P g)) \<le> (SUP P:?F. (SUP P':?F. ?INF P f + ?INF P' g))"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2744
  proof (safe intro!: SUP_mono bexI[of _ "\<lambda>x. P x \<and> 0 \<le> f x" for P])
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2745
    fix P let ?P' = "\<lambda>x. P x \<and> 0 \<le> f x"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2746
    assume "eventually P F"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2747
    with ev show "eventually ?P' F"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2748
      by eventually_elim auto
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2749
    have "?INF P f + (SUP P:?F. ?INF P g) \<le> ?INF ?P' f + (SUP P:?F. ?INF P g)"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2750
      by (intro ereal_add_mono INF_mono) auto
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2751
    also have "\<dots> = (SUP P':?F. ?INF ?P' f + ?INF P' g)"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2752
    proof (rule SUP_ereal_add_right[symmetric])
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2753
      show "INFIMUM {x. P x \<and> 0 \<le> f x} f \<noteq> - \<infinity>"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2754
        unfolding bot_ereal_def[symmetric] INF_eq_bot_iff
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2755
        by (auto intro!: exI[of _ 0] ev simp: bot_ereal_def)
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2756
    qed fact
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2757
    finally show "?INF P f + (SUP P:?F. ?INF P g) \<le> (SUP P':?F. ?INF ?P' f + ?INF P' g)" .
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2758
  qed
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2759
  also have "\<dots> \<le> (SUP P:?F. INF x:Collect P. f x + g x)"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2760
  proof (safe intro!: SUP_least)
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2761
    fix P Q assume *: "eventually P F" "eventually Q F"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2762
    show "?INF P f + ?INF Q g \<le> (SUP P:?F. INF x:Collect P. f x + g x)"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2763
    proof (rule SUP_upper2)
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2764
      show "(\<lambda>x. P x \<and> Q x) \<in> ?F"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2765
        using * by (auto simp: eventually_conj)
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2766
      show "?INF P f + ?INF Q g \<le> (INF x:{x. P x \<and> Q x}. f x + g x)"
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2767
        by (intro INF_greatest ereal_add_mono) (auto intro: INF_lower)
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2768
    qed
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2769
  qed
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2770
  finally show "(SUP P:?F. ?INF P f + (SUP P:?F. ?INF P g)) \<le> (SUP P:?F. INF x:Collect P. f x + g x)" .
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2771
qed
2574977f9afa add subadditivity for Liminf on ereal
hoelzl
parents: 59587
diff changeset
  2772
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2773
lemma Sup_ereal_mult_right':
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2774
  assumes nonempty: "Y \<noteq> {}"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2775
  and x: "x \<ge> 0"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2776
  shows "(SUP i:Y. f i) * ereal x = (SUP i:Y. f i * ereal x)" (is "?lhs = ?rhs")
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2777
proof(cases "x = 0")
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2778
  case True thus ?thesis by(auto simp add: nonempty zero_ereal_def[symmetric])
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2779
next
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2780
  case False
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2781
  show ?thesis
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2782
  proof(rule antisym)
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2783
    show "?rhs \<le> ?lhs"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2784
      by(rule SUP_least)(simp add: ereal_mult_right_mono SUP_upper x)
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2785
  next
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2786
    have "?lhs / ereal x = (SUP i:Y. f i) * (ereal x / ereal x)" by(simp only: ereal_times_divide_eq)
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2787
    also have "\<dots> = (SUP i:Y. f i)" using False by simp
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2788
    also have "\<dots> \<le> ?rhs / x"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2789
    proof(rule SUP_least)
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2790
      fix i
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2791
      assume "i \<in> Y"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2792
      have "f i = f i * (ereal x / ereal x)" using False by simp
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2793
      also have "\<dots> = f i * x / x" by(simp only: ereal_times_divide_eq)
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2794
      also from \<open>i \<in> Y\<close> have "f i * x \<le> ?rhs" by(rule SUP_upper)
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2795
      hence "f i * x / x \<le> ?rhs / x" using x False by simp
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2796
      finally show "f i \<le> ?rhs / x" .
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2797
    qed
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2798
    finally have "(?lhs / x) * x \<le> (?rhs / x) * x"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2799
      by(rule ereal_mult_right_mono)(simp add: x)
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2800
    also have "\<dots> = ?rhs" using False ereal_divide_eq mult.commute by force
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2801
    also have "(?lhs / x) * x = ?lhs" using False ereal_divide_eq mult.commute by force
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2802
    finally show "?lhs \<le> ?rhs" .
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2803
  qed
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
  2804
qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  2805
60636
ee18efe9b246 add named theorems order_continuous_intros; lfp/gfp_funpow; bounded variant for lfp/gfp transfer
hoelzl
parents: 60580
diff changeset
  2806
lemma not_MInfty_nonneg[simp]: "0 \<le> (x::ereal) \<Longrightarrow> x \<noteq> - \<infinity>"
ee18efe9b246 add named theorems order_continuous_intros; lfp/gfp_funpow; bounded variant for lfp/gfp transfer
hoelzl
parents: 60580
diff changeset
  2807
  by auto
ee18efe9b246 add named theorems order_continuous_intros; lfp/gfp_funpow; bounded variant for lfp/gfp transfer
hoelzl
parents: 60580
diff changeset
  2808
60637
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2809
lemma sup_continuous_add[order_continuous_intros]:
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2810
  fixes f g :: "'a::complete_lattice \<Rightarrow> ereal"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2811
  assumes nn: "\<And>x. 0 \<le> f x" "\<And>x. 0 \<le> g x" and cont: "sup_continuous f" "sup_continuous g"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2812
  shows "sup_continuous (\<lambda>x. f x + g x)"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2813
  unfolding sup_continuous_def
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2814
proof safe
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2815
  fix M :: "nat \<Rightarrow> 'a" assume "incseq M"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2816
  then show "f (SUP i. M i) + g (SUP i. M i) = (SUP i. f (M i) + g (M i))"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2817
    using SUP_ereal_add_pos[of "\<lambda>i. f (M i)" "\<lambda>i. g (M i)"] nn
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2818
      cont[THEN sup_continuous_mono] cont[THEN sup_continuousD]
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2819
    by (auto simp: mono_def)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2820
qed
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2821
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2822
lemma sup_continuous_mult_right[order_continuous_intros]:
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2823
  "0 \<le> c \<Longrightarrow> c < \<infinity> \<Longrightarrow> sup_continuous f \<Longrightarrow> sup_continuous (\<lambda>x. f x * c :: ereal)"
60636
ee18efe9b246 add named theorems order_continuous_intros; lfp/gfp_funpow; bounded variant for lfp/gfp transfer
hoelzl
parents: 60580
diff changeset
  2824
  by (cases c) (auto simp: sup_continuous_def fun_eq_iff Sup_ereal_mult_right')
ee18efe9b246 add named theorems order_continuous_intros; lfp/gfp_funpow; bounded variant for lfp/gfp transfer
hoelzl
parents: 60580
diff changeset
  2825
60637
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2826
lemma sup_continuous_mult_left[order_continuous_intros]:
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2827
  "0 \<le> c \<Longrightarrow> c < \<infinity> \<Longrightarrow> sup_continuous f \<Longrightarrow> sup_continuous (\<lambda>x. c * f x :: ereal)"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2828
  using sup_continuous_mult_right[of c f] by (simp add: mult_ac)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2829
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2830
lemma sup_continuous_ereal_of_enat[order_continuous_intros]:
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2831
  assumes f: "sup_continuous f" shows "sup_continuous (\<lambda>x. ereal_of_enat (f x))"
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2832
  by (rule sup_continuous_compose[OF _ f])
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2833
     (auto simp: sup_continuous_def ereal_of_enat_SUP)
03a25d3e759e generalized sup_continuty of add, ereal_of_enat
hoelzl
parents: 60636
diff changeset
  2834
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  2835
subsubsection \<open>Tests for code generator\<close>
43933
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
  2836
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
  2837
(* A small list of simple arithmetic expressions *)
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
  2838
56927
4044a7d1720f hardcoded nbe and sml into value command
haftmann
parents: 56889
diff changeset
  2839
value "- \<infinity> :: ereal"
4044a7d1720f hardcoded nbe and sml into value command
haftmann
parents: 56889
diff changeset
  2840
value "\<bar>-\<infinity>\<bar> :: ereal"
4044a7d1720f hardcoded nbe and sml into value command
haftmann
parents: 56889
diff changeset
  2841
value "4 + 5 / 4 - ereal 2 :: ereal"
4044a7d1720f hardcoded nbe and sml into value command
haftmann
parents: 56889
diff changeset
  2842
value "ereal 3 < \<infinity>"
4044a7d1720f hardcoded nbe and sml into value command
haftmann
parents: 56889
diff changeset
  2843
value "real (\<infinity>::ereal) = 0"
43933
6cc1875cf35d add code generator setup and tests for ereal
hoelzl
parents: 43924
diff changeset
  2844
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  2845
end