src/HOL/Probability/Binary_Product_Measure.thy
author hoelzl
Fri Nov 02 14:23:54 2012 +0100 (2012-11-02)
changeset 50003 8c213922ed49
parent 50002 ce0d316b5b44
child 50104 de19856feb54
permissions -rw-r--r--
use measurability prover
hoelzl@42146
     1
(*  Title:      HOL/Probability/Binary_Product_Measure.thy
hoelzl@42067
     2
    Author:     Johannes Hölzl, TU München
hoelzl@42067
     3
*)
hoelzl@42067
     4
hoelzl@42146
     5
header {*Binary product measures*}
hoelzl@42067
     6
hoelzl@42146
     7
theory Binary_Product_Measure
hoelzl@38656
     8
imports Lebesgue_Integration
hoelzl@35833
     9
begin
hoelzl@35833
    10
hoelzl@42950
    11
lemma times_eq_iff: "A \<times> B = C \<times> D \<longleftrightarrow> A = C \<and> B = D \<or> ((A = {} \<or> B = {}) \<and> (C = {} \<or> D = {}))"
hoelzl@42950
    12
  by auto
hoelzl@42950
    13
hoelzl@40859
    14
lemma times_Int_times: "A \<times> B \<inter> C \<times> D = (A \<inter> C) \<times> (B \<inter> D)"
hoelzl@40859
    15
  by auto
hoelzl@40859
    16
hoelzl@40859
    17
lemma Pair_vimage_times[simp]: "\<And>A B x. Pair x -` (A \<times> B) = (if x \<in> A then B else {})"
hoelzl@40859
    18
  by auto
hoelzl@40859
    19
hoelzl@40859
    20
lemma rev_Pair_vimage_times[simp]: "\<And>A B y. (\<lambda>x. (x, y)) -` (A \<times> B) = (if y \<in> B then A else {})"
hoelzl@40859
    21
  by auto
hoelzl@40859
    22
hoelzl@40859
    23
lemma case_prod_distrib: "f (case x of (x, y) \<Rightarrow> g x y) = (case x of (x, y) \<Rightarrow> f (g x y))"
hoelzl@40859
    24
  by (cases x) simp
hoelzl@40859
    25
hoelzl@41026
    26
lemma split_beta': "(\<lambda>(x,y). f x y) = (\<lambda>x. f (fst x) (snd x))"
hoelzl@41026
    27
  by (auto simp: fun_eq_iff)
hoelzl@41026
    28
hoelzl@40859
    29
section "Binary products"
hoelzl@40859
    30
hoelzl@41689
    31
definition pair_measure (infixr "\<Otimes>\<^isub>M" 80) where
hoelzl@47694
    32
  "A \<Otimes>\<^isub>M B = measure_of (space A \<times> space B)
hoelzl@47694
    33
      {a \<times> b | a b. a \<in> sets A \<and> b \<in> sets B}
hoelzl@47694
    34
      (\<lambda>X. \<integral>\<^isup>+x. (\<integral>\<^isup>+y. indicator X (x,y) \<partial>B) \<partial>A)"
hoelzl@40859
    35
hoelzl@49789
    36
lemma pair_measure_closed: "{a \<times> b | a b. a \<in> sets A \<and> b \<in> sets B} \<subseteq> Pow (space A \<times> space B)"
hoelzl@49789
    37
  using space_closed[of A] space_closed[of B] by auto
hoelzl@49789
    38
hoelzl@41689
    39
lemma space_pair_measure:
hoelzl@41689
    40
  "space (A \<Otimes>\<^isub>M B) = space A \<times> space B"
hoelzl@49789
    41
  unfolding pair_measure_def using pair_measure_closed[of A B]
hoelzl@49789
    42
  by (rule space_measure_of)
hoelzl@47694
    43
hoelzl@47694
    44
lemma sets_pair_measure:
hoelzl@47694
    45
  "sets (A \<Otimes>\<^isub>M B) = sigma_sets (space A \<times> space B) {a \<times> b | a b. a \<in> sets A \<and> b \<in> sets B}"
hoelzl@49789
    46
  unfolding pair_measure_def using pair_measure_closed[of A B]
hoelzl@49789
    47
  by (rule sets_measure_of)
hoelzl@41095
    48
hoelzl@49776
    49
lemma sets_pair_measure_cong[cong]:
hoelzl@49776
    50
  "sets M1 = sets M1' \<Longrightarrow> sets M2 = sets M2' \<Longrightarrow> sets (M1 \<Otimes>\<^isub>M M2) = sets (M1' \<Otimes>\<^isub>M M2')"
hoelzl@49776
    51
  unfolding sets_pair_measure by (simp cong: sets_eq_imp_space_eq)
hoelzl@49776
    52
hoelzl@50003
    53
lemma pair_measureI[intro, simp, measurable]:
hoelzl@47694
    54
  "x \<in> sets A \<Longrightarrow> y \<in> sets B \<Longrightarrow> x \<times> y \<in> sets (A \<Otimes>\<^isub>M B)"
hoelzl@47694
    55
  by (auto simp: sets_pair_measure)
hoelzl@41095
    56
hoelzl@47694
    57
lemma measurable_pair_measureI:
hoelzl@47694
    58
  assumes 1: "f \<in> space M \<rightarrow> space M1 \<times> space M2"
hoelzl@47694
    59
  assumes 2: "\<And>A B. A \<in> sets M1 \<Longrightarrow> B \<in> sets M2 \<Longrightarrow> f -` (A \<times> B) \<inter> space M \<in> sets M"
hoelzl@47694
    60
  shows "f \<in> measurable M (M1 \<Otimes>\<^isub>M M2)"
hoelzl@47694
    61
  unfolding pair_measure_def using 1 2
hoelzl@47694
    62
  by (intro measurable_measure_of) (auto dest: sets_into_space)
hoelzl@41689
    63
hoelzl@50003
    64
lemma measurable_split_replace[measurable (raw)]:
hoelzl@50003
    65
  "(\<lambda>x. f x (fst (g x)) (snd (g x))) \<in> measurable M N \<Longrightarrow> (\<lambda>x. split (f x) (g x)) \<in> measurable M N"
hoelzl@50003
    66
  unfolding split_beta' .
hoelzl@50003
    67
hoelzl@50003
    68
lemma measurable_Pair[measurable (raw)]:
hoelzl@49776
    69
  assumes f: "f \<in> measurable M M1" and g: "g \<in> measurable M M2"
hoelzl@49776
    70
  shows "(\<lambda>x. (f x, g x)) \<in> measurable M (M1 \<Otimes>\<^isub>M M2)"
hoelzl@49776
    71
proof (rule measurable_pair_measureI)
hoelzl@49776
    72
  show "(\<lambda>x. (f x, g x)) \<in> space M \<rightarrow> space M1 \<times> space M2"
hoelzl@49776
    73
    using f g by (auto simp: measurable_def)
hoelzl@49776
    74
  fix A B assume *: "A \<in> sets M1" "B \<in> sets M2"
hoelzl@49776
    75
  have "(\<lambda>x. (f x, g x)) -` (A \<times> B) \<inter> space M = (f -` A \<inter> space M) \<inter> (g -` B \<inter> space M)"
hoelzl@49776
    76
    by auto
hoelzl@49776
    77
  also have "\<dots> \<in> sets M"
hoelzl@49776
    78
    by (rule Int) (auto intro!: measurable_sets * f g)
hoelzl@49776
    79
  finally show "(\<lambda>x. (f x, g x)) -` (A \<times> B) \<inter> space M \<in> sets M" .
hoelzl@49776
    80
qed
hoelzl@49776
    81
hoelzl@50003
    82
lemma measurable_Pair_compose_split[measurable_dest]:
hoelzl@50003
    83
  assumes f: "split f \<in> measurable (M1 \<Otimes>\<^isub>M M2) N"
hoelzl@50003
    84
  assumes g: "g \<in> measurable M M1" and h: "h \<in> measurable M M2"
hoelzl@50003
    85
  shows "(\<lambda>x. f (g x) (h x)) \<in> measurable M N"
hoelzl@50003
    86
  using measurable_compose[OF measurable_Pair f, OF g h] by simp
hoelzl@50003
    87
hoelzl@49776
    88
lemma measurable_pair:
hoelzl@49776
    89
  assumes "(fst \<circ> f) \<in> measurable M M1" "(snd \<circ> f) \<in> measurable M M2"
hoelzl@49776
    90
  shows "f \<in> measurable M (M1 \<Otimes>\<^isub>M M2)"
hoelzl@49776
    91
  using measurable_Pair[OF assms] by simp
hoelzl@49776
    92
hoelzl@50003
    93
lemma measurable_fst[intro!, simp, measurable]: "fst \<in> measurable (M1 \<Otimes>\<^isub>M M2) M1"
hoelzl@49776
    94
  by (auto simp: fst_vimage_eq_Times space_pair_measure sets_into_space times_Int_times measurable_def)
hoelzl@40859
    95
hoelzl@50003
    96
lemma measurable_snd[intro!, simp, measurable]: "snd \<in> measurable (M1 \<Otimes>\<^isub>M M2) M2"
hoelzl@49776
    97
  by (auto simp: snd_vimage_eq_Times space_pair_measure sets_into_space times_Int_times measurable_def)
hoelzl@47694
    98
hoelzl@50003
    99
lemma 
hoelzl@50003
   100
  assumes f[measurable]: "f \<in> measurable M (N \<Otimes>\<^isub>M P)" 
hoelzl@50003
   101
  shows measurable_fst': "(\<lambda>x. fst (f x)) \<in> measurable M N"
hoelzl@50003
   102
    and measurable_snd': "(\<lambda>x. snd (f x)) \<in> measurable M P"
hoelzl@50003
   103
  by simp_all
hoelzl@40859
   104
hoelzl@50003
   105
lemma
hoelzl@50003
   106
  assumes f[measurable]: "f \<in> measurable M N"
hoelzl@50003
   107
  shows measurable_fst'': "(\<lambda>x. f (fst x)) \<in> measurable (M \<Otimes>\<^isub>M P) N"
hoelzl@50003
   108
    and measurable_snd'': "(\<lambda>x. f (snd x)) \<in> measurable (P \<Otimes>\<^isub>M M) N"
hoelzl@50003
   109
  by simp_all
hoelzl@47694
   110
hoelzl@47694
   111
lemma measurable_pair_iff:
hoelzl@47694
   112
  "f \<in> measurable M (M1 \<Otimes>\<^isub>M M2) \<longleftrightarrow> (fst \<circ> f) \<in> measurable M M1 \<and> (snd \<circ> f) \<in> measurable M M2"
hoelzl@50003
   113
  by (auto intro: measurable_pair[of f M M1 M2]) 
hoelzl@40859
   114
hoelzl@49776
   115
lemma measurable_split_conv:
hoelzl@49776
   116
  "(\<lambda>(x, y). f x y) \<in> measurable A B \<longleftrightarrow> (\<lambda>x. f (fst x) (snd x)) \<in> measurable A B"
hoelzl@49776
   117
  by (intro arg_cong2[where f="op \<in>"]) auto
hoelzl@40859
   118
hoelzl@47694
   119
lemma measurable_pair_swap': "(\<lambda>(x,y). (y, x)) \<in> measurable (M1 \<Otimes>\<^isub>M M2) (M2 \<Otimes>\<^isub>M M1)"
hoelzl@49776
   120
  by (auto intro!: measurable_Pair simp: measurable_split_conv)
hoelzl@47694
   121
hoelzl@47694
   122
lemma measurable_pair_swap:
hoelzl@47694
   123
  assumes f: "f \<in> measurable (M1 \<Otimes>\<^isub>M M2) M" shows "(\<lambda>(x,y). f (y, x)) \<in> measurable (M2 \<Otimes>\<^isub>M M1) M"
hoelzl@49776
   124
  using measurable_comp[OF measurable_Pair f] by (auto simp: measurable_split_conv comp_def)
hoelzl@40859
   125
hoelzl@47694
   126
lemma measurable_pair_swap_iff:
hoelzl@47694
   127
  "f \<in> measurable (M2 \<Otimes>\<^isub>M M1) M \<longleftrightarrow> (\<lambda>(x,y). f (y,x)) \<in> measurable (M1 \<Otimes>\<^isub>M M2) M"
hoelzl@50003
   128
  by (auto dest: measurable_pair_swap)
hoelzl@49776
   129
hoelzl@47694
   130
lemma measurable_Pair1': "x \<in> space M1 \<Longrightarrow> Pair x \<in> measurable M2 (M1 \<Otimes>\<^isub>M M2)"
hoelzl@50003
   131
  by simp
hoelzl@40859
   132
hoelzl@50003
   133
lemma sets_Pair1[measurable (raw)]:
hoelzl@50003
   134
  assumes A: "A \<in> sets (M1 \<Otimes>\<^isub>M M2)" shows "Pair x -` A \<in> sets M2"
hoelzl@40859
   135
proof -
hoelzl@47694
   136
  have "Pair x -` A = (if x \<in> space M1 then Pair x -` A \<inter> space M2 else {})"
hoelzl@47694
   137
    using A[THEN sets_into_space] by (auto simp: space_pair_measure)
hoelzl@47694
   138
  also have "\<dots> \<in> sets M2"
hoelzl@47694
   139
    using A by (auto simp add: measurable_Pair1' intro!: measurable_sets split: split_if_asm)
hoelzl@47694
   140
  finally show ?thesis .
hoelzl@40859
   141
qed
hoelzl@40859
   142
hoelzl@47694
   143
lemma measurable_Pair2': "y \<in> space M2 \<Longrightarrow> (\<lambda>x. (x, y)) \<in> measurable M1 (M1 \<Otimes>\<^isub>M M2)"
hoelzl@49776
   144
  by (auto intro!: measurable_Pair)
hoelzl@40859
   145
hoelzl@47694
   146
lemma sets_Pair2: assumes A: "A \<in> sets (M1 \<Otimes>\<^isub>M M2)" shows "(\<lambda>x. (x, y)) -` A \<in> sets M1"
hoelzl@47694
   147
proof -
hoelzl@47694
   148
  have "(\<lambda>x. (x, y)) -` A = (if y \<in> space M2 then (\<lambda>x. (x, y)) -` A \<inter> space M1 else {})"
hoelzl@47694
   149
    using A[THEN sets_into_space] by (auto simp: space_pair_measure)
hoelzl@47694
   150
  also have "\<dots> \<in> sets M1"
hoelzl@47694
   151
    using A by (auto simp add: measurable_Pair2' intro!: measurable_sets split: split_if_asm)
hoelzl@47694
   152
  finally show ?thesis .
hoelzl@40859
   153
qed
hoelzl@40859
   154
hoelzl@47694
   155
lemma measurable_Pair2:
hoelzl@47694
   156
  assumes f: "f \<in> measurable (M1 \<Otimes>\<^isub>M M2) M" and x: "x \<in> space M1"
hoelzl@47694
   157
  shows "(\<lambda>y. f (x, y)) \<in> measurable M2 M"
hoelzl@47694
   158
  using measurable_comp[OF measurable_Pair1' f, OF x]
hoelzl@47694
   159
  by (simp add: comp_def)
hoelzl@47694
   160
  
hoelzl@47694
   161
lemma measurable_Pair1:
hoelzl@47694
   162
  assumes f: "f \<in> measurable (M1 \<Otimes>\<^isub>M M2) M" and y: "y \<in> space M2"
hoelzl@40859
   163
  shows "(\<lambda>x. f (x, y)) \<in> measurable M1 M"
hoelzl@47694
   164
  using measurable_comp[OF measurable_Pair2' f, OF y]
hoelzl@47694
   165
  by (simp add: comp_def)
hoelzl@40859
   166
hoelzl@47694
   167
lemma Int_stable_pair_measure_generator: "Int_stable {a \<times> b | a b. a \<in> sets A \<and> b \<in> sets B}"
hoelzl@40859
   168
  unfolding Int_stable_def
hoelzl@47694
   169
  by safe (auto simp add: times_Int_times)
hoelzl@40859
   170
hoelzl@50003
   171
lemma disjoint_family_vimageI: "disjoint_family F \<Longrightarrow> disjoint_family (\<lambda>i. f -` F i)"
hoelzl@50003
   172
  by (auto simp: disjoint_family_on_def)
hoelzl@50003
   173
hoelzl@49776
   174
lemma (in finite_measure) finite_measure_cut_measurable:
hoelzl@50003
   175
  assumes [measurable]: "Q \<in> sets (N \<Otimes>\<^isub>M M)"
hoelzl@49776
   176
  shows "(\<lambda>x. emeasure M (Pair x -` Q)) \<in> borel_measurable N"
hoelzl@40859
   177
    (is "?s Q \<in> _")
hoelzl@49789
   178
  using Int_stable_pair_measure_generator pair_measure_closed assms
hoelzl@49789
   179
  unfolding sets_pair_measure
hoelzl@49789
   180
proof (induct rule: sigma_sets_induct_disjoint)
hoelzl@49789
   181
  case (compl A)
hoelzl@49789
   182
  with sets_into_space have "\<And>x. emeasure M (Pair x -` ((space N \<times> space M) - A)) =
hoelzl@49789
   183
      (if x \<in> space N then emeasure M (space M) - ?s A x else 0)"
hoelzl@49789
   184
    unfolding sets_pair_measure[symmetric]
hoelzl@49789
   185
    by (auto intro!: emeasure_compl simp: vimage_Diff sets_Pair1)
hoelzl@49789
   186
  with compl top show ?case
hoelzl@49789
   187
    by (auto intro!: measurable_If simp: space_pair_measure)
hoelzl@49789
   188
next
hoelzl@49789
   189
  case (union F)
hoelzl@50003
   190
  moreover then have *: "\<And>x. emeasure M (Pair x -` (\<Union>i. F i)) = (\<Sum>i. ?s (F i) x)"
hoelzl@50003
   191
    by (simp add: suminf_emeasure disjoint_family_vimageI subset_eq vimage_UN sets_pair_measure[symmetric])
hoelzl@49789
   192
  ultimately show ?case
hoelzl@50003
   193
    unfolding sets_pair_measure[symmetric] by simp
hoelzl@49789
   194
qed (auto simp add: if_distrib Int_def[symmetric] intro!: measurable_If)
hoelzl@49776
   195
hoelzl@49776
   196
lemma (in sigma_finite_measure) measurable_emeasure_Pair:
hoelzl@49776
   197
  assumes Q: "Q \<in> sets (N \<Otimes>\<^isub>M M)" shows "(\<lambda>x. emeasure M (Pair x -` Q)) \<in> borel_measurable N" (is "?s Q \<in> _")
hoelzl@49776
   198
proof -
hoelzl@49776
   199
  from sigma_finite_disjoint guess F . note F = this
hoelzl@49776
   200
  then have F_sets: "\<And>i. F i \<in> sets M" by auto
hoelzl@49776
   201
  let ?C = "\<lambda>x i. F i \<inter> Pair x -` Q"
hoelzl@49776
   202
  { fix i
hoelzl@49776
   203
    have [simp]: "space N \<times> F i \<inter> space N \<times> space M = space N \<times> F i"
hoelzl@49776
   204
      using F sets_into_space by auto
hoelzl@49776
   205
    let ?R = "density M (indicator (F i))"
hoelzl@49776
   206
    have "finite_measure ?R"
hoelzl@49776
   207
      using F by (intro finite_measureI) (auto simp: emeasure_restricted subset_eq)
hoelzl@49776
   208
    then have "(\<lambda>x. emeasure ?R (Pair x -` (space N \<times> space ?R \<inter> Q))) \<in> borel_measurable N"
hoelzl@49776
   209
     by (rule finite_measure.finite_measure_cut_measurable) (auto intro: Q)
hoelzl@49776
   210
    moreover have "\<And>x. emeasure ?R (Pair x -` (space N \<times> space ?R \<inter> Q))
hoelzl@49776
   211
        = emeasure M (F i \<inter> Pair x -` (space N \<times> space ?R \<inter> Q))"
hoelzl@49776
   212
      using Q F_sets by (intro emeasure_restricted) (auto intro: sets_Pair1)
hoelzl@49776
   213
    moreover have "\<And>x. F i \<inter> Pair x -` (space N \<times> space ?R \<inter> Q) = ?C x i"
hoelzl@49776
   214
      using sets_into_space[OF Q] by (auto simp: space_pair_measure)
hoelzl@49776
   215
    ultimately have "(\<lambda>x. emeasure M (?C x i)) \<in> borel_measurable N"
hoelzl@49776
   216
      by simp }
hoelzl@49776
   217
  moreover
hoelzl@49776
   218
  { fix x
hoelzl@49776
   219
    have "(\<Sum>i. emeasure M (?C x i)) = emeasure M (\<Union>i. ?C x i)"
hoelzl@49776
   220
    proof (intro suminf_emeasure)
hoelzl@49776
   221
      show "range (?C x) \<subseteq> sets M"
hoelzl@49776
   222
        using F `Q \<in> sets (N \<Otimes>\<^isub>M M)` by (auto intro!: sets_Pair1)
hoelzl@49776
   223
      have "disjoint_family F" using F by auto
hoelzl@49776
   224
      show "disjoint_family (?C x)"
hoelzl@49776
   225
        by (rule disjoint_family_on_bisimulation[OF `disjoint_family F`]) auto
hoelzl@49776
   226
    qed
hoelzl@49776
   227
    also have "(\<Union>i. ?C x i) = Pair x -` Q"
hoelzl@49776
   228
      using F sets_into_space[OF `Q \<in> sets (N \<Otimes>\<^isub>M M)`]
hoelzl@49776
   229
      by (auto simp: space_pair_measure)
hoelzl@49776
   230
    finally have "emeasure M (Pair x -` Q) = (\<Sum>i. emeasure M (?C x i))"
hoelzl@49776
   231
      by simp }
hoelzl@49776
   232
  ultimately show ?thesis using `Q \<in> sets (N \<Otimes>\<^isub>M M)` F_sets
hoelzl@49776
   233
    by auto
hoelzl@49776
   234
qed
hoelzl@49776
   235
hoelzl@50003
   236
lemma (in sigma_finite_measure) measurable_emeasure[measurable (raw)]:
hoelzl@50003
   237
  assumes space: "\<And>x. x \<in> space N \<Longrightarrow> A x \<subseteq> space M"
hoelzl@50003
   238
  assumes A: "{x\<in>space (N \<Otimes>\<^isub>M M). snd x \<in> A (fst x)} \<in> sets (N \<Otimes>\<^isub>M M)"
hoelzl@50003
   239
  shows "(\<lambda>x. emeasure M (A x)) \<in> borel_measurable N"
hoelzl@50003
   240
proof -
hoelzl@50003
   241
  from space have "\<And>x. x \<in> space N \<Longrightarrow> Pair x -` {x \<in> space (N \<Otimes>\<^isub>M M). snd x \<in> A (fst x)} = A x"
hoelzl@50003
   242
    by (auto simp: space_pair_measure)
hoelzl@50003
   243
  with measurable_emeasure_Pair[OF A] show ?thesis
hoelzl@50003
   244
    by (auto cong: measurable_cong)
hoelzl@50003
   245
qed
hoelzl@50003
   246
hoelzl@49776
   247
lemma (in sigma_finite_measure) emeasure_pair_measure:
hoelzl@49776
   248
  assumes "X \<in> sets (N \<Otimes>\<^isub>M M)"
hoelzl@49776
   249
  shows "emeasure (N \<Otimes>\<^isub>M M) X = (\<integral>\<^isup>+ x. \<integral>\<^isup>+ y. indicator X (x, y) \<partial>M \<partial>N)" (is "_ = ?\<mu> X")
hoelzl@49776
   250
proof (rule emeasure_measure_of[OF pair_measure_def])
hoelzl@49776
   251
  show "positive (sets (N \<Otimes>\<^isub>M M)) ?\<mu>"
hoelzl@49776
   252
    by (auto simp: positive_def positive_integral_positive)
hoelzl@49776
   253
  have eq[simp]: "\<And>A x y. indicator A (x, y) = indicator (Pair x -` A) y"
hoelzl@49776
   254
    by (auto simp: indicator_def)
hoelzl@49776
   255
  show "countably_additive (sets (N \<Otimes>\<^isub>M M)) ?\<mu>"
hoelzl@49776
   256
  proof (rule countably_additiveI)
hoelzl@49776
   257
    fix F :: "nat \<Rightarrow> ('b \<times> 'a) set" assume F: "range F \<subseteq> sets (N \<Otimes>\<^isub>M M)" "disjoint_family F"
hoelzl@49776
   258
    from F have *: "\<And>i. F i \<in> sets (N \<Otimes>\<^isub>M M)" "(\<Union>i. F i) \<in> sets (N \<Otimes>\<^isub>M M)" by auto
hoelzl@49776
   259
    moreover from F have "\<And>i. (\<lambda>x. emeasure M (Pair x -` F i)) \<in> borel_measurable N"
hoelzl@49776
   260
      by (intro measurable_emeasure_Pair) auto
hoelzl@49776
   261
    moreover have "\<And>x. disjoint_family (\<lambda>i. Pair x -` F i)"
hoelzl@49776
   262
      by (intro disjoint_family_on_bisimulation[OF F(2)]) auto
hoelzl@49776
   263
    moreover have "\<And>x. range (\<lambda>i. Pair x -` F i) \<subseteq> sets M"
hoelzl@49776
   264
      using F by (auto simp: sets_Pair1)
hoelzl@49776
   265
    ultimately show "(\<Sum>n. ?\<mu> (F n)) = ?\<mu> (\<Union>i. F i)"
hoelzl@49776
   266
      by (auto simp add: vimage_UN positive_integral_suminf[symmetric] suminf_emeasure subset_eq emeasure_nonneg sets_Pair1
hoelzl@49776
   267
               intro!: positive_integral_cong positive_integral_indicator[symmetric])
hoelzl@49776
   268
  qed
hoelzl@49776
   269
  show "{a \<times> b |a b. a \<in> sets N \<and> b \<in> sets M} \<subseteq> Pow (space N \<times> space M)"
hoelzl@49776
   270
    using space_closed[of N] space_closed[of M] by auto
hoelzl@49776
   271
qed fact
hoelzl@49776
   272
hoelzl@49776
   273
lemma (in sigma_finite_measure) emeasure_pair_measure_alt:
hoelzl@49776
   274
  assumes X: "X \<in> sets (N \<Otimes>\<^isub>M M)"
hoelzl@49776
   275
  shows "emeasure (N  \<Otimes>\<^isub>M M) X = (\<integral>\<^isup>+x. emeasure M (Pair x -` X) \<partial>N)"
hoelzl@49776
   276
proof -
hoelzl@49776
   277
  have [simp]: "\<And>x y. indicator X (x, y) = indicator (Pair x -` X) y"
hoelzl@49776
   278
    by (auto simp: indicator_def)
hoelzl@49776
   279
  show ?thesis
hoelzl@49776
   280
    using X by (auto intro!: positive_integral_cong simp: emeasure_pair_measure sets_Pair1)
hoelzl@49776
   281
qed
hoelzl@49776
   282
hoelzl@49776
   283
lemma (in sigma_finite_measure) emeasure_pair_measure_Times:
hoelzl@49776
   284
  assumes A: "A \<in> sets N" and B: "B \<in> sets M"
hoelzl@49776
   285
  shows "emeasure (N \<Otimes>\<^isub>M M) (A \<times> B) = emeasure N A * emeasure M B"
hoelzl@49776
   286
proof -
hoelzl@49776
   287
  have "emeasure (N \<Otimes>\<^isub>M M) (A \<times> B) = (\<integral>\<^isup>+x. emeasure M B * indicator A x \<partial>N)"
hoelzl@49776
   288
    using A B by (auto intro!: positive_integral_cong simp: emeasure_pair_measure_alt)
hoelzl@49776
   289
  also have "\<dots> = emeasure M B * emeasure N A"
hoelzl@49776
   290
    using A by (simp add: emeasure_nonneg positive_integral_cmult_indicator)
hoelzl@49776
   291
  finally show ?thesis
hoelzl@49776
   292
    by (simp add: ac_simps)
hoelzl@40859
   293
qed
hoelzl@40859
   294
hoelzl@47694
   295
subsection {* Binary products of $\sigma$-finite emeasure spaces *}
hoelzl@40859
   296
hoelzl@47694
   297
locale pair_sigma_finite = M1: sigma_finite_measure M1 + M2: sigma_finite_measure M2
hoelzl@47694
   298
  for M1 :: "'a measure" and M2 :: "'b measure"
hoelzl@40859
   299
hoelzl@47694
   300
lemma (in pair_sigma_finite) measurable_emeasure_Pair1:
hoelzl@49776
   301
  "Q \<in> sets (M1 \<Otimes>\<^isub>M M2) \<Longrightarrow> (\<lambda>x. emeasure M2 (Pair x -` Q)) \<in> borel_measurable M1"
hoelzl@49776
   302
  using M2.measurable_emeasure_Pair .
hoelzl@40859
   303
hoelzl@47694
   304
lemma (in pair_sigma_finite) measurable_emeasure_Pair2:
hoelzl@47694
   305
  assumes Q: "Q \<in> sets (M1 \<Otimes>\<^isub>M M2)" shows "(\<lambda>y. emeasure M1 ((\<lambda>x. (x, y)) -` Q)) \<in> borel_measurable M2"
hoelzl@40859
   306
proof -
hoelzl@47694
   307
  have "(\<lambda>(x, y). (y, x)) -` Q \<inter> space (M2 \<Otimes>\<^isub>M M1) \<in> sets (M2 \<Otimes>\<^isub>M M1)"
hoelzl@47694
   308
    using Q measurable_pair_swap' by (auto intro: measurable_sets)
hoelzl@49776
   309
  note M1.measurable_emeasure_Pair[OF this]
hoelzl@47694
   310
  moreover have "\<And>y. Pair y -` ((\<lambda>(x, y). (y, x)) -` Q \<inter> space (M2 \<Otimes>\<^isub>M M1)) = (\<lambda>x. (x, y)) -` Q"
hoelzl@47694
   311
    using Q[THEN sets_into_space] by (auto simp: space_pair_measure)
hoelzl@47694
   312
  ultimately show ?thesis by simp
hoelzl@39088
   313
qed
hoelzl@39088
   314
hoelzl@41689
   315
lemma (in pair_sigma_finite) sigma_finite_up_in_pair_measure_generator:
hoelzl@47694
   316
  defines "E \<equiv> {A \<times> B | A B. A \<in> sets M1 \<and> B \<in> sets M2}"
hoelzl@47694
   317
  shows "\<exists>F::nat \<Rightarrow> ('a \<times> 'b) set. range F \<subseteq> E \<and> incseq F \<and> (\<Union>i. F i) = space M1 \<times> space M2 \<and>
hoelzl@47694
   318
    (\<forall>i. emeasure (M1 \<Otimes>\<^isub>M M2) (F i) \<noteq> \<infinity>)"
hoelzl@40859
   319
proof -
hoelzl@47694
   320
  from M1.sigma_finite_incseq guess F1 . note F1 = this
hoelzl@47694
   321
  from M2.sigma_finite_incseq guess F2 . note F2 = this
hoelzl@47694
   322
  from F1 F2 have space: "space M1 = (\<Union>i. F1 i)" "space M2 = (\<Union>i. F2 i)" by auto
hoelzl@40859
   323
  let ?F = "\<lambda>i. F1 i \<times> F2 i"
hoelzl@47694
   324
  show ?thesis
hoelzl@40859
   325
  proof (intro exI[of _ ?F] conjI allI)
hoelzl@47694
   326
    show "range ?F \<subseteq> E" using F1 F2 by (auto simp: E_def) (metis range_subsetD)
hoelzl@40859
   327
  next
hoelzl@40859
   328
    have "space M1 \<times> space M2 \<subseteq> (\<Union>i. ?F i)"
hoelzl@40859
   329
    proof (intro subsetI)
hoelzl@40859
   330
      fix x assume "x \<in> space M1 \<times> space M2"
hoelzl@40859
   331
      then obtain i j where "fst x \<in> F1 i" "snd x \<in> F2 j"
hoelzl@40859
   332
        by (auto simp: space)
hoelzl@40859
   333
      then have "fst x \<in> F1 (max i j)" "snd x \<in> F2 (max j i)"
hoelzl@41981
   334
        using `incseq F1` `incseq F2` unfolding incseq_def
hoelzl@41981
   335
        by (force split: split_max)+
hoelzl@40859
   336
      then have "(fst x, snd x) \<in> F1 (max i j) \<times> F2 (max i j)"
hoelzl@40859
   337
        by (intro SigmaI) (auto simp add: min_max.sup_commute)
hoelzl@40859
   338
      then show "x \<in> (\<Union>i. ?F i)" by auto
hoelzl@40859
   339
    qed
hoelzl@47694
   340
    then show "(\<Union>i. ?F i) = space M1 \<times> space M2"
hoelzl@47694
   341
      using space by (auto simp: space)
hoelzl@40859
   342
  next
hoelzl@41981
   343
    fix i show "incseq (\<lambda>i. F1 i \<times> F2 i)"
hoelzl@41981
   344
      using `incseq F1` `incseq F2` unfolding incseq_Suc_iff by auto
hoelzl@40859
   345
  next
hoelzl@40859
   346
    fix i
hoelzl@40859
   347
    from F1 F2 have "F1 i \<in> sets M1" "F2 i \<in> sets M2" by auto
hoelzl@47694
   348
    with F1 F2 emeasure_nonneg[of M1 "F1 i"] emeasure_nonneg[of M2 "F2 i"]
hoelzl@47694
   349
    show "emeasure (M1 \<Otimes>\<^isub>M M2) (F1 i \<times> F2 i) \<noteq> \<infinity>"
hoelzl@47694
   350
      by (auto simp add: emeasure_pair_measure_Times)
hoelzl@47694
   351
  qed
hoelzl@47694
   352
qed
hoelzl@47694
   353
hoelzl@49800
   354
sublocale pair_sigma_finite \<subseteq> P: sigma_finite_measure "M1 \<Otimes>\<^isub>M M2"
hoelzl@47694
   355
proof
hoelzl@47694
   356
  from sigma_finite_up_in_pair_measure_generator guess F :: "nat \<Rightarrow> ('a \<times> 'b) set" .. note F = this
hoelzl@47694
   357
  show "\<exists>F::nat \<Rightarrow> ('a \<times> 'b) set. range F \<subseteq> sets (M1 \<Otimes>\<^isub>M M2) \<and> (\<Union>i. F i) = space (M1 \<Otimes>\<^isub>M M2) \<and> (\<forall>i. emeasure (M1 \<Otimes>\<^isub>M M2) (F i) \<noteq> \<infinity>)"
hoelzl@47694
   358
  proof (rule exI[of _ F], intro conjI)
hoelzl@47694
   359
    show "range F \<subseteq> sets (M1 \<Otimes>\<^isub>M M2)" using F by (auto simp: pair_measure_def)
hoelzl@47694
   360
    show "(\<Union>i. F i) = space (M1 \<Otimes>\<^isub>M M2)"
hoelzl@47694
   361
      using F by (auto simp: space_pair_measure)
hoelzl@47694
   362
    show "\<forall>i. emeasure (M1 \<Otimes>\<^isub>M M2) (F i) \<noteq> \<infinity>" using F by auto
hoelzl@40859
   363
  qed
hoelzl@40859
   364
qed
hoelzl@40859
   365
hoelzl@47694
   366
lemma sigma_finite_pair_measure:
hoelzl@47694
   367
  assumes A: "sigma_finite_measure A" and B: "sigma_finite_measure B"
hoelzl@47694
   368
  shows "sigma_finite_measure (A \<Otimes>\<^isub>M B)"
hoelzl@47694
   369
proof -
hoelzl@47694
   370
  interpret A: sigma_finite_measure A by fact
hoelzl@47694
   371
  interpret B: sigma_finite_measure B by fact
hoelzl@47694
   372
  interpret AB: pair_sigma_finite A  B ..
hoelzl@47694
   373
  show ?thesis ..
hoelzl@40859
   374
qed
hoelzl@39088
   375
hoelzl@47694
   376
lemma sets_pair_swap:
hoelzl@47694
   377
  assumes "A \<in> sets (M1 \<Otimes>\<^isub>M M2)"
hoelzl@41689
   378
  shows "(\<lambda>(x, y). (y, x)) -` A \<inter> space (M2 \<Otimes>\<^isub>M M1) \<in> sets (M2 \<Otimes>\<^isub>M M1)"
hoelzl@47694
   379
  using measurable_pair_swap' assms by (rule measurable_sets)
hoelzl@41661
   380
hoelzl@47694
   381
lemma (in pair_sigma_finite) distr_pair_swap:
hoelzl@47694
   382
  "M1 \<Otimes>\<^isub>M M2 = distr (M2 \<Otimes>\<^isub>M M1) (M1 \<Otimes>\<^isub>M M2) (\<lambda>(x, y). (y, x))" (is "?P = ?D")
hoelzl@40859
   383
proof -
hoelzl@41689
   384
  from sigma_finite_up_in_pair_measure_generator guess F :: "nat \<Rightarrow> ('a \<times> 'b) set" .. note F = this
hoelzl@47694
   385
  let ?E = "{a \<times> b |a b. a \<in> sets M1 \<and> b \<in> sets M2}"
hoelzl@47694
   386
  show ?thesis
hoelzl@47694
   387
  proof (rule measure_eqI_generator_eq[OF Int_stable_pair_measure_generator[of M1 M2]])
hoelzl@47694
   388
    show "?E \<subseteq> Pow (space ?P)"
hoelzl@47694
   389
      using space_closed[of M1] space_closed[of M2] by (auto simp: space_pair_measure)
hoelzl@47694
   390
    show "sets ?P = sigma_sets (space ?P) ?E"
hoelzl@47694
   391
      by (simp add: sets_pair_measure space_pair_measure)
hoelzl@47694
   392
    then show "sets ?D = sigma_sets (space ?P) ?E"
hoelzl@47694
   393
      by simp
hoelzl@47694
   394
  next
hoelzl@49784
   395
    show "range F \<subseteq> ?E" "(\<Union>i. F i) = space ?P" "\<And>i. emeasure ?P (F i) \<noteq> \<infinity>"
hoelzl@47694
   396
      using F by (auto simp: space_pair_measure)
hoelzl@47694
   397
  next
hoelzl@47694
   398
    fix X assume "X \<in> ?E"
hoelzl@47694
   399
    then obtain A B where X[simp]: "X = A \<times> B" and A: "A \<in> sets M1" and B: "B \<in> sets M2" by auto
hoelzl@47694
   400
    have "(\<lambda>(y, x). (x, y)) -` X \<inter> space (M2 \<Otimes>\<^isub>M M1) = B \<times> A"
hoelzl@47694
   401
      using sets_into_space[OF A] sets_into_space[OF B] by (auto simp: space_pair_measure)
hoelzl@47694
   402
    with A B show "emeasure (M1 \<Otimes>\<^isub>M M2) X = emeasure ?D X"
hoelzl@49776
   403
      by (simp add: M2.emeasure_pair_measure_Times M1.emeasure_pair_measure_Times emeasure_distr
hoelzl@47694
   404
                    measurable_pair_swap' ac_simps)
hoelzl@41689
   405
  qed
hoelzl@41689
   406
qed
hoelzl@41689
   407
hoelzl@47694
   408
lemma (in pair_sigma_finite) emeasure_pair_measure_alt2:
hoelzl@47694
   409
  assumes A: "A \<in> sets (M1 \<Otimes>\<^isub>M M2)"
hoelzl@47694
   410
  shows "emeasure (M1 \<Otimes>\<^isub>M M2) A = (\<integral>\<^isup>+y. emeasure M1 ((\<lambda>x. (x, y)) -` A) \<partial>M2)"
hoelzl@47694
   411
    (is "_ = ?\<nu> A")
hoelzl@41689
   412
proof -
hoelzl@47694
   413
  have [simp]: "\<And>y. (Pair y -` ((\<lambda>(x, y). (y, x)) -` A \<inter> space (M2 \<Otimes>\<^isub>M M1))) = (\<lambda>x. (x, y)) -` A"
hoelzl@47694
   414
    using sets_into_space[OF A] by (auto simp: space_pair_measure)
hoelzl@47694
   415
  show ?thesis using A
hoelzl@47694
   416
    by (subst distr_pair_swap)
hoelzl@47694
   417
       (simp_all del: vimage_Int add: measurable_sets[OF measurable_pair_swap']
hoelzl@49776
   418
                 M1.emeasure_pair_measure_alt emeasure_distr[OF measurable_pair_swap' A])
hoelzl@49776
   419
qed
hoelzl@49776
   420
hoelzl@49776
   421
lemma (in pair_sigma_finite) AE_pair:
hoelzl@49776
   422
  assumes "AE x in (M1 \<Otimes>\<^isub>M M2). Q x"
hoelzl@49776
   423
  shows "AE x in M1. (AE y in M2. Q (x, y))"
hoelzl@49776
   424
proof -
hoelzl@49776
   425
  obtain N where N: "N \<in> sets (M1 \<Otimes>\<^isub>M M2)" "emeasure (M1 \<Otimes>\<^isub>M M2) N = 0" "{x\<in>space (M1 \<Otimes>\<^isub>M M2). \<not> Q x} \<subseteq> N"
hoelzl@49776
   426
    using assms unfolding eventually_ae_filter by auto
hoelzl@49776
   427
  show ?thesis
hoelzl@49776
   428
  proof (rule AE_I)
hoelzl@49776
   429
    from N measurable_emeasure_Pair1[OF `N \<in> sets (M1 \<Otimes>\<^isub>M M2)`]
hoelzl@49776
   430
    show "emeasure M1 {x\<in>space M1. emeasure M2 (Pair x -` N) \<noteq> 0} = 0"
hoelzl@49776
   431
      by (auto simp: M2.emeasure_pair_measure_alt positive_integral_0_iff emeasure_nonneg)
hoelzl@49776
   432
    show "{x \<in> space M1. emeasure M2 (Pair x -` N) \<noteq> 0} \<in> sets M1"
hoelzl@49776
   433
      by (intro borel_measurable_ereal_neq_const measurable_emeasure_Pair1 N)
hoelzl@49776
   434
    { fix x assume "x \<in> space M1" "emeasure M2 (Pair x -` N) = 0"
hoelzl@49776
   435
      have "AE y in M2. Q (x, y)"
hoelzl@49776
   436
      proof (rule AE_I)
hoelzl@49776
   437
        show "emeasure M2 (Pair x -` N) = 0" by fact
hoelzl@49776
   438
        show "Pair x -` N \<in> sets M2" using N(1) by (rule sets_Pair1)
hoelzl@49776
   439
        show "{y \<in> space M2. \<not> Q (x, y)} \<subseteq> Pair x -` N"
hoelzl@49776
   440
          using N `x \<in> space M1` unfolding space_pair_measure by auto
hoelzl@49776
   441
      qed }
hoelzl@49776
   442
    then show "{x \<in> space M1. \<not> (AE y in M2. Q (x, y))} \<subseteq> {x \<in> space M1. emeasure M2 (Pair x -` N) \<noteq> 0}"
hoelzl@49776
   443
      by auto
hoelzl@49776
   444
  qed
hoelzl@49776
   445
qed
hoelzl@49776
   446
hoelzl@49776
   447
lemma (in pair_sigma_finite) AE_pair_measure:
hoelzl@49776
   448
  assumes "{x\<in>space (M1 \<Otimes>\<^isub>M M2). P x} \<in> sets (M1 \<Otimes>\<^isub>M M2)"
hoelzl@49776
   449
  assumes ae: "AE x in M1. AE y in M2. P (x, y)"
hoelzl@49776
   450
  shows "AE x in M1 \<Otimes>\<^isub>M M2. P x"
hoelzl@49776
   451
proof (subst AE_iff_measurable[OF _ refl])
hoelzl@49776
   452
  show "{x\<in>space (M1 \<Otimes>\<^isub>M M2). \<not> P x} \<in> sets (M1 \<Otimes>\<^isub>M M2)"
hoelzl@49776
   453
    by (rule sets_Collect) fact
hoelzl@49776
   454
  then have "emeasure (M1 \<Otimes>\<^isub>M M2) {x \<in> space (M1 \<Otimes>\<^isub>M M2). \<not> P x} =
hoelzl@49776
   455
      (\<integral>\<^isup>+ x. \<integral>\<^isup>+ y. indicator {x \<in> space (M1 \<Otimes>\<^isub>M M2). \<not> P x} (x, y) \<partial>M2 \<partial>M1)"
hoelzl@49776
   456
    by (simp add: M2.emeasure_pair_measure)
hoelzl@49776
   457
  also have "\<dots> = (\<integral>\<^isup>+ x. \<integral>\<^isup>+ y. 0 \<partial>M2 \<partial>M1)"
hoelzl@49776
   458
    using ae
hoelzl@49776
   459
    apply (safe intro!: positive_integral_cong_AE)
hoelzl@49776
   460
    apply (intro AE_I2)
hoelzl@49776
   461
    apply (safe intro!: positive_integral_cong_AE)
hoelzl@49776
   462
    apply auto
hoelzl@49776
   463
    done
hoelzl@49776
   464
  finally show "emeasure (M1 \<Otimes>\<^isub>M M2) {x \<in> space (M1 \<Otimes>\<^isub>M M2). \<not> P x} = 0" by simp
hoelzl@49776
   465
qed
hoelzl@49776
   466
hoelzl@49776
   467
lemma (in pair_sigma_finite) AE_pair_iff:
hoelzl@49776
   468
  "{x\<in>space (M1 \<Otimes>\<^isub>M M2). P (fst x) (snd x)} \<in> sets (M1 \<Otimes>\<^isub>M M2) \<Longrightarrow>
hoelzl@49776
   469
    (AE x in M1. AE y in M2. P x y) \<longleftrightarrow> (AE x in (M1 \<Otimes>\<^isub>M M2). P (fst x) (snd x))"
hoelzl@49776
   470
  using AE_pair[of "\<lambda>x. P (fst x) (snd x)"] AE_pair_measure[of "\<lambda>x. P (fst x) (snd x)"] by auto
hoelzl@49776
   471
hoelzl@49776
   472
lemma (in pair_sigma_finite) AE_commute:
hoelzl@49776
   473
  assumes P: "{x\<in>space (M1 \<Otimes>\<^isub>M M2). P (fst x) (snd x)} \<in> sets (M1 \<Otimes>\<^isub>M M2)"
hoelzl@49776
   474
  shows "(AE x in M1. AE y in M2. P x y) \<longleftrightarrow> (AE y in M2. AE x in M1. P x y)"
hoelzl@49776
   475
proof -
hoelzl@49776
   476
  interpret Q: pair_sigma_finite M2 M1 ..
hoelzl@49776
   477
  have [simp]: "\<And>x. (fst (case x of (x, y) \<Rightarrow> (y, x))) = snd x" "\<And>x. (snd (case x of (x, y) \<Rightarrow> (y, x))) = fst x"
hoelzl@49776
   478
    by auto
hoelzl@49776
   479
  have "{x \<in> space (M2 \<Otimes>\<^isub>M M1). P (snd x) (fst x)} =
hoelzl@49776
   480
    (\<lambda>(x, y). (y, x)) -` {x \<in> space (M1 \<Otimes>\<^isub>M M2). P (fst x) (snd x)} \<inter> space (M2 \<Otimes>\<^isub>M M1)"
hoelzl@49776
   481
    by (auto simp: space_pair_measure)
hoelzl@49776
   482
  also have "\<dots> \<in> sets (M2 \<Otimes>\<^isub>M M1)"
hoelzl@49776
   483
    by (intro sets_pair_swap P)
hoelzl@49776
   484
  finally show ?thesis
hoelzl@49776
   485
    apply (subst AE_pair_iff[OF P])
hoelzl@49776
   486
    apply (subst distr_pair_swap)
hoelzl@49776
   487
    apply (subst AE_distr_iff[OF measurable_pair_swap' P])
hoelzl@49776
   488
    apply (subst Q.AE_pair_iff)
hoelzl@49776
   489
    apply simp_all
hoelzl@49776
   490
    done
hoelzl@40859
   491
qed
hoelzl@40859
   492
hoelzl@40859
   493
section "Fubinis theorem"
hoelzl@40859
   494
hoelzl@49800
   495
lemma measurable_compose_Pair1:
hoelzl@49800
   496
  "x \<in> space M1 \<Longrightarrow> g \<in> measurable (M1 \<Otimes>\<^isub>M M2) L \<Longrightarrow> (\<lambda>y. g (x, y)) \<in> measurable M2 L"
hoelzl@50003
   497
  by simp
hoelzl@49800
   498
hoelzl@49999
   499
lemma (in sigma_finite_measure) borel_measurable_positive_integral_fst':
hoelzl@49999
   500
  assumes f: "f \<in> borel_measurable (M1 \<Otimes>\<^isub>M M)" "\<And>x. 0 \<le> f x"
hoelzl@49999
   501
  shows "(\<lambda>x. \<integral>\<^isup>+ y. f (x, y) \<partial>M) \<in> borel_measurable M1"
hoelzl@49800
   502
using f proof induct
hoelzl@49800
   503
  case (cong u v)
hoelzl@49999
   504
  then have "\<And>w x. w \<in> space M1 \<Longrightarrow> x \<in> space M \<Longrightarrow> u (w, x) = v (w, x)"
hoelzl@49800
   505
    by (auto simp: space_pair_measure)
hoelzl@49800
   506
  show ?case
hoelzl@49800
   507
    apply (subst measurable_cong)
hoelzl@49800
   508
    apply (rule positive_integral_cong)
hoelzl@49800
   509
    apply fact+
hoelzl@49800
   510
    done
hoelzl@49800
   511
next
hoelzl@49800
   512
  case (set Q)
hoelzl@49800
   513
  have [simp]: "\<And>x y. indicator Q (x, y) = indicator (Pair x -` Q) y"
hoelzl@49800
   514
    by (auto simp: indicator_def)
hoelzl@49999
   515
  have "\<And>x. x \<in> space M1 \<Longrightarrow> emeasure M (Pair x -` Q) = \<integral>\<^isup>+ y. indicator Q (x, y) \<partial>M"
hoelzl@49800
   516
    by (simp add: sets_Pair1[OF set])
hoelzl@49999
   517
  from this measurable_emeasure_Pair[OF set] show ?case
hoelzl@49800
   518
    by (rule measurable_cong[THEN iffD1])
hoelzl@49800
   519
qed (simp_all add: positive_integral_add positive_integral_cmult measurable_compose_Pair1
hoelzl@49800
   520
                   positive_integral_monotone_convergence_SUP incseq_def le_fun_def
hoelzl@49800
   521
              cong: measurable_cong)
hoelzl@49800
   522
hoelzl@49999
   523
lemma (in sigma_finite_measure) positive_integral_fst:
hoelzl@49999
   524
  assumes f: "f \<in> borel_measurable (M1 \<Otimes>\<^isub>M M)" "\<And>x. 0 \<le> f x"
hoelzl@49999
   525
  shows "(\<integral>\<^isup>+ x. \<integral>\<^isup>+ y. f (x, y) \<partial>M \<partial>M1) = integral\<^isup>P (M1 \<Otimes>\<^isub>M M) f" (is "?I f = _")
hoelzl@49800
   526
using f proof induct
hoelzl@49800
   527
  case (cong u v)
hoelzl@49800
   528
  moreover then have "?I u = ?I v"
hoelzl@49800
   529
    by (intro positive_integral_cong) (auto simp: space_pair_measure)
hoelzl@49800
   530
  ultimately show ?case
hoelzl@49800
   531
    by (simp cong: positive_integral_cong)
hoelzl@49999
   532
qed (simp_all add: emeasure_pair_measure positive_integral_cmult positive_integral_add
hoelzl@49800
   533
                   positive_integral_monotone_convergence_SUP
hoelzl@49800
   534
                   measurable_compose_Pair1 positive_integral_positive
hoelzl@49825
   535
                   borel_measurable_positive_integral_fst' positive_integral_mono incseq_def le_fun_def
hoelzl@49800
   536
              cong: positive_integral_cong)
hoelzl@40859
   537
hoelzl@49999
   538
lemma (in sigma_finite_measure) positive_integral_fst_measurable:
hoelzl@49999
   539
  assumes f: "f \<in> borel_measurable (M1 \<Otimes>\<^isub>M M)"
hoelzl@49999
   540
  shows "(\<lambda>x. \<integral>\<^isup>+ y. f (x, y) \<partial>M) \<in> borel_measurable M1"
hoelzl@40859
   541
      (is "?C f \<in> borel_measurable M1")
hoelzl@49999
   542
    and "(\<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. f (x, y) \<partial>M) \<partial>M1) = integral\<^isup>P (M1 \<Otimes>\<^isub>M M) f"
hoelzl@49800
   543
  using f
hoelzl@49825
   544
    borel_measurable_positive_integral_fst'[of "\<lambda>x. max 0 (f x)"]
hoelzl@49800
   545
    positive_integral_fst[of "\<lambda>x. max 0 (f x)"]
hoelzl@49800
   546
  unfolding positive_integral_max_0 by auto
hoelzl@40859
   547
hoelzl@50003
   548
lemma (in sigma_finite_measure) borel_measurable_positive_integral[measurable (raw)]:
hoelzl@50003
   549
  "split f \<in> borel_measurable (N \<Otimes>\<^isub>M M) \<Longrightarrow> (\<lambda>x. \<integral>\<^isup>+ y. f x y \<partial>M) \<in> borel_measurable N"
hoelzl@50003
   550
  using positive_integral_fst_measurable(1)[of "split f" N] by simp
hoelzl@50003
   551
hoelzl@50003
   552
lemma (in sigma_finite_measure) borel_measurable_lebesgue_integral[measurable (raw)]:
hoelzl@50003
   553
  "split f \<in> borel_measurable (N \<Otimes>\<^isub>M M) \<Longrightarrow> (\<lambda>x. \<integral> y. f x y \<partial>M) \<in> borel_measurable N"
hoelzl@50003
   554
  by (simp add: lebesgue_integral_def)
hoelzl@49825
   555
hoelzl@47694
   556
lemma (in pair_sigma_finite) positive_integral_snd_measurable:
hoelzl@47694
   557
  assumes f: "f \<in> borel_measurable (M1 \<Otimes>\<^isub>M M2)"
hoelzl@47694
   558
  shows "(\<integral>\<^isup>+ y. (\<integral>\<^isup>+ x. f (x, y) \<partial>M1) \<partial>M2) = integral\<^isup>P (M1 \<Otimes>\<^isub>M M2) f"
hoelzl@41661
   559
proof -
hoelzl@47694
   560
  note measurable_pair_swap[OF f]
hoelzl@49999
   561
  from M1.positive_integral_fst_measurable[OF this]
hoelzl@47694
   562
  have "(\<integral>\<^isup>+ y. (\<integral>\<^isup>+ x. f (x, y) \<partial>M1) \<partial>M2) = (\<integral>\<^isup>+ (x, y). f (y, x) \<partial>(M2 \<Otimes>\<^isub>M M1))"
hoelzl@40859
   563
    by simp
hoelzl@47694
   564
  also have "(\<integral>\<^isup>+ (x, y). f (y, x) \<partial>(M2 \<Otimes>\<^isub>M M1)) = integral\<^isup>P (M1 \<Otimes>\<^isub>M M2) f"
hoelzl@47694
   565
    by (subst distr_pair_swap)
hoelzl@47694
   566
       (auto simp: positive_integral_distr[OF measurable_pair_swap' f] intro!: positive_integral_cong)
hoelzl@40859
   567
  finally show ?thesis .
hoelzl@40859
   568
qed
hoelzl@40859
   569
hoelzl@40859
   570
lemma (in pair_sigma_finite) Fubini:
hoelzl@47694
   571
  assumes f: "f \<in> borel_measurable (M1 \<Otimes>\<^isub>M M2)"
hoelzl@41689
   572
  shows "(\<integral>\<^isup>+ y. (\<integral>\<^isup>+ x. f (x, y) \<partial>M1) \<partial>M2) = (\<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. f (x, y) \<partial>M2) \<partial>M1)"
hoelzl@40859
   573
  unfolding positive_integral_snd_measurable[OF assms]
hoelzl@49999
   574
  unfolding M2.positive_integral_fst_measurable[OF assms] ..
hoelzl@40859
   575
hoelzl@41026
   576
lemma (in pair_sigma_finite) integrable_product_swap:
hoelzl@47694
   577
  assumes "integrable (M1 \<Otimes>\<^isub>M M2) f"
hoelzl@41689
   578
  shows "integrable (M2 \<Otimes>\<^isub>M M1) (\<lambda>(x,y). f (y,x))"
hoelzl@41026
   579
proof -
hoelzl@41689
   580
  interpret Q: pair_sigma_finite M2 M1 by default
hoelzl@41661
   581
  have *: "(\<lambda>(x,y). f (y,x)) = (\<lambda>x. f (case x of (x,y)\<Rightarrow>(y,x)))" by (auto simp: fun_eq_iff)
hoelzl@41661
   582
  show ?thesis unfolding *
hoelzl@47694
   583
    by (rule integrable_distr[OF measurable_pair_swap'])
hoelzl@47694
   584
       (simp add: distr_pair_swap[symmetric] assms)
hoelzl@41661
   585
qed
hoelzl@41661
   586
hoelzl@41661
   587
lemma (in pair_sigma_finite) integrable_product_swap_iff:
hoelzl@47694
   588
  "integrable (M2 \<Otimes>\<^isub>M M1) (\<lambda>(x,y). f (y,x)) \<longleftrightarrow> integrable (M1 \<Otimes>\<^isub>M M2) f"
hoelzl@41661
   589
proof -
hoelzl@41689
   590
  interpret Q: pair_sigma_finite M2 M1 by default
hoelzl@41661
   591
  from Q.integrable_product_swap[of "\<lambda>(x,y). f (y,x)"] integrable_product_swap[of f]
hoelzl@41661
   592
  show ?thesis by auto
hoelzl@41026
   593
qed
hoelzl@41026
   594
hoelzl@41026
   595
lemma (in pair_sigma_finite) integral_product_swap:
hoelzl@47694
   596
  assumes f: "f \<in> borel_measurable (M1 \<Otimes>\<^isub>M M2)"
hoelzl@47694
   597
  shows "(\<integral>(x,y). f (y,x) \<partial>(M2 \<Otimes>\<^isub>M M1)) = integral\<^isup>L (M1 \<Otimes>\<^isub>M M2) f"
hoelzl@41026
   598
proof -
hoelzl@41661
   599
  have *: "(\<lambda>(x,y). f (y,x)) = (\<lambda>x. f (case x of (x,y)\<Rightarrow>(y,x)))" by (auto simp: fun_eq_iff)
hoelzl@47694
   600
  show ?thesis unfolding *
hoelzl@47694
   601
    by (simp add: integral_distr[symmetric, OF measurable_pair_swap' f] distr_pair_swap[symmetric])
hoelzl@41026
   602
qed
hoelzl@41026
   603
hoelzl@41026
   604
lemma (in pair_sigma_finite) integrable_fst_measurable:
hoelzl@47694
   605
  assumes f: "integrable (M1 \<Otimes>\<^isub>M M2) f"
hoelzl@47694
   606
  shows "AE x in M1. integrable M2 (\<lambda> y. f (x, y))" (is "?AE")
hoelzl@47694
   607
    and "(\<integral>x. (\<integral>y. f (x, y) \<partial>M2) \<partial>M1) = integral\<^isup>L (M1 \<Otimes>\<^isub>M M2) f" (is "?INT")
hoelzl@41026
   608
proof -
hoelzl@47694
   609
  have f_borel: "f \<in> borel_measurable (M1 \<Otimes>\<^isub>M M2)"
hoelzl@47694
   610
    using f by auto
wenzelm@46731
   611
  let ?pf = "\<lambda>x. ereal (f x)" and ?nf = "\<lambda>x. ereal (- f x)"
hoelzl@41026
   612
  have
hoelzl@47694
   613
    borel: "?nf \<in> borel_measurable (M1 \<Otimes>\<^isub>M M2)""?pf \<in> borel_measurable (M1 \<Otimes>\<^isub>M M2)" and
hoelzl@47694
   614
    int: "integral\<^isup>P (M1 \<Otimes>\<^isub>M M2) ?nf \<noteq> \<infinity>" "integral\<^isup>P (M1 \<Otimes>\<^isub>M M2) ?pf \<noteq> \<infinity>"
hoelzl@41026
   615
    using assms by auto
hoelzl@43920
   616
  have "(\<integral>\<^isup>+x. (\<integral>\<^isup>+y. ereal (f (x, y)) \<partial>M2) \<partial>M1) \<noteq> \<infinity>"
hoelzl@43920
   617
     "(\<integral>\<^isup>+x. (\<integral>\<^isup>+y. ereal (- f (x, y)) \<partial>M2) \<partial>M1) \<noteq> \<infinity>"
hoelzl@49999
   618
    using borel[THEN M2.positive_integral_fst_measurable(1)] int
hoelzl@49999
   619
    unfolding borel[THEN M2.positive_integral_fst_measurable(2)] by simp_all
hoelzl@49999
   620
  with borel[THEN M2.positive_integral_fst_measurable(1)]
hoelzl@43920
   621
  have AE_pos: "AE x in M1. (\<integral>\<^isup>+y. ereal (f (x, y)) \<partial>M2) \<noteq> \<infinity>"
hoelzl@43920
   622
    "AE x in M1. (\<integral>\<^isup>+y. ereal (- f (x, y)) \<partial>M2) \<noteq> \<infinity>"
hoelzl@47694
   623
    by (auto intro!: positive_integral_PInf_AE )
hoelzl@43920
   624
  then have AE: "AE x in M1. \<bar>\<integral>\<^isup>+y. ereal (f (x, y)) \<partial>M2\<bar> \<noteq> \<infinity>"
hoelzl@43920
   625
    "AE x in M1. \<bar>\<integral>\<^isup>+y. ereal (- f (x, y)) \<partial>M2\<bar> \<noteq> \<infinity>"
hoelzl@47694
   626
    by (auto simp: positive_integral_positive)
hoelzl@41981
   627
  from AE_pos show ?AE using assms
hoelzl@47694
   628
    by (simp add: measurable_Pair2[OF f_borel] integrable_def)
hoelzl@43920
   629
  { fix f have "(\<integral>\<^isup>+ x. - \<integral>\<^isup>+ y. ereal (f x y) \<partial>M2 \<partial>M1) = (\<integral>\<^isup>+x. 0 \<partial>M1)"
hoelzl@47694
   630
      using positive_integral_positive
hoelzl@47694
   631
      by (intro positive_integral_cong_pos) (auto simp: ereal_uminus_le_reorder)
hoelzl@43920
   632
    then have "(\<integral>\<^isup>+ x. - \<integral>\<^isup>+ y. ereal (f x y) \<partial>M2 \<partial>M1) = 0" by simp }
hoelzl@41981
   633
  note this[simp]
hoelzl@47694
   634
  { fix f assume borel: "(\<lambda>x. ereal (f x)) \<in> borel_measurable (M1 \<Otimes>\<^isub>M M2)"
hoelzl@47694
   635
      and int: "integral\<^isup>P (M1 \<Otimes>\<^isub>M M2) (\<lambda>x. ereal (f x)) \<noteq> \<infinity>"
hoelzl@47694
   636
      and AE: "AE x in M1. (\<integral>\<^isup>+y. ereal (f (x, y)) \<partial>M2) \<noteq> \<infinity>"
hoelzl@43920
   637
    have "integrable M1 (\<lambda>x. real (\<integral>\<^isup>+y. ereal (f (x, y)) \<partial>M2))" (is "integrable M1 ?f")
hoelzl@41705
   638
    proof (intro integrable_def[THEN iffD2] conjI)
hoelzl@41705
   639
      show "?f \<in> borel_measurable M1"
hoelzl@49999
   640
        using borel by (auto intro!: M2.positive_integral_fst_measurable)
hoelzl@43920
   641
      have "(\<integral>\<^isup>+x. ereal (?f x) \<partial>M1) = (\<integral>\<^isup>+x. (\<integral>\<^isup>+y. ereal (f (x, y))  \<partial>M2) \<partial>M1)"
hoelzl@47694
   642
        using AE positive_integral_positive[of M2]
hoelzl@47694
   643
        by (auto intro!: positive_integral_cong_AE simp: ereal_real)
hoelzl@43920
   644
      then show "(\<integral>\<^isup>+x. ereal (?f x) \<partial>M1) \<noteq> \<infinity>"
hoelzl@49999
   645
        using M2.positive_integral_fst_measurable[OF borel] int by simp
hoelzl@43920
   646
      have "(\<integral>\<^isup>+x. ereal (- ?f x) \<partial>M1) = (\<integral>\<^isup>+x. 0 \<partial>M1)"
hoelzl@47694
   647
        by (intro positive_integral_cong_pos)
hoelzl@47694
   648
           (simp add: positive_integral_positive real_of_ereal_pos)
hoelzl@43920
   649
      then show "(\<integral>\<^isup>+x. ereal (- ?f x) \<partial>M1) \<noteq> \<infinity>" by simp
hoelzl@41705
   650
    qed }
hoelzl@41981
   651
  with this[OF borel(1) int(1) AE_pos(2)] this[OF borel(2) int(2) AE_pos(1)]
hoelzl@41705
   652
  show ?INT
hoelzl@47694
   653
    unfolding lebesgue_integral_def[of "M1 \<Otimes>\<^isub>M M2"] lebesgue_integral_def[of M2]
hoelzl@49999
   654
      borel[THEN M2.positive_integral_fst_measurable(2), symmetric]
hoelzl@47694
   655
    using AE[THEN integral_real]
hoelzl@41981
   656
    by simp
hoelzl@41026
   657
qed
hoelzl@41026
   658
hoelzl@41026
   659
lemma (in pair_sigma_finite) integrable_snd_measurable:
hoelzl@47694
   660
  assumes f: "integrable (M1 \<Otimes>\<^isub>M M2) f"
hoelzl@47694
   661
  shows "AE y in M2. integrable M1 (\<lambda>x. f (x, y))" (is "?AE")
hoelzl@47694
   662
    and "(\<integral>y. (\<integral>x. f (x, y) \<partial>M1) \<partial>M2) = integral\<^isup>L (M1 \<Otimes>\<^isub>M M2) f" (is "?INT")
hoelzl@41026
   663
proof -
hoelzl@41689
   664
  interpret Q: pair_sigma_finite M2 M1 by default
hoelzl@47694
   665
  have Q_int: "integrable (M2 \<Otimes>\<^isub>M M1) (\<lambda>(x, y). f (y, x))"
hoelzl@41661
   666
    using f unfolding integrable_product_swap_iff .
hoelzl@41026
   667
  show ?INT
hoelzl@41026
   668
    using Q.integrable_fst_measurable(2)[OF Q_int]
hoelzl@47694
   669
    using integral_product_swap[of f] f by auto
hoelzl@41026
   670
  show ?AE
hoelzl@41026
   671
    using Q.integrable_fst_measurable(1)[OF Q_int]
hoelzl@41026
   672
    by simp
hoelzl@41026
   673
qed
hoelzl@41026
   674
hoelzl@41026
   675
lemma (in pair_sigma_finite) Fubini_integral:
hoelzl@47694
   676
  assumes f: "integrable (M1 \<Otimes>\<^isub>M M2) f"
hoelzl@41689
   677
  shows "(\<integral>y. (\<integral>x. f (x, y) \<partial>M1) \<partial>M2) = (\<integral>x. (\<integral>y. f (x, y) \<partial>M2) \<partial>M1)"
hoelzl@41026
   678
  unfolding integrable_snd_measurable[OF assms]
hoelzl@41026
   679
  unfolding integrable_fst_measurable[OF assms] ..
hoelzl@41026
   680
hoelzl@47694
   681
section {* Products on counting spaces, densities and distributions *}
hoelzl@40859
   682
hoelzl@41689
   683
lemma sigma_sets_pair_measure_generator_finite:
hoelzl@38656
   684
  assumes "finite A" and "finite B"
hoelzl@47694
   685
  shows "sigma_sets (A \<times> B) { a \<times> b | a b. a \<subseteq> A \<and> b \<subseteq> B} = Pow (A \<times> B)"
hoelzl@40859
   686
  (is "sigma_sets ?prod ?sets = _")
hoelzl@38656
   687
proof safe
hoelzl@38656
   688
  have fin: "finite (A \<times> B)" using assms by (rule finite_cartesian_product)
hoelzl@38656
   689
  fix x assume subset: "x \<subseteq> A \<times> B"
hoelzl@38656
   690
  hence "finite x" using fin by (rule finite_subset)
hoelzl@40859
   691
  from this subset show "x \<in> sigma_sets ?prod ?sets"
hoelzl@38656
   692
  proof (induct x)
hoelzl@38656
   693
    case empty show ?case by (rule sigma_sets.Empty)
hoelzl@38656
   694
  next
hoelzl@38656
   695
    case (insert a x)
hoelzl@47694
   696
    hence "{a} \<in> sigma_sets ?prod ?sets" by auto
hoelzl@38656
   697
    moreover have "x \<in> sigma_sets ?prod ?sets" using insert by auto
hoelzl@38656
   698
    ultimately show ?case unfolding insert_is_Un[of a x] by (rule sigma_sets_Un)
hoelzl@38656
   699
  qed
hoelzl@38656
   700
next
hoelzl@38656
   701
  fix x a b
hoelzl@40859
   702
  assume "x \<in> sigma_sets ?prod ?sets" and "(a, b) \<in> x"
hoelzl@38656
   703
  from sigma_sets_into_sp[OF _ this(1)] this(2)
hoelzl@40859
   704
  show "a \<in> A" and "b \<in> B" by auto
hoelzl@35833
   705
qed
hoelzl@35833
   706
hoelzl@47694
   707
lemma pair_measure_count_space:
hoelzl@47694
   708
  assumes A: "finite A" and B: "finite B"
hoelzl@47694
   709
  shows "count_space A \<Otimes>\<^isub>M count_space B = count_space (A \<times> B)" (is "?P = ?C")
hoelzl@47694
   710
proof (rule measure_eqI)
hoelzl@47694
   711
  interpret A: finite_measure "count_space A" by (rule finite_measure_count_space) fact
hoelzl@47694
   712
  interpret B: finite_measure "count_space B" by (rule finite_measure_count_space) fact
hoelzl@47694
   713
  interpret P: pair_sigma_finite "count_space A" "count_space B" by default
hoelzl@47694
   714
  show eq: "sets ?P = sets ?C"
hoelzl@47694
   715
    by (simp add: sets_pair_measure sigma_sets_pair_measure_generator_finite A B)
hoelzl@47694
   716
  fix X assume X: "X \<in> sets ?P"
hoelzl@47694
   717
  with eq have X_subset: "X \<subseteq> A \<times> B" by simp
hoelzl@47694
   718
  with A B have fin_Pair: "\<And>x. finite (Pair x -` X)"
hoelzl@47694
   719
    by (intro finite_subset[OF _ B]) auto
hoelzl@47694
   720
  have fin_X: "finite X" using X_subset by (rule finite_subset) (auto simp: A B)
hoelzl@47694
   721
  show "emeasure ?P X = emeasure ?C X"
hoelzl@49776
   722
    apply (subst B.emeasure_pair_measure_alt[OF X])
hoelzl@47694
   723
    apply (subst emeasure_count_space)
hoelzl@47694
   724
    using X_subset apply auto []
hoelzl@47694
   725
    apply (simp add: fin_Pair emeasure_count_space X_subset fin_X)
hoelzl@47694
   726
    apply (subst positive_integral_count_space)
hoelzl@47694
   727
    using A apply simp
hoelzl@47694
   728
    apply (simp del: real_of_nat_setsum add: real_of_nat_setsum[symmetric])
hoelzl@47694
   729
    apply (subst card_gt_0_iff)
hoelzl@47694
   730
    apply (simp add: fin_Pair)
hoelzl@47694
   731
    apply (subst card_SigmaI[symmetric])
hoelzl@47694
   732
    using A apply simp
hoelzl@47694
   733
    using fin_Pair apply simp
hoelzl@47694
   734
    using X_subset apply (auto intro!: arg_cong[where f=card])
hoelzl@47694
   735
    done
hoelzl@45777
   736
qed
hoelzl@35833
   737
hoelzl@47694
   738
lemma pair_measure_density:
hoelzl@47694
   739
  assumes f: "f \<in> borel_measurable M1" "AE x in M1. 0 \<le> f x"
hoelzl@47694
   740
  assumes g: "g \<in> borel_measurable M2" "AE x in M2. 0 \<le> g x"
hoelzl@50003
   741
  assumes "sigma_finite_measure M2" "sigma_finite_measure (density M2 g)"
hoelzl@47694
   742
  shows "density M1 f \<Otimes>\<^isub>M density M2 g = density (M1 \<Otimes>\<^isub>M M2) (\<lambda>(x,y). f x * g y)" (is "?L = ?R")
hoelzl@47694
   743
proof (rule measure_eqI)
hoelzl@47694
   744
  interpret M2: sigma_finite_measure M2 by fact
hoelzl@47694
   745
  interpret D2: sigma_finite_measure "density M2 g" by fact
hoelzl@47694
   746
hoelzl@47694
   747
  fix A assume A: "A \<in> sets ?L"
hoelzl@50003
   748
  with f g have "(\<integral>\<^isup>+ x. f x * \<integral>\<^isup>+ y. g y * indicator A (x, y) \<partial>M2 \<partial>M1) =
hoelzl@50003
   749
    (\<integral>\<^isup>+ x. \<integral>\<^isup>+ y. f x * g y * indicator A (x, y) \<partial>M2 \<partial>M1)"
hoelzl@50003
   750
    by (intro positive_integral_cong_AE)
hoelzl@50003
   751
       (auto simp add: positive_integral_cmult[symmetric] ac_simps)
hoelzl@50003
   752
  with A f g show "emeasure ?L A = emeasure ?R A"
hoelzl@50003
   753
    by (simp add: D2.emeasure_pair_measure emeasure_density positive_integral_density
hoelzl@50003
   754
                  M2.positive_integral_fst_measurable(2)[symmetric]
hoelzl@50003
   755
             cong: positive_integral_cong)
hoelzl@47694
   756
qed simp
hoelzl@47694
   757
hoelzl@47694
   758
lemma sigma_finite_measure_distr:
hoelzl@47694
   759
  assumes "sigma_finite_measure (distr M N f)" and f: "f \<in> measurable M N"
hoelzl@47694
   760
  shows "sigma_finite_measure M"
hoelzl@40859
   761
proof -
hoelzl@47694
   762
  interpret sigma_finite_measure "distr M N f" by fact
hoelzl@47694
   763
  from sigma_finite_disjoint guess A . note A = this
hoelzl@47694
   764
  show ?thesis
hoelzl@47694
   765
  proof (unfold_locales, intro conjI exI allI)
hoelzl@47694
   766
    show "range (\<lambda>i. f -` A i \<inter> space M) \<subseteq> sets M"
hoelzl@50003
   767
      using A f by auto
hoelzl@47694
   768
    show "(\<Union>i. f -` A i \<inter> space M) = space M"
hoelzl@47694
   769
      using A(1) A(2)[symmetric] f by (auto simp: measurable_def Pi_def)
hoelzl@47694
   770
    fix i show "emeasure M (f -` A i \<inter> space M) \<noteq> \<infinity>"
hoelzl@47694
   771
      using f A(1,2) A(3)[of i] by (simp add: emeasure_distr subset_eq)
hoelzl@47694
   772
  qed
hoelzl@38656
   773
qed
hoelzl@38656
   774
hoelzl@47694
   775
lemma pair_measure_distr:
hoelzl@47694
   776
  assumes f: "f \<in> measurable M S" and g: "g \<in> measurable N T"
hoelzl@50003
   777
  assumes "sigma_finite_measure (distr N T g)"
hoelzl@47694
   778
  shows "distr M S f \<Otimes>\<^isub>M distr N T g = distr (M \<Otimes>\<^isub>M N) (S \<Otimes>\<^isub>M T) (\<lambda>(x, y). (f x, g y))" (is "?P = ?D")
hoelzl@47694
   779
proof (rule measure_eqI)
hoelzl@47694
   780
  interpret T: sigma_finite_measure "distr N T g" by fact
hoelzl@47694
   781
  interpret N: sigma_finite_measure N by (rule sigma_finite_measure_distr) fact+
hoelzl@50003
   782
hoelzl@47694
   783
  fix A assume A: "A \<in> sets ?P"
hoelzl@50003
   784
  with f g show "emeasure ?P A = emeasure ?D A"
hoelzl@50003
   785
    by (auto simp add: N.emeasure_pair_measure_alt space_pair_measure emeasure_distr
hoelzl@50003
   786
                       T.emeasure_pair_measure_alt positive_integral_distr
hoelzl@50003
   787
             intro!: positive_integral_cong arg_cong[where f="emeasure N"])
hoelzl@50003
   788
qed simp
hoelzl@39097
   789
hoelzl@40859
   790
end