src/HOL/Probability/Positive_Infinite_Real.thy
author hoelzl
Mon, 23 Aug 2010 19:35:57 +0200
changeset 38656 d5d342611edb
child 38705 aaee86c0e237
permissions -rw-r--r--
Rewrite the Probability theory. Introduced pinfreal as real numbers with infinity. Use pinfreal as value for measures. Introduces Lebesgue Measure based on the integral in Multivariate Analysis. Proved Radon Nikodym for arbitrary sigma finite measure spaces.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     1
(* Author: Johannes Hoelzl, TU Muenchen *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     2
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     3
header {* A type for positive real numbers with infinity *}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     4
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     5
theory Positive_Infinite_Real
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     6
  imports Complex_Main Nat_Bijection Multivariate_Analysis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     7
begin
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     8
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     9
lemma less_Sup_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    10
  fixes a :: "'x\<Colon>{complete_lattice,linorder}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    11
  shows "a < Sup S \<longleftrightarrow> (\<exists> x \<in> S. a < x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    12
  unfolding not_le[symmetric] Sup_le_iff by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    13
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    14
lemma Inf_less_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    15
  fixes a :: "'x\<Colon>{complete_lattice,linorder}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    16
  shows "Inf S < a \<longleftrightarrow> (\<exists> x \<in> S. x < a)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    17
  unfolding not_le[symmetric] le_Inf_iff by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    18
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    19
lemma SUPR_fun_expand: "(SUP y:A. f y) = (\<lambda>x. SUP y:A. f y x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    20
  unfolding SUPR_def expand_fun_eq Sup_fun_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    21
  by (auto intro!: arg_cong[where f=Sup])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    22
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    23
lemma real_Suc_natfloor: "r < real (Suc (natfloor r))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    24
proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    25
  assume "0 \<le> r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    26
  from floor_correct[of r]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    27
  have "r < real (\<lfloor>r\<rfloor> + 1)" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    28
  also have "\<dots> = real (Suc (natfloor r))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    29
    using `0 \<le> r` by (auto simp: real_of_nat_Suc natfloor_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    30
  finally show ?thesis .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    31
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    32
  assume "\<not> 0 \<le> r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    33
  hence "r < 0" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    34
  also have "0 < real (Suc (natfloor r))" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    35
  finally show ?thesis .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    36
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    37
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    38
lemma (in complete_lattice) Sup_mono:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    39
  assumes "\<And>a. a \<in> A \<Longrightarrow> \<exists>b\<in>B. a \<le> b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    40
  shows "Sup A \<le> Sup B"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    41
proof (rule Sup_least)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    42
  fix a assume "a \<in> A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    43
  with assms obtain b where "b \<in> B" and "a \<le> b" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    44
  hence "b \<le> Sup B" by (auto intro: Sup_upper)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    45
  with `a \<le> b` show "a \<le> Sup B" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    46
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    47
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    48
lemma (in complete_lattice) Inf_mono:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    49
  assumes "\<And>b. b \<in> B \<Longrightarrow> \<exists>a\<in>A. a \<le> b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    50
  shows "Inf A \<le> Inf B"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    51
proof (rule Inf_greatest)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    52
  fix b assume "b \<in> B"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    53
  with assms obtain a where "a \<in> A" and "a \<le> b" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    54
  hence "Inf A \<le> a" by (auto intro: Inf_lower)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    55
  with `a \<le> b` show "Inf A \<le> b" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    56
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    57
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    58
lemma (in complete_lattice) Sup_mono_offset:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    59
  fixes f :: "'b :: {ordered_ab_semigroup_add,monoid_add} \<Rightarrow> 'a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    60
  assumes *: "\<And>x y. x \<le> y \<Longrightarrow> f x \<le> f y" and "0 \<le> k"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    61
  shows "(SUP n . f (k + n)) = (SUP n. f n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    62
proof (rule antisym)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    63
  show "(SUP n. f (k + n)) \<le> (SUP n. f n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    64
    by (auto intro!: Sup_mono simp: SUPR_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    65
  { fix n :: 'b
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    66
    have "0 + n \<le> k + n" using `0 \<le> k` by (rule add_right_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    67
    with * have "f n \<le> f (k + n)" by simp }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    68
  thus "(SUP n. f n) \<le> (SUP n. f (k + n))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    69
    by (auto intro!: Sup_mono exI simp: SUPR_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    70
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    71
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    72
lemma (in complete_lattice) Sup_mono_offset_Suc:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    73
  assumes *: "\<And>x. f x \<le> f (Suc x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    74
  shows "(SUP n . f (Suc n)) = (SUP n. f n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    75
  unfolding Suc_eq_plus1
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    76
  apply (subst add_commute)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    77
  apply (rule Sup_mono_offset)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    78
  by (auto intro!: order.lift_Suc_mono_le[of "op \<le>" "op <" f, OF _ *]) default
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    79
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    80
lemma (in complete_lattice) Inf_start:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    81
  assumes *: "\<And>x. f 0 \<le> f x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    82
  shows "(INF n. f n) = f 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    83
proof (rule antisym)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    84
  show "(INF n. f n) \<le> f 0" by (rule INF_leI) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    85
  show "f 0 \<le> (INF n. f n)" by (rule le_INFI[OF *])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    86
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    87
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    88
lemma (in complete_lattice) isotone_converge:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    89
  fixes f :: "nat \<Rightarrow> 'a" assumes "\<And>x y. x \<le> y \<Longrightarrow> f x \<le> f y "
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    90
  shows "(INF n. SUP m. f (n + m)) = (SUP n. INF m. f (n + m))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    91
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    92
  have "\<And>n. (SUP m. f (n + m)) = (SUP n. f n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    93
    apply (rule Sup_mono_offset)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    94
    apply (rule assms)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    95
    by simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    96
  moreover
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    97
  { fix n have "(INF m. f (n + m)) = f n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    98
      using Inf_start[of "\<lambda>m. f (n + m)"] assms by simp }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    99
  ultimately show ?thesis by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   100
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   101
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   102
lemma (in complete_lattice) Inf_mono_offset:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   103
  fixes f :: "'b :: {ordered_ab_semigroup_add,monoid_add} \<Rightarrow> 'a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   104
  assumes *: "\<And>x y. x \<le> y \<Longrightarrow> f y \<le> f x" and "0 \<le> k"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   105
  shows "(INF n . f (k + n)) = (INF n. f n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   106
proof (rule antisym)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   107
  show "(INF n. f n) \<le> (INF n. f (k + n))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   108
    by (auto intro!: Inf_mono simp: INFI_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   109
  { fix n :: 'b
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   110
    have "0 + n \<le> k + n" using `0 \<le> k` by (rule add_right_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   111
    with * have "f (k + n) \<le> f n" by simp }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   112
  thus "(INF n. f (k + n)) \<le> (INF n. f n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   113
    by (auto intro!: Inf_mono exI simp: INFI_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   114
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   115
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   116
lemma (in complete_lattice) Sup_start:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   117
  assumes *: "\<And>x. f x \<le> f 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   118
  shows "(SUP n. f n) = f 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   119
proof (rule antisym)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   120
  show "f 0 \<le> (SUP n. f n)" by (rule le_SUPI) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   121
  show "(SUP n. f n) \<le> f 0" by (rule SUP_leI[OF *])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   122
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   123
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   124
lemma (in complete_lattice) antitone_converges:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   125
  fixes f :: "nat \<Rightarrow> 'a" assumes "\<And>x y. x \<le> y \<Longrightarrow> f y \<le> f x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   126
  shows "(INF n. SUP m. f (n + m)) = (SUP n. INF m. f (n + m))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   127
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   128
  have "\<And>n. (INF m. f (n + m)) = (INF n. f n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   129
    apply (rule Inf_mono_offset)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   130
    apply (rule assms)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   131
    by simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   132
  moreover
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   133
  { fix n have "(SUP m. f (n + m)) = f n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   134
      using Sup_start[of "\<lambda>m. f (n + m)"] assms by simp }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   135
  ultimately show ?thesis by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   136
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   137
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   138
text {*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   139
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   140
We introduce the the positive real numbers as needed for measure theory.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   141
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   142
*}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   143
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   144
typedef pinfreal = "(Some ` {0::real..}) \<union> {None}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   145
  by (rule exI[of _ None]) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   146
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   147
subsection "Introduce @{typ pinfreal} similar to a datatype"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   148
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   149
definition "Real x = Abs_pinfreal (Some (sup 0 x))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   150
definition "\<omega> = Abs_pinfreal None"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   151
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   152
definition "pinfreal_case f i x = (if x = \<omega> then i else f (THE r. 0 \<le> r \<and> x = Real r))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   153
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   154
definition "of_pinfreal = pinfreal_case (\<lambda>x. x) 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   155
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   156
defs (overloaded)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   157
  real_of_pinfreal_def [code_unfold]: "real == of_pinfreal"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   158
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   159
lemma pinfreal_Some[simp]: "0 \<le> x \<Longrightarrow> Some x \<in> pinfreal"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   160
  unfolding pinfreal_def by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   161
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   162
lemma pinfreal_Some_sup[simp]: "Some (sup 0 x) \<in> pinfreal"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   163
  by (simp add: sup_ge1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   164
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   165
lemma pinfreal_None[simp]: "None \<in> pinfreal"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   166
  unfolding pinfreal_def by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   167
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   168
lemma Real_inj[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   169
  assumes  "0 \<le> x" and "0 \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   170
  shows "Real x = Real y \<longleftrightarrow> x = y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   171
  unfolding Real_def assms[THEN sup_absorb2]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   172
  using assms by (simp add: Abs_pinfreal_inject)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   173
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   174
lemma Real_neq_\<omega>[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   175
  "Real x = \<omega> \<longleftrightarrow> False"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   176
  "\<omega> = Real x \<longleftrightarrow> False"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   177
  by (simp_all add: Abs_pinfreal_inject \<omega>_def Real_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   178
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   179
lemma Real_neg: "x < 0 \<Longrightarrow> Real x = Real 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   180
  unfolding Real_def by (auto simp add: Abs_pinfreal_inject intro!: sup_absorb1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   181
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   182
lemma pinfreal_cases[case_names preal infinite, cases type: pinfreal]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   183
  assumes preal: "\<And>r. x = Real r \<Longrightarrow> 0 \<le> r \<Longrightarrow> P" and inf: "x = \<omega> \<Longrightarrow> P"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   184
  shows P
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   185
proof (cases x rule: pinfreal.Abs_pinfreal_cases)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   186
  case (Abs_pinfreal y)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   187
  hence "y = None \<or> (\<exists>x \<ge> 0. y = Some x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   188
    unfolding pinfreal_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   189
  thus P
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   190
  proof (rule disjE)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   191
    assume "\<exists>x\<ge>0. y = Some x" then guess x ..
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   192
    thus P by (simp add: preal[of x] Real_def Abs_pinfreal(1) sup_absorb2)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   193
  qed (simp add: \<omega>_def Abs_pinfreal(1) inf)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   194
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   195
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   196
lemma pinfreal_case_\<omega>[simp]: "pinfreal_case f i \<omega> = i"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   197
  unfolding pinfreal_case_def by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   198
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   199
lemma pinfreal_case_Real[simp]: "pinfreal_case f i (Real x) = (if 0 \<le> x then f x else f 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   200
proof (cases "0 \<le> x")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   201
  case True thus ?thesis unfolding pinfreal_case_def by (auto intro: theI2)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   202
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   203
  case False
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   204
  moreover have "(THE r. 0 \<le> r \<and> Real 0 = Real r) = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   205
    by (auto intro!: the_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   206
  ultimately show ?thesis unfolding pinfreal_case_def by (simp add: Real_neg)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   207
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   208
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   209
lemma pinfreal_case_cancel[simp]: "pinfreal_case (\<lambda>c. i) i x = i"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   210
  by (cases x) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   211
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   212
lemma pinfreal_case_split:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   213
  "P (pinfreal_case f i x) = ((x = \<omega> \<longrightarrow> P i) \<and> (\<forall>r\<ge>0. x = Real r \<longrightarrow> P (f r)))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   214
  by (cases x) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   215
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   216
lemma pinfreal_case_split_asm:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   217
  "P (pinfreal_case f i x) = (\<not> (x = \<omega> \<and> \<not> P i \<or> (\<exists>r. r \<ge> 0 \<and> x = Real r \<and> \<not> P (f r))))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   218
  by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   219
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   220
lemma pinfreal_case_cong[cong]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   221
  assumes eq: "x = x'" "i = i'" and cong: "\<And>r. 0 \<le> r \<Longrightarrow> f r = f' r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   222
  shows "pinfreal_case f i x = pinfreal_case f' i' x'"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   223
  unfolding eq using cong by (cases x') simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   224
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   225
lemma real_Real[simp]: "real (Real x) = (if 0 \<le> x then x else 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   226
  unfolding real_of_pinfreal_def of_pinfreal_def by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   227
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   228
lemma Real_real_image:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   229
  assumes "\<omega> \<notin> A" shows "Real ` real ` A = A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   230
proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   231
  fix x assume "x \<in> A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   232
  hence *: "x = Real (real x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   233
    using `\<omega> \<notin> A` by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   234
  show "x \<in> Real ` real ` A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   235
    using `x \<in> A` by (subst *) (auto intro!: imageI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   236
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   237
  fix x assume "x \<in> A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   238
  thus "Real (real x) \<in> A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   239
    using `\<omega> \<notin> A` by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   240
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   241
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   242
lemma real_pinfreal_nonneg[simp, intro]: "0 \<le> real (x :: pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   243
  unfolding real_of_pinfreal_def of_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   244
  by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   245
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   246
lemma real_\<omega>[simp]: "real \<omega> = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   247
  unfolding real_of_pinfreal_def of_pinfreal_def by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   248
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   249
lemma pinfreal_noteq_omega_Ex: "X \<noteq> \<omega> \<longleftrightarrow> (\<exists>r\<ge>0. X = Real r)" by (cases X) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   250
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   251
subsection "@{typ pinfreal} is a monoid for addition"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   252
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   253
instantiation pinfreal :: comm_monoid_add
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   254
begin
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   255
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   256
definition "0 = Real 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   257
definition "x + y = pinfreal_case (\<lambda>r. pinfreal_case (\<lambda>p. Real (r + p)) \<omega> y) \<omega> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   258
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   259
lemma pinfreal_plus[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   260
  "Real r + Real p = (if 0 \<le> r then if 0 \<le> p then Real (r + p) else Real r else Real p)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   261
  "x + 0 = x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   262
  "0 + x = x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   263
  "x + \<omega> = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   264
  "\<omega> + x = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   265
  by (simp_all add: plus_pinfreal_def Real_neg zero_pinfreal_def split: pinfreal_case_split)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   266
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   267
lemma \<omega>_neq_0[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   268
  "\<omega> = 0 \<longleftrightarrow> False"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   269
  "0 = \<omega> \<longleftrightarrow> False"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   270
  by (simp_all add: zero_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   271
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   272
lemma Real_eq_0[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   273
  "Real r = 0 \<longleftrightarrow> r \<le> 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   274
  "0 = Real r \<longleftrightarrow> r \<le> 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   275
  by (auto simp add: Abs_pinfreal_inject zero_pinfreal_def Real_def sup_real_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   276
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   277
lemma Real_0[simp]: "Real 0 = 0" by (simp add: zero_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   278
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   279
instance
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   280
proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   281
  fix a :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   282
  show "0 + a = a" by (cases a) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   283
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   284
  fix b show "a + b = b + a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   285
    by (cases a, cases b) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   286
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   287
  fix c show "a + b + c = a + (b + c)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   288
    by (cases a, cases b, cases c) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   289
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   290
end
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   291
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   292
lemma pinfreal_plus_eq_\<omega>[simp]: "(a :: pinfreal) + b = \<omega> \<longleftrightarrow> a = \<omega> \<or> b = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   293
  by (cases a, cases b) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   294
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   295
lemma pinfreal_add_cancel_left:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   296
  "a + b = a + c \<longleftrightarrow> (a = \<omega> \<or> b = c)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   297
  by (cases a, cases b, cases c, simp_all, cases c, simp_all)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   298
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   299
lemma pinfreal_add_cancel_right:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   300
  "b + a = c + a \<longleftrightarrow> (a = \<omega> \<or> b = c)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   301
  by (cases a, cases b, cases c, simp_all, cases c, simp_all)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   302
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   303
lemma Real_eq_Real:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   304
  "Real a = Real b \<longleftrightarrow> (a = b \<or> (a \<le> 0 \<and> b \<le> 0))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   305
proof (cases "a \<le> 0 \<or> b \<le> 0")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   306
  case False with Real_inj[of a b] show ?thesis by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   307
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   308
  case True
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   309
  thus ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   310
  proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   311
    assume "a \<le> 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   312
    hence *: "Real a = 0" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   313
    show ?thesis using `a \<le> 0` unfolding * by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   314
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   315
    assume "b \<le> 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   316
    hence *: "Real b = 0" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   317
    show ?thesis using `b \<le> 0` unfolding * by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   318
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   319
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   320
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   321
lemma real_pinfreal_0[simp]: "real (0 :: pinfreal) = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   322
  unfolding zero_pinfreal_def real_Real by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   323
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   324
lemma real_of_pinfreal_eq_0: "real X = 0 \<longleftrightarrow> (X = 0 \<or> X = \<omega>)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   325
  by (cases X) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   326
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   327
lemma real_of_pinfreal_eq: "real X = real Y \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   328
    (X = Y \<or> (X = 0 \<and> Y = \<omega>) \<or> (Y = 0 \<and> X = \<omega>))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   329
  by (cases X, cases Y) (auto simp add: real_of_pinfreal_eq_0)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   330
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   331
lemma real_of_pinfreal_add: "real X + real Y =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   332
    (if X = \<omega> then real Y else if Y = \<omega> then real X else real (X + Y))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   333
  by (auto simp: pinfreal_noteq_omega_Ex)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   334
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   335
subsection "@{typ pinfreal} is a monoid for multiplication"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   336
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   337
instantiation pinfreal :: comm_monoid_mult
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   338
begin
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   339
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   340
definition "1 = Real 1"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   341
definition "x * y = (if x = 0 \<or> y = 0 then 0 else
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   342
  pinfreal_case (\<lambda>r. pinfreal_case (\<lambda>p. Real (r * p)) \<omega> y) \<omega> x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   343
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   344
lemma pinfreal_times[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   345
  "Real r * Real p = (if 0 \<le> r \<and> 0 \<le> p then Real (r * p) else 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   346
  "\<omega> * x = (if x = 0 then 0 else \<omega>)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   347
  "x * \<omega> = (if x = 0 then 0 else \<omega>)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   348
  "0 * x = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   349
  "x * 0 = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   350
  "1 = \<omega> \<longleftrightarrow> False"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   351
  "\<omega> = 1 \<longleftrightarrow> False"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   352
  by (auto simp add: times_pinfreal_def one_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   353
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   354
lemma pinfreal_one_mult[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   355
  "Real x + 1 = (if 0 \<le> x then Real (x + 1) else 1)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   356
  "1 + Real x = (if 0 \<le> x then Real (1 + x) else 1)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   357
  unfolding one_pinfreal_def by simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   358
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   359
instance
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   360
proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   361
  fix a :: pinfreal show "1 * a = a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   362
    by (cases a) (simp_all add: one_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   363
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   364
  fix b show "a * b = b * a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   365
    by (cases a, cases b) (simp_all add: mult_nonneg_nonneg)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   366
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   367
  fix c show "a * b * c = a * (b * c)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   368
    apply (cases a, cases b, cases c)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   369
    apply (simp_all add: mult_nonneg_nonneg not_le mult_pos_pos)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   370
    apply (cases b, cases c)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   371
    apply (simp_all add: mult_nonneg_nonneg not_le mult_pos_pos)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   372
    done
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   373
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   374
end
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   375
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   376
lemma pinfreal_mult_cancel_left:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   377
  "a * b = a * c \<longleftrightarrow> (a = 0 \<or> b = c \<or> (a = \<omega> \<and> b \<noteq> 0 \<and> c \<noteq> 0))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   378
  by (cases a, cases b, cases c, auto simp: Real_eq_Real mult_le_0_iff, cases c, auto)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   379
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   380
lemma pinfreal_mult_cancel_right:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   381
  "b * a = c * a \<longleftrightarrow> (a = 0 \<or> b = c \<or> (a = \<omega> \<and> b \<noteq> 0 \<and> c \<noteq> 0))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   382
  by (cases a, cases b, cases c, auto simp: Real_eq_Real mult_le_0_iff, cases c, auto)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   383
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   384
lemma Real_1[simp]: "Real 1 = 1" by (simp add: one_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   385
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   386
lemma real_pinfreal_1[simp]: "real (1 :: pinfreal) = 1"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   387
  unfolding one_pinfreal_def real_Real by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   388
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   389
lemma real_of_pinfreal_mult: "real X * real Y = real (X * Y :: pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   390
  by (cases X, cases Y) (auto simp: zero_le_mult_iff)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   391
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   392
subsection "@{typ pinfreal} is a linear order"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   393
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   394
instantiation pinfreal :: linorder
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   395
begin
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   396
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   397
definition "x < y \<longleftrightarrow> pinfreal_case (\<lambda>i. pinfreal_case (\<lambda>j. i < j) True y) False x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   398
definition "x \<le> y \<longleftrightarrow> pinfreal_case (\<lambda>j. pinfreal_case (\<lambda>i. i \<le> j) False x) True y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   399
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   400
lemma pinfreal_less[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   401
  "Real r < \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   402
  "Real r < Real p \<longleftrightarrow> (if 0 \<le> r \<and> 0 \<le> p then r < p else 0 < p)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   403
  "\<omega> < x \<longleftrightarrow> False"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   404
  "0 < \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   405
  "0 < Real r \<longleftrightarrow> 0 < r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   406
  "x < 0 \<longleftrightarrow> False"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   407
  "0 < (1::pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   408
  by (simp_all add: less_pinfreal_def zero_pinfreal_def one_pinfreal_def del: Real_0 Real_1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   409
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   410
lemma pinfreal_less_eq[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   411
  "x \<le> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   412
  "Real r \<le> Real p \<longleftrightarrow> (if 0 \<le> r \<and> 0 \<le> p then r \<le> p else r \<le> 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   413
  "0 \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   414
  by (simp_all add: less_eq_pinfreal_def zero_pinfreal_def del: Real_0)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   415
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   416
lemma pinfreal_\<omega>_less_eq[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   417
  "\<omega> \<le> x \<longleftrightarrow> x = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   418
  by (cases x) (simp_all add: not_le less_eq_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   419
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   420
lemma pinfreal_less_eq_zero[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   421
  "(x::pinfreal) \<le> 0 \<longleftrightarrow> x = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   422
  by (cases x) (simp_all add: zero_pinfreal_def del: Real_0)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   423
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   424
instance
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   425
proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   426
  fix x :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   427
  show "x \<le> x" by (cases x) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   428
  fix y
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   429
  show "(x < y) = (x \<le> y \<and> \<not> y \<le> x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   430
    by (cases x, cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   431
  show "x \<le> y \<or> y \<le> x "
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   432
    by (cases x, cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   433
  { assume "x \<le> y" "y \<le> x" thus "x = y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   434
      by (cases x, cases y) auto }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   435
  { fix z assume "x \<le> y" "y \<le> z"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   436
    thus "x \<le> z" by (cases x, cases y, cases z) auto }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   437
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   438
end
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   439
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   440
lemma pinfreal_zero_lessI[intro]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   441
  "(a :: pinfreal) \<noteq> 0 \<Longrightarrow> 0 < a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   442
  by (cases a) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   443
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   444
lemma pinfreal_less_omegaI[intro, simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   445
  "a \<noteq> \<omega> \<Longrightarrow> a < \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   446
  by (cases a) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   447
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   448
lemma pinfreal_plus_eq_0[simp]: "(a :: pinfreal) + b = 0 \<longleftrightarrow> a = 0 \<and> b = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   449
  by (cases a, cases b) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   450
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   451
lemma pinfreal_le_add1[simp, intro]: "n \<le> n + (m::pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   452
  by (cases n, cases m) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   453
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   454
lemma pinfreal_le_add2: "(n::pinfreal) + m \<le> k \<Longrightarrow> m \<le> k"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   455
  by (cases n, cases m, cases k) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   456
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   457
lemma pinfreal_le_add3: "(n::pinfreal) + m \<le> k \<Longrightarrow> n \<le> k"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   458
  by (cases n, cases m, cases k) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   459
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   460
lemma pinfreal_less_\<omega>: "x < \<omega> \<longleftrightarrow> x \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   461
  by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   462
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   463
subsection {* @{text "x - y"} on @{typ pinfreal} *}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   464
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   465
instantiation pinfreal :: minus
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   466
begin
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   467
definition "x - y = (if y < x then THE d. x = y + d else 0 :: pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   468
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   469
lemma minus_pinfreal_eq:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   470
  "(x - y = (z :: pinfreal)) \<longleftrightarrow> (if y < x then x = y + z else z = 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   471
  (is "?diff \<longleftrightarrow> ?if")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   472
proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   473
  assume ?diff
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   474
  thus ?if
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   475
  proof (cases "y < x")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   476
    case True
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   477
    then obtain p where p: "y = Real p" "0 \<le> p" by (cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   478
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   479
    show ?thesis unfolding `?diff`[symmetric] if_P[OF True] minus_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   480
    proof (rule theI2[where Q="\<lambda>d. x = y + d"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   481
      show "x = y + pinfreal_case (\<lambda>r. Real (r - real y)) \<omega> x" (is "x = y + ?d")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   482
        using `y < x` p by (cases x) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   483
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   484
      fix d assume "x = y + d"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   485
      thus "d = ?d" using `y < x` p by (cases d, cases x) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   486
    qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   487
  qed (simp add: minus_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   488
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   489
  assume ?if
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   490
  thus ?diff
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   491
  proof (cases "y < x")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   492
    case True
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   493
    then obtain p where p: "y = Real p" "0 \<le> p" by (cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   494
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   495
    from True `?if` have "x = y + z" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   496
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   497
    show ?thesis unfolding minus_pinfreal_def if_P[OF True] unfolding `x = y + z`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   498
    proof (rule the_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   499
      fix d :: pinfreal assume "y + z = y + d"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   500
      thus "d = z" using `y < x` p
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   501
        by (cases d, cases z) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   502
    qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   503
  qed (simp add: minus_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   504
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   505
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   506
instance ..
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   507
end
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   508
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   509
lemma pinfreal_minus[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   510
  "Real r - Real p = (if 0 \<le> r \<and> p < r then if 0 \<le> p then Real (r - p) else Real r else 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   511
  "(A::pinfreal) - A = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   512
  "\<omega> - Real r = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   513
  "Real r - \<omega> = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   514
  "A - 0 = A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   515
  "0 - A = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   516
  by (auto simp: minus_pinfreal_eq not_less)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   517
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   518
lemma pinfreal_le_epsilon:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   519
  fixes x y :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   520
  assumes "\<And>e. 0 < e \<Longrightarrow> x \<le> y + e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   521
  shows "x \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   522
proof (cases y)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   523
  case (preal r)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   524
  then obtain p where x: "x = Real p" "0 \<le> p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   525
    using assms[of 1] by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   526
  { fix e have "0 < e \<Longrightarrow> p \<le> r + e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   527
      using assms[of "Real e"] preal x by auto }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   528
  hence "p \<le> r" by (rule field_le_epsilon)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   529
  thus ?thesis using preal x by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   530
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   531
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   532
instance pinfreal :: "{ordered_comm_semiring, comm_semiring_1}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   533
proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   534
  show "0 \<noteq> (1::pinfreal)" unfolding zero_pinfreal_def one_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   535
    by (simp del: Real_1 Real_0)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   536
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   537
  fix a :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   538
  show "0 * a = 0" "a * 0 = 0" by simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   539
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   540
  fix b c :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   541
  show "(a + b) * c = a * c + b * c"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   542
    by (cases c, cases a, cases b)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   543
       (auto intro!: arg_cong[where f=Real] simp: field_simps not_le mult_le_0_iff mult_less_0_iff)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   544
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   545
  { assume "a \<le> b" thus "c + a \<le> c + b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   546
     by (cases c, cases a, cases b) auto }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   547
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   548
  assume "a \<le> b" "0 \<le> c"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   549
  thus "c * a \<le> c * b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   550
    apply (cases c, cases a, cases b)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   551
    by (auto simp: mult_left_mono mult_le_0_iff mult_less_0_iff not_le)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   552
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   553
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   554
lemma mult_\<omega>[simp]: "x * y = \<omega> \<longleftrightarrow> (x = \<omega> \<or> y = \<omega>) \<and> x \<noteq> 0 \<and> y \<noteq> 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   555
  by (cases x, cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   556
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   557
lemma \<omega>_mult[simp]: "(\<omega> = x * y) = ((x = \<omega> \<or> y = \<omega>) \<and> x \<noteq> 0 \<and> y \<noteq> 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   558
  by (cases x, cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   559
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   560
lemma pinfreal_mult_0[simp]: "x * y = 0 \<longleftrightarrow> x = 0 \<or> (y::pinfreal) = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   561
  by (cases x, cases y) (auto simp: mult_le_0_iff)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   562
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   563
lemma pinfreal_mult_cancel:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   564
  fixes x y z :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   565
  assumes "y \<le> z"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   566
  shows "x * y \<le> x * z"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   567
  using assms
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   568
  by (cases x, cases y, cases z)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   569
     (auto simp: mult_le_cancel_left mult_le_0_iff mult_less_0_iff not_le)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   570
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   571
lemma Real_power[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   572
  "Real x ^ n = (if x \<le> 0 then (if n = 0 then 1 else 0) else Real (x ^ n))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   573
  by (induct n) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   574
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   575
lemma Real_power_\<omega>[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   576
  "\<omega> ^ n = (if n = 0 then 1 else \<omega>)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   577
  by (induct n) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   578
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   579
lemma pinfreal_of_nat[simp]: "of_nat m = Real (real m)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   580
  by (induct m) (auto simp: real_of_nat_Suc one_pinfreal_def simp del: Real_1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   581
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   582
lemma real_of_pinfreal_mono:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   583
  fixes a b :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   584
  assumes "b \<noteq> \<omega>" "a \<le> b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   585
  shows "real a \<le> real b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   586
using assms by (cases b, cases a) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   587
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   588
instance pinfreal :: "semiring_char_0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   589
proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   590
  fix m n
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   591
  show "inj (of_nat::nat\<Rightarrow>pinfreal)" by (auto intro!: inj_onI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   592
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   593
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   594
subsection "@{typ pinfreal} is a complete lattice"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   595
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   596
instantiation pinfreal :: lattice
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   597
begin
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   598
definition [simp]: "sup x y = (max x y :: pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   599
definition [simp]: "inf x y = (min x y :: pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   600
instance proof qed simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   601
end
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   602
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   603
instantiation pinfreal :: complete_lattice
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   604
begin
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   605
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   606
definition "bot = Real 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   607
definition "top = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   608
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   609
definition "Sup S = (LEAST z. \<forall>x\<in>S. x \<le> z :: pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   610
definition "Inf S = (GREATEST z. \<forall>x\<in>S. z \<le> x :: pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   611
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   612
lemma pinfreal_complete_Sup:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   613
  fixes S :: "pinfreal set" assumes "S \<noteq> {}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   614
  shows "\<exists>x. (\<forall>y\<in>S. y \<le> x) \<and> (\<forall>z. (\<forall>y\<in>S. y \<le> z) \<longrightarrow> x \<le> z)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   615
proof (cases "\<exists>x\<ge>0. \<forall>a\<in>S. a \<le> Real x")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   616
  case False
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   617
  hence *: "\<And>x. x\<ge>0 \<Longrightarrow> \<exists>a\<in>S. \<not>a \<le> Real x" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   618
  show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   619
  proof (safe intro!: exI[of _ \<omega>])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   620
    fix y assume **: "\<forall>z\<in>S. z \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   621
    show "\<omega> \<le> y" unfolding pinfreal_\<omega>_less_eq
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   622
    proof (rule ccontr)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   623
      assume "y \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   624
      then obtain x where [simp]: "y = Real x" and "0 \<le> x" by (cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   625
      from *[OF `0 \<le> x`] show False using ** by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   626
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   627
  qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   628
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   629
  case True then obtain y where y: "\<And>a. a\<in>S \<Longrightarrow> a \<le> Real y" and "0 \<le> y" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   630
  from y[of \<omega>] have "\<omega> \<notin> S" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   631
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   632
  with `S \<noteq> {}` obtain x where "x \<in> S" and "x \<noteq> \<omega>" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   633
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   634
  have bound: "\<forall>x\<in>real ` S. x \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   635
  proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   636
    fix z assume "z \<in> real ` S" then guess a ..
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   637
    with y[of a] `\<omega> \<notin> S` `0 \<le> y` show "z \<le> y" by (cases a) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   638
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   639
  with reals_complete2[of "real ` S"] `x \<in> S`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   640
  obtain s where s: "\<forall>y\<in>S. real y \<le> s" "\<forall>z. ((\<forall>y\<in>S. real y \<le> z) \<longrightarrow> s \<le> z)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   641
    by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   642
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   643
  show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   644
  proof (safe intro!: exI[of _ "Real s"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   645
    fix z assume "z \<in> S" thus "z \<le> Real s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   646
      using s `\<omega> \<notin> S` by (cases z) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   647
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   648
    fix z assume *: "\<forall>y\<in>S. y \<le> z"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   649
    show "Real s \<le> z"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   650
    proof (cases z)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   651
      case (preal u)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   652
      { fix v assume "v \<in> S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   653
        hence "v \<le> Real u" using * preal by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   654
        hence "real v \<le> u" using `\<omega> \<notin> S` `0 \<le> u` by (cases v) auto }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   655
      hence "s \<le> u" using s(2) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   656
      thus "Real s \<le> z" using preal by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   657
    qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   658
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   659
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   660
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   661
lemma pinfreal_complete_Inf:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   662
  fixes S :: "pinfreal set" assumes "S \<noteq> {}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   663
  shows "\<exists>x. (\<forall>y\<in>S. x \<le> y) \<and> (\<forall>z. (\<forall>y\<in>S. z \<le> y) \<longrightarrow> z \<le> x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   664
proof (cases "S = {\<omega>}")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   665
  case True thus ?thesis by (auto intro!: exI[of _ \<omega>])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   666
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   667
  case False with `S \<noteq> {}` have "S - {\<omega>} \<noteq> {}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   668
  hence not_empty: "\<exists>x. x \<in> uminus ` real ` (S - {\<omega>})" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   669
  have bounds: "\<exists>x. \<forall>y\<in>uminus ` real ` (S - {\<omega>}). y \<le> x" by (auto intro!: exI[of _ 0])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   670
  from reals_complete2[OF not_empty bounds]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   671
  obtain s where s: "\<And>y. y\<in>S - {\<omega>} \<Longrightarrow> - real y \<le> s" "\<forall>z. ((\<forall>y\<in>S - {\<omega>}. - real y \<le> z) \<longrightarrow> s \<le> z)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   672
    by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   673
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   674
  show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   675
  proof (safe intro!: exI[of _ "Real (-s)"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   676
    fix z assume "z \<in> S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   677
    show "Real (-s) \<le> z"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   678
    proof (cases z)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   679
      case (preal r)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   680
      with s `z \<in> S` have "z \<in> S - {\<omega>}" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   681
      hence "- r \<le> s" using preal s(1)[of z] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   682
      hence "- s \<le> r" by (subst neg_le_iff_le[symmetric]) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   683
      thus ?thesis using preal by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   684
    qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   685
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   686
    fix z assume *: "\<forall>y\<in>S. z \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   687
    show "z \<le> Real (-s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   688
    proof (cases z)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   689
      case (preal u)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   690
      { fix v assume "v \<in> S-{\<omega>}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   691
        hence "Real u \<le> v" using * preal by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   692
        hence "- real v \<le> - u" using `0 \<le> u` `v \<in> S - {\<omega>}` by (cases v) auto }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   693
      hence "u \<le> - s" using s(2) by (subst neg_le_iff_le[symmetric]) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   694
      thus "z \<le> Real (-s)" using preal by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   695
    next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   696
      case infinite
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   697
      with * have "S = {\<omega>}" using `S \<noteq> {}` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   698
      with `S - {\<omega>} \<noteq> {}` show ?thesis by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   699
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   700
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   701
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   702
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   703
instance
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   704
proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   705
  fix x :: pinfreal and A
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   706
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   707
  show "bot \<le> x" by (cases x) (simp_all add: bot_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   708
  show "x \<le> top" by (simp add: top_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   709
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   710
  { assume "x \<in> A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   711
    with pinfreal_complete_Sup[of A]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   712
    obtain s where s: "\<forall>y\<in>A. y \<le> s" "\<forall>z. (\<forall>y\<in>A. y \<le> z) \<longrightarrow> s \<le> z" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   713
    hence "x \<le> s" using `x \<in> A` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   714
    also have "... = Sup A" using s unfolding Sup_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   715
      by (auto intro!: Least_equality[symmetric])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   716
    finally show "x \<le> Sup A" . }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   717
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   718
  { assume "x \<in> A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   719
    with pinfreal_complete_Inf[of A]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   720
    obtain i where i: "\<forall>y\<in>A. i \<le> y" "\<forall>z. (\<forall>y\<in>A. z \<le> y) \<longrightarrow> z \<le> i" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   721
    hence "Inf A = i" unfolding Inf_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   722
      by (auto intro!: Greatest_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   723
    also have "i \<le> x" using i `x \<in> A` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   724
    finally show "Inf A \<le> x" . }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   725
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   726
  { assume *: "\<And>z. z \<in> A \<Longrightarrow> z \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   727
    show "Sup A \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   728
    proof (cases "A = {}")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   729
      case True
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   730
      hence "Sup A = 0" unfolding Sup_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   731
        by (auto intro!: Least_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   732
      thus "Sup A \<le> x" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   733
    next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   734
      case False
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   735
      with pinfreal_complete_Sup[of A]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   736
      obtain s where s: "\<forall>y\<in>A. y \<le> s" "\<forall>z. (\<forall>y\<in>A. y \<le> z) \<longrightarrow> s \<le> z" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   737
      hence "Sup A = s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   738
        unfolding Sup_pinfreal_def by (auto intro!: Least_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   739
      also have "s \<le> x" using * s by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   740
      finally show "Sup A \<le> x" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   741
    qed }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   742
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   743
  { assume *: "\<And>z. z \<in> A \<Longrightarrow> x \<le> z"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   744
    show "x \<le> Inf A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   745
    proof (cases "A = {}")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   746
      case True
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   747
      hence "Inf A = \<omega>" unfolding Inf_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   748
        by (auto intro!: Greatest_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   749
      thus "x \<le> Inf A" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   750
    next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   751
      case False
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   752
      with pinfreal_complete_Inf[of A]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   753
      obtain i where i: "\<forall>y\<in>A. i \<le> y" "\<forall>z. (\<forall>y\<in>A. z \<le> y) \<longrightarrow> z \<le> i" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   754
      have "x \<le> i" using * i by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   755
      also have "i = Inf A" using i
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   756
        unfolding Inf_pinfreal_def by (auto intro!: Greatest_equality[symmetric])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   757
      finally show "x \<le> Inf A" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   758
    qed }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   759
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   760
end
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   761
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   762
lemma Inf_pinfreal_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   763
  fixes z :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   764
  shows "(\<And>x. x \<in> X \<Longrightarrow> z \<le> x) \<Longrightarrow> (\<exists>x\<in>X. x<y) \<longleftrightarrow> Inf X < y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   765
  by (metis complete_lattice_class.Inf_greatest complete_lattice_class.Inf_lower less_le_not_le linear
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   766
            order_less_le_trans)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   767
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   768
lemma Inf_greater:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   769
  fixes z :: pinfreal assumes "Inf X < z"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   770
  shows "\<exists>x \<in> X. x < z"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   771
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   772
  have "X \<noteq> {}" using assms by (auto simp: Inf_empty top_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   773
  with assms show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   774
    by (metis Inf_pinfreal_iff mem_def not_leE)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   775
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   776
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   777
lemma Inf_close:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   778
  fixes e :: pinfreal assumes "Inf X \<noteq> \<omega>" "0 < e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   779
  shows "\<exists>x \<in> X. x < Inf X + e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   780
proof (rule Inf_greater)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   781
  show "Inf X < Inf X + e" using assms
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   782
    by (cases "Inf X", cases e) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   783
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   784
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   785
lemma pinfreal_SUPI:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   786
  fixes x :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   787
  assumes "\<And>i. i \<in> A \<Longrightarrow> f i \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   788
  assumes "\<And>y. (\<And>i. i \<in> A \<Longrightarrow> f i \<le> y) \<Longrightarrow> x \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   789
  shows "(SUP i:A. f i) = x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   790
  unfolding SUPR_def Sup_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   791
  using assms by (auto intro!: Least_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   792
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   793
lemma Sup_pinfreal_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   794
  fixes z :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   795
  shows "(\<And>x. x \<in> X \<Longrightarrow> x \<le> z) \<Longrightarrow> (\<exists>x\<in>X. y<x) \<longleftrightarrow> y < Sup X"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   796
  by (metis complete_lattice_class.Sup_least complete_lattice_class.Sup_upper less_le_not_le linear
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   797
            order_less_le_trans)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   798
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   799
lemma Sup_lesser:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   800
  fixes z :: pinfreal assumes "z < Sup X"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   801
  shows "\<exists>x \<in> X. z < x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   802
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   803
  have "X \<noteq> {}" using assms by (auto simp: Sup_empty bot_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   804
  with assms show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   805
    by (metis Sup_pinfreal_iff mem_def not_leE)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   806
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   807
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   808
lemma Sup_eq_\<omega>: "\<omega> \<in> S \<Longrightarrow> Sup S = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   809
  unfolding Sup_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   810
  by (auto intro!: Least_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   811
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   812
lemma Sup_close:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   813
  assumes "0 < e" and S: "Sup S \<noteq> \<omega>" "S \<noteq> {}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   814
  shows "\<exists>X\<in>S. Sup S < X + e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   815
proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   816
  assume "Sup S = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   817
  moreover obtain X where "X \<in> S" using `S \<noteq> {}` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   818
  ultimately show ?thesis using `0 < e` by (auto intro!: bexI[OF _ `X\<in>S`])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   819
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   820
  assume "Sup S \<noteq> 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   821
  have "\<exists>X\<in>S. Sup S - e < X"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   822
  proof (rule Sup_lesser)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   823
    show "Sup S - e < Sup S" using `0 < e` `Sup S \<noteq> 0` `Sup S \<noteq> \<omega>`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   824
      by (cases e) (auto simp: pinfreal_noteq_omega_Ex)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   825
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   826
  then guess X .. note X = this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   827
  with `Sup S \<noteq> \<omega>` Sup_eq_\<omega> have "X \<noteq> \<omega>" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   828
  thus ?thesis using `Sup S \<noteq> \<omega>` X unfolding pinfreal_noteq_omega_Ex
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   829
    by (cases e) (auto intro!: bexI[OF _ `X\<in>S`] simp: split: split_if_asm)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   830
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   831
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   832
lemma Sup_\<omega>: "(SUP i::nat. Real (real i)) = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   833
proof (rule pinfreal_SUPI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   834
  fix y assume *: "\<And>i::nat. i \<in> UNIV \<Longrightarrow> Real (real i) \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   835
  thus "\<omega> \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   836
  proof (cases y)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   837
    case (preal r)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   838
    then obtain k :: nat where "r < real k"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   839
      using ex_less_of_nat by (auto simp: real_eq_of_nat)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   840
    with *[of k] preal show ?thesis by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   841
  qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   842
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   843
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   844
subsubsection {* Equivalence between @{text "f ----> x"} and @{text SUP} on @{typ pinfreal} *}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   845
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   846
lemma monoseq_monoI: "mono f \<Longrightarrow> monoseq f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   847
  unfolding mono_def monoseq_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   848
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   849
lemma incseq_mono: "mono f \<longleftrightarrow> incseq f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   850
  unfolding mono_def incseq_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   851
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   852
lemma SUP_eq_LIMSEQ:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   853
  assumes "mono f" and "\<And>n. 0 \<le> f n" and "0 \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   854
  shows "(SUP n. Real (f n)) = Real x \<longleftrightarrow> f ----> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   855
proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   856
  assume x: "(SUP n. Real (f n)) = Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   857
  { fix n
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   858
    have "Real (f n) \<le> Real x" using x[symmetric] by (auto intro: le_SUPI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   859
    hence "f n \<le> x" using assms by simp }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   860
  show "f ----> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   861
  proof (rule LIMSEQ_I)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   862
    fix r :: real assume "0 < r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   863
    show "\<exists>no. \<forall>n\<ge>no. norm (f n - x) < r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   864
    proof (rule ccontr)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   865
      assume *: "\<not> ?thesis"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   866
      { fix N
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   867
        from * obtain n where "N \<le> n" "r \<le> x - f n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   868
          using `\<And>n. f n \<le> x` by (auto simp: not_less)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   869
        hence "f N \<le> f n" using `mono f` by (auto dest: monoD)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   870
        hence "f N \<le> x - r" using `r \<le> x - f n` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   871
        hence "Real (f N) \<le> Real (x - r)" and "r \<le> x" using `0 \<le> f N` by auto }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   872
      hence "(SUP n. Real (f n)) \<le> Real (x - r)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   873
        and "Real (x - r) < Real x" using `0 < r` by (auto intro: SUP_leI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   874
      hence "(SUP n. Real (f n)) < Real x" by (rule le_less_trans)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   875
      thus False using x by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   876
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   877
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   878
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   879
  assume "f ----> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   880
  show "(SUP n. Real (f n)) = Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   881
  proof (rule pinfreal_SUPI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   882
    fix n
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   883
    from incseq_le[of f x] `mono f` `f ----> x`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   884
    show "Real (f n) \<le> Real x" using assms incseq_mono by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   885
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   886
    fix y assume *: "\<And>n. n\<in>UNIV \<Longrightarrow> Real (f n) \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   887
    show "Real x \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   888
    proof (cases y)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   889
      case (preal r)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   890
      with * have "\<exists>N. \<forall>n\<ge>N. f n \<le> r" using assms by fastsimp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   891
      from LIMSEQ_le_const2[OF `f ----> x` this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   892
      show "Real x \<le> y" using `0 \<le> x` preal by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   893
    qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   894
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   895
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   896
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   897
lemma SUPR_bound:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   898
  assumes "\<forall>N. f N \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   899
  shows "(SUP n. f n) \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   900
  using assms by (simp add: SUPR_def Sup_le_iff)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   901
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   902
lemma pinfreal_less_eq_diff_eq_sum:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   903
  fixes x y z :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   904
  assumes "y \<le> x" and "x \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   905
  shows "z \<le> x - y \<longleftrightarrow> z + y \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   906
  using assms
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   907
  apply (cases z, cases y, cases x)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   908
  by (simp_all add: field_simps minus_pinfreal_eq)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   909
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   910
lemma Real_diff_less_omega: "Real r - x < \<omega>" by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   911
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   912
subsubsection {* Numbers on @{typ pinfreal} *}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   913
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   914
instantiation pinfreal :: number
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   915
begin
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   916
definition [simp]: "number_of x = Real (number_of x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   917
instance proof qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   918
end
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   919
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   920
subsubsection {* Division on @{typ pinfreal} *}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   921
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   922
instantiation pinfreal :: inverse
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   923
begin
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   924
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   925
definition "inverse x = pinfreal_case (\<lambda>x. if x = 0 then \<omega> else Real (inverse x)) 0 x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   926
definition [simp]: "x / y = x * inverse (y :: pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   927
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   928
instance proof qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   929
end
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   930
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   931
lemma pinfreal_inverse[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   932
  "inverse 0 = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   933
  "inverse (Real x) = (if x \<le> 0 then \<omega> else Real (inverse x))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   934
  "inverse \<omega> = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   935
  "inverse (1::pinfreal) = 1"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   936
  "inverse (inverse x) = x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   937
  by (simp_all add: inverse_pinfreal_def one_pinfreal_def split: pinfreal_case_split del: Real_1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   938
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   939
lemma pinfreal_inverse_le_eq:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   940
  assumes "x \<noteq> 0" "x \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   941
  shows "y \<le> z / x \<longleftrightarrow> x * y \<le> (z :: pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   942
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   943
  from assms obtain r where r: "x = Real r" "0 < r" by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   944
  { fix p q :: real assume "0 \<le> p" "0 \<le> q"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   945
    have "p \<le> q * inverse r \<longleftrightarrow> p \<le> q / r" by (simp add: divide_inverse)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   946
    also have "... \<longleftrightarrow> p * r \<le> q" using `0 < r` by (auto simp: field_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   947
    finally have "p \<le> q * inverse r \<longleftrightarrow> p * r \<le> q" . }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   948
  with r show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   949
    by (cases y, cases z, auto simp: zero_le_mult_iff field_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   950
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   951
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   952
lemma inverse_antimono_strict:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   953
  fixes x y :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   954
  assumes "x < y" shows "inverse y < inverse x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   955
  using assms by (cases x, cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   956
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   957
lemma inverse_antimono:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   958
  fixes x y :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   959
  assumes "x \<le> y" shows "inverse y \<le> inverse x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   960
  using assms by (cases x, cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   961
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   962
lemma pinfreal_inverse_\<omega>_iff[simp]: "inverse x = \<omega> \<longleftrightarrow> x = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   963
  by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   964
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   965
subsection "Infinite sum over @{typ pinfreal}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   966
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   967
text {*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   968
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   969
The infinite sum over @{typ pinfreal} has the nice property that it is always
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   970
defined.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   971
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   972
*}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   973
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   974
definition psuminf :: "(nat \<Rightarrow> pinfreal) \<Rightarrow> pinfreal" (binder "\<Sum>\<^isub>\<infinity>" 10) where
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   975
  "(\<Sum>\<^isub>\<infinity> x. f x) = (SUP n. \<Sum>i<n. f i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   976
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   977
subsubsection {* Equivalence between @{text "\<Sum> n. f n"} and @{text "\<Sum>\<^isub>\<infinity> n. f n"} *}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   978
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   979
lemma setsum_Real:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   980
  assumes "\<forall>x\<in>A. 0 \<le> f x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   981
  shows "(\<Sum>x\<in>A. Real (f x)) = Real (\<Sum>x\<in>A. f x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   982
proof (cases "finite A")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   983
  case True
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   984
  thus ?thesis using assms
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   985
  proof induct case (insert x s)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   986
    hence "0 \<le> setsum f s" apply-apply(rule setsum_nonneg) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   987
    thus ?case using insert by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   988
  qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   989
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   990
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   991
lemma setsum_Real':
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   992
  assumes "\<forall>x. 0 \<le> f x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   993
  shows "(\<Sum>x\<in>A. Real (f x)) = Real (\<Sum>x\<in>A. f x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   994
  apply(rule setsum_Real) using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   995
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   996
lemma setsum_\<omega>:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   997
  "(\<Sum>x\<in>P. f x) = \<omega> \<longleftrightarrow> (finite P \<and> (\<exists>i\<in>P. f i = \<omega>))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   998
proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   999
  assume *: "setsum f P = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1000
  show "finite P"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1001
  proof (rule ccontr) assume "infinite P" with * show False by auto qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1002
  show "\<exists>i\<in>P. f i = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1003
  proof (rule ccontr)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1004
    assume "\<not> ?thesis" hence "\<And>i. i\<in>P \<Longrightarrow> f i \<noteq> \<omega>" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1005
    from `finite P` this have "setsum f P \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1006
      by induct auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1007
    with * show False by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1008
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1009
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1010
  fix i assume "finite P" "i \<in> P" "f i = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1011
  thus "setsum f P = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1012
  proof induct
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1013
    case (insert x A)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1014
    show ?case using insert by (cases "x = i") auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1015
  qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1016
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1017
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1018
lemma real_of_pinfreal_setsum:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1019
  assumes "\<And>x. x \<in> S \<Longrightarrow> f x \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1020
  shows "(\<Sum>x\<in>S. real (f x)) = real (setsum f S)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1021
proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1022
  assume "finite S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1023
  from this assms show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1024
    by induct (simp_all add: real_of_pinfreal_add setsum_\<omega>)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1025
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1026
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1027
lemma setsum_0:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1028
  fixes f :: "'a \<Rightarrow> pinfreal" assumes "finite A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1029
  shows "(\<Sum>x\<in>A. f x) = 0 \<longleftrightarrow> (\<forall>i\<in>A. f i = 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1030
  using assms by induct auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1031
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1032
lemma suminf_imp_psuminf:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1033
  assumes "f sums x" and "\<forall>n. 0 \<le> f n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1034
  shows "(\<Sum>\<^isub>\<infinity> x. Real (f x)) = Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1035
  unfolding psuminf_def setsum_Real'[OF assms(2)]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1036
proof (rule SUP_eq_LIMSEQ[THEN iffD2])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1037
  show "mono (\<lambda>n. setsum f {..<n})" (is "mono ?S")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1038
    unfolding mono_iff_le_Suc using assms by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1039
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1040
  { fix n show "0 \<le> ?S n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1041
      using setsum_nonneg[of "{..<n}" f] assms by auto }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1042
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1043
  thus "0 \<le> x" "?S ----> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1044
    using `f sums x` LIMSEQ_le_const
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1045
    by (auto simp: atLeast0LessThan sums_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1046
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1047
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1048
lemma psuminf_equality:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1049
  assumes "\<And>n. setsum f {..<n} \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1050
  and "\<And>y. y \<noteq> \<omega> \<Longrightarrow> (\<And>n. setsum f {..<n} \<le> y) \<Longrightarrow> x \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1051
  shows "psuminf f = x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1052
  unfolding psuminf_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1053
proof (safe intro!: pinfreal_SUPI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1054
  fix n show "setsum f {..<n} \<le> x" using assms(1) .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1055
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1056
  fix y assume *: "\<forall>n. n \<in> UNIV \<longrightarrow> setsum f {..<n} \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1057
  show "x \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1058
  proof (cases "y = \<omega>")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1059
    assume "y \<noteq> \<omega>" from assms(2)[OF this] *
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1060
    show "x \<le> y" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1061
  qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1062
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1063
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1064
lemma psuminf_\<omega>:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1065
  assumes "f i = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1066
  shows "(\<Sum>\<^isub>\<infinity> x. f x) = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1067
proof (rule psuminf_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1068
  fix y assume *: "\<And>n. setsum f {..<n} \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1069
  have "setsum f {..<Suc i} = \<omega>" 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1070
    using assms by (simp add: setsum_\<omega>)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1071
  thus "\<omega> \<le> y" using *[of "Suc i"] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1072
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1073
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1074
lemma psuminf_imp_suminf:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1075
  assumes "(\<Sum>\<^isub>\<infinity> x. f x) \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1076
  shows "(\<lambda>x. real (f x)) sums real (\<Sum>\<^isub>\<infinity> x. f x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1077
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1078
  have "\<forall>i. \<exists>r. f i = Real r \<and> 0 \<le> r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1079
  proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1080
    fix i show "\<exists>r. f i = Real r \<and> 0 \<le> r" using psuminf_\<omega> assms by (cases "f i") auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1081
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1082
  from choice[OF this] obtain r where f: "f = (\<lambda>i. Real (r i))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1083
    and pos: "\<forall>i. 0 \<le> r i"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1084
    by (auto simp: expand_fun_eq)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1085
  hence [simp]: "\<And>i. real (f i) = r i" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1086
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1087
  have "mono (\<lambda>n. setsum r {..<n})" (is "mono ?S")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1088
    unfolding mono_iff_le_Suc using pos by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1089
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1090
  { fix n have "0 \<le> ?S n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1091
      using setsum_nonneg[of "{..<n}" r] pos by auto }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1092
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1093
  from assms obtain p where *: "(\<Sum>\<^isub>\<infinity> x. f x) = Real p" and "0 \<le> p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1094
    by (cases "(\<Sum>\<^isub>\<infinity> x. f x)") auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1095
  show ?thesis unfolding * using * pos `0 \<le> p` SUP_eq_LIMSEQ[OF `mono ?S` `\<And>n. 0 \<le> ?S n` `0 \<le> p`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1096
    by (simp add: f atLeast0LessThan sums_def psuminf_def setsum_Real'[OF pos] f)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1097
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1098
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1099
lemma psuminf_bound:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1100
  assumes "\<forall>N. (\<Sum>n<N. f n) \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1101
  shows "(\<Sum>\<^isub>\<infinity> n. f n) \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1102
  using assms by (simp add: psuminf_def SUPR_def Sup_le_iff)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1103
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1104
lemma psuminf_bound_add:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1105
  assumes "\<forall>N. (\<Sum>n<N. f n) + y \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1106
  shows "(\<Sum>\<^isub>\<infinity> n. f n) + y \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1107
proof (cases "x = \<omega>")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1108
  have "y \<le> x" using assms by (auto intro: pinfreal_le_add2)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1109
  assume "x \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1110
  note move_y = pinfreal_less_eq_diff_eq_sum[OF `y \<le> x` this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1111
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1112
  have "\<forall>N. (\<Sum>n<N. f n) \<le> x - y" using assms by (simp add: move_y)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1113
  hence "(\<Sum>\<^isub>\<infinity> n. f n) \<le> x - y" by (rule psuminf_bound)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1114
  thus ?thesis by (simp add: move_y)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1115
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1116
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1117
lemma psuminf_finite:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1118
  assumes "\<forall>N\<ge>n. f N = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1119
  shows "(\<Sum>\<^isub>\<infinity> n. f n) = (\<Sum>N<n. f N)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1120
proof (rule psuminf_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1121
  fix N
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1122
  show "setsum f {..<N} \<le> setsum f {..<n}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1123
  proof (cases rule: linorder_cases)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1124
    assume "N < n" thus ?thesis by (auto intro!: setsum_mono3)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1125
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1126
    assume "n < N"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1127
    hence *: "{..<N} = {..<n} \<union> {n..<N}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1128
    moreover have "setsum f {n..<N} = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1129
      using assms by (auto intro!: setsum_0')
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1130
    ultimately show ?thesis unfolding *
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1131
      by (subst setsum_Un_disjoint) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1132
  qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1133
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1134
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1135
lemma psuminf_upper:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1136
  shows "(\<Sum>n<N. f n) \<le> (\<Sum>\<^isub>\<infinity> n. f n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1137
  unfolding psuminf_def SUPR_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1138
  by (auto intro: complete_lattice_class.Sup_upper image_eqI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1139
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1140
lemma psuminf_le:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1141
  assumes "\<And>N. f N \<le> g N"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1142
  shows "psuminf f \<le> psuminf g"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1143
proof (safe intro!: psuminf_bound)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1144
  fix n
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1145
  have "setsum f {..<n} \<le> setsum g {..<n}" using assms by (auto intro: setsum_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1146
  also have "... \<le> psuminf g" by (rule psuminf_upper)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1147
  finally show "setsum f {..<n} \<le> psuminf g" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1148
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1149
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1150
lemma psuminf_const[simp]: "psuminf (\<lambda>n. c) = (if c = 0 then 0 else \<omega>)" (is "_ = ?if")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1151
proof (rule psuminf_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1152
  fix y assume *: "\<And>n :: nat. (\<Sum>n<n. c) \<le> y" and "y \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1153
  then obtain r p where
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1154
    y: "y = Real r" "0 \<le> r" and
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1155
    c: "c = Real p" "0 \<le> p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1156
      using *[of 1] by (cases c, cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1157
  show "(if c = 0 then 0 else \<omega>) \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1158
  proof (cases "p = 0")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1159
    assume "p = 0" with c show ?thesis by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1160
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1161
    assume "p \<noteq> 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1162
    with * c y have **: "\<And>n :: nat. real n \<le> r / p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1163
      by (auto simp: zero_le_mult_iff field_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1164
    from ex_less_of_nat[of "r / p"] guess n ..
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1165
    with **[of n] show ?thesis by (simp add: real_eq_of_nat)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1166
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1167
qed (cases "c = 0", simp_all)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1168
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1169
lemma psuminf_add[simp]: "psuminf (\<lambda>n. f n + g n) = psuminf f + psuminf g"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1170
proof (rule psuminf_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1171
  fix n
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1172
  from psuminf_upper[of f n] psuminf_upper[of g n]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1173
  show "(\<Sum>n<n. f n + g n) \<le> psuminf f + psuminf g"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1174
    by (auto simp add: setsum_addf intro!: add_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1175
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1176
  fix y assume *: "\<And>n. (\<Sum>n<n. f n + g n) \<le> y" and "y \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1177
  { fix n m
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1178
    have **: "(\<Sum>n<n. f n) + (\<Sum>n<m. g n) \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1179
    proof (cases rule: linorder_le_cases)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1180
      assume "n \<le> m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1181
      hence "(\<Sum>n<n. f n) + (\<Sum>n<m. g n) \<le> (\<Sum>n<m. f n) + (\<Sum>n<m. g n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1182
        by (auto intro!: add_right_mono setsum_mono3)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1183
      also have "... \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1184
        using * by (simp add: setsum_addf)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1185
      finally show ?thesis .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1186
    next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1187
      assume "m \<le> n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1188
      hence "(\<Sum>n<n. f n) + (\<Sum>n<m. g n) \<le> (\<Sum>n<n. f n) + (\<Sum>n<n. g n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1189
        by (auto intro!: add_left_mono setsum_mono3)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1190
      also have "... \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1191
        using * by (simp add: setsum_addf)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1192
      finally show ?thesis .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1193
    qed }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1194
  hence "\<And>m. \<forall>n. (\<Sum>n<n. f n) + (\<Sum>n<m. g n) \<le> y" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1195
  from psuminf_bound_add[OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1196
  have "\<forall>m. (\<Sum>n<m. g n) + psuminf f \<le> y" by (simp add: ac_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1197
  from psuminf_bound_add[OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1198
  show "psuminf f + psuminf g \<le> y" by (simp add: ac_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1199
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1200
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1201
lemma psuminf_0: "psuminf f = 0 \<longleftrightarrow> (\<forall>i. f i = 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1202
proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1203
  assume "\<forall>i. f i = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1204
  hence "f = (\<lambda>i. 0)" by (simp add: expand_fun_eq)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1205
  thus "psuminf f = 0" using psuminf_const by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1206
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1207
  fix i assume "psuminf f = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1208
  hence "(\<Sum>n<Suc i. f n) = 0" using psuminf_upper[of f "Suc i"] by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1209
  thus "f i = 0" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1210
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1211
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1212
lemma psuminf_cmult_right[simp]: "psuminf (\<lambda>n. c * f n) = c * psuminf f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1213
proof (rule psuminf_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1214
  fix n show "(\<Sum>n<n. c * f n) \<le> c * psuminf f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1215
   by (auto simp: setsum_right_distrib[symmetric] intro: mult_left_mono psuminf_upper)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1216
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1217
  fix y
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1218
  assume "\<And>n. (\<Sum>n<n. c * f n) \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1219
  hence *: "\<And>n. c * (\<Sum>n<n. f n) \<le> y" by (auto simp add: setsum_right_distrib)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1220
  thus "c * psuminf f \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1221
  proof (cases "c = \<omega> \<or> c = 0")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1222
    assume "c = \<omega> \<or> c = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1223
    thus ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1224
      using * by (fastsimp simp add: psuminf_0 setsum_0 split: split_if_asm)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1225
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1226
    assume "\<not> (c = \<omega> \<or> c = 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1227
    hence "c \<noteq> 0" "c \<noteq> \<omega>" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1228
    note rewrite_div = pinfreal_inverse_le_eq[OF this, of _ y]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1229
    hence "\<forall>n. (\<Sum>n<n. f n) \<le> y / c" using * by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1230
    hence "psuminf f \<le> y / c" by (rule psuminf_bound)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1231
    thus ?thesis using rewrite_div by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1232
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1233
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1234
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1235
lemma psuminf_cmult_left[simp]: "psuminf (\<lambda>n. f n * c) = psuminf f * c"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1236
  using psuminf_cmult_right[of c f] by (simp add: ac_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1237
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1238
lemma psuminf_half_series: "psuminf (\<lambda>n. (1/2)^Suc n) = 1"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1239
  using suminf_imp_psuminf[OF power_half_series] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1240
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1241
lemma setsum_pinfsum: "(\<Sum>\<^isub>\<infinity> n. \<Sum>m\<in>A. f n m) = (\<Sum>m\<in>A. (\<Sum>\<^isub>\<infinity> n. f n m))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1242
proof (cases "finite A")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1243
  assume "finite A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1244
  thus ?thesis by induct simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1245
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1246
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1247
lemma psuminf_reindex:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1248
  fixes f:: "nat \<Rightarrow> nat" assumes "bij f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1249
  shows "psuminf (g \<circ> f) = psuminf g"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1250
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1251
  have [intro, simp]: "\<And>A. inj_on f A" using `bij f` unfolding bij_def by (auto intro: subset_inj_on)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1252
  have f[intro, simp]: "\<And>x. f (inv f x) = x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1253
    using `bij f` unfolding bij_def by (auto intro: surj_f_inv_f)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1254
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1255
  show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1256
  proof (rule psuminf_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1257
    fix n
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1258
    have "setsum (g \<circ> f) {..<n} = setsum g (f ` {..<n})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1259
      by (simp add: setsum_reindex)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1260
    also have "\<dots> \<le> setsum g {..Max (f ` {..<n})}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1261
      by (rule setsum_mono3) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1262
    also have "\<dots> \<le> psuminf g" unfolding lessThan_Suc_atMost[symmetric] by (rule psuminf_upper)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1263
    finally show "setsum (g \<circ> f) {..<n} \<le> psuminf g" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1264
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1265
    fix y assume *: "\<And>n. setsum (g \<circ> f) {..<n} \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1266
    show "psuminf g \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1267
    proof (safe intro!: psuminf_bound)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1268
      fix N
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1269
      have "setsum g {..<N} \<le> setsum g (f ` {..Max (inv f ` {..<N})})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1270
        by (rule setsum_mono3) (auto intro!: image_eqI[where f="f", OF f[symmetric]])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1271
      also have "\<dots> = setsum (g \<circ> f) {..Max (inv f ` {..<N})}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1272
        by (simp add: setsum_reindex)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1273
      also have "\<dots> \<le> y" unfolding lessThan_Suc_atMost[symmetric] by (rule *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1274
      finally show "setsum g {..<N} \<le> y" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1275
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1276
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1277
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1278
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1279
lemma psuminf_2dimen:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1280
  fixes f:: "nat * nat \<Rightarrow> pinfreal"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1281
  assumes fsums: "\<And>m. g m = (\<Sum>\<^isub>\<infinity> n. f (m,n))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1282
  shows "psuminf (f \<circ> prod_decode) = psuminf g"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1283
proof (rule psuminf_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1284
  fix n :: nat
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1285
  let ?P = "prod_decode ` {..<n}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1286
  have "setsum (f \<circ> prod_decode) {..<n} = setsum f ?P"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1287
    by (auto simp: setsum_reindex inj_prod_decode)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1288
  also have "\<dots> \<le> setsum f ({..Max (fst ` ?P)} \<times> {..Max (snd ` ?P)})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1289
  proof (safe intro!: setsum_mono3 Max_ge image_eqI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1290
    fix a b x assume "(a, b) = prod_decode x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1291
    from this[symmetric] show "a = fst (prod_decode x)" "b = snd (prod_decode x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1292
      by simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1293
  qed simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1294
  also have "\<dots> = (\<Sum>m\<le>Max (fst ` ?P). (\<Sum>n\<le>Max (snd ` ?P). f (m,n)))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1295
    unfolding setsum_cartesian_product by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1296
  also have "\<dots> \<le> (\<Sum>m\<le>Max (fst ` ?P). g m)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1297
    by (auto intro!: setsum_mono psuminf_upper simp del: setsum_lessThan_Suc
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1298
        simp: fsums lessThan_Suc_atMost[symmetric])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1299
  also have "\<dots> \<le> psuminf g"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1300
    by (auto intro!: psuminf_upper simp del: setsum_lessThan_Suc
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1301
        simp: lessThan_Suc_atMost[symmetric])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1302
  finally show "setsum (f \<circ> prod_decode) {..<n} \<le> psuminf g" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1303
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1304
  fix y assume *: "\<And>n. setsum (f \<circ> prod_decode) {..<n} \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1305
  have g: "g = (\<lambda>m. \<Sum>\<^isub>\<infinity> n. f (m,n))" unfolding fsums[symmetric] ..
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1306
  show "psuminf g \<le> y" unfolding g
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1307
  proof (rule psuminf_bound, unfold setsum_pinfsum[symmetric], safe intro!: psuminf_bound)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1308
    fix N M :: nat
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1309
    let ?P = "{..<N} \<times> {..<M}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1310
    let ?M = "Max (prod_encode ` ?P)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1311
    have "(\<Sum>n<M. \<Sum>m<N. f (m, n)) \<le> (\<Sum>(m, n)\<in>?P. f (m, n))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1312
      unfolding setsum_commute[of _ _ "{..<M}"] unfolding setsum_cartesian_product ..
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1313
    also have "\<dots> \<le> (\<Sum>(m,n)\<in>(prod_decode ` {..?M}). f (m, n))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1314
      by (auto intro!: setsum_mono3 image_eqI[where f=prod_decode, OF prod_encode_inverse[symmetric]])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1315
    also have "\<dots> \<le> y" using *[of "Suc ?M"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1316
      by (simp add: lessThan_Suc_atMost[symmetric] setsum_reindex
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1317
               inj_prod_decode del: setsum_lessThan_Suc)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1318
    finally show "(\<Sum>n<M. \<Sum>m<N. f (m, n)) \<le> y" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1319
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1320
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1321
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1322
lemma pinfreal_mult_less_right:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1323
  assumes "b * a < c * a" "0 < a" "a < \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1324
  shows "b < c"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1325
  using assms
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1326
  by (cases a, cases b, cases c) (auto split: split_if_asm simp: zero_less_mult_iff zero_le_mult_iff)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1327
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1328
lemma pinfreal_\<omega>_eq_plus[simp]: "\<omega> = a + b \<longleftrightarrow> (a = \<omega> \<or> b = \<omega>)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1329
  by (cases a, cases b) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1330
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1331
lemma pinfreal_of_nat_le_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1332
  "(of_nat k :: pinfreal) \<le> of_nat m \<longleftrightarrow> k \<le> m" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1333
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1334
lemma pinfreal_of_nat_less_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1335
  "(of_nat k :: pinfreal) < of_nat m \<longleftrightarrow> k < m" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1336
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1337
lemma pinfreal_bound_add:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1338
  assumes "\<forall>N. f N + y \<le> (x::pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1339
  shows "(SUP n. f n) + y \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1340
proof (cases "x = \<omega>")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1341
  have "y \<le> x" using assms by (auto intro: pinfreal_le_add2)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1342
  assume "x \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1343
  note move_y = pinfreal_less_eq_diff_eq_sum[OF `y \<le> x` this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1344
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1345
  have "\<forall>N. f N \<le> x - y" using assms by (simp add: move_y)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1346
  hence "(SUP n. f n) \<le> x - y" by (rule SUPR_bound)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1347
  thus ?thesis by (simp add: move_y)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1348
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1349
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1350
lemma SUPR_pinfreal_add:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1351
  fixes f g :: "nat \<Rightarrow> pinfreal"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1352
  assumes f: "\<forall>n. f n \<le> f (Suc n)" and g: "\<forall>n. g n \<le> g (Suc n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1353
  shows "(SUP n. f n + g n) = (SUP n. f n) + (SUP n. g n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1354
proof (rule pinfreal_SUPI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1355
  fix n :: nat from le_SUPI[of n UNIV f] le_SUPI[of n UNIV g]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1356
  show "f n + g n \<le> (SUP n. f n) + (SUP n. g n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1357
    by (auto intro!: add_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1358
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1359
  fix y assume *: "\<And>n. n \<in> UNIV \<Longrightarrow> f n + g n \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1360
  { fix n m
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1361
    have "f n + g m \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1362
    proof (cases rule: linorder_le_cases)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1363
      assume "n \<le> m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1364
      hence "f n + g m \<le> f m + g m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1365
        using f lift_Suc_mono_le by (auto intro!: add_right_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1366
      also have "\<dots> \<le> y" using * by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1367
      finally show ?thesis .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1368
    next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1369
      assume "m \<le> n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1370
      hence "f n + g m \<le> f n + g n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1371
        using g lift_Suc_mono_le by (auto intro!: add_left_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1372
      also have "\<dots> \<le> y" using * by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1373
      finally show ?thesis .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1374
    qed }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1375
  hence "\<And>m. \<forall>n. f n + g m \<le> y" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1376
  from pinfreal_bound_add[OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1377
  have "\<forall>m. (g m) + (SUP n. f n) \<le> y" by (simp add: ac_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1378
  from pinfreal_bound_add[OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1379
  show "SUPR UNIV f + SUPR UNIV g \<le> y" by (simp add: ac_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1380
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1381
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1382
lemma SUPR_pinfreal_setsum:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1383
  fixes f :: "'x \<Rightarrow> nat \<Rightarrow> pinfreal"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1384
  assumes "\<And>i. i \<in> P \<Longrightarrow> \<forall>n. f i n \<le> f i (Suc n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1385
  shows "(SUP n. \<Sum>i\<in>P. f i n) = (\<Sum>i\<in>P. SUP n. f i n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1386
proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1387
  assume "finite P" from this assms show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1388
  proof induct
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1389
    case (insert i P)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1390
    thus ?case
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1391
      apply simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1392
      apply (subst SUPR_pinfreal_add)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1393
      by (auto intro!: setsum_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1394
  qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1395
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1396
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1397
lemma Real_max:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1398
  assumes "x \<ge> 0" "y \<ge> 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1399
  shows "Real (max x y) = max (Real x) (Real y)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1400
  using assms unfolding max_def by (auto simp add:not_le)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1401
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1402
lemma Real_real: "Real (real x) = (if x = \<omega> then 0 else x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1403
  using assms by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1404
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1405
lemma inj_on_real: "inj_on real (UNIV - {\<omega>})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1406
proof (rule inj_onI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1407
  fix x y assume mem: "x \<in> UNIV - {\<omega>}" "y \<in> UNIV - {\<omega>}" and "real x = real y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1408
  thus "x = y" by (cases x, cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1409
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1410
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1411
lemma inj_on_Real: "inj_on Real {0..}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1412
  by (auto intro!: inj_onI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1413
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1414
lemma range_Real[simp]: "range Real = UNIV - {\<omega>}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1415
proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1416
  fix x assume "x \<notin> range Real"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1417
  thus "x = \<omega>" by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1418
qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1419
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1420
lemma image_Real[simp]: "Real ` {0..} = UNIV - {\<omega>}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1421
proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1422
  fix x assume "x \<notin> Real ` {0..}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1423
  thus "x = \<omega>" by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1424
qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1425
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1426
lemma pinfreal_SUP_cmult:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1427
  fixes f :: "'a \<Rightarrow> pinfreal"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1428
  shows "(SUP i : R. z * f i) = z * (SUP i : R. f i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1429
proof (rule pinfreal_SUPI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1430
  fix i assume "i \<in> R"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1431
  from le_SUPI[OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1432
  show "z * f i \<le> z * (SUP i:R. f i)" by (rule pinfreal_mult_cancel)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1433
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1434
  fix y assume "\<And>i. i\<in>R \<Longrightarrow> z * f i \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1435
  hence *: "\<And>i. i\<in>R \<Longrightarrow> z * f i \<le> y" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1436
  show "z * (SUP i:R. f i) \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1437
  proof (cases "\<forall>i\<in>R. f i = 0")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1438
    case True
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1439
    show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1440
    proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1441
      assume "R \<noteq> {}" hence "f ` R = {0}" using True by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1442
      thus ?thesis by (simp add: SUPR_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1443
    qed (simp add: SUPR_def Sup_empty bot_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1444
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1445
    case False then obtain i where i: "i \<in> R" and f0: "f i \<noteq> 0" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1446
    show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1447
    proof (cases "z = 0 \<or> z = \<omega>")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1448
      case True with f0 *[OF i] show ?thesis by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1449
    next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1450
      case False hence z: "z \<noteq> 0" "z \<noteq> \<omega>" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1451
      note div = pinfreal_inverse_le_eq[OF this, symmetric]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1452
      hence "\<And>i. i\<in>R \<Longrightarrow> f i \<le> y / z" using * by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1453
      thus ?thesis unfolding div SUP_le_iff by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1454
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1455
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1456
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1457
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1458
instantiation pinfreal :: topological_space
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1459
begin
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1460
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1461
definition "open A \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1462
  (\<exists>T. open T \<and> (Real ` (T\<inter>{0..}) = A - {\<omega>})) \<and> (\<omega> \<in> A \<longrightarrow> (\<exists>x\<ge>0. {Real x <..} \<subseteq> A))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1463
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1464
lemma open_omega: "open A \<Longrightarrow> \<omega> \<in> A \<Longrightarrow> (\<exists>x\<ge>0. {Real x<..} \<subseteq> A)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1465
  unfolding open_pinfreal_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1466
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1467
lemma open_omegaD: assumes "open A" "\<omega> \<in> A" obtains x where "x\<ge>0" "{Real x<..} \<subseteq> A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1468
  using open_omega[OF assms] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1469
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1470
lemma pinfreal_openE: assumes "open A" obtains A' x where
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1471
  "open A'" "Real ` (A' \<inter> {0..}) = A - {\<omega>}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1472
  "x \<ge> 0" "\<omega> \<in> A \<Longrightarrow> {Real x<..} \<subseteq> A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1473
  using assms open_pinfreal_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1474
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1475
instance
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1476
proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1477
  let ?U = "UNIV::pinfreal set"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1478
  show "open ?U" unfolding open_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1479
    by (auto intro!: exI[of _ "UNIV"] exI[of _ 0])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1480
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1481
  fix S T::"pinfreal set" assume "open S" and "open T"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1482
  from `open S`[THEN pinfreal_openE] guess S' xS . note S' = this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1483
  from `open T`[THEN pinfreal_openE] guess T' xT . note T' = this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1484
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1485
  from S'(1-3) T'(1-3)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1486
  show "open (S \<inter> T)" unfolding open_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1487
  proof (safe intro!: exI[of _ "S' \<inter> T'"] exI[of _ "max xS xT"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1488
    fix x assume *: "Real (max xS xT) < x" and "\<omega> \<in> S" "\<omega> \<in> T"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1489
    from `\<omega> \<in> S`[THEN S'(4)] * show "x \<in> S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1490
      by (cases x, auto simp: max_def split: split_if_asm)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1491
    from `\<omega> \<in> T`[THEN T'(4)] * show "x \<in> T"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1492
      by (cases x, auto simp: max_def split: split_if_asm)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1493
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1494
    fix x assume x: "x \<notin> Real ` (S' \<inter> T' \<inter> {0..})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1495
    have *: "S' \<inter> T' \<inter> {0..} = (S' \<inter> {0..}) \<inter> (T' \<inter> {0..})" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1496
    assume "x \<in> T" "x \<in> S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1497
    with S'(2) T'(2) show "x = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1498
      using x[unfolded *] inj_on_image_Int[OF inj_on_Real] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1499
  qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1500
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1501
  fix K assume openK: "\<forall>S \<in> K. open (S:: pinfreal set)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1502
  hence "\<forall>S\<in>K. \<exists>T. open T \<and> Real ` (T \<inter> {0..}) = S - {\<omega>}" by (auto simp: open_pinfreal_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1503
  from bchoice[OF this] guess T .. note T = this[rule_format]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1504
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1505
  show "open (\<Union>K)" unfolding open_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1506
  proof (safe intro!: exI[of _ "\<Union>(T ` K)"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1507
    fix x S assume "0 \<le> x" "x \<in> T S" "S \<in> K"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1508
    with T[OF `S \<in> K`] show "Real x \<in> \<Union>K" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1509
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1510
    fix x S assume x: "x \<notin> Real ` (\<Union>T ` K \<inter> {0..})" "S \<in> K" "x \<in> S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1511
    hence "x \<notin> Real ` (T S \<inter> {0..})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1512
      by (auto simp: image_UN UN_simps[symmetric] simp del: UN_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1513
    thus "x = \<omega>" using T[OF `S \<in> K`] `x \<in> S` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1514
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1515
    fix S assume "\<omega> \<in> S" "S \<in> K"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1516
    from openK[rule_format, OF `S \<in> K`, THEN pinfreal_openE] guess S' x .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1517
    from this(3, 4) `\<omega> \<in> S`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1518
    show "\<exists>x\<ge>0. {Real x<..} \<subseteq> \<Union>K"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1519
      by (auto intro!: exI[of _ x] bexI[OF _ `S \<in> K`])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1520
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1521
    from T[THEN conjunct1] show "open (\<Union>T`K)" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1522
  qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1523
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1524
end
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1525
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1526
lemma open_pinfreal_lessThan[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1527
  "open {..< a :: pinfreal}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1528
proof (cases a)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1529
  case (preal x) thus ?thesis unfolding open_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1530
  proof (safe intro!: exI[of _ "{..< x}"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1531
    fix y assume "y < Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1532
    moreover assume "y \<notin> Real ` ({..<x} \<inter> {0..})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1533
    ultimately have "y \<noteq> Real (real y)" using preal by (cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1534
    thus "y = \<omega>" by (auto simp: Real_real split: split_if_asm)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1535
  qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1536
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1537
  case infinite thus ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1538
    unfolding open_pinfreal_def by (auto intro!: exI[of _ UNIV])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1539
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1540
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1541
lemma open_pinfreal_greaterThan[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1542
  "open {a :: pinfreal <..}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1543
proof (cases a)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1544
  case (preal x) thus ?thesis unfolding open_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1545
  proof (safe intro!: exI[of _ "{x <..}"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1546
    fix y assume "Real x < y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1547
    moreover assume "y \<notin> Real ` ({x<..} \<inter> {0..})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1548
    ultimately have "y \<noteq> Real (real y)" using preal by (cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1549
    thus "y = \<omega>" by (auto simp: Real_real split: split_if_asm)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1550
  qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1551
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1552
  case infinite thus ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1553
    unfolding open_pinfreal_def by (auto intro!: exI[of _ "{}"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1554
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1555
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1556
lemma pinfreal_open_greaterThanLessThan[simp]: "open {a::pinfreal <..< b}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1557
  unfolding greaterThanLessThan_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1558
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1559
lemma closed_pinfreal_atLeast[simp, intro]: "closed {a :: pinfreal ..}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1560
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1561
  have "- {a ..} = {..< a}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1562
  then show "closed {a ..}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1563
    unfolding closed_def using open_pinfreal_lessThan by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1564
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1565
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1566
lemma closed_pinfreal_atMost[simp, intro]: "closed {.. b :: pinfreal}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1567
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1568
  have "- {.. b} = {b <..}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1569
  then show "closed {.. b}" 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1570
    unfolding closed_def using open_pinfreal_greaterThan by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1571
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1572
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1573
lemma closed_pinfreal_atLeastAtMost[simp, intro]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1574
  shows "closed {a :: pinfreal .. b}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1575
  unfolding atLeastAtMost_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1576
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1577
lemma pinfreal_dense:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1578
  fixes x y :: pinfreal assumes "x < y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1579
  shows "\<exists>z. x < z \<and> z < y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1580
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1581
  from `x < y` obtain p where p: "x = Real p" "0 \<le> p" by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1582
  show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1583
  proof (cases y)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1584
    case (preal r) with p `x < y` have "p < r" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1585
    with dense obtain z where "p < z" "z < r" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1586
    thus ?thesis using preal p by (auto intro!: exI[of _ "Real z"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1587
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1588
    case infinite thus ?thesis using `x < y` p
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1589
      by (auto intro!: exI[of _ "Real p + 1"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1590
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1591
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1592
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1593
instance pinfreal :: t2_space
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1594
proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1595
  fix x y :: pinfreal assume "x \<noteq> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1596
  let "?P x (y::pinfreal)" = "\<exists> U V. open U \<and> open V \<and> x \<in> U \<and> y \<in> V \<and> U \<inter> V = {}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1597
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1598
  { fix x y :: pinfreal assume "x < y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1599
    from pinfreal_dense[OF this] obtain z where z: "x < z" "z < y" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1600
    have "?P x y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1601
      apply (rule exI[of _ "{..<z}"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1602
      apply (rule exI[of _ "{z<..}"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1603
      using z by auto }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1604
  note * = this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1605
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1606
  from `x \<noteq> y`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1607
  show "\<exists>U V. open U \<and> open V \<and> x \<in> U \<and> y \<in> V \<and> U \<inter> V = {}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1608
  proof (cases rule: linorder_cases)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1609
    assume "x = y" with `x \<noteq> y` show ?thesis by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1610
  next assume "x < y" from *[OF this] show ?thesis by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1611
  next assume "y < x" from *[OF this] show ?thesis by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1612
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1613
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1614
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1615
definition (in complete_lattice) isoton :: "(nat \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<up>" 50) where
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1616
  "A \<up> X \<longleftrightarrow> (\<forall>i. A i \<le> A (Suc i)) \<and> (SUP i. A i) = X"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1617
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1618
definition (in complete_lattice) antiton (infix "\<down>" 50) where
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1619
  "A \<down> X \<longleftrightarrow> (\<forall>i. A i \<ge> A (Suc i)) \<and> (INF i. A i) = X"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1620
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1621
lemma range_const[simp]: "range (\<lambda>x. c) = {c}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1622
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1623
lemma isoton_cmult_right:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1624
  assumes "f \<up> (x::pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1625
  shows "(\<lambda>i. c * f i) \<up> (c * x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1626
  using assms unfolding isoton_def pinfreal_SUP_cmult
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1627
  by (auto intro: pinfreal_mult_cancel)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1628
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1629
lemma isoton_cmult_left:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1630
  "f \<up> (x::pinfreal) \<Longrightarrow> (\<lambda>i. f i * c) \<up> (x * c)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1631
  by (subst (1 2) mult_commute) (rule isoton_cmult_right)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1632
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1633
lemma isoton_add:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1634
  assumes "f \<up> (x::pinfreal)" and "g \<up> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1635
  shows "(\<lambda>i. f i + g i) \<up> (x + y)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1636
  using assms unfolding isoton_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1637
  by (auto intro: pinfreal_mult_cancel add_mono simp: SUPR_pinfreal_add)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1638
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1639
lemma isoton_fun_expand:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1640
  "f \<up> x \<longleftrightarrow> (\<forall>i. (\<lambda>j. f j i) \<up> (x i))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1641
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1642
  have "\<And>i. {y. \<exists>f'\<in>range f. y = f' i} = range (\<lambda>j. f j i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1643
    by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1644
  with assms show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1645
    by (auto simp add: isoton_def le_fun_def Sup_fun_def SUPR_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1646
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1647
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1648
lemma isoton_indicator:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1649
  assumes "f \<up> g"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1650
  shows "(\<lambda>i x. f i x * indicator A x) \<up> (\<lambda>x. g x * indicator A x :: pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1651
  using assms unfolding isoton_fun_expand by (auto intro!: isoton_cmult_left)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1652
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1653
lemma pinfreal_ord_one[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1654
  "Real p < 1 \<longleftrightarrow> p < 1"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1655
  "Real p \<le> 1 \<longleftrightarrow> p \<le> 1"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1656
  "1 < Real p \<longleftrightarrow> 1 < p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1657
  "1 \<le> Real p \<longleftrightarrow> 1 \<le> p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1658
  by (simp_all add: one_pinfreal_def del: Real_1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1659
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1660
lemma SUP_mono:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1661
  assumes "\<And>n. f n \<le> g (N n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1662
  shows "(SUP n. f n) \<le> (SUP n. g n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1663
proof (safe intro!: SUPR_bound)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1664
  fix n note assms[of n]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1665
  also have "g (N n) \<le> (SUP n. g n)" by (auto intro!: le_SUPI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1666
  finally show "f n \<le> (SUP n. g n)" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1667
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1668
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1669
lemma isoton_Sup:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1670
  assumes "f \<up> u"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1671
  shows "f i \<le> u"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1672
  using le_SUPI[of i UNIV f] assms
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1673
  unfolding isoton_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1674
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1675
lemma isoton_mono:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1676
  assumes iso: "x \<up> a" "y \<up> b" and *: "\<And>n. x n \<le> y (N n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1677
  shows "a \<le> b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1678
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1679
  from iso have "a = (SUP n. x n)" "b = (SUP n. y n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1680
    unfolding isoton_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1681
  with * show ?thesis by (auto intro!: SUP_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1682
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1683
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1684
lemma pinfreal_le_mult_one_interval:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1685
  fixes x y :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1686
  assumes "\<And>z. \<lbrakk> 0 < z ; z < 1 \<rbrakk> \<Longrightarrow> z * x \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1687
  shows "x \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1688
proof (cases x, cases y)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1689
  assume "x = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1690
  with assms[of "1 / 2"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1691
  show "x \<le> y" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1692
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1693
  fix r p assume *: "y = Real p" "x = Real r" and **: "0 \<le> r" "0 \<le> p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1694
  have "r \<le> p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1695
  proof (rule field_le_mult_one_interval)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1696
    fix z :: real assume "0 < z" and "z < 1"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1697
    with assms[of "Real z"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1698
    show "z * r \<le> p" using ** * by (auto simp: zero_le_mult_iff)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1699
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1700
  thus "x \<le> y" using ** * by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1701
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1702
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1703
lemma pinfreal_greater_0[intro]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1704
  fixes a :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1705
  assumes "a \<noteq> 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1706
  shows "a > 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1707
using assms apply (cases a) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1708
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1709
lemma pinfreal_mult_strict_right_mono:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1710
  assumes "a < b" and "0 < c" "c < \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1711
  shows "a * c < b * c"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1712
  using assms
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1713
  by (cases a, cases b, cases c)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1714
     (auto simp: zero_le_mult_iff pinfreal_less_\<omega>)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1715
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1716
lemma minus_pinfreal_eq2:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1717
  fixes x y z :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1718
  assumes "y \<le> x" and "y \<noteq> \<omega>" shows "z = x - y \<longleftrightarrow> z + y = x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1719
  using assms
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1720
  apply (subst eq_commute)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1721
  apply (subst minus_pinfreal_eq)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1722
  by (cases x, cases z, auto simp add: ac_simps not_less)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1723
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1724
lemma pinfreal_diff_eq_diff_imp_eq:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1725
  assumes "a \<noteq> \<omega>" "b \<le> a" "c \<le> a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1726
  assumes "a - b = a - c"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1727
  shows "b = c"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1728
  using assms
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1729
  by (cases a, cases b, cases c) (auto split: split_if_asm)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1730
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1731
lemma pinfreal_inverse_eq_0: "inverse x = 0 \<longleftrightarrow> x = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1732
  by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1733
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1734
lemma pinfreal_mult_inverse:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1735
  "\<lbrakk> x \<noteq> \<omega> ; x \<noteq> 0 \<rbrakk> \<Longrightarrow> x * inverse x = 1"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1736
  by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1737
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1738
lemma pinfreal_zero_less_diff_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1739
  fixes a b :: pinfreal shows "0 < a - b \<longleftrightarrow> b < a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1740
  apply (cases a, cases b)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1741
  apply (auto simp: pinfreal_noteq_omega_Ex pinfreal_less_\<omega>)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1742
  apply (cases b)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1743
  by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1744
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1745
lemma pinfreal_less_Real_Ex:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1746
  fixes a b :: pinfreal shows "x < Real r \<longleftrightarrow> (\<exists>p\<ge>0. p < r \<and> x = Real p)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1747
  by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1748
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1749
lemma open_Real: assumes "open S" shows "open (Real ` ({0..} \<inter> S))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1750
  unfolding open_pinfreal_def apply(rule,rule,rule,rule assms) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1751
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1752
lemma pinfreal_zero_le_diff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1753
  fixes a b :: pinfreal shows "a - b = 0 \<longleftrightarrow> a \<le> b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1754
  by (cases a, cases b, simp_all, cases b, auto)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1755
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1756
lemma lim_Real[simp]: assumes "\<forall>n. f n \<ge> 0" "m\<ge>0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1757
  shows "(\<lambda>n. Real (f n)) ----> Real m \<longleftrightarrow> (\<lambda>n. f n) ----> m" (is "?l = ?r")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1758
proof assume ?l show ?r unfolding Lim_sequentially
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1759
  proof safe fix e::real assume e:"e>0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1760
    note open_ball[of m e] note open_Real[OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1761
    note * = `?l`[unfolded tendsto_def,rule_format,OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1762
    have "eventually (\<lambda>x. Real (f x) \<in> Real ` ({0..} \<inter> ball m e)) sequentially"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1763
      apply(rule *) unfolding image_iff using assms(2) e by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1764
    thus "\<exists>N. \<forall>n\<ge>N. dist (f n) m < e" unfolding eventually_sequentially 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1765
      apply safe apply(rule_tac x=N in exI,safe) apply(erule_tac x=n in allE,safe)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1766
    proof- fix n x assume "Real (f n) = Real x" "0 \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1767
      hence *:"f n = x" using assms(1) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1768
      assume "x \<in> ball m e" thus "dist (f n) m < e" unfolding *
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1769
        by (auto simp add:dist_commute)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1770
    qed qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1771
next assume ?r show ?l unfolding tendsto_def eventually_sequentially 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1772
  proof safe fix S assume S:"open S" "Real m \<in> S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1773
    guess T y using S(1) apply-apply(erule pinfreal_openE) . note T=this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1774
    have "m\<in>real ` (S - {\<omega>})" unfolding image_iff 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1775
      apply(rule_tac x="Real m" in bexI) using assms(2) S(2) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1776
    hence "m \<in> T" unfolding T(2)[THEN sym] by auto 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1777
    from `?r`[unfolded tendsto_def eventually_sequentially,rule_format,OF T(1) this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1778
    guess N .. note N=this[rule_format]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1779
    show "\<exists>N. \<forall>n\<ge>N. Real (f n) \<in> S" apply(rule_tac x=N in exI) 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1780
    proof safe fix n assume n:"N\<le>n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1781
      have "f n \<in> real ` (S - {\<omega>})" using N[OF n] assms unfolding T(2)[THEN sym] 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1782
        unfolding image_iff apply-apply(rule_tac x="Real (f n)" in bexI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1783
        unfolding real_Real by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1784
      then guess x unfolding image_iff .. note x=this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1785
      show "Real (f n) \<in> S" unfolding x apply(subst Real_real) using x by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1786
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1787
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1788
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1789
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1790
lemma pinfreal_INFI:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1791
  fixes x :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1792
  assumes "\<And>i. i \<in> A \<Longrightarrow> x \<le> f i"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1793
  assumes "\<And>y. (\<And>i. i \<in> A \<Longrightarrow> y \<le> f i) \<Longrightarrow> y \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1794
  shows "(INF i:A. f i) = x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1795
  unfolding INFI_def Inf_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1796
  using assms by (auto intro!: Greatest_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1797
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1798
lemma real_of_pinfreal_less:"x < y \<Longrightarrow> y\<noteq>\<omega> \<Longrightarrow> real x < real y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1799
proof- case goal1
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1800
  have *:"y = Real (real y)" "x = Real (real x)" using goal1 Real_real by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1801
  show ?case using goal1 apply- apply(subst(asm) *(1))apply(subst(asm) *(2))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1802
    unfolding pinfreal_less by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1803
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1804
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1805
lemma not_less_omega[simp]:"\<not> x < \<omega> \<longleftrightarrow> x = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1806
  by (metis antisym_conv3 pinfreal_less(3)) 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1807
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1808
lemma Real_real': assumes "x\<noteq>\<omega>" shows "Real (real x) = x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1809
proof- have *:"(THE r. 0 \<le> r \<and> x = Real r) = real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1810
    apply(rule the_equality) using assms unfolding Real_real by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1811
  have "Real (THE r. 0 \<le> r \<and> x = Real r) = x" unfolding *
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1812
    using assms unfolding Real_real by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1813
  thus ?thesis unfolding real_of_pinfreal_def of_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1814
    unfolding pinfreal_case_def using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1815
qed 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1816
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1817
lemma Real_less_plus_one:"Real x < Real (max (x + 1) 1)" 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1818
  unfolding pinfreal_less by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1819
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1820
lemma Lim_omega: "f ----> \<omega> \<longleftrightarrow> (\<forall>B. \<exists>N. \<forall>n\<ge>N. f n \<ge> Real B)" (is "?l = ?r")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1821
proof assume ?r show ?l apply(rule topological_tendstoI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1822
    unfolding eventually_sequentially
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1823
  proof- fix S assume "open S" "\<omega> \<in> S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1824
    from open_omega[OF this] guess B .. note B=this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1825
    from `?r`[rule_format,of "(max B 0)+1"] guess N .. note N=this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1826
    show "\<exists>N. \<forall>n\<ge>N. f n \<in> S" apply(rule_tac x=N in exI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1827
    proof safe case goal1 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1828
      have "Real B < Real ((max B 0) + 1)" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1829
      also have "... \<le> f n" using goal1 N by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1830
      finally show ?case using B by fastsimp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1831
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1832
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1833
next assume ?l show ?r
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1834
  proof fix B::real have "open {Real B<..}" "\<omega> \<in> {Real B<..}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1835
    from topological_tendstoD[OF `?l` this,unfolded eventually_sequentially]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1836
    guess N .. note N=this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1837
    show "\<exists>N. \<forall>n\<ge>N. Real B \<le> f n" apply(rule_tac x=N in exI) using N by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1838
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1839
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1840
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1841
lemma Lim_bounded_omgea: assumes lim:"f ----> l" and "\<And>n. f n \<le> Real B" shows "l \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1842
proof(rule ccontr,unfold not_not) let ?B = "max (B + 1) 1" assume as:"l=\<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1843
  from lim[unfolded this Lim_omega,rule_format,of "?B"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1844
  guess N .. note N=this[rule_format,OF le_refl]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1845
  hence "Real ?B \<le> Real B" using assms(2)[of N] by(rule order_trans) 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1846
  hence "Real ?B < Real ?B" using Real_less_plus_one[of B] by(rule le_less_trans)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1847
  thus False by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1848
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1849
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1850
lemma incseq_le_pinfreal: assumes inc: "\<And>n m. n\<ge>m \<Longrightarrow> X n \<ge> X m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1851
  and lim: "X ----> (L::pinfreal)" shows "X n \<le> L"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1852
proof(cases "L = \<omega>")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1853
  case False have "\<forall>n. X n \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1854
  proof(rule ccontr,unfold not_all not_not,safe)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1855
    case goal1 hence "\<forall>n\<ge>x. X n = \<omega>" using inc[of x] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1856
    hence "X ----> \<omega>" unfolding tendsto_def eventually_sequentially
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1857
      apply safe apply(rule_tac x=x in exI) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1858
    note Lim_unique[OF trivial_limit_sequentially this lim]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1859
    with False show False by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1860
  qed note * =this[rule_format]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1861
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1862
  have **:"\<forall>m n. m \<le> n \<longrightarrow> Real (real (X m)) \<le> Real (real (X n))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1863
    unfolding Real_real using * inc by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1864
  have "real (X n) \<le> real L" apply-apply(rule incseq_le) defer
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1865
    apply(subst lim_Real[THEN sym]) apply(rule,rule,rule)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1866
    unfolding Real_real'[OF *] Real_real'[OF False] 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1867
    unfolding incseq_def using ** lim by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1868
  hence "Real (real (X n)) \<le> Real (real L)" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1869
  thus ?thesis unfolding Real_real using * False by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1870
qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1871
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1872
lemma SUP_Lim_pinfreal: assumes "\<And>n m. n\<ge>m \<Longrightarrow> f n \<ge> f m" "f ----> l"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1873
  shows "(SUP n. f n) = (l::pinfreal)" unfolding SUPR_def Sup_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1874
proof (safe intro!: Least_equality)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1875
  fix n::nat show "f n \<le> l" apply(rule incseq_le_pinfreal)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1876
    using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1877
next fix y assume y:"\<forall>x\<in>range f. x \<le> y" show "l \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1878
  proof(rule ccontr,cases "y=\<omega>",unfold not_le)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1879
    case False assume as:"y < l"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1880
    have l:"l \<noteq> \<omega>" apply(rule Lim_bounded_omgea[OF assms(2), of "real y"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1881
      using False y unfolding Real_real by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1882
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1883
    have yl:"real y < real l" using as apply-
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1884
      apply(subst(asm) Real_real'[THEN sym,OF `y\<noteq>\<omega>`])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1885
      apply(subst(asm) Real_real'[THEN sym,OF `l\<noteq>\<omega>`]) 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1886
      unfolding pinfreal_less apply(subst(asm) if_P) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1887
    hence "y + (y - l) * Real (1 / 2) < l" apply-
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1888
      apply(subst Real_real'[THEN sym,OF `y\<noteq>\<omega>`]) apply(subst(2) Real_real'[THEN sym,OF `y\<noteq>\<omega>`])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1889
      apply(subst Real_real'[THEN sym,OF `l\<noteq>\<omega>`]) apply(subst(2) Real_real'[THEN sym,OF `l\<noteq>\<omega>`]) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1890
    hence *:"l \<in> {y + (y - l) / 2<..}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1891
    have "open {y + (y-l)/2 <..}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1892
    note topological_tendstoD[OF assms(2) this *]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1893
    from this[unfolded eventually_sequentially] guess N .. note this[rule_format, of N]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1894
    hence "y + (y - l) * Real (1 / 2) < y" using y[rule_format,of "f N"] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1895
    hence "Real (real y) + (Real (real y) - Real (real l)) * Real (1 / 2) < Real (real y)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1896
      unfolding Real_real using `y\<noteq>\<omega>` `l\<noteq>\<omega>` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1897
    thus False using yl by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1898
  qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1899
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1900
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1901
lemma Real_max':"Real x = Real (max x 0)" 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1902
proof(cases "x < 0") case True
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1903
  hence *:"max x 0 = 0" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1904
  show ?thesis unfolding * using True by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1905
qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1906
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1907
lemma lim_pinfreal_increasing: assumes "\<forall>n m. n\<ge>m \<longrightarrow> f n \<ge> f m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1908
  obtains l where "f ----> (l::pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1909
proof(cases "\<exists>B. \<forall>n. f n < Real B")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1910
  case False thus thesis apply- apply(rule that[of \<omega>]) unfolding Lim_omega not_ex not_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1911
    apply safe apply(erule_tac x=B in allE,safe) apply(rule_tac x=x in exI,safe)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1912
    apply(rule order_trans[OF _ assms[rule_format]]) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1913
next case True then guess B .. note B = this[rule_format]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1914
  hence *:"\<And>n. f n < \<omega>" apply-apply(rule less_le_trans,assumption) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1915
  have *:"\<And>n. f n \<noteq> \<omega>" proof- case goal1 show ?case using *[of n] by auto qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1916
  have B':"\<And>n. real (f n) \<le> max 0 B" proof- case goal1 thus ?case
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1917
      using B[of n] apply-apply(subst(asm) Real_real'[THEN sym]) defer
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1918
      apply(subst(asm)(2) Real_max') unfolding pinfreal_less apply(subst(asm) if_P) using *[of n] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1919
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1920
  have "\<exists>l. (\<lambda>n. real (f n)) ----> l" apply(rule Topology_Euclidean_Space.bounded_increasing_convergent)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1921
  proof safe show "bounded {real (f n) |n. True}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1922
      unfolding bounded_def apply(rule_tac x=0 in exI,rule_tac x="max 0 B" in exI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1923
      using B' unfolding dist_norm by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1924
    fix n::nat have "Real (real (f n)) \<le> Real (real (f (Suc n)))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1925
      using assms[rule_format,of n "Suc n"] apply(subst Real_real)+
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1926
      using *[of n] *[of "Suc n"] by fastsimp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1927
    thus "real (f n) \<le> real (f (Suc n))" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1928
  qed then guess l .. note l=this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1929
  have "0 \<le> l" apply(rule LIMSEQ_le_const[OF l])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1930
    by(rule_tac x=0 in exI,auto)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1931
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1932
  thus ?thesis apply-apply(rule that[of "Real l"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1933
    using l apply-apply(subst(asm) lim_Real[THEN sym]) prefer 3
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1934
    unfolding Real_real using * by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1935
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1936
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1937
lemma setsum_neq_omega: assumes "finite s" "\<And>x. x \<in> s \<Longrightarrow> f x \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1938
  shows "setsum f s \<noteq> \<omega>" using assms
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1939
proof induct case (insert x s)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1940
  show ?case unfolding setsum.insert[OF insert(1-2)] 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1941
    using insert by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1942
qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1943
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1944
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1945
lemma real_Real': "0 \<le> x \<Longrightarrow> real (Real x) = x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1946
  unfolding real_Real by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1947
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1948
lemma real_pinfreal_pos[intro]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1949
  assumes "x \<noteq> 0" "x \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1950
  shows "real x > 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1951
  apply(subst real_Real'[THEN sym,of 0]) defer
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1952
  apply(rule real_of_pinfreal_less) using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1953
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1954
lemma Lim_omega_gt: "f ----> \<omega> \<longleftrightarrow> (\<forall>B. \<exists>N. \<forall>n\<ge>N. f n > Real B)" (is "?l = ?r")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1955
proof assume ?l thus ?r unfolding Lim_omega apply safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1956
    apply(erule_tac x="max B 0 +1" in allE,safe)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1957
    apply(rule_tac x=N in exI,safe) apply(erule_tac x=n in allE,safe)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1958
    apply(rule_tac y="Real (max B 0 + 1)" in less_le_trans) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1959
next assume ?r thus ?l unfolding Lim_omega apply safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1960
    apply(erule_tac x=B in allE,safe) apply(rule_tac x=N in exI,safe) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1961
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1962
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1963
lemma pinfreal_minus_le_cancel:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1964
  fixes a b c :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1965
  assumes "b \<le> a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1966
  shows "c - a \<le> c - b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1967
  using assms by (cases a, cases b, cases c, simp, simp, simp, cases b, cases c, simp_all)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1968
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1969
lemma pinfreal_minus_\<omega>[simp]: "x - \<omega> = 0" by (cases x) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1970
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1971
lemma pinfreal_minus_mono[intro]: "a - x \<le> (a::pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1972
proof- have "a - x \<le> a - 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1973
    apply(rule pinfreal_minus_le_cancel) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1974
  thus ?thesis by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1975
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1976
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1977
lemma pinfreal_minus_eq_\<omega>[simp]: "x - y = \<omega> \<longleftrightarrow> (x = \<omega> \<and> y \<noteq> \<omega>)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1978
  by (cases x, cases y) (auto, cases y, auto)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1979
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1980
lemma pinfreal_less_minus_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1981
  fixes a b c :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1982
  shows "a < b - c \<longleftrightarrow> c + a < b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1983
  by (cases c, cases a, cases b, auto)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1984
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1985
lemma pinfreal_minus_less_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1986
  fixes a b c :: pinfreal shows "a - c < b \<longleftrightarrow> (0 < b \<and> (c \<noteq> \<omega> \<longrightarrow> a < b + c))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1987
  by (cases c, cases a, cases b, auto)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1988
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1989
lemma pinfreal_le_minus_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1990
  fixes a b c :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1991
  shows "a \<le> c - b \<longleftrightarrow> ((c \<le> b \<longrightarrow> a = 0) \<and> (b < c \<longrightarrow> a + b \<le> c))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1992
  by (cases a, cases c, cases b, auto simp: pinfreal_noteq_omega_Ex)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1993
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1994
lemma pinfreal_minus_le_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1995
  fixes a b c :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1996
  shows "a - c \<le> b \<longleftrightarrow> (c \<le> a \<longrightarrow> a \<le> b + c)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1997
  by (cases a, cases c, cases b, auto simp: pinfreal_noteq_omega_Ex)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1998
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1999
lemmas pinfreal_minus_order = pinfreal_minus_le_iff pinfreal_minus_less_iff pinfreal_le_minus_iff pinfreal_less_minus_iff
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2000
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2001
lemma pinfreal_minus_strict_mono:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2002
  assumes "a > 0" "x > 0" "a\<noteq>\<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2003
  shows "a - x < (a::pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2004
  using assms by(cases x, cases a, auto)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2005
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2006
lemma pinfreal_minus':
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2007
  "Real r - Real p = (if 0 \<le> r \<and> p \<le> r then if 0 \<le> p then Real (r - p) else Real r else 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2008
  by (auto simp: minus_pinfreal_eq not_less)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2009
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2010
lemma pinfreal_minus_plus:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2011
  "x \<le> (a::pinfreal) \<Longrightarrow> a - x + x = a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2012
  by (cases a, cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2013
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2014
lemma pinfreal_cancel_plus_minus: "b \<noteq> \<omega> \<Longrightarrow> a + b - b = a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2015
  by (cases a, cases b) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2016
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2017
lemma pinfreal_minus_le_cancel_right:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2018
  fixes a b c :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2019
  assumes "a \<le> b" "c \<le> a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2020
  shows "a - c \<le> b - c"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2021
  using assms by (cases a, cases b, cases c, auto, cases c, auto)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2022
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2023
lemma real_of_pinfreal_setsum':
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2024
  assumes "\<forall>x \<in> S. f x \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2025
  shows "(\<Sum>x\<in>S. real (f x)) = real (setsum f S)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2026
proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2027
  assume "finite S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2028
  from this assms show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2029
    by induct (simp_all add: real_of_pinfreal_add setsum_\<omega>)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2030
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2031
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2032
lemma Lim_omega_pos: "f ----> \<omega> \<longleftrightarrow> (\<forall>B>0. \<exists>N. \<forall>n\<ge>N. f n \<ge> Real B)" (is "?l = ?r")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2033
  unfolding Lim_omega apply safe defer
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2034
  apply(erule_tac x="max 1 B" in allE) apply safe defer
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2035
  apply(rule_tac x=N in exI,safe) apply(erule_tac x=n in allE,safe)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2036
  apply(rule_tac y="Real (max 1 B)" in order_trans) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2037
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2038
lemma (in complete_lattice) isotonD[dest]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2039
  assumes "A \<up> X" shows "A i \<le> A (Suc i)" "(SUP i. A i) = X"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2040
  using assms unfolding isoton_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2041
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2042
lemma isotonD'[dest]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2043
  assumes "(A::_=>_) \<up> X" shows "A i x \<le> A (Suc i) x" "(SUP i. A i) = X"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2044
  using assms unfolding isoton_def le_fun_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2045
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2046
lemma pinfreal_LimI_finite:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2047
  assumes "x \<noteq> \<omega>" "\<And>r. 0 < r \<Longrightarrow> \<exists>N. \<forall>n\<ge>N. u n < x + r \<and> x < u n + r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2048
  shows "u ----> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2049
proof (rule topological_tendstoI, unfold eventually_sequentially)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2050
  fix S assume "open S" "x \<in> S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2051
  then obtain A where "open A" and A_eq: "Real ` (A \<inter> {0..}) = S - {\<omega>}" by (auto elim!: pinfreal_openE)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2052
  then have "x \<in> Real ` (A \<inter> {0..})" using `x \<in> S` `x \<noteq> \<omega>` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2053
  then have "real x \<in> A" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2054
  then obtain r where "0 < r" and dist: "\<And>y. dist y (real x) < r \<Longrightarrow> y \<in> A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2055
    using `open A` unfolding open_real_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2056
  then obtain n where
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2057
    upper: "\<And>N. n \<le> N \<Longrightarrow> u N < x + Real r" and
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2058
    lower: "\<And>N. n \<le> N \<Longrightarrow> x < u N + Real r" using assms(2)[of "Real r"] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2059
  show "\<exists>N. \<forall>n\<ge>N. u n \<in> S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2060
  proof (safe intro!: exI[of _ n])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2061
    fix N assume "n \<le> N"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2062
    from upper[OF this] `x \<noteq> \<omega>` `0 < r`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2063
    have "u N \<noteq> \<omega>" by (force simp: pinfreal_noteq_omega_Ex)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2064
    with `x \<noteq> \<omega>` `0 < r` lower[OF `n \<le> N`] upper[OF `n \<le> N`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2065
    have "dist (real (u N)) (real x) < r" "u N \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2066
      by (auto simp: pinfreal_noteq_omega_Ex dist_real_def abs_diff_less_iff field_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2067
    from dist[OF this(1)]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2068
    have "u N \<in> Real ` (A \<inter> {0..})" using `u N \<noteq> \<omega>`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2069
      by (auto intro!: image_eqI[of _ _ "real (u N)"] simp: pinfreal_noteq_omega_Ex Real_real)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2070
    thus "u N \<in> S" using A_eq by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2071
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2072
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2073
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2074
lemma real_Real_max:"real (Real x) = max x 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2075
  unfolding real_Real by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2076
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2077
lemma (in complete_lattice) SUPR_upper:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2078
  "x \<in> A \<Longrightarrow> f x \<le> SUPR A f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2079
  unfolding SUPR_def apply(rule Sup_upper) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2080
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2081
lemma (in complete_lattice) SUPR_subset:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2082
  assumes "A \<subseteq> B" shows "SUPR A f \<le> SUPR B f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2083
  apply(rule SUP_leI) apply(rule SUPR_upper) using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2084
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2085
lemma (in complete_lattice) SUPR_mono:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2086
  assumes "\<forall>a\<in>A. \<exists>b\<in>B. f b \<ge> f a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2087
  shows "SUPR A f \<le> SUPR B f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2088
  unfolding SUPR_def apply(rule Sup_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2089
  using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2090
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2091
lemma Sup_lim:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2092
  assumes "\<forall>n. b n \<in> s" "b ----> (a::pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2093
  shows "a \<le> Sup s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2094
proof(rule ccontr,unfold not_le)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2095
  assume as:"Sup s < a" hence om:"Sup s \<noteq> \<omega>" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2096
  have s:"s \<noteq> {}" using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2097
  { presume *:"\<forall>n. b n < a \<Longrightarrow> False"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2098
    show False apply(cases,rule *,assumption,unfold not_all not_less)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2099
    proof- case goal1 then guess n .. note n=this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2100
      thus False using complete_lattice_class.Sup_upper[OF assms(1)[rule_format,of n]]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2101
        using as by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2102
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2103
  } assume b:"\<forall>n. b n < a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2104
  show False
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2105
  proof(cases "a = \<omega>")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2106
    case False have *:"a - Sup s > 0" 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2107
      using False as by(auto simp: pinfreal_zero_le_diff)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2108
    have "(a - Sup s) / 2 \<le> a / 2" unfolding divide_pinfreal_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2109
      apply(rule mult_right_mono) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2110
    also have "... = Real (real (a / 2))" apply(rule Real_real'[THEN sym])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2111
      using False by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2112
    also have "... < Real (real a)" unfolding pinfreal_less using as False
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2113
      by(auto simp add: real_of_pinfreal_mult[THEN sym])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2114
    also have "... = a" apply(rule Real_real') using False by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2115
    finally have asup:"a > (a - Sup s) / 2" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2116
    have "\<exists>n. a - b n < (a - Sup s) / 2"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2117
    proof(rule ccontr,unfold not_ex not_less)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2118
      case goal1
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2119
      have "(a - Sup s) * Real (1 / 2)  > 0" 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2120
        using * by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2121
      hence "a - (a - Sup s) * Real (1 / 2) < a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2122
        apply-apply(rule pinfreal_minus_strict_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2123
        using False * by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2124
      hence *:"a \<in> {a - (a - Sup s) / 2<..}"using asup by auto 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2125
      note topological_tendstoD[OF assms(2) open_pinfreal_greaterThan,OF *]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2126
      from this[unfolded eventually_sequentially] guess n .. 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2127
      note n = this[rule_format,of n] 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2128
      have "b n + (a - Sup s) / 2 \<le> a" 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2129
        using add_right_mono[OF goal1[rule_format,of n],of "b n"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2130
        unfolding pinfreal_minus_plus[OF less_imp_le[OF b[rule_format]]]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2131
        by(auto simp: add_commute)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2132
      hence "b n \<le> a - (a - Sup s) / 2" unfolding pinfreal_le_minus_iff
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2133
        using asup by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2134
      hence "b n \<notin> {a - (a - Sup s) / 2<..}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2135
      thus False using n by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2136
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2137
    then guess n .. note n = this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2138
    have "Sup s < a - (a - Sup s) / 2"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2139
      using False as om by (cases a) (auto simp: pinfreal_noteq_omega_Ex field_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2140
    also have "... \<le> b n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2141
    proof- note add_right_mono[OF less_imp_le[OF n],of "b n"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2142
      note this[unfolded pinfreal_minus_plus[OF less_imp_le[OF b[rule_format]]]]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2143
      hence "a - (a - Sup s) / 2 \<le> (a - Sup s) / 2 + b n - (a - Sup s) / 2"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2144
        apply(rule pinfreal_minus_le_cancel_right) using asup by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2145
      also have "... = b n + (a - Sup s) / 2 - (a - Sup s) / 2" 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2146
        by(auto simp add: add_commute)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2147
      also have "... = b n" apply(subst pinfreal_cancel_plus_minus)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2148
      proof(rule ccontr,unfold not_not) case goal1
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2149
        show ?case using asup unfolding goal1 by auto 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2150
      qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2151
      finally show ?thesis .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2152
    qed     
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2153
    finally show False
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2154
      using complete_lattice_class.Sup_upper[OF assms(1)[rule_format,of n]] by auto  
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2155
  next case True
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2156
    from assms(2)[unfolded True Lim_omega_gt,rule_format,of "real (Sup s)"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2157
    guess N .. note N = this[rule_format,of N]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2158
    thus False using complete_lattice_class.Sup_upper[OF assms(1)[rule_format,of N]] 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2159
      unfolding Real_real using om by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2160
  qed qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2161
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2162
lemma less_SUP_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2163
  fixes a :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2164
  shows "(a < (SUP i:A. f i)) \<longleftrightarrow> (\<exists>x\<in>A. a < f x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2165
  unfolding SUPR_def less_Sup_iff by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2166
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2167
lemma Sup_mono_lim:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2168
  assumes "\<forall>a\<in>A. \<exists>b. \<forall>n. b n \<in> B \<and> b ----> (a::pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2169
  shows "Sup A \<le> Sup B"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2170
  unfolding Sup_le_iff apply(rule) apply(drule assms[rule_format]) apply safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2171
  apply(rule_tac b=b in Sup_lim) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2172
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2173
lemma pinfreal_less_add:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2174
  assumes "x \<noteq> \<omega>" "a < b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2175
  shows "x + a < x + b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2176
  using assms by (cases a, cases b, cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2177
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2178
lemma SUPR_lim:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2179
  assumes "\<forall>n. b n \<in> B" "(\<lambda>n. f (b n)) ----> (f a::pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2180
  shows "f a \<le> SUPR B f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2181
  unfolding SUPR_def apply(rule Sup_lim[of "\<lambda>n. f (b n)"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2182
  using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2183
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2184
lemma SUP_\<omega>_imp:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2185
  assumes "(SUP i. f i) = \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2186
  shows "\<exists>i. Real x < f i"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2187
proof (rule ccontr)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2188
  assume "\<not> ?thesis" hence "\<And>i. f i \<le> Real x" by (simp add: not_less)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2189
  hence "(SUP i. f i) \<le> Real x" unfolding SUP_le_iff by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2190
  with assms show False by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2191
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2192
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2193
lemma SUPR_mono_lim:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2194
  assumes "\<forall>a\<in>A. \<exists>b. \<forall>n. b n \<in> B \<and> (\<lambda>n. f (b n)) ----> (f a::pinfreal)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2195
  shows "SUPR A f \<le> SUPR B f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2196
  unfolding SUPR_def apply(rule Sup_mono_lim)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2197
  apply safe apply(drule assms[rule_format],safe)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2198
  apply(rule_tac x="\<lambda>n. f (b n)" in exI) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2199
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2200
lemma real_0_imp_eq_0:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2201
  assumes "x \<noteq> \<omega>" "real x = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2202
  shows "x = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2203
using assms by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2204
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2205
lemma SUPR_mono:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2206
  assumes "\<forall>a\<in>A. \<exists>b\<in>B. f b \<ge> f a"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2207
  shows "SUPR A f \<le> SUPR B f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2208
  unfolding SUPR_def apply(rule Sup_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2209
  using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2210
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2211
lemma less_add_Real:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2212
  fixes x :: real
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2213
  fixes a b :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2214
  assumes "x \<ge> 0" "a < b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2215
  shows "a + Real x < b + Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2216
using assms by (cases a, cases b) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2217
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2218
lemma le_add_Real:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2219
  fixes x :: real
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2220
  fixes a b :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2221
  assumes "x \<ge> 0" "a \<le> b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2222
  shows "a + Real x \<le> b + Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2223
using assms by (cases a, cases b) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2224
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2225
lemma le_imp_less_pinfreal:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2226
  fixes x :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2227
  assumes "x > 0" "a + x \<le> b" "a \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2228
  shows "a < b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2229
using assms by (cases x, cases a, cases b) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2230
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2231
lemma pinfreal_INF_minus:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2232
  fixes f :: "nat \<Rightarrow> pinfreal"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2233
  assumes "c \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2234
  shows "(INF i. c - f i) = c - (SUP i. f i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2235
proof (cases "SUP i. f i")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2236
  case infinite
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2237
  from `c \<noteq> \<omega>` obtain x where [simp]: "c = Real x" by (cases c) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2238
  from SUP_\<omega>_imp[OF infinite] obtain i where "Real x < f i" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2239
  have "(INF i. c - f i) \<le> c - f i"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2240
    by (auto intro!: complete_lattice_class.INF_leI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2241
  also have "\<dots> = 0" using `Real x < f i` by (auto simp: minus_pinfreal_eq)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2242
  finally show ?thesis using infinite by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2243
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2244
  case (preal r)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2245
  from `c \<noteq> \<omega>` obtain x where c: "c = Real x" by (cases c) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2246
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2247
  show ?thesis unfolding c
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2248
  proof (rule pinfreal_INFI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2249
    fix i have "f i \<le> (SUP i. f i)" by (rule le_SUPI) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2250
    thus "Real x - (SUP i. f i) \<le> Real x - f i" by (rule pinfreal_minus_le_cancel)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2251
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2252
    fix y assume *: "\<And>i. i \<in> UNIV \<Longrightarrow> y \<le> Real x - f i"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2253
    from this[of 0] obtain p where p: "y = Real p" "0 \<le> p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2254
      by (cases "f 0", cases y, auto split: split_if_asm)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2255
    hence "\<And>i. Real p \<le> Real x - f i" using * by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2256
    hence *: "\<And>i. Real x \<le> f i \<Longrightarrow> Real p = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2257
      "\<And>i. f i < Real x \<Longrightarrow> Real p + f i \<le> Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2258
      unfolding pinfreal_le_minus_iff by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2259
    show "y \<le> Real x - (SUP i. f i)" unfolding p pinfreal_le_minus_iff
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2260
    proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2261
      assume x_less: "Real x \<le> (SUP i. f i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2262
      show "Real p = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2263
      proof (rule ccontr)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2264
        assume "Real p \<noteq> 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2265
        hence "0 < Real p" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2266
        from Sup_close[OF this, of "range f"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2267
        obtain i where e: "(SUP i. f i) < f i + Real p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2268
          using preal unfolding SUPR_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2269
        hence "Real x \<le> f i + Real p" using x_less by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2270
        show False
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2271
        proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2272
          assume "\<forall>i. f i < Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2273
          hence "Real p + f i \<le> Real x" using * by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2274
          hence "f i + Real p \<le> (SUP i. f i)" using x_less by (auto simp: field_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2275
          thus False using e by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2276
        next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2277
          assume "\<not> (\<forall>i. f i < Real x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2278
          then obtain i where "Real x \<le> f i" by (auto simp: not_less)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2279
          from *(1)[OF this] show False using `Real p \<noteq> 0` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2280
        qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2281
      qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2282
    next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2283
      have "\<And>i. f i \<le> (SUP i. f i)" by (rule complete_lattice_class.le_SUPI) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2284
      also assume "(SUP i. f i) < Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2285
      finally have "\<And>i. f i < Real x" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2286
      hence *: "\<And>i. Real p + f i \<le> Real x" using * by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2287
      have "Real p \<le> Real x" using *[of 0] by (cases "f 0") (auto split: split_if_asm)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2288
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2289
      have SUP_eq: "(SUP i. f i) \<le> Real x - Real p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2290
      proof (rule SUP_leI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2291
        fix i show "f i \<le> Real x - Real p" unfolding pinfreal_le_minus_iff
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2292
        proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2293
          assume "Real x \<le> Real p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2294
          with *[of i] show "f i = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2295
            by (cases "f i") (auto split: split_if_asm)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2296
        next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2297
          assume "Real p < Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2298
          show "f i + Real p \<le> Real x" using * by (auto simp: field_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2299
        qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2300
      qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2301
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2302
      show "Real p + (SUP i. f i) \<le> Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2303
      proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2304
        assume "Real x \<le> Real p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2305
        with `Real p \<le> Real x` have [simp]: "Real p = Real x" by (rule antisym)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2306
        { fix i have "f i = 0" using *[of i] by (cases "f i") (auto split: split_if_asm) }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2307
        hence "(SUP i. f i) \<le> 0" by (auto intro!: SUP_leI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2308
        thus ?thesis by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2309
      next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2310
        assume "\<not> Real x \<le> Real p" hence "Real p < Real x" unfolding not_le .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2311
        with SUP_eq show ?thesis unfolding pinfreal_le_minus_iff by (auto simp: field_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2312
      qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2313
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2314
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2315
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2316
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2317
lemma pinfreal_SUP_minus:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2318
  fixes f :: "nat \<Rightarrow> pinfreal"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2319
  shows "(SUP i. c - f i) = c - (INF i. f i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2320
proof (rule pinfreal_SUPI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2321
  fix i have "(INF i. f i) \<le> f i" by (rule INF_leI) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2322
  thus "c - f i \<le> c - (INF i. f i)" by (rule pinfreal_minus_le_cancel)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2323
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2324
  fix y assume *: "\<And>i. i \<in> UNIV \<Longrightarrow> c - f i \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2325
  show "c - (INF i. f i) \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2326
  proof (cases y)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2327
    case (preal p)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2328
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2329
    show ?thesis unfolding pinfreal_minus_le_iff preal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2330
    proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2331
      assume INF_le_x: "(INF i. f i) \<le> c"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2332
      from * have *: "\<And>i. f i \<le> c \<Longrightarrow> c \<le> Real p + f i"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2333
        unfolding pinfreal_minus_le_iff preal by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2334
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2335
      have INF_eq: "c - Real p \<le> (INF i. f i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2336
      proof (rule le_INFI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2337
        fix i show "c - Real p \<le> f i" unfolding pinfreal_minus_le_iff
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2338
        proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2339
          assume "Real p \<le> c"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2340
          show "c \<le> f i + Real p"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2341
          proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2342
            assume "f i \<le> c" from *[OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2343
            show ?thesis by (simp add: field_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2344
          next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2345
            assume "\<not> f i \<le> c"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2346
            hence "c \<le> f i" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2347
            also have "\<dots> \<le> f i + Real p" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2348
            finally show ?thesis .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2349
          qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2350
        qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2351
      qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2352
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2353
      show "c \<le> Real p + (INF i. f i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2354
      proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2355
        assume "Real p \<le> c"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2356
        with INF_eq show ?thesis unfolding pinfreal_minus_le_iff by (auto simp: field_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2357
      next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2358
        assume "\<not> Real p \<le> c"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2359
        hence "c \<le> Real p" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2360
        also have "Real p \<le> Real p + (INF i. f i)" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2361
        finally show ?thesis .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2362
      qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2363
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2364
  qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2365
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2366
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2367
lemma pinfreal_le_minus_imp_0:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2368
  fixes a b :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2369
  shows "a \<le> a - b \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> a \<noteq> \<omega> \<Longrightarrow> b = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2370
  by (cases a, cases b, auto split: split_if_asm)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2371
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2372
lemma lim_INF_le_lim_SUP:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2373
  fixes f :: "nat \<Rightarrow> pinfreal"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2374
  shows "(SUP n. INF m. f (n + m)) \<le> (INF n. SUP m. f (n + m))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2375
proof (rule complete_lattice_class.SUP_leI, rule complete_lattice_class.le_INFI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2376
  fix i j show "(INF m. f (i + m)) \<le> (SUP m. f (j + m))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2377
  proof (cases rule: le_cases)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2378
    assume "i \<le> j"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2379
    have "(INF m. f (i + m)) \<le> f (i + (j - i))" by (rule INF_leI) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2380
    also have "\<dots> = f (j + 0)" using `i \<le> j` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2381
    also have "\<dots> \<le> (SUP m. f (j + m))" by (rule le_SUPI) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2382
    finally show ?thesis .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2383
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2384
    assume "j \<le> i"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2385
    have "(INF m. f (i + m)) \<le> f (i + 0)" by (rule INF_leI) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2386
    also have "\<dots> = f (j + (i - j))" using `j \<le> i` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2387
    also have "\<dots> \<le> (SUP m. f (j + m))" by (rule le_SUPI) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2388
    finally show ?thesis .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2389
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2390
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2391
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2392
lemma lim_INF_eq_lim_SUP:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2393
  fixes X :: "nat \<Rightarrow> real"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2394
  assumes "\<And>i. 0 \<le> X i" and "0 \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2395
  and lim_INF: "(SUP n. INF m. Real (X (n + m))) = Real x" (is "(SUP n. ?INF n) = _")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2396
  and lim_SUP: "(INF n. SUP m. Real (X (n + m))) = Real x" (is "(INF n. ?SUP n) = _")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2397
  shows "X ----> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2398
proof (rule LIMSEQ_I)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2399
  fix r :: real assume "0 < r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2400
  hence "0 \<le> r" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2401
  from Sup_close[of "Real r" "range ?INF"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2402
  obtain n where inf: "Real x < ?INF n + Real r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2403
    unfolding SUPR_def lim_INF[unfolded SUPR_def] using `0 < r` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2404
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2405
  from Inf_close[of "range ?SUP" "Real r"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2406
  obtain n' where sup: "?SUP n' < Real x + Real r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2407
    unfolding INFI_def lim_SUP[unfolded INFI_def] using `0 < r` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2408
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2409
  show "\<exists>N. \<forall>n\<ge>N. norm (X n - x) < r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2410
  proof (safe intro!: exI[of _ "max n n'"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2411
    fix m assume "max n n' \<le> m" hence "n \<le> m" "n' \<le> m" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2412
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2413
    note inf
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2414
    also have "?INF n + Real r \<le> Real (X (n + (m - n))) + Real r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2415
      by (rule le_add_Real, auto simp: `0 \<le> r` intro: INF_leI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2416
    finally have up: "x < X m + r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2417
      using `0 \<le> X m` `0 \<le> x` `0 \<le> r` `n \<le> m` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2418
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2419
    have "Real (X (n' + (m - n'))) \<le> ?SUP n'"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2420
      by (auto simp: `0 \<le> r` intro: le_SUPI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2421
    also note sup
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2422
    finally have down: "X m < x + r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2423
      using `0 \<le> X m` `0 \<le> x` `0 \<le> r` `n' \<le> m` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2424
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2425
    show "norm (X m - x) < r" using up down by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2426
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2427
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2428
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2429
lemma Sup_countable_SUPR:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2430
  assumes "Sup A \<noteq> \<omega>" "A \<noteq> {}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2431
  shows "\<exists> f::nat \<Rightarrow> pinfreal. range f \<subseteq> A \<and> Sup A = SUPR UNIV f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2432
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2433
  have "\<And>n. 0 < 1 / (of_nat n :: pinfreal)" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2434
  from Sup_close[OF this assms]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2435
  have "\<forall>n. \<exists>x. x \<in> A \<and> Sup A < x + 1 / of_nat n" by blast
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2436
  from choice[OF this] obtain f where "range f \<subseteq> A" and
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2437
    epsilon: "\<And>n. Sup A < f n + 1 / of_nat n" by blast
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2438
  have "SUPR UNIV f = Sup A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2439
  proof (rule pinfreal_SUPI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2440
    fix i show "f i \<le> Sup A" using `range f \<subseteq> A`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2441
      by (auto intro!: complete_lattice_class.Sup_upper)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2442
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2443
    fix y assume bound: "\<And>i. i \<in> UNIV \<Longrightarrow> f i \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2444
    show "Sup A \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2445
    proof (rule pinfreal_le_epsilon)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2446
      fix e :: pinfreal assume "0 < e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2447
      show "Sup A \<le> y + e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2448
      proof (cases e)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2449
        case (preal r)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2450
        hence "0 < r" using `0 < e` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2451
        then obtain n where *: "inverse (of_nat n) < r" "0 < n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2452
          using ex_inverse_of_nat_less by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2453
        have "Sup A \<le> f n + 1 / of_nat n" using epsilon[of n] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2454
        also have "1 / of_nat n \<le> e" using preal * by (auto simp: real_eq_of_nat)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2455
        with bound have "f n + 1 / of_nat n \<le> y + e" by (rule add_mono) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2456
        finally show "Sup A \<le> y + e" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2457
      qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2458
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2459
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2460
  with `range f \<subseteq> A` show ?thesis by (auto intro!: exI[of _ f])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2461
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2462
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2463
lemma SUPR_countable_SUPR:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2464
  assumes "SUPR A g \<noteq> \<omega>" "A \<noteq> {}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2465
  shows "\<exists> f::nat \<Rightarrow> pinfreal. range f \<subseteq> g`A \<and> SUPR A g = SUPR UNIV f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2466
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2467
  have "Sup (g`A) \<noteq> \<omega>" "g`A \<noteq> {}" using assms unfolding SUPR_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2468
  from Sup_countable_SUPR[OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2469
  show ?thesis unfolding SUPR_def .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2470
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2471
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2472
lemma pinfreal_setsum_subtractf:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2473
  assumes "\<And>i. i\<in>A \<Longrightarrow> g i \<le> f i" and "\<And>i. i\<in>A \<Longrightarrow> f i \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2474
  shows "(\<Sum>i\<in>A. f i - g i) = (\<Sum>i\<in>A. f i) - (\<Sum>i\<in>A. g i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2475
proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2476
  assume "finite A" from this assms show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2477
  proof induct
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2478
    case (insert x A)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2479
    hence hyp: "(\<Sum>i\<in>A. f i - g i) = (\<Sum>i\<in>A. f i) - (\<Sum>i\<in>A. g i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2480
      by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2481
    { fix i assume *: "i \<in> insert x A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2482
      hence "g i \<le> f i" using insert by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2483
      also have "f i < \<omega>" using * insert by (simp add: pinfreal_less_\<omega>)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2484
      finally have "g i \<noteq> \<omega>" by (simp add: pinfreal_less_\<omega>) }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2485
    hence "setsum g A \<noteq> \<omega>" "g x \<noteq> \<omega>" by (auto simp: setsum_\<omega>)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2486
    moreover have "setsum f A \<noteq> \<omega>" "f x \<noteq> \<omega>" using insert by (auto simp: setsum_\<omega>)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2487
    moreover have "g x \<le> f x" using insert by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2488
    moreover have "(\<Sum>i\<in>A. g i) \<le> (\<Sum>i\<in>A. f i)" using insert by (auto intro!: setsum_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2489
    ultimately show ?case using `finite A` `x \<notin> A` hyp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2490
      by (auto simp: pinfreal_noteq_omega_Ex)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2491
  qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2492
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2493
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2494
lemma real_of_pinfreal_diff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2495
  "y \<le> x \<Longrightarrow> x \<noteq> \<omega> \<Longrightarrow> real x - real y = real (x - y)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2496
  by (cases x, cases y) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2497
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2498
lemma psuminf_minus:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2499
  assumes ord: "\<And>i. g i \<le> f i" and fin: "psuminf g \<noteq> \<omega>" "psuminf f \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2500
  shows "(\<Sum>\<^isub>\<infinity> i. f i - g i) = psuminf f - psuminf g"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2501
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2502
  have [simp]: "\<And>i. f i \<noteq> \<omega>" using fin by (auto intro: psuminf_\<omega>)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2503
  from fin have "(\<lambda>x. real (f x)) sums real (\<Sum>\<^isub>\<infinity>x. f x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2504
    and "(\<lambda>x. real (g x)) sums real (\<Sum>\<^isub>\<infinity>x. g x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2505
    by (auto intro: psuminf_imp_suminf)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2506
  from sums_diff[OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2507
  have "(\<lambda>n. real (f n - g n)) sums (real ((\<Sum>\<^isub>\<infinity>x. f x) - (\<Sum>\<^isub>\<infinity>x. g x)))" using fin ord
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2508
    by (subst (asm) (1 2) real_of_pinfreal_diff) (auto simp: psuminf_\<omega> psuminf_le)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2509
  hence "(\<Sum>\<^isub>\<infinity> i. Real (real (f i - g i))) = Real (real ((\<Sum>\<^isub>\<infinity>x. f x) - (\<Sum>\<^isub>\<infinity>x. g x)))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2510
    by (rule suminf_imp_psuminf) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2511
  thus ?thesis using fin by (simp add: Real_real psuminf_\<omega>)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2512
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2513
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2514
lemma INF_eq_LIMSEQ:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2515
  assumes "mono (\<lambda>i. - f i)" and "\<And>n. 0 \<le> f n" and "0 \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2516
  shows "(INF n. Real (f n)) = Real x \<longleftrightarrow> f ----> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2517
proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2518
  assume x: "(INF n. Real (f n)) = Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2519
  { fix n
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2520
    have "Real x \<le> Real (f n)" using x[symmetric] by (auto intro: INF_leI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2521
    hence "x \<le> f n" using assms by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2522
    hence "\<bar>f n - x\<bar> = f n - x" by auto }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2523
  note abs_eq = this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2524
  show "f ----> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2525
  proof (rule LIMSEQ_I)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2526
    fix r :: real assume "0 < r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2527
    show "\<exists>no. \<forall>n\<ge>no. norm (f n - x) < r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2528
    proof (rule ccontr)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2529
      assume *: "\<not> ?thesis"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2530
      { fix N
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2531
        from * obtain n where *: "N \<le> n" "r \<le> f n - x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2532
          using abs_eq by (auto simp: not_less)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2533
        hence "x + r \<le> f n" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2534
        also have "f n \<le> f N" using `mono (\<lambda>i. - f i)` * by (auto dest: monoD)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2535
        finally have "Real (x + r) \<le> Real (f N)" using `0 \<le> f N` by auto }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2536
      hence "Real x < Real (x + r)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2537
        and "Real (x + r) \<le> (INF n. Real (f n))" using `0 < r` `0 \<le> x` by (auto intro: le_INFI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2538
      hence "Real x < (INF n. Real (f n))" by (rule less_le_trans)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2539
      thus False using x by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2540
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2541
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2542
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2543
  assume "f ----> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2544
  show "(INF n. Real (f n)) = Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2545
  proof (rule pinfreal_INFI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2546
    fix n
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2547
    from decseq_le[OF _ `f ----> x`] assms
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2548
    show "Real x \<le> Real (f n)" unfolding decseq_eq_incseq incseq_mono by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2549
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2550
    fix y assume *: "\<And>n. n\<in>UNIV \<Longrightarrow> y \<le> Real (f n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2551
    thus "y \<le> Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2552
    proof (cases y)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2553
      case (preal r)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2554
      with * have "\<exists>N. \<forall>n\<ge>N. r \<le> f n" using assms by fastsimp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2555
      from LIMSEQ_le_const[OF `f ----> x` this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2556
      show "y \<le> Real x" using `0 \<le> x` preal by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2557
    qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2558
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2559
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2560
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2561
lemma INFI_bound:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2562
  assumes "\<forall>N. x \<le> f N"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2563
  shows "x \<le> (INF n. f n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2564
  using assms by (simp add: INFI_def le_Inf_iff)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2565
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2566
lemma INF_mono:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2567
  assumes "\<And>n. f (N n) \<le> g n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2568
  shows "(INF n. f n) \<le> (INF n. g n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2569
proof (safe intro!: INFI_bound)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2570
  fix n
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2571
  have "(INF n. f n) \<le> f (N n)" by (auto intro!: INF_leI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2572
  also note assms[of n]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2573
  finally show "(INF n. f n) \<le> g n" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2574
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2575
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2576
lemma INFI_fun_expand: "(INF y:A. f y) = (\<lambda>x. INF y:A. f y x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2577
  unfolding INFI_def expand_fun_eq Inf_fun_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2578
  by (auto intro!: arg_cong[where f=Inf])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2579
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2580
lemma LIMSEQ_imp_lim_INF:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2581
  assumes pos: "\<And>i. 0 \<le> X i" and lim: "X ----> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2582
  shows "(SUP n. INF m. Real (X (n + m))) = Real x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2583
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2584
  have "0 \<le> x" using assms by (auto intro!: LIMSEQ_le_const)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2585
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2586
  have "\<And>n. (INF m. Real (X (n + m))) \<le> Real (X (n + 0))" by (rule INF_leI) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2587
  also have "\<And>n. Real (X (n + 0)) < \<omega>" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2588
  finally have "\<forall>n. \<exists>r\<ge>0. (INF m. Real (X (n + m))) = Real r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2589
    by (auto simp: pinfreal_less_\<omega> pinfreal_noteq_omega_Ex)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2590
  from choice[OF this] obtain r where r: "\<And>n. (INF m. Real (X (n + m))) = Real (r n)" "\<And>n. 0 \<le> r n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2591
    by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2592
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2593
  show ?thesis unfolding r
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2594
  proof (subst SUP_eq_LIMSEQ)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2595
    show "mono r" unfolding mono_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2596
    proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2597
      fix x y :: nat assume "x \<le> y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2598
      have "Real (r x) \<le> Real (r y)" unfolding r(1)[symmetric] using pos
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2599
      proof (safe intro!: INF_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2600
        fix m have "x + (m + y - x) = y + m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2601
          using `x \<le> y` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2602
        thus "Real (X (x + (m + y - x))) \<le> Real (X (y + m))" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2603
      qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2604
      thus "r x \<le> r y" using r by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2605
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2606
    show "\<And>n. 0 \<le> r n" by fact
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2607
    show "0 \<le> x" by fact
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2608
    show "r ----> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2609
    proof (rule LIMSEQ_I)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2610
      fix e :: real assume "0 < e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2611
      hence "0 < e/2" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2612
      from LIMSEQ_D[OF lim this] obtain N where *: "\<And>n. N \<le> n \<Longrightarrow> \<bar>X n - x\<bar> < e/2"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2613
        by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2614
      show "\<exists>N. \<forall>n\<ge>N. norm (r n - x) < e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2615
      proof (safe intro!: exI[of _ N])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2616
        fix n assume "N \<le> n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2617
        show "norm (r n - x) < e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2618
        proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2619
          assume "r n < x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2620
          have "x - r n \<le> e/2"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2621
          proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2622
            assume e: "e/2 \<le> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2623
            have "Real (x - e/2) \<le> Real (r n)" unfolding r(1)[symmetric]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2624
            proof (rule le_INFI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2625
              fix m show "Real (x - e / 2) \<le> Real (X (n + m))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2626
                using *[of "n + m"] `N \<le> n`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2627
                using pos by (auto simp: field_simps abs_real_def split: split_if_asm)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2628
            qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2629
            with e show ?thesis using pos `0 \<le> x` r(2) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2630
          next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2631
            assume "\<not> e/2 \<le> x" hence "x - e/2 < 0" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2632
            with `0 \<le> r n` show ?thesis by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2633
          qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2634
          with `r n < x` show ?thesis by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2635
        next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2636
          assume e: "\<not> r n < x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2637
          have "Real (r n) \<le> Real (X (n + 0))" unfolding r(1)[symmetric]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2638
            by (rule INF_leI) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2639
          hence "r n - x \<le> X n - x" using r pos by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2640
          also have "\<dots> < e/2" using *[OF `N \<le> n`] by (auto simp: field_simps abs_real_def split: split_if_asm)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2641
          finally have "r n - x < e" using `0 < e` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2642
          with e show ?thesis by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2643
        qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2644
      qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2645
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2646
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2647
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2648
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2649
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2650
lemma real_of_pinfreal_strict_mono_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2651
  "real a < real b \<longleftrightarrow> (b \<noteq> \<omega> \<and> ((a = \<omega> \<and> 0 < b) \<or> (a < b)))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2652
proof (cases a)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2653
  case infinite thus ?thesis by (cases b) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2654
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2655
  case preal thus ?thesis by (cases b) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2656
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2657
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2658
lemma real_of_pinfreal_mono_iff:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2659
  "real a \<le> real b \<longleftrightarrow> (a = \<omega> \<or> (b \<noteq> \<omega> \<and> a \<le> b) \<or> (b = \<omega> \<and> a = 0))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2660
proof (cases a)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2661
  case infinite thus ?thesis by (cases b) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2662
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2663
  case preal thus ?thesis by (cases b)  auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2664
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2665
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2666
lemma ex_pinfreal_inverse_of_nat_Suc_less:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2667
  fixes e :: pinfreal assumes "0 < e" shows "\<exists>n. inverse (of_nat (Suc n)) < e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2668
proof (cases e)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2669
  case (preal r)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2670
  with `0 < e` ex_inverse_of_nat_Suc_less[of r]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2671
  obtain n where "inverse (of_nat (Suc n)) < r" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2672
  with preal show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2673
    by (auto simp: real_eq_of_nat[symmetric])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2674
qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2675
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2676
lemma Lim_eq_Sup_mono:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2677
  fixes u :: "nat \<Rightarrow> pinfreal" assumes "mono u"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2678
  shows "u ----> (SUP i. u i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2679
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2680
  from lim_pinfreal_increasing[of u] `mono u`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2681
  obtain l where l: "u ----> l" unfolding mono_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2682
  from SUP_Lim_pinfreal[OF _ this] `mono u`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2683
  have "(SUP i. u i) = l" unfolding mono_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2684
  with l show ?thesis by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2685
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2686
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2687
lemma isotone_Lim:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2688
  fixes x :: pinfreal assumes "u \<up> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2689
  shows "u ----> x" (is ?lim) and "mono u" (is ?mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2690
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2691
  show ?mono using assms unfolding mono_iff_le_Suc isoton_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2692
  from Lim_eq_Sup_mono[OF this] `u \<up> x`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2693
  show ?lim unfolding isoton_def by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2694
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2695
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2696
lemma isoton_iff_Lim_mono:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2697
  fixes u :: "nat \<Rightarrow> pinfreal"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2698
  shows "u \<up> x \<longleftrightarrow> (mono u \<and> u ----> x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2699
proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2700
  assume "mono u" and x: "u ----> x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2701
  with SUP_Lim_pinfreal[OF _ x]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2702
  show "u \<up> x" unfolding isoton_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2703
    using `mono u`[unfolded mono_def]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2704
    using `mono u`[unfolded mono_iff_le_Suc]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2705
    by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2706
qed (auto dest: isotone_Lim)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2707
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2708
lemma pinfreal_inverse_inverse[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2709
  fixes x :: pinfreal
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2710
  shows "inverse (inverse x) = x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2711
  by (cases x) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2712
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2713
lemma atLeastAtMost_omega_eq_atLeast:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2714
  shows "{a .. \<omega>} = {a ..}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2715
by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2716
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2717
lemma atLeast0AtMost_eq_atMost: "{0 :: pinfreal .. a} = {.. a}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2718
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2719
lemma greaterThan_omega_Empty: "{\<omega> <..} = {}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2720
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2721
lemma lessThan_0_Empty: "{..< 0 :: pinfreal} = {}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2722
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2723
end