src/HOL/Library/Extended_Reals.thy
author hoelzl
Mon, 23 May 2011 19:21:05 +0200
changeset 42950 6e5c2a3c69da
parent 42600 604661fb94eb
child 43138 818521a90356
permissions -rw-r--r--
move lemmas to Extended_Reals and Extended_Real_Limits
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41983
2dc6e382a58b standardized headers;
wenzelm
parents: 41980
diff changeset
     1
(*  Title:      HOL/Library/Extended_Reals.thy
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
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    10
theory Extended_Reals
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    11
  imports Complex_Main
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    12
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    13
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    14
text {*
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    15
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    16
For more lemmas about the extended real numbers go to
42600
604661fb94eb fixing typo
bulwahn
parents: 41983
diff changeset
    17
  @{text "src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy"}
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    18
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    19
*}
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    20
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    21
lemma (in complete_lattice) atLeast_eq_UNIV_iff: "{x..} = UNIV \<longleftrightarrow> x = bot"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    22
proof
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    23
  assume "{x..} = UNIV"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    24
  show "x = bot"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    25
  proof (rule ccontr)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    26
    assume "x \<noteq> bot" then have "bot \<notin> {x..}" by (simp add: le_less)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    27
    then show False using `{x..} = UNIV` by simp
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    28
  qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    29
qed auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    30
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    31
lemma SUPR_pair:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    32
  "(SUP i : A. SUP j : B. f i j) = (SUP p : A \<times> B. f (fst p) (snd p))"
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    33
  by (rule antisym) (auto intro!: SUP_leI le_SUPI2)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    34
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    35
lemma INFI_pair:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    36
  "(INF i : A. INF j : B. f i j) = (INF p : A \<times> B. f (fst p) (snd p))"
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
    37
  by (rule antisym) (auto intro!: le_INFI INF_leI2)
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    38
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    39
subsection {* Definition and basic properties *}
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    40
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    41
datatype extreal = extreal real | PInfty | MInfty
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    42
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    43
notation (xsymbols)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    44
  PInfty  ("\<infinity>")
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    45
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    46
notation (HTML output)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    47
  PInfty  ("\<infinity>")
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    48
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    49
declare [[coercion "extreal :: real \<Rightarrow> extreal"]]
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
    50
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    51
instantiation extreal :: uminus
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    52
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    53
  fun uminus_extreal where
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    54
    "- (extreal r) = extreal (- r)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    55
  | "- \<infinity> = MInfty"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    56
  | "- MInfty = \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    57
  instance ..
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    58
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    59
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
    60
lemma inj_extreal[simp]: "inj_on extreal A"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
    61
  unfolding inj_on_def by auto
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
    62
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    63
lemma MInfty_neq_PInfty[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    64
  "\<infinity> \<noteq> - \<infinity>" "- \<infinity> \<noteq> \<infinity>" by simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    65
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    66
lemma MInfty_neq_extreal[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    67
  "extreal r \<noteq> - \<infinity>" "- \<infinity> \<noteq> extreal r" by simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    68
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    69
lemma MInfinity_cases[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    70
  "(case - \<infinity> of extreal r \<Rightarrow> f r | \<infinity> \<Rightarrow> y | MInfinity \<Rightarrow> z) = z"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    71
  by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    72
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    73
lemma extreal_uminus_uminus[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    74
  fixes a :: extreal shows "- (- a) = a"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    75
  by (cases a) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    76
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    77
lemma MInfty_eq[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    78
  "MInfty = - \<infinity>" by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    79
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    80
declare uminus_extreal.simps(2)[simp del]
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    81
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    82
lemma extreal_cases[case_names real PInf MInf, cases type: extreal]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    83
  assumes "\<And>r. x = extreal r \<Longrightarrow> P"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    84
  assumes "x = \<infinity> \<Longrightarrow> P"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    85
  assumes "x = -\<infinity> \<Longrightarrow> P"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    86
  shows P
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    87
  using assms by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    88
41974
6e691abef08f use case_product for extrel[2,3]_cases
hoelzl
parents: 41973
diff changeset
    89
lemmas extreal2_cases = extreal_cases[case_product extreal_cases]
6e691abef08f use case_product for extrel[2,3]_cases
hoelzl
parents: 41973
diff changeset
    90
lemmas extreal3_cases = extreal2_cases[case_product extreal_cases]
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    91
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    92
lemma extreal_uminus_eq_iff[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    93
  fixes a b :: extreal shows "-a = -b \<longleftrightarrow> a = b"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    94
  by (cases rule: extreal2_cases[of a b]) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    95
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    96
function of_extreal :: "extreal \<Rightarrow> real" where
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    97
"of_extreal (extreal r) = r" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    98
"of_extreal \<infinity> = 0" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
    99
"of_extreal (-\<infinity>) = 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   100
  by (auto intro: extreal_cases)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   101
termination proof qed (rule wf_empty)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   102
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   103
defs (overloaded)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   104
  real_of_extreal_def [code_unfold]: "real \<equiv> of_extreal"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   105
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   106
lemma real_of_extreal[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   107
    "real (- x :: extreal) = - (real x)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   108
    "real (extreal r) = r"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   109
    "real \<infinity> = 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   110
  by (cases x) (simp_all add: real_of_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   111
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   112
lemma range_extreal[simp]: "range extreal = UNIV - {\<infinity>, -\<infinity>}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   113
proof safe
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   114
  fix x assume "x \<notin> range extreal" "x \<noteq> \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   115
  then show "x = -\<infinity>" by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   116
qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   117
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   118
lemma extreal_range_uminus[simp]: "range uminus = (UNIV::extreal set)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   119
proof safe
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   120
  fix x :: extreal show "x \<in> range uminus" by (intro image_eqI[of _ _ "-x"]) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   121
qed auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   122
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   123
instantiation extreal :: number
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   124
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   125
definition [simp]: "number_of x = extreal (number_of x)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   126
instance proof qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   127
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   128
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   129
instantiation extreal :: abs
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   130
begin
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   131
  function abs_extreal where
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   132
    "\<bar>extreal r\<bar> = extreal \<bar>r\<bar>"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   133
  | "\<bar>-\<infinity>\<bar> = \<infinity>"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   134
  | "\<bar>\<infinity>\<bar> = \<infinity>"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   135
  by (auto intro: extreal_cases)
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   136
  termination proof qed (rule wf_empty)
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   137
  instance ..
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   138
end
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   139
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   140
lemma abs_eq_infinity_cases[elim!]: "\<lbrakk> \<bar>x\<bar> = \<infinity> ; x = \<infinity> \<Longrightarrow> P ; x = -\<infinity> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   141
  by (cases x) auto
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   142
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   143
lemma abs_neq_infinity_cases[elim!]: "\<lbrakk> \<bar>x\<bar> \<noteq> \<infinity> ; \<And>r. x = extreal r \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   144
  by (cases x) auto
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   145
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   146
lemma abs_extreal_uminus[simp]: "\<bar>- x\<bar> = \<bar>x::extreal\<bar>"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   147
  by (cases x) auto
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   148
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   149
subsubsection "Addition"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   150
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   151
instantiation extreal :: comm_monoid_add
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   152
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   153
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   154
definition "0 = extreal 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   155
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   156
function plus_extreal where
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   157
"extreal r + extreal p = extreal (r + p)" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   158
"\<infinity> + a = \<infinity>" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   159
"a + \<infinity> = \<infinity>" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   160
"extreal r + -\<infinity> = - \<infinity>" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   161
"-\<infinity> + extreal p = -\<infinity>" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   162
"-\<infinity> + -\<infinity> = -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   163
proof -
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   164
  case (goal1 P x)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   165
  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
   166
  ultimately show P
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   167
   by (cases rule: extreal2_cases[of a b]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   168
qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   169
termination proof qed (rule wf_empty)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   170
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   171
lemma Infty_neq_0[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   172
  "\<infinity> \<noteq> 0" "0 \<noteq> \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   173
  "-\<infinity> \<noteq> 0" "0 \<noteq> -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   174
  by (simp_all add: zero_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   175
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   176
lemma extreal_eq_0[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   177
  "extreal r = 0 \<longleftrightarrow> r = 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   178
  "0 = extreal r \<longleftrightarrow> r = 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   179
  unfolding zero_extreal_def by simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   180
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   181
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   182
proof
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   183
  fix a :: extreal show "0 + a = a"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   184
    by (cases a) (simp_all add: zero_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   185
  fix b :: extreal show "a + b = b + a"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   186
    by (cases rule: extreal2_cases[of a b]) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   187
  fix c :: extreal show "a + b + c = a + (b + c)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   188
    by (cases rule: extreal3_cases[of a b c]) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   189
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   190
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   191
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   192
lemma real_of_extreal_0[simp]: "real (0::extreal) = 0"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   193
  unfolding real_of_extreal_def zero_extreal_def by simp
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   194
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   195
lemma abs_extreal_zero[simp]: "\<bar>0\<bar> = (0::extreal)"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   196
  unfolding zero_extreal_def abs_extreal.simps by simp
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   197
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   198
lemma extreal_uminus_zero[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   199
  "- 0 = (0::extreal)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   200
  by (simp add: zero_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   201
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   202
lemma extreal_uminus_zero_iff[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   203
  fixes a :: extreal shows "-a = 0 \<longleftrightarrow> a = 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   204
  by (cases a) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   205
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   206
lemma extreal_plus_eq_PInfty[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   207
  shows "a + b = \<infinity> \<longleftrightarrow> a = \<infinity> \<or> b = \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   208
  by (cases rule: extreal2_cases[of a b]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   209
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   210
lemma extreal_plus_eq_MInfty[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   211
  shows "a + b = -\<infinity> \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   212
    (a = -\<infinity> \<or> b = -\<infinity>) \<and> a \<noteq> \<infinity> \<and> b \<noteq> \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   213
  by (cases rule: extreal2_cases[of a b]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   214
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   215
lemma extreal_add_cancel_left:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   216
  assumes "a \<noteq> -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   217
  shows "a + b = a + c \<longleftrightarrow> (a = \<infinity> \<or> b = c)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   218
  using assms by (cases rule: extreal3_cases[of a b c]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   219
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   220
lemma extreal_add_cancel_right:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   221
  assumes "a \<noteq> -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   222
  shows "b + a = c + a \<longleftrightarrow> (a = \<infinity> \<or> b = c)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   223
  using assms by (cases rule: extreal3_cases[of a b c]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   224
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   225
lemma extreal_real:
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   226
  "extreal (real x) = (if \<bar>x\<bar> = \<infinity> then 0 else x)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   227
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   228
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   229
lemma real_of_extreal_add:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   230
  fixes a b :: extreal
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   231
  shows "real (a + b) = (if (\<bar>a\<bar> = \<infinity>) \<and> (\<bar>b\<bar> = \<infinity>) \<or> (\<bar>a\<bar> \<noteq> \<infinity>) \<and> (\<bar>b\<bar> \<noteq> \<infinity>) then real a + real b else 0)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   232
  by (cases rule: extreal2_cases[of a b]) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   233
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   234
subsubsection "Linear order on @{typ extreal}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   235
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   236
instantiation extreal :: linorder
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   237
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   238
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   239
function less_extreal where
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   240
"extreal x < extreal y \<longleftrightarrow> x < y" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   241
"        \<infinity> < a         \<longleftrightarrow> False" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   242
"        a < -\<infinity>        \<longleftrightarrow> False" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   243
"extreal x < \<infinity>         \<longleftrightarrow> True" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   244
"       -\<infinity> < extreal r \<longleftrightarrow> True" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   245
"       -\<infinity> < \<infinity>         \<longleftrightarrow> True"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   246
proof -
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   247
  case (goal1 P x)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   248
  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
   249
  ultimately show P by (cases rule: extreal2_cases[of a b]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   250
qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   251
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   252
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   253
definition "x \<le> (y::extreal) \<longleftrightarrow> x < y \<or> x = y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   254
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   255
lemma extreal_infty_less[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   256
  "x < \<infinity> \<longleftrightarrow> (x \<noteq> \<infinity>)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   257
  "-\<infinity> < x \<longleftrightarrow> (x \<noteq> -\<infinity>)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   258
  by (cases x, simp_all) (cases x, simp_all)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   259
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   260
lemma extreal_infty_less_eq[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   261
  "\<infinity> \<le> x \<longleftrightarrow> x = \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   262
  "x \<le> -\<infinity> \<longleftrightarrow> x = -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   263
  by (auto simp add: less_eq_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   264
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   265
lemma extreal_less[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   266
  "extreal r < 0 \<longleftrightarrow> (r < 0)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   267
  "0 < extreal r \<longleftrightarrow> (0 < r)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   268
  "0 < \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   269
  "-\<infinity> < 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   270
  by (simp_all add: zero_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   271
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   272
lemma extreal_less_eq[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   273
  "x \<le> \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   274
  "-\<infinity> \<le> x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   275
  "extreal r \<le> extreal p \<longleftrightarrow> r \<le> p"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   276
  "extreal r \<le> 0 \<longleftrightarrow> r \<le> 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   277
  "0 \<le> extreal r \<longleftrightarrow> 0 \<le> r"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   278
  by (auto simp add: less_eq_extreal_def zero_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   279
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   280
lemma extreal_infty_less_eq2:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   281
  "a \<le> b \<Longrightarrow> a = \<infinity> \<Longrightarrow> b = \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   282
  "a \<le> b \<Longrightarrow> b = -\<infinity> \<Longrightarrow> a = -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   283
  by simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   284
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   285
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   286
proof
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   287
  fix x :: extreal show "x \<le> x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   288
    by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   289
  fix y :: extreal show "x < y \<longleftrightarrow> x \<le> y \<and> \<not> y \<le> x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   290
    by (cases rule: extreal2_cases[of x y]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   291
  show "x \<le> y \<or> y \<le> x "
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   292
    by (cases rule: extreal2_cases[of x y]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   293
  { assume "x \<le> y" "y \<le> x" then show "x = y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   294
    by (cases rule: extreal2_cases[of x y]) auto }
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   295
  { fix z assume "x \<le> y" "y \<le> z" then show "x \<le> z"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   296
    by (cases rule: extreal3_cases[of x y z]) auto }
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   297
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   298
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   299
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   300
instance extreal :: ordered_ab_semigroup_add
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   301
proof
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   302
  fix a b c :: extreal assume "a \<le> b" then show "c + a \<le> c + b"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   303
    by (cases rule: extreal3_cases[of a b c]) auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   304
qed
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   305
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   306
lemma real_of_extreal_positive_mono:
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   307
  "\<lbrakk>0 \<le> x; x \<le> y; y \<noteq> \<infinity>\<rbrakk> \<Longrightarrow> real x \<le> real y"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   308
  by (cases rule: extreal2_cases[of x y]) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   309
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   310
lemma extreal_MInfty_lessI[intro, simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   311
  "a \<noteq> -\<infinity> \<Longrightarrow> -\<infinity> < a"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   312
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   313
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   314
lemma extreal_less_PInfty[intro, simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   315
  "a \<noteq> \<infinity> \<Longrightarrow> a < \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   316
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   317
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   318
lemma extreal_less_extreal_Ex:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   319
  fixes a b :: extreal
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   320
  shows "x < extreal r \<longleftrightarrow> x = -\<infinity> \<or> (\<exists>p. p < r \<and> x = extreal p)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   321
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   322
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   323
lemma less_PInf_Ex_of_nat: "x \<noteq> \<infinity> \<longleftrightarrow> (\<exists>n::nat. x < extreal (real n))"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   324
proof (cases x)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   325
  case (real r) then show ?thesis
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents: 41979
diff changeset
   326
    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
   327
qed simp_all
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   328
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   329
lemma extreal_add_mono:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   330
  fixes a b c d :: extreal assumes "a \<le> b" "c \<le> d" shows "a + c \<le> b + d"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   331
  using assms
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   332
  apply (cases a)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   333
  apply (cases rule: extreal3_cases[of b c d], auto)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   334
  apply (cases rule: extreal3_cases[of b c d], auto)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   335
  done
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   336
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   337
lemma extreal_minus_le_minus[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   338
  fixes a b :: extreal shows "- a \<le> - b \<longleftrightarrow> b \<le> a"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   339
  by (cases rule: extreal2_cases[of a b]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   340
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   341
lemma extreal_minus_less_minus[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   342
  fixes a b :: extreal shows "- a < - b \<longleftrightarrow> b < a"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   343
  by (cases rule: extreal2_cases[of a b]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   344
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   345
lemma extreal_le_real_iff:
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   346
  "x \<le> real y \<longleftrightarrow> ((\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> extreal 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
   347
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   348
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   349
lemma real_le_extreal_iff:
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   350
  "real y \<le> x \<longleftrightarrow> ((\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> y \<le> extreal x) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> 0 \<le> x))"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   351
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   352
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   353
lemma extreal_less_real_iff:
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   354
  "x < real y \<longleftrightarrow> ((\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> extreal x < y) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> x < 0))"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   355
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   356
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   357
lemma real_less_extreal_iff:
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   358
  "real y < x \<longleftrightarrow> ((\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> y < extreal x) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> 0 < x))"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   359
  by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   360
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   361
lemma real_of_extreal_pos:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   362
  fixes x :: extreal shows "0 \<le> x \<Longrightarrow> 0 \<le> real x" by (cases x) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   363
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   364
lemmas real_of_extreal_ord_simps =
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   365
  extreal_le_real_iff real_le_extreal_iff extreal_less_real_iff real_less_extreal_iff
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   366
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   367
lemma abs_extreal_ge0[simp]: "0 \<le> x \<Longrightarrow> \<bar>x :: extreal\<bar> = x"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   368
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   369
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   370
lemma abs_extreal_less0[simp]: "x < 0 \<Longrightarrow> \<bar>x :: extreal\<bar> = -x"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   371
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   372
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   373
lemma abs_extreal_pos[simp]: "0 \<le> \<bar>x :: extreal\<bar>"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   374
  by (cases x) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   375
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   376
lemma real_of_extreal_le_0[simp]: "real (X :: extreal) \<le> 0 \<longleftrightarrow> (X \<le> 0 \<or> X = \<infinity>)"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   377
  by (cases X) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   378
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   379
lemma abs_real_of_extreal[simp]: "\<bar>real (X :: extreal)\<bar> = real \<bar>X\<bar>"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   380
  by (cases X) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   381
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   382
lemma zero_less_real_of_extreal: "0 < real X \<longleftrightarrow> (0 < X \<and> X \<noteq> \<infinity>)"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   383
  by (cases X) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   384
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   385
lemma extreal_0_le_uminus_iff[simp]:
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   386
  fixes a :: extreal shows "0 \<le> -a \<longleftrightarrow> a \<le> 0"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   387
  by (cases rule: extreal2_cases[of a]) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   388
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   389
lemma extreal_uminus_le_0_iff[simp]:
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   390
  fixes a :: extreal shows "-a \<le> 0 \<longleftrightarrow> 0 \<le> a"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   391
  by (cases rule: extreal2_cases[of a]) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   392
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   393
lemma extreal_dense:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   394
  fixes x y :: extreal assumes "x < y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   395
  shows "EX z. x < z & z < y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   396
proof -
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   397
{ assume a: "x = (-\<infinity>)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   398
  { assume "y = \<infinity>" hence ?thesis using a by (auto intro!: exI[of _ "0"]) }
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   399
  moreover
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   400
  { assume "y ~= \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   401
    with `x < y` obtain r where r: "y = extreal r" by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   402
    hence ?thesis using `x < y` a by (auto intro!: exI[of _ "extreal (r - 1)"])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   403
  } ultimately have ?thesis by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   404
}
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   405
moreover
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   406
{ assume "x ~= (-\<infinity>)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   407
  with `x < y` obtain p where p: "x = extreal p" by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   408
  { assume "y = \<infinity>" hence ?thesis using `x < y` p
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   409
       by (auto intro!: exI[of _ "extreal (p + 1)"]) }
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   410
  moreover
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   411
  { assume "y ~= \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   412
    with `x < y` obtain r where r: "y = extreal r" by (cases y) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   413
    with p `x < y` have "p < r" by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   414
    with dense obtain z where "p < z" "z < r" by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   415
    hence ?thesis using r p by (auto intro!: exI[of _ "extreal z"])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   416
  } ultimately have ?thesis by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   417
} ultimately show ?thesis by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   418
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   419
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   420
lemma extreal_dense2:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   421
  fixes x y :: extreal assumes "x < y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   422
  shows "EX z. x < extreal z & extreal z < y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   423
  by (metis extreal_dense[OF `x < y`] extreal_cases less_extreal.simps(2,3))
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   424
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   425
lemma extreal_add_strict_mono:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   426
  fixes a b c d :: extreal
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   427
  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
   428
  shows "a + c < b + d"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   429
  using assms by (cases rule: extreal3_cases[case_product extreal_cases, of a b c d]) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   430
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   431
lemma extreal_less_add: "\<bar>a\<bar> \<noteq> \<infinity> \<Longrightarrow> c < b \<Longrightarrow> a + c < a + b"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   432
  by (cases rule: extreal2_cases[of b c]) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   433
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   434
lemma extreal_uminus_eq_reorder: "- a = b \<longleftrightarrow> a = (-b::extreal)" by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   435
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   436
lemma extreal_uminus_less_reorder: "- a < b \<longleftrightarrow> -b < (a::extreal)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   437
  by (subst (3) extreal_uminus_uminus[symmetric]) (simp only: extreal_minus_less_minus)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   438
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   439
lemma extreal_uminus_le_reorder: "- a \<le> b \<longleftrightarrow> -b \<le> (a::extreal)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   440
  by (subst (3) extreal_uminus_uminus[symmetric]) (simp only: extreal_minus_le_minus)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   441
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   442
lemmas extreal_uminus_reorder =
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   443
  extreal_uminus_eq_reorder extreal_uminus_less_reorder extreal_uminus_le_reorder
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   444
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   445
lemma extreal_bot:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   446
  fixes x :: extreal assumes "\<And>B. x \<le> extreal B" shows "x = - \<infinity>"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   447
proof (cases x)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   448
  case (real r) with assms[of "r - 1"] show ?thesis by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   449
next case PInf with assms[of 0] show ?thesis by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   450
next case MInf then show ?thesis by simp
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   451
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   452
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   453
lemma extreal_top:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   454
  fixes x :: extreal assumes "\<And>B. x \<ge> extreal B" shows "x = \<infinity>"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   455
proof (cases x)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   456
  case (real r) with assms[of "r + 1"] show ?thesis by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   457
next case MInf with assms[of 0] show ?thesis by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   458
next case PInf then show ?thesis by simp
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   459
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   460
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   461
lemma
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   462
  shows extreal_max[simp]: "extreal (max x y) = max (extreal x) (extreal y)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   463
    and extreal_min[simp]: "extreal (min x y) = min (extreal x) (extreal y)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   464
  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
   465
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   466
lemma extreal_max_0: "max 0 (extreal r) = extreal (max 0 r)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   467
  by (auto simp: zero_extreal_def)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   468
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   469
lemma
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   470
  fixes f :: "nat \<Rightarrow> extreal"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   471
  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
   472
  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
   473
  unfolding decseq_def incseq_def by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   474
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   475
lemma incseq_extreal: "incseq f \<Longrightarrow> incseq (\<lambda>x. extreal (f x))"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   476
  unfolding incseq_def by auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   477
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   478
lemma extreal_add_nonneg_nonneg:
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   479
  fixes a b :: extreal shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a + b"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   480
  using add_mono[of 0 a 0 b] by simp
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   481
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   482
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
   483
  by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   484
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   485
lemma incseq_setsumI:
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   486
  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
   487
  assumes "\<And>i. 0 \<le> f i"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   488
  shows "incseq (\<lambda>i. setsum f {..< i})"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   489
proof (intro incseq_SucI)
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   490
  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
   491
    using assms by (rule add_left_mono)
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   492
  then show "setsum f {..< n} \<le> setsum f {..< Suc n}"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   493
    by auto
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   494
qed
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   495
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   496
lemma incseq_setsumI2:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   497
  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
   498
  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
   499
  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
   500
  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
   501
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   502
subsubsection "Multiplication"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   503
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   504
instantiation extreal :: "{comm_monoid_mult, sgn}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   505
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   506
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   507
definition "1 = extreal 1"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   508
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   509
function sgn_extreal where
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   510
  "sgn (extreal r) = extreal (sgn r)"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   511
| "sgn \<infinity> = 1"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   512
| "sgn (-\<infinity>) = -1"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   513
by (auto intro: extreal_cases)
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   514
termination proof qed (rule wf_empty)
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   515
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   516
function times_extreal where
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   517
"extreal r * extreal p = extreal (r * p)" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   518
"extreal r * \<infinity> = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   519
"\<infinity> * extreal r = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   520
"extreal r * -\<infinity> = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   521
"-\<infinity> * extreal r = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   522
"\<infinity> * \<infinity> = \<infinity>" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   523
"-\<infinity> * \<infinity> = -\<infinity>" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   524
"\<infinity> * -\<infinity> = -\<infinity>" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   525
"-\<infinity> * -\<infinity> = \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   526
proof -
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   527
  case (goal1 P x)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   528
  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
   529
  ultimately show P by (cases rule: extreal2_cases[of a b]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   530
qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   531
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   532
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   533
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   534
proof
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   535
  fix a :: extreal show "1 * a = a"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   536
    by (cases a) (simp_all add: one_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   537
  fix b :: extreal show "a * b = b * a"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   538
    by (cases rule: extreal2_cases[of a b]) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   539
  fix c :: extreal show "a * b * c = a * (b * c)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   540
    by (cases rule: extreal3_cases[of a b c])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   541
       (simp_all add: zero_extreal_def zero_less_mult_iff)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   542
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   543
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   544
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   545
lemma real_of_extreal_le_1:
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   546
  fixes a :: extreal shows "a \<le> 1 \<Longrightarrow> real a \<le> 1"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   547
  by (cases a) (auto simp: one_extreal_def)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   548
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   549
lemma abs_extreal_one[simp]: "\<bar>1\<bar> = (1::extreal)"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   550
  unfolding one_extreal_def by simp
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   551
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   552
lemma extreal_mult_zero[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   553
  fixes a :: extreal shows "a * 0 = 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   554
  by (cases a) (simp_all add: zero_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   555
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   556
lemma extreal_zero_mult[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   557
  fixes a :: extreal shows "0 * a = 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   558
  by (cases a) (simp_all add: zero_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   559
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   560
lemma extreal_m1_less_0[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   561
  "-(1::extreal) < 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   562
  by (simp add: zero_extreal_def one_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   563
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   564
lemma extreal_zero_m1[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   565
  "1 \<noteq> (0::extreal)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   566
  by (simp add: zero_extreal_def one_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   567
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   568
lemma extreal_times_0[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   569
  fixes x :: extreal shows "0 * x = 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   570
  by (cases x) (auto simp: zero_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   571
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   572
lemma extreal_times[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   573
  "1 \<noteq> \<infinity>" "\<infinity> \<noteq> 1"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   574
  "1 \<noteq> -\<infinity>" "-\<infinity> \<noteq> 1"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   575
  by (auto simp add: times_extreal_def one_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   576
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   577
lemma extreal_plus_1[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   578
  "1 + extreal r = extreal (r + 1)" "extreal r + 1 = extreal (r + 1)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   579
  "1 + -\<infinity> = -\<infinity>" "-\<infinity> + 1 = -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   580
  unfolding one_extreal_def by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   581
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   582
lemma extreal_zero_times[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   583
  fixes a b :: extreal shows "a * b = 0 \<longleftrightarrow> a = 0 \<or> b = 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   584
  by (cases rule: extreal2_cases[of a b]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   585
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   586
lemma extreal_mult_eq_PInfty[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   587
  shows "a * b = \<infinity> \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   588
    (a = \<infinity> \<and> b > 0) \<or> (a > 0 \<and> b = \<infinity>) \<or> (a = -\<infinity> \<and> b < 0) \<or> (a < 0 \<and> b = -\<infinity>)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   589
  by (cases rule: extreal2_cases[of a b]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   590
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   591
lemma extreal_mult_eq_MInfty[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   592
  shows "a * b = -\<infinity> \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   593
    (a = \<infinity> \<and> b < 0) \<or> (a < 0 \<and> b = \<infinity>) \<or> (a = -\<infinity> \<and> b > 0) \<or> (a > 0 \<and> b = -\<infinity>)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   594
  by (cases rule: extreal2_cases[of a b]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   595
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   596
lemma extreal_0_less_1[simp]: "0 < (1::extreal)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   597
  by (simp_all add: zero_extreal_def one_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   598
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   599
lemma extreal_zero_one[simp]: "0 \<noteq> (1::extreal)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   600
  by (simp_all add: zero_extreal_def one_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   601
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   602
lemma extreal_mult_minus_left[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   603
  fixes a b :: extreal shows "-a * b = - (a * b)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   604
  by (cases rule: extreal2_cases[of a b]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   605
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   606
lemma extreal_mult_minus_right[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   607
  fixes a b :: extreal shows "a * -b = - (a * b)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   608
  by (cases rule: extreal2_cases[of a b]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   609
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   610
lemma extreal_mult_infty[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   611
  "a * \<infinity> = (if a = 0 then 0 else if 0 < a then \<infinity> else - \<infinity>)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   612
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   613
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   614
lemma extreal_infty_mult[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   615
  "\<infinity> * a = (if a = 0 then 0 else if 0 < a then \<infinity> else - \<infinity>)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   616
  by (cases a) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   617
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   618
lemma extreal_mult_strict_right_mono:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   619
  assumes "a < b" and "0 < c" "c < \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   620
  shows "a * c < b * c"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   621
  using assms
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   622
  by (cases rule: extreal3_cases[of a b c])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   623
     (auto simp: zero_le_mult_iff extreal_less_PInfty)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   624
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   625
lemma extreal_mult_strict_left_mono:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   626
  "\<lbrakk> a < b ; 0 < c ; c < \<infinity>\<rbrakk> \<Longrightarrow> c * a < c * b"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   627
  using extreal_mult_strict_right_mono by (simp add: mult_commute[of c])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   628
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   629
lemma extreal_mult_right_mono:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   630
  fixes a b c :: extreal shows "\<lbrakk>a \<le> b; 0 \<le> c\<rbrakk> \<Longrightarrow> a*c \<le> b*c"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   631
  using assms
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   632
  apply (cases "c = 0") apply simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   633
  by (cases rule: extreal3_cases[of a b c])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   634
     (auto simp: zero_le_mult_iff extreal_less_PInfty)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   635
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   636
lemma extreal_mult_left_mono:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   637
  fixes a b c :: extreal shows "\<lbrakk>a \<le> b; 0 \<le> c\<rbrakk> \<Longrightarrow> c * a \<le> c * b"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   638
  using extreal_mult_right_mono by (simp add: mult_commute[of c])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   639
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   640
lemma zero_less_one_extreal[simp]: "0 \<le> (1::extreal)"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   641
  by (simp add: one_extreal_def zero_extreal_def)
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   642
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   643
lemma extreal_0_le_mult[simp]: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a * (b :: extreal)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   644
  by (cases rule: extreal2_cases[of a b]) (auto simp: mult_nonneg_nonneg)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   645
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   646
lemma extreal_right_distrib:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   647
  fixes r a b :: extreal shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> r * (a + b) = r * a + r * b"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   648
  by (cases rule: extreal3_cases[of r a b]) (simp_all add: field_simps)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   649
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   650
lemma extreal_left_distrib:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   651
  fixes r a b :: extreal shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> (a + b) * r = a * r + b * r"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   652
  by (cases rule: extreal3_cases[of r a b]) (simp_all add: field_simps)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   653
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   654
lemma extreal_mult_le_0_iff:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   655
  fixes a b :: extreal
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   656
  shows "a * b \<le> 0 \<longleftrightarrow> (0 \<le> a \<and> b \<le> 0) \<or> (a \<le> 0 \<and> 0 \<le> b)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   657
  by (cases rule: extreal2_cases[of a b]) (simp_all add: mult_le_0_iff)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   658
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   659
lemma extreal_zero_le_0_iff:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   660
  fixes a b :: extreal
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   661
  shows "0 \<le> a * b \<longleftrightarrow> (0 \<le> a \<and> 0 \<le> b) \<or> (a \<le> 0 \<and> b \<le> 0)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   662
  by (cases rule: extreal2_cases[of a b]) (simp_all add: zero_le_mult_iff)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   663
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   664
lemma extreal_mult_less_0_iff:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   665
  fixes a b :: extreal
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   666
  shows "a * b < 0 \<longleftrightarrow> (0 < a \<and> b < 0) \<or> (a < 0 \<and> 0 < b)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   667
  by (cases rule: extreal2_cases[of a b]) (simp_all add: mult_less_0_iff)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   668
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   669
lemma extreal_zero_less_0_iff:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   670
  fixes a b :: extreal
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   671
  shows "0 < a * b \<longleftrightarrow> (0 < a \<and> 0 < b) \<or> (a < 0 \<and> b < 0)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   672
  by (cases rule: extreal2_cases[of a b]) (simp_all add: zero_less_mult_iff)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   673
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   674
lemma extreal_distrib:
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   675
  fixes a b c :: extreal
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   676
  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
   677
  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
   678
  using assms
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   679
  by (cases rule: extreal3_cases[of a b c]) (simp_all add: field_simps)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   680
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   681
lemma extreal_le_epsilon:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   682
  fixes x y :: extreal
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   683
  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
   684
  shows "x <= y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   685
proof-
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   686
{ assume a: "EX r. y = extreal r"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   687
  from this obtain r where r_def: "y = extreal r" by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   688
  { 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
   689
  moreover
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   690
  { assume "~(x=(-\<infinity>))"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   691
    from this obtain p where p_def: "x = extreal p"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   692
    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
   693
    { fix e have "0 < e --> p <= r + e"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   694
      using assms[rule_format, of "extreal e"] p_def r_def by auto }
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   695
    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
   696
    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
   697
  } ultimately have ?thesis by blast
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   698
}
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   699
moreover
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   700
{ 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
   701
    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
   702
} 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
   703
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   704
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   705
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   706
lemma extreal_le_epsilon2:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   707
  fixes x y :: extreal
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   708
  assumes "ALL e. 0 < e --> x <= y + extreal e"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   709
  shows "x <= y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   710
proof-
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   711
{ fix e :: extreal assume "e>0"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   712
  { 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
   713
  moreover
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   714
  { assume "e~=\<infinity>"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   715
    from this obtain r where "e = extreal r" using `e>0` apply (cases e) by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   716
    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
   717
  } ultimately have "x<=y+e" by blast
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   718
} from this show ?thesis using extreal_le_epsilon by auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   719
qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   720
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   721
lemma extreal_le_real:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   722
  fixes x y :: extreal
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   723
  assumes "ALL z. x <= extreal z --> y <= extreal z"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   724
  shows "y <= x"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   725
by (metis assms extreal.exhaust extreal_bot extreal_less_eq(1)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   726
          extreal_less_eq(2) order_refl uminus_extreal.simps(2))
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   727
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   728
lemma extreal_le_extreal:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   729
  fixes x y :: extreal
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   730
  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
   731
  shows "x <= y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   732
by (metis assms extreal_dense leD linorder_le_less_linear)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   733
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   734
lemma extreal_ge_extreal:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   735
  fixes x y :: extreal
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   736
  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
   737
  shows "x >= y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   738
by (metis assms extreal_dense leD linorder_le_less_linear)
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   739
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   740
lemma setprod_extreal_0:
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   741
  fixes f :: "'a \<Rightarrow> extreal"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   742
  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
   743
proof cases
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   744
  assume "finite A"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   745
  then show ?thesis by (induct A) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   746
qed auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   747
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   748
lemma setprod_extreal_pos:
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   749
  fixes f :: "'a \<Rightarrow> extreal" assumes pos: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" shows "0 \<le> (\<Prod>i\<in>I. f i)"
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 pos show ?thesis by induct auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   752
qed simp
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   753
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   754
lemma setprod_PInf:
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   755
  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
   756
  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
   757
proof cases
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   758
  assume "finite I" from this assms show ?thesis
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   759
  proof (induct I)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   760
    case (insert i I)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   761
    then have pos: "0 \<le> f i" "0 \<le> setprod f I" by (auto intro!: setprod_extreal_pos)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   762
    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
   763
    also have "\<dots> \<longleftrightarrow> (setprod f I = \<infinity> \<or> f i = \<infinity>) \<and> f i \<noteq> 0 \<and> setprod f I \<noteq> 0"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   764
      using setprod_extreal_pos[of I f] pos
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   765
      by (cases rule: extreal2_cases[of "f i" "setprod f I"]) auto
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   766
    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)"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   767
      using insert by (auto simp: setprod_extreal_0)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   768
    finally show ?case .
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   769
  qed simp
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   770
qed simp
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   771
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   772
lemma setprod_extreal: "(\<Prod>i\<in>A. extreal (f i)) = extreal (setprod f A)"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   773
proof cases
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   774
  assume "finite A" then show ?thesis
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   775
    by induct (auto simp: one_extreal_def)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   776
qed (simp add: one_extreal_def)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   777
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   778
subsubsection {* Power *}
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   779
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   780
instantiation extreal :: power
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   781
begin
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   782
primrec power_extreal where
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   783
  "power_extreal x 0 = 1" |
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   784
  "power_extreal x (Suc n) = x * x ^ n"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   785
instance ..
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   786
end
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   787
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   788
lemma extreal_power[simp]: "(extreal x) ^ n = extreal (x^n)"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   789
  by (induct n) (auto simp: one_extreal_def)
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   790
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   791
lemma extreal_power_PInf[simp]: "\<infinity> ^ n = (if n = 0 then 1 else \<infinity>)"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   792
  by (induct n) (auto simp: one_extreal_def)
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   793
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   794
lemma extreal_power_uminus[simp]:
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   795
  fixes x :: extreal
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   796
  shows "(- x) ^ n = (if even n then x ^ n else - (x^n))"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   797
  by (induct n) (auto simp: one_extreal_def)
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
   798
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   799
lemma extreal_power_number_of[simp]:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   800
  "(number_of num :: extreal) ^ n = extreal (number_of num ^ n)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   801
  by (induct n) (auto simp: one_extreal_def)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   802
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   803
lemma zero_le_power_extreal[simp]:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   804
  fixes a :: extreal assumes "0 \<le> a"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   805
  shows "0 \<le> a ^ n"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   806
  using assms by (induct n) (auto simp: extreal_zero_le_0_iff)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   807
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   808
subsubsection {* Subtraction *}
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   809
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   810
lemma extreal_minus_minus_image[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   811
  fixes S :: "extreal set"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   812
  shows "uminus ` uminus ` S = S"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   813
  by (auto simp: image_iff)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   814
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   815
lemma extreal_uminus_lessThan[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   816
  fixes a :: extreal shows "uminus ` {..<a} = {-a<..}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   817
proof (safe intro!: image_eqI)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   818
  fix x assume "-a < x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   819
  then have "- x < - (- a)" by (simp del: extreal_uminus_uminus)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   820
  then show "- x < a" by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   821
qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   822
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   823
lemma extreal_uminus_greaterThan[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   824
  "uminus ` {(a::extreal)<..} = {..<-a}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   825
  by (metis extreal_uminus_lessThan extreal_uminus_uminus
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   826
            extreal_minus_minus_image)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   827
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   828
instantiation extreal :: minus
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   829
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   830
definition "x - y = x + -(y::extreal)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   831
instance ..
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   832
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   833
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   834
lemma extreal_minus[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   835
  "extreal r - extreal p = extreal (r - p)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   836
  "-\<infinity> - extreal r = -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   837
  "extreal r - \<infinity> = -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   838
  "\<infinity> - x = \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   839
  "-\<infinity> - \<infinity> = -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   840
  "x - -y = x + y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   841
  "x - 0 = x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   842
  "0 - x = -x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   843
  by (simp_all add: minus_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   844
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   845
lemma extreal_x_minus_x[simp]:
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   846
  "x - x = (if \<bar>x\<bar> = \<infinity> then \<infinity> else 0)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   847
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   848
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   849
lemma extreal_eq_minus_iff:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   850
  fixes x y z :: extreal
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   851
  shows "x = z - y \<longleftrightarrow>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   852
    (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x + y = z) \<and>
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   853
    (y = -\<infinity> \<longrightarrow> x = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   854
    (y = \<infinity> \<longrightarrow> z = \<infinity> \<longrightarrow> x = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   855
    (y = \<infinity> \<longrightarrow> z \<noteq> \<infinity> \<longrightarrow> x = -\<infinity>)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   856
  by (cases rule: extreal3_cases[of x y z]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   857
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   858
lemma extreal_eq_minus:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   859
  fixes x y z :: extreal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   860
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x = z - y \<longleftrightarrow> x + y = z"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   861
  by (auto simp: extreal_eq_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   862
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   863
lemma extreal_less_minus_iff:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   864
  fixes x y z :: extreal
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   865
  shows "x < z - y \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   866
    (y = \<infinity> \<longrightarrow> z = \<infinity> \<and> x \<noteq> \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   867
    (y = -\<infinity> \<longrightarrow> x \<noteq> \<infinity>) \<and>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   868
    (\<bar>y\<bar> \<noteq> \<infinity>\<longrightarrow> x + y < z)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   869
  by (cases rule: extreal3_cases[of x y z]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   870
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   871
lemma extreal_less_minus:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   872
  fixes x y z :: extreal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   873
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x < z - y \<longleftrightarrow> x + y < z"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   874
  by (auto simp: extreal_less_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   875
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   876
lemma extreal_le_minus_iff:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   877
  fixes x y z :: extreal
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   878
  shows "x \<le> z - y \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   879
    (y = \<infinity> \<longrightarrow> z \<noteq> \<infinity> \<longrightarrow> x = -\<infinity>) \<and>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   880
    (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x + y \<le> z)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   881
  by (cases rule: extreal3_cases[of x y z]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   882
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   883
lemma extreal_le_minus:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   884
  fixes x y z :: extreal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   885
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x \<le> z - y \<longleftrightarrow> x + y \<le> z"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   886
  by (auto simp: extreal_le_minus_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   887
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   888
lemma extreal_minus_less_iff:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   889
  fixes x y z :: extreal
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   890
  shows "x - y < z \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   891
    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
   892
    (y \<noteq> \<infinity> \<longrightarrow> x < z + y)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   893
  by (cases rule: extreal3_cases[of x y z]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   894
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   895
lemma extreal_minus_less:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   896
  fixes x y z :: extreal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   897
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x - y < z \<longleftrightarrow> x < z + y"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   898
  by (auto simp: extreal_minus_less_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   899
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   900
lemma extreal_minus_le_iff:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   901
  fixes x y z :: extreal
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   902
  shows "x - y \<le> z \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   903
    (y = -\<infinity> \<longrightarrow> z = \<infinity>) \<and>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   904
    (y = \<infinity> \<longrightarrow> x = \<infinity> \<longrightarrow> z = \<infinity>) \<and>
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   905
    (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x \<le> z + y)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   906
  by (cases rule: extreal3_cases[of x y z]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   907
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   908
lemma extreal_minus_le:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   909
  fixes x y z :: extreal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   910
  shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x - y \<le> z \<longleftrightarrow> x \<le> z + y"
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   911
  by (auto simp: extreal_minus_le_iff)
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   912
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   913
lemma extreal_minus_eq_minus_iff:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   914
  fixes a b c :: extreal
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   915
  shows "a - b = a - c \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   916
    b = c \<or> a = \<infinity> \<or> (a = -\<infinity> \<and> b \<noteq> -\<infinity> \<and> c \<noteq> -\<infinity>)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   917
  by (cases rule: extreal3_cases[of a b c]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   918
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   919
lemma extreal_add_le_add_iff:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   920
  "c + a \<le> c + b \<longleftrightarrow>
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   921
    a \<le> b \<or> c = \<infinity> \<or> (c = -\<infinity> \<and> a \<noteq> \<infinity> \<and> b \<noteq> \<infinity>)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   922
  by (cases rule: extreal3_cases[of a b c]) (simp_all add: field_simps)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   923
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   924
lemma extreal_mult_le_mult_iff:
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   925
  "\<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)"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   926
  by (cases rule: extreal3_cases[of a b c]) (simp_all add: mult_le_cancel_left)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   927
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   928
lemma extreal_minus_mono:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   929
  fixes A B C D :: extreal assumes "A \<le> B" "D \<le> C"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   930
  shows "A - C \<le> B - D"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   931
  using assms
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   932
  by (cases rule: extreal3_cases[case_product extreal_cases, of A B C D]) simp_all
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   933
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   934
lemma real_of_extreal_minus:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   935
  "real (a - b) = (if \<bar>a\<bar> = \<infinity> \<or> \<bar>b\<bar> = \<infinity> then 0 else real a - real b)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   936
  by (cases rule: extreal2_cases[of a b]) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   937
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   938
lemma extreal_diff_positive:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   939
  fixes a b :: extreal shows "a \<le> b \<Longrightarrow> 0 \<le> b - a"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   940
  by (cases rule: extreal2_cases[of a b]) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
   941
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   942
lemma extreal_between:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   943
  fixes x e :: extreal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   944
  assumes "\<bar>x\<bar> \<noteq> \<infinity>" "0 < e"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   945
  shows "x - e < x" "x < x + e"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   946
using assms apply (cases x, cases e) apply auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   947
using assms by (cases x, cases e) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   948
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   949
subsubsection {* Division *}
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   950
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   951
instantiation extreal :: inverse
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   952
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   953
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   954
function inverse_extreal where
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   955
"inverse (extreal r) = (if r = 0 then \<infinity> else extreal (inverse r))" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   956
"inverse \<infinity> = 0" |
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   957
"inverse (-\<infinity>) = 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   958
  by (auto intro: extreal_cases)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   959
termination by (relation "{}") simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   960
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   961
definition "x / y = x * inverse (y :: extreal)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   962
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   963
instance proof qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   964
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   965
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   966
lemma real_of_extreal_inverse[simp]:
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   967
  fixes a :: extreal
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   968
  shows "real (inverse a) = 1 / real a"
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   969
  by (cases a) (auto simp: inverse_eq_divide)
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42600
diff changeset
   970
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   971
lemma extreal_inverse[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   972
  "inverse 0 = \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   973
  "inverse (1::extreal) = 1"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   974
  by (simp_all add: one_extreal_def zero_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   975
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   976
lemma extreal_divide[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   977
  "extreal r / extreal p = (if p = 0 then extreal r * \<infinity> else extreal (r / p))"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   978
  unfolding divide_extreal_def by (auto simp: divide_real_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   979
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   980
lemma extreal_divide_same[simp]:
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
   981
  "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
   982
  by (cases x)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   983
     (simp_all add: divide_real_def divide_extreal_def one_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   984
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   985
lemma extreal_inv_inv[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   986
  "inverse (inverse x) = (if x \<noteq> -\<infinity> then x else \<infinity>)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   987
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   988
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   989
lemma extreal_inverse_minus[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   990
  "inverse (- x) = (if x = 0 then \<infinity> else -inverse x)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   991
  by (cases x) simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   992
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   993
lemma extreal_uminus_divide[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   994
  fixes x y :: extreal shows "- x / y = - (x / y)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   995
  unfolding divide_extreal_def by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   996
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   997
lemma extreal_divide_Infty[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   998
  "x / \<infinity> = 0" "x / -\<infinity> = 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
   999
  unfolding divide_extreal_def by simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1000
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1001
lemma extreal_divide_one[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1002
  "x / 1 = (x::extreal)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1003
  unfolding divide_extreal_def by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1004
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1005
lemma extreal_divide_extreal[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1006
  "\<infinity> / extreal r = (if 0 \<le> r then \<infinity> else -\<infinity>)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1007
  unfolding divide_extreal_def by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1008
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1009
lemma zero_le_divide_extreal[simp]:
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1010
  fixes a :: extreal assumes "0 \<le> a" "0 \<le> b"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1011
  shows "0 \<le> a / b"
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1012
  using assms by (cases rule: extreal2_cases[of a b]) (auto simp: zero_le_divide_iff)
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1013
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1014
lemma extreal_le_divide_pos:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1015
  "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y \<le> z / x \<longleftrightarrow> x * y \<le> z"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1016
  by (cases rule: extreal3_cases[of x y z]) (auto simp: field_simps)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1017
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1018
lemma extreal_divide_le_pos:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1019
  "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> z / x \<le> y \<longleftrightarrow> z \<le> x * y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1020
  by (cases rule: extreal3_cases[of x y z]) (auto simp: field_simps)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1021
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1022
lemma extreal_le_divide_neg:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1023
  "x < 0 \<Longrightarrow> x \<noteq> -\<infinity> \<Longrightarrow> y \<le> z / x \<longleftrightarrow> z \<le> x * y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1024
  by (cases rule: extreal3_cases[of x y z]) (auto simp: field_simps)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1025
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1026
lemma extreal_divide_le_neg:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1027
  "x < 0 \<Longrightarrow> x \<noteq> -\<infinity> \<Longrightarrow> z / x \<le> y \<longleftrightarrow> x * y \<le> z"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1028
  by (cases rule: extreal3_cases[of x y z]) (auto simp: field_simps)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1029
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1030
lemma extreal_inverse_antimono_strict:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1031
  fixes x y :: extreal
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1032
  shows "0 \<le> x \<Longrightarrow> x < y \<Longrightarrow> inverse y < inverse x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1033
  by (cases rule: extreal2_cases[of x y]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1034
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1035
lemma extreal_inverse_antimono:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1036
  fixes x y :: extreal
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1037
  shows "0 \<le> x \<Longrightarrow> x <= y \<Longrightarrow> inverse y <= inverse x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1038
  by (cases rule: extreal2_cases[of x y]) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1039
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1040
lemma inverse_inverse_Pinfty_iff[simp]:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1041
  "inverse x = \<infinity> \<longleftrightarrow> x = 0"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1042
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1043
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1044
lemma extreal_inverse_eq_0:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1045
  "inverse x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1046
  by (cases x) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1047
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1048
lemma extreal_0_gt_inverse:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1049
  fixes x :: extreal shows "0 < inverse x \<longleftrightarrow> x \<noteq> \<infinity> \<and> 0 \<le> x"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1050
  by (cases x) auto
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1051
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1052
lemma extreal_mult_less_right:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1053
  assumes "b * a < c * a" "0 < a" "a < \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1054
  shows "b < c"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1055
  using assms
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1056
  by (cases rule: extreal3_cases[of a b c])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1057
     (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
  1058
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1059
lemma extreal_power_divide:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1060
  "y \<noteq> 0 \<Longrightarrow> (x / y :: extreal) ^ n = x^n / y^n"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1061
  by (cases rule: extreal2_cases[of x y])
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1062
     (auto simp: one_extreal_def zero_extreal_def power_divide not_le
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1063
                 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
  1064
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1065
lemma extreal_le_mult_one_interval:
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1066
  fixes x y :: extreal
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1067
  assumes y: "y \<noteq> -\<infinity>"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1068
  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
  1069
  shows "x \<le> y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1070
proof (cases x)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1071
  case PInf with z[of "1 / 2"] show "x \<le> y" by (simp add: one_extreal_def)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1072
next
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1073
  case (real r) note r = this
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1074
  show "x \<le> y"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1075
  proof (cases y)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1076
    case (real p) note p = this
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1077
    have "r \<le> p"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1078
    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
  1079
      fix z :: real assume "0 < z" and "z < 1"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1080
      with z[of "extreal z"]
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1081
      show "z * r \<le> p" using p r by (auto simp: zero_le_mult_iff one_extreal_def)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1082
    qed
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1083
    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
  1084
  qed (insert y, simp_all)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1085
qed simp
41978
656298577a33 add infinite sums and power on extreal
hoelzl
parents: 41977
diff changeset
  1086
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1087
subsection "Complete lattice"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1088
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1089
instantiation extreal :: lattice
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1090
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1091
definition [simp]: "sup x y = (max x y :: extreal)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1092
definition [simp]: "inf x y = (min x y :: extreal)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1093
instance proof qed simp_all
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1094
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1095
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1096
instantiation extreal :: complete_lattice
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1097
begin
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1098
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1099
definition "bot = -\<infinity>"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1100
definition "top = \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1101
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1102
definition "Sup S = (LEAST z. ALL x:S. x <= z :: extreal)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1103
definition "Inf S = (GREATEST z. ALL x:S. z <= x :: extreal)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1104
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1105
lemma extreal_complete_Sup:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1106
  fixes S :: "extreal set" assumes "S \<noteq> {}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1107
  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
  1108
proof cases
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1109
  assume "\<exists>x. \<forall>a\<in>S. a \<le> extreal x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1110
  then obtain y where y: "\<And>a. a\<in>S \<Longrightarrow> a \<le> extreal y" by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1111
  then have "\<infinity> \<notin> S" by force
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1112
  show ?thesis
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1113
  proof cases
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1114
    assume "S = {-\<infinity>}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1115
    then show ?thesis by (auto intro!: exI[of _ "-\<infinity>"])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1116
  next
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1117
    assume "S \<noteq> {-\<infinity>}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1118
    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
  1119
    with y `\<infinity> \<notin> S` have "\<forall>z\<in>real ` (S - {-\<infinity>}). z \<le> y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1120
      by (auto simp: real_of_extreal_ord_simps)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1121
    with reals_complete2[of "real ` (S - {-\<infinity>})"] `x \<in> S - {-\<infinity>}`
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1122
    obtain s where s:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1123
       "\<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
  1124
       by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1125
    show ?thesis
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1126
    proof (safe intro!: exI[of _ "extreal s"])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1127
      fix z assume "z \<in> S" with `\<infinity> \<notin> S` show "z \<le> extreal s"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1128
      proof (cases z)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1129
        case (real r)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1130
        then show ?thesis
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1131
          using s(1)[rule_format, of z] `z \<in> S` `z = extreal r` by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1132
      qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1133
    next
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1134
      fix z assume *: "\<forall>y\<in>S. y \<le> z"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1135
      with `S \<noteq> {-\<infinity>}` `S \<noteq> {}` show "extreal s \<le> z"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1136
      proof (cases z)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1137
        case (real u)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1138
        with * have "s \<le> u"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1139
          by (intro s(2)[of u]) (auto simp: real_of_extreal_ord_simps)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1140
        then show ?thesis using real by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1141
      qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1142
    qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1143
  qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1144
next
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1145
  assume *: "\<not> (\<exists>x. \<forall>a\<in>S. a \<le> extreal x)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1146
  show ?thesis
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1147
  proof (safe intro!: exI[of _ \<infinity>])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1148
    fix y assume **: "\<forall>z\<in>S. z \<le> y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1149
    with * show "\<infinity> \<le> y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1150
    proof (cases y)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1151
      case MInf with * ** show ?thesis by (force simp: not_le)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1152
    qed auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1153
  qed simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1154
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1155
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1156
lemma extreal_complete_Inf:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1157
  fixes S :: "extreal set" assumes "S ~= {}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1158
  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
  1159
proof-
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1160
def S1 == "uminus ` S"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1161
hence "S1 ~= {}" using assms by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1162
from this obtain x where x_def: "(ALL y:S1. y <= x) & (ALL z. (ALL y:S1. y <= z) --> x <= z)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1163
   using extreal_complete_Sup[of S1] by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1164
{ fix z assume "ALL y:S. z <= y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1165
  hence "ALL y:S1. y <= -z" unfolding S1_def by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1166
  hence "x <= -z" using x_def by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1167
  hence "z <= -x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1168
    apply (subst extreal_uminus_uminus[symmetric])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1169
    unfolding extreal_minus_le_minus . }
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1170
moreover have "(ALL y:S. -x <= y)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1171
   using x_def unfolding S1_def
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1172
   apply simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1173
   apply (subst (3) extreal_uminus_uminus[symmetric])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1174
   unfolding extreal_minus_le_minus by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1175
ultimately show ?thesis by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1176
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1177
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1178
lemma extreal_complete_uminus_eq:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1179
  fixes S :: "extreal set"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1180
  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
  1181
     \<longleftrightarrow> (\<forall>y\<in>S. -x \<le> y) \<and> (\<forall>z. (\<forall>y\<in>S. z \<le> y) \<longrightarrow> z \<le> -x)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1182
  by simp (metis extreal_minus_le_minus extreal_uminus_uminus)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1183
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1184
lemma extreal_Sup_uminus_image_eq:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1185
  fixes S :: "extreal set"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1186
  shows "Sup (uminus ` S) = - Inf S"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1187
proof cases
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1188
  assume "S = {}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1189
  moreover have "(THE x. All (op \<le> x)) = (-\<infinity>::extreal)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1190
    by (rule the_equality) (auto intro!: extreal_bot)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1191
  moreover have "(SOME x. \<forall>y. y \<le> x) = (\<infinity>::extreal)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1192
    by (rule some_equality) (auto intro!: extreal_top)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1193
  ultimately show ?thesis unfolding Inf_extreal_def Sup_extreal_def
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1194
    Least_def Greatest_def GreatestM_def by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1195
next
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1196
  assume "S \<noteq> {}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1197
  with extreal_complete_Sup[of "uminus`S"]
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1198
  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)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1199
    unfolding extreal_complete_uminus_eq by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1200
  show "Sup (uminus ` S) = - Inf S"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1201
    unfolding Inf_extreal_def Greatest_def GreatestM_def
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1202
  proof (intro someI2[of _ _ "\<lambda>x. Sup (uminus`S) = - x"])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1203
    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
  1204
      using x .
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1205
    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
  1206
    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)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1207
      unfolding extreal_complete_uminus_eq by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1208
    then show "Sup (uminus ` S) = -x'"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1209
      unfolding Sup_extreal_def extreal_uminus_eq_iff
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1210
      by (intro Least_equality) auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1211
  qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1212
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1213
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1214
instance
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1215
proof
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1216
  { fix x :: extreal and A
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1217
    show "bot <= x" by (cases x) (simp_all add: bot_extreal_def)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1218
    show "x <= top" by (simp add: top_extreal_def) }
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1219
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1220
  { fix x :: extreal and A assume "x : A"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1221
    with extreal_complete_Sup[of A]
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1222
    obtain s where s: "\<forall>y\<in>A. y <= s" "\<forall>z. (\<forall>y\<in>A. y <= z) \<longrightarrow> s <= z" by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1223
    hence "x <= s" using `x : A` by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1224
    also have "... = Sup A" using s unfolding Sup_extreal_def
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1225
      by (auto intro!: Least_equality[symmetric])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1226
    finally show "x <= Sup A" . }
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1227
  note le_Sup = this
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
  { fix x :: extreal and A assume *: "!!z. (z : A ==> z <= x)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1230
    show "Sup A <= x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1231
    proof (cases "A = {}")
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1232
      case True
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1233
      hence "Sup A = -\<infinity>" unfolding Sup_extreal_def
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1234
        by (auto intro!: Least_equality)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1235
      thus "Sup A <= x" by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1236
    next
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1237
      case False
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1238
      with extreal_complete_Sup[of A]
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1239
      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
  1240
      hence "Sup A = s"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1241
        unfolding Sup_extreal_def by (auto intro!: Least_equality)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1242
      also have "s <= x" using * s by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1243
      finally show "Sup A <= x" .
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1244
    qed }
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1245
  note Sup_le = this
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1246
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1247
  { fix x :: extreal and A assume "x \<in> A"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1248
    with le_Sup[of "-x" "uminus`A"] show "Inf A \<le> x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1249
      unfolding extreal_Sup_uminus_image_eq by simp }
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1250
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1251
  { fix x :: extreal and A assume *: "!!z. (z : A ==> x <= z)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1252
    with Sup_le[of "uminus`A" "-x"] show "x \<le> Inf A"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1253
      unfolding extreal_Sup_uminus_image_eq by force }
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1254
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1255
end
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1256
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1257
lemma extreal_SUPR_uminus:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1258
  fixes f :: "'a => extreal"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1259
  shows "(SUP i : R. -(f i)) = -(INF i : R. f i)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1260
  unfolding SUPR_def INFI_def
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1261
  using extreal_Sup_uminus_image_eq[of "f`R"]
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1262
  by (simp add: image_image)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1263
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1264
lemma extreal_INFI_uminus:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1265
  fixes f :: "'a => extreal"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1266
  shows "(INF i : R. -(f i)) = -(SUP i : R. f i)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1267
  using extreal_SUPR_uminus[of _ "\<lambda>x. - f x"] by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1268
41979
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1269
lemma extreal_Inf_uminus_image_eq: "Inf (uminus ` S) = - Sup (S::extreal set)"
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1270
  using extreal_Sup_uminus_image_eq[of "uminus ` S"] by (simp add: image_image)
b10ec1f5e9d5 lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents: 41978
diff changeset
  1271
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1272
lemma extreal_inj_on_uminus[intro, simp]: "inj_on uminus (A :: extreal set)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1273
  by (auto intro!: inj_onI)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1274
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1275
lemma extreal_image_uminus_shift:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1276
  fixes X Y :: "extreal set" shows "uminus ` X = Y \<longleftrightarrow> X = uminus ` Y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1277
proof
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1278
  assume "uminus ` X = Y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1279
  then have "uminus ` uminus ` X = uminus ` Y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1280
    by (simp add: inj_image_eq_iff)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1281
  then show "X = uminus ` Y" by (simp add: image_image)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1282
qed (simp add: image_image)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1283
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1284
lemma Inf_extreal_iff:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1285
  fixes z :: extreal
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1286
  shows "(!!x. x:X ==> z <= x) ==> (EX x:X. x<y) <-> Inf X < y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1287
  by (metis complete_lattice_class.Inf_greatest complete_lattice_class.Inf_lower less_le_not_le linear
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1288
            order_less_le_trans)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1289
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1290
lemma Sup_eq_MInfty:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1291
  fixes S :: "extreal set" shows "Sup S = -\<infinity> \<longleftrightarrow> S = {} \<or> S = {-\<infinity>}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1292
proof
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1293
  assume a: "Sup S = -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1294
  with complete_lattice_class.Sup_upper[of _ S]
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1295
  show "S={} \<or> S={-\<infinity>}" by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1296
next
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1297
  assume "S={} \<or> S={-\<infinity>}" then show "Sup S = -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1298
    unfolding Sup_extreal_def by (auto intro!: Least_equality)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1299
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1300
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1301
lemma Inf_eq_PInfty:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1302
  fixes S :: "extreal set" shows "Inf S = \<infinity> \<longleftrightarrow> S = {} \<or> S = {\<infinity>}"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1303
  using Sup_eq_MInfty[of "uminus`S"]
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1304
  unfolding extreal_Sup_uminus_image_eq extreal_image_uminus_shift by simp
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1305
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1306
lemma Inf_eq_MInfty: "-\<infinity> : S ==> Inf S = -\<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1307
  unfolding Inf_extreal_def
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1308
  by (auto intro!: Greatest_equality)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1309
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1310
lemma Sup_eq_PInfty: "\<infinity> : S ==> Sup S = \<infinity>"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1311
  unfolding Sup_extreal_def
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1312
  by (auto intro!: Least_equality)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1313
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1314
lemma extreal_SUPI:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1315
  fixes x :: extreal
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1316
  assumes "!!i. i : A ==> f i <= x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1317
  assumes "!!y. (!!i. i : A ==> f i <= y) ==> x <= y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1318
  shows "(SUP i:A. f i) = x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1319
  unfolding SUPR_def Sup_extreal_def
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1320
  using assms by (auto intro!: Least_equality)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1321
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1322
lemma extreal_INFI:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1323
  fixes x :: extreal
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1324
  assumes "!!i. i : A ==> f i >= x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1325
  assumes "!!y. (!!i. i : A ==> f i >= y) ==> x >= y"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1326
  shows "(INF i:A. f i) = x"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1327
  unfolding INFI_def Inf_extreal_def
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1328
  using assms by (auto intro!: Greatest_equality)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1329
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1330
lemma Sup_extreal_close:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1331
  fixes e :: extreal
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1332
  assumes "0 < e" and S: "\<bar>Sup S\<bar> \<noteq> \<infinity>" "S \<noteq> {}"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1333
  shows "\<exists>x\<in>S. Sup S - e < x"
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1334
  using assms by (cases e) (auto intro!: less_Sup_iff[THEN iffD1])
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1335
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1336
lemma Inf_extreal_close:
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1337
  fixes e :: extreal assumes "\<bar>Inf X\<bar> \<noteq> \<infinity>" "0 < e"
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1338
  shows "\<exists>x\<in>X. x < Inf X + e"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1339
proof (rule Inf_less_iff[THEN iffD1])
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1340
  show "Inf X < Inf X + e" using assms
41976
3fdbc7d5b525 use abs_extreal
hoelzl
parents: 41975
diff changeset
  1341
    by (cases e) auto
41973
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1342
qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1343
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1344
lemma Sup_eq_top_iff:
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1345
  fixes A :: "'a::{complete_lattice, linorder} set"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1346
  shows "Sup A = top \<longleftrightarrow> (\<forall>x<top. \<exists>i\<in>A. x < i)"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1347
proof
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1348
  assume *: "Sup A = top"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1349
  show "(\<forall>x<top. \<exists>i\<in>A. x < i)" unfolding *[symmetric]
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1350
  proof (intro allI impI)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1351
    fix x assume "x < Sup A" then show "\<exists>i\<in>A. x < i"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1352
      unfolding less_Sup_iff by auto
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1353
  qed
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1354
next
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1355
  assume *: "\<forall>x<top. \<exists>i\<in>A. x < i"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1356
  show "Sup A = top"
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset
  1357
  proof (rule ccontr)
15927c040731 add Extended_Reals from AFP/Lower_Semicontinuous
hoelzl
parents:
diff changeset