src/HOL/Library/Extended_Real.thy
author hoelzl
Tue, 19 Jul 2011 14:38:29 +0200
changeset 43923 ab93d0190a5d
parent 43920 cedb5cb948fd
child 43924 1165fe965da8
permissions -rw-r--r--
add ereal to typeclass infinity
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
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
     8
header {* Extended real number line *}
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
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    11
  imports Complex_Main Extended_Nat
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
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    14
text {*
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    15
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    16
For more lemmas about the extended real numbers go to
42600
604661fb94eb fixing typo
bulwahn
parents: 41983
diff changeset
    17
  @{text "src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy"}
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    18
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    19
*}
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    20
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    21
lemma (in complete_lattice) atLeast_eq_UNIV_iff: "{x..} = UNIV \<longleftrightarrow> x = bot"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    22
proof
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    23
  assume "{x..} = UNIV"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    24
  show "x = bot"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    25
  proof (rule ccontr)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    26
    assume "x \<noteq> bot" then have "bot \<notin> {x..}" by (simp add: le_less)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    27
    then show False using `{x..} = UNIV` by simp
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    28
  qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    29
qed auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    30
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    31
lemma SUPR_pair:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    32
  "(SUP i : A. SUP j : B. f i j) = (SUP p : A \<times> B. f (fst p) (snd p))"
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    33
  by (rule antisym) (auto intro!: SUP_leI le_SUPI2)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    34
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    35
lemma INFI_pair:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    36
  "(INF i : A. INF j : B. f i j) = (INF p : A \<times> B. f (fst p) (snd p))"
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    37
  by (rule antisym) (auto intro!: le_INFI INF_leI2)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    38
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    39
subsection {* Definition and basic properties *}
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    40
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    41
datatype ereal = ereal real | PInfty | MInfty
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    42
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    43
instantiation ereal :: uminus
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    44
begin
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    45
  fun uminus_ereal where
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    46
    "- (ereal r) = ereal (- r)"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    47
  | "- PInfty = MInfty"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    48
  | "- MInfty = PInfty"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    49
  instance ..
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    50
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    51
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    52
instantiation ereal :: infinity
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    53
begin
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    54
  definition "(\<infinity>::ereal) = PInfty"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    55
  instance ..
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    56
end
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    57
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    58
definition "ereal_of_enat n = (case n of Fin n \<Rightarrow> ereal (real n) | \<infinity> \<Rightarrow> \<infinity>)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    59
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    60
declare [[coercion "ereal :: real \<Rightarrow> ereal"]]
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    61
declare [[coercion "ereal_of_enat :: enat \<Rightarrow> ereal"]]
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    62
declare [[coercion "(\<lambda>n. ereal (of_nat n)) :: nat \<Rightarrow> ereal"]]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    63
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    64
lemma ereal_uminus_uminus[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    65
  fixes a :: ereal shows "- (- a) = a"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    66
  by (cases a) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    67
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    68
lemma
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    69
  shows PInfty_eq_infinity[simp]: "PInfty = \<infinity>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    70
    and MInfty_eq_minfinity[simp]: "MInfty = - \<infinity>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    71
    and MInfty_neq_PInfty[simp]: "\<infinity> \<noteq> - (\<infinity>::ereal)" "- \<infinity> \<noteq> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    72
    and MInfty_neq_ereal[simp]: "ereal r \<noteq> - \<infinity>" "- \<infinity> \<noteq> ereal r"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    73
    and PInfty_neq_ereal[simp]: "ereal r \<noteq> \<infinity>" "\<infinity> \<noteq> ereal r"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    74
    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
    75
    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
    76
  by (simp_all add: infinity_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    77
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    78
lemma inj_ereal[simp]: "inj_on ereal A"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
    79
  unfolding inj_on_def by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    80
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    81
lemma ereal_cases[case_names real PInf MInf, cases type: ereal]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    82
  assumes "\<And>r. x = ereal r \<Longrightarrow> P"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    83
  assumes "x = \<infinity> \<Longrightarrow> P"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    84
  assumes "x = -\<infinity> \<Longrightarrow> P"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    85
  shows P
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    86
  using assms by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    87
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    88
lemmas ereal2_cases = ereal_cases[case_product ereal_cases]
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    89
lemmas ereal3_cases = ereal2_cases[case_product ereal_cases]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    90
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    91
lemma ereal_uminus_eq_iff[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    92
  fixes a b :: ereal shows "-a = -b \<longleftrightarrow> a = b"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    93
  by (cases rule: ereal2_cases[of a b]) simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    94
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    95
function of_ereal :: "ereal \<Rightarrow> real" where
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    96
"of_ereal (ereal r) = r" |
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    97
"of_ereal \<infinity> = 0" |
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    98
"of_ereal (-\<infinity>) = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
    99
  by (auto intro: ereal_cases)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   100
termination proof qed (rule wf_empty)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   101
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   102
defs (overloaded)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   103
  real_of_ereal_def [code_unfold]: "real \<equiv> of_ereal"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   104
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   105
lemma real_of_ereal[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   106
    "real (- x :: ereal) = - (real x)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   107
    "real (ereal r) = r"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   108
    "real (\<infinity>::ereal) = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   109
  by (cases x) (simp_all add: real_of_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   110
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   111
lemma range_ereal[simp]: "range ereal = UNIV - {\<infinity>, -\<infinity>}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   112
proof safe
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   113
  fix x assume "x \<notin> range ereal" "x \<noteq> \<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   114
  then show "x = -\<infinity>" by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   115
qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   116
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   117
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
   118
proof safe
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   119
  fix x :: ereal show "x \<in> range uminus" 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
   120
qed auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   121
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   122
instantiation ereal :: number
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   123
begin
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   124
definition [simp]: "number_of x = ereal (number_of x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   125
instance proof qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   126
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   127
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   128
instantiation ereal :: abs
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   129
begin
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   130
  function abs_ereal where
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   131
    "\<bar>ereal r\<bar> = ereal \<bar>r\<bar>"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   132
  | "\<bar>-\<infinity>\<bar> = (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   133
  | "\<bar>\<infinity>\<bar> = (\<infinity>::ereal)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   134
  by (auto intro: ereal_cases)
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   135
  termination proof qed (rule wf_empty)
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   136
  instance ..
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   137
end
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   138
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   139
lemma abs_eq_infinity_cases[elim!]: "\<lbrakk> \<bar>x :: ereal\<bar> = \<infinity> ; x = \<infinity> \<Longrightarrow> P ; x = -\<infinity> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   140
  by (cases x) auto
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   141
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   142
lemma abs_neq_infinity_cases[elim!]: "\<lbrakk> \<bar>x :: ereal\<bar> \<noteq> \<infinity> ; \<And>r. x = ereal r \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   143
  by (cases x) auto
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   144
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   145
lemma abs_ereal_uminus[simp]: "\<bar>- x\<bar> = \<bar>x::ereal\<bar>"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   146
  by (cases x) auto
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   147
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   148
subsubsection "Addition"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   149
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   150
instantiation ereal :: comm_monoid_add
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   151
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   152
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   153
definition "0 = ereal 0"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   154
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   155
function plus_ereal where
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   156
"ereal r + ereal p = ereal (r + p)" |
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   157
"\<infinity> + a = (\<infinity>::ereal)" |
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   158
"a + \<infinity> = (\<infinity>::ereal)" |
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   159
"ereal r + -\<infinity> = - \<infinity>" |
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   160
"-\<infinity> + ereal p = -(\<infinity>::ereal)" |
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   161
"-\<infinity> + -\<infinity> = -(\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   162
proof -
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   163
  case (goal1 P x)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   164
  moreover then obtain a b where "x = (a, b)" by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   165
  ultimately show P
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   166
   by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   167
qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   168
termination proof qed (rule wf_empty)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   169
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   170
lemma Infty_neq_0[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   171
  "(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   172
  "-(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> -(\<infinity>::ereal)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   173
  by (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   174
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   175
lemma ereal_eq_0[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   176
  "ereal r = 0 \<longleftrightarrow> r = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   177
  "0 = ereal r \<longleftrightarrow> r = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   178
  unfolding zero_ereal_def by simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   179
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   180
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   181
proof
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   182
  fix a :: ereal show "0 + a = a"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   183
    by (cases a) (simp_all add: zero_ereal_def)
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   184
  fix b :: ereal show "a + b = b + a"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   185
    by (cases rule: ereal2_cases[of a b]) simp_all
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   186
  fix c :: ereal show "a + b + c = a + (b + c)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   187
    by (cases rule: ereal3_cases[of a b c]) simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   188
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   189
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   190
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   191
lemma real_of_ereal_0[simp]: "real (0::ereal) = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   192
  unfolding real_of_ereal_def zero_ereal_def by simp
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   193
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   194
lemma abs_ereal_zero[simp]: "\<bar>0\<bar> = (0::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   195
  unfolding zero_ereal_def abs_ereal.simps by simp
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   196
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   197
lemma ereal_uminus_zero[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   198
  "- 0 = (0::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   199
  by (simp add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   200
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   201
lemma ereal_uminus_zero_iff[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   202
  fixes a :: ereal shows "-a = 0 \<longleftrightarrow> a = 0"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   203
  by (cases a) simp_all
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_plus_eq_PInfty[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   206
  fixes a b :: ereal shows "a + b = \<infinity> \<longleftrightarrow> a = \<infinity> \<or> b = \<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   207
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   208
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   209
lemma ereal_plus_eq_MInfty[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   210
  fixes a b :: ereal shows "a + b = -\<infinity> \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   211
    (a = -\<infinity> \<or> b = -\<infinity>) \<and> a \<noteq> \<infinity> \<and> b \<noteq> \<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   212
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   213
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   214
lemma ereal_add_cancel_left:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   215
  fixes a b :: ereal assumes "a \<noteq> -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   216
  shows "a + b = a + c \<longleftrightarrow> (a = \<infinity> \<or> b = c)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   217
  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
   218
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   219
lemma ereal_add_cancel_right:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   220
  fixes a b :: ereal assumes "a \<noteq> -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   221
  shows "b + a = c + a \<longleftrightarrow> (a = \<infinity> \<or> b = c)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   222
  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
   223
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   224
lemma ereal_real:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   225
  "ereal (real x) = (if \<bar>x\<bar> = \<infinity> then 0 else x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   226
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   227
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   228
lemma real_of_ereal_add:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   229
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   230
  shows "real (a + b) = (if (\<bar>a\<bar> = \<infinity>) \<and> (\<bar>b\<bar> = \<infinity>) \<or> (\<bar>a\<bar> \<noteq> \<infinity>) \<and> (\<bar>b\<bar> \<noteq> \<infinity>) then real a + real b else 0)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   231
  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
   232
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   233
subsubsection "Linear order on @{typ ereal}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   234
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   235
instantiation ereal :: linorder
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   236
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   237
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   238
function less_ereal where
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   239
"   ereal x < ereal y     \<longleftrightarrow> x < y" |
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   240
"(\<infinity>::ereal) < a           \<longleftrightarrow> False" |
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   241
"         a < -(\<infinity>::ereal) \<longleftrightarrow> False" |
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   242
"ereal x    < \<infinity>           \<longleftrightarrow> True" |
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   243
"        -\<infinity> < ereal r     \<longleftrightarrow> True" |
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   244
"        -\<infinity> < (\<infinity>::ereal) \<longleftrightarrow> True"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   245
proof -
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   246
  case (goal1 P x)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   247
  moreover then obtain a b where "x = (a,b)" by (cases x) auto
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   248
  ultimately show P by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   249
qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   250
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   251
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   252
definition "x \<le> (y::ereal) \<longleftrightarrow> x < y \<or> x = y"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   253
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   254
lemma ereal_infty_less[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   255
  fixes x :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   256
  shows "x < \<infinity> \<longleftrightarrow> (x \<noteq> \<infinity>)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   257
    "-\<infinity> < x \<longleftrightarrow> (x \<noteq> -\<infinity>)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   258
  by (cases x, simp_all) (cases x, simp_all)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   259
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   260
lemma ereal_infty_less_eq[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   261
  fixes x :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   262
  shows "\<infinity> \<le> x \<longleftrightarrow> x = \<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   263
  "x \<le> -\<infinity> \<longleftrightarrow> x = -\<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   264
  by (auto simp add: less_eq_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   265
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   266
lemma ereal_less[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   267
  "ereal r < 0 \<longleftrightarrow> (r < 0)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   268
  "0 < ereal r \<longleftrightarrow> (0 < r)"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   269
  "0 < (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   270
  "-(\<infinity>::ereal) < 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   271
  by (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   272
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   273
lemma ereal_less_eq[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   274
  "x \<le> (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   275
  "-(\<infinity>::ereal) \<le> x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   276
  "ereal r \<le> ereal p \<longleftrightarrow> r \<le> p"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   277
  "ereal r \<le> 0 \<longleftrightarrow> r \<le> 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   278
  "0 \<le> ereal r \<longleftrightarrow> 0 \<le> r"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   279
  by (auto simp add: less_eq_ereal_def zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   280
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   281
lemma ereal_infty_less_eq2:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   282
  "a \<le> b \<Longrightarrow> a = \<infinity> \<Longrightarrow> b = (\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   283
  "a \<le> b \<Longrightarrow> b = -\<infinity> \<Longrightarrow> a = -(\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   284
  by simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   285
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   286
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   287
proof
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   288
  fix x :: ereal show "x \<le> x"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   289
    by (cases x) simp_all
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   290
  fix y :: ereal show "x < y \<longleftrightarrow> x \<le> y \<and> \<not> y \<le> x"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   291
    by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   292
  show "x \<le> y \<or> y \<le> x "
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   293
    by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   294
  { assume "x \<le> y" "y \<le> x" then show "x = y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   295
    by (cases rule: ereal2_cases[of x y]) auto }
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   296
  { fix z assume "x \<le> y" "y \<le> z" then show "x \<le> z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   297
    by (cases rule: ereal3_cases[of x y z]) auto }
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   298
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   299
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   300
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   301
instance ereal :: ordered_ab_semigroup_add
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   302
proof
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   303
  fix a b c :: ereal assume "a \<le> b" then show "c + a \<le> c + b"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   304
    by (cases rule: ereal3_cases[of a b c]) auto
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   305
qed
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   306
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   307
lemma real_of_ereal_positive_mono:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   308
  fixes x y :: ereal shows "\<lbrakk>0 \<le> x; x \<le> y; y \<noteq> \<infinity>\<rbrakk> \<Longrightarrow> real x \<le> real y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   309
  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
   310
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   311
lemma ereal_MInfty_lessI[intro, simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   312
  fixes a :: ereal shows "a \<noteq> -\<infinity> \<Longrightarrow> -\<infinity> < a"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   313
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   314
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   315
lemma ereal_less_PInfty[intro, simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   316
  fixes a :: ereal shows "a \<noteq> \<infinity> \<Longrightarrow> a < \<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   317
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   318
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   319
lemma ereal_less_ereal_Ex:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   320
  fixes a b :: ereal
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   321
  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
   322
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   323
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   324
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
   325
proof (cases x)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   326
  case (real r) then show ?thesis
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
   327
    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
   328
qed simp_all
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   329
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   330
lemma ereal_add_mono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   331
  fixes a b c d :: ereal assumes "a \<le> b" "c \<le> d" shows "a + c \<le> b + d"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   332
  using assms
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   333
  apply (cases a)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   334
  apply (cases rule: ereal3_cases[of b c d], auto)
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   335
  apply (cases rule: ereal3_cases[of b c d], auto)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   336
  done
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   337
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   338
lemma ereal_minus_le_minus[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   339
  fixes a b :: ereal shows "- a \<le> - b \<longleftrightarrow> b \<le> a"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   340
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   341
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   342
lemma ereal_minus_less_minus[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   343
  fixes a b :: ereal shows "- a < - b \<longleftrightarrow> b < a"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   344
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   345
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   346
lemma ereal_le_real_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   347
  "x \<le> real y \<longleftrightarrow> ((\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> ereal x \<le> y) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> x \<le> 0))"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   348
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   349
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   350
lemma real_le_ereal_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   351
  "real y \<le> x \<longleftrightarrow> ((\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> y \<le> ereal x) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> 0 \<le> x))"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   352
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   353
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   354
lemma ereal_less_real_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   355
  "x < real y \<longleftrightarrow> ((\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> ereal x < y) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> x < 0))"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   356
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   357
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   358
lemma real_less_ereal_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   359
  "real y < x \<longleftrightarrow> ((\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> y < ereal x) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> 0 < x))"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   360
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   361
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   362
lemma real_of_ereal_pos:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   363
  fixes x :: ereal shows "0 \<le> x \<Longrightarrow> 0 \<le> real x" by (cases x) auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   364
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   365
lemmas real_of_ereal_ord_simps =
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   366
  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
   367
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   368
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
   369
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   370
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   371
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
   372
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   373
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   374
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
   375
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   376
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   377
lemma real_of_ereal_le_0[simp]: "real (x :: ereal) \<le> 0 \<longleftrightarrow> (x \<le> 0 \<or> x = \<infinity>)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   378
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   379
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   380
lemma abs_real_of_ereal[simp]: "\<bar>real (x :: ereal)\<bar> = real \<bar>x\<bar>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   381
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   382
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   383
lemma zero_less_real_of_ereal:
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   384
  fixes x :: ereal shows "0 < real x \<longleftrightarrow> (0 < x \<and> x \<noteq> \<infinity>)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   385
  by (cases x) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   386
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   387
lemma ereal_0_le_uminus_iff[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   388
  fixes a :: ereal shows "0 \<le> -a \<longleftrightarrow> a \<le> 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   389
  by (cases rule: ereal2_cases[of a]) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   390
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   391
lemma ereal_uminus_le_0_iff[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   392
  fixes a :: ereal shows "-a \<le> 0 \<longleftrightarrow> 0 \<le> a"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   393
  by (cases rule: ereal2_cases[of a]) auto
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   394
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   395
lemma ereal_dense2: "x < y \<Longrightarrow> \<exists>z. x < ereal z \<and> ereal z < y"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   396
  using lt_ex gt_ex dense by (cases x y rule: ereal2_cases) auto
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   397
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   398
lemma ereal_dense:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   399
  fixes x y :: ereal assumes "x < y"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   400
  shows "\<exists>z. x < z \<and> z < y"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   401
  using ereal_dense2[OF `x < y`] by blast
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   402
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   403
lemma ereal_add_strict_mono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   404
  fixes a b c d :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   405
  assumes "a = b" "0 \<le> a" "a \<noteq> \<infinity>" "c < d"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   406
  shows "a + c < b + d"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   407
  using assms 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
   408
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   409
lemma ereal_less_add: 
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   410
  fixes a b c :: ereal shows "\<bar>a\<bar> \<noteq> \<infinity> \<Longrightarrow> c < b \<Longrightarrow> a + c < a + b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   411
  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
   412
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   413
lemma ereal_uminus_eq_reorder: "- a = b \<longleftrightarrow> a = (-b::ereal)" by auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   414
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   415
lemma ereal_uminus_less_reorder: "- a < b \<longleftrightarrow> -b < (a::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   416
  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
   417
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   418
lemma ereal_uminus_le_reorder: "- a \<le> b \<longleftrightarrow> -b \<le> (a::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   419
  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
   420
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   421
lemmas ereal_uminus_reorder =
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   422
  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
   423
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   424
lemma ereal_bot:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   425
  fixes x :: ereal assumes "\<And>B. x \<le> ereal B" shows "x = - \<infinity>"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   426
proof (cases x)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   427
  case (real r) with assms[of "r - 1"] show ?thesis by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   428
next case PInf with assms[of 0] show ?thesis by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   429
next case MInf then show ?thesis by simp
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   430
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   431
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   432
lemma ereal_top:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   433
  fixes x :: ereal assumes "\<And>B. x \<ge> ereal B" shows "x = \<infinity>"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   434
proof (cases x)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   435
  case (real r) with assms[of "r + 1"] show ?thesis by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   436
next case MInf with assms[of 0] show ?thesis by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   437
next case PInf then show ?thesis by simp
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   438
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   439
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   440
lemma
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   441
  shows ereal_max[simp]: "ereal (max x y) = max (ereal x) (ereal y)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   442
    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
   443
  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
   444
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   445
lemma ereal_max_0: "max 0 (ereal r) = ereal (max 0 r)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   446
  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
   447
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   448
lemma
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   449
  fixes f :: "nat \<Rightarrow> ereal"
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   450
  shows incseq_uminus[simp]: "incseq (\<lambda>x. - f x) \<longleftrightarrow> decseq f"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   451
  and decseq_uminus[simp]: "decseq (\<lambda>x. - f x) \<longleftrightarrow> incseq f"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   452
  unfolding decseq_def incseq_def by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   453
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   454
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
   455
  unfolding incseq_def by auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   456
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   457
lemma ereal_add_nonneg_nonneg:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   458
  fixes a b :: ereal 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
   459
  using add_mono[of 0 a 0 b] by simp
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   460
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   461
lemma image_eqD: "f ` A = B \<Longrightarrow> (\<forall>x\<in>A. f x \<in> B)"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   462
  by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   463
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   464
lemma incseq_setsumI:
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   465
  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
   466
  assumes "\<And>i. 0 \<le> f i"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   467
  shows "incseq (\<lambda>i. setsum f {..< i})"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   468
proof (intro incseq_SucI)
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   469
  fix n have "setsum f {..< n} + 0 \<le> setsum f {..<n} + f n"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   470
    using assms by (rule add_left_mono)
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   471
  then show "setsum f {..< n} \<le> setsum f {..< Suc n}"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   472
    by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   473
qed
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   474
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   475
lemma incseq_setsumI2:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   476
  fixes f :: "'i \<Rightarrow> nat \<Rightarrow> 'a::{comm_monoid_add, ordered_ab_semigroup_add}"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   477
  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
   478
  shows "incseq (\<lambda>i. \<Sum>n\<in>A. f n i)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   479
  using assms unfolding incseq_def by (auto intro: setsum_mono)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   480
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   481
subsubsection "Multiplication"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   482
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   483
instantiation ereal :: "{comm_monoid_mult, sgn}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   484
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   485
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   486
definition "1 = ereal 1"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   487
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   488
function sgn_ereal where
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   489
  "sgn (ereal r) = ereal (sgn r)"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   490
| "sgn (\<infinity>::ereal) = 1"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   491
| "sgn (-\<infinity>::ereal) = -1"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   492
by (auto intro: ereal_cases)
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   493
termination proof qed (rule wf_empty)
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   494
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   495
function times_ereal where
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   496
"ereal r * ereal p = ereal (r * p)" |
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   497
"ereal r * \<infinity> = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)" |
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   498
"\<infinity> * ereal r = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)" |
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   499
"ereal r * -\<infinity> = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)" |
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   500
"-\<infinity> * ereal r = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)" |
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   501
"(\<infinity>::ereal) * \<infinity> = \<infinity>" |
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   502
"-(\<infinity>::ereal) * \<infinity> = -\<infinity>" |
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   503
"(\<infinity>::ereal) * -\<infinity> = -\<infinity>" |
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   504
"-(\<infinity>::ereal) * -\<infinity> = \<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   505
proof -
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   506
  case (goal1 P x)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   507
  moreover then obtain a b where "x = (a, b)" by (cases x) auto
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   508
  ultimately show P by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   509
qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   510
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   511
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   512
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   513
proof
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   514
  fix a :: ereal show "1 * a = a"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   515
    by (cases a) (simp_all add: one_ereal_def)
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   516
  fix b :: ereal show "a * b = b * a"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   517
    by (cases rule: ereal2_cases[of a b]) simp_all
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   518
  fix c :: ereal show "a * b * c = a * (b * c)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   519
    by (cases rule: ereal3_cases[of a b c])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   520
       (simp_all add: zero_ereal_def zero_less_mult_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   521
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   522
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   523
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   524
lemma real_of_ereal_le_1:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   525
  fixes a :: ereal shows "a \<le> 1 \<Longrightarrow> real a \<le> 1"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   526
  by (cases a) (auto simp: one_ereal_def)
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   527
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   528
lemma abs_ereal_one[simp]: "\<bar>1\<bar> = (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   529
  unfolding one_ereal_def by simp
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   530
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   531
lemma ereal_mult_zero[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   532
  fixes a :: ereal shows "a * 0 = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   533
  by (cases a) (simp_all add: zero_ereal_def)
41973
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 ereal_zero_mult[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   536
  fixes a :: ereal shows "0 * a = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   537
  by (cases a) (simp_all add: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   538
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   539
lemma ereal_m1_less_0[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   540
  "-(1::ereal) < 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   541
  by (simp add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   542
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   543
lemma ereal_zero_m1[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   544
  "1 \<noteq> (0::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   545
  by (simp add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   546
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   547
lemma ereal_times_0[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   548
  fixes x :: ereal shows "0 * x = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   549
  by (cases x) (auto simp: zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   550
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   551
lemma ereal_times[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   552
  "1 \<noteq> (\<infinity>::ereal)" "(\<infinity>::ereal) \<noteq> 1"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   553
  "1 \<noteq> -(\<infinity>::ereal)" "-(\<infinity>::ereal) \<noteq> 1"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   554
  by (auto simp add: times_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   555
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   556
lemma ereal_plus_1[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   557
  "1 + ereal r = ereal (r + 1)" "ereal r + 1 = ereal (r + 1)"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   558
  "1 + -(\<infinity>::ereal) = -\<infinity>" "-(\<infinity>::ereal) + 1 = -\<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   559
  unfolding one_ereal_def by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   560
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   561
lemma ereal_zero_times[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   562
  fixes a b :: ereal shows "a * b = 0 \<longleftrightarrow> a = 0 \<or> b = 0"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   563
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   564
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   565
lemma ereal_mult_eq_PInfty[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   566
  shows "a * b = (\<infinity>::ereal) \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   567
    (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
   568
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   569
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   570
lemma ereal_mult_eq_MInfty[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   571
  shows "a * b = -(\<infinity>::ereal) \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   572
    (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
   573
  by (cases rule: ereal2_cases[of a b]) auto
41973
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 ereal_0_less_1[simp]: "0 < (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   576
  by (simp_all add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   577
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   578
lemma ereal_zero_one[simp]: "0 \<noteq> (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   579
  by (simp_all add: zero_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   580
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   581
lemma ereal_mult_minus_left[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   582
  fixes a b :: ereal shows "-a * b = - (a * b)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   583
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   584
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   585
lemma ereal_mult_minus_right[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   586
  fixes a b :: ereal shows "a * -b = - (a * b)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   587
  by (cases rule: ereal2_cases[of a b]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   588
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   589
lemma ereal_mult_infty[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   590
  "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
   591
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   592
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   593
lemma ereal_infty_mult[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   594
  "(\<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
   595
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   596
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   597
lemma ereal_mult_strict_right_mono:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   598
  assumes "a < b" and "0 < c" "c < (\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   599
  shows "a * c < b * c"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   600
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   601
  by (cases rule: ereal3_cases[of a b c])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   602
     (auto simp: zero_le_mult_iff ereal_less_PInfty)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   603
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   604
lemma ereal_mult_strict_left_mono:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   605
  "\<lbrakk> a < b ; 0 < c ; c < (\<infinity>::ereal)\<rbrakk> \<Longrightarrow> c * a < c * b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   606
  using ereal_mult_strict_right_mono by (simp add: mult_commute[of c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   607
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   608
lemma ereal_mult_right_mono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   609
  fixes a b c :: ereal shows "\<lbrakk>a \<le> b; 0 \<le> c\<rbrakk> \<Longrightarrow> a*c \<le> b*c"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   610
  using assms
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   611
  apply (cases "c = 0") apply simp
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   612
  by (cases rule: ereal3_cases[of a b c])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   613
     (auto simp: zero_le_mult_iff ereal_less_PInfty)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   614
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   615
lemma ereal_mult_left_mono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   616
  fixes a b c :: ereal shows "\<lbrakk>a \<le> b; 0 \<le> c\<rbrakk> \<Longrightarrow> c * a \<le> c * b"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   617
  using ereal_mult_right_mono by (simp add: mult_commute[of c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   618
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   619
lemma zero_less_one_ereal[simp]: "0 \<le> (1::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   620
  by (simp add: one_ereal_def zero_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   621
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   622
lemma ereal_0_le_mult[simp]: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a * (b :: ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   623
  by (cases rule: ereal2_cases[of a b]) (auto simp: mult_nonneg_nonneg)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   624
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   625
lemma ereal_right_distrib:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   626
  fixes r a b :: ereal shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> r * (a + b) = r * a + r * b"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   627
  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
   628
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   629
lemma ereal_left_distrib:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   630
  fixes r a b :: ereal shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> (a + b) * r = a * r + b * r"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   631
  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
   632
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   633
lemma ereal_mult_le_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   634
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   635
  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
   636
  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
   637
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   638
lemma ereal_zero_le_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   639
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   640
  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
   641
  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
   642
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   643
lemma ereal_mult_less_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   644
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   645
  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
   646
  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
   647
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   648
lemma ereal_zero_less_0_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   649
  fixes a b :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   650
  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
   651
  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
   652
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   653
lemma ereal_distrib:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   654
  fixes a b c :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   655
  assumes "a \<noteq> \<infinity> \<or> b \<noteq> -\<infinity>" "a \<noteq> -\<infinity> \<or> b \<noteq> \<infinity>" "\<bar>c\<bar> \<noteq> \<infinity>"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   656
  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
   657
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   658
  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
   659
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   660
lemma ereal_le_epsilon:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   661
  fixes x y :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   662
  assumes "ALL e. 0 < e --> x <= y + e"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   663
  shows "x <= y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   664
proof-
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   665
{ assume a: "EX r. y = ereal r"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   666
  from this obtain r where r_def: "y = ereal r" by auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   667
  { assume "x=(-\<infinity>)" hence ?thesis by auto }
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   668
  moreover
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   669
  { assume "~(x=(-\<infinity>))"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   670
    from this obtain p where p_def: "x = ereal p"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   671
    using a assms[rule_format, of 1] by (cases x) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   672
    { fix e have "0 < e --> p <= r + e"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   673
      using assms[rule_format, of "ereal e"] p_def r_def by auto }
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   674
    hence "p <= r" apply (subst field_le_epsilon) by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   675
    hence ?thesis using r_def p_def by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   676
  } ultimately have ?thesis by blast
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   677
}
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   678
moreover
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   679
{ assume "y=(-\<infinity>) | y=\<infinity>" hence ?thesis
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   680
    using assms[rule_format, of 1] by (cases x) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   681
} ultimately show ?thesis by (cases y) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   682
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   683
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   684
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   685
lemma ereal_le_epsilon2:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   686
  fixes x y :: ereal
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   687
  assumes "ALL e. 0 < e --> x <= y + ereal e"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   688
  shows "x <= y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   689
proof-
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   690
{ fix e :: ereal assume "e>0"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   691
  { assume "e=\<infinity>" hence "x<=y+e" by auto }
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   692
  moreover
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   693
  { assume "e~=\<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   694
    from this obtain r where "e = ereal r" using `e>0` apply (cases e) by auto
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   695
    hence "x<=y+e" using assms[rule_format, of r] `e>0` by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   696
  } ultimately have "x<=y+e" by blast
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   697
} from this show ?thesis 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
   698
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   699
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   700
lemma ereal_le_real:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   701
  fixes x y :: ereal
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   702
  assumes "ALL z. x <= ereal z --> y <= ereal z"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   703
  shows "y <= x"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   704
by (metis assms ereal_bot ereal_cases ereal_infty_less_eq ereal_less_eq linorder_le_cases)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   705
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   706
lemma ereal_le_ereal:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   707
  fixes x y :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   708
  assumes "\<And>B. B < x \<Longrightarrow> B <= y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   709
  shows "x <= y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   710
by (metis assms ereal_dense leD linorder_le_less_linear)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   711
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   712
lemma ereal_ge_ereal:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   713
  fixes x y :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   714
  assumes "ALL B. B>x --> B >= y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   715
  shows "x >= y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   716
by (metis assms ereal_dense leD linorder_le_less_linear)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   717
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   718
lemma setprod_ereal_0:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   719
  fixes f :: "'a \<Rightarrow> ereal"
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   720
  shows "(\<Prod>i\<in>A. f i) = 0 \<longleftrightarrow> (finite A \<and> (\<exists>i\<in>A. f i = 0))"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   721
proof cases
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   722
  assume "finite A"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   723
  then show ?thesis by (induct A) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   724
qed auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   725
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   726
lemma setprod_ereal_pos:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   727
  fixes f :: "'a \<Rightarrow> ereal" assumes pos: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" shows "0 \<le> (\<Prod>i\<in>I. f i)"
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   728
proof cases
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   729
  assume "finite I" from this pos show ?thesis by induct auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   730
qed simp
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   731
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   732
lemma setprod_PInf:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   733
  fixes f :: "'a \<Rightarrow> ereal"
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   734
  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
   735
  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)"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   736
proof cases
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   737
  assume "finite I" from this assms show ?thesis
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   738
  proof (induct I)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   739
    case (insert i I)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   740
    then have pos: "0 \<le> f i" "0 \<le> setprod f I" by (auto intro!: setprod_ereal_pos)
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   741
    from insert have "(\<Prod>j\<in>insert i I. f j) = \<infinity> \<longleftrightarrow> setprod f I * f i = \<infinity>" by auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   742
    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
   743
      using setprod_ereal_pos[of I f] pos
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   744
      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
   745
    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
   746
      using insert by (auto simp: setprod_ereal_0)
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   747
    finally show ?case .
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   748
  qed simp
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   749
qed simp
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   750
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   751
lemma setprod_ereal: "(\<Prod>i\<in>A. ereal (f i)) = ereal (setprod f A)"
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   752
proof cases
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   753
  assume "finite A" then show ?thesis
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   754
    by induct (auto simp: one_ereal_def)
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   755
qed (simp add: one_ereal_def)
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   756
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   757
subsubsection {* Power *}
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   758
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   759
instantiation ereal :: power
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   760
begin
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   761
primrec power_ereal where
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   762
  "power_ereal x 0 = 1" |
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   763
  "power_ereal x (Suc n) = x * x ^ n"
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   764
instance ..
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   765
end
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   766
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   767
lemma ereal_power[simp]: "(ereal x) ^ n = ereal (x^n)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   768
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   769
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   770
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
   771
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   772
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   773
lemma ereal_power_uminus[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   774
  fixes x :: ereal
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   775
  shows "(- x) ^ n = (if even n then x ^ n else - (x^n))"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   776
  by (induct n) (auto simp: one_ereal_def)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   777
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   778
lemma ereal_power_number_of[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   779
  "(number_of num :: ereal) ^ n = ereal (number_of num ^ n)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   780
  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
   781
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   782
lemma zero_le_power_ereal[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   783
  fixes a :: ereal assumes "0 \<le> a"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   784
  shows "0 \<le> a ^ n"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   785
  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
   786
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   787
subsubsection {* Subtraction *}
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   788
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   789
lemma ereal_minus_minus_image[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   790
  fixes S :: "ereal set"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   791
  shows "uminus ` uminus ` S = S"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   792
  by (auto simp: image_iff)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   793
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   794
lemma ereal_uminus_lessThan[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   795
  fixes a :: ereal shows "uminus ` {..<a} = {-a<..}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   796
proof (safe intro!: image_eqI)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   797
  fix x assume "-a < x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   798
  then have "- x < - (- a)" by (simp del: ereal_uminus_uminus)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   799
  then show "- x < a" by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   800
qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   801
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   802
lemma ereal_uminus_greaterThan[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   803
  "uminus ` {(a::ereal)<..} = {..<-a}"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   804
  by (metis ereal_uminus_lessThan ereal_uminus_uminus
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   805
            ereal_minus_minus_image)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   806
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   807
instantiation ereal :: minus
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   808
begin
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   809
definition "x - y = x + -(y::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   810
instance ..
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   811
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   812
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   813
lemma ereal_minus[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   814
  "ereal r - ereal p = ereal (r - p)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   815
  "-\<infinity> - ereal r = -\<infinity>"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   816
  "ereal r - \<infinity> = -\<infinity>"
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   817
  "(\<infinity>::ereal) - x = \<infinity>"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   818
  "-(\<infinity>::ereal) - \<infinity> = -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   819
  "x - -y = x + y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   820
  "x - 0 = x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   821
  "0 - x = -x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   822
  by (simp_all add: minus_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   823
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   824
lemma ereal_x_minus_x[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   825
  "x - x = (if \<bar>x\<bar> = \<infinity> then \<infinity> else 0::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   826
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   827
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   828
lemma ereal_eq_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   829
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   830
  shows "x = z - y \<longleftrightarrow>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   831
    (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x + y = z) \<and>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   832
    (y = -\<infinity> \<longrightarrow> x = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   833
    (y = \<infinity> \<longrightarrow> z = \<infinity> \<longrightarrow> x = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   834
    (y = \<infinity> \<longrightarrow> z \<noteq> \<infinity> \<longrightarrow> x = -\<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   835
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   836
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   837
lemma ereal_eq_minus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   838
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   839
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x = z - y \<longleftrightarrow> x + y = z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   840
  by (auto simp: ereal_eq_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   841
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   842
lemma ereal_less_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   843
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   844
  shows "x < z - y \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   845
    (y = \<infinity> \<longrightarrow> z = \<infinity> \<and> x \<noteq> \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   846
    (y = -\<infinity> \<longrightarrow> x \<noteq> \<infinity>) \<and>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   847
    (\<bar>y\<bar> \<noteq> \<infinity>\<longrightarrow> x + y < z)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   848
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   849
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   850
lemma ereal_less_minus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   851
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   852
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x < z - y \<longleftrightarrow> x + y < z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   853
  by (auto simp: ereal_less_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   854
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   855
lemma ereal_le_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   856
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   857
  shows "x \<le> z - y \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   858
    (y = \<infinity> \<longrightarrow> z \<noteq> \<infinity> \<longrightarrow> x = -\<infinity>) \<and>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   859
    (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x + y \<le> z)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   860
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   861
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   862
lemma ereal_le_minus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   863
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   864
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x \<le> z - y \<longleftrightarrow> x + y \<le> z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   865
  by (auto simp: ereal_le_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   866
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   867
lemma ereal_minus_less_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   868
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   869
  shows "x - y < z \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   870
    y \<noteq> -\<infinity> \<and> (y = \<infinity> \<longrightarrow> x \<noteq> \<infinity> \<and> z \<noteq> -\<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   871
    (y \<noteq> \<infinity> \<longrightarrow> x < z + y)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   872
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   873
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   874
lemma ereal_minus_less:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   875
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   876
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x - y < z \<longleftrightarrow> x < z + y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   877
  by (auto simp: ereal_minus_less_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   878
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   879
lemma ereal_minus_le_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   880
  fixes x y z :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   881
  shows "x - y \<le> z \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   882
    (y = -\<infinity> \<longrightarrow> z = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   883
    (y = \<infinity> \<longrightarrow> x = \<infinity> \<longrightarrow> z = \<infinity>) \<and>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   884
    (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x \<le> z + y)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   885
  by (cases rule: ereal3_cases[of x y z]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   886
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   887
lemma ereal_minus_le:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   888
  fixes x y z :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   889
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x - y \<le> z \<longleftrightarrow> x \<le> z + y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   890
  by (auto simp: ereal_minus_le_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   891
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   892
lemma ereal_minus_eq_minus_iff:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   893
  fixes a b c :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   894
  shows "a - b = a - c \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   895
    b = c \<or> a = \<infinity> \<or> (a = -\<infinity> \<and> b \<noteq> -\<infinity> \<and> c \<noteq> -\<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   896
  by (cases rule: ereal3_cases[of a b c]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   897
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   898
lemma ereal_add_le_add_iff:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   899
  fixes a b c :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   900
  shows "c + a \<le> c + b \<longleftrightarrow>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   901
    a \<le> b \<or> c = \<infinity> \<or> (c = -\<infinity> \<and> a \<noteq> \<infinity> \<and> b \<noteq> \<infinity>)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   902
  by (cases rule: ereal3_cases[of a b c]) (simp_all add: field_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   903
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   904
lemma ereal_mult_le_mult_iff:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   905
  fixes a b c :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   906
  shows "\<bar>c\<bar> \<noteq> \<infinity> \<Longrightarrow> c * a \<le> c * b \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   907
  by (cases rule: ereal3_cases[of a b c]) (simp_all add: mult_le_cancel_left)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   908
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   909
lemma ereal_minus_mono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   910
  fixes A B C D :: ereal assumes "A \<le> B" "D \<le> C"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   911
  shows "A - C \<le> B - D"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   912
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   913
  by (cases rule: ereal3_cases[case_product ereal_cases, of A B C D]) simp_all
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   914
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   915
lemma real_of_ereal_minus:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   916
  fixes a b :: ereal
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   917
  shows "real (a - b) = (if \<bar>a\<bar> = \<infinity> \<or> \<bar>b\<bar> = \<infinity> then 0 else real a - real b)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   918
  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
   919
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   920
lemma ereal_diff_positive:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   921
  fixes a b :: ereal shows "a \<le> b \<Longrightarrow> 0 \<le> b - a"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   922
  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
   923
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   924
lemma ereal_between:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   925
  fixes x e :: ereal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   926
  assumes "\<bar>x\<bar> \<noteq> \<infinity>" "0 < e"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   927
  shows "x - e < x" "x < x + e"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   928
using assms apply (cases x, cases e) apply auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   929
using assms by (cases x, cases e) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   930
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   931
subsubsection {* Division *}
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   932
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   933
instantiation ereal :: inverse
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   934
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   935
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   936
function inverse_ereal where
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   937
"inverse (ereal r) = (if r = 0 then \<infinity> else ereal (inverse r))" |
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   938
"inverse (\<infinity>::ereal) = 0" |
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   939
"inverse (-\<infinity>::ereal) = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   940
  by (auto intro: ereal_cases)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   941
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   942
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   943
definition "x / y = x * inverse (y :: ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   944
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   945
instance proof qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   946
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   947
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   948
lemma real_of_ereal_inverse[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   949
  fixes a :: ereal
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   950
  shows "real (inverse a) = 1 / real a"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   951
  by (cases a) (auto simp: inverse_eq_divide)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   952
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   953
lemma ereal_inverse[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   954
  "inverse (0::ereal) = \<infinity>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   955
  "inverse (1::ereal) = 1"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   956
  by (simp_all add: one_ereal_def zero_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   957
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   958
lemma ereal_divide[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   959
  "ereal r / ereal p = (if p = 0 then ereal r * \<infinity> else ereal (r / p))"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   960
  unfolding divide_ereal_def by (auto simp: divide_real_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   961
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   962
lemma ereal_divide_same[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   963
  fixes x :: ereal shows "x / x = (if \<bar>x\<bar> = \<infinity> \<or> x = 0 then 0 else 1)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   964
  by (cases x)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   965
     (simp_all add: divide_real_def divide_ereal_def one_ereal_def)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   966
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   967
lemma ereal_inv_inv[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   968
  fixes x :: ereal shows "inverse (inverse x) = (if x \<noteq> -\<infinity> then x else \<infinity>)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   969
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   970
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   971
lemma ereal_inverse_minus[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   972
  fixes x :: ereal shows "inverse (- x) = (if x = 0 then \<infinity> else -inverse x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   973
  by (cases x) simp_all
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_uminus_divide[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   976
  fixes x y :: ereal shows "- x / y = - (x / y)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   977
  unfolding divide_ereal_def by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   978
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   979
lemma ereal_divide_Infty[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   980
  fixes x :: ereal shows "x / \<infinity> = 0" "x / -\<infinity> = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   981
  unfolding divide_ereal_def by simp_all
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   982
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   983
lemma ereal_divide_one[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   984
  "x / 1 = (x::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   985
  unfolding divide_ereal_def by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   986
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   987
lemma ereal_divide_ereal[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   988
  "\<infinity> / ereal r = (if 0 \<le> r then \<infinity> else -\<infinity>)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   989
  unfolding divide_ereal_def by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   990
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   991
lemma zero_le_divide_ereal[simp]:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   992
  fixes a :: ereal assumes "0 \<le> a" "0 \<le> b"
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   993
  shows "0 \<le> a / b"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   994
  using assms by (cases rule: ereal2_cases[of a b]) (auto simp: zero_le_divide_iff)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   995
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   996
lemma ereal_le_divide_pos:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   997
  fixes x y z :: ereal shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y \<le> z / x \<longleftrightarrow> x * y \<le> z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
   998
  by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   999
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1000
lemma ereal_divide_le_pos:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1001
  fixes x y z :: ereal shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> z / x \<le> y \<longleftrightarrow> z \<le> x * y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1002
  by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1003
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1004
lemma ereal_le_divide_neg:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1005
  fixes x y z :: ereal shows "x < 0 \<Longrightarrow> x \<noteq> -\<infinity> \<Longrightarrow> y \<le> z / x \<longleftrightarrow> z \<le> x * y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1006
  by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1007
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1008
lemma ereal_divide_le_neg:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1009
  fixes x y z :: ereal shows "x < 0 \<Longrightarrow> x \<noteq> -\<infinity> \<Longrightarrow> z / x \<le> y \<longleftrightarrow> x * y \<le> z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1010
  by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1011
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1012
lemma ereal_inverse_antimono_strict:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1013
  fixes x y :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1014
  shows "0 \<le> x \<Longrightarrow> x < y \<Longrightarrow> inverse y < inverse x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1015
  by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1016
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1017
lemma ereal_inverse_antimono:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1018
  fixes x y :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1019
  shows "0 \<le> x \<Longrightarrow> x <= y \<Longrightarrow> inverse y <= inverse x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1020
  by (cases rule: ereal2_cases[of x y]) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1021
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1022
lemma inverse_inverse_Pinfty_iff[simp]:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1023
  fixes x :: ereal shows "inverse x = \<infinity> \<longleftrightarrow> x = 0"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1024
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1025
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1026
lemma ereal_inverse_eq_0:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1027
  fixes x :: ereal shows "inverse x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1028
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1029
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1030
lemma ereal_0_gt_inverse:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1031
  fixes x :: ereal shows "0 < inverse x \<longleftrightarrow> x \<noteq> \<infinity> \<and> 0 \<le> x"
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1032
  by (cases x) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1033
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1034
lemma ereal_mult_less_right:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1035
  fixes a b c :: ereal
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1036
  assumes "b * a < c * a" "0 < a" "a < \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1037
  shows "b < c"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1038
  using assms
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1039
  by (cases rule: ereal3_cases[of a b c])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1040
     (auto split: split_if_asm simp: zero_less_mult_iff zero_le_mult_iff)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1041
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1042
lemma ereal_power_divide:
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1043
  fixes x y :: ereal shows "y \<noteq> 0 \<Longrightarrow> (x / y) ^ n = x^n / y^n"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1044
  by (cases rule: ereal2_cases[of x y])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1045
     (auto simp: one_ereal_def zero_ereal_def power_divide not_le
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1046
                 power_less_zero_eq zero_le_power_iff)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1047
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1048
lemma ereal_le_mult_one_interval:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1049
  fixes x y :: ereal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1050
  assumes y: "y \<noteq> -\<infinity>"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1051
  assumes z: "\<And>z. \<lbrakk> 0 < z ; z < 1 \<rbrakk> \<Longrightarrow> z * x \<le> y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1052
  shows "x \<le> y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1053
proof (cases x)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1054
  case PInf with z[of "1 / 2"] show "x \<le> y" by (simp add: one_ereal_def)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1055
next
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1056
  case (real r) note r = this
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1057
  show "x \<le> y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1058
  proof (cases y)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1059
    case (real p) note p = this
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1060
    have "r \<le> p"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1061
    proof (rule field_le_mult_one_interval)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1062
      fix z :: real assume "0 < z" and "z < 1"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1063
      with z[of "ereal z"]
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1064
      show "z * r \<le> p" using p r by (auto simp: zero_le_mult_iff one_ereal_def)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1065
    qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1066
    then show "x \<le> y" using p r by simp
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1067
  qed (insert y, simp_all)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1068
qed simp
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1069
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1070
subsection "Complete lattice"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1071
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1072
instantiation ereal :: lattice
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1073
begin
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1074
definition [simp]: "sup x y = (max x y :: ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1075
definition [simp]: "inf x y = (min x y :: ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1076
instance proof qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1077
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1078
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1079
instantiation ereal :: complete_lattice
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1080
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1081
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1082
definition "bot = (-\<infinity>::ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1083
definition "top = (\<infinity>::ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1084
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1085
definition "Sup S = (LEAST z. \<forall>x\<in>S. x \<le> z :: ereal)"
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
  1086
definition "Inf S = (GREATEST z. \<forall>x\<in>S. z \<le> x :: ereal)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1087
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1088
lemma ereal_complete_Sup:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1089
  fixes S :: "ereal set" assumes "S \<noteq> {}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1090
  shows "\<exists>x. (\<forall>y\<in>S. y \<le> x) \<and> (\<forall>z. (\<forall>y\<in>S. y \<le> z) \<longrightarrow> x \<le> z)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1091
proof cases
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1092
  assume "\<exists>x. \<forall>a\<in>S. a \<le> ereal x"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1093
  then obtain y where y: "\<And>a. a\<in>S \<Longrightarrow> a \<le> ereal y" by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1094
  then have "\<infinity> \<notin> S" by force
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1095
  show ?thesis
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1096
  proof cases
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1097
    assume "S = {-\<infinity>}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1098
    then show ?thesis by (auto intro!: exI[of _ "-\<infinity>"])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1099
  next
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1100
    assume "S \<noteq> {-\<infinity>}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1101
    with `S \<noteq> {}` `\<infinity> \<notin> S` obtain x where "x \<in> S - {-\<infinity>}" "x \<noteq> \<infinity>" by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1102
    with y `\<infinity> \<notin> S` have "\<forall>z\<in>real ` (S - {-\<infinity>}). z \<le> y"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1103
      by (auto simp: real_of_ereal_ord_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1104
    with reals_complete2[of "real ` (S - {-\<infinity>})"] `x \<in> S - {-\<infinity>}`
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1105
    obtain s where s:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1106
       "\<forall>y\<in>S - {-\<infinity>}. real y \<le> s" "\<And>z. (\<forall>y\<in>S - {-\<infinity>}. real y \<le> z) \<Longrightarrow> s \<le> z"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1107
       by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1108
    show ?thesis
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1109
    proof (safe intro!: exI[of _ "ereal s"])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1110
      fix z assume "z \<in> S" with `\<infinity> \<notin> S` show "z \<le> ereal s"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1111
      proof (cases z)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1112
        case (real r)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1113
        then show ?thesis
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1114
          using s(1)[rule_format, of z] `z \<in> S` `z = ereal r` by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1115
      qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1116
    next
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1117
      fix z assume *: "\<forall>y\<in>S. y \<le> z"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1118
      with `S \<noteq> {-\<infinity>}` `S \<noteq> {}` show "ereal s \<le> z"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1119
      proof (cases z)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1120
        case (real u)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1121
        with * have "s \<le> u"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1122
          by (intro s(2)[of u]) (auto simp: real_of_ereal_ord_simps)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1123
        then show ?thesis using real by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1124
      qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1125
    qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1126
  qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1127
next
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1128
  assume *: "\<not> (\<exists>x. \<forall>a\<in>S. a \<le> ereal x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1129
  show ?thesis
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1130
  proof (safe intro!: exI[of _ \<infinity>])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1131
    fix y assume **: "\<forall>z\<in>S. z \<le> y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1132
    with * show "\<infinity> \<le> y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1133
    proof (cases y)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1134
      case MInf with * ** show ?thesis by (force simp: not_le)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1135
    qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1136
  qed simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1137
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1138
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1139
lemma ereal_complete_Inf:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1140
  fixes S :: "ereal set" assumes "S ~= {}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1141
  shows "EX x. (ALL y:S. x <= y) & (ALL z. (ALL y:S. z <= y) --> z <= x)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1142
proof-
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1143
def S1 == "uminus ` S"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1144
hence "S1 ~= {}" using assms by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1145
from this obtain x where x_def: "(ALL y:S1. y <= x) & (ALL z. (ALL y:S1. y <= z) --> x <= z)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1146
   using ereal_complete_Sup[of S1] by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1147
{ fix z assume "ALL y:S. z <= y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1148
  hence "ALL y:S1. y <= -z" unfolding S1_def by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1149
  hence "x <= -z" using x_def by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1150
  hence "z <= -x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1151
    apply (subst ereal_uminus_uminus[symmetric])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1152
    unfolding ereal_minus_le_minus . }
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1153
moreover have "(ALL y:S. -x <= y)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1154
   using x_def unfolding S1_def
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1155
   apply simp
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1156
   apply (subst (3) ereal_uminus_uminus[symmetric])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1157
   unfolding ereal_minus_le_minus by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1158
ultimately show ?thesis by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1159
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1160
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1161
lemma ereal_complete_uminus_eq:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1162
  fixes S :: "ereal set"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1163
  shows "(\<forall>y\<in>uminus`S. y \<le> x) \<and> (\<forall>z. (\<forall>y\<in>uminus`S. y \<le> z) \<longrightarrow> x \<le> z)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1164
     \<longleftrightarrow> (\<forall>y\<in>S. -x \<le> y) \<and> (\<forall>z. (\<forall>y\<in>S. z \<le> y) \<longrightarrow> z \<le> -x)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1165
  by simp (metis ereal_minus_le_minus ereal_uminus_uminus)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1166
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1167
lemma ereal_Sup_uminus_image_eq:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1168
  fixes S :: "ereal set"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1169
  shows "Sup (uminus ` S) = - Inf S"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1170
proof cases
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1171
  assume "S = {}"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1172
  moreover have "(THE x. All (op \<le> x)) = (-\<infinity>::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1173
    by (rule the_equality) (auto intro!: ereal_bot)
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1174
  moreover have "(SOME x. \<forall>y. y \<le> x) = (\<infinity>::ereal)"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1175
    by (rule some_equality) (auto intro!: ereal_top)
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1176
  ultimately show ?thesis unfolding Inf_ereal_def Sup_ereal_def
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1177
    Least_def Greatest_def GreatestM_def by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1178
next
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1179
  assume "S \<noteq> {}"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1180
  with ereal_complete_Sup[of "uminus`S"]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1181
  obtain x where x: "(\<forall>y\<in>S. -x \<le> y) \<and> (\<forall>z. (\<forall>y\<in>S. z \<le> y) \<longrightarrow> z \<le> -x)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1182
    unfolding ereal_complete_uminus_eq by auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1183
  show "Sup (uminus ` S) = - Inf S"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1184
    unfolding Inf_ereal_def Greatest_def GreatestM_def
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1185
  proof (intro someI2[of _ _ "\<lambda>x. Sup (uminus`S) = - x"])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1186
    show "(\<forall>y\<in>S. -x \<le> y) \<and> (\<forall>y. (\<forall>z\<in>S. y \<le> z) \<longrightarrow> y \<le> -x)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1187
      using x .
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1188
    fix x' assume "(\<forall>y\<in>S. x' \<le> y) \<and> (\<forall>y. (\<forall>z\<in>S. y \<le> z) \<longrightarrow> y \<le> x')"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1189
    then have "(\<forall>y\<in>uminus`S. y \<le> - x') \<and> (\<forall>y. (\<forall>z\<in>uminus`S. z \<le> y) \<longrightarrow> - x' \<le> y)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1190
      unfolding ereal_complete_uminus_eq by simp
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1191
    then show "Sup (uminus ` S) = -x'"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1192
      unfolding Sup_ereal_def ereal_uminus_eq_iff
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1193
      by (intro Least_equality) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1194
  qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1195
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1196
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1197
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1198
proof
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1199
  { fix x :: ereal and A
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1200
    show "bot <= x" by (cases x) (simp_all add: bot_ereal_def)
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1201
    show "x <= top" by (simp add: top_ereal_def) }
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1202
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1203
  { fix x :: ereal and A assume "x : A"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1204
    with ereal_complete_Sup[of A]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1205
    obtain s where s: "\<forall>y\<in>A. y <= s" "\<forall>z. (\<forall>y\<in>A. y <= z) \<longrightarrow> s <= z" by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1206
    hence "x <= s" using `x : A` by auto
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1207
    also have "... = Sup A" using s unfolding Sup_ereal_def
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1208
      by (auto intro!: Least_equality[symmetric])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1209
    finally show "x <= Sup A" . }
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1210
  note le_Sup = this
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1211
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1212
  { fix x :: ereal and A assume *: "!!z. (z : A ==> z <= x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1213
    show "Sup A <= x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1214
    proof (cases "A = {}")
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1215
      case True
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1216
      hence "Sup A = -\<infinity>" unfolding Sup_ereal_def
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1217
        by (auto intro!: Least_equality)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1218
      thus "Sup A <= x" by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1219
    next
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1220
      case False
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1221
      with ereal_complete_Sup[of A]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1222
      obtain s where s: "\<forall>y\<in>A. y <= s" "\<forall>z. (\<forall>y\<in>A. y <= z) \<longrightarrow> s <= z" by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1223
      hence "Sup A = s"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1224
        unfolding Sup_ereal_def by (auto intro!: Least_equality)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1225
      also have "s <= x" using * s by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1226
      finally show "Sup A <= x" .
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1227
    qed }
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1228
  note Sup_le = this
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1229
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1230
  { fix x :: ereal and A assume "x \<in> A"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1231
    with le_Sup[of "-x" "uminus`A"] show "Inf A \<le> x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1232
      unfolding ereal_Sup_uminus_image_eq by simp }
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1233
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1234
  { fix x :: ereal and A assume *: "!!z. (z : A ==> x <= z)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1235
    with Sup_le[of "uminus`A" "-x"] show "x \<le> Inf A"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1236
      unfolding ereal_Sup_uminus_image_eq by force }
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1237
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1238
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1239
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1240
lemma ereal_SUPR_uminus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1241
  fixes f :: "'a => ereal"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1242
  shows "(SUP i : R. -(f i)) = -(INF i : R. f i)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1243
  unfolding SUPR_def INFI_def
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1244
  using ereal_Sup_uminus_image_eq[of "f`R"]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1245
  by (simp add: image_image)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1246
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1247
lemma ereal_INFI_uminus:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1248
  fixes f :: "'a => ereal"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1249
  shows "(INF i : R. -(f i)) = -(SUP i : R. f i)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43138
diff changeset
  1250
  using ereal_SUPR_uminus[of _ "\<lambda>x. - f x"] by simp
41973