src/HOL/Probability/Lebesgue_Integration.thy
author immler
Tue, 18 Mar 2014 10:12:57 +0100
changeset 56188 0268784f60da
parent 56166 9a241bc276cd
child 56193 c726ecfb22b6
permissions -rw-r--r--
use cbox to relax class constraints
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42067
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     1
(*  Title:      HOL/Probability/Lebesgue_Integration.thy
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     2
    Author:     Johannes Hölzl, TU München
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     3
    Author:     Armin Heller, TU München
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     4
*)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
     5
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     6
header {*Lebesgue Integration*}
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     7
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
     8
theory Lebesgue_Integration
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
     9
  imports Measure_Space Borel_Space
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    10
begin
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    11
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    12
lemma tendsto_real_max:
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    13
  fixes x y :: real
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    14
  assumes "(X ---> x) net"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    15
  assumes "(Y ---> y) net"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    16
  shows "((\<lambda>x. max (X x) (Y x)) ---> max x y) net"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    17
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    18
  have *: "\<And>x y :: real. max x y = y + ((x - y) + norm (x - y)) / 2"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    19
    by (auto split: split_max simp: field_simps)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    20
  show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    21
    unfolding *
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    22
    by (intro tendsto_add assms tendsto_divide tendsto_norm tendsto_diff) auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    23
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    24
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    25
lemma measurable_sets2[intro]:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    26
  assumes "f \<in> measurable M M'" "g \<in> measurable M M''"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    27
  and "A \<in> sets M'" "B \<in> sets M''"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    28
  shows "f -` A \<inter> g -` B \<inter> space M \<in> sets M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    29
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    30
  have "f -` A \<inter> g -` B \<inter> space M = (f -` A \<inter> space M) \<inter> (g -` B \<inter> space M)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    31
    by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    32
  then show ?thesis using assms by (auto intro: measurable_sets)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    33
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    34
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    35
section "Simple function"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    36
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    37
text {*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    38
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    39
Our simple functions are not restricted to positive real numbers. Instead
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    40
they are just functions with a finite range and are measurable when singleton
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    41
sets are measurable.
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    42
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    43
*}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    44
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
    45
definition "simple_function M g \<longleftrightarrow>
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    46
    finite (g ` space M) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    47
    (\<forall>x \<in> g ` space M. g -` {x} \<inter> space M \<in> sets M)"
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    48
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    49
lemma simple_functionD:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
    50
  assumes "simple_function M g"
40875
9a9d33f6fb46 generalized simple_functionD
hoelzl
parents: 40873
diff changeset
    51
  shows "finite (g ` space M)" and "g -` X \<inter> space M \<in> sets M"
40871
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
    52
proof -
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
    53
  show "finite (g ` space M)"
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
    54
    using assms unfolding simple_function_def by auto
40875
9a9d33f6fb46 generalized simple_functionD
hoelzl
parents: 40873
diff changeset
    55
  have "g -` X \<inter> space M = g -` (X \<inter> g`space M) \<inter> space M" by auto
9a9d33f6fb46 generalized simple_functionD
hoelzl
parents: 40873
diff changeset
    56
  also have "\<dots> = (\<Union>x\<in>X \<inter> g`space M. g-`{x} \<inter> space M)" by auto
9a9d33f6fb46 generalized simple_functionD
hoelzl
parents: 40873
diff changeset
    57
  finally show "g -` X \<inter> space M \<in> sets M" using assms
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
    58
    by (auto simp del: UN_simps simp: simple_function_def)
40871
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
    59
qed
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    60
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    61
lemma simple_function_measurable2[intro]:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    62
  assumes "simple_function M f" "simple_function M g"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    63
  shows "f -` A \<inter> g -` B \<inter> space M \<in> sets M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    64
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    65
  have "f -` A \<inter> g -` B \<inter> space M = (f -` A \<inter> space M) \<inter> (g -` B \<inter> space M)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    66
    by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    67
  then show ?thesis using assms[THEN simple_functionD(2)] by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    68
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    69
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    70
lemma simple_function_indicator_representation:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
    71
  fixes f ::"'a \<Rightarrow> ereal"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
    72
  assumes f: "simple_function M f" and x: "x \<in> space M"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    73
  shows "f x = (\<Sum>y \<in> f ` space M. y * indicator (f -` {y} \<inter> space M) x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    74
  (is "?l = ?r")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    75
proof -
38705
aaee86c0e237 moved generic lemmas in Probability to HOL
hoelzl
parents: 38656
diff changeset
    76
  have "?r = (\<Sum>y \<in> f ` space M.
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    77
    (if y = f x then y * indicator (f -` {y} \<inter> space M) x else 0))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    78
    by (auto intro!: setsum_cong2)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    79
  also have "... =  f x *  indicator (f -` {f x} \<inter> space M) x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    80
    using assms by (auto dest: simple_functionD simp: setsum_delta)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    81
  also have "... = f x" using x by (auto simp: indicator_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    82
  finally show ?thesis by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    83
qed
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    84
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    85
lemma simple_function_notspace:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
    86
  "simple_function M (\<lambda>x. h x * indicator (- space M) x::ereal)" (is "simple_function M ?h")
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
    87
proof -
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    88
  have "?h ` space M \<subseteq> {0}" unfolding indicator_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    89
  hence [simp, intro]: "finite (?h ` space M)" by (auto intro: finite_subset)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    90
  have "?h -` {0} \<inter> space M = space M" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    91
  thus ?thesis unfolding simple_function_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    92
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    93
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    94
lemma simple_function_cong:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    95
  assumes "\<And>t. t \<in> space M \<Longrightarrow> f t = g t"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
    96
  shows "simple_function M f \<longleftrightarrow> simple_function M g"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    97
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    98
  have "f ` space M = g ` space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    99
    "\<And>x. f -` {x} \<inter> space M = g -` {x} \<inter> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   100
    using assms by (auto intro!: image_eqI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   101
  thus ?thesis unfolding simple_function_def using assms by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   102
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   103
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   104
lemma simple_function_cong_algebra:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   105
  assumes "sets N = sets M" "space N = space M"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   106
  shows "simple_function M f \<longleftrightarrow> simple_function N f"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   107
  unfolding simple_function_def assms ..
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   108
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   109
lemma borel_measurable_simple_function[measurable_dest]:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   110
  assumes "simple_function M f"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   111
  shows "f \<in> borel_measurable M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   112
proof (rule borel_measurableI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   113
  fix S
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   114
  let ?I = "f ` (f -` S \<inter> space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   115
  have *: "(\<Union>x\<in>?I. f -` {x} \<inter> space M) = f -` S \<inter> space M" (is "?U = _") by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   116
  have "finite ?I"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   117
    using assms unfolding simple_function_def
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   118
    using finite_subset[of "f ` (f -` S \<inter> space M)" "f ` space M"] by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   119
  hence "?U \<in> sets M"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   120
    apply (rule sets.finite_UN)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   121
    using assms unfolding simple_function_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   122
  thus "f -` S \<inter> space M \<in> sets M" unfolding * .
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
   123
qed
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
   124
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   125
lemma simple_function_borel_measurable:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   126
  fixes f :: "'a \<Rightarrow> 'x::{t2_space}"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   127
  assumes "f \<in> borel_measurable M" and "finite (f ` space M)"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   128
  shows "simple_function M f"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   129
  using assms unfolding simple_function_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   130
  by (auto intro: borel_measurable_vimage)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   131
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   132
lemma simple_function_eq_borel_measurable:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   133
  fixes f :: "'a \<Rightarrow> ereal"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   134
  shows "simple_function M f \<longleftrightarrow> finite (f`space M) \<and> f \<in> borel_measurable M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   135
  using simple_function_borel_measurable[of f] borel_measurable_simple_function[of M f]
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44666
diff changeset
   136
  by (fastforce simp: simple_function_def)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   137
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   138
lemma simple_function_const[intro, simp]:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   139
  "simple_function M (\<lambda>x. c)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   140
  by (auto intro: finite_subset simp: simple_function_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   141
lemma simple_function_compose[intro, simp]:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   142
  assumes "simple_function M f"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   143
  shows "simple_function M (g \<circ> f)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   144
  unfolding simple_function_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   145
proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   146
  show "finite ((g \<circ> f) ` space M)"
56154
f0a927235162 more complete set of lemmas wrt. image and composition
haftmann
parents: 54611
diff changeset
   147
    using assms unfolding simple_function_def by (auto simp: image_comp [symmetric])
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   148
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   149
  fix x assume "x \<in> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   150
  let ?G = "g -` {g (f x)} \<inter> (f`space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   151
  have *: "(g \<circ> f) -` {(g \<circ> f) x} \<inter> space M =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   152
    (\<Union>x\<in>?G. f -` {x} \<inter> space M)" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   153
  show "(g \<circ> f) -` {(g \<circ> f) x} \<inter> space M \<in> sets M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   154
    using assms unfolding simple_function_def *
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   155
    by (rule_tac sets.finite_UN) auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   156
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   157
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   158
lemma simple_function_indicator[intro, simp]:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   159
  assumes "A \<in> sets M"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   160
  shows "simple_function M (indicator A)"
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
   161
proof -
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   162
  have "indicator A ` space M \<subseteq> {0, 1}" (is "?S \<subseteq> _")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   163
    by (auto simp: indicator_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   164
  hence "finite ?S" by (rule finite_subset) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   165
  moreover have "- A \<inter> space M = space M - A" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   166
  ultimately show ?thesis unfolding simple_function_def
46905
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 46884
diff changeset
   167
    using assms by (auto simp: indicator_def [abs_def])
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
   168
qed
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
   169
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   170
lemma simple_function_Pair[intro, simp]:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   171
  assumes "simple_function M f"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   172
  assumes "simple_function M g"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   173
  shows "simple_function M (\<lambda>x. (f x, g x))" (is "simple_function M ?p")
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   174
  unfolding simple_function_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   175
proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   176
  show "finite (?p ` space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   177
    using assms unfolding simple_function_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   178
    by (rule_tac finite_subset[of _ "f`space M \<times> g`space M"]) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   179
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   180
  fix x assume "x \<in> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   181
  have "(\<lambda>x. (f x, g x)) -` {(f x, g x)} \<inter> space M =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   182
      (f -` {f x} \<inter> space M) \<inter> (g -` {g x} \<inter> space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   183
    by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   184
  with `x \<in> space M` show "(\<lambda>x. (f x, g x)) -` {(f x, g x)} \<inter> space M \<in> sets M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   185
    using assms unfolding simple_function_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   186
qed
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
   187
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   188
lemma simple_function_compose1:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   189
  assumes "simple_function M f"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   190
  shows "simple_function M (\<lambda>x. g (f x))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   191
  using simple_function_compose[OF assms, of g]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   192
  by (simp add: comp_def)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   193
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   194
lemma simple_function_compose2:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   195
  assumes "simple_function M f" and "simple_function M g"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   196
  shows "simple_function M (\<lambda>x. h (f x) (g x))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   197
proof -
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   198
  have "simple_function M ((\<lambda>(x, y). h x y) \<circ> (\<lambda>x. (f x, g x)))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   199
    using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   200
  thus ?thesis by (simp_all add: comp_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   201
qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   202
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   203
lemmas simple_function_add[intro, simp] = simple_function_compose2[where h="op +"]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   204
  and simple_function_diff[intro, simp] = simple_function_compose2[where h="op -"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   205
  and simple_function_uminus[intro, simp] = simple_function_compose[where g="uminus"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   206
  and simple_function_mult[intro, simp] = simple_function_compose2[where h="op *"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   207
  and simple_function_div[intro, simp] = simple_function_compose2[where h="op /"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   208
  and simple_function_inverse[intro, simp] = simple_function_compose[where g="inverse"]
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   209
  and simple_function_max[intro, simp] = simple_function_compose2[where h=max]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   210
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   211
lemma simple_function_setsum[intro, simp]:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   212
  assumes "\<And>i. i \<in> P \<Longrightarrow> simple_function M (f i)"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   213
  shows "simple_function M (\<lambda>x. \<Sum>i\<in>P. f i x)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   214
proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   215
  assume "finite P" from this assms show ?thesis by induct auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   216
qed auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   217
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   218
lemma
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   219
  fixes f g :: "'a \<Rightarrow> real" assumes sf: "simple_function M f"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   220
  shows simple_function_ereal[intro, simp]: "simple_function M (\<lambda>x. ereal (f x))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   221
  by (auto intro!: simple_function_compose1[OF sf])
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   222
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   223
lemma
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   224
  fixes f g :: "'a \<Rightarrow> nat" assumes sf: "simple_function M f"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   225
  shows simple_function_real_of_nat[intro, simp]: "simple_function M (\<lambda>x. real (f x))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   226
  by (auto intro!: simple_function_compose1[OF sf])
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   227
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   228
lemma borel_measurable_implies_simple_function_sequence:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   229
  fixes u :: "'a \<Rightarrow> ereal"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   230
  assumes u: "u \<in> borel_measurable M"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   231
  shows "\<exists>f. incseq f \<and> (\<forall>i. \<infinity> \<notin> range (f i) \<and> simple_function M (f i)) \<and>
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   232
             (\<forall>x. (SUP i. f i x) = max 0 (u x)) \<and> (\<forall>i x. 0 \<le> f i x)"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   233
proof -
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   234
  def f \<equiv> "\<lambda>x i. if real i \<le> u x then i * 2 ^ i else natfloor (real (u x) * 2 ^ i)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   235
  { fix x j have "f x j \<le> j * 2 ^ j" unfolding f_def
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   236
    proof (split split_if, intro conjI impI)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   237
      assume "\<not> real j \<le> u x"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   238
      then have "natfloor (real (u x) * 2 ^ j) \<le> natfloor (j * 2 ^ j)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   239
         by (cases "u x") (auto intro!: natfloor_mono simp: mult_nonneg_nonneg)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   240
      moreover have "real (natfloor (j * 2 ^ j)) \<le> j * 2^j"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   241
        by (intro real_natfloor_le) (auto simp: mult_nonneg_nonneg)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   242
      ultimately show "natfloor (real (u x) * 2 ^ j) \<le> j * 2 ^ j"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   243
        unfolding real_of_nat_le_iff by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   244
    qed auto }
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   245
  note f_upper = this
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   246
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   247
  have real_f:
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   248
    "\<And>i x. real (f x i) = (if real i \<le> u x then i * 2 ^ i else real (natfloor (real (u x) * 2 ^ i)))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   249
    unfolding f_def by auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   250
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   251
  let ?g = "\<lambda>j x. real (f x j) / 2^j :: ereal"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   252
  show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   253
  proof (intro exI[of _ ?g] conjI allI ballI)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   254
    fix i
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   255
    have "simple_function M (\<lambda>x. real (f x i))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   256
    proof (intro simple_function_borel_measurable)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   257
      show "(\<lambda>x. real (f x i)) \<in> borel_measurable M"
50021
d96a3f468203 add support for function application to measurability prover
hoelzl
parents: 50003
diff changeset
   258
        using u by (auto simp: real_f)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   259
      have "(\<lambda>x. real (f x i))`space M \<subseteq> real`{..i*2^i}"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   260
        using f_upper[of _ i] by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   261
      then show "finite ((\<lambda>x. real (f x i))`space M)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   262
        by (rule finite_subset) auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   263
    qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   264
    then show "simple_function M (?g i)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   265
      by (auto intro: simple_function_ereal simple_function_div)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   266
  next
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   267
    show "incseq ?g"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   268
    proof (intro incseq_ereal incseq_SucI le_funI)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   269
      fix x and i :: nat
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   270
      have "f x i * 2 \<le> f x (Suc i)" unfolding f_def
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   271
      proof ((split split_if)+, intro conjI impI)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   272
        assume "ereal (real i) \<le> u x" "\<not> ereal (real (Suc i)) \<le> u x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   273
        then show "i * 2 ^ i * 2 \<le> natfloor (real (u x) * 2 ^ Suc i)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   274
          by (cases "u x") (auto intro!: le_natfloor)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   275
      next
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   276
        assume "\<not> ereal (real i) \<le> u x" "ereal (real (Suc i)) \<le> u x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   277
        then show "natfloor (real (u x) * 2 ^ i) * 2 \<le> Suc i * 2 ^ Suc i"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   278
          by (cases "u x") auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   279
      next
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   280
        assume "\<not> ereal (real i) \<le> u x" "\<not> ereal (real (Suc i)) \<le> u x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   281
        have "natfloor (real (u x) * 2 ^ i) * 2 = natfloor (real (u x) * 2 ^ i) * natfloor 2"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   282
          by simp
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   283
        also have "\<dots> \<le> natfloor (real (u x) * 2 ^ i * 2)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   284
        proof cases
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   285
          assume "0 \<le> u x" then show ?thesis
46671
3a40ea076230 removing unnecessary assumptions in RComplete;
bulwahn
parents: 45342
diff changeset
   286
            by (intro le_mult_natfloor) 
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   287
        next
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   288
          assume "\<not> 0 \<le> u x" then show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   289
            by (cases "u x") (auto simp: natfloor_neg mult_nonpos_nonneg)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   290
        qed
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   291
        also have "\<dots> = natfloor (real (u x) * 2 ^ Suc i)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   292
          by (simp add: ac_simps)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   293
        finally show "natfloor (real (u x) * 2 ^ i) * 2 \<le> natfloor (real (u x) * 2 ^ Suc i)" .
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   294
      qed simp
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   295
      then show "?g i x \<le> ?g (Suc i) x"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   296
        by (auto simp: field_simps)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   297
    qed
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   298
  next
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   299
    fix x show "(SUP i. ?g i x) = max 0 (u x)"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50384
diff changeset
   300
    proof (rule SUP_eqI)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   301
      fix i show "?g i x \<le> max 0 (u x)" unfolding max_def f_def
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   302
        by (cases "u x") (auto simp: field_simps real_natfloor_le natfloor_neg
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   303
                                     mult_nonpos_nonneg mult_nonneg_nonneg)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   304
    next
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   305
      fix y assume *: "\<And>i. i \<in> UNIV \<Longrightarrow> ?g i x \<le> y"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   306
      have "\<And>i. 0 \<le> ?g i x" by (auto simp: divide_nonneg_pos)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   307
      from order_trans[OF this *] have "0 \<le> y" by simp
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   308
      show "max 0 (u x) \<le> y"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   309
      proof (cases y)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   310
        case (real r)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   311
        with * have *: "\<And>i. f x i \<le> r * 2^i" by (auto simp: divide_le_eq)
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44568
diff changeset
   312
        from reals_Archimedean2[of r] * have "u x \<noteq> \<infinity>" by (auto simp: f_def) (metis less_le_not_le)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   313
        then have "\<exists>p. max 0 (u x) = ereal p \<and> 0 \<le> p" by (cases "u x") (auto simp: max_def)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   314
        then guess p .. note ux = this
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44568
diff changeset
   315
        obtain m :: nat where m: "p < real m" using reals_Archimedean2 ..
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   316
        have "p \<le> r"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   317
        proof (rule ccontr)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   318
          assume "\<not> p \<le> r"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   319
          with LIMSEQ_inverse_realpow_zero[unfolded LIMSEQ_iff, rule_format, of 2 "p - r"]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   320
          obtain N where "\<forall>n\<ge>N. r * 2^n < p * 2^n - 1" by (auto simp: inverse_eq_divide field_simps)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   321
          then have "r * 2^max N m < p * 2^max N m - 1" by simp
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   322
          moreover
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   323
          have "real (natfloor (p * 2 ^ max N m)) \<le> r * 2 ^ max N m"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   324
            using *[of "max N m"] m unfolding real_f using ux
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   325
            by (cases "0 \<le> u x") (simp_all add: max_def mult_nonneg_nonneg split: split_if_asm)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   326
          then have "p * 2 ^ max N m - 1 < r * 2 ^ max N m"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   327
            by (metis real_natfloor_gt_diff_one less_le_trans)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   328
          ultimately show False by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   329
        qed
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   330
        then show "max 0 (u x) \<le> y" using real ux by simp
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   331
      qed (insert `0 \<le> y`, auto)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   332
    qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   333
  qed (auto simp: divide_nonneg_pos)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   334
qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   335
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   336
lemma borel_measurable_implies_simple_function_sequence':
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   337
  fixes u :: "'a \<Rightarrow> ereal"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   338
  assumes u: "u \<in> borel_measurable M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   339
  obtains f where "\<And>i. simple_function M (f i)" "incseq f" "\<And>i. \<infinity> \<notin> range (f i)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   340
    "\<And>x. (SUP i. f i x) = max 0 (u x)" "\<And>i x. 0 \<le> f i x"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   341
  using borel_measurable_implies_simple_function_sequence[OF u] by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   342
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   343
lemma simple_function_induct[consumes 1, case_names cong set mult add, induct set: simple_function]:
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   344
  fixes u :: "'a \<Rightarrow> ereal"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   345
  assumes u: "simple_function M u"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   346
  assumes cong: "\<And>f g. simple_function M f \<Longrightarrow> simple_function M g \<Longrightarrow> (AE x in M. f x = g x) \<Longrightarrow> P f \<Longrightarrow> P g"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   347
  assumes set: "\<And>A. A \<in> sets M \<Longrightarrow> P (indicator A)"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   348
  assumes mult: "\<And>u c. P u \<Longrightarrow> P (\<lambda>x. c * u x)"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   349
  assumes add: "\<And>u v. P u \<Longrightarrow> P v \<Longrightarrow> P (\<lambda>x. v x + u x)"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   350
  shows "P u"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   351
proof (rule cong)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   352
  from AE_space show "AE x in M. (\<Sum>y\<in>u ` space M. y * indicator (u -` {y} \<inter> space M) x) = u x"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   353
  proof eventually_elim
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   354
    fix x assume x: "x \<in> space M"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   355
    from simple_function_indicator_representation[OF u x]
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   356
    show "(\<Sum>y\<in>u ` space M. y * indicator (u -` {y} \<inter> space M) x) = u x" ..
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   357
  qed
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   358
next
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   359
  from u have "finite (u ` space M)"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   360
    unfolding simple_function_def by auto
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   361
  then show "P (\<lambda>x. \<Sum>y\<in>u ` space M. y * indicator (u -` {y} \<inter> space M) x)"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   362
  proof induct
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   363
    case empty show ?case
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   364
      using set[of "{}"] by (simp add: indicator_def[abs_def])
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   365
  qed (auto intro!: add mult set simple_functionD u)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   366
next
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   367
  show "simple_function M (\<lambda>x. (\<Sum>y\<in>u ` space M. y * indicator (u -` {y} \<inter> space M) x))"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   368
    apply (subst simple_function_cong)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   369
    apply (rule simple_function_indicator_representation[symmetric])
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   370
    apply (auto intro: u)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   371
    done
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   372
qed fact
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   373
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   374
lemma simple_function_induct_nn[consumes 2, case_names cong set mult add]:
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   375
  fixes u :: "'a \<Rightarrow> ereal"
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   376
  assumes u: "simple_function M u" and nn: "\<And>x. 0 \<le> u x"
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   377
  assumes cong: "\<And>f g. simple_function M f \<Longrightarrow> simple_function M g \<Longrightarrow> (\<And>x. x \<in> space M \<Longrightarrow> f x = g x) \<Longrightarrow> P f \<Longrightarrow> P g"
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   378
  assumes set: "\<And>A. A \<in> sets M \<Longrightarrow> P (indicator A)"
49797
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
   379
  assumes mult: "\<And>u c. 0 \<le> c \<Longrightarrow> simple_function M u \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> P (\<lambda>x. c * u x)"
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
   380
  assumes add: "\<And>u v. simple_function M u \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> simple_function M v \<Longrightarrow> (\<And>x. 0 \<le> v x) \<Longrightarrow> P v \<Longrightarrow> P (\<lambda>x. v x + u x)"
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   381
  shows "P u"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   382
proof -
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   383
  show ?thesis
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   384
  proof (rule cong)
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   385
    fix x assume x: "x \<in> space M"
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   386
    from simple_function_indicator_representation[OF u x]
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   387
    show "(\<Sum>y\<in>u ` space M. y * indicator (u -` {y} \<inter> space M) x) = u x" ..
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   388
  next
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   389
    show "simple_function M (\<lambda>x. (\<Sum>y\<in>u ` space M. y * indicator (u -` {y} \<inter> space M) x))"
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   390
      apply (subst simple_function_cong)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   391
      apply (rule simple_function_indicator_representation[symmetric])
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   392
      apply (auto intro: u)
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   393
      done
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   394
  next
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   395
    from u nn have "finite (u ` space M)" "\<And>x. x \<in> u ` space M \<Longrightarrow> 0 \<le> x"
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   396
      unfolding simple_function_def by auto
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   397
    then show "P (\<lambda>x. \<Sum>y\<in>u ` space M. y * indicator (u -` {y} \<inter> space M) x)"
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   398
    proof induct
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   399
      case empty show ?case
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   400
        using set[of "{}"] by (simp add: indicator_def[abs_def])
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   401
    qed (auto intro!: add mult set simple_functionD u setsum_nonneg
49797
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
   402
       simple_function_setsum)
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   403
  qed fact
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   404
qed
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   405
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   406
lemma borel_measurable_induct[consumes 2, case_names cong set mult add seq, induct set: borel_measurable]:
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   407
  fixes u :: "'a \<Rightarrow> ereal"
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   408
  assumes u: "u \<in> borel_measurable M" "\<And>x. 0 \<le> u x"
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   409
  assumes cong: "\<And>f g. f \<in> borel_measurable M \<Longrightarrow> g \<in> borel_measurable M \<Longrightarrow> (\<And>x. x \<in> space M \<Longrightarrow> f x = g x) \<Longrightarrow> P g \<Longrightarrow> P f"
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   410
  assumes set: "\<And>A. A \<in> sets M \<Longrightarrow> P (indicator A)"
49797
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
   411
  assumes mult: "\<And>u c. 0 \<le> c \<Longrightarrow> u \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> P (\<lambda>x. c * u x)"
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
   412
  assumes add: "\<And>u v. u \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> v \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> v x) \<Longrightarrow> P v \<Longrightarrow> P (\<lambda>x. v x + u x)"
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
   413
  assumes seq: "\<And>U. (\<And>i. U i \<in> borel_measurable M) \<Longrightarrow>  (\<And>i x. 0 \<le> U i x) \<Longrightarrow>  (\<And>i. P (U i)) \<Longrightarrow> incseq U \<Longrightarrow> P (SUP i. U i)"
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   414
  shows "P u"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   415
  using u
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   416
proof (induct rule: borel_measurable_implies_simple_function_sequence')
49797
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
   417
  fix U assume U: "\<And>i. simple_function M (U i)" "incseq U" "\<And>i. \<infinity> \<notin> range (U i)" and
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   418
    sup: "\<And>x. (SUP i. U i x) = max 0 (u x)" and nn: "\<And>i x. 0 \<le> U i x"
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   419
  have u_eq: "u = (SUP i. U i)"
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   420
    using nn u sup by (auto simp: max_def)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   421
  
49797
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
   422
  from U have "\<And>i. U i \<in> borel_measurable M"
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
   423
    by (simp add: borel_measurable_simple_function)
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
   424
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   425
  show "P u"
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   426
    unfolding u_eq
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   427
  proof (rule seq)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   428
    fix i show "P (U i)"
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   429
      using `simple_function M (U i)` nn
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   430
      by (induct rule: simple_function_induct_nn)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   431
         (auto intro: set mult add cong dest!: borel_measurable_simple_function)
49797
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
   432
  qed fact+
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   433
qed
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   434
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   435
lemma simple_function_If_set:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   436
  assumes sf: "simple_function M f" "simple_function M g" and A: "A \<inter> space M \<in> sets M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   437
  shows "simple_function M (\<lambda>x. if x \<in> A then f x else g x)" (is "simple_function M ?IF")
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   438
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   439
  def F \<equiv> "\<lambda>x. f -` {x} \<inter> space M" and G \<equiv> "\<lambda>x. g -` {x} \<inter> space M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   440
  show ?thesis unfolding simple_function_def
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   441
  proof safe
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   442
    have "?IF ` space M \<subseteq> f ` space M \<union> g ` space M" by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   443
    from finite_subset[OF this] assms
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   444
    show "finite (?IF ` space M)" unfolding simple_function_def by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   445
  next
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   446
    fix x assume "x \<in> space M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   447
    then have *: "?IF -` {?IF x} \<inter> space M = (if x \<in> A
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   448
      then ((F (f x) \<inter> (A \<inter> space M)) \<union> (G (f x) - (G (f x) \<inter> (A \<inter> space M))))
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   449
      else ((F (g x) \<inter> (A \<inter> space M)) \<union> (G (g x) - (G (g x) \<inter> (A \<inter> space M)))))"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   450
      using sets.sets_into_space[OF A] by (auto split: split_if_asm simp: G_def F_def)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   451
    have [intro]: "\<And>x. F x \<in> sets M" "\<And>x. G x \<in> sets M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   452
      unfolding F_def G_def using sf[THEN simple_functionD(2)] by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   453
    show "?IF -` {?IF x} \<inter> space M \<in> sets M" unfolding * using A by auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   454
  qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   455
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   456
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   457
lemma simple_function_If:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   458
  assumes sf: "simple_function M f" "simple_function M g" and P: "{x\<in>space M. P x} \<in> sets M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   459
  shows "simple_function M (\<lambda>x. if P x then f x else g x)"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   460
proof -
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   461
  have "{x\<in>space M. P x} = {x. P x} \<inter> space M" by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   462
  with simple_function_If_set[OF sf, of "{x. P x}"] P show ?thesis by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   463
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   464
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   465
lemma simple_function_subalgebra:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   466
  assumes "simple_function N f"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   467
  and N_subalgebra: "sets N \<subseteq> sets M" "space N = space M"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   468
  shows "simple_function M f"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   469
  using assms unfolding simple_function_def by auto
39092
98de40859858 move lemmas to correct theory files
hoelzl
parents: 38705
diff changeset
   470
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   471
lemma simple_function_comp:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   472
  assumes T: "T \<in> measurable M M'"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   473
    and f: "simple_function M' f"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   474
  shows "simple_function M (\<lambda>x. f (T x))"
41661
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   475
proof (intro simple_function_def[THEN iffD2] conjI ballI)
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   476
  have "(\<lambda>x. f (T x)) ` space M \<subseteq> f ` space M'"
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   477
    using T unfolding measurable_def by auto
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   478
  then show "finite ((\<lambda>x. f (T x)) ` space M)"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   479
    using f unfolding simple_function_def by (auto intro: finite_subset)
41661
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   480
  fix i assume i: "i \<in> (\<lambda>x. f (T x)) ` space M"
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   481
  then have "i \<in> f ` space M'"
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   482
    using T unfolding measurable_def by auto
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   483
  then have "f -` {i} \<inter> space M' \<in> sets M'"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   484
    using f unfolding simple_function_def by auto
41661
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   485
  then have "T -` (f -` {i} \<inter> space M') \<inter> space M \<in> sets M"
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   486
    using T unfolding measurable_def by auto
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   487
  also have "T -` (f -` {i} \<inter> space M') \<inter> space M = (\<lambda>x. f (T x)) -` {i} \<inter> space M"
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   488
    using T unfolding measurable_def by auto
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   489
  finally show "(\<lambda>x. f (T x)) -` {i} \<inter> space M \<in> sets M" .
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   490
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   491
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   492
section "Simple integral"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   493
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   494
definition simple_integral :: "'a measure \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> ereal" ("integral\<^sup>S") where
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   495
  "integral\<^sup>S M f = (\<Sum>x \<in> f ` space M. x * emeasure M (f -` {x} \<inter> space M))"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   496
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   497
syntax
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   498
  "_simple_integral" :: "pttrn \<Rightarrow> ereal \<Rightarrow> 'a measure \<Rightarrow> ereal" ("\<integral>\<^sup>S _. _ \<partial>_" [60,61] 110)
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   499
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   500
translations
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   501
  "\<integral>\<^sup>S x. f \<partial>M" == "CONST simple_integral M (%x. f)"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   502
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   503
lemma simple_integral_cong:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   504
  assumes "\<And>t. t \<in> space M \<Longrightarrow> f t = g t"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   505
  shows "integral\<^sup>S M f = integral\<^sup>S M g"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   506
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   507
  have "f ` space M = g ` space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   508
    "\<And>x. f -` {x} \<inter> space M = g -` {x} \<inter> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   509
    using assms by (auto intro!: image_eqI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   510
  thus ?thesis unfolding simple_integral_def by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   511
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   512
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   513
lemma simple_integral_const[simp]:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   514
  "(\<integral>\<^sup>Sx. c \<partial>M) = c * (emeasure M) (space M)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   515
proof (cases "space M = {}")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   516
  case True thus ?thesis unfolding simple_integral_def by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   517
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   518
  case False hence "(\<lambda>x. c) ` space M = {c}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   519
  thus ?thesis unfolding simple_integral_def by simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   520
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   521
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   522
lemma simple_function_partition:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   523
  assumes f: "simple_function M f" and g: "simple_function M g"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   524
  shows "integral\<^sup>S M f = (\<Sum>A\<in>(\<lambda>x. f -` {f x} \<inter> g -` {g x} \<inter> space M) ` space M. the_elem (f`A) * (emeasure M) A)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   525
    (is "_ = setsum _ (?p ` space M)")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   526
proof-
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   527
  let ?sub = "\<lambda>x. ?p ` (f -` {x} \<inter> space M)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   528
  let ?SIGMA = "Sigma (f`space M) ?sub"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   529
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   530
  have [intro]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   531
    "finite (f ` space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   532
    "finite (g ` space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   533
    using assms unfolding simple_function_def by simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   534
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   535
  { fix A
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   536
    have "?p ` (A \<inter> space M) \<subseteq>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   537
      (\<lambda>(x,y). f -` {x} \<inter> g -` {y} \<inter> space M) ` (f`space M \<times> g`space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   538
      by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   539
    hence "finite (?p ` (A \<inter> space M))"
40786
0a54cfc9add3 gave more standard finite set rules simp and intro attribute
nipkow
parents: 39910
diff changeset
   540
      by (rule finite_subset) auto }
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   541
  note this[intro, simp]
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   542
  note sets = simple_function_measurable2[OF f g]
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   543
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   544
  { fix x assume "x \<in> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   545
    have "\<Union>(?sub (f x)) = (f -` {f x} \<inter> space M)" by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   546
    with sets have "(emeasure M) (f -` {f x} \<inter> space M) = setsum (emeasure M) (?sub (f x))"
47761
dfe747e72fa8 moved lemmas to appropriate places
hoelzl
parents: 47694
diff changeset
   547
      by (subst setsum_emeasure) (auto simp: disjoint_family_on_def) }
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   548
  hence "integral\<^sup>S M f = (\<Sum>(x,A)\<in>?SIGMA. x * (emeasure M) A)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   549
    unfolding simple_integral_def using f sets
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   550
    by (subst setsum_Sigma[symmetric])
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   551
       (auto intro!: setsum_cong setsum_ereal_right_distrib)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   552
  also have "\<dots> = (\<Sum>A\<in>?p ` space M. the_elem (f`A) * (emeasure M) A)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   553
  proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   554
    have [simp]: "\<And>x. x \<in> space M \<Longrightarrow> f ` ?p x = {f x}" by (auto intro!: imageI)
39910
10097e0a9dbd constant `contents` renamed to `the_elem`
haftmann
parents: 39302
diff changeset
   555
    have "(\<lambda>A. (the_elem (f ` A), A)) ` ?p ` space M
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   556
      = (\<lambda>x. (f x, ?p x)) ` space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   557
    proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   558
      fix x assume "x \<in> space M"
39910
10097e0a9dbd constant `contents` renamed to `the_elem`
haftmann
parents: 39302
diff changeset
   559
      thus "(f x, ?p x) \<in> (\<lambda>A. (the_elem (f`A), A)) ` ?p ` space M"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   560
        by (auto intro!: image_eqI[of _ _ "?p x"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   561
    qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   562
    thus ?thesis
39910
10097e0a9dbd constant `contents` renamed to `the_elem`
haftmann
parents: 39302
diff changeset
   563
      apply (auto intro!: setsum_reindex_cong[of "\<lambda>A. (the_elem (f`A), A)"] inj_onI)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   564
      apply (rule_tac x="xa" in image_eqI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   565
      by simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   566
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   567
  finally show ?thesis .
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   568
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   569
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   570
lemma simple_integral_add[simp]:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   571
  assumes f: "simple_function M f" and "\<And>x. 0 \<le> f x" and g: "simple_function M g" and "\<And>x. 0 \<le> g x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   572
  shows "(\<integral>\<^sup>Sx. f x + g x \<partial>M) = integral\<^sup>S M f + integral\<^sup>S M g"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   573
proof -
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   574
  { fix x let ?S = "g -` {g x} \<inter> f -` {f x} \<inter> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   575
    assume "x \<in> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   576
    hence "(\<lambda>a. f a + g a) ` ?S = {f x + g x}" "f ` ?S = {f x}" "g ` ?S = {g x}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   577
        "(\<lambda>x. (f x, g x)) -` {(f x, g x)} \<inter> space M = ?S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   578
      by auto }
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   579
  with assms show ?thesis
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   580
    unfolding
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   581
      simple_function_partition[OF simple_function_add[OF f g] simple_function_Pair[OF f g]]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   582
      simple_function_partition[OF f g]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   583
      simple_function_partition[OF g f]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   584
    by (subst (3) Int_commute)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   585
       (auto simp add: ereal_left_distrib setsum_addf[symmetric] intro!: setsum_cong)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   586
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   587
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   588
lemma simple_integral_setsum[simp]:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   589
  assumes "\<And>i x. i \<in> P \<Longrightarrow> 0 \<le> f i x"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   590
  assumes "\<And>i. i \<in> P \<Longrightarrow> simple_function M (f i)"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   591
  shows "(\<integral>\<^sup>Sx. (\<Sum>i\<in>P. f i x) \<partial>M) = (\<Sum>i\<in>P. integral\<^sup>S M (f i))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   592
proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   593
  assume "finite P"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   594
  from this assms show ?thesis
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   595
    by induct (auto simp: simple_function_setsum simple_integral_add setsum_nonneg)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   596
qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   597
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   598
lemma simple_integral_mult[simp]:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   599
  assumes f: "simple_function M f" "\<And>x. 0 \<le> f x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   600
  shows "(\<integral>\<^sup>Sx. c * f x \<partial>M) = c * integral\<^sup>S M f"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   601
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   602
  note mult = simple_function_mult[OF simple_function_const[of _ c] f(1)]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   603
  { fix x let ?S = "f -` {f x} \<inter> (\<lambda>x. c * f x) -` {c * f x} \<inter> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   604
    assume "x \<in> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   605
    hence "(\<lambda>x. c * f x) ` ?S = {c * f x}" "f ` ?S = {f x}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   606
      by auto }
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   607
  with assms show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   608
    unfolding simple_function_partition[OF mult f(1)]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   609
              simple_function_partition[OF f(1) mult]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   610
    by (subst setsum_ereal_right_distrib)
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   611
       (auto intro!: ereal_0_le_mult setsum_cong simp: mult_assoc)
40871
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
   612
qed
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
   613
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   614
lemma simple_integral_mono_AE:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   615
  assumes f: "simple_function M f" and g: "simple_function M g"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   616
  and mono: "AE x in M. f x \<le> g x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   617
  shows "integral\<^sup>S M f \<le> integral\<^sup>S M g"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   618
proof -
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   619
  let ?S = "\<lambda>x. (g -` {g x} \<inter> space M) \<inter> (f -` {f x} \<inter> space M)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   620
  have *: "\<And>x. g -` {g x} \<inter> f -` {f x} \<inter> space M = ?S x"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   621
    "\<And>x. f -` {f x} \<inter> g -` {g x} \<inter> space M = ?S x" by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   622
  show ?thesis
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   623
    unfolding *
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   624
      simple_function_partition[OF f g]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   625
      simple_function_partition[OF g f]
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   626
  proof (safe intro!: setsum_mono)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   627
    fix x assume "x \<in> space M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   628
    then have *: "f ` ?S x = {f x}" "g ` ?S x = {g x}" by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   629
    show "the_elem (f`?S x) * (emeasure M) (?S x) \<le> the_elem (g`?S x) * (emeasure M) (?S x)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   630
    proof (cases "f x \<le> g x")
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   631
      case True then show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   632
        using * assms(1,2)[THEN simple_functionD(2)]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   633
        by (auto intro!: ereal_mult_right_mono)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   634
    next
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   635
      case False
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   636
      obtain N where N: "{x\<in>space M. \<not> f x \<le> g x} \<subseteq> N" "N \<in> sets M" "(emeasure M) N = 0"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   637
        using mono by (auto elim!: AE_E)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   638
      have "?S x \<subseteq> N" using N `x \<in> space M` False by auto
40871
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
   639
      moreover have "?S x \<in> sets M" using assms
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   640
        by (rule_tac sets.Int) (auto intro!: simple_functionD)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   641
      ultimately have "(emeasure M) (?S x) \<le> (emeasure M) N"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   642
        using `N \<in> sets M` by (auto intro!: emeasure_mono)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   643
      moreover have "0 \<le> (emeasure M) (?S x)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   644
        using assms(1,2)[THEN simple_functionD(2)] by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   645
      ultimately have "(emeasure M) (?S x) = 0" using `(emeasure M) N = 0` by auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   646
      then show ?thesis by simp
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   647
    qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   648
  qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   649
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   650
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   651
lemma simple_integral_mono:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   652
  assumes "simple_function M f" and "simple_function M g"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   653
  and mono: "\<And> x. x \<in> space M \<Longrightarrow> f x \<le> g x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   654
  shows "integral\<^sup>S M f \<le> integral\<^sup>S M g"
41705
1100512e16d8 add auto support for AE_mp
hoelzl
parents: 41689
diff changeset
   655
  using assms by (intro simple_integral_mono_AE) auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   656
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   657
lemma simple_integral_cong_AE:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   658
  assumes "simple_function M f" and "simple_function M g"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   659
  and "AE x in M. f x = g x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   660
  shows "integral\<^sup>S M f = integral\<^sup>S M g"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   661
  using assms by (auto simp: eq_iff intro!: simple_integral_mono_AE)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   662
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   663
lemma simple_integral_cong':
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   664
  assumes sf: "simple_function M f" "simple_function M g"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   665
  and mea: "(emeasure M) {x\<in>space M. f x \<noteq> g x} = 0"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   666
  shows "integral\<^sup>S M f = integral\<^sup>S M g"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   667
proof (intro simple_integral_cong_AE sf AE_I)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   668
  show "(emeasure M) {x\<in>space M. f x \<noteq> g x} = 0" by fact
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   669
  show "{x \<in> space M. f x \<noteq> g x} \<in> sets M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   670
    using sf[THEN borel_measurable_simple_function] by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   671
qed simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   672
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   673
lemma simple_integral_indicator:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   674
  assumes "A \<in> sets M"
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   675
  assumes f: "simple_function M f"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   676
  shows "(\<integral>\<^sup>Sx. f x * indicator A x \<partial>M) =
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   677
    (\<Sum>x \<in> f ` space M. x * (emeasure M) (f -` {x} \<inter> space M \<inter> A))"
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   678
proof (cases "A = space M")
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   679
  case True
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   680
  then have "(\<integral>\<^sup>Sx. f x * indicator A x \<partial>M) = integral\<^sup>S M f"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   681
    by (auto intro!: simple_integral_cong)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   682
  with True show ?thesis by (simp add: simple_integral_def)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   683
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   684
  assume "A \<noteq> space M"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   685
  then obtain x where x: "x \<in> space M" "x \<notin> A" using sets.sets_into_space[OF assms(1)] by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   686
  have I: "(\<lambda>x. f x * indicator A x) ` space M = f ` A \<union> {0}" (is "?I ` _ = _")
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   687
  proof safe
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   688
    fix y assume "?I y \<notin> f ` A" hence "y \<notin> A" by auto thus "?I y = 0" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   689
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   690
    fix y assume "y \<in> A" thus "f y \<in> ?I ` space M"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   691
      using sets.sets_into_space[OF assms(1)] by (auto intro!: image_eqI[of _ _ y])
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   692
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   693
    show "0 \<in> ?I ` space M" using x by (auto intro!: image_eqI[of _ _ x])
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   694
  qed
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   695
  have *: "(\<integral>\<^sup>Sx. f x * indicator A x \<partial>M) =
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   696
    (\<Sum>x \<in> f ` space M \<union> {0}. x * (emeasure M) (f -` {x} \<inter> space M \<inter> A))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   697
    unfolding simple_integral_def I
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   698
  proof (rule setsum_mono_zero_cong_left)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   699
    show "finite (f ` space M \<union> {0})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   700
      using assms(2) unfolding simple_function_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   701
    show "f ` A \<union> {0} \<subseteq> f`space M \<union> {0}"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   702
      using sets.sets_into_space[OF assms(1)] by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   703
    have "\<And>x. f x \<notin> f ` A \<Longrightarrow> f -` {f x} \<inter> space M \<inter> A = {}"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   704
      by (auto simp: image_iff)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   705
    thus "\<forall>i\<in>f ` space M \<union> {0} - (f ` A \<union> {0}).
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   706
      i * (emeasure M) (f -` {i} \<inter> space M \<inter> A) = 0" by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   707
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   708
    fix x assume "x \<in> f`A \<union> {0}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   709
    hence "x \<noteq> 0 \<Longrightarrow> ?I -` {x} \<inter> space M = f -` {x} \<inter> space M \<inter> A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   710
      by (auto simp: indicator_def split: split_if_asm)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   711
    thus "x * (emeasure M) (?I -` {x} \<inter> space M) =
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   712
      x * (emeasure M) (f -` {x} \<inter> space M \<inter> A)" by (cases "x = 0") simp_all
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   713
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   714
  show ?thesis unfolding *
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   715
    using assms(2) unfolding simple_function_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   716
    by (auto intro!: setsum_mono_zero_cong_right)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   717
qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   718
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   719
lemma simple_integral_indicator_only[simp]:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   720
  assumes "A \<in> sets M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   721
  shows "integral\<^sup>S M (indicator A) = emeasure M A"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   722
proof cases
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   723
  assume "space M = {}" hence "A = {}" using sets.sets_into_space[OF assms] by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   724
  thus ?thesis unfolding simple_integral_def using `space M = {}` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   725
next
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   726
  assume "space M \<noteq> {}" hence "(\<lambda>x. 1) ` space M = {1::ereal}" by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   727
  thus ?thesis
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   728
    using simple_integral_indicator[OF assms simple_function_const[of _ 1]]
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   729
    using sets.sets_into_space[OF assms]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   730
    by (auto intro!: arg_cong[where f="(emeasure M)"])
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   731
qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   732
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   733
lemma simple_integral_null_set:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   734
  assumes "simple_function M u" "\<And>x. 0 \<le> u x" and "N \<in> null_sets M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   735
  shows "(\<integral>\<^sup>Sx. u x * indicator N x \<partial>M) = 0"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   736
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   737
  have "AE x in M. indicator N x = (0 :: ereal)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   738
    using `N \<in> null_sets M` by (auto simp: indicator_def intro!: AE_I[of _ _ N])
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   739
  then have "(\<integral>\<^sup>Sx. u x * indicator N x \<partial>M) = (\<integral>\<^sup>Sx. 0 \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   740
    using assms apply (intro simple_integral_cong_AE) by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   741
  then show ?thesis by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   742
qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   743
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   744
lemma simple_integral_cong_AE_mult_indicator:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   745
  assumes sf: "simple_function M f" and eq: "AE x in M. x \<in> S" and "S \<in> sets M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   746
  shows "integral\<^sup>S M f = (\<integral>\<^sup>Sx. f x * indicator S x \<partial>M)"
41705
1100512e16d8 add auto support for AE_mp
hoelzl
parents: 41689
diff changeset
   747
  using assms by (intro simple_integral_cong_AE) auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   748
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   749
lemma simple_integral_cmult_indicator:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   750
  assumes A: "A \<in> sets M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   751
  shows "(\<integral>\<^sup>Sx. c * indicator A x \<partial>M) = c * (emeasure M) A"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   752
  using simple_integral_mult[OF simple_function_indicator[OF A]]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   753
  unfolding simple_integral_indicator_only[OF A] by simp
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   754
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   755
lemma simple_integral_positive:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   756
  assumes f: "simple_function M f" and ae: "AE x in M. 0 \<le> f x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   757
  shows "0 \<le> integral\<^sup>S M f"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   758
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   759
  have "integral\<^sup>S M (\<lambda>x. 0) \<le> integral\<^sup>S M f"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   760
    using simple_integral_mono_AE[OF _ f ae] by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   761
  then show ?thesis by simp
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   762
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   763
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   764
section "Continuous positive integration"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   765
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   766
definition positive_integral :: "'a measure \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> ereal" ("integral\<^sup>P") where
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   767
  "integral\<^sup>P M f = (SUP g : {g. simple_function M g \<and> g \<le> max 0 \<circ> f}. integral\<^sup>S M g)"
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
   768
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   769
syntax
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   770
  "_positive_integral" :: "pttrn \<Rightarrow> ereal \<Rightarrow> 'a measure \<Rightarrow> ereal" ("\<integral>\<^sup>+ _. _ \<partial>_" [60,61] 110)
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   771
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   772
translations
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   773
  "\<integral>\<^sup>+ x. f \<partial>M" == "CONST positive_integral M (%x. f)"
40872
7c556a9240de Move SUP_commute, SUP_less_iff to HOL image;
hoelzl
parents: 40871
diff changeset
   774
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   775
lemma positive_integral_positive:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   776
  "0 \<le> integral\<^sup>P M f"
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   777
  by (auto intro!: SUP_upper2[of "\<lambda>x. 0"] simp: positive_integral_def le_fun_def)
40873
1ef85f4e7097 Shorter definition for positive_integral.
hoelzl
parents: 40872
diff changeset
   778
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   779
lemma positive_integral_not_MInfty[simp]: "integral\<^sup>P M f \<noteq> -\<infinity>"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   780
  using positive_integral_positive[of M f] by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   781
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   782
lemma positive_integral_def_finite:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   783
  "integral\<^sup>P M f = (SUP g : {g. simple_function M g \<and> g \<le> max 0 \<circ> f \<and> range g \<subseteq> {0 ..< \<infinity>}}. integral\<^sup>S M g)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   784
    (is "_ = SUPR ?A ?f")
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   785
  unfolding positive_integral_def
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   786
proof (safe intro!: antisym SUP_least)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   787
  fix g assume g: "simple_function M g" "g \<le> max 0 \<circ> f"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   788
  let ?G = "{x \<in> space M. \<not> g x \<noteq> \<infinity>}"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   789
  note gM = g(1)[THEN borel_measurable_simple_function]
50252
4aa34bd43228 eliminated slightly odd identifiers;
wenzelm
parents: 50244
diff changeset
   790
  have \<mu>_G_pos: "0 \<le> (emeasure M) ?G" using gM by auto
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   791
  let ?g = "\<lambda>y x. if g x = \<infinity> then y else max 0 (g x)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   792
  from g gM have g_in_A: "\<And>y. 0 \<le> y \<Longrightarrow> y \<noteq> \<infinity> \<Longrightarrow> ?g y \<in> ?A"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   793
    apply (safe intro!: simple_function_max simple_function_If)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   794
    apply (force simp: max_def le_fun_def split: split_if_asm)+
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   795
    done
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   796
  show "integral\<^sup>S M g \<le> SUPR ?A ?f"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   797
  proof cases
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   798
    have g0: "?g 0 \<in> ?A" by (intro g_in_A) auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   799
    assume "(emeasure M) ?G = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   800
    with gM have "AE x in M. x \<notin> ?G"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   801
      by (auto simp add: AE_iff_null intro!: null_setsI)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   802
    with gM g show ?thesis
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   803
      by (intro SUP_upper2[OF g0] simple_integral_mono_AE)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   804
         (auto simp: max_def intro!: simple_function_If)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   805
  next
50252
4aa34bd43228 eliminated slightly odd identifiers;
wenzelm
parents: 50244
diff changeset
   806
    assume \<mu>_G: "(emeasure M) ?G \<noteq> 0"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   807
    have "SUPR ?A (integral\<^sup>S M) = \<infinity>"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   808
    proof (intro SUP_PInfty)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   809
      fix n :: nat
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   810
      let ?y = "ereal (real n) / (if (emeasure M) ?G = \<infinity> then 1 else (emeasure M) ?G)"
50252
4aa34bd43228 eliminated slightly odd identifiers;
wenzelm
parents: 50244
diff changeset
   811
      have "0 \<le> ?y" "?y \<noteq> \<infinity>" using \<mu>_G \<mu>_G_pos by (auto simp: ereal_divide_eq)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   812
      then have "?g ?y \<in> ?A" by (rule g_in_A)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   813
      have "real n \<le> ?y * (emeasure M) ?G"
50252
4aa34bd43228 eliminated slightly odd identifiers;
wenzelm
parents: 50244
diff changeset
   814
        using \<mu>_G \<mu>_G_pos by (cases "(emeasure M) ?G") (auto simp: field_simps)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   815
      also have "\<dots> = (\<integral>\<^sup>Sx. ?y * indicator ?G x \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   816
        using `0 \<le> ?y` `?g ?y \<in> ?A` gM
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   817
        by (subst simple_integral_cmult_indicator) auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   818
      also have "\<dots> \<le> integral\<^sup>S M (?g ?y)" using `?g ?y \<in> ?A` gM
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   819
        by (intro simple_integral_mono) auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   820
      finally show "\<exists>i\<in>?A. real n \<le> integral\<^sup>S M i"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   821
        using `?g ?y \<in> ?A` by blast
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   822
    qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   823
    then show ?thesis by simp
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   824
  qed
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   825
qed (auto intro: SUP_upper)
40873
1ef85f4e7097 Shorter definition for positive_integral.
hoelzl
parents: 40872
diff changeset
   826
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   827
lemma positive_integral_mono_AE:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   828
  assumes ae: "AE x in M. u x \<le> v x" shows "integral\<^sup>P M u \<le> integral\<^sup>P M v"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   829
  unfolding positive_integral_def
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   830
proof (safe intro!: SUP_mono)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   831
  fix n assume n: "simple_function M n" "n \<le> max 0 \<circ> u"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   832
  from ae[THEN AE_E] guess N . note N = this
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   833
  then have ae_N: "AE x in M. x \<notin> N" by (auto intro: AE_not_in)
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   834
  let ?n = "\<lambda>x. n x * indicator (space M - N) x"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   835
  have "AE x in M. n x \<le> ?n x" "simple_function M ?n"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   836
    using n N ae_N by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   837
  moreover
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   838
  { fix x have "?n x \<le> max 0 (v x)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   839
    proof cases
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   840
      assume x: "x \<in> space M - N"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   841
      with N have "u x \<le> v x" by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   842
      with n(2)[THEN le_funD, of x] x show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   843
        by (auto simp: max_def split: split_if_asm)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   844
    qed simp }
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   845
  then have "?n \<le> max 0 \<circ> v" by (auto simp: le_funI)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   846
  moreover have "integral\<^sup>S M n \<le> integral\<^sup>S M ?n"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   847
    using ae_N N n by (auto intro!: simple_integral_mono_AE)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   848
  ultimately show "\<exists>m\<in>{g. simple_function M g \<and> g \<le> max 0 \<circ> v}. integral\<^sup>S M n \<le> integral\<^sup>S M m"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   849
    by force
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   850
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   851
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   852
lemma positive_integral_mono:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   853
  "(\<And>x. x \<in> space M \<Longrightarrow> u x \<le> v x) \<Longrightarrow> integral\<^sup>P M u \<le> integral\<^sup>P M v"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   854
  by (auto intro: positive_integral_mono_AE)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   855
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   856
lemma positive_integral_cong_AE:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   857
  "AE x in M. u x = v x \<Longrightarrow> integral\<^sup>P M u = integral\<^sup>P M v"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   858
  by (auto simp: eq_iff intro!: positive_integral_mono_AE)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   859
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   860
lemma positive_integral_cong:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   861
  "(\<And>x. x \<in> space M \<Longrightarrow> u x = v x) \<Longrightarrow> integral\<^sup>P M u = integral\<^sup>P M v"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   862
  by (auto intro: positive_integral_cong_AE)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   863
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   864
lemma positive_integral_eq_simple_integral:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   865
  assumes f: "simple_function M f" "\<And>x. 0 \<le> f x" shows "integral\<^sup>P M f = integral\<^sup>S M f"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   866
proof -
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   867
  let ?f = "\<lambda>x. f x * indicator (space M) x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   868
  have f': "simple_function M ?f" using f by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   869
  with f(2) have [simp]: "max 0 \<circ> ?f = ?f"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   870
    by (auto simp: fun_eq_iff max_def split: split_indicator)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   871
  have "integral\<^sup>P M ?f \<le> integral\<^sup>S M ?f" using f'
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   872
    by (force intro!: SUP_least simple_integral_mono simp: le_fun_def positive_integral_def)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   873
  moreover have "integral\<^sup>S M ?f \<le> integral\<^sup>P M ?f"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   874
    unfolding positive_integral_def
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   875
    using f' by (auto intro!: SUP_upper)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   876
  ultimately show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   877
    by (simp cong: positive_integral_cong simple_integral_cong)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   878
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   879
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   880
lemma positive_integral_eq_simple_integral_AE:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   881
  assumes f: "simple_function M f" "AE x in M. 0 \<le> f x" shows "integral\<^sup>P M f = integral\<^sup>S M f"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   882
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   883
  have "AE x in M. f x = max 0 (f x)" using f by (auto split: split_max)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   884
  with f have "integral\<^sup>P M f = integral\<^sup>S M (\<lambda>x. max 0 (f x))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   885
    by (simp cong: positive_integral_cong_AE simple_integral_cong_AE
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   886
             add: positive_integral_eq_simple_integral)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   887
  with assms show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   888
    by (auto intro!: simple_integral_cong_AE split: split_max)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   889
qed
40873
1ef85f4e7097 Shorter definition for positive_integral.
hoelzl
parents: 40872
diff changeset
   890
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   891
lemma positive_integral_SUP_approx:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   892
  assumes f: "incseq f" "\<And>i. f i \<in> borel_measurable M" "\<And>i x. 0 \<le> f i x"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   893
  and u: "simple_function M u" "u \<le> (SUP i. f i)" "u`space M \<subseteq> {0..<\<infinity>}"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   894
  shows "integral\<^sup>S M u \<le> (SUP i. integral\<^sup>P M (f i))" (is "_ \<le> ?S")
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   895
proof (rule ereal_le_mult_one_interval)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   896
  have "0 \<le> (SUP i. integral\<^sup>P M (f i))"
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   897
    using f(3) by (auto intro!: SUP_upper2 positive_integral_positive)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   898
  then show "(SUP i. integral\<^sup>P M (f i)) \<noteq> -\<infinity>" by auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   899
  have u_range: "\<And>x. x \<in> space M \<Longrightarrow> 0 \<le> u x \<and> u x \<noteq> \<infinity>"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   900
    using u(3) by auto
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   901
  fix a :: ereal assume "0 < a" "a < 1"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   902
  hence "a \<noteq> 0" by auto
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   903
  let ?B = "\<lambda>i. {x \<in> space M. a * u x \<le> f i x}"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   904
  have B: "\<And>i. ?B i \<in> sets M"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   905
    using f `simple_function M u` by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   906
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   907
  let ?uB = "\<lambda>i x. u x * indicator (?B i) x"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   908
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   909
  { fix i have "?B i \<subseteq> ?B (Suc i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   910
    proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   911
      fix i x assume "a * u x \<le> f i x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   912
      also have "\<dots> \<le> f (Suc i) x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   913
        using `incseq f`[THEN incseq_SucD] unfolding le_fun_def by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   914
      finally show "a * u x \<le> f (Suc i) x" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   915
    qed }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   916
  note B_mono = this
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   917
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   918
  note B_u = sets.Int[OF u(1)[THEN simple_functionD(2)] B]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   919
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   920
  let ?B' = "\<lambda>i n. (u -` {i} \<inter> space M) \<inter> ?B n"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   921
  have measure_conv: "\<And>i. (emeasure M) (u -` {i} \<inter> space M) = (SUP n. (emeasure M) (?B' i n))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   922
  proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   923
    fix i
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   924
    have 1: "range (?B' i) \<subseteq> sets M" using B_u by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   925
    have 2: "incseq (?B' i)" using B_mono by (auto intro!: incseq_SucI)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   926
    have "(\<Union>n. ?B' i n) = u -` {i} \<inter> space M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   927
    proof safe
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   928
      fix x i assume x: "x \<in> space M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   929
      show "x \<in> (\<Union>i. ?B' (u x) i)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   930
      proof cases
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   931
        assume "u x = 0" thus ?thesis using `x \<in> space M` f(3) by simp
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   932
      next
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   933
        assume "u x \<noteq> 0"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   934
        with `a < 1` u_range[OF `x \<in> space M`]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   935
        have "a * u x < 1 * u x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   936
          by (intro ereal_mult_strict_right_mono) (auto simp: image_iff)
46884
154dc6ec0041 tuned proofs
noschinl
parents: 46731
diff changeset
   937
        also have "\<dots> \<le> (SUP i. f i x)" using u(2) by (auto simp: le_fun_def)
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   938
        finally obtain i where "a * u x < f i x" unfolding SUP_def
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 56154
diff changeset
   939
          by (auto simp add: less_SUP_iff)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   940
        hence "a * u x \<le> f i x" by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   941
        thus ?thesis using `x \<in> space M` by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   942
      qed
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   943
    qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   944
    then show "?thesis i" using SUP_emeasure_incseq[OF 1 2] by simp
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   945
  qed
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   946
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   947
  have "integral\<^sup>S M u = (SUP i. integral\<^sup>S M (?uB i))"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   948
    unfolding simple_integral_indicator[OF B `simple_function M u`]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   949
  proof (subst SUPR_ereal_setsum, safe)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   950
    fix x n assume "x \<in> space M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   951
    with u_range show "incseq (\<lambda>i. u x * (emeasure M) (?B' (u x) i))" "\<And>i. 0 \<le> u x * (emeasure M) (?B' (u x) i)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   952
      using B_mono B_u by (auto intro!: emeasure_mono ereal_mult_left_mono incseq_SucI simp: ereal_zero_le_0_iff)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   953
  next
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   954
    show "integral\<^sup>S M u = (\<Sum>i\<in>u ` space M. SUP n. i * (emeasure M) (?B' i n))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   955
      using measure_conv u_range B_u unfolding simple_integral_def
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   956
      by (auto intro!: setsum_cong SUPR_ereal_cmult[symmetric])
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   957
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   958
  moreover
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   959
  have "a * (SUP i. integral\<^sup>S M (?uB i)) \<le> ?S"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   960
    apply (subst SUPR_ereal_cmult[symmetric])
38705
aaee86c0e237 moved generic lemmas in Probability to HOL
hoelzl
parents: 38656
diff changeset
   961
  proof (safe intro!: SUP_mono bexI)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   962
    fix i
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   963
    have "a * integral\<^sup>S M (?uB i) = (\<integral>\<^sup>Sx. a * ?uB i x \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   964
      using B `simple_function M u` u_range
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   965
      by (subst simple_integral_mult) (auto split: split_indicator)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   966
    also have "\<dots> \<le> integral\<^sup>P M (f i)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   967
    proof -
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   968
      have *: "simple_function M (\<lambda>x. a * ?uB i x)" using B `0 < a` u(1) by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   969
      show ?thesis using f(3) * u_range `0 < a`
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   970
        by (subst positive_integral_eq_simple_integral[symmetric])
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   971
           (auto intro!: positive_integral_mono split: split_indicator)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   972
    qed
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   973
    finally show "a * integral\<^sup>S M (?uB i) \<le> integral\<^sup>P M (f i)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   974
      by auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   975
  next
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   976
    fix i show "0 \<le> \<integral>\<^sup>S x. ?uB i x \<partial>M" using B `0 < a` u(1) u_range
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   977
      by (intro simple_integral_positive) (auto split: split_indicator)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   978
  qed (insert `0 < a`, auto)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   979
  ultimately show "a * integral\<^sup>S M u \<le> ?S" by simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   980
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   981
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   982
lemma incseq_positive_integral:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   983
  assumes "incseq f" shows "incseq (\<lambda>i. integral\<^sup>P M (f i))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   984
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   985
  have "\<And>i x. f i x \<le> f (Suc i) x"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   986
    using assms by (auto dest!: incseq_SucD simp: le_fun_def)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   987
  then show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   988
    by (auto intro!: incseq_SucI positive_integral_mono)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   989
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   990
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   991
text {* Beppo-Levi monotone convergence theorem *}
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   992
lemma positive_integral_monotone_convergence_SUP:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   993
  assumes f: "incseq f" "\<And>i. f i \<in> borel_measurable M" "\<And>i x. 0 \<le> f i x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   994
  shows "(\<integral>\<^sup>+ x. (SUP i. f i x) \<partial>M) = (SUP i. integral\<^sup>P M (f i))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   995
proof (rule antisym)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   996
  show "(SUP j. integral\<^sup>P M (f j)) \<le> (\<integral>\<^sup>+ x. (SUP i. f i x) \<partial>M)"
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   997
    by (auto intro!: SUP_least SUP_upper positive_integral_mono)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   998
next
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
   999
  show "(\<integral>\<^sup>+ x. (SUP i. f i x) \<partial>M) \<le> (SUP j. integral\<^sup>P M (f j))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1000
    unfolding positive_integral_def_finite[of _ "\<lambda>x. SUP i. f i x"]
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
  1001
  proof (safe intro!: SUP_least)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1002
    fix g assume g: "simple_function M g"
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  1003
      and *: "g \<le> max 0 \<circ> (\<lambda>x. SUP i. f i x)" "range g \<subseteq> {0..<\<infinity>}"
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  1004
    then have "\<And>x. 0 \<le> (SUP i. f i x)" and g': "g`space M \<subseteq> {0..<\<infinity>}"
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
  1005
      using f by (auto intro!: SUP_upper2)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  1006
    with * show "integral\<^sup>S M g \<le> (SUP j. integral\<^sup>P M (f j))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1007
      by (intro  positive_integral_SUP_approx[OF f g _ g'])
46884
154dc6ec0041 tuned proofs
noschinl
parents: 46731
diff changeset
  1008
         (auto simp: le_fun_def max_def)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1009
  qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1010
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1011
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1012
lemma positive_integral_monotone_convergence_SUP_AE:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1013
  assumes f: "\<And>i. AE x in M. f i x \<le> f (Suc i) x \<and> 0 \<le> f i x" "\<And>i. f i \<in> borel_measurable M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1014
  shows "(\<integral>\<^sup>+ x. (SUP i. f i x) \<partial>M) = (SUP i. integral\<^sup>P M (f i))"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1015
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1016
  from f have "AE x in M. \<forall>i. f i x \<le> f (Suc i) x \<and> 0 \<le> f i x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1017
    by (simp add: AE_all_countable)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1018
  from this[THEN AE_E] guess N . note N = this
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1019
  let ?f = "\<lambda>i x. if x \<in> space M - N then f i x else 0"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1020
  have f_eq: "AE x in M. \<forall>i. ?f i x = f i x" using N by (auto intro!: AE_I[of _ _ N])
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1021
  then have "(\<integral>\<^sup>+ x. (SUP i. f i x) \<partial>M) = (\<integral>\<^sup>+ x. (SUP i. ?f i x) \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1022
    by (auto intro!: positive_integral_cong_AE)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1023
  also have "\<dots> = (SUP i. (\<integral>\<^sup>+ x. ?f i x \<partial>M))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1024
  proof (rule positive_integral_monotone_convergence_SUP)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1025
    show "incseq ?f" using N(1) by (force intro!: incseq_SucI le_funI)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1026
    { fix i show "(\<lambda>x. if x \<in> space M - N then f i x else 0) \<in> borel_measurable M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1027
        using f N(3) by (intro measurable_If_set) auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1028
      fix x show "0 \<le> ?f i x"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1029
        using N(1) by auto }
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1030
  qed
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1031
  also have "\<dots> = (SUP i. (\<integral>\<^sup>+ x. f i x \<partial>M))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1032
    using f_eq by (force intro!: arg_cong[where f="SUPR UNIV"] positive_integral_cong_AE ext)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1033
  finally show ?thesis .
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1034
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1035
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1036
lemma positive_integral_monotone_convergence_SUP_AE_incseq:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1037
  assumes f: "incseq f" "\<And>i. AE x in M. 0 \<le> f i x" and borel: "\<And>i. f i \<in> borel_measurable M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1038
  shows "(\<integral>\<^sup>+ x. (SUP i. f i x) \<partial>M) = (SUP i. integral\<^sup>P M (f i))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1039
  using f[unfolded incseq_Suc_iff le_fun_def]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1040
  by (intro positive_integral_monotone_convergence_SUP_AE[OF _ borel])
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1041
     auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1042
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1043
lemma positive_integral_monotone_convergence_simple:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1044
  assumes f: "incseq f" "\<And>i x. 0 \<le> f i x" "\<And>i. simple_function M (f i)"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1045
  shows "(SUP i. integral\<^sup>S M (f i)) = (\<integral>\<^sup>+x. (SUP i. f i x) \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1046
  using assms unfolding positive_integral_monotone_convergence_SUP[OF f(1)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1047
    f(3)[THEN borel_measurable_simple_function] f(2)]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1048
  by (auto intro!: positive_integral_eq_simple_integral[symmetric] arg_cong[where f="SUPR UNIV"] ext)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1049
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1050
lemma positive_integral_max_0:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1051
  "(\<integral>\<^sup>+x. max 0 (f x) \<partial>M) = integral\<^sup>P M f"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1052
  by (simp add: le_fun_def positive_integral_def)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1053
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1054
lemma positive_integral_cong_pos:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1055
  assumes "\<And>x. x \<in> space M \<Longrightarrow> f x \<le> 0 \<and> g x \<le> 0 \<or> f x = g x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1056
  shows "integral\<^sup>P M f = integral\<^sup>P M g"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1057
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1058
  have "integral\<^sup>P M (\<lambda>x. max 0 (f x)) = integral\<^sup>P M (\<lambda>x. max 0 (g x))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1059
  proof (intro positive_integral_cong)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1060
    fix x assume "x \<in> space M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1061
    from assms[OF this] show "max 0 (f x) = max 0 (g x)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1062
      by (auto split: split_max)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1063
  qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1064
  then show ?thesis by (simp add: positive_integral_max_0)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1065
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1066
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1067
lemma SUP_simple_integral_sequences:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1068
  assumes f: "incseq f" "\<And>i x. 0 \<le> f i x" "\<And>i. simple_function M (f i)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1069
  and g: "incseq g" "\<And>i x. 0 \<le> g i x" "\<And>i. simple_function M (g i)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1070
  and eq: "AE x in M. (SUP i. f i x) = (SUP i. g i x)"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1071
  shows "(SUP i. integral\<^sup>S M (f i)) = (SUP i. integral\<^sup>S M (g i))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1072
    (is "SUPR _ ?F = SUPR _ ?G")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1073
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1074
  have "(SUP i. integral\<^sup>S M (f i)) = (\<integral>\<^sup>+x. (SUP i. f i x) \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1075
    using f by (rule positive_integral_monotone_convergence_simple)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1076
  also have "\<dots> = (\<integral>\<^sup>+x. (SUP i. g i x) \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1077
    unfolding eq[THEN positive_integral_cong_AE] ..
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1078
  also have "\<dots> = (SUP i. ?G i)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1079
    using g by (rule positive_integral_monotone_convergence_simple[symmetric])
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1080
  finally show ?thesis by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1081
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1082
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1083
lemma positive_integral_const[simp]:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1084
  "0 \<le> c \<Longrightarrow> (\<integral>\<^sup>+ x. c \<partial>M) = c * (emeasure M) (space M)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1085
  by (subst positive_integral_eq_simple_integral) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1086
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1087
lemma positive_integral_linear:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1088
  assumes f: "f \<in> borel_measurable M" "\<And>x. 0 \<le> f x" and "0 \<le> a"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1089
  and g: "g \<in> borel_measurable M" "\<And>x. 0 \<le> g x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1090
  shows "(\<integral>\<^sup>+ x. a * f x + g x \<partial>M) = a * integral\<^sup>P M f + integral\<^sup>P M g"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1091
    (is "integral\<^sup>P M ?L = _")
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1092
proof -
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1093
  from borel_measurable_implies_simple_function_sequence'[OF f(1)] guess u .
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1094
  note u = positive_integral_monotone_convergence_simple[OF this(2,5,1)] this
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1095
  from borel_measurable_implies_simple_function_sequence'[OF g(1)] guess v .
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1096
  note v = positive_integral_monotone_convergence_simple[OF this(2,5,1)] this
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1097
  let ?L' = "\<lambda>i x. a * u i x + v i x"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1098
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1099
  have "?L \<in> borel_measurable M" using assms by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1100
  from borel_measurable_implies_simple_function_sequence'[OF this] guess l .
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1101
  note l = positive_integral_monotone_convergence_simple[OF this(2,5,1)] this
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1102
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1103
  have inc: "incseq (\<lambda>i. a * integral\<^sup>S M (u i))" "incseq (\<lambda>i. integral\<^sup>S M (v i))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1104
    using u v `0 \<le> a`
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1105
    by (auto simp: incseq_Suc_iff le_fun_def
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1106
             intro!: add_mono ereal_mult_left_mono simple_integral_mono)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1107
  have pos: "\<And>i. 0 \<le> integral\<^sup>S M (u i)" "\<And>i. 0 \<le> integral\<^sup>S M (v i)" "\<And>i. 0 \<le> a * integral\<^sup>S M (u i)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1108
    using u v `0 \<le> a` by (auto simp: simple_integral_positive)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1109
  { fix i from pos[of i] have "a * integral\<^sup>S M (u i) \<noteq> -\<infinity>" "integral\<^sup>S M (v i) \<noteq> -\<infinity>"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1110
      by (auto split: split_if_asm) }
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1111
  note not_MInf = this
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1112
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1113
  have l': "(SUP i. integral\<^sup>S M (l i)) = (SUP i. integral\<^sup>S M (?L' i))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1114
  proof (rule SUP_simple_integral_sequences[OF l(3,6,2)])
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1115
    show "incseq ?L'" "\<And>i x. 0 \<le> ?L' i x" "\<And>i. simple_function M (?L' i)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1116
      using u v  `0 \<le> a` unfolding incseq_Suc_iff le_fun_def
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1117
      by (auto intro!: add_mono ereal_mult_left_mono ereal_add_nonneg_nonneg)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1118
    { fix x
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1119
      { fix i have "a * u i x \<noteq> -\<infinity>" "v i x \<noteq> -\<infinity>" "u i x \<noteq> -\<infinity>" using `0 \<le> a` u(6)[of i x] v(6)[of i x]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1120
          by auto }
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1121
      then have "(SUP i. a * u i x + v i x) = a * (SUP i. u i x) + (SUP i. v i x)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1122
        using `0 \<le> a` u(3) v(3) u(6)[of _ x] v(6)[of _ x]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1123
        by (subst SUPR_ereal_cmult[symmetric, OF u(6) `0 \<le> a`])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1124
           (auto intro!: SUPR_ereal_add
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1125
                 simp: incseq_Suc_iff le_fun_def add_mono ereal_mult_left_mono ereal_add_nonneg_nonneg) }
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1126
    then show "AE x in M. (SUP i. l i x) = (SUP i. ?L' i x)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1127
      unfolding l(5) using `0 \<le> a` u(5) v(5) l(5) f(2) g(2)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1128
      by (intro AE_I2) (auto split: split_max simp add: ereal_add_nonneg_nonneg)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1129
  qed
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1130
  also have "\<dots> = (SUP i. a * integral\<^sup>S M (u i) + integral\<^sup>S M (v i))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1131
    using u(2, 6) v(2, 6) `0 \<le> a` by (auto intro!: arg_cong[where f="SUPR UNIV"] ext)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1132
  finally have "(\<integral>\<^sup>+ x. max 0 (a * f x + g x) \<partial>M) = a * (\<integral>\<^sup>+x. max 0 (f x) \<partial>M) + (\<integral>\<^sup>+x. max 0 (g x) \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1133
    unfolding l(5)[symmetric] u(5)[symmetric] v(5)[symmetric]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1134
    unfolding l(1)[symmetric] u(1)[symmetric] v(1)[symmetric]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1135
    apply (subst SUPR_ereal_cmult[symmetric, OF pos(1) `0 \<le> a`])
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1136
    apply (subst SUPR_ereal_add[symmetric, OF inc not_MInf]) .
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1137
  then show ?thesis by (simp add: positive_integral_max_0)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1138
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1139
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1140
lemma positive_integral_cmult:
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1141
  assumes f: "f \<in> borel_measurable M" "0 \<le> c"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1142
  shows "(\<integral>\<^sup>+ x. c * f x \<partial>M) = c * integral\<^sup>P M f"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1143
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1144
  have [simp]: "\<And>x. c * max 0 (f x) = max 0 (c * f x)" using `0 \<le> c`
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1145
    by (auto split: split_max simp: ereal_zero_le_0_iff)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1146
  have "(\<integral>\<^sup>+ x. c * f x \<partial>M) = (\<integral>\<^sup>+ x. c * max 0 (f x) \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1147
    by (simp add: positive_integral_max_0)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1148
  then show ?thesis
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1149
    using positive_integral_linear[OF _ _ `0 \<le> c`, of "\<lambda>x. max 0 (f x)" _ "\<lambda>x. 0"] f
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1150
    by (auto simp: positive_integral_max_0)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1151
qed
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1152
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1153
lemma positive_integral_multc:
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1154
  assumes "f \<in> borel_measurable M" "0 \<le> c"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1155
  shows "(\<integral>\<^sup>+ x. f x * c \<partial>M) = integral\<^sup>P M f * c"
41096
843c40bbc379 integral over setprod
hoelzl
parents: 41095
diff changeset
  1156
  unfolding mult_commute[of _ c] positive_integral_cmult[OF assms] by simp
843c40bbc379 integral over setprod
hoelzl
parents: 41095
diff changeset
  1157
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1158
lemma positive_integral_indicator[simp]:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1159
  "A \<in> sets M \<Longrightarrow> (\<integral>\<^sup>+ x. indicator A x\<partial>M) = (emeasure M) A"
41544
c3b977fee8a3 introduced integral syntax
hoelzl
parents: 41097
diff changeset
  1160
  by (subst positive_integral_eq_simple_integral)
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1161
     (auto simp: simple_integral_indicator)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1162
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1163
lemma positive_integral_cmult_indicator:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1164
  "0 \<le> c \<Longrightarrow> A \<in> sets M \<Longrightarrow> (\<integral>\<^sup>+ x. c * indicator A x \<partial>M) = c * (emeasure M) A"
41544
c3b977fee8a3 introduced integral syntax
hoelzl
parents: 41097
diff changeset
  1165
  by (subst positive_integral_eq_simple_integral)
c3b977fee8a3 introduced integral syntax
hoelzl
parents: 41097
diff changeset
  1166
     (auto simp: simple_function_indicator simple_integral_indicator)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1167
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1168
lemma positive_integral_indicator':
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1169
  assumes [measurable]: "A \<inter> space M \<in> sets M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1170
  shows "(\<integral>\<^sup>+ x. indicator A x \<partial>M) = emeasure M (A \<inter> space M)"
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1171
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1172
  have "(\<integral>\<^sup>+ x. indicator A x \<partial>M) = (\<integral>\<^sup>+ x. indicator (A \<inter> space M) x \<partial>M)"
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1173
    by (intro positive_integral_cong) (simp split: split_indicator)
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1174
  also have "\<dots> = emeasure M (A \<inter> space M)"
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1175
    by simp
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1176
  finally show ?thesis .
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1177
qed
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1178
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1179
lemma positive_integral_add:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1180
  assumes f: "f \<in> borel_measurable M" "AE x in M. 0 \<le> f x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1181
  and g: "g \<in> borel_measurable M" "AE x in M. 0 \<le> g x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1182
  shows "(\<integral>\<^sup>+ x. f x + g x \<partial>M) = integral\<^sup>P M f + integral\<^sup>P M g"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1183
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1184
  have ae: "AE x in M. max 0 (f x) + max 0 (g x) = max 0 (f x + g x)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1185
    using assms by (auto split: split_max simp: ereal_add_nonneg_nonneg)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1186
  have "(\<integral>\<^sup>+ x. f x + g x \<partial>M) = (\<integral>\<^sup>+ x. max 0 (f x + g x) \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1187
    by (simp add: positive_integral_max_0)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1188
  also have "\<dots> = (\<integral>\<^sup>+ x. max 0 (f x) + max 0 (g x) \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1189
    unfolding ae[THEN positive_integral_cong_AE] ..
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1190
  also have "\<dots> = (\<integral>\<^sup>+ x. max 0 (f x) \<partial>M) + (\<integral>\<^sup>+ x. max 0 (g x) \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1191
    using positive_integral_linear[of "\<lambda>x. max 0 (f x)" _ 1 "\<lambda>x. max 0 (g x)"] f g
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1192
    by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1193
  finally show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1194
    by (simp add: positive_integral_max_0)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1195
qed
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1196
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1197
lemma positive_integral_setsum:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1198
  assumes "\<And>i. i\<in>P \<Longrightarrow> f i \<in> borel_measurable M" "\<And>i. i\<in>P \<Longrightarrow> AE x in M. 0 \<le> f i x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1199
  shows "(\<integral>\<^sup>+ x. (\<Sum>i\<in>P. f i x) \<partial>M) = (\<Sum>i\<in>P. integral\<^sup>P M (f i))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1200
proof cases
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1201
  assume f: "finite P"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1202
  from assms have "AE x in M. \<forall>i\<in>P. 0 \<le> f i x" unfolding AE_finite_all[OF f] by auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1203
  from f this assms(1) show ?thesis
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1204
  proof induct
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1205
    case (insert i P)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1206
    then have "f i \<in> borel_measurable M" "AE x in M. 0 \<le> f i x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1207
      "(\<lambda>x. \<Sum>i\<in>P. f i x) \<in> borel_measurable M" "AE x in M. 0 \<le> (\<Sum>i\<in>P. f i x)"
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
  1208
      by (auto intro!: setsum_nonneg)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1209
    from positive_integral_add[OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1210
    show ?case using insert by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1211
  qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1212
qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1213
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1214
lemma positive_integral_Markov_inequality:
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1215
  assumes u: "u \<in> borel_measurable M" "AE x in M. 0 \<le> u x" and "A \<in> sets M" and c: "0 \<le> c"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1216
  shows "(emeasure M) ({x\<in>space M. 1 \<le> c * u x} \<inter> A) \<le> c * (\<integral>\<^sup>+ x. u x * indicator A x \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1217
    (is "(emeasure M) ?A \<le> _ * ?PI")
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1218
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1219
  have "?A \<in> sets M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1220
    using `A \<in> sets M` u by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1221
  hence "(emeasure M) ?A = (\<integral>\<^sup>+ x. indicator ?A x \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1222
    using positive_integral_indicator by simp
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1223
  also have "\<dots> \<le> (\<integral>\<^sup>+ x. c * (u x * indicator A x) \<partial>M)" using u c
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1224
    by (auto intro!: positive_integral_mono_AE
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1225
      simp: indicator_def ereal_zero_le_0_iff)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1226
  also have "\<dots> = c * (\<integral>\<^sup>+ x. u x * indicator A x \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1227
    using assms
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
  1228
    by (auto intro!: positive_integral_cmult simp: ereal_zero_le_0_iff)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1229
  finally show ?thesis .
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1230
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1231
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1232
lemma positive_integral_noteq_infinite:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1233
  assumes g: "g \<in> borel_measurable M" "AE x in M. 0 \<le> g x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1234
  and "integral\<^sup>P M g \<noteq> \<infinity>"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1235
  shows "AE x in M. g x \<noteq> \<infinity>"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1236
proof (rule ccontr)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1237
  assume c: "\<not> (AE x in M. g x \<noteq> \<infinity>)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1238
  have "(emeasure M) {x\<in>space M. g x = \<infinity>} \<noteq> 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1239
    using c g by (auto simp add: AE_iff_null)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1240
  moreover have "0 \<le> (emeasure M) {x\<in>space M. g x = \<infinity>}" using g by (auto intro: measurable_sets)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1241
  ultimately have "0 < (emeasure M) {x\<in>space M. g x = \<infinity>}" by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1242
  then have "\<infinity> = \<infinity> * (emeasure M) {x\<in>space M. g x = \<infinity>}" by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1243
  also have "\<dots> \<le> (\<integral>\<^sup>+x. \<infinity> * indicator {x\<in>space M. g x = \<infinity>} x \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1244
    using g by (subst positive_integral_cmult_indicator) auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1245
  also have "\<dots> \<le> integral\<^sup>P M g"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1246
    using assms by (auto intro!: positive_integral_mono_AE simp: indicator_def)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1247
  finally show False using `integral\<^sup>P M g \<noteq> \<infinity>` by auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1248
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1249
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1250
lemma positive_integral_diff:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1251
  assumes f: "f \<in> borel_measurable M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1252
  and g: "g \<in> borel_measurable M" "AE x in M. 0 \<le> g x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1253
  and fin: "integral\<^sup>P M g \<noteq> \<infinity>"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1254
  and mono: "AE x in M. g x \<le> f x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1255
  shows "(\<integral>\<^sup>+ x. f x - g x \<partial>M) = integral\<^sup>P M f - integral\<^sup>P M g"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1256
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1257
  have diff: "(\<lambda>x. f x - g x) \<in> borel_measurable M" "AE x in M. 0 \<le> f x - g x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1258
    using assms by (auto intro: ereal_diff_positive)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1259
  have pos_f: "AE x in M. 0 \<le> f x" using mono g by auto
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1260
  { fix a b :: ereal assume "0 \<le> a" "a \<noteq> \<infinity>" "0 \<le> b" "a \<le> b" then have "b - a + a = b"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1261
      by (cases rule: ereal2_cases[of a b]) auto }
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1262
  note * = this
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1263
  then have "AE x in M. f x = f x - g x + g x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1264
    using mono positive_integral_noteq_infinite[OF g fin] assms by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1265
  then have **: "integral\<^sup>P M f = (\<integral>\<^sup>+x. f x - g x \<partial>M) + integral\<^sup>P M g"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1266
    unfolding positive_integral_add[OF diff g, symmetric]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1267
    by (rule positive_integral_cong_AE)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1268
  show ?thesis unfolding **
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1269
    using fin positive_integral_positive[of M g]
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1270
    by (cases rule: ereal2_cases[of "\<integral>\<^sup>+ x. f x - g x \<partial>M" "integral\<^sup>P M g"]) auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1271
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1272
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1273
lemma positive_integral_suminf:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1274
  assumes f: "\<And>i. f i \<in> borel_measurable M" "\<And>i. AE x in M. 0 \<le> f i x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1275
  shows "(\<integral>\<^sup>+ x. (\<Sum>i. f i x) \<partial>M) = (\<Sum>i. integral\<^sup>P M (f i))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1276
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1277
  have all_pos: "AE x in M. \<forall>i. 0 \<le> f i x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1278
    using assms by (auto simp: AE_all_countable)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1279
  have "(\<Sum>i. integral\<^sup>P M (f i)) = (SUP n. \<Sum>i<n. integral\<^sup>P M (f i))"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1280
    using positive_integral_positive by (rule suminf_ereal_eq_SUPR)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1281
  also have "\<dots> = (SUP n. \<integral>\<^sup>+x. (\<Sum>i<n. f i x) \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1282
    unfolding positive_integral_setsum[OF f] ..
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1283
  also have "\<dots> = \<integral>\<^sup>+x. (SUP n. \<Sum>i<n. f i x) \<partial>M" using f all_pos
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1284
    by (intro positive_integral_monotone_convergence_SUP_AE[symmetric])
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1285
       (elim AE_mp, auto simp: setsum_nonneg simp del: setsum_lessThan_Suc intro!: AE_I2 setsum_mono3)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1286
  also have "\<dots> = \<integral>\<^sup>+x. (\<Sum>i. f i x) \<partial>M" using all_pos
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1287
    by (intro positive_integral_cong_AE) (auto simp: suminf_ereal_eq_SUPR)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1288
  finally show ?thesis by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1289
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1290
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1291
text {* Fatou's lemma: convergence theorem on limes inferior *}
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1292
lemma positive_integral_lim_INF:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1293
  fixes u :: "nat \<Rightarrow> 'a \<Rightarrow> ereal"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1294
  assumes u: "\<And>i. u i \<in> borel_measurable M" "\<And>i. AE x in M. 0 \<le> u i x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1295
  shows "(\<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M) \<le> liminf (\<lambda>n. integral\<^sup>P M (u n))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1296
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1297
  have pos: "AE x in M. \<forall>i. 0 \<le> u i x" using u by (auto simp: AE_all_countable)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1298
  have "(\<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M) =
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1299
    (SUP n. \<integral>\<^sup>+ x. (INF i:{n..}. u i x) \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1300
    unfolding liminf_SUPR_INFI using pos u
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1301
    by (intro positive_integral_monotone_convergence_SUP_AE)
44937
22c0857b8aab removed further legacy rules from Complete_Lattices
hoelzl
parents: 44928
diff changeset
  1302
       (elim AE_mp, auto intro!: AE_I2 intro: INF_greatest INF_superset_mono)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1303
  also have "\<dots> \<le> liminf (\<lambda>n. integral\<^sup>P M (u n))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1304
    unfolding liminf_SUPR_INFI
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
  1305
    by (auto intro!: SUP_mono exI INF_greatest positive_integral_mono INF_lower)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1306
  finally show ?thesis .
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1307
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1308
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1309
lemma positive_integral_null_set:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1310
  assumes "N \<in> null_sets M" shows "(\<integral>\<^sup>+ x. u x * indicator N x \<partial>M) = 0"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1311
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1312
  have "(\<integral>\<^sup>+ x. u x * indicator N x \<partial>M) = (\<integral>\<^sup>+ x. 0 \<partial>M)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1313
  proof (intro positive_integral_cong_AE AE_I)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1314
    show "{x \<in> space M. u x * indicator N x \<noteq> 0} \<subseteq> N"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1315
      by (auto simp: indicator_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1316
    show "(emeasure M) N = 0" "N \<in> sets M"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1317
      using assms by auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1318
  qed
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1319
  then show ?thesis by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1320
qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1321
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1322
lemma positive_integral_0_iff:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1323
  assumes u: "u \<in> borel_measurable M" and pos: "AE x in M. 0 \<le> u x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1324
  shows "integral\<^sup>P M u = 0 \<longleftrightarrow> emeasure M {x\<in>space M. u x \<noteq> 0} = 0"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1325
    (is "_ \<longleftrightarrow> (emeasure M) ?A = 0")
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1326
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1327
  have u_eq: "(\<integral>\<^sup>+ x. u x * indicator ?A x \<partial>M) = integral\<^sup>P M u"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1328
    by (auto intro!: positive_integral_cong simp: indicator_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1329
  show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1330
  proof
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1331
    assume "(emeasure M) ?A = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1332
    with positive_integral_null_set[of ?A M u] u
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1333
    show "integral\<^sup>P M u = 0" by (simp add: u_eq null_sets_def)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1334
  next
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1335
    { fix r :: ereal and n :: nat assume gt_1: "1 \<le> real n * r"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1336
      then have "0 < real n * r" by (cases r) (auto split: split_if_asm simp: one_ereal_def)
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1337
      then have "0 \<le> r" by (auto simp add: ereal_zero_less_0_iff) }
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1338
    note gt_1 = this
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1339
    assume *: "integral\<^sup>P M u = 0"
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1340
    let ?M = "\<lambda>n. {x \<in> space M. 1 \<le> real (n::nat) * u x}"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1341
    have "0 = (SUP n. (emeasure M) (?M n \<inter> ?A))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1342
    proof -
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1343
      { fix n :: nat
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1344
        from positive_integral_Markov_inequality[OF u pos, of ?A "ereal (real n)"]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1345
        have "(emeasure M) (?M n \<inter> ?A) \<le> 0" unfolding u_eq * using u by simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1346
        moreover have "0 \<le> (emeasure M) (?M n \<inter> ?A)" using u by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1347
        ultimately have "(emeasure M) (?M n \<inter> ?A) = 0" by auto }
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1348
      thus ?thesis by simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1349
    qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1350
    also have "\<dots> = (emeasure M) (\<Union>n. ?M n \<inter> ?A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1351
    proof (safe intro!: SUP_emeasure_incseq)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1352
      fix n show "?M n \<inter> ?A \<in> sets M"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
  1353
        using u by (auto intro!: sets.Int)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1354
    next
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1355
      show "incseq (\<lambda>n. {x \<in> space M. 1 \<le> real n * u x} \<inter> {x \<in> space M. u x \<noteq> 0})"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1356
      proof (safe intro!: incseq_SucI)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1357
        fix n :: nat and x
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1358
        assume *: "1 \<le> real n * u x"
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  1359
        also from gt_1[OF *] have "real n * u x \<le> real (Suc n) * u x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1360
          using `0 \<le> u x` by (auto intro!: ereal_mult_right_mono)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1361
        finally show "1 \<le> real (Suc n) * u x" by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1362
      qed
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1363
    qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1364
    also have "\<dots> = (emeasure M) {x\<in>space M. 0 < u x}"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1365
    proof (safe intro!: arg_cong[where f="(emeasure M)"] dest!: gt_1)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1366
      fix x assume "0 < u x" and [simp, intro]: "x \<in> space M"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1367
      show "x \<in> (\<Union>n. ?M n \<inter> ?A)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1368
      proof (cases "u x")
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1369
        case (real r) with `0 < u x` have "0 < r" by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1370
        obtain j :: nat where "1 / r \<le> real j" using real_arch_simple ..
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1371
        hence "1 / r * r \<le> real j * r" unfolding mult_le_cancel_right using `0 < r` by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1372
        hence "1 \<le> real j * r" using real `0 < r` by auto
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1373
        thus ?thesis using `0 < r` real by (auto simp: one_ereal_def)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1374
      qed (insert `0 < u x`, auto)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1375
    qed auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1376
    finally have "(emeasure M) {x\<in>space M. 0 < u x} = 0" by simp
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1377
    moreover
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1378
    from pos have "AE x in M. \<not> (u x < 0)" by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1379
    then have "(emeasure M) {x\<in>space M. u x < 0} = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1380
      using AE_iff_null[of M] u by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1381
    moreover have "(emeasure M) {x\<in>space M. u x \<noteq> 0} = (emeasure M) {x\<in>space M. u x < 0} + (emeasure M) {x\<in>space M. 0 < u x}"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1382
      using u by (subst plus_emeasure) (auto intro!: arg_cong[where f="emeasure M"])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1383
    ultimately show "(emeasure M) ?A = 0" by simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1384
  qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1385
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1386
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1387
lemma positive_integral_0_iff_AE:
41705
1100512e16d8 add auto support for AE_mp
hoelzl
parents: 41689
diff changeset
  1388
  assumes u: "u \<in> borel_measurable M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1389
  shows "integral\<^sup>P M u = 0 \<longleftrightarrow> (AE x in M. u x \<le> 0)"
41705
1100512e16d8 add auto support for AE_mp
hoelzl
parents: 41689
diff changeset
  1390
proof -
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1391
  have sets: "{x\<in>space M. max 0 (u x) \<noteq> 0} \<in> sets M"
41705
1100512e16d8 add auto support for AE_mp
hoelzl
parents: 41689
diff changeset
  1392
    using u by auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1393
  from positive_integral_0_iff[of "\<lambda>x. max 0 (u x)"]
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1394
  have "integral\<^sup>P M u = 0 \<longleftrightarrow> (AE x in M. max 0 (u x) = 0)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1395
    unfolding positive_integral_max_0
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1396
    using AE_iff_null[OF sets] u by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1397
  also have "\<dots> \<longleftrightarrow> (AE x in M. u x \<le> 0)" by (auto split: split_max)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1398
  finally show ?thesis .
41705
1100512e16d8 add auto support for AE_mp
hoelzl
parents: 41689
diff changeset
  1399
qed
1100512e16d8 add auto support for AE_mp
hoelzl
parents: 41689
diff changeset
  1400
50001
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49800
diff changeset
  1401
lemma AE_iff_positive_integral: 
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1402
  "{x\<in>space M. P x} \<in> sets M \<Longrightarrow> (AE x in M. P x) \<longleftrightarrow> integral\<^sup>P M (indicator {x. \<not> P x}) = 0"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
  1403
  by (subst positive_integral_0_iff_AE) (auto simp: one_ereal_def zero_ereal_def
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
  1404
    sets.sets_Collect_neg indicator_def[abs_def] measurable_If)
50001
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49800
diff changeset
  1405
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1406
lemma positive_integral_const_If:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1407
  "(\<integral>\<^sup>+x. a \<partial>M) = (if 0 \<le> a then a * (emeasure M) (space M) else 0)"
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  1408
  by (auto intro!: positive_integral_0_iff_AE[THEN iffD2])
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  1409
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1410
lemma positive_integral_subalgebra:
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  1411
  assumes f: "f \<in> borel_measurable N" "\<And>x. 0 \<le> f x"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1412
  and N: "sets N \<subseteq> sets M" "space N = space M" "\<And>A. A \<in> sets N \<Longrightarrow> emeasure N A = emeasure M A"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1413
  shows "integral\<^sup>P N f = integral\<^sup>P M f"
39092
98de40859858 move lemmas to correct theory files
hoelzl
parents: 38705
diff changeset
  1414
proof -
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  1415
  have [simp]: "\<And>f :: 'a \<Rightarrow> ereal. f \<in> borel_measurable N \<Longrightarrow> f \<in> borel_measurable M"
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  1416
    using N by (auto simp: measurable_def)
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  1417
  have [simp]: "\<And>P. (AE x in N. P x) \<Longrightarrow> (AE x in M. P x)"
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  1418
    using N by (auto simp add: eventually_ae_filter null_sets_def)
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  1419
  have [simp]: "\<And>A. A \<in> sets N \<Longrightarrow> A \<in> sets M"
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  1420
    using N by auto
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  1421
  from f show ?thesis
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  1422
    apply induct
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  1423
    apply (simp_all add: positive_integral_add positive_integral_cmult positive_integral_monotone_convergence_SUP N)
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  1424
    apply (auto intro!: positive_integral_cong cong: positive_integral_cong simp: N(2)[symmetric])
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  1425
    done
39092
98de40859858 move lemmas to correct theory files
hoelzl
parents: 38705
diff changeset
  1426
qed
98de40859858 move lemmas to correct theory files
hoelzl
parents: 38705
diff changeset
  1427
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1428
lemma positive_integral_nat_function:
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1429
  fixes f :: "'a \<Rightarrow> nat"
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1430
  assumes "f \<in> measurable M (count_space UNIV)"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1431
  shows "(\<integral>\<^sup>+x. ereal (of_nat (f x)) \<partial>M) = (\<Sum>t. emeasure M {x\<in>space M. t < f x})"
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1432
proof -
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1433
  def F \<equiv> "\<lambda>i. {x\<in>space M. i < f x}"
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1434
  with assms have [measurable]: "\<And>i. F i \<in> sets M"
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1435
    by auto
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1436
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1437
  { fix x assume "x \<in> space M"
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1438
    have "(\<lambda>i. if i < f x then 1 else 0) sums (of_nat (f x)::real)"
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1439
      using sums_If_finite[of "\<lambda>i. i < f x" "\<lambda>_. 1::real"] by simp
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1440
    then have "(\<lambda>i. ereal(if i < f x then 1 else 0)) sums (ereal(of_nat(f x)))"
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1441
      unfolding sums_ereal .
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1442
    moreover have "\<And>i. ereal (if i < f x then 1 else 0) = indicator (F i) x"
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1443
      using `x \<in> space M` by (simp add: one_ereal_def F_def)
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1444
    ultimately have "ereal(of_nat(f x)) = (\<Sum>i. indicator (F i) x)"
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1445
      by (simp add: sums_iff) }
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1446
  then have "(\<integral>\<^sup>+x. ereal (of_nat (f x)) \<partial>M) = (\<integral>\<^sup>+x. (\<Sum>i. indicator (F i) x) \<partial>M)"
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1447
    by (simp cong: positive_integral_cong)
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1448
  also have "\<dots> = (\<Sum>i. emeasure M (F i))"
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1449
    by (simp add: positive_integral_suminf)
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1450
  finally show ?thesis
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1451
    by (simp add: F_def)
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1452
qed
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1453
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
  1454
section "Lebesgue Integral"
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
  1455
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1456
definition integrable :: "'a measure \<Rightarrow> ('a \<Rightarrow> real) \<Rightarrow> bool" where
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1457
  "integrable M f \<longleftrightarrow> f \<in> borel_measurable M \<and>
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1458
    (\<integral>\<^sup>+ x. ereal (f x) \<partial>M) \<noteq> \<infinity> \<and> (\<integral>\<^sup>+ x. ereal (- f x) \<partial>M) \<noteq> \<infinity>"
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
  1459
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1460
lemma borel_measurable_integrable[measurable_dest]:
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1461
  "integrable M f \<Longrightarrow> f \<in> borel_measurable M"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1462
  by (auto simp: integrable_def)
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1463
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1464
lemma integrableD[dest]:
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1465
  assumes "integrable M f"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1466
  shows "f \<in> borel_measurable M" "(\<integral>\<^sup>+ x. ereal (f x) \<partial>M) \<noteq> \<infinity>" "(\<integral>\<^sup>+ x. ereal (- f x) \<partial>M) \<noteq> \<infinity>"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1467
  using assms unfolding integrable_def by auto
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
  1468
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1469
definition lebesgue_integral :: "'a measure \<Rightarrow> ('a \<Rightarrow> real) \<Rightarrow> real" ("integral\<^sup>L") where
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1470
  "integral\<^sup>L M f = real ((\<integral>\<^sup>+ x. ereal (f x) \<partial>M)) - real ((\<integral>\<^sup>+ x. ereal (- f x) \<partial>M))"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1471
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1472
syntax
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1473
  "_lebesgue_integral" :: "pttrn \<Rightarrow> real \<Rightarrow> 'a measure \<Rightarrow> real" ("\<integral> _. _ \<partial>_" [60,61] 110)
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1474
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1475
translations
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1476
  "\<integral> x. f \<partial>M" == "CONST lebesgue_integral M (%x. f)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1477
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1478
lemma integrableE:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1479
  assumes "integrable M f"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1480
  obtains r q where
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1481
    "(\<integral>\<^sup>+x. ereal (f x)\<partial>M) = ereal r"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1482
    "(\<integral>\<^sup>+x. ereal (-f x)\<partial>M) = ereal q"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1483
    "f \<in> borel_measurable M" "integral\<^sup>L M f = r - q"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1484
  using assms unfolding integrable_def lebesgue_integral_def
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1485
  using positive_integral_positive[of M "\<lambda>x. ereal (f x)"]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1486
  using positive_integral_positive[of M "\<lambda>x. ereal (-f x)"]
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1487
  by (cases rule: ereal2_cases[of "(\<integral>\<^sup>+x. ereal (-f x)\<partial>M)" "(\<integral>\<^sup>+x. ereal (f x)\<partial>M)"]) auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1488
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1489
lemma integral_cong:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1490
  assumes "\<And>x. x \<in> space M \<Longrightarrow> f x = g x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1491
  shows "integral\<^sup>L M f = integral\<^sup>L M g"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1492
  using assms by (simp cong: positive_integral_cong add: lebesgue_integral_def)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1493
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1494
lemma integral_cong_AE:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1495
  assumes cong: "AE x in M. f x = g x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1496
  shows "integral\<^sup>L M f = integral\<^sup>L M g"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1497
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1498
  have *: "AE x in M. ereal (f x) = ereal (g x)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1499
    "AE x in M. ereal (- f x) = ereal (- g x)" using cong by auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1500
  show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1501
    unfolding *[THEN positive_integral_cong_AE] lebesgue_integral_def ..
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1502
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1503
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1504
lemma integrable_cong_AE:
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  1505
  assumes borel: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1506
  assumes "AE x in M. f x = g x"
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  1507
  shows "integrable M f = integrable M g"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  1508
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1509
  have "(\<integral>\<^sup>+ x. ereal (f x) \<partial>M) = (\<integral>\<^sup>+ x. ereal (g x) \<partial>M)"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1510
    "(\<integral>\<^sup>+ x. ereal (- f x) \<partial>M) = (\<integral>\<^sup>+ x. ereal (- g x) \<partial>M)"
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  1511
    using assms by (auto intro!: positive_integral_cong_AE)
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  1512
  with assms show ?thesis
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  1513
    by (auto simp: integrable_def)
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  1514
qed
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  1515
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1516
lemma integrable_cong:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1517
  "(\<And>x. x \<in> space M \<Longrightarrow> f x = g x) \<Longrightarrow> integrable M f \<longleftrightarrow> integrable M g"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1518
  by (simp cong: positive_integral_cong measurable_cong add: integrable_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1519
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1520
lemma integral_mono_AE:
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1521
  assumes fg: "integrable M f" "integrable M g"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1522
  and mono: "AE t in M. f t \<le> g t"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1523
  shows "integral\<^sup>L M f \<le> integral\<^sup>L M g"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1524
proof -
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1525
  have "AE x in M. ereal (f x) \<le> ereal (g x)"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1526
    using mono by auto
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1527
  moreover have "AE x in M. ereal (- g x) \<le> ereal (- f x)"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1528
    using mono by auto
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1529
  ultimately show ?thesis using fg
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1530
    by (auto intro!: add_mono positive_integral_mono_AE real_of_ereal_positive_mono
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53374
diff changeset
  1531
             simp: positive_integral_positive lebesgue_integral_def algebra_simps)
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1532
qed
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1533
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1534
lemma integral_mono:
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1535
  assumes "integrable M f" "integrable M g" "\<And>t. t \<in> space M \<Longrightarrow> f t \<le> g t"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1536
  shows "integral\<^sup>L M f \<le> integral\<^sup>L M g"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1537
  using assms by (auto intro: integral_mono_AE)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1538
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1539
lemma positive_integral_eq_integral:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1540
  assumes f: "integrable M f"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1541
  assumes nonneg: "AE x in M. 0 \<le> f x" 
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1542
  shows "(\<integral>\<^sup>+ x. ereal (f x) \<partial>M) = integral\<^sup>L M f"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1543
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1544
  have "(\<integral>\<^sup>+ x. max 0 (ereal (- f x)) \<partial>M) = (\<integral>\<^sup>+ x. 0 \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1545
    using nonneg by (intro positive_integral_cong_AE) (auto split: split_max)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1546
  with f positive_integral_positive show ?thesis
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1547
    by (cases "\<integral>\<^sup>+ x. ereal (f x) \<partial>M")
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1548
       (auto simp add: lebesgue_integral_def positive_integral_max_0 integrable_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1549
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1550
  
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1551
lemma integral_eq_positive_integral:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1552
  assumes f: "\<And>x. 0 \<le> f x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1553
  shows "integral\<^sup>L M f = real (\<integral>\<^sup>+ x. ereal (f x) \<partial>M)"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1554
proof -
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1555
  { fix x have "max 0 (ereal (- f x)) = 0" using f[of x] by (simp split: split_max) }
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1556
  then have "0 = (\<integral>\<^sup>+ x. max 0 (ereal (- f x)) \<partial>M)" by simp
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1557
  also have "\<dots> = (\<integral>\<^sup>+ x. ereal (- f x) \<partial>M)" unfolding positive_integral_max_0 ..
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1558
  finally show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1559
    unfolding lebesgue_integral_def by simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1560
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1561
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1562
lemma integral_minus[intro, simp]:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1563
  assumes "integrable M f"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1564
  shows "integrable M (\<lambda>x. - f x)" "(\<integral>x. - f x \<partial>M) = - integral\<^sup>L M f"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1565
  using assms by (auto simp: integrable_def lebesgue_integral_def)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1566
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1567
lemma integral_minus_iff[simp]:
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  1568
  "integrable M (\<lambda>x. - f x) \<longleftrightarrow> integrable M f"
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  1569
proof
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  1570
  assume "integrable M (\<lambda>x. - f x)"
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  1571
  then have "integrable M (\<lambda>x. - (- f x))"
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  1572
    by (rule integral_minus)
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  1573
  then show "integrable M f" by simp
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  1574
qed (rule integral_minus)
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  1575
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1576
lemma integral_of_positive_diff:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1577
  assumes integrable: "integrable M u" "integrable M v"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1578
  and f_def: "\<And>x. f x = u x - v x" and pos: "\<And>x. 0 \<le> u x" "\<And>x. 0 \<le> v x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1579
  shows "integrable M f" and "integral\<^sup>L M f = integral\<^sup>L M u - integral\<^sup>L M v"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1580
proof -
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1581
  let ?f = "\<lambda>x. max 0 (ereal (f x))"
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1582
  let ?mf = "\<lambda>x. max 0 (ereal (- f x))"
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1583
  let ?u = "\<lambda>x. max 0 (ereal (u x))"
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1584
  let ?v = "\<lambda>x. max 0 (ereal (v x))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1585
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1586
  from borel_measurable_diff[of u M v] integrable
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1587
  have f_borel: "?f \<in> borel_measurable M" and
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1588
    mf_borel: "?mf \<in> borel_measurable M" and
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1589
    v_borel: "?v \<in> borel_measurable M" and
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1590
    u_borel: "?u \<in> borel_measurable M" and
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1591
    "f \<in> borel_measurable M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1592
    by (auto simp: f_def[symmetric] integrable_def)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1593
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1594
  have "(\<integral>\<^sup>+ x. ereal (u x - v x) \<partial>M) \<le> integral\<^sup>P M ?u"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1595
    using pos by (auto intro!: positive_integral_mono simp: positive_integral_max_0)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1596
  moreover have "(\<integral>\<^sup>+ x. ereal (v x - u x) \<partial>M) \<le> integral\<^sup>P M ?v"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1597
    using pos by (auto intro!: positive_integral_mono simp: positive_integral_max_0)
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1598
  ultimately show f: "integrable M f"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1599
    using `integrable M u` `integrable M v` `f \<in> borel_measurable M`
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1600
    by (auto simp: integrable_def f_def positive_integral_max_0)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1601
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1602
  have "\<And>x. ?u x + ?mf x = ?v x + ?f x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1603
    unfolding f_def using pos by (simp split: split_max)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1604
  then have "(\<integral>\<^sup>+ x. ?u x + ?mf x \<partial>M) = (\<integral>\<^sup>+ x. ?v x + ?f x \<partial>M)" by simp
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1605
  then have "real (integral\<^sup>P M ?u + integral\<^sup>P M ?mf) =
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1606
      real (integral\<^sup>P M ?v + integral\<^sup>P M ?f)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1607
    using positive_integral_add[OF u_borel _ mf_borel]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1608
    using positive_integral_add[OF v_borel _ f_borel]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1609
    by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1610
  then show "integral\<^sup>L M f = integral\<^sup>L M u - integral\<^sup>L M v"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1611
    unfolding positive_integral_max_0
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1612
    unfolding pos[THEN integral_eq_positive_integral]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1613
    using integrable f by (auto elim!: integrableE)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1614
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1615
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1616
lemma integral_linear:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1617
  assumes "integrable M f" "integrable M g" and "0 \<le> a"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1618
  shows "integrable M (\<lambda>t. a * f t + g t)"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1619
  and "(\<integral> t. a * f t + g t \<partial>M) = a * integral\<^sup>L M f + integral\<^sup>L M g" (is ?EQ)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1620
proof -
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1621
  let ?f = "\<lambda>x. max 0 (ereal (f x))"
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1622
  let ?g = "\<lambda>x. max 0 (ereal (g x))"
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1623
  let ?mf = "\<lambda>x. max 0 (ereal (- f x))"
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1624
  let ?mg = "\<lambda>x. max 0 (ereal (- g x))"
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1625
  let ?p = "\<lambda>t. max 0 (a * f t) + max 0 (g t)"
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1626
  let ?n = "\<lambda>t. max 0 (- (a * f t)) + max 0 (- g t)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1627
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1628
  from assms have linear:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1629
    "(\<integral>\<^sup>+ x. ereal a * ?f x + ?g x \<partial>M) = ereal a * integral\<^sup>P M ?f + integral\<^sup>P M ?g"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1630
    "(\<integral>\<^sup>+ x. ereal a * ?mf x + ?mg x \<partial>M) = ereal a * integral\<^sup>P M ?mf + integral\<^sup>P M ?mg"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1631
    by (auto intro!: positive_integral_linear simp: integrable_def)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1632
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1633
  have *: "(\<integral>\<^sup>+x. ereal (- ?p x) \<partial>M) = 0" "(\<integral>\<^sup>+x. ereal (- ?n x) \<partial>M) = 0"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1634
    using `0 \<le> a` assms by (auto simp: positive_integral_0_iff_AE integrable_def)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1635
  have **: "\<And>x. ereal a * ?f x + ?g x = max 0 (ereal (?p x))"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1636
           "\<And>x. ereal a * ?mf x + ?mg x = max 0 (ereal (?n x))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1637
    using `0 \<le> a` by (auto split: split_max simp: zero_le_mult_iff mult_le_0_iff)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1638
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1639
  have "integrable M ?p" "integrable M ?n"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1640
      "\<And>t. a * f t + g t = ?p t - ?n t" "\<And>t. 0 \<le> ?p t" "\<And>t. 0 \<le> ?n t"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1641
    using linear assms unfolding integrable_def ** *
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1642
    by (auto simp: positive_integral_max_0)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1643
  note diff = integral_of_positive_diff[OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1644
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1645
  show "integrable M (\<lambda>t. a * f t + g t)" by (rule diff)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1646
  from assms linear show ?EQ
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1647
    unfolding diff(2) ** positive_integral_max_0
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1648
    unfolding lebesgue_integral_def *
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1649
    by (auto elim!: integrableE simp: field_simps)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1650
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1651
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1652
lemma integral_add[simp, intro]:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1653
  assumes "integrable M f" "integrable M g"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1654
  shows "integrable M (\<lambda>t. f t + g t)"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1655
  and "(\<integral> t. f t + g t \<partial>M) = integral\<^sup>L M f + integral\<^sup>L M g"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1656
  using assms integral_linear[where a=1] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1657
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1658
lemma integral_zero[simp, intro]:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1659
  shows "integrable M (\<lambda>x. 0)" "(\<integral> x.0 \<partial>M) = 0"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1660
  unfolding integrable_def lebesgue_integral_def
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
  1661
  by auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1662
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1663
lemma lebesgue_integral_uminus:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1664
    "(\<integral>x. - f x \<partial>M) = - integral\<^sup>L M f"
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1665
  unfolding lebesgue_integral_def by simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1666
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1667
lemma lebesgue_integral_cmult_nonneg:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1668
  assumes f: "f \<in> borel_measurable M" and "0 \<le> c"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1669
  shows "(\<integral>x. c * f x \<partial>M) = c * integral\<^sup>L M f"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1670
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1671
  { have "real (ereal c * integral\<^sup>P M (\<lambda>x. max 0 (ereal (f x)))) =
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1672
      real (integral\<^sup>P M (\<lambda>x. ereal c * max 0 (ereal (f x))))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1673
      using f `0 \<le> c` by (subst positive_integral_cmult) auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1674
    also have "\<dots> = real (integral\<^sup>P M (\<lambda>x. max 0 (ereal (c * f x))))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1675
      using `0 \<le> c` by (auto intro!: arg_cong[where f=real] positive_integral_cong simp: max_def zero_le_mult_iff)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1676
    finally have "real (integral\<^sup>P M (\<lambda>x. ereal (c * f x))) = c * real (integral\<^sup>P M (\<lambda>x. ereal (f x)))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1677
      by (simp add: positive_integral_max_0) }
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1678
  moreover
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1679
  { have "real (ereal c * integral\<^sup>P M (\<lambda>x. max 0 (ereal (- f x)))) =
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1680
      real (integral\<^sup>P M (\<lambda>x. ereal c * max 0 (ereal (- f x))))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1681
      using f `0 \<le> c` by (subst positive_integral_cmult) auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1682
    also have "\<dots> = real (integral\<^sup>P M (\<lambda>x. max 0 (ereal (- c * f x))))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1683
      using `0 \<le> c` by (auto intro!: arg_cong[where f=real] positive_integral_cong simp: max_def mult_le_0_iff)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1684
    finally have "real (integral\<^sup>P M (\<lambda>x. ereal (- c * f x))) = c * real (integral\<^sup>P M (\<lambda>x. ereal (- f x)))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1685
      by (simp add: positive_integral_max_0) }
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1686
  ultimately show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1687
    by (simp add: lebesgue_integral_def field_simps)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1688
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1689
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1690
lemma lebesgue_integral_cmult:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1691
  assumes f: "f \<in> borel_measurable M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1692
  shows "(\<integral>x. c * f x \<partial>M) = c * integral\<^sup>L M f"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1693
proof (cases rule: linorder_le_cases)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1694
  assume "0 \<le> c" with f show ?thesis by (rule lebesgue_integral_cmult_nonneg)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1695
next
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1696
  assume "c \<le> 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1697
  with lebesgue_integral_cmult_nonneg[OF f, of "-c"]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1698
  show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1699
    by (simp add: lebesgue_integral_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1700
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1701
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1702
lemma lebesgue_integral_multc:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1703
  "f \<in> borel_measurable M \<Longrightarrow> (\<integral>x. f x * c \<partial>M) = integral\<^sup>L M f * c"
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1704
  using lebesgue_integral_cmult[of f M c] by (simp add: ac_simps)
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1705
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1706
lemma integral_multc:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1707
  "integrable M f \<Longrightarrow> (\<integral> x. f x * c \<partial>M) = integral\<^sup>L M f * c"
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1708
  by (simp add: lebesgue_integral_multc)
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1709
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1710
lemma integral_cmult[simp, intro]:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1711
  assumes "integrable M f"
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1712
  shows "integrable M (\<lambda>t. a * f t)" (is ?P)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1713
  and "(\<integral> t. a * f t \<partial>M) = a * integral\<^sup>L M f" (is ?I)
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1714
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1715
  have "integrable M (\<lambda>t. a * f t) \<and> (\<integral> t. a * f t \<partial>M) = a * integral\<^sup>L M f"
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1716
  proof (cases rule: le_cases)
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1717
    assume "0 \<le> a" show ?thesis
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1718
      using integral_linear[OF assms integral_zero(1) `0 \<le> a`]
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1719
      by simp
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1720
  next
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1721
    assume "a \<le> 0" hence "0 \<le> - a" by auto
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1722
    have *: "\<And>t. - a * t + 0 = (-a) * t" by simp
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1723
    show ?thesis using integral_linear[OF assms integral_zero(1) `0 \<le> - a`]
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1724
        integral_minus(1)[of M "\<lambda>t. - a * f t"]
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1725
      unfolding * integral_zero by simp
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1726
  qed
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1727
  thus ?P ?I by auto
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1728
qed
41096
843c40bbc379 integral over setprod
hoelzl
parents: 41095
diff changeset
  1729
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1730
lemma integral_diff[simp, intro]:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1731
  assumes f: "integrable M f" and g: "integrable M g"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1732
  shows "integrable M (\<lambda>t. f t - g t)"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1733
  and "(\<integral> t. f t - g t \<partial>M) = integral\<^sup>L M f - integral\<^sup>L M g"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1734
  using integral_add[OF f integral_minus(1)[OF g]]
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53374
diff changeset
  1735
  unfolding integral_minus(2)[OF g]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1736
  by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1737
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1738
lemma integral_indicator[simp, intro]:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1739
  assumes "A \<in> sets M" and "(emeasure M) A \<noteq> \<infinity>"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1740
  shows "integral\<^sup>L M (indicator A) = real (emeasure M A)" (is ?int)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1741
  and "integrable M (indicator A)" (is ?able)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1742
proof -
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1743
  from `A \<in> sets M` have *:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1744
    "\<And>x. ereal (indicator A x) = indicator A x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1745
    "(\<integral>\<^sup>+x. ereal (- indicator A x) \<partial>M) = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1746
    by (auto split: split_indicator simp: positive_integral_0_iff_AE one_ereal_def)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1747
  show ?int ?able
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1748
    using assms unfolding lebesgue_integral_def integrable_def
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
  1749
    by (auto simp: *)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1750
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1751
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1752
lemma integral_cmul_indicator:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1753
  assumes "A \<in> sets M" and "c \<noteq> 0 \<Longrightarrow> (emeasure M) A \<noteq> \<infinity>"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1754
  shows "integrable M (\<lambda>x. c * indicator A x)" (is ?P)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1755
  and "(\<integral>x. c * indicator A x \<partial>M) = c * real ((emeasure M) A)" (is ?I)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1756
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1757
  show ?P
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1758
  proof (cases "c = 0")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1759
    case False with assms show ?thesis by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1760
  qed simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1761
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1762
  show ?I
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1763
  proof (cases "c = 0")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1764
    case False with assms show ?thesis by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1765
  qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1766
qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1767
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1768
lemma integral_setsum[simp, intro]:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1769
  assumes "\<And>n. n \<in> S \<Longrightarrow> integrable M (f n)"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1770
  shows "(\<integral>x. (\<Sum> i \<in> S. f i x) \<partial>M) = (\<Sum> i \<in> S. integral\<^sup>L M (f i))" (is "?int S")
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1771
    and "integrable M (\<lambda>x. \<Sum> i \<in> S. f i x)" (is "?I S")
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1772
proof -
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1773
  have "?int S \<and> ?I S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1774
  proof (cases "finite S")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1775
    assume "finite S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1776
    from this assms show ?thesis by (induct S) simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1777
  qed simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1778
  thus "?int S" and "?I S" by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1779
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1780
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1781
lemma integrable_bound:
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1782
  assumes "integrable M f" and f: "AE x in M. \<bar>g x\<bar> \<le> f x"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1783
  assumes borel: "g \<in> borel_measurable M"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1784
  shows "integrable M g"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1785
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1786
  have "(\<integral>\<^sup>+ x. ereal (g x) \<partial>M) \<le> (\<integral>\<^sup>+ x. ereal \<bar>g x\<bar> \<partial>M)"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1787
    by (auto intro!: positive_integral_mono)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1788
  also have "\<dots> \<le> (\<integral>\<^sup>+ x. ereal (f x) \<partial>M)"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1789
    using f by (auto intro!: positive_integral_mono_AE)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1790
  also have "\<dots> < \<infinity>"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1791
    using `integrable M f` unfolding integrable_def by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1792
  finally have pos: "(\<integral>\<^sup>+ x. ereal (g x) \<partial>M) < \<infinity>" .
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1793
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1794
  have "(\<integral>\<^sup>+ x. ereal (- g x) \<partial>M) \<le> (\<integral>\<^sup>+ x. ereal (\<bar>g x\<bar>) \<partial>M)"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1795
    by (auto intro!: positive_integral_mono)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1796
  also have "\<dots> \<le> (\<integral>\<^sup>+ x. ereal (f x) \<partial>M)"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1797
    using f by (auto intro!: positive_integral_mono_AE)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1798
  also have "\<dots> < \<infinity>"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1799
    using `integrable M f` unfolding integrable_def by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1800
  finally have neg: "(\<integral>\<^sup>+ x. ereal (- g x) \<partial>M) < \<infinity>" .
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1801
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1802
  from neg pos borel show ?thesis
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1803
    unfolding integrable_def by auto
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1804
qed
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1805
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1806
lemma integrable_abs:
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1807
  assumes f[measurable]: "integrable M f"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1808
  shows "integrable M (\<lambda> x. \<bar>f x\<bar>)"
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
  1809
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1810
  from assms have *: "(\<integral>\<^sup>+x. ereal (- \<bar>f x\<bar>)\<partial>M) = 0"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1811
    "\<And>x. ereal \<bar>f x\<bar> = max 0 (ereal (f x)) + max 0 (ereal (- f x))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1812
    by (auto simp: integrable_def positive_integral_0_iff_AE split: split_max)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1813
  with assms show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1814
    by (simp add: positive_integral_add positive_integral_max_0 integrable_def)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1815
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1816
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1817
lemma integral_subalgebra:
41545
9c869baf1c66 tuned formalization of subalgebra
hoelzl
parents: 41544
diff changeset
  1818
  assumes borel: "f \<in> borel_measurable N"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1819
  and N: "sets N \<subseteq> sets M" "space N = space M" "\<And>A. A \<in> sets N \<Longrightarrow> emeasure N A = emeasure M A"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1820
  shows "integrable N f \<longleftrightarrow> integrable M f" (is ?P)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1821
    and "integral\<^sup>L N f = integral\<^sup>L M f" (is ?I)
41545
9c869baf1c66 tuned formalization of subalgebra
hoelzl
parents: 41544
diff changeset
  1822
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1823
  have "(\<integral>\<^sup>+ x. max 0 (ereal (f x)) \<partial>N) = (\<integral>\<^sup>+ x. max 0 (ereal (f x)) \<partial>M)"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1824
       "(\<integral>\<^sup>+ x. max 0 (ereal (- f x)) \<partial>N) = (\<integral>\<^sup>+ x. max 0 (ereal (- f x)) \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1825
    using borel by (auto intro!: positive_integral_subalgebra N)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1826
  moreover have "f \<in> borel_measurable M \<longleftrightarrow> f \<in> borel_measurable N"
41545
9c869baf1c66 tuned formalization of subalgebra
hoelzl
parents: 41544
diff changeset
  1827
    using assms unfolding measurable_def by auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1828
  ultimately show ?P ?I
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1829
    by (auto simp: integrable_def lebesgue_integral_def positive_integral_max_0)
41545
9c869baf1c66 tuned formalization of subalgebra
hoelzl
parents: 41544
diff changeset
  1830
qed
9c869baf1c66 tuned formalization of subalgebra
hoelzl
parents: 41544
diff changeset
  1831
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1832
lemma lebesgue_integral_nonneg:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1833
  assumes ae: "(AE x in M. 0 \<le> f x)" shows "0 \<le> integral\<^sup>L M f"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1834
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1835
  have "(\<integral>\<^sup>+x. max 0 (ereal (- f x)) \<partial>M) = (\<integral>\<^sup>+x. 0 \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1836
    using ae by (intro positive_integral_cong_AE) (auto simp: max_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1837
  then show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1838
    by (auto simp: lebesgue_integral_def positive_integral_max_0
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1839
             intro!: real_of_ereal_pos positive_integral_positive)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1840
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1841
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1842
lemma integrable_abs_iff:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1843
  "f \<in> borel_measurable M \<Longrightarrow> integrable M (\<lambda> x. \<bar>f x\<bar>) \<longleftrightarrow> integrable M f"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1844
  by (auto intro!: integrable_bound[where g=f] integrable_abs)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1845
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1846
lemma integrable_max:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1847
  assumes int: "integrable M f" "integrable M g"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1848
  shows "integrable M (\<lambda> x. max (f x) (g x))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1849
proof (rule integrable_bound)
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1850
  show "integrable M (\<lambda>x. \<bar>f x\<bar> + \<bar>g x\<bar>)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1851
    using int by (simp add: integrable_abs)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1852
  show "(\<lambda>x. max (f x) (g x)) \<in> borel_measurable M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1853
    using int unfolding integrable_def by auto
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1854
qed auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1855
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1856
lemma integrable_min:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1857
  assumes int: "integrable M f" "integrable M g"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1858
  shows "integrable M (\<lambda> x. min (f x) (g x))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1859
proof (rule integrable_bound)
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1860
  show "integrable M (\<lambda>x. \<bar>f x\<bar> + \<bar>g x\<bar>)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1861
    using int by (simp add: integrable_abs)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1862
  show "(\<lambda>x. min (f x) (g x)) \<in> borel_measurable M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1863
    using int unfolding integrable_def by auto
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1864
qed auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1865
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1866
lemma integral_triangle_inequality:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1867
  assumes "integrable M f"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1868
  shows "\<bar>integral\<^sup>L M f\<bar> \<le> (\<integral>x. \<bar>f x\<bar> \<partial>M)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1869
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1870
  have "\<bar>integral\<^sup>L M f\<bar> = max (integral\<^sup>L M f) (- integral\<^sup>L M f)" by auto
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1871
  also have "\<dots> \<le> (\<integral>x. \<bar>f x\<bar> \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1872
      using assms integral_minus(2)[of M f, symmetric]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1873
      by (auto intro!: integral_mono integrable_abs simp del: integral_minus)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1874
  finally show ?thesis .
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
  1875
qed
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
  1876
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1877
lemma integrable_nonneg:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1878
  assumes f: "f \<in> borel_measurable M" "AE x in M. 0 \<le> f x" "(\<integral>\<^sup>+ x. f x \<partial>M) \<noteq> \<infinity>"
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1879
  shows "integrable M f"
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1880
  unfolding integrable_def
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1881
proof (intro conjI f)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1882
  have "(\<integral>\<^sup>+ x. ereal (- f x) \<partial>M) = 0"
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1883
    using f by (subst positive_integral_0_iff_AE) auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1884
  then show "(\<integral>\<^sup>+ x. ereal (- f x) \<partial>M) \<noteq> \<infinity>" by simp
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1885
qed
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  1886
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1887
lemma integral_positive:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1888
  assumes "integrable M f" "\<And>x. x \<in> space M \<Longrightarrow> 0 \<le> f x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1889
  shows "0 \<le> integral\<^sup>L M f"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1890
proof -
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
  1891
  have "0 = (\<integral>x. 0 \<partial>M)" by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1892
  also have "\<dots> \<le> integral\<^sup>L M f"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1893
    using assms by (rule integral_mono[OF integral_zero(1)])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1894
  finally show ?thesis .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1895
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1896
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1897
lemma integral_monotone_convergence_pos:
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1898
  assumes i: "\<And>i. integrable M (f i)" and mono: "AE x in M. mono (\<lambda>n. f n x)"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1899
    and pos: "\<And>i. AE x in M. 0 \<le> f i x"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1900
    and lim: "AE x in M. (\<lambda>i. f i x) ----> u x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1901
    and ilim: "(\<lambda>i. integral\<^sup>L M (f i)) ----> x"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1902
    and u: "u \<in> borel_measurable M"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1903
  shows "integrable M u"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1904
  and "integral\<^sup>L M u = x"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1905
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1906
  have "(\<integral>\<^sup>+ x. ereal (u x) \<partial>M) = (SUP n. (\<integral>\<^sup>+ x. ereal (f n x) \<partial>M))"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1907
  proof (subst positive_integral_monotone_convergence_SUP_AE[symmetric])
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1908
    fix i
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1909
    from mono pos show "AE x in M. ereal (f i x) \<le> ereal (f (Suc i) x) \<and> 0 \<le> ereal (f i x)"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1910
      by eventually_elim (auto simp: mono_def)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1911
    show "(\<lambda>x. ereal (f i x)) \<in> borel_measurable M"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1912
      using i by auto
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1913
  next
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1914
    show "(\<integral>\<^sup>+ x. ereal (u x) \<partial>M) = \<integral>\<^sup>+ x. (SUP i. ereal (f i x)) \<partial>M"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1915
      apply (rule positive_integral_cong_AE)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1916
      using lim mono
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1917
      by eventually_elim (simp add: SUP_eq_LIMSEQ[THEN iffD2])
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1918
  qed
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1919
  also have "\<dots> = ereal x"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1920
    using mono i unfolding positive_integral_eq_integral[OF i pos]
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1921
    by (subst SUP_eq_LIMSEQ) (auto simp: mono_def intro!: integral_mono_AE ilim)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1922
  finally have "(\<integral>\<^sup>+ x. ereal (u x) \<partial>M) = ereal x" .
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1923
  moreover have "(\<integral>\<^sup>+ x. ereal (- u x) \<partial>M) = 0"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1924
  proof (subst positive_integral_0_iff_AE)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1925
    show "(\<lambda>x. ereal (- u x)) \<in> borel_measurable M"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1926
      using u by auto
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1927
    from mono pos[of 0] lim show "AE x in M. ereal (- u x) \<le> 0"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1928
    proof eventually_elim
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1929
      fix x assume "mono (\<lambda>n. f n x)" "0 \<le> f 0 x" "(\<lambda>i. f i x) ----> u x"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1930
      then show "ereal (- u x) \<le> 0"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1931
        using incseq_le[of "\<lambda>n. f n x" "u x" 0] by (simp add: mono_def incseq_def)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1932
    qed
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1933
  qed
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1934
  ultimately show "integrable M u" "integral\<^sup>L M u = x"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1935
    by (auto simp: integrable_def lebesgue_integral_def u)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1936
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1937
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1938
lemma integral_monotone_convergence:
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1939
  assumes f: "\<And>i. integrable M (f i)" and mono: "AE x in M. mono (\<lambda>n. f n x)"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1940
  and lim: "AE x in M. (\<lambda>i. f i x) ----> u x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1941
  and ilim: "(\<lambda>i. integral\<^sup>L M (f i)) ----> x"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1942
  and u: "u \<in> borel_measurable M"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1943
  shows "integrable M u"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1944
  and "integral\<^sup>L M u = x"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1945
proof -
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1946
  have 1: "\<And>i. integrable M (\<lambda>x. f i x - f 0 x)"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1947
    using f by auto
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1948
  have 2: "AE x in M. mono (\<lambda>n. f n x - f 0 x)"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1949
    using mono by (auto simp: mono_def le_fun_def)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1950
  have 3: "\<And>n. AE x in M. 0 \<le> f n x - f 0 x"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1951
    using mono by (auto simp: field_simps mono_def le_fun_def)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1952
  have 4: "AE x in M. (\<lambda>i. f i x - f 0 x) ----> u x - f 0 x"
44568
e6f291cb5810 discontinue many legacy theorems about LIM and LIMSEQ, in favor of tendsto theorems
huffman
parents: 43941
diff changeset
  1953
    using lim by (auto intro!: tendsto_diff)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1954
  have 5: "(\<lambda>i. (\<integral>x. f i x - f 0 x \<partial>M)) ----> x - integral\<^sup>L M (f 0)"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1955
    using f ilim by (auto intro!: tendsto_diff)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1956
  have 6: "(\<lambda>x. u x - f 0 x) \<in> borel_measurable M"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1957
    using f[of 0] u by auto
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1958
  note diff = integral_monotone_convergence_pos[OF 1 2 3 4 5 6]
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1959
  have "integrable M (\<lambda>x. (u x - f 0 x) + f 0 x)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1960
    using diff(1) f by (rule integral_add(1))
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1961
  with diff(2) f show "integrable M u" "integral\<^sup>L M u = x"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  1962
    by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1963
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1964
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1965
lemma integral_0_iff:
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1966
  assumes "integrable M f"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1967
  shows "(\<integral>x. \<bar>f x\<bar> \<partial>M) = 0 \<longleftrightarrow> (emeasure M) {x\<in>space M. f x \<noteq> 0} = 0"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1968
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1969
  have *: "(\<integral>\<^sup>+x. ereal (- \<bar>f x\<bar>) \<partial>M) = 0"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1970
    using assms by (auto simp: positive_integral_0_iff_AE integrable_def)
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1971
  have "integrable M (\<lambda>x. \<bar>f x\<bar>)" using assms by (rule integrable_abs)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1972
  hence "(\<lambda>x. ereal (\<bar>f x\<bar>)) \<in> borel_measurable M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1973
    "(\<integral>\<^sup>+ x. ereal \<bar>f x\<bar> \<partial>M) \<noteq> \<infinity>" unfolding integrable_def by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1974
  from positive_integral_0_iff[OF this(1)] this(2)
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1975
  show ?thesis unfolding lebesgue_integral_def *
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1976
    using positive_integral_positive[of M "\<lambda>x. ereal \<bar>f x\<bar>"]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1977
    by (auto simp add: real_of_ereal_eq_0)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1978
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1979
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1980
lemma positive_integral_PInf:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1981
  assumes f: "f \<in> borel_measurable M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1982
  and not_Inf: "integral\<^sup>P M f \<noteq> \<infinity>"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1983
  shows "(emeasure M) (f -` {\<infinity>} \<inter> space M) = 0"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1984
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1985
  have "\<infinity> * (emeasure M) (f -` {\<infinity>} \<inter> space M) = (\<integral>\<^sup>+ x. \<infinity> * indicator (f -` {\<infinity>} \<inter> space M) x \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1986
    using f by (subst positive_integral_cmult_indicator) (auto simp: measurable_sets)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1987
  also have "\<dots> \<le> integral\<^sup>P M (\<lambda>x. max 0 (f x))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1988
    by (auto intro!: positive_integral_mono simp: indicator_def max_def)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1989
  finally have "\<infinity> * (emeasure M) (f -` {\<infinity>} \<inter> space M) \<le> integral\<^sup>P M f"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1990
    by (simp add: positive_integral_max_0)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1991
  moreover have "0 \<le> (emeasure M) (f -` {\<infinity>} \<inter> space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1992
    by (rule emeasure_nonneg)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1993
  ultimately show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1994
    using assms by (auto split: split_if_asm)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1995
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1996
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1997
lemma positive_integral_PInf_AE:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  1998
  assumes "f \<in> borel_measurable M" "integral\<^sup>P M f \<noteq> \<infinity>" shows "AE x in M. f x \<noteq> \<infinity>"
41026
bea75746dc9d folding on arbitrary Lebesgue integrable functions
hoelzl
parents: 41023
diff changeset
  1999
proof (rule AE_I)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2000
  show "(emeasure M) (f -` {\<infinity>} \<inter> space M) = 0"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2001
    by (rule positive_integral_PInf[OF assms])
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2002
  show "f -` {\<infinity>} \<inter> space M \<in> sets M"
41026
bea75746dc9d folding on arbitrary Lebesgue integrable functions
hoelzl
parents: 41023
diff changeset
  2003
    using assms by (auto intro: borel_measurable_vimage)
bea75746dc9d folding on arbitrary Lebesgue integrable functions
hoelzl
parents: 41023
diff changeset
  2004
qed auto
bea75746dc9d folding on arbitrary Lebesgue integrable functions
hoelzl
parents: 41023
diff changeset
  2005
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2006
lemma simple_integral_PInf:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2007
  assumes "simple_function M f" "\<And>x. 0 \<le> f x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2008
  and "integral\<^sup>S M f \<noteq> \<infinity>"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2009
  shows "(emeasure M) (f -` {\<infinity>} \<inter> space M) = 0"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2010
proof (rule positive_integral_PInf)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  2011
  show "f \<in> borel_measurable M" using assms by (auto intro: borel_measurable_simple_function)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2012
  show "integral\<^sup>P M f \<noteq> \<infinity>"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  2013
    using assms by (simp add: positive_integral_eq_simple_integral)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  2014
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  2015
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2016
lemma integral_real:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2017
  "AE x in M. \<bar>f x\<bar> \<noteq> \<infinity> \<Longrightarrow> (\<integral>x. real (f x) \<partial>M) = real (integral\<^sup>P M f) - real (integral\<^sup>P M (\<lambda>x. - f x))"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2018
  using assms unfolding lebesgue_integral_def
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  2019
  by (subst (1 2) positive_integral_cong_AE) (auto simp add: ereal_real)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2020
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2021
lemma (in finite_measure) lebesgue_integral_const[simp]:
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2022
  shows "integrable M (\<lambda>x. a)"
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  2023
  and  "(\<integral>x. a \<partial>M) = a * measure M (space M)"
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2024
proof -
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2025
  { fix a :: real assume "0 \<le> a"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2026
    then have "(\<integral>\<^sup>+ x. ereal a \<partial>M) = ereal a * (emeasure M) (space M)"
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2027
      by (subst positive_integral_const) auto
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2028
    moreover
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2029
    from `0 \<le> a` have "(\<integral>\<^sup>+ x. ereal (-a) \<partial>M) = 0"
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2030
      by (subst positive_integral_0_iff_AE) auto
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2031
    ultimately have "integrable M (\<lambda>x. a)" by (auto simp: integrable_def) }
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2032
  note * = this
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2033
  show "integrable M (\<lambda>x. a)"
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2034
  proof cases
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2035
    assume "0 \<le> a" with * show ?thesis .
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2036
  next
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2037
    assume "\<not> 0 \<le> a"
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2038
    then have "0 \<le> -a" by auto
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2039
    from *[OF this] show ?thesis by simp
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2040
  qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2041
  show "(\<integral>x. a \<partial>M) = a * measure M (space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2042
    by (simp add: lebesgue_integral_def positive_integral_const_If emeasure_eq_measure)
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2043
qed
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2044
50097
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  2045
lemma (in finite_measure) integrable_const_bound:
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  2046
  assumes "AE x in M. \<bar>f x\<bar> \<le> B" and "f \<in> borel_measurable M" shows "integrable M f"
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  2047
  by (auto intro: integrable_bound[where f="\<lambda>x. B"] lebesgue_integral_const assms)
32973da2d4f7 rules for intergration: integrating nat-functions, integrals on finite measures, constant multiplication
hoelzl
parents: 50027
diff changeset
  2048
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  2049
lemma indicator_less[simp]:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  2050
  "indicator A x \<le> (indicator B x::ereal) \<longleftrightarrow> (x \<in> A \<longrightarrow> x \<in> B)"
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  2051
  by (simp add: indicator_def not_le)
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  2052
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2053
lemma (in finite_measure) integral_less_AE:
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2054
  assumes int: "integrable M X" "integrable M Y"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2055
  assumes A: "(emeasure M) A \<noteq> 0" "A \<in> sets M" "AE x in M. x \<in> A \<longrightarrow> X x \<noteq> Y x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2056
  assumes gt: "AE x in M. X x \<le> Y x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2057
  shows "integral\<^sup>L M X < integral\<^sup>L M Y"
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2058
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2059
  have "integral\<^sup>L M X \<le> integral\<^sup>L M Y"
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2060
    using gt int by (intro integral_mono_AE) auto
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2061
  moreover
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2062
  have "integral\<^sup>L M X \<noteq> integral\<^sup>L M Y"
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2063
  proof
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2064
    assume eq: "integral\<^sup>L M X = integral\<^sup>L M Y"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2065
    have "integral\<^sup>L M (\<lambda>x. \<bar>Y x - X x\<bar>) = integral\<^sup>L M (\<lambda>x. Y x - X x)"
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2066
      using gt by (intro integral_cong_AE) auto
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2067
    also have "\<dots> = 0"
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2068
      using eq int by simp
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2069
    finally have "(emeasure M) {x \<in> space M. Y x - X x \<noteq> 0} = 0"
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  2070
      using int by (simp add: integral_0_iff)
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  2071
    moreover
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2072
    have "(\<integral>\<^sup>+x. indicator A x \<partial>M) \<le> (\<integral>\<^sup>+x. indicator {x \<in> space M. Y x - X x \<noteq> 0} x \<partial>M)"
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  2073
      using A by (intro positive_integral_mono_AE) auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2074
    then have "(emeasure M) A \<le> (emeasure M) {x \<in> space M. Y x - X x \<noteq> 0}"
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  2075
      using int A by (simp add: integrable_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2076
    ultimately have "emeasure M A = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2077
      using emeasure_nonneg[of M A] by simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2078
    with `(emeasure M) A \<noteq> 0` show False by auto
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2079
  qed
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2080
  ultimately show ?thesis by auto
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2081
qed
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
  2082
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  2083
lemma (in finite_measure) integral_less_AE_space:
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  2084
  assumes int: "integrable M X" "integrable M Y"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2085
  assumes gt: "AE x in M. X x < Y x" "(emeasure M) (space M) \<noteq> 0"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2086
  shows "integral\<^sup>L M X < integral\<^sup>L M Y"
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  2087
  using gt by (intro integral_less_AE[OF int, where A="space M"]) auto
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
  2088
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2089
lemma integral_dominated_convergence:
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2090
  assumes u[measurable]: "\<And>i. integrable M (u i)" and bound: "\<And>j. AE x in M. \<bar>u j x\<bar> \<le> w x"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2091
  and w[measurable]: "integrable M w"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2092
  and u': "AE x in M. (\<lambda>i. u i x) ----> u' x"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2093
  and [measurable]: "u' \<in> borel_measurable M"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2094
  shows "integrable M u'"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2095
  and "(\<lambda>i. (\<integral>x. \<bar>u i x - u' x\<bar> \<partial>M)) ----> 0" (is "?lim_diff")
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2096
  and "(\<lambda>i. integral\<^sup>L M (u i)) ----> integral\<^sup>L M u'" (is ?lim)
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
  2097
proof -
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2098
  have all_bound: "AE x in M. \<forall>j. \<bar>u j x\<bar> \<le> w x"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2099
    using bound by (auto simp: AE_all_countable)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2100
  with u' have u'_bound: "AE x in M. \<bar>u' x\<bar> \<le> w x"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2101
    by eventually_elim (auto intro: LIMSEQ_le_const2 tendsto_rabs)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2102
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2103
  from bound[of 0] have w_pos: "AE x in M. 0 \<le> w x"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2104
    by eventually_elim auto
41705
1100512e16d8 add auto support for AE_mp
hoelzl
parents: 41689
diff changeset
  2105
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2106
  show "integrable M u'"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2107
    by (rule integrable_bound) fact+
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2108
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  2109
  let ?diff = "\<lambda>n x. 2 * w x - \<bar>u n x - u' x\<bar>"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2110
  have diff: "\<And>n. integrable M (\<lambda>x. \<bar>u n x - u' x\<bar>)"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2111
    using w u `integrable M u'` by (auto intro!: integrable_abs)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2112
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2113
  from u'_bound all_bound
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2114
  have diff_less_2w: "AE x in M. \<forall>j. \<bar>u j x - u' x\<bar> \<le> 2 * w x"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2115
  proof (eventually_elim, intro allI)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2116
    fix x j assume *: "\<bar>u' x\<bar> \<le> w x" "\<forall>j. \<bar>u j x\<bar> \<le> w x"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2117
    then have "\<bar>u j x - u' x\<bar> \<le> \<bar>u j x\<bar> + \<bar>u' x\<bar>" by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2118
    also have "\<dots> \<le> w x + w x"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2119
      using * by (intro add_mono) auto
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2120
    finally show "\<bar>u j x - u' x\<bar> \<le> 2 * w x" by simp
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2121
  qed
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2122
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2123
  have PI_diff: "\<And>n. (\<integral>\<^sup>+ x. ereal (?diff n x) \<partial>M) =
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2124
    (\<integral>\<^sup>+ x. ereal (2 * w x) \<partial>M) - (\<integral>\<^sup>+ x. ereal \<bar>u n x - u' x\<bar> \<partial>M)"
41705
1100512e16d8 add auto support for AE_mp
hoelzl
parents: 41689
diff changeset
  2125
    using diff w diff_less_2w w_pos
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2126
    by (subst positive_integral_diff[symmetric])
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2127
       (auto simp: integrable_def intro!: positive_integral_cong_AE)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2128
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2129
  have "integrable M (\<lambda>x. 2 * w x)"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2130
    using w by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2131
  hence I2w_fin: "(\<integral>\<^sup>+ x. ereal (2 * w x) \<partial>M) \<noteq> \<infinity>" and
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  2132
    borel_2w: "(\<lambda>x. ereal (2 * w x)) \<in> borel_measurable M"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2133
    unfolding integrable_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2134
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2135
  have "limsup (\<lambda>n. \<integral>\<^sup>+ x. ereal \<bar>u n x - u' x\<bar> \<partial>M) = 0" (is "limsup ?f = 0")
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2136
  proof cases
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2137
    assume eq_0: "(\<integral>\<^sup>+ x. max 0 (ereal (2 * w x)) \<partial>M) = 0" (is "?wx = 0")
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2138
    { fix n
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2139
      have "?f n \<le> ?wx" (is "integral\<^sup>P M ?f' \<le> _")
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2140
        using diff_less_2w unfolding positive_integral_max_0
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2141
        by (intro positive_integral_mono_AE) auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2142
      then have "?f n = 0"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2143
        using positive_integral_positive[of M ?f'] eq_0 by auto }
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2144
    then show ?thesis by (simp add: Limsup_const)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2145
  next
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2146
    assume neq_0: "(\<integral>\<^sup>+ x. max 0 (ereal (2 * w x)) \<partial>M) \<noteq> 0" (is "?wx \<noteq> 0")
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  2147
    have "0 = limsup (\<lambda>n. 0 :: ereal)" by (simp add: Limsup_const)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2148
    also have "\<dots> \<le> limsup (\<lambda>n. \<integral>\<^sup>+ x. ereal \<bar>u n x - u' x\<bar> \<partial>M)"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50384
diff changeset
  2149
      by (simp add: Limsup_mono  positive_integral_positive)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2150
    finally have pos: "0 \<le> limsup (\<lambda>n. \<integral>\<^sup>+ x. ereal \<bar>u n x - u' x\<bar> \<partial>M)" .
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2151
    have "?wx = (\<integral>\<^sup>+ x. liminf (\<lambda>n. max 0 (ereal (?diff n x))) \<partial>M)"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2152
      using u'
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2153
    proof (intro positive_integral_cong_AE, eventually_elim)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2154
      fix x assume u': "(\<lambda>i. u i x) ----> u' x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  2155
      show "max 0 (ereal (2 * w x)) = liminf (\<lambda>n. max 0 (ereal (?diff n x)))"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  2156
        unfolding ereal_max_0
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  2157
      proof (rule lim_imp_Liminf[symmetric], unfold lim_ereal)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2158
        have "(\<lambda>i. ?diff i x) ----> 2 * w x - \<bar>u' x - u' x\<bar>"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2159
          using u' by (safe intro!: tendsto_intros)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2160
        then show "(\<lambda>i. max 0 (?diff i x)) ----> max 0 (2 * w x)"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2161
          by (auto intro!: tendsto_real_max)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2162
      qed (rule trivial_limit_sequentially)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2163
    qed
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2164
    also have "\<dots> \<le> liminf (\<lambda>n. \<integral>\<^sup>+ x. max 0 (ereal (?diff n x)) \<partial>M)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2165
      using w u unfolding integrable_def
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2166
      by (intro positive_integral_lim_INF) (auto intro!: positive_integral_lim_INF)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2167
    also have "\<dots> = (\<integral>\<^sup>+ x. ereal (2 * w x) \<partial>M) -
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2168
        limsup (\<lambda>n. \<integral>\<^sup>+ x. ereal \<bar>u n x - u' x\<bar> \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2169
      unfolding PI_diff positive_integral_max_0
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2170
      using positive_integral_positive[of M "\<lambda>x. ereal (2 * w x)"]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  2171
      by (subst liminf_ereal_cminus) auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2172
    finally show ?thesis
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2173
      using neq_0 I2w_fin positive_integral_positive[of M "\<lambda>x. ereal (2 * w x)"] pos
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2174
      unfolding positive_integral_max_0
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2175
      by (cases rule: ereal2_cases[of "\<integral>\<^sup>+ x. ereal (2 * w x) \<partial>M" "limsup (\<lambda>n. \<integral>\<^sup>+ x. ereal \<bar>u n x - u' x\<bar> \<partial>M)"])
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2176
         auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2177
  qed
41705
1100512e16d8 add auto support for AE_mp
hoelzl
parents: 41689
diff changeset
  2178
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2179
  have "liminf ?f \<le> limsup ?f"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50384
diff changeset
  2180
    by (intro Liminf_le_Limsup trivial_limit_sequentially)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2181
  moreover
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  2182
  { have "0 = liminf (\<lambda>n. 0 :: ereal)" by (simp add: Liminf_const)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2183
    also have "\<dots> \<le> liminf ?f"
51000
c9adb50f74ad use order topology for extended reals
hoelzl
parents: 50384
diff changeset
  2184
      by (simp add: Liminf_mono positive_integral_positive)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2185
    finally have "0 \<le> liminf ?f" . }
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  2186
  ultimately have liminf_limsup_eq: "liminf ?f = ereal 0" "limsup ?f = ereal 0"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2187
    using `limsup ?f = 0` by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2188
  have "\<And>n. (\<integral>\<^sup>+ x. ereal \<bar>u n x - u' x\<bar> \<partial>M) = ereal (\<integral>x. \<bar>u n x - u' x\<bar> \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2189
    using diff positive_integral_positive[of M]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2190
    by (subst integral_eq_positive_integral[of _ M]) (auto simp: ereal_real integrable_def)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  2191
  then show ?lim_diff
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51000
diff changeset
  2192
    using Liminf_eq_Limsup[OF trivial_limit_sequentially liminf_limsup_eq]
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2193
    by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2194
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2195
  show ?lim
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2196
  proof (rule LIMSEQ_I)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2197
    fix r :: real assume "0 < r"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2198
    from LIMSEQ_D[OF `?lim_diff` this]
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2199
    obtain N where N: "\<And>n. N \<le> n \<Longrightarrow> (\<integral>x. \<bar>u n x - u' x\<bar> \<partial>M) < r"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2200
      using diff by (auto simp: integral_positive)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2201
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2202
    show "\<exists>N. \<forall>n\<ge>N. norm (integral\<^sup>L M (u n) - integral\<^sup>L M u') < r"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2203
    proof (safe intro!: exI[of _ N])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2204
      fix n assume "N \<le> n"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2205
      have "\<bar>integral\<^sup>L M (u n) - integral\<^sup>L M u'\<bar> = \<bar>(\<integral>x. u n x - u' x \<partial>M)\<bar>"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2206
        using u `integrable M u'` by auto
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2207
      also have "\<dots> \<le> (\<integral>x. \<bar>u n x - u' x\<bar> \<partial>M)" using u `integrable M u'`
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2208
        by (rule_tac integral_triangle_inequality) auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2209
      also note N[OF `N \<le> n`]
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2210
      finally show "norm (integral\<^sup>L M (u n) - integral\<^sup>L M u') < r" by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2211
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2212
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2213
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2214
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2215
lemma integral_sums:
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2216
  assumes integrable[measurable]: "\<And>i. integrable M (f i)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2217
  and summable: "\<And>x. x \<in> space M \<Longrightarrow> summable (\<lambda>i. \<bar>f i x\<bar>)"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2218
  and sums: "summable (\<lambda>i. (\<integral>x. \<bar>f i x\<bar> \<partial>M))"
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2219
  shows "integrable M (\<lambda>x. (\<Sum>i. f i x))" (is "integrable M ?S")
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2220
  and "(\<lambda>i. integral\<^sup>L M (f i)) sums (\<integral>x. (\<Sum>i. f i x) \<partial>M)" (is ?integral)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2221
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2222
  have "\<forall>x\<in>space M. \<exists>w. (\<lambda>i. \<bar>f i x\<bar>) sums w"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2223
    using summable unfolding summable_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2224
  from bchoice[OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2225
  obtain w where w: "\<And>x. x \<in> space M \<Longrightarrow> (\<lambda>i. \<bar>f i x\<bar>) sums w x" by auto
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2226
  then have w_borel: "w \<in> borel_measurable M" unfolding sums_def
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2227
    by (rule borel_measurable_LIMSEQ) auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2228
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  2229
  let ?w = "\<lambda>y. if y \<in> space M then w y else 0"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2230
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2231
  obtain x where abs_sum: "(\<lambda>i. (\<integral>x. \<bar>f i x\<bar> \<partial>M)) sums x"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2232
    using sums unfolding summable_def ..
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2233
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2234
  have 1: "\<And>n. integrable M (\<lambda>x. \<Sum>i = 0..<n. f i x)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2235
    using integrable by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2236
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2237
  have 2: "\<And>j. AE x in M. \<bar>\<Sum>i = 0..<j. f i x\<bar> \<le> ?w x"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2238
    using AE_space
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2239
  proof eventually_elim
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2240
    fix j x assume [simp]: "x \<in> space M"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2241
    have "\<bar>\<Sum>i = 0..< j. f i x\<bar> \<le> (\<Sum>i = 0..< j. \<bar>f i x\<bar>)" by (rule setsum_abs)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2242
    also have "\<dots> \<le> w x" using w[of x] series_pos_le[of "\<lambda>i. \<bar>f i x\<bar>"] unfolding sums_iff by auto
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2243
    finally show "\<bar>\<Sum>i = 0..<j. f i x\<bar> \<le> ?w x" by simp
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2244
  qed
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2245
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2246
  have 3: "integrable M ?w"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2247
  proof (rule integral_monotone_convergence(1))
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  2248
    let ?F = "\<lambda>n y. (\<Sum>i = 0..<n. \<bar>f i y\<bar>)"
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  2249
    let ?w' = "\<lambda>n y. if y \<in> space M then ?F n y else 0"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2250
    have "\<And>n. integrable M (?F n)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2251
      using integrable by (auto intro!: integrable_abs)
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2252
    thus "\<And>n. integrable M (?w' n)" by (simp cong: integrable_cong)
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2253
    show "AE x in M. mono (\<lambda>n. ?w' n x)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2254
      by (auto simp: mono_def le_fun_def intro!: setsum_mono2)
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2255
    show "AE x in M. (\<lambda>n. ?w' n x) ----> ?w x"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2256
        using w by (simp_all add: tendsto_const sums_def)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2257
    have *: "\<And>n. integral\<^sup>L M (?w' n) = (\<Sum>i = 0..< n. (\<integral>x. \<bar>f i x\<bar> \<partial>M))"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2258
      using integrable by (simp add: integrable_abs cong: integral_cong)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2259
    from abs_sum
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2260
    show "(\<lambda>i. integral\<^sup>L M (?w' i)) ----> x" unfolding * sums_def .
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2261
  qed (simp add: w_borel measurable_If_set)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2262
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2263
  from summable[THEN summable_rabs_cancel]
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2264
  have 4: "AE x in M. (\<lambda>n. \<Sum>i = 0..<n. f i x) ----> (\<Sum>i. f i x)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2265
    by (auto intro: summable_sumr_LIMSEQ_suminf)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2266
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2267
  note int = integral_dominated_convergence(1,3)[OF 1 2 3 4
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2268
    borel_measurable_suminf[OF integrableD(1)[OF integrable]]]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2269
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2270
  from int show "integrable M ?S" by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2271
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2272
  show ?integral unfolding sums_def integral_setsum(1)[symmetric, OF integrable]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2273
    using int(2) by simp
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
  2274
qed
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
  2275
50384
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2276
lemma integrable_mult_indicator:
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2277
  "A \<in> sets M \<Longrightarrow> integrable M f \<Longrightarrow> integrable M (\<lambda>x. f x * indicator A x)"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2278
  by (rule integrable_bound[where f="\<lambda>x. \<bar>f x\<bar>"])
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2279
     (auto intro: integrable_abs split: split_indicator)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2280
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2281
lemma tendsto_integral_at_top:
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2282
  fixes M :: "real measure"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2283
  assumes M: "sets M = sets borel" and f[measurable]: "integrable M f"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2284
  shows "((\<lambda>y. \<integral> x. f x * indicator {.. y} x \<partial>M) ---> \<integral> x. f x \<partial>M) at_top"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2285
proof -
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2286
  have M_measure[simp]: "borel_measurable M = borel_measurable borel"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2287
    using M by (simp add: sets_eq_imp_space_eq measurable_def)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2288
  { fix f assume f: "integrable M f" "\<And>x. 0 \<le> f x"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2289
    then have [measurable]: "f \<in> borel_measurable borel"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2290
      by (simp add: integrable_def)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2291
    have "((\<lambda>y. \<integral> x. f x * indicator {.. y} x \<partial>M) ---> \<integral> x. f x \<partial>M) at_top"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2292
    proof (rule tendsto_at_topI_sequentially)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2293
      have "\<And>j. AE x in M. \<bar>f x * indicator {.. j} x\<bar> \<le> f x"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2294
        using f(2) by (intro AE_I2) (auto split: split_indicator)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2295
      have int: "\<And>n. integrable M (\<lambda>x. f x * indicator {.. n} x)"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2296
        by (rule integrable_mult_indicator) (auto simp: M f)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2297
      show "(\<lambda>n. \<integral> x. f x * indicator {..real n} x \<partial>M) ----> integral\<^sup>L M f"
50384
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2298
      proof (rule integral_dominated_convergence)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2299
        { fix x have "eventually (\<lambda>n. f x * indicator {..real n} x = f x) sequentially"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2300
            by (rule eventually_sequentiallyI[of "natceiling x"])
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2301
               (auto split: split_indicator simp: natceiling_le_eq) }
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2302
        from filterlim_cong[OF refl refl this]
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2303
        show "AE x in M. (\<lambda>n. f x * indicator {..real n} x) ----> f x"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2304
          by (simp add: tendsto_const)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2305
      qed (fact+, simp)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2306
      show "mono (\<lambda>y. \<integral> x. f x * indicator {..y} x \<partial>M)"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2307
        by (intro monoI integral_mono int) (auto split: split_indicator intro: f)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2308
    qed }
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2309
  note nonneg = this
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2310
  let ?P = "\<lambda>y. \<integral> x. max 0 (f x) * indicator {..y} x \<partial>M"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2311
  let ?N = "\<lambda>y. \<integral> x. max 0 (- f x) * indicator {..y} x \<partial>M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2312
  let ?p = "integral\<^sup>L M (\<lambda>x. max 0 (f x))"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2313
  let ?n = "integral\<^sup>L M (\<lambda>x. max 0 (- f x))"
50384
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2314
  have "(?P ---> ?p) at_top" "(?N ---> ?n) at_top"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2315
    by (auto intro!: nonneg integrable_max f)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2316
  note tendsto_diff[OF this]
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2317
  also have "(\<lambda>y. ?P y - ?N y) = (\<lambda>y. \<integral> x. f x * indicator {..y} x \<partial>M)"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2318
    by (subst integral_diff(2)[symmetric])
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2319
       (auto intro!: integrable_mult_indicator integrable_max f integral_cong ext
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2320
             simp: M split: split_max)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2321
  also have "?p - ?n = integral\<^sup>L M f"
50384
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2322
    by (subst integral_diff(2)[symmetric])
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2323
       (auto intro!: integrable_max f integral_cong ext simp: M split: split_max)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2324
  finally show ?thesis .
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2325
qed
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2326
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2327
lemma integral_monotone_convergence_at_top:
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2328
  fixes M :: "real measure"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2329
  assumes M: "sets M = sets borel"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2330
  assumes nonneg: "AE x in M. 0 \<le> f x"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2331
  assumes borel: "f \<in> borel_measurable borel"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2332
  assumes int: "\<And>y. integrable M (\<lambda>x. f x * indicator {.. y} x)"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2333
  assumes conv: "((\<lambda>y. \<integral> x. f x * indicator {.. y} x \<partial>M) ---> x) at_top"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2334
  shows "integrable M f" "integral\<^sup>L M f = x"
50384
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2335
proof -
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2336
  from nonneg have "AE x in M. mono (\<lambda>n::nat. f x * indicator {..real n} x)"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2337
    by (auto split: split_indicator intro!: monoI)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2338
  { fix x have "eventually (\<lambda>n. f x * indicator {..real n} x = f x) sequentially"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2339
      by (rule eventually_sequentiallyI[of "natceiling x"])
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2340
         (auto split: split_indicator simp: natceiling_le_eq) }
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2341
  from filterlim_cong[OF refl refl this]
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2342
  have "AE x in M. (\<lambda>i. f x * indicator {..real i} x) ----> f x"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2343
    by (simp add: tendsto_const)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2344
  have "(\<lambda>i. \<integral> x. f x * indicator {..real i} x \<partial>M) ----> x"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2345
    using conv filterlim_real_sequentially by (rule filterlim_compose)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2346
  have M_measure[simp]: "borel_measurable M = borel_measurable borel"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2347
    using M by (simp add: sets_eq_imp_space_eq measurable_def)
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2348
  have "f \<in> borel_measurable M"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2349
    using borel by simp
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2350
  show "integrable M f"
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2351
    by (rule integral_monotone_convergence) fact+
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2352
  show "integral\<^sup>L M f = x"
50384
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2353
    by (rule integral_monotone_convergence) fact+
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2354
qed
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2355
b9b967da28e9 rules for improper Lebesgue integrals (using tendsto at_top)
hoelzl
parents: 50252
diff changeset
  2356
35748
5f35613d9a65 Equality of integral and infinite sum.
hoelzl
parents: 35692
diff changeset
  2357
section "Lebesgue integration on countable spaces"
5f35613d9a65 Equality of integral and infinite sum.
hoelzl
parents: 35692
diff changeset
  2358
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2359
lemma integral_on_countable:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2360
  assumes f: "f \<in> borel_measurable M"
35748
5f35613d9a65 Equality of integral and infinite sum.
hoelzl
parents: 35692
diff changeset
  2361
  and bij: "bij_betw enum S (f ` space M)"
5f35613d9a65 Equality of integral and infinite sum.
hoelzl
parents: 35692
diff changeset
  2362
  and enum_zero: "enum ` (-S) \<subseteq> {0}"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2363
  and fin: "\<And>x. x \<noteq> 0 \<Longrightarrow> (emeasure M) (f -` {x} \<inter> space M) \<noteq> \<infinity>"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2364
  and abs_summable: "summable (\<lambda>r. \<bar>enum r * real ((emeasure M) (f -` {enum r} \<inter> space M))\<bar>)"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2365
  shows "integrable M f"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2366
  and "(\<lambda>r. enum r * real ((emeasure M) (f -` {enum r} \<inter> space M))) sums integral\<^sup>L M f" (is ?sums)
35748
5f35613d9a65 Equality of integral and infinite sum.
hoelzl
parents: 35692
diff changeset
  2367
proof -
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  2368
  let ?A = "\<lambda>r. f -` {enum r} \<inter> space M"
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  2369
  let ?F = "\<lambda>r x. enum r * indicator (?A r) x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2370
  have enum_eq: "\<And>r. enum r * real ((emeasure M) (?A r)) = integral\<^sup>L M (?F r)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2371
    using f fin by (simp add: borel_measurable_vimage integral_cmul_indicator)
35748
5f35613d9a65 Equality of integral and infinite sum.
hoelzl
parents: 35692
diff changeset
  2372
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2373
  { fix x assume "x \<in> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2374
    hence "f x \<in> enum ` S" using bij unfolding bij_betw_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2375
    then obtain i where "i\<in>S" "enum i = f x" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2376
    have F: "\<And>j. ?F j x = (if j = i then f x else 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2377
    proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2378
      fix j assume "j = i"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2379
      thus "?thesis j" using `x \<in> space M` `enum i = f x` by (simp add: indicator_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2380
    next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2381
      fix j assume "j \<noteq> i"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2382
      show "?thesis j" using bij `i \<in> S` `j \<noteq> i` `enum i = f x` enum_zero
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2383
        by (cases "j \<in> S") (auto simp add: indicator_def bij_betw_def inj_on_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2384
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2385
    hence F_abs: "\<And>j. \<bar>if j = i then f x else 0\<bar> = (if j = i then \<bar>f x\<bar> else 0)" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2386
    have "(\<lambda>i. ?F i x) sums f x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2387
         "(\<lambda>i. \<bar>?F i x\<bar>) sums \<bar>f x\<bar>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2388
      by (auto intro!: sums_single simp: F F_abs) }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2389
  note F_sums_f = this(1) and F_abs_sums_f = this(2)
35748
5f35613d9a65 Equality of integral and infinite sum.
hoelzl
parents: 35692
diff changeset
  2390
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2391
  have int_f: "integral\<^sup>L M f = (\<integral>x. (\<Sum>r. ?F r x) \<partial>M)" "integrable M f = integrable M (\<lambda>x. \<Sum>r. ?F r x)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2392
    using F_sums_f by (auto intro!: integral_cong integrable_cong simp: sums_iff)
35748
5f35613d9a65 Equality of integral and infinite sum.
hoelzl
parents: 35692
diff changeset
  2393
5f35613d9a65 Equality of integral and infinite sum.
hoelzl
parents: 35692
diff changeset
  2394
  { fix r
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2395
    have "(\<integral>x. \<bar>?F r x\<bar> \<partial>M) = (\<integral>x. \<bar>enum r\<bar> * indicator (?A r) x \<partial>M)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2396
      by (auto simp: indicator_def intro!: integral_cong)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2397
    also have "\<dots> = \<bar>enum r\<bar> * real ((emeasure M) (?A r))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2398
      using f fin by (simp add: borel_measurable_vimage integral_cmul_indicator)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2399
    finally have "(\<integral>x. \<bar>?F r x\<bar> \<partial>M) = \<bar>enum r * real ((emeasure M) (?A r))\<bar>"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  2400
      using f by (subst (2) abs_mult_pos[symmetric]) (auto intro!: real_of_ereal_pos measurable_sets) }
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2401
  note int_abs_F = this
35748
5f35613d9a65 Equality of integral and infinite sum.
hoelzl
parents: 35692
diff changeset
  2402
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2403
  have 1: "\<And>i. integrable M (\<lambda>x. ?F i x)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2404
    using f fin by (simp add: borel_measurable_vimage integral_cmul_indicator)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2405
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2406
  have 2: "\<And>x. x \<in> space M \<Longrightarrow> summable (\<lambda>i. \<bar>?F i x\<bar>)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2407
    using F_abs_sums_f unfolding sums_iff by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2408
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2409
  from integral_sums(2)[OF 1 2, unfolded int_abs_F, OF _ abs_summable]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2410
  show ?sums unfolding enum_eq int_f by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2411
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2412
  from integral_sums(1)[OF 1 2, unfolded int_abs_F, OF _ abs_summable]
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  2413
  show "integrable M f" unfolding int_f by simp
35748
5f35613d9a65 Equality of integral and infinite sum.
hoelzl
parents: 35692
diff changeset
  2414
qed
5f35613d9a65 Equality of integral and infinite sum.
hoelzl
parents: 35692
diff changeset
  2415
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2416
section {* Distributions *}
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2417
49797
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
  2418
lemma positive_integral_distr':
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
  2419
  assumes T: "T \<in> measurable M M'"
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  2420
  and f: "f \<in> borel_measurable (distr M M' T)" "\<And>x. 0 \<le> f x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2421
  shows "integral\<^sup>P (distr M M' T) f = (\<integral>\<^sup>+ x. f (T x) \<partial>M)"
49797
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
  2422
  using f 
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
  2423
proof induct
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
  2424
  case (cong f g)
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  2425
  with T show ?case
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  2426
    apply (subst positive_integral_cong[of _ f g])
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  2427
    apply simp
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  2428
    apply (subst positive_integral_cong[of _ "\<lambda>x. f (T x)" "\<lambda>x. g (T x)"])
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  2429
    apply (simp add: measurable_def Pi_iff)
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  2430
    apply simp
49797
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
  2431
    done
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
  2432
next
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
  2433
  case (set A)
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
  2434
  then have eq: "\<And>x. x \<in> space M \<Longrightarrow> indicator A (T x) = indicator (T -` A \<inter> space M) x"
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
  2435
    by (auto simp: indicator_def)
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
  2436
  from set T show ?case
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
  2437
    by (subst positive_integral_cong[OF eq])
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
  2438
       (auto simp add: emeasure_distr intro!: positive_integral_indicator[symmetric] measurable_sets)
49798
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2439
qed (simp_all add: measurable_compose[OF T] T positive_integral_cmult positive_integral_add
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2440
                   positive_integral_monotone_convergence_SUP le_fun_def incseq_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2441
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2442
lemma positive_integral_distr:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2443
  "T \<in> measurable M M' \<Longrightarrow> f \<in> borel_measurable M' \<Longrightarrow> integral\<^sup>P (distr M M' T) f = (\<integral>\<^sup>+ x. f (T x) \<partial>M)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2444
  by (subst (1 2) positive_integral_max_0[symmetric])
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2445
     (simp add: positive_integral_distr')
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
  2446
49800
a6678da5692c induction prove for positive_integral_fst
hoelzl
parents: 49799
diff changeset
  2447
lemma integral_distr:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2448
  "T \<in> measurable M M' \<Longrightarrow> f \<in> borel_measurable M' \<Longrightarrow> integral\<^sup>L (distr M M' T) f = (\<integral> x. f (T x) \<partial>M)"
49800
a6678da5692c induction prove for positive_integral_fst
hoelzl
parents: 49799
diff changeset
  2449
  unfolding lebesgue_integral_def
a6678da5692c induction prove for positive_integral_fst
hoelzl
parents: 49799
diff changeset
  2450
  by (subst (1 2) positive_integral_distr) auto
a6678da5692c induction prove for positive_integral_fst
hoelzl
parents: 49799
diff changeset
  2451
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2452
lemma integrable_distr_eq:
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2453
  "T \<in> measurable M M' \<Longrightarrow> f \<in> borel_measurable M' \<Longrightarrow> integrable (distr M M' T) f \<longleftrightarrow> integrable M (\<lambda>x. f (T x))"
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2454
  unfolding integrable_def 
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2455
  by (subst (1 2) positive_integral_distr) (auto simp: comp_def)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2456
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2457
lemma integrable_distr:
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2458
  "T \<in> measurable M M' \<Longrightarrow> integrable (distr M M' T) f \<Longrightarrow> integrable M (\<lambda>x. f (T x))"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2459
  by (subst integrable_distr_eq[symmetric]) auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2460
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2461
section {* Lebesgue integration on @{const count_space} *}
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2462
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2463
lemma simple_function_count_space[simp]:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2464
  "simple_function (count_space A) f \<longleftrightarrow> finite (f ` A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2465
  unfolding simple_function_def by simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2466
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2467
lemma positive_integral_count_space:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2468
  assumes A: "finite {a\<in>A. 0 < f a}"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2469
  shows "integral\<^sup>P (count_space A) f = (\<Sum>a|a\<in>A \<and> 0 < f a. f a)"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  2470
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2471
  have *: "(\<integral>\<^sup>+x. max 0 (f x) \<partial>count_space A) =
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2472
    (\<integral>\<^sup>+ x. (\<Sum>a|a\<in>A \<and> 0 < f a. f a * indicator {a} x) \<partial>count_space A)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2473
    by (auto intro!: positive_integral_cong
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2474
             simp add: indicator_def if_distrib setsum_cases[OF A] max_def le_less)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2475
  also have "\<dots> = (\<Sum>a|a\<in>A \<and> 0 < f a. \<integral>\<^sup>+ x. f a * indicator {a} x \<partial>count_space A)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2476
    by (subst positive_integral_setsum)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2477
       (simp_all add: AE_count_space ereal_zero_le_0_iff less_imp_le)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2478
  also have "\<dots> = (\<Sum>a|a\<in>A \<and> 0 < f a. f a)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2479
    by (auto intro!: setsum_cong simp: positive_integral_cmult_indicator one_ereal_def[symmetric])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2480
  finally show ?thesis by (simp add: positive_integral_max_0)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2481
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2482
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2483
lemma integrable_count_space:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2484
  "finite X \<Longrightarrow> integrable (count_space X) f"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2485
  by (auto simp: positive_integral_count_space integrable_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2486
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2487
lemma positive_integral_count_space_finite:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2488
    "finite A \<Longrightarrow> (\<integral>\<^sup>+x. f x \<partial>count_space A) = (\<Sum>a\<in>A. max 0 (f a))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2489
  by (subst positive_integral_max_0[symmetric])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2490
     (auto intro!: setsum_mono_zero_left simp: positive_integral_count_space less_le)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2491
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2492
lemma lebesgue_integral_count_space_finite_support:
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2493
  assumes f: "finite {a\<in>A. f a \<noteq> 0}" shows "(\<integral>x. f x \<partial>count_space A) = (\<Sum>a | a \<in> A \<and> f a \<noteq> 0. f a)"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2494
proof -
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2495
  have *: "\<And>r::real. 0 < max 0 r \<longleftrightarrow> 0 < r" "\<And>x. max 0 (ereal x) = ereal (max 0 x)"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2496
    "\<And>a. a \<in> A \<and> 0 < f a \<Longrightarrow> max 0 (f a) = f a"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2497
    "\<And>a. a \<in> A \<and> f a < 0 \<Longrightarrow> max 0 (- f a) = - f a"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2498
    "{a \<in> A. f a \<noteq> 0} = {a \<in> A. 0 < f a} \<union> {a \<in> A. f a < 0}"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2499
    "({a \<in> A. 0 < f a} \<inter> {a \<in> A. f a < 0}) = {}"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2500
    by (auto split: split_max)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2501
  have "finite {a \<in> A. 0 < f a}" "finite {a \<in> A. f a < 0}"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2502
    by (auto intro: finite_subset[OF _ f])
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2503
  then show ?thesis
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2504
    unfolding lebesgue_integral_def
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2505
    apply (subst (1 2) positive_integral_max_0[symmetric])
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2506
    apply (subst (1 2) positive_integral_count_space)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2507
    apply (auto simp add: * setsum_negf setsum_Un
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2508
                simp del: ereal_max)
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2509
    done
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2510
qed
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2511
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2512
lemma lebesgue_integral_count_space_finite:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2513
    "finite A \<Longrightarrow> (\<integral>x. f x \<partial>count_space A) = (\<Sum>a\<in>A. f a)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2514
  apply (auto intro!: setsum_mono_zero_left
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2515
              simp: positive_integral_count_space_finite lebesgue_integral_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2516
  apply (subst (1 2)  setsum_real_of_ereal[symmetric])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2517
  apply (auto simp: max_def setsum_subtractf[symmetric] intro!: setsum_cong)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2518
  done
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2519
49775
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2520
lemma borel_measurable_count_space[simp, intro!]:
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2521
  "f \<in> borel_measurable (count_space A)"
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2522
  by simp
970964690b3d remove some unneeded positivity assumptions; generalize some assumptions to AE; tuned proofs
hoelzl
parents: 47761
diff changeset
  2523
54418
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2524
lemma lessThan_eq_empty_iff: "{..< n::nat} = {} \<longleftrightarrow> n = 0"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2525
  by auto
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2526
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2527
lemma emeasure_UN_countable:
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2528
  assumes sets: "\<And>i. i \<in> I \<Longrightarrow> X i \<in> sets M" and I: "countable I" 
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2529
  assumes disj: "disjoint_family_on X I"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2530
  shows "emeasure M (UNION I X) = (\<integral>\<^sup>+i. emeasure M (X i) \<partial>count_space I)"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2531
proof cases
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2532
  assume "finite I" with sets disj show ?thesis
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2533
    by (subst setsum_emeasure[symmetric])
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2534
       (auto intro!: setsum_cong simp add: max_def subset_eq positive_integral_count_space_finite emeasure_nonneg)
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2535
next
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2536
  assume f: "\<not> finite I"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2537
  then have [intro]: "I \<noteq> {}" by auto
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2538
  from from_nat_into_inj_infinite[OF I f] from_nat_into[OF this] disj
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2539
  have disj2: "disjoint_family (\<lambda>i. X (from_nat_into I i))"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2540
    unfolding disjoint_family_on_def by metis
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2541
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2542
  from f have "bij_betw (from_nat_into I) UNIV I"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2543
    using bij_betw_from_nat_into[OF I] by simp
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2544
  then have "(\<Union>i\<in>I. X i) = (\<Union>i. (X \<circ> from_nat_into I) i)"
56154
f0a927235162 more complete set of lemmas wrt. image and composition
haftmann
parents: 54611
diff changeset
  2545
    unfolding SUP_def image_comp [symmetric] by (simp add: bij_betw_def)
54418
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2546
  then have "emeasure M (UNION I X) = emeasure M (\<Union>i. X (from_nat_into I i))"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2547
    by simp
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2548
  also have "\<dots> = (\<Sum>i. emeasure M (X (from_nat_into I i)))"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2549
    by (intro suminf_emeasure[symmetric] disj disj2) (auto intro!: sets from_nat_into[OF `I \<noteq> {}`])
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2550
  also have "\<dots> = (\<Sum>n. \<integral>\<^sup>+i. emeasure M (X i) * indicator {from_nat_into I n} i \<partial>count_space I)"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2551
  proof (intro arg_cong[where f=suminf] ext)
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2552
    fix i
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2553
    have eq: "{a \<in> I. 0 < emeasure M (X a) * indicator {from_nat_into I i} a}
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2554
     = (if 0 < emeasure M (X (from_nat_into I i)) then {from_nat_into I i} else {})"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2555
     using ereal_0_less_1
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2556
     by (auto simp: ereal_zero_less_0_iff indicator_def from_nat_into `I \<noteq> {}` simp del: ereal_0_less_1)
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2557
    have "(\<integral>\<^sup>+ ia. emeasure M (X ia) * indicator {from_nat_into I i} ia \<partial>count_space I) =
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2558
      (if 0 < emeasure M (X (from_nat_into I i)) then emeasure M (X (from_nat_into I i)) else 0)"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2559
      by (subst positive_integral_count_space) (simp_all add: eq)
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2560
    also have "\<dots> = emeasure M (X (from_nat_into I i))"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2561
      by (simp add: less_le emeasure_nonneg)
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2562
    finally show "emeasure M (X (from_nat_into I i)) =
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2563
         \<integral>\<^sup>+ ia. emeasure M (X ia) * indicator {from_nat_into I i} ia \<partial>count_space I" ..
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2564
  qed
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2565
  also have "\<dots> = (\<integral>\<^sup>+i. emeasure M (X i) \<partial>count_space I)"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2566
    apply (subst positive_integral_suminf[symmetric])
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2567
    apply (auto simp: emeasure_nonneg intro!: positive_integral_cong)
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2568
  proof -
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2569
    fix x assume "x \<in> I"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2570
    then have "(\<Sum>i. emeasure M (X x) * indicator {from_nat_into I i} x) = (\<Sum>i\<in>{to_nat_on I x}. emeasure M (X x) * indicator {from_nat_into I i} x)"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2571
      by (intro suminf_finite) (auto simp: indicator_def I f)
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2572
    also have "\<dots> = emeasure M (X x)"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2573
      by (simp add: I f `x\<in>I`)
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2574
    finally show "(\<Sum>i. emeasure M (X x) * indicator {from_nat_into I i} x) = emeasure M (X x)" .
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2575
  qed
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2576
  finally show ?thesis .
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2577
qed
3b8e33d1a39a measure of a countable union
hoelzl
parents: 54417
diff changeset
  2578
54417
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2579
section {* Measures with Restricted Space *}
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2580
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2581
lemma positive_integral_restrict_space:
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2582
  assumes \<Omega>: "\<Omega> \<in> sets M" and f: "f \<in> borel_measurable M" "\<And>x. 0 \<le> f x" "\<And>x. x \<in> space M - \<Omega> \<Longrightarrow> f x = 0"
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2583
  shows "positive_integral (restrict_space M \<Omega>) f = positive_integral M f"
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2584
using f proof (induct rule: borel_measurable_induct)
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2585
  case (cong f g) then show ?case
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2586
    using positive_integral_cong[of M f g] positive_integral_cong[of "restrict_space M \<Omega>" f g]
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2587
      sets.sets_into_space[OF `\<Omega> \<in> sets M`]
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2588
    by (simp add: subset_eq space_restrict_space)
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2589
next
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2590
  case (set A)
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2591
  then have "A \<subseteq> \<Omega>"
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2592
    unfolding indicator_eq_0_iff by (auto dest: sets.sets_into_space)
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2593
  with set `\<Omega> \<in> sets M` sets.sets_into_space[OF `\<Omega> \<in> sets M`] show ?case
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2594
    by (subst positive_integral_indicator')
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2595
       (auto simp add: sets_restrict_space_iff space_restrict_space
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2596
                  emeasure_restrict_space Int_absorb2
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2597
                dest: sets.sets_into_space)
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2598
next
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2599
  case (mult f c) then show ?case
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2600
    by (cases "c = 0") (simp_all add: measurable_restrict_space1 \<Omega> positive_integral_cmult)
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2601
next
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2602
  case (add f g) then show ?case
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2603
    by (simp add: measurable_restrict_space1 \<Omega> positive_integral_add ereal_add_nonneg_eq_0_iff)
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2604
next
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2605
  case (seq F) then show ?case
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2606
    by (auto simp add: SUP_eq_iff measurable_restrict_space1 \<Omega> positive_integral_monotone_convergence_SUP)
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2607
qed
dbb8ecfe1337 add restrict_space measure
hoelzl
parents: 54230
diff changeset
  2608
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2609
section {* Measure spaces with an associated density *}
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2610
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2611
definition density :: "'a measure \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> 'a measure" where
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2612
  "density M f = measure_of (space M) (sets M) (\<lambda>A. \<integral>\<^sup>+ x. f x * indicator A x \<partial>M)"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  2613
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2614
lemma 
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2615
  shows sets_density[simp]: "sets (density M f) = sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2616
    and space_density[simp]: "space (density M f) = space M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2617
  by (auto simp: density_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2618
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2619
(* FIXME: add conversion to simplify space, sets and measurable *)
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2620
lemma space_density_imp[measurable_dest]:
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2621
  "\<And>x M f. x \<in> space (density M f) \<Longrightarrow> x \<in> space M" by auto
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2622
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2623
lemma 
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2624
  shows measurable_density_eq1[simp]: "g \<in> measurable (density Mg f) Mg' \<longleftrightarrow> g \<in> measurable Mg Mg'"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2625
    and measurable_density_eq2[simp]: "h \<in> measurable Mh (density Mh' f) \<longleftrightarrow> h \<in> measurable Mh Mh'"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2626
    and simple_function_density_eq[simp]: "simple_function (density Mu f) u \<longleftrightarrow> simple_function Mu u"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2627
  unfolding measurable_def simple_function_def by simp_all
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2628
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2629
lemma density_cong: "f \<in> borel_measurable M \<Longrightarrow> f' \<in> borel_measurable M \<Longrightarrow>
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2630
  (AE x in M. f x = f' x) \<Longrightarrow> density M f = density M f'"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
  2631
  unfolding density_def by (auto intro!: measure_of_eq positive_integral_cong_AE sets.space_closed)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2632
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2633
lemma density_max_0: "density M f = density M (\<lambda>x. max 0 (f x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2634
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2635
  have "\<And>x A. max 0 (f x) * indicator A x = max 0 (f x * indicator A x)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2636
    by (auto simp: indicator_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2637
  then show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2638
    unfolding density_def by (simp add: positive_integral_max_0)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2639
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2640
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2641
lemma density_ereal_max_0: "density M (\<lambda>x. ereal (f x)) = density M (\<lambda>x. ereal (max 0 (f x)))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2642
  by (subst density_max_0) (auto intro!: arg_cong[where f="density M"] split: split_max)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2643
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2644
lemma emeasure_density:
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
  2645
  assumes f[measurable]: "f \<in> borel_measurable M" and A[measurable]: "A \<in> sets M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2646
  shows "emeasure (density M f) A = (\<integral>\<^sup>+ x. f x * indicator A x \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2647
    (is "_ = ?\<mu> A")
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2648
  unfolding density_def
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2649
proof (rule emeasure_measure_of_sigma)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2650
  show "sigma_algebra (space M) (sets M)" ..
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2651
  show "positive (sets M) ?\<mu>"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2652
    using f by (auto simp: positive_def intro!: positive_integral_positive)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2653
  have \<mu>_eq: "?\<mu> = (\<lambda>A. \<integral>\<^sup>+ x. max 0 (f x) * indicator A x \<partial>M)" (is "?\<mu> = ?\<mu>'")
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2654
    apply (subst positive_integral_max_0[symmetric])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2655
    apply (intro ext positive_integral_cong_AE AE_I2)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2656
    apply (auto simp: indicator_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2657
    done
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2658
  show "countably_additive (sets M) ?\<mu>"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2659
    unfolding \<mu>_eq
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2660
  proof (intro countably_additiveI)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2661
    fix A :: "nat \<Rightarrow> 'a set" assume "range A \<subseteq> sets M"
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
  2662
    then have "\<And>i. A i \<in> sets M" by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2663
    then have *: "\<And>i. (\<lambda>x. max 0 (f x) * indicator (A i) x) \<in> borel_measurable M"
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
  2664
      by (auto simp: set_eq_iff)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2665
    assume disj: "disjoint_family A"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2666
    have "(\<Sum>n. ?\<mu>' (A n)) = (\<integral>\<^sup>+ x. (\<Sum>n. max 0 (f x) * indicator (A n) x) \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2667
      using f * by (simp add: positive_integral_suminf)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2668
    also have "\<dots> = (\<integral>\<^sup>+ x. max 0 (f x) * (\<Sum>n. indicator (A n) x) \<partial>M)" using f
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2669
      by (auto intro!: suminf_cmult_ereal positive_integral_cong_AE)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2670
    also have "\<dots> = (\<integral>\<^sup>+ x. max 0 (f x) * indicator (\<Union>n. A n) x \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2671
      unfolding suminf_indicator[OF disj] ..
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2672
    finally show "(\<Sum>n. ?\<mu>' (A n)) = ?\<mu>' (\<Union>x. A x)" by simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2673
  qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2674
qed fact
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  2675
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2676
lemma null_sets_density_iff:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2677
  assumes f: "f \<in> borel_measurable M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2678
  shows "A \<in> null_sets (density M f) \<longleftrightarrow> A \<in> sets M \<and> (AE x in M. x \<in> A \<longrightarrow> f x \<le> 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2679
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2680
  { assume "A \<in> sets M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2681
    have eq: "(\<integral>\<^sup>+x. f x * indicator A x \<partial>M) = (\<integral>\<^sup>+x. max 0 (f x) * indicator A x \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2682
      apply (subst positive_integral_max_0[symmetric])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2683
      apply (intro positive_integral_cong)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2684
      apply (auto simp: indicator_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2685
      done
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2686
    have "(\<integral>\<^sup>+x. f x * indicator A x \<partial>M) = 0 \<longleftrightarrow> 
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2687
      emeasure M {x \<in> space M. max 0 (f x) * indicator A x \<noteq> 0} = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2688
      unfolding eq
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2689
      using f `A \<in> sets M`
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2690
      by (intro positive_integral_0_iff) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2691
    also have "\<dots> \<longleftrightarrow> (AE x in M. max 0 (f x) * indicator A x = 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2692
      using f `A \<in> sets M`
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
  2693
      by (intro AE_iff_measurable[OF _ refl, symmetric]) auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2694
    also have "(AE x in M. max 0 (f x) * indicator A x = 0) \<longleftrightarrow> (AE x in M. x \<in> A \<longrightarrow> f x \<le> 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2695
      by (auto simp add: indicator_def max_def split: split_if_asm)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2696
    finally have "(\<integral>\<^sup>+x. f x * indicator A x \<partial>M) = 0 \<longleftrightarrow> (AE x in M. x \<in> A \<longrightarrow> f x \<le> 0)" . }
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2697
  with f show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2698
    by (simp add: null_sets_def emeasure_density cong: conj_cong)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2699
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2700
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2701
lemma AE_density:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2702
  assumes f: "f \<in> borel_measurable M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2703
  shows "(AE x in density M f. P x) \<longleftrightarrow> (AE x in M. 0 < f x \<longrightarrow> P x)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2704
proof
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2705
  assume "AE x in density M f. P x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2706
  with f obtain N where "{x \<in> space M. \<not> P x} \<subseteq> N" "N \<in> sets M" and ae: "AE x in M. x \<in> N \<longrightarrow> f x \<le> 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2707
    by (auto simp: eventually_ae_filter null_sets_density_iff)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2708
  then have "AE x in M. x \<notin> N \<longrightarrow> P x" by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2709
  with ae show "AE x in M. 0 < f x \<longrightarrow> P x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2710
    by (rule eventually_elim2) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2711
next
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2712
  fix N assume ae: "AE x in M. 0 < f x \<longrightarrow> P x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2713
  then obtain N where "{x \<in> space M. \<not> (0 < f x \<longrightarrow> P x)} \<subseteq> N" "N \<in> null_sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2714
    by (auto simp: eventually_ae_filter)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2715
  then have *: "{x \<in> space (density M f). \<not> P x} \<subseteq> N \<union> {x\<in>space M. \<not> 0 < f x}"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2716
    "N \<union> {x\<in>space M. \<not> 0 < f x} \<in> sets M" and ae2: "AE x in M. x \<notin> N"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
  2717
    using f by (auto simp: subset_eq intro!: sets.sets_Collect_neg AE_not_in)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2718
  show "AE x in density M f. P x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2719
    using ae2
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2720
    unfolding eventually_ae_filter[of _ "density M f"] Bex_def null_sets_density_iff[OF f]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2721
    by (intro exI[of _ "N \<union> {x\<in>space M. \<not> 0 < f x}"] conjI *)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2722
       (auto elim: eventually_elim2)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  2723
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  2724
49798
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2725
lemma positive_integral_density':
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2726
  assumes f: "f \<in> borel_measurable M" "AE x in M. 0 \<le> f x"
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  2727
  assumes g: "g \<in> borel_measurable M" "\<And>x. 0 \<le> g x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2728
  shows "integral\<^sup>P (density M f) g = (\<integral>\<^sup>+ x. f x * g x \<partial>M)"
49798
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2729
using g proof induct
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2730
  case (cong u v)
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  2731
  then show ?case
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  2732
    apply (subst positive_integral_cong[OF cong(3)])
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
  2733
    apply (simp_all cong: positive_integral_cong)
49798
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2734
    done
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2735
next
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2736
  case (set A) then show ?case
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2737
    by (simp add: emeasure_density f)
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2738
next
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2739
  case (mult u c)
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2740
  moreover have "\<And>x. f x * (c * u x) = c * (f x * u x)" by (simp add: field_simps)
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2741
  ultimately show ?case
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  2742
    using f by (simp add: positive_integral_cmult)
49798
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2743
next
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2744
  case (add u v)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  2745
  then have "\<And>x. f x * (v x + u x) = f x * v x + f x * u x"
49798
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2746
    by (simp add: ereal_right_distrib)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  2747
  with add f show ?case
49798
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2748
    by (auto simp add: positive_integral_add ereal_zero_le_0_iff intro!: positive_integral_add[symmetric])
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2749
next
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2750
  case (seq U)
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2751
  from f(2) have eq: "AE x in M. f x * (SUP i. U i x) = (SUP i. f x * U i x)"
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2752
    by eventually_elim (simp add: SUPR_ereal_cmult seq)
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2753
  from seq f show ?case
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2754
    apply (simp add: positive_integral_monotone_convergence_SUP)
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2755
    apply (subst positive_integral_cong_AE[OF eq])
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2756
    apply (subst positive_integral_monotone_convergence_SUP_AE)
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2757
    apply (auto simp: incseq_def le_fun_def intro!: ereal_mult_left_mono)
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2758
    done
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2759
qed
38705
aaee86c0e237 moved generic lemmas in Probability to HOL
hoelzl
parents: 38656
diff changeset
  2760
49798
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2761
lemma positive_integral_density:
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2762
  "f \<in> borel_measurable M \<Longrightarrow> AE x in M. 0 \<le> f x \<Longrightarrow> g' \<in> borel_measurable M \<Longrightarrow> 
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2763
    integral\<^sup>P (density M f) g' = (\<integral>\<^sup>+ x. f x * g' x \<partial>M)"
49798
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2764
  by (subst (1 2) positive_integral_max_0[symmetric])
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2765
     (auto intro!: positive_integral_cong_AE
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2766
           simp: measurable_If max_def ereal_zero_le_0_iff positive_integral_density')
8d5668f73c42 induction prove for positive_integral_density
hoelzl
parents: 49797
diff changeset
  2767
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2768
lemma integral_density:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2769
  assumes f: "f \<in> borel_measurable M" "AE x in M. 0 \<le> f x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2770
    and g: "g \<in> borel_measurable M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2771
  shows "integral\<^sup>L (density M f) g = (\<integral> x. f x * g x \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2772
    and "integrable (density M f) g \<longleftrightarrow> integrable M (\<lambda>x. f x * g x)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2773
  unfolding lebesgue_integral_def integrable_def using f g
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2774
  by (auto simp: positive_integral_density)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2775
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2776
lemma emeasure_restricted:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2777
  assumes S: "S \<in> sets M" and X: "X \<in> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2778
  shows "emeasure (density M (indicator S)) X = emeasure M (S \<inter> X)"
38705
aaee86c0e237 moved generic lemmas in Probability to HOL
hoelzl
parents: 38656
diff changeset
  2779
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2780
  have "emeasure (density M (indicator S)) X = (\<integral>\<^sup>+x. indicator S x * indicator X x \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2781
    using S X by (simp add: emeasure_density)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2782
  also have "\<dots> = (\<integral>\<^sup>+x. indicator (S \<inter> X) x \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2783
    by (auto intro!: positive_integral_cong simp: indicator_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2784
  also have "\<dots> = emeasure M (S \<inter> X)"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
  2785
    using S X by (simp add: sets.Int)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2786
  finally show ?thesis .
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2787
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2788
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2789
lemma measure_restricted:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2790
  "S \<in> sets M \<Longrightarrow> X \<in> sets M \<Longrightarrow> measure (density M (indicator S)) X = measure M (S \<inter> X)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2791
  by (simp add: emeasure_restricted measure_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2792
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2793
lemma (in finite_measure) finite_measure_restricted:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2794
  "S \<in> sets M \<Longrightarrow> finite_measure (density M (indicator S))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2795
  by default (simp add: emeasure_restricted)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2796
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2797
lemma emeasure_density_const:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2798
  "A \<in> sets M \<Longrightarrow> 0 \<le> c \<Longrightarrow> emeasure (density M (\<lambda>_. c)) A = c * emeasure M A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2799
  by (auto simp: positive_integral_cmult_indicator emeasure_density)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2800
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2801
lemma measure_density_const:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2802
  "A \<in> sets M \<Longrightarrow> 0 < c \<Longrightarrow> c \<noteq> \<infinity> \<Longrightarrow> measure (density M (\<lambda>_. c)) A = real c * measure M A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2803
  by (auto simp: emeasure_density_const measure_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2804
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2805
lemma density_density_eq:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2806
   "f \<in> borel_measurable M \<Longrightarrow> g \<in> borel_measurable M \<Longrightarrow> AE x in M. 0 \<le> f x \<Longrightarrow>
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2807
   density (density M f) g = density M (\<lambda>x. f x * g x)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2808
  by (auto intro!: measure_eqI simp: emeasure_density positive_integral_density ac_simps)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2809
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2810
lemma distr_density_distr:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2811
  assumes T: "T \<in> measurable M M'" and T': "T' \<in> measurable M' M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2812
    and inv: "\<forall>x\<in>space M. T' (T x) = x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2813
  assumes f: "f \<in> borel_measurable M'"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2814
  shows "distr (density (distr M M' T) f) M T' = density M (f \<circ> T)" (is "?R = ?L")
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2815
proof (rule measure_eqI)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2816
  fix A assume A: "A \<in> sets ?R"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2817
  { fix x assume "x \<in> space M"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
  2818
    with sets.sets_into_space[OF A]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2819
    have "indicator (T' -` A \<inter> space M') (T x) = (indicator A x :: ereal)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2820
      using T inv by (auto simp: indicator_def measurable_space) }
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2821
  with A T T' f show "emeasure ?R A = emeasure ?L A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2822
    by (simp add: measurable_comp emeasure_density emeasure_distr
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2823
                  positive_integral_distr measurable_sets cong: positive_integral_cong)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2824
qed simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2825
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2826
lemma density_density_divide:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2827
  fixes f g :: "'a \<Rightarrow> real"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2828
  assumes f: "f \<in> borel_measurable M" "AE x in M. 0 \<le> f x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2829
  assumes g: "g \<in> borel_measurable M" "AE x in M. 0 \<le> g x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2830
  assumes ac: "AE x in M. f x = 0 \<longrightarrow> g x = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2831
  shows "density (density M f) (\<lambda>x. g x / f x) = density M g"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2832
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2833
  have "density M g = density M (\<lambda>x. f x * (g x / f x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2834
    using f g ac by (auto intro!: density_cong measurable_If)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2835
  then show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2836
    using f g by (subst density_density_eq) auto
38705
aaee86c0e237 moved generic lemmas in Probability to HOL
hoelzl
parents: 38656
diff changeset
  2837
qed
aaee86c0e237 moved generic lemmas in Probability to HOL
hoelzl
parents: 38656
diff changeset
  2838
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2839
section {* Point measure *}
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2840
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2841
definition point_measure :: "'a set \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> 'a measure" where
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2842
  "point_measure A f = density (count_space A) f"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2843
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2844
lemma
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2845
  shows space_point_measure: "space (point_measure A f) = A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2846
    and sets_point_measure: "sets (point_measure A f) = Pow A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2847
  by (auto simp: point_measure_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2848
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2849
lemma measurable_point_measure_eq1[simp]:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2850
  "g \<in> measurable (point_measure A f) M \<longleftrightarrow> g \<in> A \<rightarrow> space M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2851
  unfolding point_measure_def by simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2852
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2853
lemma measurable_point_measure_eq2_finite[simp]:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2854
  "finite A \<Longrightarrow>
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2855
   g \<in> measurable M (point_measure A f) \<longleftrightarrow>
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2856
    (g \<in> space M \<rightarrow> A \<and> (\<forall>a\<in>A. g -` {a} \<inter> space M \<in> sets M))"
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
  2857
  unfolding point_measure_def by (simp add: measurable_count_space_eq2)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2858
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2859
lemma simple_function_point_measure[simp]:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2860
  "simple_function (point_measure A f) g \<longleftrightarrow> finite (g ` A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2861
  by (simp add: point_measure_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2862
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2863
lemma emeasure_point_measure:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2864
  assumes A: "finite {a\<in>X. 0 < f a}" "X \<subseteq> A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2865
  shows "emeasure (point_measure A f) X = (\<Sum>a|a\<in>X \<and> 0 < f a. f a)"
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35833
diff changeset
  2866
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2867
  have "{a. (a \<in> X \<longrightarrow> a \<in> A \<and> 0 < f a) \<and> a \<in> X} = {a\<in>X. 0 < f a}"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2868
    using `X \<subseteq> A` by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2869
  with A show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2870
    by (simp add: emeasure_density positive_integral_count_space ereal_zero_le_0_iff
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2871
                  point_measure_def indicator_def)
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35833
diff changeset
  2872
qed
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35833
diff changeset
  2873
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2874
lemma emeasure_point_measure_finite:
49795
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49775
diff changeset
  2875
  "finite A \<Longrightarrow> (\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i) \<Longrightarrow> X \<subseteq> A \<Longrightarrow> emeasure (point_measure A f) X = (\<Sum>a\<in>X. f a)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2876
  by (subst emeasure_point_measure) (auto dest: finite_subset intro!: setsum_mono_zero_left simp: less_le)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2877
49795
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49775
diff changeset
  2878
lemma emeasure_point_measure_finite2:
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49775
diff changeset
  2879
  "X \<subseteq> A \<Longrightarrow> finite X \<Longrightarrow> (\<And>i. i \<in> X \<Longrightarrow> 0 \<le> f i) \<Longrightarrow> emeasure (point_measure A f) X = (\<Sum>a\<in>X. f a)"
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49775
diff changeset
  2880
  by (subst emeasure_point_measure)
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49775
diff changeset
  2881
     (auto dest: finite_subset intro!: setsum_mono_zero_left simp: less_le)
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49775
diff changeset
  2882
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2883
lemma null_sets_point_measure_iff:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2884
  "X \<in> null_sets (point_measure A f) \<longleftrightarrow> X \<subseteq> A \<and> (\<forall>x\<in>X. f x \<le> 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2885
 by (auto simp: AE_count_space null_sets_density_iff point_measure_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2886
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2887
lemma AE_point_measure:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2888
  "(AE x in point_measure A f. P x) \<longleftrightarrow> (\<forall>x\<in>A. 0 < f x \<longrightarrow> P x)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2889
  unfolding point_measure_def
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2890
  by (subst AE_density) (auto simp: AE_density AE_count_space point_measure_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2891
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2892
lemma positive_integral_point_measure:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2893
  "finite {a\<in>A. 0 < f a \<and> 0 < g a} \<Longrightarrow>
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2894
    integral\<^sup>P (point_measure A f) g = (\<Sum>a|a\<in>A \<and> 0 < f a \<and> 0 < g a. f a * g a)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2895
  unfolding point_measure_def
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2896
  apply (subst density_max_0)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2897
  apply (subst positive_integral_density)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2898
  apply (simp_all add: AE_count_space positive_integral_density)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2899
  apply (subst positive_integral_count_space )
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2900
  apply (auto intro!: setsum_cong simp: max_def ereal_zero_less_0_iff)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2901
  apply (rule finite_subset)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2902
  prefer 2
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2903
  apply assumption
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2904
  apply auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2905
  done
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2906
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2907
lemma positive_integral_point_measure_finite:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2908
  "finite A \<Longrightarrow> (\<And>a. a \<in> A \<Longrightarrow> 0 \<le> f a) \<Longrightarrow> (\<And>a. a \<in> A \<Longrightarrow> 0 \<le> g a) \<Longrightarrow>
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2909
    integral\<^sup>P (point_measure A f) g = (\<Sum>a\<in>A. f a * g a)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2910
  by (subst positive_integral_point_measure) (auto intro!: setsum_mono_zero_left simp: less_le)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2911
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2912
lemma lebesgue_integral_point_measure_finite:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2913
  "finite A \<Longrightarrow> (\<And>a. a \<in> A \<Longrightarrow> 0 \<le> f a) \<Longrightarrow> integral\<^sup>L (point_measure A f) g = (\<Sum>a\<in>A. f a * g a)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2914
  by (simp add: lebesgue_integral_count_space_finite AE_count_space integral_density point_measure_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2915
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2916
lemma integrable_point_measure_finite:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2917
  "finite A \<Longrightarrow> integrable (point_measure A (\<lambda>x. ereal (f x))) g"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2918
  unfolding point_measure_def
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2919
  apply (subst density_ereal_max_0)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2920
  apply (subst integral_density)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2921
  apply (auto simp: AE_count_space integrable_count_space)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2922
  done
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2923
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2924
section {* Uniform measure *}
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2925
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2926
definition "uniform_measure M A = density M (\<lambda>x. indicator A x / emeasure M A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2927
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2928
lemma
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2929
  shows sets_uniform_measure[simp]: "sets (uniform_measure M A) = sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2930
    and space_uniform_measure[simp]: "space (uniform_measure M A) = space M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2931
  by (auto simp: uniform_measure_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2932
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2933
lemma emeasure_uniform_measure[simp]:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2934
  assumes A: "A \<in> sets M" and B: "B \<in> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2935
  shows "emeasure (uniform_measure M A) B = emeasure M (A \<inter> B) / emeasure M A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2936
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51340
diff changeset
  2937
  from A B have "emeasure (uniform_measure M A) B = (\<integral>\<^sup>+x. (1 / emeasure M A) * indicator (A \<inter> B) x \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2938
    by (auto simp add: uniform_measure_def emeasure_density split: split_indicator
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2939
             intro!: positive_integral_cong)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2940
  also have "\<dots> = emeasure M (A \<inter> B) / emeasure M A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2941
    using A B
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
  2942
    by (subst positive_integral_cmult_indicator) (simp_all add: sets.Int emeasure_nonneg)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2943
  finally show ?thesis .
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2944
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2945
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2946
lemma emeasure_neq_0_sets: "emeasure M A \<noteq> 0 \<Longrightarrow> A \<in> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2947
  using emeasure_notin_sets[of A M] by blast
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2948
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2949
lemma measure_uniform_measure[simp]:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2950
  assumes A: "emeasure M A \<noteq> 0" "emeasure M A \<noteq> \<infinity>" and B: "B \<in> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2951
  shows "measure (uniform_measure M A) B = measure M (A \<inter> B) / measure M A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2952
  using emeasure_uniform_measure[OF emeasure_neq_0_sets[OF A(1)] B] A
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2953
  by (cases "emeasure M A" "emeasure M (A \<inter> B)" rule: ereal2_cases) (simp_all add: measure_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2954
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2955
section {* Uniform count measure *}
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2956
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2957
definition "uniform_count_measure A = point_measure A (\<lambda>x. 1 / card A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2958
 
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2959
lemma 
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2960
  shows space_uniform_count_measure: "space (uniform_count_measure A) = A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2961
    and sets_uniform_count_measure: "sets (uniform_count_measure A) = Pow A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2962
    unfolding uniform_count_measure_def by (auto simp: space_point_measure sets_point_measure)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2963
 
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2964
lemma emeasure_uniform_count_measure:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2965
  "finite A \<Longrightarrow> X \<subseteq> A \<Longrightarrow> emeasure (uniform_count_measure A) X = card X / card A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2966
  by (simp add: real_eq_of_nat emeasure_point_measure_finite uniform_count_measure_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2967
 
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2968
lemma measure_uniform_count_measure:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2969
  "finite A \<Longrightarrow> X \<subseteq> A \<Longrightarrow> measure (uniform_count_measure A) X = card X / card A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2970
  by (simp add: real_eq_of_nat emeasure_point_measure_finite uniform_count_measure_def measure_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  2971
35748
5f35613d9a65 Equality of integral and infinite sum.
hoelzl
parents: 35692
diff changeset
  2972
end