src/HOL/Probability/Lebesgue_Integration.thy
author hoelzl
Fri, 02 Nov 2012 14:23:54 +0100
changeset 50003 8c213922ed49
parent 50002 ce0d316b5b44
child 50021 d96a3f468203
permissions -rw-r--r--
use measurability prover
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
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    12
lemma ereal_minus_eq_PInfty_iff:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    13
  fixes x y :: ereal shows "x - y = \<infinity> \<longleftrightarrow> y = -\<infinity> \<or> x = \<infinity>"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    14
  by (cases x y rule: ereal2_cases) simp_all
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    15
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
    16
lemma real_ereal_1[simp]: "real (1::ereal) = 1"
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
    17
  unfolding one_ereal_def by simp
42991
3fa22920bf86 integral strong monotone; finite subadditivity for measure
hoelzl
parents: 42950
diff changeset
    18
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
    19
lemma ereal_indicator_pos[simp,intro]: "0 \<le> (indicator A x ::ereal)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    20
  unfolding indicator_def by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    21
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    22
lemma tendsto_real_max:
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    23
  fixes x y :: real
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    24
  assumes "(X ---> x) net"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    25
  assumes "(Y ---> y) net"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    26
  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
    27
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    28
  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
    29
    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
    30
  show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    31
    unfolding *
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    32
    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
    33
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    34
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    35
lemma measurable_sets2[intro]:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    36
  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
    37
  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
    38
  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
    39
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    40
  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
    41
    by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    42
  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
    43
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    44
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    45
lemma incseq_Suc_iff: "incseq f \<longleftrightarrow> (\<forall>n. f n \<le> f (Suc n))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    46
proof
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    47
  assume "\<forall>n. f n \<le> f (Suc n)" then show "incseq f" by (auto intro!: incseq_SucI)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    48
qed (auto simp: incseq_def)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    49
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    50
section "Simple function"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    51
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    52
text {*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    53
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    54
Our simple functions are not restricted to positive real numbers. Instead
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    55
they are just functions with a finite range and are measurable when singleton
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    56
sets are measurable.
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    57
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    58
*}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    59
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
    60
definition "simple_function M g \<longleftrightarrow>
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    61
    finite (g ` space M) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    62
    (\<forall>x \<in> g ` space M. g -` {x} \<inter> space M \<in> sets M)"
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    63
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    64
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
    65
  assumes "simple_function M g"
40875
9a9d33f6fb46 generalized simple_functionD
hoelzl
parents: 40873
diff changeset
    66
  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
    67
proof -
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
    68
  show "finite (g ` space M)"
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
    69
    using assms unfolding simple_function_def by auto
40875
9a9d33f6fb46 generalized simple_functionD
hoelzl
parents: 40873
diff changeset
    70
  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
    71
  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
    72
  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
    73
    by (auto simp del: UN_simps simp: simple_function_def)
40871
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
    74
qed
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    75
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    76
lemma simple_function_measurable2[intro]:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    77
  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
    78
  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
    79
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    80
  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
    81
    by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    82
  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
    83
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    84
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    85
lemma simple_function_indicator_representation:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
    86
  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
    87
  assumes f: "simple_function M f" and x: "x \<in> space M"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    88
  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
    89
  (is "?l = ?r")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    90
proof -
38705
aaee86c0e237 moved generic lemmas in Probability to HOL
hoelzl
parents: 38656
diff changeset
    91
  have "?r = (\<Sum>y \<in> f ` space M.
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    92
    (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
    93
    by (auto intro!: setsum_cong2)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    94
  also have "... =  f x *  indicator (f -` {f x} \<inter> space M) x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    95
    using assms by (auto dest: simple_functionD simp: setsum_delta)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    96
  also have "... = f x" using x by (auto simp: indicator_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    97
  finally show ?thesis by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
    98
qed
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    99
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   100
lemma simple_function_notspace:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   101
  "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
   102
proof -
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   103
  have "?h ` space M \<subseteq> {0}" unfolding indicator_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   104
  hence [simp, intro]: "finite (?h ` space M)" by (auto intro: finite_subset)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   105
  have "?h -` {0} \<inter> space M = space M" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   106
  thus ?thesis unfolding simple_function_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   107
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   108
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   109
lemma simple_function_cong:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   110
  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
   111
  shows "simple_function M f \<longleftrightarrow> simple_function M g"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   112
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   113
  have "f ` space M = g ` space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   114
    "\<And>x. f -` {x} \<inter> space M = g -` {x} \<inter> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   115
    using assms by (auto intro!: image_eqI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   116
  thus ?thesis unfolding simple_function_def using assms by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   117
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   118
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   119
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
   120
  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
   121
  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
   122
  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
   123
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   124
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
   125
  assumes "simple_function M f"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   126
  shows "f \<in> borel_measurable M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   127
proof (rule borel_measurableI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   128
  fix S
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   129
  let ?I = "f ` (f -` S \<inter> space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   130
  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
   131
  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
   132
    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
   133
    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
   134
  hence "?U \<in> sets M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   135
    apply (rule finite_UN)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   136
    using assms unfolding simple_function_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   137
  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
   138
qed
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
   139
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   140
lemma simple_function_borel_measurable:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   141
  fixes f :: "'a \<Rightarrow> 'x::{t2_space}"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   142
  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
   143
  shows "simple_function M f"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   144
  using assms unfolding simple_function_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   145
  by (auto intro: borel_measurable_vimage)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   146
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   147
lemma simple_function_eq_borel_measurable:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   148
  fixes f :: "'a \<Rightarrow> ereal"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   149
  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
   150
  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
   151
  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
   152
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   153
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
   154
  "simple_function M (\<lambda>x. c)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   155
  by (auto intro: finite_subset simp: simple_function_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   156
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
   157
  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
   158
  shows "simple_function M (g \<circ> f)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   159
  unfolding simple_function_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   160
proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   161
  show "finite ((g \<circ> f) ` space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   162
    using assms unfolding simple_function_def by (auto simp: image_compose)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   163
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   164
  fix x assume "x \<in> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   165
  let ?G = "g -` {g (f x)} \<inter> (f`space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   166
  have *: "(g \<circ> f) -` {(g \<circ> f) x} \<inter> space M =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   167
    (\<Union>x\<in>?G. f -` {x} \<inter> space M)" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   168
  show "(g \<circ> f) -` {(g \<circ> f) x} \<inter> space M \<in> sets M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   169
    using assms unfolding simple_function_def *
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
   170
    by (rule_tac finite_UN) auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   171
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   172
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   173
lemma simple_function_indicator[intro, simp]:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   174
  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
   175
  shows "simple_function M (indicator A)"
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
   176
proof -
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   177
  have "indicator A ` space M \<subseteq> {0, 1}" (is "?S \<subseteq> _")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   178
    by (auto simp: indicator_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   179
  hence "finite ?S" by (rule finite_subset) simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   180
  moreover have "- A \<inter> space M = space M - A" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   181
  ultimately show ?thesis unfolding simple_function_def
46905
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 46884
diff changeset
   182
    using assms by (auto simp: indicator_def [abs_def])
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
   183
qed
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
   184
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   185
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
   186
  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
   187
  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
   188
  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
   189
  unfolding simple_function_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   190
proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   191
  show "finite (?p ` space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   192
    using assms unfolding simple_function_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   193
    by (rule_tac finite_subset[of _ "f`space M \<times> g`space M"]) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   194
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   195
  fix x assume "x \<in> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   196
  have "(\<lambda>x. (f x, g x)) -` {(f x, g x)} \<inter> space M =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   197
      (f -` {f x} \<inter> space M) \<inter> (g -` {g x} \<inter> space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   198
    by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   199
  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
   200
    using assms unfolding simple_function_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   201
qed
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
   202
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   203
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
   204
  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
   205
  shows "simple_function M (\<lambda>x. g (f x))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   206
  using simple_function_compose[OF assms, of g]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   207
  by (simp add: comp_def)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   208
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   209
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
   210
  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
   211
  shows "simple_function M (\<lambda>x. h (f x) (g x))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   212
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
   213
  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
   214
    using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   215
  thus ?thesis by (simp_all add: comp_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   216
qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   217
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   218
lemmas simple_function_add[intro, simp] = simple_function_compose2[where h="op +"]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   219
  and simple_function_diff[intro, simp] = simple_function_compose2[where h="op -"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   220
  and simple_function_uminus[intro, simp] = simple_function_compose[where g="uminus"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   221
  and simple_function_mult[intro, simp] = simple_function_compose2[where h="op *"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   222
  and simple_function_div[intro, simp] = simple_function_compose2[where h="op /"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   223
  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
   224
  and simple_function_max[intro, simp] = simple_function_compose2[where h=max]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   225
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   226
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
   227
  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
   228
  shows "simple_function M (\<lambda>x. \<Sum>i\<in>P. f i x)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   229
proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   230
  assume "finite P" from this assms show ?thesis by induct auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   231
qed auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   232
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   233
lemma
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   234
  fixes f g :: "'a \<Rightarrow> real" assumes sf: "simple_function M f"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   235
  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
   236
  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
   237
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   238
lemma
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   239
  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
   240
  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
   241
  by (auto intro!: simple_function_compose1[OF sf])
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   242
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   243
lemma borel_measurable_implies_simple_function_sequence:
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   244
  fixes u :: "'a \<Rightarrow> ereal"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   245
  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
   246
  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
   247
             (\<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
   248
proof -
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   249
  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
   250
  { 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
   251
    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
   252
      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
   253
      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
   254
         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
   255
      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
   256
        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
   257
      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
   258
        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
   259
    qed auto }
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   260
  note f_upper = this
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   261
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   262
  have real_f:
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   263
    "\<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
   264
    unfolding f_def by auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   265
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   266
  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
   267
  show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   268
  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
   269
    fix i
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   270
    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
   271
    proof (intro simple_function_borel_measurable)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   272
      show "(\<lambda>x. real (f x i)) \<in> borel_measurable M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   273
        using u by (auto intro!: measurable_If simp: real_f)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   274
      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
   275
        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
   276
      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
   277
        by (rule finite_subset) auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   278
    qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   279
    then show "simple_function M (?g i)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   280
      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
   281
  next
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   282
    show "incseq ?g"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   283
    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
   284
      fix x and i :: nat
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   285
      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
   286
      proof ((split split_if)+, intro conjI impI)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   287
        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
   288
        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
   289
          by (cases "u x") (auto intro!: le_natfloor)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   290
      next
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   291
        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
   292
        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
   293
          by (cases "u x") auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   294
      next
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   295
        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
   296
        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
   297
          by simp
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   298
        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
   299
        proof cases
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   300
          assume "0 \<le> u x" then show ?thesis
46671
3a40ea076230 removing unnecessary assumptions in RComplete;
bulwahn
parents: 45342
diff changeset
   301
            by (intro le_mult_natfloor) 
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   302
        next
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   303
          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
   304
            by (cases "u x") (auto simp: natfloor_neg mult_nonpos_nonneg)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   305
        qed
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   306
        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
   307
          by (simp add: ac_simps)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   308
        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
   309
      qed simp
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   310
      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
   311
        by (auto simp: field_simps)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   312
    qed
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   313
  next
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   314
    fix x show "(SUP i. ?g i x) = max 0 (u x)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   315
    proof (rule ereal_SUPI)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   316
      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
   317
        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
   318
                                     mult_nonpos_nonneg mult_nonneg_nonneg)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   319
    next
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   320
      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
   321
      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
   322
      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
   323
      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
   324
      proof (cases y)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   325
        case (real r)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   326
        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
   327
        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
   328
        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
   329
        then guess p .. note ux = this
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44568
diff changeset
   330
        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
   331
        have "p \<le> r"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   332
        proof (rule ccontr)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   333
          assume "\<not> p \<le> r"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   334
          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
   335
          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
   336
          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
   337
          moreover
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   338
          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
   339
            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
   340
            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
   341
          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
   342
            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
   343
          ultimately show False by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   344
        qed
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   345
        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
   346
      qed (insert `0 \<le> y`, auto)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   347
    qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   348
  qed (auto simp: divide_nonneg_pos)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   349
qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   350
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   351
lemma borel_measurable_implies_simple_function_sequence':
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   352
  fixes u :: "'a \<Rightarrow> ereal"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   353
  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
   354
  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
   355
    "\<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
   356
  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
   357
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   358
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
   359
  fixes u :: "'a \<Rightarrow> ereal"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   360
  assumes u: "simple_function M u"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   361
  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
   362
  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
   363
  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
   364
  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
   365
  shows "P u"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   366
proof (rule cong)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   367
  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
   368
  proof eventually_elim
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   369
    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
   370
    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
   371
    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
   372
  qed
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   373
next
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   374
  from u have "finite (u ` space M)"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   375
    unfolding simple_function_def by auto
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   376
  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
   377
  proof induct
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   378
    case empty show ?case
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   379
      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
   380
  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
   381
next
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   382
  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
   383
    apply (subst simple_function_cong)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   384
    apply (rule simple_function_indicator_representation[symmetric])
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   385
    apply (auto intro: u)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   386
    done
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   387
qed fact
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   388
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   389
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
   390
  fixes u :: "'a \<Rightarrow> ereal"
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   391
  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
   392
  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
   393
  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
   394
  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
   395
  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
   396
  shows "P u"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   397
proof -
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   398
  show ?thesis
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   399
  proof (rule cong)
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   400
    fix x assume x: "x \<in> space M"
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   401
    from simple_function_indicator_representation[OF u x]
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   402
    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
   403
  next
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   404
    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
   405
      apply (subst simple_function_cong)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   406
      apply (rule simple_function_indicator_representation[symmetric])
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   407
      apply (auto intro: u)
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   408
      done
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   409
  next
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   410
    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
   411
      unfolding simple_function_def by auto
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   412
    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
   413
    proof induct
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   414
      case empty show ?case
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   415
        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
   416
    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
   417
       simple_function_setsum)
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   418
  qed fact
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   419
qed
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   420
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   421
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
   422
  fixes u :: "'a \<Rightarrow> ereal"
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   423
  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
   424
  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
   425
  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
   426
  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
   427
  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
   428
  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
   429
  shows "P u"
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   430
  using u
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   431
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
   432
  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
   433
    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
   434
  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
   435
    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
   436
  
49797
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
   437
  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
   438
    by (simp add: borel_measurable_simple_function)
28066863284c add induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49796
diff changeset
   439
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   440
  show "P u"
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   441
    unfolding u_eq
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   442
  proof (rule seq)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   443
    fix i show "P (U i)"
49799
15ea98537c76 strong nonnegativ (instead of ae nn) for induction rule
hoelzl
parents: 49798
diff changeset
   444
      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
   445
      by (induct rule: simple_function_induct_nn)
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   446
         (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
   447
  qed fact+
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   448
qed
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   449
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   450
lemma simple_function_If_set:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   451
  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
   452
  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
   453
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   454
  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
   455
  show ?thesis unfolding simple_function_def
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   456
  proof safe
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   457
    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
   458
    from finite_subset[OF this] assms
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   459
    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
   460
  next
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   461
    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
   462
    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
   463
      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
   464
      else ((F (g x) \<inter> (A \<inter> space M)) \<union> (G (g x) - (G (g x) \<inter> (A \<inter> space M)))))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   465
      using sets_into_space[OF A] by (auto split: split_if_asm simp: G_def F_def)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   466
    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
   467
      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
   468
    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
   469
  qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   470
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   471
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   472
lemma simple_function_If:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   473
  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
   474
  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
   475
proof -
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   476
  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
   477
  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
   478
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   479
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   480
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
   481
  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
   482
  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
   483
  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
   484
  using assms unfolding simple_function_def by auto
39092
98de40859858 move lemmas to correct theory files
hoelzl
parents: 38705
diff changeset
   485
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   486
lemma simple_function_comp:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   487
  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
   488
    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
   489
  shows "simple_function M (\<lambda>x. f (T x))"
41661
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   490
proof (intro simple_function_def[THEN iffD2] conjI ballI)
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   491
  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
   492
    using T unfolding measurable_def by auto
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   493
  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
   494
    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
   495
  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
   496
  then have "i \<in> f ` space M'"
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   497
    using T unfolding measurable_def by auto
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   498
  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
   499
    using f unfolding simple_function_def by auto
41661
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   500
  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
   501
    using T unfolding measurable_def by auto
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   502
  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
   503
    using T unfolding measurable_def by auto
baf1964bc468 use pre-image measure, instead of image
hoelzl
parents: 41545
diff changeset
   504
  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
   505
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   506
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   507
section "Simple integral"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   508
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   509
definition simple_integral :: "'a measure \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> ereal" ("integral\<^isup>S") where
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   510
  "integral\<^isup>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
   511
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
   512
syntax
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   513
  "_simple_integral" :: "pttrn \<Rightarrow> ereal \<Rightarrow> 'a measure \<Rightarrow> ereal" ("\<integral>\<^isup>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
   514
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
   515
translations
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   516
  "\<integral>\<^isup>S x. f \<partial>M" == "CONST simple_integral M (%x. f)"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   517
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   518
lemma simple_integral_cong:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   519
  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
   520
  shows "integral\<^isup>S M f = integral\<^isup>S M g"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   521
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   522
  have "f ` space M = g ` space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   523
    "\<And>x. f -` {x} \<inter> space M = g -` {x} \<inter> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   524
    using assms by (auto intro!: image_eqI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   525
  thus ?thesis unfolding simple_integral_def by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   526
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   527
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   528
lemma simple_integral_const[simp]:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   529
  "(\<integral>\<^isup>Sx. c \<partial>M) = c * (emeasure M) (space M)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   530
proof (cases "space M = {}")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   531
  case True thus ?thesis unfolding simple_integral_def by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   532
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   533
  case False hence "(\<lambda>x. c) ` space M = {c}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   534
  thus ?thesis unfolding simple_integral_def by simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   535
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   536
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   537
lemma simple_function_partition:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   538
  assumes f: "simple_function M f" and g: "simple_function M g"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   539
  shows "integral\<^isup>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
   540
    (is "_ = setsum _ (?p ` space M)")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   541
proof-
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   542
  let ?sub = "\<lambda>x. ?p ` (f -` {x} \<inter> space M)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   543
  let ?SIGMA = "Sigma (f`space M) ?sub"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   544
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   545
  have [intro]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   546
    "finite (f ` space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   547
    "finite (g ` space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   548
    using assms unfolding simple_function_def by simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   549
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   550
  { fix A
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   551
    have "?p ` (A \<inter> space M) \<subseteq>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   552
      (\<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
   553
      by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   554
    hence "finite (?p ` (A \<inter> space M))"
40786
0a54cfc9add3 gave more standard finite set rules simp and intro attribute
nipkow
parents: 39910
diff changeset
   555
      by (rule finite_subset) auto }
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   556
  note this[intro, simp]
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   557
  note sets = simple_function_measurable2[OF f g]
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   558
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   559
  { fix x assume "x \<in> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   560
    have "\<Union>(?sub (f x)) = (f -` {f x} \<inter> space M)" by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   561
    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
   562
      by (subst setsum_emeasure) (auto simp: disjoint_family_on_def) }
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   563
  hence "integral\<^isup>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
   564
    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
   565
    by (subst setsum_Sigma[symmetric])
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   566
       (auto intro!: setsum_cong setsum_ereal_right_distrib)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   567
  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
   568
  proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   569
    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
   570
    have "(\<lambda>A. (the_elem (f ` A), A)) ` ?p ` space M
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   571
      = (\<lambda>x. (f x, ?p x)) ` space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   572
    proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   573
      fix x assume "x \<in> space M"
39910
10097e0a9dbd constant `contents` renamed to `the_elem`
haftmann
parents: 39302
diff changeset
   574
      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
   575
        by (auto intro!: image_eqI[of _ _ "?p x"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   576
    qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   577
    thus ?thesis
39910
10097e0a9dbd constant `contents` renamed to `the_elem`
haftmann
parents: 39302
diff changeset
   578
      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
   579
      apply (rule_tac x="xa" in image_eqI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   580
      by simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   581
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   582
  finally show ?thesis .
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   583
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   584
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   585
lemma simple_integral_add[simp]:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   586
  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"
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
   587
  shows "(\<integral>\<^isup>Sx. f x + g x \<partial>M) = integral\<^isup>S M f + integral\<^isup>S M g"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   588
proof -
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   589
  { fix x let ?S = "g -` {g x} \<inter> f -` {f x} \<inter> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   590
    assume "x \<in> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   591
    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
   592
        "(\<lambda>x. (f x, g x)) -` {(f x, g x)} \<inter> space M = ?S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   593
      by auto }
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   594
  with assms show ?thesis
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   595
    unfolding
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   596
      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
   597
      simple_function_partition[OF f g]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   598
      simple_function_partition[OF g f]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   599
    by (subst (3) Int_commute)
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   600
       (auto simp add: ereal_left_distrib setsum_addf[symmetric] intro!: setsum_cong)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   601
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   602
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   603
lemma simple_integral_setsum[simp]:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   604
  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
   605
  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
   606
  shows "(\<integral>\<^isup>Sx. (\<Sum>i\<in>P. f i x) \<partial>M) = (\<Sum>i\<in>P. integral\<^isup>S M (f i))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   607
proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   608
  assume "finite P"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   609
  from this assms show ?thesis
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   610
    by induct (auto simp: simple_function_setsum simple_integral_add setsum_nonneg)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   611
qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   612
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   613
lemma simple_integral_mult[simp]:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   614
  assumes f: "simple_function M f" "\<And>x. 0 \<le> f 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
   615
  shows "(\<integral>\<^isup>Sx. c * f x \<partial>M) = c * integral\<^isup>S M f"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   616
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   617
  note mult = simple_function_mult[OF simple_function_const[of _ c] f(1)]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   618
  { 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
   619
    assume "x \<in> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   620
    hence "(\<lambda>x. c * f x) ` ?S = {c * f x}" "f ` ?S = {f x}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   621
      by auto }
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   622
  with assms show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   623
    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
   624
              simple_function_partition[OF f(1) mult]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   625
    by (subst setsum_ereal_right_distrib)
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   626
       (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
   627
qed
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
   628
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   629
lemma simple_integral_mono_AE:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   630
  assumes f: "simple_function M f" and g: "simple_function M g"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   631
  and mono: "AE x in M. f x \<le> g 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
   632
  shows "integral\<^isup>S M f \<le> integral\<^isup>S M g"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   633
proof -
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   634
  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
   635
  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
   636
    "\<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
   637
  show ?thesis
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   638
    unfolding *
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   639
      simple_function_partition[OF f g]
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   640
      simple_function_partition[OF g f]
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   641
  proof (safe intro!: setsum_mono)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   642
    fix x assume "x \<in> space M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   643
    then have *: "f ` ?S x = {f x}" "g ` ?S x = {g x}" by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   644
    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
   645
    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
   646
      case True then show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   647
        using * assms(1,2)[THEN simple_functionD(2)]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   648
        by (auto intro!: ereal_mult_right_mono)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   649
    next
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   650
      case False
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   651
      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
   652
        using mono by (auto elim!: AE_E)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   653
      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
   654
      moreover have "?S x \<in> sets M" using assms
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
   655
        by (rule_tac Int) (auto intro!: simple_functionD)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   656
      ultimately have "(emeasure M) (?S x) \<le> (emeasure M) N"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   657
        using `N \<in> sets M` by (auto intro!: emeasure_mono)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   658
      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
   659
        using assms(1,2)[THEN simple_functionD(2)] by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   660
      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
   661
      then show ?thesis by simp
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   662
    qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   663
  qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   664
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   665
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   666
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
   667
  assumes "simple_function M f" and "simple_function M g"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   668
  and mono: "\<And> x. x \<in> space M \<Longrightarrow> f x \<le> g 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
   669
  shows "integral\<^isup>S M f \<le> integral\<^isup>S M g"
41705
1100512e16d8 add auto support for AE_mp
hoelzl
parents: 41689
diff changeset
   670
  using assms by (intro simple_integral_mono_AE) auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   671
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   672
lemma simple_integral_cong_AE:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   673
  assumes "simple_function M f" and "simple_function M g"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   674
  and "AE x in M. f x = g 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
   675
  shows "integral\<^isup>S M f = integral\<^isup>S M g"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   676
  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
   677
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   678
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
   679
  assumes sf: "simple_function M f" "simple_function M g"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   680
  and mea: "(emeasure M) {x\<in>space M. f x \<noteq> g x} = 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
   681
  shows "integral\<^isup>S M f = integral\<^isup>S M g"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   682
proof (intro simple_integral_cong_AE sf AE_I)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   683
  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
   684
  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
   685
    using sf[THEN borel_measurable_simple_function] by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   686
qed simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   687
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   688
lemma simple_integral_indicator:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   689
  assumes "A \<in> sets M"
49796
182fa22e7ee8 introduce induction rules for simple functions and for Borel measurable functions
hoelzl
parents: 49795
diff changeset
   690
  assumes f: "simple_function 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
   691
  shows "(\<integral>\<^isup>Sx. f x * indicator A x \<partial>M) =
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   692
    (\<Sum>x \<in> f ` space M. x * (emeasure M) (f -` {x} \<inter> space M \<inter> A))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   693
proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   694
  assume "A = 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
   695
  moreover hence "(\<integral>\<^isup>Sx. f x * indicator A x \<partial>M) = integral\<^isup>S M f"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   696
    by (auto intro!: simple_integral_cong)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   697
  moreover have "\<And>X. X \<inter> space M \<inter> space M = X \<inter> space M" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   698
  ultimately show ?thesis by (simp add: simple_integral_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   699
next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   700
  assume "A \<noteq> space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   701
  then obtain x where x: "x \<in> space M" "x \<notin> A" using sets_into_space[OF assms(1)] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   702
  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
   703
  proof safe
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   704
    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
   705
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   706
    fix y assume "y \<in> A" thus "f y \<in> ?I ` space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   707
      using sets_into_space[OF assms(1)] by (auto intro!: image_eqI[of _ _ y])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   708
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   709
    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
   710
  qed
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
   711
  have *: "(\<integral>\<^isup>Sx. f x * indicator A x \<partial>M) =
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   712
    (\<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
   713
    unfolding simple_integral_def I
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   714
  proof (rule setsum_mono_zero_cong_left)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   715
    show "finite (f ` space M \<union> {0})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   716
      using assms(2) unfolding simple_function_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   717
    show "f ` A \<union> {0} \<subseteq> f`space M \<union> {0}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   718
      using sets_into_space[OF assms(1)] by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   719
    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
   720
      by (auto simp: image_iff)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   721
    thus "\<forall>i\<in>f ` space M \<union> {0} - (f ` A \<union> {0}).
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   722
      i * (emeasure M) (f -` {i} \<inter> space M \<inter> A) = 0" by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   723
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   724
    fix x assume "x \<in> f`A \<union> {0}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   725
    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
   726
      by (auto simp: indicator_def split: split_if_asm)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   727
    thus "x * (emeasure M) (?I -` {x} \<inter> space M) =
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   728
      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
   729
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   730
  show ?thesis unfolding *
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   731
    using assms(2) unfolding simple_function_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   732
    by (auto intro!: setsum_mono_zero_cong_right)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   733
qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   734
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   735
lemma simple_integral_indicator_only[simp]:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   736
  assumes "A \<in> sets M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   737
  shows "integral\<^isup>S M (indicator A) = emeasure M A"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   738
proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   739
  assume "space M = {}" hence "A = {}" using sets_into_space[OF assms] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   740
  thus ?thesis unfolding simple_integral_def using `space M = {}` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   741
next
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   742
  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
   743
  thus ?thesis
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   744
    using simple_integral_indicator[OF assms simple_function_const[of _ 1]]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   745
    using sets_into_space[OF assms]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   746
    by (auto intro!: arg_cong[where f="(emeasure M)"])
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   747
qed
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_null_set:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   750
  assumes "simple_function M u" "\<And>x. 0 \<le> u x" and "N \<in> null_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
   751
  shows "(\<integral>\<^isup>Sx. u x * indicator N x \<partial>M) = 0"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   752
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   753
  have "AE x in M. indicator N x = (0 :: ereal)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   754
    using `N \<in> null_sets M` by (auto simp: indicator_def intro!: AE_I[of _ _ N])
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
   755
  then have "(\<integral>\<^isup>Sx. u x * indicator N x \<partial>M) = (\<integral>\<^isup>Sx. 0 \<partial>M)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   756
    using assms apply (intro simple_integral_cong_AE) by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   757
  then show ?thesis by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   758
qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   759
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   760
lemma simple_integral_cong_AE_mult_indicator:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   761
  assumes sf: "simple_function M f" and eq: "AE x in M. x \<in> S" and "S \<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
   762
  shows "integral\<^isup>S M f = (\<integral>\<^isup>Sx. f x * indicator S x \<partial>M)"
41705
1100512e16d8 add auto support for AE_mp
hoelzl
parents: 41689
diff changeset
   763
  using assms by (intro simple_integral_cong_AE) auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   764
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   765
lemma simple_integral_cmult_indicator:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   766
  assumes A: "A \<in> sets M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   767
  shows "(\<integral>\<^isup>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
   768
  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
   769
  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
   770
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   771
lemma simple_integral_positive:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   772
  assumes f: "simple_function M f" and ae: "AE x in M. 0 \<le> f x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   773
  shows "0 \<le> integral\<^isup>S M f"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   774
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   775
  have "integral\<^isup>S M (\<lambda>x. 0) \<le> integral\<^isup>S M f"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   776
    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
   777
  then show ?thesis by simp
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   778
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   779
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
   780
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
   781
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   782
definition positive_integral :: "'a measure \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> ereal" ("integral\<^isup>P") where
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   783
  "integral\<^isup>P M f = (SUP g : {g. simple_function M g \<and> g \<le> max 0 \<circ> f}. integral\<^isup>S M g)"
35692
f1315bbf1bc9 Moved theorems in Lebesgue to the right places
hoelzl
parents: 35582
diff changeset
   784
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
   785
syntax
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   786
  "_positive_integral" :: "pttrn \<Rightarrow> ereal \<Rightarrow> 'a measure \<Rightarrow> ereal" ("\<integral>\<^isup>+ _. _ \<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
   787
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
   788
translations
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   789
  "\<integral>\<^isup>+ 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
   790
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   791
lemma positive_integral_positive:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   792
  "0 \<le> integral\<^isup>P M f"
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   793
  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
   794
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   795
lemma positive_integral_not_MInfty[simp]: "integral\<^isup>P M f \<noteq> -\<infinity>"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   796
  using positive_integral_positive[of M f] by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   797
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   798
lemma positive_integral_def_finite:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   799
  "integral\<^isup>P M f = (SUP g : {g. simple_function M g \<and> g \<le> max 0 \<circ> f \<and> range g \<subseteq> {0 ..< \<infinity>}}. integral\<^isup>S M g)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   800
    (is "_ = SUPR ?A ?f")
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   801
  unfolding positive_integral_def
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   802
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
   803
  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
   804
  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
   805
  note gM = g(1)[THEN borel_measurable_simple_function]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   806
  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
   807
  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
   808
  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
   809
    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
   810
    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
   811
    done
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   812
  show "integral\<^isup>S M g \<le> SUPR ?A ?f"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   813
  proof cases
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   814
    have g0: "?g 0 \<in> ?A" by (intro g_in_A) auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   815
    assume "(emeasure M) ?G = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   816
    with gM have "AE x in M. x \<notin> ?G"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   817
      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
   818
    with gM g show ?thesis
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   819
      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
   820
         (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
   821
  next
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   822
    assume \<mu>G: "(emeasure M) ?G \<noteq> 0"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   823
    have "SUPR ?A (integral\<^isup>S M) = \<infinity>"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   824
    proof (intro SUP_PInfty)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   825
      fix n :: nat
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   826
      let ?y = "ereal (real n) / (if (emeasure M) ?G = \<infinity> then 1 else (emeasure M) ?G)"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   827
      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
   828
      then have "?g ?y \<in> ?A" by (rule g_in_A)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   829
      have "real n \<le> ?y * (emeasure M) ?G"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   830
        using \<mu>G \<mu>G_pos by (cases "(emeasure M) ?G") (auto simp: field_simps)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   831
      also have "\<dots> = (\<integral>\<^isup>Sx. ?y * indicator ?G x \<partial>M)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   832
        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
   833
        by (subst simple_integral_cmult_indicator) auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   834
      also have "\<dots> \<le> integral\<^isup>S M (?g ?y)" using `?g ?y \<in> ?A` gM
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   835
        by (intro simple_integral_mono) auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   836
      finally show "\<exists>i\<in>?A. real n \<le> integral\<^isup>S M i"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   837
        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
   838
    qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   839
    then show ?thesis by simp
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   840
  qed
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   841
qed (auto intro: SUP_upper)
40873
1ef85f4e7097 Shorter definition for positive_integral.
hoelzl
parents: 40872
diff changeset
   842
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   843
lemma positive_integral_mono_AE:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   844
  assumes ae: "AE x in M. u x \<le> v x" shows "integral\<^isup>P M u \<le> integral\<^isup>P M v"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   845
  unfolding positive_integral_def
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   846
proof (safe intro!: SUP_mono)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   847
  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
   848
  from ae[THEN AE_E] guess N . note N = this
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   849
  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
   850
  let ?n = "\<lambda>x. n x * indicator (space M - N) x"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   851
  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
   852
    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
   853
  moreover
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   854
  { 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
   855
    proof cases
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   856
      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
   857
      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
   858
      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
   859
        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
   860
    qed simp }
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   861
  then have "?n \<le> max 0 \<circ> v" by (auto simp: le_funI)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   862
  moreover have "integral\<^isup>S M n \<le> integral\<^isup>S M ?n"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   863
    using ae_N N n by (auto intro!: simple_integral_mono_AE)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   864
  ultimately show "\<exists>m\<in>{g. simple_function M g \<and> g \<le> max 0 \<circ> v}. integral\<^isup>S M n \<le> integral\<^isup>S M m"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   865
    by force
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   866
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   867
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   868
lemma positive_integral_mono:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   869
  "(\<And>x. x \<in> space M \<Longrightarrow> u x \<le> v x) \<Longrightarrow> integral\<^isup>P M u \<le> integral\<^isup>P M v"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   870
  by (auto intro: positive_integral_mono_AE)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   871
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   872
lemma positive_integral_cong_AE:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   873
  "AE x in M. u x = v x \<Longrightarrow> integral\<^isup>P M u = integral\<^isup>P M v"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   874
  by (auto simp: eq_iff intro!: positive_integral_mono_AE)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   875
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   876
lemma positive_integral_cong:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   877
  "(\<And>x. x \<in> space M \<Longrightarrow> u x = v x) \<Longrightarrow> integral\<^isup>P M u = integral\<^isup>P M v"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   878
  by (auto intro: positive_integral_cong_AE)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   879
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   880
lemma positive_integral_eq_simple_integral:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   881
  assumes f: "simple_function M f" "\<And>x. 0 \<le> f x" shows "integral\<^isup>P M f = integral\<^isup>S M f"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   882
proof -
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   883
  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
   884
  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
   885
  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
   886
    by (auto simp: fun_eq_iff max_def split: split_indicator)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   887
  have "integral\<^isup>P M ?f \<le> integral\<^isup>S M ?f" using f'
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   888
    by (force intro!: SUP_least simple_integral_mono simp: le_fun_def positive_integral_def)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   889
  moreover have "integral\<^isup>S M ?f \<le> integral\<^isup>P M ?f"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   890
    unfolding positive_integral_def
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   891
    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
   892
  ultimately show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   893
    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
   894
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   895
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   896
lemma positive_integral_eq_simple_integral_AE:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   897
  assumes f: "simple_function M f" "AE x in M. 0 \<le> f x" shows "integral\<^isup>P M f = integral\<^isup>S M f"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   898
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   899
  have "AE x in M. f x = max 0 (f x)" using f by (auto split: split_max)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   900
  with f have "integral\<^isup>P M f = integral\<^isup>S M (\<lambda>x. max 0 (f x))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   901
    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
   902
             add: positive_integral_eq_simple_integral)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   903
  with assms show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   904
    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
   905
qed
40873
1ef85f4e7097 Shorter definition for positive_integral.
hoelzl
parents: 40872
diff changeset
   906
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   907
lemma positive_integral_SUP_approx:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   908
  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
   909
  and u: "simple_function M u" "u \<le> (SUP i. f i)" "u`space M \<subseteq> {0..<\<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
   910
  shows "integral\<^isup>S M u \<le> (SUP i. integral\<^isup>P M (f i))" (is "_ \<le> ?S")
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   911
proof (rule ereal_le_mult_one_interval)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   912
  have "0 \<le> (SUP i. integral\<^isup>P M (f i))"
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
   913
    using f(3) by (auto intro!: SUP_upper2 positive_integral_positive)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   914
  then show "(SUP i. integral\<^isup>P M (f i)) \<noteq> -\<infinity>" by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   915
  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
   916
    using u(3) by auto
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   917
  fix a :: ereal assume "0 < a" "a < 1"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   918
  hence "a \<noteq> 0" by auto
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   919
  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
   920
  have B: "\<And>i. ?B i \<in> sets M"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   921
    using f `simple_function M u` by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   922
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   923
  let ?uB = "\<lambda>i x. u x * indicator (?B i) x"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   924
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   925
  { fix i have "?B i \<subseteq> ?B (Suc i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   926
    proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   927
      fix i x assume "a * u x \<le> f i x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   928
      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
   929
        using `incseq f`[THEN incseq_SucD] unfolding le_fun_def by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   930
      finally show "a * u x \<le> f (Suc i) x" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   931
    qed }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   932
  note B_mono = this
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   933
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   934
  note B_u = Int[OF u(1)[THEN simple_functionD(2)] B]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   935
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
   936
  let ?B' = "\<lambda>i n. (u -` {i} \<inter> space M) \<inter> ?B n"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   937
  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
   938
  proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   939
    fix i
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   940
    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
   941
    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
   942
    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
   943
    proof safe
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   944
      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
   945
      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
   946
      proof cases
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   947
        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
   948
      next
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   949
        assume "u x \<noteq> 0"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   950
        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
   951
        have "a * u x < 1 * u x"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   952
          by (intro ereal_mult_strict_right_mono) (auto simp: image_iff)
46884
154dc6ec0041 tuned proofs
noschinl
parents: 46731
diff changeset
   953
        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
   954
        finally obtain i where "a * u x < f i x" unfolding SUP_def
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   955
          by (auto simp add: less_Sup_iff)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   956
        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
   957
        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
   958
      qed
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
   959
    qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   960
    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
   961
  qed
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   962
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
   963
  have "integral\<^isup>S M u = (SUP i. integral\<^isup>S M (?uB 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
   964
    unfolding simple_integral_indicator[OF B `simple_function M u`]
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   965
  proof (subst SUPR_ereal_setsum, safe)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   966
    fix x n assume "x \<in> space M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   967
    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
   968
      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
   969
  next
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   970
    show "integral\<^isup>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
   971
      using measure_conv u_range B_u unfolding simple_integral_def
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   972
      by (auto intro!: setsum_cong SUPR_ereal_cmult[symmetric])
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   973
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   974
  moreover
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
   975
  have "a * (SUP i. integral\<^isup>S M (?uB i)) \<le> ?S"
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
   976
    apply (subst SUPR_ereal_cmult[symmetric])
38705
aaee86c0e237 moved generic lemmas in Probability to HOL
hoelzl
parents: 38656
diff changeset
   977
  proof (safe intro!: SUP_mono bexI)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   978
    fix 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
   979
    have "a * integral\<^isup>S M (?uB i) = (\<integral>\<^isup>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
   980
      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
   981
      by (subst simple_integral_mult) (auto split: split_indicator)
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
   982
    also have "\<dots> \<le> integral\<^isup>P M (f i)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   983
    proof -
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   984
      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
   985
      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
   986
        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
   987
           (auto intro!: positive_integral_mono split: split_indicator)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   988
    qed
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
   989
    finally show "a * integral\<^isup>S M (?uB i) \<le> integral\<^isup>P M (f i)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
   990
      by auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   991
  next
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   992
    fix i show "0 \<le> \<integral>\<^isup>S x. ?uB i x \<partial>M" using B `0 < a` u(1) u_range
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   993
      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
   994
  qed (insert `0 < a`, 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
   995
  ultimately show "a * integral\<^isup>S M u \<le> ?S" by simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   996
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   997
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   998
lemma incseq_positive_integral:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
   999
  assumes "incseq f" shows "incseq (\<lambda>i. integral\<^isup>P M (f i))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1000
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1001
  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
  1002
    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
  1003
  then show ?thesis
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1004
    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
  1005
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1006
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1007
text {* Beppo-Levi monotone convergence theorem *}
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1008
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
  1009
  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
  1010
  shows "(\<integral>\<^isup>+ x. (SUP i. f i x) \<partial>M) = (SUP i. integral\<^isup>P M (f i))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1011
proof (rule antisym)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1012
  show "(SUP j. integral\<^isup>P M (f j)) \<le> (\<integral>\<^isup>+ x. (SUP i. f i x) \<partial>M)"
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44890
diff changeset
  1013
    by (auto intro!: SUP_least SUP_upper positive_integral_mono)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1014
next
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1015
  show "(\<integral>\<^isup>+ x. (SUP i. f i x) \<partial>M) \<le> (SUP j. integral\<^isup>P M (f j))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1016
    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
  1017
  proof (safe intro!: SUP_least)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1018
    fix g assume g: "simple_function M g"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1019
      and "g \<le> max 0 \<circ> (\<lambda>x. SUP i. f i x)" "range g \<subseteq> {0..<\<infinity>}"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1020
    moreover 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
  1021
      using f by (auto intro!: SUP_upper2)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1022
    ultimately show "integral\<^isup>S M g \<le> (SUP j. integral\<^isup>P M (f j))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1023
      by (intro  positive_integral_SUP_approx[OF f g _ g'])
46884
154dc6ec0041 tuned proofs
noschinl
parents: 46731
diff changeset
  1024
         (auto simp: le_fun_def max_def)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1025
  qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1026
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1027
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1028
lemma positive_integral_monotone_convergence_SUP_AE:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1029
  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"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1030
  shows "(\<integral>\<^isup>+ x. (SUP i. f i x) \<partial>M) = (SUP i. integral\<^isup>P M (f i))"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1031
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1032
  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
  1033
    by (simp add: AE_all_countable)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1034
  from this[THEN AE_E] guess N . note N = this
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 46671
diff changeset
  1035
  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
  1036
  have f_eq: "AE x in M. \<forall>i. ?f i x = f i x" using N by (auto intro!: AE_I[of _ _ N])
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1037
  then have "(\<integral>\<^isup>+ x. (SUP i. f i x) \<partial>M) = (\<integral>\<^isup>+ x. (SUP i. ?f i x) \<partial>M)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1038
    by (auto intro!: positive_integral_cong_AE)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1039
  also have "\<dots> = (SUP i. (\<integral>\<^isup>+ x. ?f i x \<partial>M))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1040
  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
  1041
    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
  1042
    { 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
  1043
        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
  1044
      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
  1045
        using N(1) by auto }
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1046
  qed
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1047
  also have "\<dots> = (SUP i. (\<integral>\<^isup>+ x. f i x \<partial>M))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1048
    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
  1049
  finally show ?thesis .
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1050
qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1051
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1052
lemma positive_integral_monotone_convergence_SUP_AE_incseq:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1053
  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"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1054
  shows "(\<integral>\<^isup>+ x. (SUP i. f i x) \<partial>M) = (SUP i. integral\<^isup>P M (f i))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1055
  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
  1056
  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
  1057
     auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1058
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1059
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
  1060
  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
  1061
  shows "(SUP i. integral\<^isup>S M (f i)) = (\<integral>\<^isup>+x. (SUP i. f i x) \<partial>M)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1062
  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
  1063
    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
  1064
  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
  1065
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1066
lemma positive_integral_max_0:
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1067
  "(\<integral>\<^isup>+x. max 0 (f x) \<partial>M) = integral\<^isup>P M f"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1068
  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
  1069
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1070
lemma positive_integral_cong_pos:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1071
  assumes "\<And>x. x \<in> space M \<Longrightarrow> f x \<le> 0 \<and> g x \<le> 0 \<or> f x = g x"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1072
  shows "integral\<^isup>P M f = integral\<^isup>P M g"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1073
proof -
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1074
  have "integral\<^isup>P M (\<lambda>x. max 0 (f x)) = integral\<^isup>P M (\<lambda>x. max 0 (g x))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1075
  proof (intro positive_integral_cong)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1076
    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
  1077
    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
  1078
      by (auto split: split_max)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1079
  qed
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1080
  then show ?thesis by (simp add: positive_integral_max_0)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1081
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 40786
diff changeset
  1082
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1083
lemma SUP_simple_integral_sequences:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1084
  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
  1085
  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
  1086
  and eq: "AE x in M. (SUP i. f i x) = (SUP i. g 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
  1087
  shows "(SUP i. integral\<^isup>S M (f i)) = (SUP i. integral\<^isup>S M (g i))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1088
    (is "SUPR _ ?F = SUPR _ ?G")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1089
proof -
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1090
  have "(SUP i. integral\<^isup>S M (f i)) = (\<integral>\<^isup>+x. (SUP i. f i x) \<partial>M)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1091
    using f by (rule positive_integral_monotone_convergence_simple)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1092
  also have "\<dots> = (\<integral>\<^isup>+x. (SUP i. g i x) \<partial>M)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1093
    unfolding eq[THEN positive_integral_cong_AE] ..
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1094
  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
  1095
    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
  1096
  finally show ?thesis by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1097
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1098
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1099
lemma positive_integral_const[simp]:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1100
  "0 \<le> c \<Longrightarrow> (\<integral>\<^isup>+ x. c \<partial>M) = c * (emeasure M) (space M)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1101
  by (subst positive_integral_eq_simple_integral) auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1102
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1103
lemma positive_integral_linear:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1104
  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
  1105
  and g: "g \<in> borel_measurable M" "\<And>x. 0 \<le> g 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
  1106
  shows "(\<integral>\<^isup>+ x. a * f x + g x \<partial>M) = a * integral\<^isup>P M f + integral\<^isup>P 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
  1107
    (is "integral\<^isup>P M ?L = _")
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1108
proof -
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1109
  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
  1110
  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
  1111
  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
  1112
  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
  1113
  let ?L' = "\<lambda>i x. a * u i x + v i x"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1114
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1115
  have "?L \<in> borel_measurable M" using assms by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 38642
diff changeset
  1116
  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
  1117
  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
  1118
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1119
  have inc: "incseq (\<lambda>i. a * integral\<^isup>S M (u i))" "incseq (\<lambda>i. integral\<^isup>S M (v i))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1120
    using u v `0 \<le> a`
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1121
    by (auto simp: incseq_Suc_iff le_fun_def
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1122
             intro!: add_mono ereal_mult_left_mono simple_integral_mono)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1123
  have pos: "\<And>i. 0 \<le> integral\<^isup>S M (u i)" "\<And>i. 0 \<le> integral\<^isup>S M (v i)" "\<And>i. 0 \<le> a * integral\<^isup>S M (u i)"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1124
    using u v `0 \<le> a` by (auto simp: simple_integral_positive)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1125
  { fix i from pos[of i] have "a * integral\<^isup>S M (u i) \<noteq> -\<infinity>" "integral\<^isup>S M (v i) \<noteq> -\<infinity>"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1126
      by (auto split: split_if_asm) }
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1127
  note not_MInf = this
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1128
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1129
  have l': "(SUP i. integral\<^isup>S M (l i)) = (SUP i. integral\<^isup>S M (?L' i))"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1130
  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
  1131
    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
  1132
      using u v  `0 \<le> a` unfolding incseq_Suc_iff le_fun_def
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 43339
diff changeset
  1133
      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
  1134
    { fix x
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1135
      { 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
  1136
          by auto }
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
  1137
      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