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