src/HOL/Library/Extended_Real.thy
author Andreas Lochbihler
Wed, 11 Nov 2015 10:07:27 +0100
changeset 61631 4f7ef088c4ed
parent 61610 4f54d2759a0b
child 61738 c4f6031f1310
permissions -rw-r--r--
add lemmas for extended nats and reals
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
61585
a9599d3d7610 isabelle update_cartouches -c -t;
wenzelm
parents: 61245
diff changeset
    17
AFP-entry \<open>Jinja_Thread\<close> 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
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   252
function real_of_ereal :: "ereal \<Rightarrow> real" where
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   253
  "real_of_ereal (ereal r) = r"
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   254
| "real_of_ereal \<infinity> = 0"
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   255
| "real_of_ereal (-\<infinity>) = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   256
  by (auto intro: ereal_cases)
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   257
termination by standard (rule wf_empty)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   258
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   259
lemma real_of_ereal[simp]:
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   260
  "real_of_ereal (- x :: ereal) = - (real_of_ereal x)"
58042
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   261
  by (cases x) simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   262
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   263
lemma range_ereal[simp]: "range ereal = UNIV - {\<infinity>, -\<infinity>}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   264
proof safe
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   265
  fix x
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   266
  assume "x \<notin> range ereal" "x \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   267
  then show "x = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   268
    by (cases x) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   269
qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   270
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   271
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
   272
proof safe
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   273
  fix x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   274
  show "x \<in> range uminus"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   275
    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
   276
qed auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   277
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   278
instantiation ereal :: abs
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   279
begin
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   280
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   281
function abs_ereal where
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   282
  "\<bar>ereal r\<bar> = ereal \<bar>r\<bar>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   283
| "\<bar>-\<infinity>\<bar> = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   284
| "\<bar>\<infinity>\<bar> = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   285
by (auto intro: ereal_cases)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   286
termination proof qed (rule wf_empty)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   287
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   288
instance ..
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   289
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   290
end
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   291
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   292
lemma abs_eq_infinity_cases[elim!]:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   293
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   294
  assumes "\<bar>x\<bar> = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   295
  obtains "x = \<infinity>" | "x = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   296
  using assms by (cases x) auto
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   297
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   298
lemma abs_neq_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> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   301
  obtains r where "x = ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   302
  using assms by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   303
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   304
lemma abs_ereal_uminus[simp]:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   305
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   306
  shows "\<bar>- x\<bar> = \<bar>x\<bar>"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   307
  by (cases x) auto
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   308
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   309
lemma ereal_infinity_cases:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   310
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   311
  shows "a \<noteq> \<infinity> \<Longrightarrow> a \<noteq> -\<infinity> \<Longrightarrow> \<bar>a\<bar> \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   312
  by auto
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   313
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   314
subsubsection "Addition"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   315
54408
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 53873
diff changeset
   316
instantiation ereal :: "{one,comm_monoid_add,zero_neq_one}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   317
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   318
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   319
definition "0 = ereal 0"
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   320
definition "1 = ereal 1"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   321
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   322
function plus_ereal where
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   323
  "ereal r + ereal p = ereal (r + p)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   324
| "\<infinity> + a = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   325
| "a + \<infinity> = (\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   326
| "ereal r + -\<infinity> = - \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   327
| "-\<infinity> + ereal p = -(\<infinity>::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   328
| "-\<infinity> + -\<infinity> = -(\<infinity>::ereal)"
61166
5976fe402824 renamed method "goals" to "goal_cases" to emphasize its meaning;
wenzelm
parents: 61120
diff changeset
   329
proof goal_cases
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   330
  case prems: (1 P x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   331
  then obtain a b where "x = (a, b)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   332
    by (cases x) auto
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   333
  with prems show P
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   334
   by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   335
qed auto
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   336
termination by standard (rule wf_empty)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   337
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   338
lemma Infty_neq_0[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   339
  "(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   340
  "-(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> -(\<infinity>::ereal)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   341
  by (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   342
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   343
lemma ereal_eq_0[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   344
  "ereal r = 0 \<longleftrightarrow> r = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   345
  "0 = ereal r \<longleftrightarrow> r = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   346
  unfolding zero_ereal_def by simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   347
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   348
lemma ereal_eq_1[simp]:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   349
  "ereal r = 1 \<longleftrightarrow> r = 1"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   350
  "1 = ereal r \<longleftrightarrow> r = 1"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   351
  unfolding one_ereal_def by simp_all
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   352
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   353
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   354
proof
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   355
  fix a b c :: ereal
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   356
  show "0 + a = a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   357
    by (cases a) (simp_all add: zero_ereal_def)
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   358
  show "a + b = b + a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   359
    by (cases rule: ereal2_cases[of a b]) simp_all
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   360
  show "a + b + c = a + (b + c)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   361
    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
   362
  show "0 \<noteq> (1::ereal)"
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 53873
diff changeset
   363
    by (simp add: one_ereal_def zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   364
qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   365
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   366
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   367
60060
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   368
lemma ereal_0_plus [simp]: "ereal 0 + x = x"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   369
  and plus_ereal_0 [simp]: "x + ereal 0 = x"
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   370
by(simp_all add: zero_ereal_def[symmetric])
3630ecde4e7c more lemmas about ereal
Andreas Lochbihler
parents: 59679
diff changeset
   371
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   372
instance ereal :: numeral ..
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   373
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   374
lemma real_of_ereal_0[simp]: "real_of_ereal (0::ereal) = 0"
58042
ffa9e39763e3 introduce real_of typeclass for real :: 'a => real
hoelzl
parents: 57512
diff changeset
   375
  unfolding zero_ereal_def by simp
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   376
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   377
lemma abs_ereal_zero[simp]: "\<bar>0\<bar> = (0::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   378
  unfolding zero_ereal_def abs_ereal.simps by simp
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   379
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   380
lemma ereal_uminus_zero[simp]: "- 0 = (0::ereal)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   381
  by (simp add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   382
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   383
lemma ereal_uminus_zero_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   384
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   385
  shows "-a = 0 \<longleftrightarrow> a = 0"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   386
  by (cases a) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   387
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   388
lemma ereal_plus_eq_PInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   389
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   390
  shows "a + b = \<infinity> \<longleftrightarrow> a = \<infinity> \<or> b = \<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   391
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   392
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   393
lemma ereal_plus_eq_MInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   394
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   395
  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
   396
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   397
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   398
lemma ereal_add_cancel_left:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   399
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   400
  assumes "a \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   401
  shows "a + b = a + c \<longleftrightarrow> a = \<infinity> \<or> b = c"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   402
  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
   403
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   404
lemma ereal_add_cancel_right:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   405
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   406
  assumes "a \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   407
  shows "b + a = c + a \<longleftrightarrow> a = \<infinity> \<or> b = c"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   408
  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
   409
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   410
lemma ereal_real: "ereal (real_of_ereal x) = (if \<bar>x\<bar> = \<infinity> then 0 else x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   411
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   412
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   413
lemma real_of_ereal_add:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   414
  fixes a b :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   415
  shows "real_of_ereal (a + b) =
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   416
    (if (\<bar>a\<bar> = \<infinity>) \<and> (\<bar>b\<bar> = \<infinity>) \<or> (\<bar>a\<bar> \<noteq> \<infinity>) \<and> (\<bar>b\<bar> \<noteq> \<infinity>) then real_of_ereal a + real_of_ereal b else 0)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   417
  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
   418
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   419
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   420
subsubsection "Linear order on @{typ ereal}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   421
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   422
instantiation ereal :: linorder
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   423
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   424
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   425
function less_ereal
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   426
where
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   427
  "   ereal x < ereal y     \<longleftrightarrow> x < y"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   428
| "(\<infinity>::ereal) < a           \<longleftrightarrow> False"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   429
| "         a < -(\<infinity>::ereal) \<longleftrightarrow> False"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   430
| "ereal x    < \<infinity>           \<longleftrightarrow> True"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   431
| "        -\<infinity> < ereal r     \<longleftrightarrow> True"
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   432
| "        -\<infinity> < (\<infinity>::ereal) \<longleftrightarrow> True"
61166
5976fe402824 renamed method "goals" to "goal_cases" to emphasize its meaning;
wenzelm
parents: 61120
diff changeset
   433
proof goal_cases
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   434
  case prems: (1 P x)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53216
diff changeset
   435
  then obtain a b where "x = (a,b)" by (cases x) auto
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   436
  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
   437
qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   438
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   439
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   440
definition "x \<le> (y::ereal) \<longleftrightarrow> x < y \<or> x = y"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   441
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   442
lemma ereal_infty_less[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   443
  fixes x :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   444
  shows "x < \<infinity> \<longleftrightarrow> (x \<noteq> \<infinity>)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   445
    "-\<infinity> < x \<longleftrightarrow> (x \<noteq> -\<infinity>)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   446
  by (cases x, simp_all) (cases x, simp_all)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   447
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   448
lemma ereal_infty_less_eq[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   449
  fixes x :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   450
  shows "\<infinity> \<le> x \<longleftrightarrow> x = \<infinity>"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   451
    and "x \<le> -\<infinity> \<longleftrightarrow> x = -\<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   452
  by (auto simp add: less_eq_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   453
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   454
lemma ereal_less[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   455
  "ereal r < 0 \<longleftrightarrow> (r < 0)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   456
  "0 < ereal r \<longleftrightarrow> (0 < r)"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   457
  "ereal r < 1 \<longleftrightarrow> (r < 1)"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   458
  "1 < ereal r \<longleftrightarrow> (1 < r)"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   459
  "0 < (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   460
  "-(\<infinity>::ereal) < 0"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   461
  by (simp_all add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   462
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   463
lemma ereal_less_eq[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   464
  "x \<le> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   465
  "-(\<infinity>::ereal) \<le> x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   466
  "ereal r \<le> ereal p \<longleftrightarrow> r \<le> p"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   467
  "ereal r \<le> 0 \<longleftrightarrow> r \<le> 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   468
  "0 \<le> ereal r \<longleftrightarrow> 0 \<le> r"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   469
  "ereal r \<le> 1 \<longleftrightarrow> r \<le> 1"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   470
  "1 \<le> ereal r \<longleftrightarrow> 1 \<le> r"
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   471
  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
   472
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   473
lemma ereal_infty_less_eq2:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   474
  "a \<le> b \<Longrightarrow> a = \<infinity> \<Longrightarrow> b = (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   475
  "a \<le> b \<Longrightarrow> b = -\<infinity> \<Longrightarrow> a = -(\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   476
  by simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   477
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   478
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   479
proof
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   480
  fix x y z :: ereal
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   481
  show "x \<le> x"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   482
    by (cases x) simp_all
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   483
  show "x < y \<longleftrightarrow> x \<le> y \<and> \<not> y \<le> x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   484
    by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   485
  show "x \<le> y \<or> y \<le> x "
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   486
    by (cases rule: ereal2_cases[of x y]) auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   487
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   488
    assume "x \<le> y" "y \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   489
    then show "x = y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   490
      by (cases rule: ereal2_cases[of x y]) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   491
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   492
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   493
    assume "x \<le> y" "y \<le> z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   494
    then show "x \<le> z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   495
      by (cases rule: ereal3_cases[of x y z]) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   496
  }
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   497
qed
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   498
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   499
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   500
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
   501
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
   502
  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
   503
53216
ad2e09c30aa8 renamed inner_dense_linorder to dense_linorder
hoelzl
parents: 52729
diff changeset
   504
instance ereal :: dense_linorder
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   505
  by standard (blast dest: ereal_dense2)
51329
4a3c453f99a1 split dense into inner_dense_order and no_top/no_bot
hoelzl
parents: 51328
diff changeset
   506
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   507
instance ereal :: ordered_ab_semigroup_add
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   508
proof
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   509
  fix a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   510
  assume "a \<le> b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   511
  then show "c + a \<le> c + b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   512
    by (cases rule: ereal3_cases[of a b c]) auto
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   513
qed
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   514
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   515
lemma real_of_ereal_positive_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   516
  fixes x y :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   517
  shows "0 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<noteq> \<infinity> \<Longrightarrow> real_of_ereal x \<le> real_of_ereal y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   518
  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
   519
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   520
lemma ereal_MInfty_lessI[intro, simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   521
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   522
  shows "a \<noteq> -\<infinity> \<Longrightarrow> -\<infinity> < a"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   523
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   524
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   525
lemma ereal_less_PInfty[intro, simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   526
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   527
  shows "a \<noteq> \<infinity> \<Longrightarrow> a < \<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   528
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   529
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   530
lemma ereal_less_ereal_Ex:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   531
  fixes a b :: ereal
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   532
  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
   533
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   534
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   535
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
   536
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   537
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   538
  then show ?thesis
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
   539
    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
   540
qed simp_all
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   541
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   542
lemma ereal_add_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   543
  fixes a b c d :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   544
  assumes "a \<le> b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   545
    and "c \<le> d"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   546
  shows "a + c \<le> b + d"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   547
  using assms
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   548
  apply (cases a)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   549
  apply (cases rule: ereal3_cases[of b c d], auto)
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   550
  apply (cases rule: ereal3_cases[of b c d], auto)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   551
  done
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   552
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   553
lemma ereal_minus_le_minus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   554
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   555
  shows "- a \<le> - b \<longleftrightarrow> b \<le> a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   556
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   557
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   558
lemma ereal_minus_less_minus[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   559
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   560
  shows "- a < - b \<longleftrightarrow> b < a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   561
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   562
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   563
lemma ereal_le_real_iff:
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   564
  "x \<le> real_of_ereal y \<longleftrightarrow> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> ereal x \<le> y) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> x \<le> 0)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   565
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   566
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   567
lemma real_le_ereal_iff:
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   568
  "real_of_ereal y \<le> x \<longleftrightarrow> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> y \<le> ereal x) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> 0 \<le> x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   569
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   570
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   571
lemma ereal_less_real_iff:
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   572
  "x < real_of_ereal y \<longleftrightarrow> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> ereal x < y) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> x < 0)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   573
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   574
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   575
lemma real_less_ereal_iff:
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   576
  "real_of_ereal y < x \<longleftrightarrow> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> y < ereal x) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> 0 < x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   577
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   578
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   579
lemma real_of_ereal_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   580
  fixes x :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   581
  shows "0 \<le> x \<Longrightarrow> 0 \<le> real_of_ereal x" by (cases x) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   582
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   583
lemmas real_of_ereal_ord_simps =
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   584
  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
   585
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   586
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
   587
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   588
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   589
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
   590
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   591
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   592
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
   593
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   594
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   595
lemma ereal_abs_leI:
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   596
  fixes x y :: ereal 
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   597
  shows "\<lbrakk> x \<le> y; -x \<le> y \<rbrakk> \<Longrightarrow> \<bar>x\<bar> \<le> y"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   598
by(cases x y rule: ereal2_cases)(simp_all)
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   599
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   600
lemma real_of_ereal_le_0[simp]: "real_of_ereal (x :: ereal) \<le> 0 \<longleftrightarrow> x \<le> 0 \<or> x = \<infinity>"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   601
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   602
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   603
lemma abs_real_of_ereal[simp]: "\<bar>real_of_ereal (x :: ereal)\<bar> = real_of_ereal \<bar>x\<bar>"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   604
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   605
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   606
lemma zero_less_real_of_ereal:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   607
  fixes x :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   608
  shows "0 < real_of_ereal x \<longleftrightarrow> 0 < x \<and> x \<noteq> \<infinity>"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   609
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   610
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   611
lemma ereal_0_le_uminus_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   612
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   613
  shows "0 \<le> - a \<longleftrightarrow> a \<le> 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   614
  by (cases rule: ereal2_cases[of a]) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   615
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   616
lemma ereal_uminus_le_0_iff[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   617
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   618
  shows "- a \<le> 0 \<longleftrightarrow> 0 \<le> a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   619
  by (cases rule: ereal2_cases[of a]) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   620
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   621
lemma ereal_add_strict_mono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   622
  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
   623
  assumes "a \<le> b"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   624
    and "0 \<le> a"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   625
    and "a \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   626
    and "c < d"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   627
  shows "a + c < b + d"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   628
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   629
  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
   630
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   631
lemma ereal_less_add:
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   632
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   633
  shows "\<bar>a\<bar> \<noteq> \<infinity> \<Longrightarrow> c < b \<Longrightarrow> a + c < a + b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   634
  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
   635
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   636
lemma ereal_add_nonneg_eq_0_iff:
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   637
  fixes a b :: ereal
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   638
  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
   639
  by (cases a b rule: ereal2_cases) auto
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   640
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   641
lemma ereal_uminus_eq_reorder: "- a = b \<longleftrightarrow> a = (-b::ereal)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   642
  by auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   643
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   644
lemma ereal_uminus_less_reorder: "- a < b \<longleftrightarrow> -b < (a::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   645
  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
   646
59452
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
   647
lemma ereal_less_uminus_reorder: "a < - b \<longleftrightarrow> b < - (a::ereal)"
2538b2c51769 ereal: tuned proofs concerning continuity and suprema
hoelzl
parents: 59425
diff changeset
   648
  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
   649
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   650
lemma ereal_uminus_le_reorder: "- a \<le> b \<longleftrightarrow> -b \<le> (a::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   651
  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
   652
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   653
lemmas ereal_uminus_reorder =
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   654
  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
   655
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   656
lemma ereal_bot:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   657
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   658
  assumes "\<And>B. x \<le> ereal B"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   659
  shows "x = - \<infinity>"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   660
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   661
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   662
  with assms[of "r - 1"] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   663
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   664
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   665
  case PInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   666
  with assms[of 0] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   667
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   668
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   669
  case MInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   670
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   671
    by simp
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   672
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   673
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   674
lemma ereal_top:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   675
  fixes x :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   676
  assumes "\<And>B. x \<ge> ereal B"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   677
  shows "x = \<infinity>"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   678
proof (cases x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   679
  case (real r)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   680
  with assms[of "r + 1"] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   681
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   682
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   683
  case MInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   684
  with assms[of 0] show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   685
    by auto
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   686
next
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   687
  case PInf
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   688
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   689
    by simp
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   690
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   691
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   692
lemma
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   693
  shows ereal_max[simp]: "ereal (max x y) = max (ereal x) (ereal y)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   694
    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
   695
  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
   696
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   697
lemma ereal_max_0: "max 0 (ereal r) = ereal (max 0 r)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   698
  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
   699
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   700
lemma
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   701
  fixes f :: "nat \<Rightarrow> ereal"
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   702
  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
   703
    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
   704
  unfolding decseq_def incseq_def by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   705
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   706
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
   707
  unfolding incseq_def by auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   708
56537
01caba82e1d2 made ereal_add_nonneg_nonneg a simp rule
nipkow
parents: 56536
diff changeset
   709
lemma ereal_add_nonneg_nonneg[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   710
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   711
  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
   712
  using add_mono[of 0 a 0 b] by simp
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   713
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   714
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
   715
  by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   716
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   717
lemma incseq_setsumI:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   718
  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
   719
  assumes "\<And>i. 0 \<le> f i"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   720
  shows "incseq (\<lambda>i. setsum f {..< i})"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   721
proof (intro incseq_SucI)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   722
  fix n
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   723
  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
   724
    using assms by (rule add_left_mono)
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   725
  then show "setsum f {..< n} \<le> setsum f {..< Suc n}"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   726
    by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   727
qed
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   728
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   729
lemma incseq_setsumI2:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   730
  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
   731
  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
   732
  shows "incseq (\<lambda>i. \<Sum>n\<in>A. f n i)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   733
  using assms
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   734
  unfolding incseq_def by (auto intro: setsum_mono)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   735
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   736
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
   737
proof (cases "finite A")
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   738
  case True
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   739
  then show ?thesis by induct auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   740
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   741
  case False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   742
  then show ?thesis by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   743
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   744
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   745
lemma setsum_Pinfty:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   746
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   747
  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
   748
proof safe
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   749
  assume *: "setsum f P = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   750
  show "finite P"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   751
  proof (rule ccontr)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   752
    assume "\<not> finite P"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   753
    with * show False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   754
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   755
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   756
  show "\<exists>i\<in>P. f i = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   757
  proof (rule ccontr)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   758
    assume "\<not> ?thesis"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   759
    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
   760
      by auto
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   761
    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
   762
      by induct auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   763
    with * show False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   764
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   765
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   766
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   767
  fix i
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   768
  assume "finite P" and "i \<in> P" and "f i = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   769
  then show "setsum f P = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   770
  proof induct
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   771
    case (insert x A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   772
    show ?case using insert by (cases "x = i") auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   773
  qed simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   774
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   775
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   776
lemma setsum_Inf:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   777
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   778
  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
   779
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   780
  assume *: "\<bar>setsum f A\<bar> = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   781
  have "finite A"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   782
    by (rule ccontr) (insert *, auto)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   783
  moreover have "\<exists>i\<in>A. \<bar>f i\<bar> = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   784
  proof (rule ccontr)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   785
    assume "\<not> ?thesis"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   786
    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
   787
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   788
    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
   789
    with * show False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   790
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   791
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   792
  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
   793
    by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   794
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   795
  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
   796
  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
   797
    by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   798
  then show "\<bar>setsum f A\<bar> = \<infinity>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   799
  proof induct
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   800
    case (insert j A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   801
    then show ?case
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   802
      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
   803
  qed simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   804
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   805
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   806
lemma setsum_real_of_ereal:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   807
  fixes f :: "'i \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   808
  assumes "\<And>x. x \<in> S \<Longrightarrow> \<bar>f x\<bar> \<noteq> \<infinity>"
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   809
  shows "(\<Sum>x\<in>S. real_of_ereal (f x)) = real_of_ereal (setsum f S)"
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   810
proof -
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   811
  have "\<forall>x\<in>S. \<exists>r. f x = ereal r"
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
    fix x
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   814
    assume "x \<in> S"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   815
    from assms[OF this] show "\<exists>r. f x = ereal r"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   816
      by (cases "f x") auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   817
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   818
  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
   819
  then show ?thesis
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   820
    by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   821
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   822
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   823
lemma setsum_ereal_0:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   824
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   825
  assumes "finite A"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   826
    and "\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   827
  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
   828
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   829
  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
   830
  proof (induction A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   831
    case (insert a A)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   832
    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
   833
      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
   834
    with insert show ?case
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   835
      by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   836
  qed simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   837
qed auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   838
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   839
subsubsection "Multiplication"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   840
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   841
instantiation ereal :: "{comm_monoid_mult,sgn}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   842
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   843
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
   844
function sgn_ereal :: "ereal \<Rightarrow> ereal" where
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   845
  "sgn (ereal r) = ereal (sgn r)"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   846
| "sgn (\<infinity>::ereal) = 1"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   847
| "sgn (-\<infinity>::ereal) = -1"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   848
by (auto intro: ereal_cases)
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60637
diff changeset
   849
termination by standard (rule wf_empty)
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   850
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   851
function times_ereal where
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   852
  "ereal r * ereal p = ereal (r * p)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   853
| "ereal r * \<infinity> = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   854
| "\<infinity> * ereal r = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)"
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
| "(\<infinity>::ereal) * \<infinity> = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   858
| "-(\<infinity>::ereal) * \<infinity> = -\<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>"
61166
5976fe402824 renamed method "goals" to "goal_cases" to emphasize its meaning;
wenzelm
parents: 61120
diff changeset
   861
proof goal_cases
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   862
  case prems: (1 P x)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   863
  then obtain a b where "x = (a, b)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   864
    by (cases x) auto
60580
7e741e22d7fc tuned proofs;
wenzelm
parents: 60500
diff changeset
   865
  with prems show P
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   866
    by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   867
qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   868
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   869
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   870
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   871
proof
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   872
  fix a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   873
  show "1 * a = a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   874
    by (cases a) (simp_all add: one_ereal_def)
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   875
  show "a * b = b * a"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   876
    by (cases rule: ereal2_cases[of a b]) simp_all
47082
737d7bc8e50f tuned proofs;
wenzelm
parents: 45934
diff changeset
   877
  show "a * b * c = a * (b * c)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   878
    by (cases rule: ereal3_cases[of a b c])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   879
       (simp_all add: zero_ereal_def zero_less_mult_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   880
qed
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   881
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   882
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   883
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   884
lemma [simp]: 
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   885
  shows ereal_1_times: "ereal 1 * x = x"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   886
  and times_ereal_1: "x * ereal 1 = x"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   887
by(simp_all add: one_ereal_def[symmetric])
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
   888
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   889
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
   890
  by (simp add: one_ereal_def zero_ereal_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   891
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   892
lemma real_ereal_1[simp]: "real_of_ereal (1::ereal) = 1"
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
   893
  unfolding one_ereal_def by simp
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
   894
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   895
lemma real_of_ereal_le_1:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   896
  fixes a :: ereal
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61245
diff changeset
   897
  shows "a \<le> 1 \<Longrightarrow> real_of_ereal a \<le> 1"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   898
  by (cases a) (auto simp: one_ereal_def)
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   899
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   900
lemma abs_ereal_one[simp]: "\<bar>1\<bar> = (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   901
  unfolding one_ereal_def by simp
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   902
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   903
lemma ereal_mult_zero[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   904
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   905
  shows "a * 0 = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   906
  by (cases a) (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   907
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   908
lemma ereal_zero_mult[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   909
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   910
  shows "0 * a = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   911
  by (cases a) (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   912
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   913
lemma ereal_m1_less_0[simp]: "-(1::ereal) < 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   914
  by (simp add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   915
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   916
lemma ereal_times[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   917
  "1 \<noteq> (\<infinity>::ereal)" "(\<infinity>::ereal) \<noteq> 1"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   918
  "1 \<noteq> -(\<infinity>::ereal)" "-(\<infinity>::ereal) \<noteq> 1"
61120
65082457c117 tuned proofs;
wenzelm
parents: 60772
diff changeset
   919
  by (auto simp: one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   920
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   921
lemma ereal_plus_1[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   922
  "1 + ereal r = ereal (r + 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   923
  "ereal r + 1 = ereal (r + 1)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   924
  "1 + -(\<infinity>::ereal) = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   925
  "-(\<infinity>::ereal) + 1 = -\<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   926
  unfolding one_ereal_def by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   927
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   928
lemma ereal_zero_times[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   929
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   930
  shows "a * b = 0 \<longleftrightarrow> a = 0 \<or> b = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   931
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   932
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   933
lemma ereal_mult_eq_PInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   934
  "a * b = (\<infinity>::ereal) \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   935
    (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
   936
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   937
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   938
lemma ereal_mult_eq_MInfty[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   939
  "a * b = -(\<infinity>::ereal) \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   940
    (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
   941
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   942
54416
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   943
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
   944
  by (cases x y rule: ereal2_cases) (auto simp: abs_mult)
7fb88ed6ff3c better support for enat and ereal conversions
hoelzl
parents: 54408
diff changeset
   945
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   946
lemma ereal_0_less_1[simp]: "0 < (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   947
  by (simp_all add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   948
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   949
lemma ereal_mult_minus_left[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   950
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   951
  shows "-a * b = - (a * b)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   952
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   953
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   954
lemma ereal_mult_minus_right[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   955
  fixes a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   956
  shows "a * -b = - (a * b)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   957
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   958
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   959
lemma ereal_mult_infty[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   960
  "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
   961
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   962
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   963
lemma ereal_infty_mult[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   964
  "(\<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
   965
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   966
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   967
lemma ereal_mult_strict_right_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   968
  assumes "a < b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   969
    and "0 < c"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   970
    and "c < (\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   971
  shows "a * c < b * c"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   972
  using assms
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   973
  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
   974
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   975
lemma ereal_mult_strict_left_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   976
  "a < b \<Longrightarrow> 0 < c \<Longrightarrow> c < (\<infinity>::ereal) \<Longrightarrow> c * a < c * b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   977
  using ereal_mult_strict_right_mono
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57447
diff changeset
   978
  by (simp add: mult.commute[of c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   979
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   980
lemma ereal_mult_right_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   981
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   982
  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
   983
  using assms
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   984
  apply (cases "c = 0")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   985
  apply simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   986
  apply (cases rule: ereal3_cases[of a b c])
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   987
  apply (auto simp: zero_le_mult_iff)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   988
  done
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   989
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   990
lemma ereal_mult_left_mono:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   991
  fixes a b c :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   992
  shows "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> c * a \<le> c * b"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
   993
  using ereal_mult_right_mono
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57447
diff changeset
   994
  by (simp add: mult.commute[of c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   995
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   996
lemma zero_less_one_ereal[simp]: "0 \<le> (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   997
  by (simp add: one_ereal_def zero_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   998
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   999
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
  1000
  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
  1001
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1002
lemma ereal_right_distrib:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1003
  fixes r a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1004
  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
  1005
  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
  1006
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1007
lemma ereal_left_distrib:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1008
  fixes r a b :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1009
  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
  1010
  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
  1011
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1012
lemma ereal_mult_le_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1013
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1014
  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
  1015
  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
  1016
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1017
lemma ereal_zero_le_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1018
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1019
  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
  1020
  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
  1021
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1022
lemma ereal_mult_less_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1023
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1024
  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
  1025
  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
  1026
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1027
lemma ereal_zero_less_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1028
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1029
  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
  1030
  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
  1031
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1032
lemma ereal_left_mult_cong:
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1033
  fixes a b c :: ereal
59002
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1034
  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
  1035
  by (cases "c = 0") simp_all
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1036
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1037
lemma ereal_right_mult_cong: 
59002
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1038
  fixes a b c :: ereal
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1039
  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
  1040
  by (cases "c = 0") simp_all
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 47108
diff changeset
  1041
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1042
lemma ereal_distrib:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1043
  fixes a b c :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1044
  assumes "a \<noteq> \<infinity> \<or> b \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1045
    and "a \<noteq> -\<infinity> \<or> b \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1046
    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
  1047
  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
  1048
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1049
  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
  1050
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1051
lemma numeral_eq_ereal [simp]: "numeral w = ereal (numeral w)"
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1052
  apply (induct w rule: num_induct)
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1053
  apply (simp only: numeral_One one_ereal_def)
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1054
  apply (simp only: numeral_inc ereal_plus_1)
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1055
  done
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1056
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1057
lemma distrib_left_ereal_nn:
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1058
  "c \<ge> 0 \<Longrightarrow> (x + y) * ereal c = x * ereal c + y * ereal c"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1059
by(cases x y rule: ereal2_cases)(simp_all add: ring_distribs)
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1060
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1061
lemma setsum_ereal_right_distrib:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1062
  fixes f :: "'a \<Rightarrow> ereal"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
  1063
  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
  1064
  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
  1065
59002
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1066
lemma setsum_ereal_left_distrib:
2c8b2fb54b88 cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
hoelzl
parents: 59000
diff changeset
  1067
  "(\<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
  1068
  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
  1069
61631
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1070
lemma setsum_left_distrib_ereal:
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1071
  "c \<ge> 0 \<Longrightarrow> setsum f A * ereal c = (\<Sum>x\<in>A. f x * c :: ereal)"
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1072
by(subst setsum_comp_morphism[where h="\<lambda>x. x * ereal c", symmetric])(simp_all add: distrib_left_ereal_nn)
4f7ef088c4ed add lemmas for extended nats and reals
Andreas Lochbihler
parents: 61610
diff changeset
  1073
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1074
lemma ereal_le_epsilon:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1075
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1076
  assumes "\<forall>e. 0 < e \<longrightarrow> x \<le> y + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1077
  shows "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1078
proof -
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1079
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1080
    assume a: "\<exists>r. y = ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1081
    then obtain r where r_def: "y = ereal r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1082
      by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1083
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1084
      assume "x = -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1085
      then have ?thesis by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1086
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1087
    moreover
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1088
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1089
      assume "x \<noteq> -\<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1090
      then obtain p where p_def: "x = ereal p"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1091
      using a assms[rule_format, of 1]
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1092
        by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1093
      {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1094
        fix e
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1095
        have "0 < e \<longrightarrow> p \<le> r + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1096
          using assms[rule_format, of "ereal e"] p_def r_def by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1097
      }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1098
      then have "p \<le> r"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1099
        apply (subst field_le_epsilon)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1100
        apply auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1101
        done
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1102
      then have ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1103
        using r_def p_def by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1104
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1105
    ultimately have ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1106
      by blast
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1107
  }
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1108
  moreover
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1109
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1110
    assume "y = -\<infinity> | y = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1111
    then have ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1112
      using assms[rule_format, of 1] by (cases x) auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1113
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1114
  ultimately show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1115
    by (cases y) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1116
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1117
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1118
lemma ereal_le_epsilon2:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1119
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1120
  assumes "\<forall>e. 0 < e \<longrightarrow> x \<le> y + ereal e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1121
  shows "x \<le> y"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1122
proof -
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1123
  {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1124
    fix e :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1125
    assume "e > 0"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1126
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1127
      assume "e = \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1128
      then have "x \<le> y + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1129
        by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1130
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1131
    moreover
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1132
    {
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1133
      assume "e \<noteq> \<infinity>"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1134
      then obtain r where "e = ereal r"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1135
        using \<open>e > 0\<close> by (cases e) auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1136
      then have "x \<le> y + e"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1137
        using assms[rule_format, of r] \<open>e>0\<close> by auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1138
    }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1139
    ultimately have "x \<le> y + e"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1140
      by blast
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1141
  }
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1142
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1143
    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
  1144
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1145
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1146
lemma ereal_le_real:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1147
  fixes x y :: ereal
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1148
  assumes "\<forall>z. x \<le> ereal z \<longrightarrow> y \<le> ereal z"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1149
  shows "y \<le> x"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1150
  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
  1151
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1152
lemma setprod_ereal_0:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1153
  fixes f :: "'a \<Rightarrow> ereal"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1154
  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
  1155
proof (cases "finite A")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1156
  case True
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1157
  then show ?thesis by (induct A) auto
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1158
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1159
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1160
  then show ?thesis by auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1161
qed
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1162
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1163
lemma setprod_ereal_pos:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1164
  fixes f :: "'a \<Rightarrow> ereal"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1165
  assumes pos: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1166
  shows "0 \<le> (\<Prod>i\<in>I. f i)"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1167
proof (cases "finite I")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1168
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1169
  from this pos show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1170
    by induct auto
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1171
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1172
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1173
  then show ?thesis by simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1174
qed
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1175
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1176
lemma setprod_PInf:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1177
  fixes f :: "'a \<Rightarrow> ereal"
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1178
  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
  1179
  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
  1180
proof (cases "finite I")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1181
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1182
  from this assms show ?thesis
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1183
  proof (induct I)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1184
    case (insert i I)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1185
    then have pos: "0 \<le> f i" "0 \<le> setprod f I"
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1186
      by (auto intro!: setprod_ereal_pos)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1187
    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
  1188
      by auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1189
    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
  1190
      using setprod_ereal_pos[of I f] pos
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1191
      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
  1192
    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
  1193
      using insert by (auto simp: setprod_ereal_0)
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1194
    finally show ?case .
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1195
  qed simp
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1196
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1197
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1198
  then show ?thesis by simp
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1199
qed
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1200
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1201
lemma setprod_ereal: "(\<Prod>i\<in>A. ereal (f i)) = ereal (setprod f A)"
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1202
proof (cases "finite A")
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1203
  case True
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1204
  then show ?thesis
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1205
    by induct (auto simp: one_ereal_def)
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1206
next
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1207
  case False
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1208
  then show ?thesis
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1209
    by (simp add: one_ereal_def)
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1210
qed
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1211
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
  1212
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1213
subsubsection \<open>Power\<close>
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1214
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1215
lemma ereal_power[simp]: "(ereal x) ^ n = ereal (x^n)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1216
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1217
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1218
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
  1219
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1220
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1221
lemma ereal_power_uminus[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1222
  fixes x :: ereal
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1223
  shows "(- x) ^ n = (if even n then x ^ n else - (x^n))"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1224
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1225
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1226
lemma ereal_power_numeral[simp]:
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 47082
diff changeset
  1227
  "(numeral num :: ereal) ^ n = ereal (numeral num ^ n)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1228
  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
  1229
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1230
lemma zero_le_power_ereal[simp]:
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1231
  fixes a :: ereal
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1232
  assumes "0 \<le> a"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1233
  shows "0 \<le> a ^ n"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1234
  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
  1235
53873
08594daabcd9 tuned proofs;
wenzelm
parents: 53381
diff changeset
  1236
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
  1237
subsubsection \<open>Subtraction\<close>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1238
43920