src/HOL/Probability/Product_Measure.thy
author hoelzl
Tue Mar 22 20:06:10 2011 +0100 (2011-03-22)
changeset 42067 66c8281349ec
parent 41981 cdf7693bbe08
permissions -rw-r--r--
standardized headers
hoelzl@42067
     1
(*  Title:      HOL/Probability/Product_Measure.thy
hoelzl@42067
     2
    Author:     Johannes Hölzl, TU München
hoelzl@42067
     3
*)
hoelzl@42067
     4
hoelzl@42067
     5
header {*Product measure spaces*}
hoelzl@42067
     6
hoelzl@35833
     7
theory Product_Measure
hoelzl@38656
     8
imports Lebesgue_Integration
hoelzl@35833
     9
begin
hoelzl@35833
    10
hoelzl@41689
    11
lemma sigma_sets_subseteq: assumes "A \<subseteq> B" shows "sigma_sets X A \<subseteq> sigma_sets X B"
hoelzl@41689
    12
proof
hoelzl@41689
    13
  fix x assume "x \<in> sigma_sets X A" then show "x \<in> sigma_sets X B"
hoelzl@41689
    14
    by induct (insert `A \<subseteq> B`, auto intro: sigma_sets.intros)
hoelzl@41689
    15
qed
hoelzl@41689
    16
hoelzl@40859
    17
lemma times_Int_times: "A \<times> B \<inter> C \<times> D = (A \<inter> C) \<times> (B \<inter> D)"
hoelzl@40859
    18
  by auto
hoelzl@40859
    19
hoelzl@40859
    20
lemma Pair_vimage_times[simp]: "\<And>A B x. Pair x -` (A \<times> B) = (if x \<in> A then B else {})"
hoelzl@40859
    21
  by auto
hoelzl@40859
    22
hoelzl@40859
    23
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
    24
  by auto
hoelzl@40859
    25
hoelzl@40859
    26
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
    27
  by (cases x) simp
hoelzl@40859
    28
hoelzl@41026
    29
lemma split_beta': "(\<lambda>(x,y). f x y) = (\<lambda>x. f (fst x) (snd x))"
hoelzl@41026
    30
  by (auto simp: fun_eq_iff)
hoelzl@41026
    31
hoelzl@40859
    32
abbreviation
hoelzl@40859
    33
  "Pi\<^isub>E A B \<equiv> Pi A B \<inter> extensional A"
hellerar@39094
    34
hoelzl@41689
    35
syntax
hoelzl@41689
    36
  "_PiE"  :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3PIE _:_./ _)" 10)
hoelzl@41689
    37
hoelzl@41689
    38
syntax (xsymbols)
hoelzl@41689
    39
  "_PiE" :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3\<Pi>\<^isub>E _\<in>_./ _)"   10)
hoelzl@41689
    40
hoelzl@41689
    41
syntax (HTML output)
hoelzl@41689
    42
  "_PiE" :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3\<Pi>\<^isub>E _\<in>_./ _)"   10)
hoelzl@41689
    43
hoelzl@41689
    44
translations
hoelzl@41689
    45
  "PIE x:A. B" == "CONST Pi\<^isub>E A (%x. B)"
hoelzl@41689
    46
hoelzl@40859
    47
abbreviation
hoelzl@40859
    48
  funcset_extensional :: "['a set, 'b set] => ('a => 'b) set"
hoelzl@40859
    49
    (infixr "->\<^isub>E" 60) where
hoelzl@40859
    50
  "A ->\<^isub>E B \<equiv> Pi\<^isub>E A (%_. B)"
hoelzl@40859
    51
hoelzl@40859
    52
notation (xsymbols)
hoelzl@40859
    53
  funcset_extensional  (infixr "\<rightarrow>\<^isub>E" 60)
hoelzl@40859
    54
hoelzl@40859
    55
lemma extensional_empty[simp]: "extensional {} = {\<lambda>x. undefined}"
hoelzl@40859
    56
  by safe (auto simp add: extensional_def fun_eq_iff)
hoelzl@40859
    57
hoelzl@40859
    58
lemma extensional_insert[intro, simp]:
hoelzl@40859
    59
  assumes "a \<in> extensional (insert i I)"
hoelzl@40859
    60
  shows "a(i := b) \<in> extensional (insert i I)"
hoelzl@40859
    61
  using assms unfolding extensional_def by auto
hoelzl@40859
    62
hoelzl@40859
    63
lemma extensional_Int[simp]:
hoelzl@40859
    64
  "extensional I \<inter> extensional I' = extensional (I \<inter> I')"
hoelzl@40859
    65
  unfolding extensional_def by auto
hoelzl@38656
    66
hoelzl@35833
    67
definition
hoelzl@40859
    68
  "merge I x J y = (\<lambda>i. if i \<in> I then x i else if i \<in> J then y i else undefined)"
hoelzl@40859
    69
hoelzl@40859
    70
lemma merge_apply[simp]:
hoelzl@40859
    71
  "I \<inter> J = {} \<Longrightarrow> i \<in> I \<Longrightarrow> merge I x J y i = x i"
hoelzl@40859
    72
  "I \<inter> J = {} \<Longrightarrow> i \<in> J \<Longrightarrow> merge I x J y i = y i"
hoelzl@40859
    73
  "J \<inter> I = {} \<Longrightarrow> i \<in> I \<Longrightarrow> merge I x J y i = x i"
hoelzl@40859
    74
  "J \<inter> I = {} \<Longrightarrow> i \<in> J \<Longrightarrow> merge I x J y i = y i"
hoelzl@40859
    75
  "i \<notin> I \<Longrightarrow> i \<notin> J \<Longrightarrow> merge I x J y i = undefined"
hoelzl@40859
    76
  unfolding merge_def by auto
hoelzl@40859
    77
hoelzl@40859
    78
lemma merge_commute:
hoelzl@40859
    79
  "I \<inter> J = {} \<Longrightarrow> merge I x J y = merge J y I x"
hoelzl@40859
    80
  by (auto simp: merge_def intro!: ext)
hoelzl@40859
    81
hoelzl@40859
    82
lemma Pi_cancel_merge_range[simp]:
hoelzl@40859
    83
  "I \<inter> J = {} \<Longrightarrow> x \<in> Pi I (merge I A J B) \<longleftrightarrow> x \<in> Pi I A"
hoelzl@40859
    84
  "I \<inter> J = {} \<Longrightarrow> x \<in> Pi I (merge J B I A) \<longleftrightarrow> x \<in> Pi I A"
hoelzl@40859
    85
  "J \<inter> I = {} \<Longrightarrow> x \<in> Pi I (merge I A J B) \<longleftrightarrow> x \<in> Pi I A"
hoelzl@40859
    86
  "J \<inter> I = {} \<Longrightarrow> x \<in> Pi I (merge J B I A) \<longleftrightarrow> x \<in> Pi I A"
hoelzl@40859
    87
  by (auto simp: Pi_def)
hoelzl@40859
    88
hoelzl@40859
    89
lemma Pi_cancel_merge[simp]:
hoelzl@40859
    90
  "I \<inter> J = {} \<Longrightarrow> merge I x J y \<in> Pi I B \<longleftrightarrow> x \<in> Pi I B"
hoelzl@40859
    91
  "J \<inter> I = {} \<Longrightarrow> merge I x J y \<in> Pi I B \<longleftrightarrow> x \<in> Pi I B"
hoelzl@40859
    92
  "I \<inter> J = {} \<Longrightarrow> merge I x J y \<in> Pi J B \<longleftrightarrow> y \<in> Pi J B"
hoelzl@40859
    93
  "J \<inter> I = {} \<Longrightarrow> merge I x J y \<in> Pi J B \<longleftrightarrow> y \<in> Pi J B"
hoelzl@40859
    94
  by (auto simp: Pi_def)
hoelzl@40859
    95
hoelzl@40859
    96
lemma extensional_merge[simp]: "merge I x J y \<in> extensional (I \<union> J)"
hoelzl@40859
    97
  by (auto simp: extensional_def)
hoelzl@40859
    98
hoelzl@40859
    99
lemma restrict_Pi_cancel: "restrict x I \<in> Pi I A \<longleftrightarrow> x \<in> Pi I A"
hoelzl@40859
   100
  by (auto simp: restrict_def Pi_def)
hoelzl@40859
   101
hoelzl@40859
   102
lemma restrict_merge[simp]:
hoelzl@40859
   103
  "I \<inter> J = {} \<Longrightarrow> restrict (merge I x J y) I = restrict x I"
hoelzl@40859
   104
  "I \<inter> J = {} \<Longrightarrow> restrict (merge I x J y) J = restrict y J"
hoelzl@40859
   105
  "J \<inter> I = {} \<Longrightarrow> restrict (merge I x J y) I = restrict x I"
hoelzl@40859
   106
  "J \<inter> I = {} \<Longrightarrow> restrict (merge I x J y) J = restrict y J"
hoelzl@40859
   107
  by (auto simp: restrict_def intro!: ext)
hoelzl@40859
   108
hoelzl@40859
   109
lemma extensional_insert_undefined[intro, simp]:
hoelzl@40859
   110
  assumes "a \<in> extensional (insert i I)"
hoelzl@40859
   111
  shows "a(i := undefined) \<in> extensional I"
hoelzl@40859
   112
  using assms unfolding extensional_def by auto
hoelzl@40859
   113
hoelzl@40859
   114
lemma extensional_insert_cancel[intro, simp]:
hoelzl@40859
   115
  assumes "a \<in> extensional I"
hoelzl@40859
   116
  shows "a \<in> extensional (insert i I)"
hoelzl@40859
   117
  using assms unfolding extensional_def by auto
hoelzl@40859
   118
hoelzl@41095
   119
lemma merge_singleton[simp]: "i \<notin> I \<Longrightarrow> merge I x {i} y = restrict (x(i := y i)) (insert i I)"
hoelzl@41095
   120
  unfolding merge_def by (auto simp: fun_eq_iff)
hoelzl@41095
   121
hoelzl@41095
   122
lemma Pi_Int: "Pi I E \<inter> Pi I F = (\<Pi> i\<in>I. E i \<inter> F i)"
hoelzl@41095
   123
  by auto
hoelzl@41095
   124
hoelzl@40859
   125
lemma PiE_Int: "(Pi\<^isub>E I A) \<inter> (Pi\<^isub>E I B) = Pi\<^isub>E I (\<lambda>x. A x \<inter> B x)"
hoelzl@40859
   126
  by auto
hoelzl@40859
   127
hoelzl@40859
   128
lemma Pi_cancel_fupd_range[simp]: "i \<notin> I \<Longrightarrow> x \<in> Pi I (B(i := b)) \<longleftrightarrow> x \<in> Pi I B"
hoelzl@40859
   129
  by (auto simp: Pi_def)
hoelzl@40859
   130
hoelzl@40859
   131
lemma Pi_split_insert_domain[simp]: "x \<in> Pi (insert i I) X \<longleftrightarrow> x \<in> Pi I X \<and> x i \<in> X i"
hoelzl@40859
   132
  by (auto simp: Pi_def)
hoelzl@39088
   133
hoelzl@40859
   134
lemma Pi_split_domain[simp]: "x \<in> Pi (I \<union> J) X \<longleftrightarrow> x \<in> Pi I X \<and> x \<in> Pi J X"
hoelzl@40859
   135
  by (auto simp: Pi_def)
hoelzl@40859
   136
hoelzl@40859
   137
lemma Pi_cancel_fupd[simp]: "i \<notin> I \<Longrightarrow> x(i := a) \<in> Pi I B \<longleftrightarrow> x \<in> Pi I B"
hoelzl@40859
   138
  by (auto simp: Pi_def)
hoelzl@40859
   139
hoelzl@41095
   140
lemma restrict_vimage:
hoelzl@41095
   141
  assumes "I \<inter> J = {}"
hoelzl@41095
   142
  shows "(\<lambda>x. (restrict x I, restrict x J)) -` (Pi\<^isub>E I E \<times> Pi\<^isub>E J F) = Pi (I \<union> J) (merge I E J F)"
hoelzl@41095
   143
  using assms by (auto simp: restrict_Pi_cancel)
hoelzl@41095
   144
hoelzl@41095
   145
lemma merge_vimage:
hoelzl@41095
   146
  assumes "I \<inter> J = {}"
hoelzl@41095
   147
  shows "(\<lambda>(x,y). merge I x J y) -` Pi\<^isub>E (I \<union> J) E = Pi I E \<times> Pi J E"
hoelzl@41095
   148
  using assms by (auto simp: restrict_Pi_cancel)
hoelzl@41095
   149
hoelzl@41095
   150
lemma restrict_fupd[simp]: "i \<notin> I \<Longrightarrow> restrict (f (i := x)) I = restrict f I"
hoelzl@41095
   151
  by (auto simp: restrict_def intro!: ext)
hoelzl@41095
   152
hoelzl@41095
   153
lemma merge_restrict[simp]:
hoelzl@41095
   154
  "merge I (restrict x I) J y = merge I x J y"
hoelzl@41095
   155
  "merge I x J (restrict y J) = merge I x J y"
hoelzl@41095
   156
  unfolding merge_def by (auto intro!: ext)
hoelzl@41095
   157
hoelzl@41095
   158
lemma merge_x_x_eq_restrict[simp]:
hoelzl@41095
   159
  "merge I x J x = restrict x (I \<union> J)"
hoelzl@41095
   160
  unfolding merge_def by (auto intro!: ext)
hoelzl@41095
   161
hoelzl@41095
   162
lemma Pi_fupd_iff: "i \<in> I \<Longrightarrow> f \<in> Pi I (B(i := A)) \<longleftrightarrow> f \<in> Pi (I - {i}) B \<and> f i \<in> A"
hoelzl@41095
   163
  apply auto
hoelzl@41095
   164
  apply (drule_tac x=x in Pi_mem)
hoelzl@41095
   165
  apply (simp_all split: split_if_asm)
hoelzl@41095
   166
  apply (drule_tac x=i in Pi_mem)
hoelzl@41095
   167
  apply (auto dest!: Pi_mem)
hoelzl@41095
   168
  done
hoelzl@41095
   169
hoelzl@41095
   170
lemma Pi_UN:
hoelzl@41095
   171
  fixes A :: "nat \<Rightarrow> 'i \<Rightarrow> 'a set"
hoelzl@41095
   172
  assumes "finite I" and mono: "\<And>i n m. i \<in> I \<Longrightarrow> n \<le> m \<Longrightarrow> A n i \<subseteq> A m i"
hoelzl@41095
   173
  shows "(\<Union>n. Pi I (A n)) = (\<Pi> i\<in>I. \<Union>n. A n i)"
hoelzl@41095
   174
proof (intro set_eqI iffI)
hoelzl@41095
   175
  fix f assume "f \<in> (\<Pi> i\<in>I. \<Union>n. A n i)"
hoelzl@41095
   176
  then have "\<forall>i\<in>I. \<exists>n. f i \<in> A n i" by auto
hoelzl@41095
   177
  from bchoice[OF this] obtain n where n: "\<And>i. i \<in> I \<Longrightarrow> f i \<in> (A (n i) i)" by auto
hoelzl@41095
   178
  obtain k where k: "\<And>i. i \<in> I \<Longrightarrow> n i \<le> k"
hoelzl@41095
   179
    using `finite I` finite_nat_set_iff_bounded_le[of "n`I"] by auto
hoelzl@41095
   180
  have "f \<in> Pi I (A k)"
hoelzl@41095
   181
  proof (intro Pi_I)
hoelzl@41095
   182
    fix i assume "i \<in> I"
hoelzl@41095
   183
    from mono[OF this, of "n i" k] k[OF this] n[OF this]
hoelzl@41095
   184
    show "f i \<in> A k i" by auto
hoelzl@41095
   185
  qed
hoelzl@41095
   186
  then show "f \<in> (\<Union>n. Pi I (A n))" by auto
hoelzl@41095
   187
qed auto
hoelzl@41095
   188
hoelzl@41095
   189
lemma PiE_cong:
hoelzl@41095
   190
  assumes "\<And>i. i\<in>I \<Longrightarrow> A i = B i"
hoelzl@41095
   191
  shows "Pi\<^isub>E I A = Pi\<^isub>E I B"
hoelzl@41095
   192
  using assms by (auto intro!: Pi_cong)
hoelzl@41095
   193
hoelzl@41095
   194
lemma restrict_upd[simp]:
hoelzl@41095
   195
  "i \<notin> I \<Longrightarrow> (restrict f I)(i := y) = restrict (f(i := y)) (insert i I)"
hoelzl@41095
   196
  by (auto simp: fun_eq_iff)
hoelzl@41095
   197
hoelzl@41689
   198
lemma Pi_eq_subset:
hoelzl@41689
   199
  assumes ne: "\<And>i. i \<in> I \<Longrightarrow> F i \<noteq> {}" "\<And>i. i \<in> I \<Longrightarrow> F' i \<noteq> {}"
hoelzl@41689
   200
  assumes eq: "Pi\<^isub>E I F = Pi\<^isub>E I F'" and "i \<in> I"
hoelzl@41689
   201
  shows "F i \<subseteq> F' i"
hoelzl@41689
   202
proof
hoelzl@41689
   203
  fix x assume "x \<in> F i"
hoelzl@41689
   204
  with ne have "\<forall>j. \<exists>y. ((j \<in> I \<longrightarrow> y \<in> F j \<and> (i = j \<longrightarrow> x = y)) \<and> (j \<notin> I \<longrightarrow> y = undefined))" by auto
hoelzl@41689
   205
  from choice[OF this] guess f .. note f = this
hoelzl@41689
   206
  then have "f \<in> Pi\<^isub>E I F" by (auto simp: extensional_def)
hoelzl@41689
   207
  then have "f \<in> Pi\<^isub>E I F'" using assms by simp
hoelzl@41689
   208
  then show "x \<in> F' i" using f `i \<in> I` by auto
hoelzl@41689
   209
qed
hoelzl@41689
   210
hoelzl@41689
   211
lemma Pi_eq_iff_not_empty:
hoelzl@41689
   212
  assumes ne: "\<And>i. i \<in> I \<Longrightarrow> F i \<noteq> {}" "\<And>i. i \<in> I \<Longrightarrow> F' i \<noteq> {}"
hoelzl@41689
   213
  shows "Pi\<^isub>E I F = Pi\<^isub>E I F' \<longleftrightarrow> (\<forall>i\<in>I. F i = F' i)"
hoelzl@41689
   214
proof (intro iffI ballI)
hoelzl@41689
   215
  fix i assume eq: "Pi\<^isub>E I F = Pi\<^isub>E I F'" and i: "i \<in> I"
hoelzl@41689
   216
  show "F i = F' i"
hoelzl@41689
   217
    using Pi_eq_subset[of I F F', OF ne eq i]
hoelzl@41689
   218
    using Pi_eq_subset[of I F' F, OF ne(2,1) eq[symmetric] i]
hoelzl@41689
   219
    by auto
hoelzl@41689
   220
qed auto
hoelzl@41689
   221
hoelzl@41689
   222
lemma Pi_eq_empty_iff:
hoelzl@41689
   223
  "Pi\<^isub>E I F = {} \<longleftrightarrow> (\<exists>i\<in>I. F i = {})"
hoelzl@41689
   224
proof
hoelzl@41689
   225
  assume "Pi\<^isub>E I F = {}"
hoelzl@41689
   226
  show "\<exists>i\<in>I. F i = {}"
hoelzl@41689
   227
  proof (rule ccontr)
hoelzl@41689
   228
    assume "\<not> ?thesis"
hoelzl@41689
   229
    then have "\<forall>i. \<exists>y. (i \<in> I \<longrightarrow> y \<in> F i) \<and> (i \<notin> I \<longrightarrow> y = undefined)" by auto
hoelzl@41689
   230
    from choice[OF this] guess f ..
hoelzl@41689
   231
    then have "f \<in> Pi\<^isub>E I F" by (auto simp: extensional_def)
hoelzl@41689
   232
    with `Pi\<^isub>E I F = {}` show False by auto
hoelzl@41689
   233
  qed
hoelzl@41689
   234
qed auto
hoelzl@41689
   235
hoelzl@41689
   236
lemma Pi_eq_iff:
hoelzl@41689
   237
  "Pi\<^isub>E I F = Pi\<^isub>E I F' \<longleftrightarrow> (\<forall>i\<in>I. F i = F' i) \<or> ((\<exists>i\<in>I. F i = {}) \<and> (\<exists>i\<in>I. F' i = {}))"
hoelzl@41689
   238
proof (intro iffI disjCI)
hoelzl@41689
   239
  assume eq[simp]: "Pi\<^isub>E I F = Pi\<^isub>E I F'"
hoelzl@41689
   240
  assume "\<not> ((\<exists>i\<in>I. F i = {}) \<and> (\<exists>i\<in>I. F' i = {}))"
hoelzl@41689
   241
  then have "(\<forall>i\<in>I. F i \<noteq> {}) \<and> (\<forall>i\<in>I. F' i \<noteq> {})"
hoelzl@41689
   242
    using Pi_eq_empty_iff[of I F] Pi_eq_empty_iff[of I F'] by auto
hoelzl@41689
   243
  with Pi_eq_iff_not_empty[of I F F'] show "\<forall>i\<in>I. F i = F' i" by auto
hoelzl@41689
   244
next
hoelzl@41689
   245
  assume "(\<forall>i\<in>I. F i = F' i) \<or> (\<exists>i\<in>I. F i = {}) \<and> (\<exists>i\<in>I. F' i = {})"
hoelzl@41689
   246
  then show "Pi\<^isub>E I F = Pi\<^isub>E I F'"
hoelzl@41689
   247
    using Pi_eq_empty_iff[of I F] Pi_eq_empty_iff[of I F'] by auto
hoelzl@41689
   248
qed
hoelzl@41689
   249
hoelzl@40859
   250
section "Binary products"
hoelzl@40859
   251
hoelzl@40859
   252
definition
hoelzl@41689
   253
  "pair_measure_generator A B =
hoelzl@41689
   254
    \<lparr> space = space A \<times> space B,
hoelzl@41689
   255
      sets = {a \<times> b | a b. a \<in> sets A \<and> b \<in> sets B},
hoelzl@41689
   256
      measure = \<lambda>X. \<integral>\<^isup>+x. (\<integral>\<^isup>+y. indicator X (x,y) \<partial>B) \<partial>A \<rparr>"
hoelzl@41689
   257
hoelzl@41689
   258
definition pair_measure (infixr "\<Otimes>\<^isub>M" 80) where
hoelzl@41689
   259
  "A \<Otimes>\<^isub>M B = sigma (pair_measure_generator A B)"
hoelzl@40859
   260
hoelzl@40859
   261
locale pair_sigma_algebra = M1: sigma_algebra M1 + M2: sigma_algebra M2
hoelzl@41689
   262
  for M1 :: "('a, 'c) measure_space_scheme" and M2 :: "('b, 'd) measure_space_scheme"
hoelzl@41689
   263
hoelzl@41689
   264
abbreviation (in pair_sigma_algebra)
hoelzl@41689
   265
  "E \<equiv> pair_measure_generator M1 M2"
hoelzl@40859
   266
hoelzl@40859
   267
abbreviation (in pair_sigma_algebra)
hoelzl@41689
   268
  "P \<equiv> M1 \<Otimes>\<^isub>M M2"
hoelzl@40859
   269
hoelzl@41689
   270
lemma sigma_algebra_pair_measure:
hoelzl@41689
   271
  "sets M1 \<subseteq> Pow (space M1) \<Longrightarrow> sets M2 \<subseteq> Pow (space M2) \<Longrightarrow> sigma_algebra (pair_measure M1 M2)"
hoelzl@41689
   272
  by (force simp: pair_measure_def pair_measure_generator_def intro!: sigma_algebra_sigma)
hoelzl@40859
   273
hoelzl@40859
   274
sublocale pair_sigma_algebra \<subseteq> sigma_algebra P
hoelzl@41689
   275
  using M1.space_closed M2.space_closed
hoelzl@41689
   276
  by (rule sigma_algebra_pair_measure)
hoelzl@40859
   277
hoelzl@41689
   278
lemma pair_measure_generatorI[intro, simp]:
hoelzl@41689
   279
  "x \<in> sets A \<Longrightarrow> y \<in> sets B \<Longrightarrow> x \<times> y \<in> sets (pair_measure_generator A B)"
hoelzl@41689
   280
  by (auto simp add: pair_measure_generator_def)
hoelzl@40859
   281
hoelzl@41689
   282
lemma pair_measureI[intro, simp]:
hoelzl@41689
   283
  "x \<in> sets A \<Longrightarrow> y \<in> sets B \<Longrightarrow> x \<times> y \<in> sets (A \<Otimes>\<^isub>M B)"
hoelzl@41689
   284
  by (auto simp add: pair_measure_def)
hoelzl@40859
   285
hoelzl@41689
   286
lemma space_pair_measure:
hoelzl@41689
   287
  "space (A \<Otimes>\<^isub>M B) = space A \<times> space B"
hoelzl@41689
   288
  by (simp add: pair_measure_def pair_measure_generator_def)
hoelzl@41095
   289
hoelzl@41689
   290
lemma sets_pair_measure_generator:
hoelzl@41689
   291
  "sets (pair_measure_generator N M) = (\<lambda>(x, y). x \<times> y) ` (sets N \<times> sets M)"
hoelzl@41689
   292
  unfolding pair_measure_generator_def by auto
hoelzl@41095
   293
hoelzl@41689
   294
lemma pair_measure_generator_sets_into_space:
hoelzl@41689
   295
  assumes "sets M \<subseteq> Pow (space M)" "sets N \<subseteq> Pow (space N)"
hoelzl@41689
   296
  shows "sets (pair_measure_generator M N) \<subseteq> Pow (space (pair_measure_generator M N))"
hoelzl@41689
   297
  using assms by (auto simp: pair_measure_generator_def)
hoelzl@41689
   298
hoelzl@41689
   299
lemma pair_measure_generator_Int_snd:
hoelzl@40859
   300
  assumes "sets S1 \<subseteq> Pow (space S1)"
hoelzl@41689
   301
  shows "sets (pair_measure_generator S1 (algebra.restricted_space S2 A)) =
hoelzl@41689
   302
         sets (algebra.restricted_space (pair_measure_generator S1 S2) (space S1 \<times> A))"
hoelzl@40859
   303
  (is "?L = ?R")
hoelzl@41689
   304
  apply (auto simp: pair_measure_generator_def image_iff)
hoelzl@41689
   305
  using assms
hoelzl@41689
   306
  apply (rule_tac x="a \<times> xa" in exI)
hoelzl@41689
   307
  apply force
hoelzl@41689
   308
  using assms
hoelzl@41689
   309
  apply (rule_tac x="a" in exI)
hoelzl@41689
   310
  apply (rule_tac x="b \<inter> A" in exI)
hoelzl@41689
   311
  apply auto
hoelzl@41689
   312
  done
hoelzl@40859
   313
hoelzl@40859
   314
lemma (in pair_sigma_algebra)
hoelzl@40859
   315
  shows measurable_fst[intro!, simp]:
hoelzl@40859
   316
    "fst \<in> measurable P M1" (is ?fst)
hoelzl@40859
   317
  and measurable_snd[intro!, simp]:
hoelzl@40859
   318
    "snd \<in> measurable P M2" (is ?snd)
hoelzl@39088
   319
proof -
hoelzl@39088
   320
  { fix X assume "X \<in> sets M1"
hoelzl@39088
   321
    then have "\<exists>X1\<in>sets M1. \<exists>X2\<in>sets M2. fst -` X \<inter> space M1 \<times> space M2 = X1 \<times> X2"
hoelzl@39088
   322
      apply - apply (rule bexI[of _ X]) apply (rule bexI[of _ "space M2"])
hoelzl@39088
   323
      using M1.sets_into_space by force+ }
hoelzl@39088
   324
  moreover
hoelzl@39088
   325
  { fix X assume "X \<in> sets M2"
hoelzl@39088
   326
    then have "\<exists>X1\<in>sets M1. \<exists>X2\<in>sets M2. snd -` X \<inter> space M1 \<times> space M2 = X1 \<times> X2"
hoelzl@39088
   327
      apply - apply (rule bexI[of _ "space M1"]) apply (rule bexI[of _ X])
hoelzl@39088
   328
      using M2.sets_into_space by force+ }
hoelzl@40859
   329
  ultimately have "?fst \<and> ?snd"
hoelzl@41689
   330
    by (fastsimp simp: measurable_def sets_sigma space_pair_measure
hoelzl@40859
   331
                 intro!: sigma_sets.Basic)
hoelzl@40859
   332
  then show ?fst ?snd by auto
hoelzl@40859
   333
qed
hoelzl@40859
   334
hoelzl@41095
   335
lemma (in pair_sigma_algebra) measurable_pair_iff:
hoelzl@40859
   336
  assumes "sigma_algebra M"
hoelzl@40859
   337
  shows "f \<in> measurable M P \<longleftrightarrow>
hoelzl@40859
   338
    (fst \<circ> f) \<in> measurable M M1 \<and> (snd \<circ> f) \<in> measurable M M2"
hoelzl@40859
   339
proof -
hoelzl@40859
   340
  interpret M: sigma_algebra M by fact
hoelzl@40859
   341
  from assms show ?thesis
hoelzl@40859
   342
  proof (safe intro!: measurable_comp[where b=P])
hoelzl@40859
   343
    assume f: "(fst \<circ> f) \<in> measurable M M1" and s: "(snd \<circ> f) \<in> measurable M M2"
hoelzl@41689
   344
    show "f \<in> measurable M P" unfolding pair_measure_def
hoelzl@40859
   345
    proof (rule M.measurable_sigma)
hoelzl@41689
   346
      show "sets (pair_measure_generator M1 M2) \<subseteq> Pow (space E)"
hoelzl@41689
   347
        unfolding pair_measure_generator_def using M1.sets_into_space M2.sets_into_space by auto
hoelzl@40859
   348
      show "f \<in> space M \<rightarrow> space E"
hoelzl@41689
   349
        using f s by (auto simp: mem_Times_iff measurable_def comp_def space_sigma pair_measure_generator_def)
hoelzl@40859
   350
      fix A assume "A \<in> sets E"
hoelzl@40859
   351
      then obtain B C where "B \<in> sets M1" "C \<in> sets M2" "A = B \<times> C"
hoelzl@41689
   352
        unfolding pair_measure_generator_def by auto
hoelzl@40859
   353
      moreover have "(fst \<circ> f) -` B \<inter> space M \<in> sets M"
hoelzl@40859
   354
        using f `B \<in> sets M1` unfolding measurable_def by auto
hoelzl@40859
   355
      moreover have "(snd \<circ> f) -` C \<inter> space M \<in> sets M"
hoelzl@40859
   356
        using s `C \<in> sets M2` unfolding measurable_def by auto
hoelzl@40859
   357
      moreover have "f -` A \<inter> space M = ((fst \<circ> f) -` B \<inter> space M) \<inter> ((snd \<circ> f) -` C \<inter> space M)"
hoelzl@40859
   358
        unfolding `A = B \<times> C` by (auto simp: vimage_Times)
hoelzl@40859
   359
      ultimately show "f -` A \<inter> space M \<in> sets M" by auto
hoelzl@40859
   360
    qed
hoelzl@40859
   361
  qed
hoelzl@40859
   362
qed
hoelzl@40859
   363
hoelzl@41095
   364
lemma (in pair_sigma_algebra) measurable_pair:
hoelzl@40859
   365
  assumes "sigma_algebra M"
hoelzl@41095
   366
  assumes "(fst \<circ> f) \<in> measurable M M1" "(snd \<circ> f) \<in> measurable M M2"
hoelzl@40859
   367
  shows "f \<in> measurable M P"
hoelzl@41095
   368
  unfolding measurable_pair_iff[OF assms(1)] using assms(2,3) by simp
hoelzl@40859
   369
hoelzl@41689
   370
lemma pair_measure_generatorE:
hoelzl@41689
   371
  assumes "X \<in> sets (pair_measure_generator M1 M2)"
hoelzl@40859
   372
  obtains A B where "X = A \<times> B" "A \<in> sets M1" "B \<in> sets M2"
hoelzl@41689
   373
  using assms unfolding pair_measure_generator_def by auto
hoelzl@40859
   374
hoelzl@41689
   375
lemma (in pair_sigma_algebra) pair_measure_generator_swap:
hoelzl@41689
   376
  "(\<lambda>X. (\<lambda>(x,y). (y,x)) -` X \<inter> space M2 \<times> space M1) ` sets E = sets (pair_measure_generator M2 M1)"
hoelzl@41689
   377
proof (safe elim!: pair_measure_generatorE)
hoelzl@40859
   378
  fix A B assume "A \<in> sets M1" "B \<in> sets M2"
hoelzl@40859
   379
  moreover then have "(\<lambda>(x, y). (y, x)) -` (A \<times> B) \<inter> space M2 \<times> space M1 = B \<times> A"
hoelzl@40859
   380
    using M1.sets_into_space M2.sets_into_space by auto
hoelzl@41689
   381
  ultimately show "(\<lambda>(x, y). (y, x)) -` (A \<times> B) \<inter> space M2 \<times> space M1 \<in> sets (pair_measure_generator M2 M1)"
hoelzl@41689
   382
    by (auto intro: pair_measure_generatorI)
hoelzl@40859
   383
next
hoelzl@40859
   384
  fix A B assume "A \<in> sets M1" "B \<in> sets M2"
hoelzl@40859
   385
  then show "B \<times> A \<in> (\<lambda>X. (\<lambda>(x, y). (y, x)) -` X \<inter> space M2 \<times> space M1) ` sets E"
hoelzl@40859
   386
    using M1.sets_into_space M2.sets_into_space
hoelzl@41689
   387
    by (auto intro!: image_eqI[where x="A \<times> B"] pair_measure_generatorI)
hoelzl@40859
   388
qed
hoelzl@40859
   389
hoelzl@40859
   390
lemma (in pair_sigma_algebra) sets_pair_sigma_algebra_swap:
hoelzl@40859
   391
  assumes Q: "Q \<in> sets P"
hoelzl@41689
   392
  shows "(\<lambda>(x,y). (y, x)) -` Q \<in> sets (M2 \<Otimes>\<^isub>M M1)" (is "_ \<in> sets ?Q")
hoelzl@40859
   393
proof -
hoelzl@41689
   394
  let "?f Q" = "(\<lambda>(x,y). (y, x)) -` Q \<inter> space M2 \<times> space M1"
hoelzl@41689
   395
  have *: "(\<lambda>(x,y). (y, x)) -` Q = ?f Q"
hoelzl@41689
   396
    using sets_into_space[OF Q] by (auto simp: space_pair_measure)
hoelzl@41689
   397
  have "sets (M2 \<Otimes>\<^isub>M M1) = sets (sigma (pair_measure_generator M2 M1))"
hoelzl@41689
   398
    unfolding pair_measure_def ..
hoelzl@41689
   399
  also have "\<dots> = sigma_sets (space M2 \<times> space M1) (?f ` sets E)"
hoelzl@41689
   400
    unfolding sigma_def pair_measure_generator_swap[symmetric]
hoelzl@41689
   401
    by (simp add: pair_measure_generator_def)
hoelzl@41689
   402
  also have "\<dots> = ?f ` sigma_sets (space M1 \<times> space M2) (sets E)"
hoelzl@41689
   403
    using M1.sets_into_space M2.sets_into_space
hoelzl@41689
   404
    by (intro sigma_sets_vimage) (auto simp: pair_measure_generator_def)
hoelzl@41689
   405
  also have "\<dots> = ?f ` sets P"
hoelzl@41689
   406
    unfolding pair_measure_def pair_measure_generator_def sigma_def by simp
hoelzl@41689
   407
  finally show ?thesis
hoelzl@41689
   408
    using Q by (subst *) auto
hoelzl@40859
   409
qed
hoelzl@40859
   410
hoelzl@40859
   411
lemma (in pair_sigma_algebra) pair_sigma_algebra_swap_measurable:
hoelzl@41689
   412
  shows "(\<lambda>(x,y). (y, x)) \<in> measurable P (M2 \<Otimes>\<^isub>M M1)"
hoelzl@40859
   413
    (is "?f \<in> measurable ?P ?Q")
hoelzl@40859
   414
  unfolding measurable_def
hoelzl@40859
   415
proof (intro CollectI conjI Pi_I ballI)
hoelzl@40859
   416
  fix x assume "x \<in> space ?P" then show "(case x of (x, y) \<Rightarrow> (y, x)) \<in> space ?Q"
hoelzl@41689
   417
    unfolding pair_measure_generator_def pair_measure_def by auto
hoelzl@40859
   418
next
hoelzl@41689
   419
  fix A assume "A \<in> sets (M2 \<Otimes>\<^isub>M M1)"
hoelzl@40859
   420
  interpret Q: pair_sigma_algebra M2 M1 by default
hoelzl@41689
   421
  with Q.sets_pair_sigma_algebra_swap[OF `A \<in> sets (M2 \<Otimes>\<^isub>M M1)`]
hoelzl@40859
   422
  show "?f -` A \<inter> space ?P \<in> sets ?P" by simp
hoelzl@40859
   423
qed
hoelzl@40859
   424
hoelzl@41981
   425
lemma (in pair_sigma_algebra) measurable_cut_fst[simp,intro]:
hoelzl@40859
   426
  assumes "Q \<in> sets P" shows "Pair x -` Q \<in> sets M2"
hoelzl@40859
   427
proof -
hoelzl@40859
   428
  let ?Q' = "{Q. Q \<subseteq> space P \<and> Pair x -` Q \<in> sets M2}"
hoelzl@40859
   429
  let ?Q = "\<lparr> space = space P, sets = ?Q' \<rparr>"
hoelzl@40859
   430
  interpret Q: sigma_algebra ?Q
hoelzl@41689
   431
    proof qed (auto simp: vimage_UN vimage_Diff space_pair_measure)
hoelzl@40859
   432
  have "sets E \<subseteq> sets ?Q"
hoelzl@40859
   433
    using M1.sets_into_space M2.sets_into_space
hoelzl@41689
   434
    by (auto simp: pair_measure_generator_def space_pair_measure)
hoelzl@40859
   435
  then have "sets P \<subseteq> sets ?Q"
hoelzl@41689
   436
    apply (subst pair_measure_def, intro Q.sets_sigma_subset)
hoelzl@41689
   437
    by (simp add: pair_measure_def)
hoelzl@40859
   438
  with assms show ?thesis by auto
hoelzl@40859
   439
qed
hoelzl@40859
   440
hoelzl@40859
   441
lemma (in pair_sigma_algebra) measurable_cut_snd:
hoelzl@40859
   442
  assumes Q: "Q \<in> sets P" shows "(\<lambda>x. (x, y)) -` Q \<in> sets M1" (is "?cut Q \<in> sets M1")
hoelzl@40859
   443
proof -
hoelzl@40859
   444
  interpret Q: pair_sigma_algebra M2 M1 by default
hoelzl@40859
   445
  with Q.measurable_cut_fst[OF sets_pair_sigma_algebra_swap[OF Q], of y]
hoelzl@41689
   446
  show ?thesis by (simp add: vimage_compose[symmetric] comp_def)
hoelzl@40859
   447
qed
hoelzl@40859
   448
hoelzl@40859
   449
lemma (in pair_sigma_algebra) measurable_pair_image_snd:
hoelzl@40859
   450
  assumes m: "f \<in> measurable P M" and "x \<in> space M1"
hoelzl@40859
   451
  shows "(\<lambda>y. f (x, y)) \<in> measurable M2 M"
hoelzl@40859
   452
  unfolding measurable_def
hoelzl@40859
   453
proof (intro CollectI conjI Pi_I ballI)
hoelzl@40859
   454
  fix y assume "y \<in> space M2" with `f \<in> measurable P M` `x \<in> space M1`
hoelzl@41689
   455
  show "f (x, y) \<in> space M"
hoelzl@41689
   456
    unfolding measurable_def pair_measure_generator_def pair_measure_def by auto
hoelzl@40859
   457
next
hoelzl@40859
   458
  fix A assume "A \<in> sets M"
hoelzl@40859
   459
  then have "Pair x -` (f -` A \<inter> space P) \<in> sets M2" (is "?C \<in> _")
hoelzl@40859
   460
    using `f \<in> measurable P M`
hoelzl@40859
   461
    by (intro measurable_cut_fst) (auto simp: measurable_def)
hoelzl@40859
   462
  also have "?C = (\<lambda>y. f (x, y)) -` A \<inter> space M2"
hoelzl@41689
   463
    using `x \<in> space M1` by (auto simp: pair_measure_generator_def pair_measure_def)
hoelzl@40859
   464
  finally show "(\<lambda>y. f (x, y)) -` A \<inter> space M2 \<in> sets M2" .
hoelzl@40859
   465
qed
hoelzl@40859
   466
hoelzl@40859
   467
lemma (in pair_sigma_algebra) measurable_pair_image_fst:
hoelzl@40859
   468
  assumes m: "f \<in> measurable P M" and "y \<in> space M2"
hoelzl@40859
   469
  shows "(\<lambda>x. f (x, y)) \<in> measurable M1 M"
hoelzl@40859
   470
proof -
hoelzl@40859
   471
  interpret Q: pair_sigma_algebra M2 M1 by default
hoelzl@40859
   472
  from Q.measurable_pair_image_snd[OF measurable_comp `y \<in> space M2`,
hoelzl@40859
   473
                                      OF Q.pair_sigma_algebra_swap_measurable m]
hoelzl@40859
   474
  show ?thesis by simp
hoelzl@40859
   475
qed
hoelzl@40859
   476
hoelzl@41689
   477
lemma (in pair_sigma_algebra) Int_stable_pair_measure_generator: "Int_stable E"
hoelzl@40859
   478
  unfolding Int_stable_def
hoelzl@40859
   479
proof (intro ballI)
hoelzl@40859
   480
  fix A B assume "A \<in> sets E" "B \<in> sets E"
hoelzl@40859
   481
  then obtain A1 A2 B1 B2 where "A = A1 \<times> A2" "B = B1 \<times> B2"
hoelzl@40859
   482
    "A1 \<in> sets M1" "A2 \<in> sets M2" "B1 \<in> sets M1" "B2 \<in> sets M2"
hoelzl@41689
   483
    unfolding pair_measure_generator_def by auto
hoelzl@40859
   484
  then show "A \<inter> B \<in> sets E"
hoelzl@41689
   485
    by (auto simp add: times_Int_times pair_measure_generator_def)
hoelzl@40859
   486
qed
hoelzl@40859
   487
hoelzl@40859
   488
lemma finite_measure_cut_measurable:
hoelzl@41689
   489
  fixes M1 :: "('a, 'c) measure_space_scheme" and M2 :: "('b, 'd) measure_space_scheme"
hoelzl@41689
   490
  assumes "sigma_finite_measure M1" "finite_measure M2"
hoelzl@41689
   491
  assumes "Q \<in> sets (M1 \<Otimes>\<^isub>M M2)"
hoelzl@41689
   492
  shows "(\<lambda>x. measure M2 (Pair x -` Q)) \<in> borel_measurable M1"
hoelzl@40859
   493
    (is "?s Q \<in> _")
hoelzl@40859
   494
proof -
hoelzl@41689
   495
  interpret M1: sigma_finite_measure M1 by fact
hoelzl@41689
   496
  interpret M2: finite_measure M2 by fact
hoelzl@40859
   497
  interpret pair_sigma_algebra M1 M2 by default
hoelzl@40859
   498
  have [intro]: "sigma_algebra M1" by fact
hoelzl@40859
   499
  have [intro]: "sigma_algebra M2" by fact
hoelzl@40859
   500
  let ?D = "\<lparr> space = space P, sets = {A\<in>sets P. ?s A \<in> borel_measurable M1}  \<rparr>"
hoelzl@41689
   501
  note space_pair_measure[simp]
hoelzl@40859
   502
  interpret dynkin_system ?D
hoelzl@40859
   503
  proof (intro dynkin_systemI)
hoelzl@40859
   504
    fix A assume "A \<in> sets ?D" then show "A \<subseteq> space ?D"
hoelzl@40859
   505
      using sets_into_space by simp
hoelzl@40859
   506
  next
hoelzl@40859
   507
    from top show "space ?D \<in> sets ?D"
hoelzl@40859
   508
      by (auto simp add: if_distrib intro!: M1.measurable_If)
hoelzl@40859
   509
  next
hoelzl@40859
   510
    fix A assume "A \<in> sets ?D"
hoelzl@41689
   511
    with sets_into_space have "\<And>x. measure M2 (Pair x -` (space M1 \<times> space M2 - A)) =
hoelzl@41689
   512
        (if x \<in> space M1 then measure M2 (space M2) - ?s A x else 0)"
hoelzl@41981
   513
      by (auto intro!: M2.measure_compl simp: vimage_Diff)
hoelzl@40859
   514
    with `A \<in> sets ?D` top show "space ?D - A \<in> sets ?D"
hoelzl@41981
   515
      by (auto intro!: Diff M1.measurable_If M1.borel_measurable_extreal_diff)
hoelzl@40859
   516
  next
hoelzl@40859
   517
    fix F :: "nat \<Rightarrow> ('a\<times>'b) set" assume "disjoint_family F" "range F \<subseteq> sets ?D"
hoelzl@41981
   518
    moreover then have "\<And>x. measure M2 (\<Union>i. Pair x -` F i) = (\<Sum>i. ?s (F i) x)"
hoelzl@40859
   519
      by (intro M2.measure_countably_additive[symmetric])
hoelzl@41981
   520
         (auto simp: disjoint_family_on_def)
hoelzl@40859
   521
    ultimately show "(\<Union>i. F i) \<in> sets ?D"
hoelzl@40859
   522
      by (auto simp: vimage_UN intro!: M1.borel_measurable_psuminf)
hoelzl@40859
   523
  qed
hoelzl@41689
   524
  have "sets P = sets ?D" apply (subst pair_measure_def)
hoelzl@40859
   525
  proof (intro dynkin_lemma)
hoelzl@41689
   526
    show "Int_stable E" by (rule Int_stable_pair_measure_generator)
hoelzl@40859
   527
    from M1.sets_into_space have "\<And>A. A \<in> sets M1 \<Longrightarrow> {x \<in> space M1. x \<in> A} = A"
hoelzl@40859
   528
      by auto
hoelzl@40859
   529
    then show "sets E \<subseteq> sets ?D"
hoelzl@41689
   530
      by (auto simp: pair_measure_generator_def sets_sigma if_distrib
hoelzl@40859
   531
               intro: sigma_sets.Basic intro!: M1.measurable_If)
hoelzl@41689
   532
  qed (auto simp: pair_measure_def)
hoelzl@40859
   533
  with `Q \<in> sets P` have "Q \<in> sets ?D" by simp
hoelzl@40859
   534
  then show "?s Q \<in> borel_measurable M1" by simp
hoelzl@40859
   535
qed
hoelzl@40859
   536
hoelzl@40859
   537
subsection {* Binary products of $\sigma$-finite measure spaces *}
hoelzl@40859
   538
hoelzl@41689
   539
locale pair_sigma_finite = M1: sigma_finite_measure M1 + M2: sigma_finite_measure M2
hoelzl@41689
   540
  for M1 :: "('a, 'c) measure_space_scheme" and M2 :: "('b, 'd) measure_space_scheme"
hoelzl@40859
   541
hoelzl@40859
   542
sublocale pair_sigma_finite \<subseteq> pair_sigma_algebra M1 M2
hoelzl@40859
   543
  by default
hoelzl@40859
   544
hoelzl@41689
   545
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@41689
   546
  by auto
hoelzl@41689
   547
hoelzl@40859
   548
lemma (in pair_sigma_finite) measure_cut_measurable_fst:
hoelzl@41689
   549
  assumes "Q \<in> sets P" shows "(\<lambda>x. measure M2 (Pair x -` Q)) \<in> borel_measurable M1" (is "?s Q \<in> _")
hoelzl@40859
   550
proof -
hoelzl@40859
   551
  have [intro]: "sigma_algebra M1" and [intro]: "sigma_algebra M2" by default+
hoelzl@41689
   552
  have M1: "sigma_finite_measure M1" by default
hoelzl@40859
   553
  from M2.disjoint_sigma_finite guess F .. note F = this
hoelzl@41981
   554
  then have F_sets: "\<And>i. F i \<in> sets M2" by auto
hoelzl@40859
   555
  let "?C x i" = "F i \<inter> Pair x -` Q"
hoelzl@40859
   556
  { fix i
hoelzl@40859
   557
    let ?R = "M2.restricted_space (F i)"
hoelzl@40859
   558
    have [simp]: "space M1 \<times> F i \<inter> space M1 \<times> space M2 = space M1 \<times> F i"
hoelzl@40859
   559
      using F M2.sets_into_space by auto
hoelzl@41689
   560
    let ?R2 = "M2.restricted_space (F i)"
hoelzl@41689
   561
    have "(\<lambda>x. measure ?R2 (Pair x -` (space M1 \<times> space ?R2 \<inter> Q))) \<in> borel_measurable M1"
hoelzl@40859
   562
    proof (intro finite_measure_cut_measurable[OF M1])
hoelzl@41689
   563
      show "finite_measure ?R2"
hoelzl@40859
   564
        using F by (intro M2.restricted_to_finite_measure) auto
hoelzl@41689
   565
      have "(space M1 \<times> space ?R2) \<inter> Q \<in> (op \<inter> (space M1 \<times> F i)) ` sets P"
hoelzl@41689
   566
        using `Q \<in> sets P` by (auto simp: image_iff)
hoelzl@41689
   567
      also have "\<dots> = sigma_sets (space M1 \<times> F i) ((op \<inter> (space M1 \<times> F i)) ` sets E)"
hoelzl@41689
   568
        unfolding pair_measure_def pair_measure_generator_def sigma_def
hoelzl@41689
   569
        using `F i \<in> sets M2` M2.sets_into_space
hoelzl@41689
   570
        by (auto intro!: sigma_sets_Int sigma_sets.Basic)
hoelzl@41689
   571
      also have "\<dots> \<subseteq> sets (M1 \<Otimes>\<^isub>M ?R2)"
hoelzl@41689
   572
        using M1.sets_into_space
hoelzl@41689
   573
        apply (auto simp: times_Int_times pair_measure_def pair_measure_generator_def sigma_def
hoelzl@41689
   574
                    intro!: sigma_sets_subseteq)
hoelzl@41689
   575
        apply (rule_tac x="a" in exI)
hoelzl@41689
   576
        apply (rule_tac x="b \<inter> F i" in exI)
hoelzl@41689
   577
        by auto
hoelzl@41689
   578
      finally show "(space M1 \<times> space ?R2) \<inter> Q \<in> sets (M1 \<Otimes>\<^isub>M ?R2)" .
hoelzl@40859
   579
    qed
hoelzl@40859
   580
    moreover have "\<And>x. Pair x -` (space M1 \<times> F i \<inter> Q) = ?C x i"
hoelzl@41689
   581
      using `Q \<in> sets P` sets_into_space by (auto simp: space_pair_measure)
hoelzl@41689
   582
    ultimately have "(\<lambda>x. measure M2 (?C x i)) \<in> borel_measurable M1"
hoelzl@40859
   583
      by simp }
hoelzl@40859
   584
  moreover
hoelzl@40859
   585
  { fix x
hoelzl@41981
   586
    have "(\<Sum>i. measure M2 (?C x i)) = measure M2 (\<Union>i. ?C x i)"
hoelzl@40859
   587
    proof (intro M2.measure_countably_additive)
hoelzl@40859
   588
      show "range (?C x) \<subseteq> sets M2"
hoelzl@41981
   589
        using F `Q \<in> sets P` by (auto intro!: M2.Int)
hoelzl@40859
   590
      have "disjoint_family F" using F by auto
hoelzl@40859
   591
      show "disjoint_family (?C x)"
hoelzl@40859
   592
        by (rule disjoint_family_on_bisimulation[OF `disjoint_family F`]) auto
hoelzl@40859
   593
    qed
hoelzl@40859
   594
    also have "(\<Union>i. ?C x i) = Pair x -` Q"
hoelzl@40859
   595
      using F sets_into_space `Q \<in> sets P`
hoelzl@41689
   596
      by (auto simp: space_pair_measure)
hoelzl@41981
   597
    finally have "measure M2 (Pair x -` Q) = (\<Sum>i. measure M2 (?C x i))"
hoelzl@40859
   598
      by simp }
hoelzl@41981
   599
  ultimately show ?thesis using `Q \<in> sets P` F_sets
hoelzl@41981
   600
    by (auto intro!: M1.borel_measurable_psuminf M2.Int)
hoelzl@40859
   601
qed
hoelzl@40859
   602
hoelzl@40859
   603
lemma (in pair_sigma_finite) measure_cut_measurable_snd:
hoelzl@41689
   604
  assumes "Q \<in> sets P" shows "(\<lambda>y. M1.\<mu> ((\<lambda>x. (x, y)) -` Q)) \<in> borel_measurable M2"
hoelzl@40859
   605
proof -
hoelzl@41689
   606
  interpret Q: pair_sigma_finite M2 M1 by default
hoelzl@40859
   607
  note sets_pair_sigma_algebra_swap[OF assms]
hoelzl@40859
   608
  from Q.measure_cut_measurable_fst[OF this]
hoelzl@41689
   609
  show ?thesis by (simp add: vimage_compose[symmetric] comp_def)
hoelzl@40859
   610
qed
hoelzl@40859
   611
hoelzl@40859
   612
lemma (in pair_sigma_algebra) pair_sigma_algebra_measurable:
hoelzl@41689
   613
  assumes "f \<in> measurable P M" shows "(\<lambda>(x,y). f (y, x)) \<in> measurable (M2 \<Otimes>\<^isub>M M1) M"
hoelzl@40859
   614
proof -
hoelzl@40859
   615
  interpret Q: pair_sigma_algebra M2 M1 by default
hoelzl@40859
   616
  have *: "(\<lambda>(x,y). f (y, x)) = f \<circ> (\<lambda>(x,y). (y, x))" by (simp add: fun_eq_iff)
hoelzl@40859
   617
  show ?thesis
hoelzl@40859
   618
    using Q.pair_sigma_algebra_swap_measurable assms
hoelzl@40859
   619
    unfolding * by (rule measurable_comp)
hoelzl@39088
   620
qed
hoelzl@39088
   621
hoelzl@40859
   622
lemma (in pair_sigma_finite) pair_measure_alt:
hoelzl@40859
   623
  assumes "A \<in> sets P"
hoelzl@41689
   624
  shows "measure (M1 \<Otimes>\<^isub>M M2) A = (\<integral>\<^isup>+ x. measure M2 (Pair x -` A) \<partial>M1)"
hoelzl@41689
   625
  apply (simp add: pair_measure_def pair_measure_generator_def)
hoelzl@40859
   626
proof (rule M1.positive_integral_cong)
hoelzl@40859
   627
  fix x assume "x \<in> space M1"
hoelzl@41981
   628
  have *: "\<And>y. indicator A (x, y) = (indicator (Pair x -` A) y :: extreal)"
hoelzl@40859
   629
    unfolding indicator_def by auto
hoelzl@41689
   630
  show "(\<integral>\<^isup>+ y. indicator A (x, y) \<partial>M2) = measure M2 (Pair x -` A)"
hoelzl@40859
   631
    unfolding *
hoelzl@40859
   632
    apply (subst M2.positive_integral_indicator)
hoelzl@40859
   633
    apply (rule measurable_cut_fst[OF assms])
hoelzl@40859
   634
    by simp
hoelzl@40859
   635
qed
hoelzl@40859
   636
hoelzl@40859
   637
lemma (in pair_sigma_finite) pair_measure_times:
hoelzl@40859
   638
  assumes A: "A \<in> sets M1" and "B \<in> sets M2"
hoelzl@41689
   639
  shows "measure (M1 \<Otimes>\<^isub>M M2) (A \<times> B) = M1.\<mu> A * measure M2 B"
hoelzl@40859
   640
proof -
hoelzl@41689
   641
  have "measure (M1 \<Otimes>\<^isub>M M2) (A \<times> B) = (\<integral>\<^isup>+ x. measure M2 B * indicator A x \<partial>M1)"
hoelzl@41689
   642
    using assms by (auto intro!: M1.positive_integral_cong simp: pair_measure_alt)
hoelzl@40859
   643
  with assms show ?thesis
hoelzl@40859
   644
    by (simp add: M1.positive_integral_cmult_indicator ac_simps)
hoelzl@40859
   645
qed
hoelzl@40859
   646
hoelzl@41981
   647
lemma (in measure_space) measure_not_negative[simp,intro]:
hoelzl@41981
   648
  assumes A: "A \<in> sets M" shows "\<mu> A \<noteq> - \<infinity>"
hoelzl@41981
   649
  using positive_measure[OF A] by auto
hoelzl@41981
   650
hoelzl@41689
   651
lemma (in pair_sigma_finite) sigma_finite_up_in_pair_measure_generator:
hoelzl@41981
   652
  "\<exists>F::nat \<Rightarrow> ('a \<times> 'b) set. range F \<subseteq> sets E \<and> incseq F \<and> (\<Union>i. F i) = space E \<and>
hoelzl@41981
   653
    (\<forall>i. measure (M1 \<Otimes>\<^isub>M M2) (F i) \<noteq> \<infinity>)"
hoelzl@40859
   654
proof -
hoelzl@40859
   655
  obtain F1 :: "nat \<Rightarrow> 'a set" and F2 :: "nat \<Rightarrow> 'b set" where
hoelzl@41981
   656
    F1: "range F1 \<subseteq> sets M1" "incseq F1" "(\<Union>i. F1 i) = space M1" "\<And>i. M1.\<mu> (F1 i) \<noteq> \<infinity>" and
hoelzl@41981
   657
    F2: "range F2 \<subseteq> sets M2" "incseq F2" "(\<Union>i. F2 i) = space M2" "\<And>i. M2.\<mu> (F2 i) \<noteq> \<infinity>"
hoelzl@40859
   658
    using M1.sigma_finite_up M2.sigma_finite_up by auto
hoelzl@41981
   659
  then have space: "space M1 = (\<Union>i. F1 i)" "space M2 = (\<Union>i. F2 i)" by auto
hoelzl@40859
   660
  let ?F = "\<lambda>i. F1 i \<times> F2 i"
hoelzl@41981
   661
  show ?thesis unfolding space_pair_measure
hoelzl@40859
   662
  proof (intro exI[of _ ?F] conjI allI)
hoelzl@40859
   663
    show "range ?F \<subseteq> sets E" using F1 F2
hoelzl@41689
   664
      by (fastsimp intro!: pair_measure_generatorI)
hoelzl@40859
   665
  next
hoelzl@40859
   666
    have "space M1 \<times> space M2 \<subseteq> (\<Union>i. ?F i)"
hoelzl@40859
   667
    proof (intro subsetI)
hoelzl@40859
   668
      fix x assume "x \<in> space M1 \<times> space M2"
hoelzl@40859
   669
      then obtain i j where "fst x \<in> F1 i" "snd x \<in> F2 j"
hoelzl@40859
   670
        by (auto simp: space)
hoelzl@40859
   671
      then have "fst x \<in> F1 (max i j)" "snd x \<in> F2 (max j i)"
hoelzl@41981
   672
        using `incseq F1` `incseq F2` unfolding incseq_def
hoelzl@41981
   673
        by (force split: split_max)+
hoelzl@40859
   674
      then have "(fst x, snd x) \<in> F1 (max i j) \<times> F2 (max i j)"
hoelzl@40859
   675
        by (intro SigmaI) (auto simp add: min_max.sup_commute)
hoelzl@40859
   676
      then show "x \<in> (\<Union>i. ?F i)" by auto
hoelzl@40859
   677
    qed
hoelzl@41689
   678
    then show "(\<Union>i. ?F i) = space E"
hoelzl@41689
   679
      using space by (auto simp: space pair_measure_generator_def)
hoelzl@40859
   680
  next
hoelzl@41981
   681
    fix i show "incseq (\<lambda>i. F1 i \<times> F2 i)"
hoelzl@41981
   682
      using `incseq F1` `incseq F2` unfolding incseq_Suc_iff by auto
hoelzl@40859
   683
  next
hoelzl@40859
   684
    fix i
hoelzl@40859
   685
    from F1 F2 have "F1 i \<in> sets M1" "F2 i \<in> sets M2" by auto
hoelzl@41981
   686
    with F1 F2 M1.positive_measure[OF this(1)] M2.positive_measure[OF this(2)]
hoelzl@41981
   687
    show "measure P (F1 i \<times> F2 i) \<noteq> \<infinity>"
hoelzl@40859
   688
      by (simp add: pair_measure_times)
hoelzl@40859
   689
  qed
hoelzl@40859
   690
qed
hoelzl@40859
   691
hoelzl@41689
   692
sublocale pair_sigma_finite \<subseteq> sigma_finite_measure P
hoelzl@40859
   693
proof
hoelzl@41981
   694
  show "positive P (measure P)"
hoelzl@41981
   695
    unfolding pair_measure_def pair_measure_generator_def sigma_def positive_def
hoelzl@41981
   696
    by (auto intro: M1.positive_integral_positive M2.positive_integral_positive)
hoelzl@40859
   697
hoelzl@41689
   698
  show "countably_additive P (measure P)"
hoelzl@40859
   699
    unfolding countably_additive_def
hoelzl@40859
   700
  proof (intro allI impI)
hoelzl@40859
   701
    fix F :: "nat \<Rightarrow> ('a \<times> 'b) set"
hoelzl@40859
   702
    assume F: "range F \<subseteq> sets P" "disjoint_family F"
hoelzl@40859
   703
    from F have *: "\<And>i. F i \<in> sets P" "(\<Union>i. F i) \<in> sets P" by auto
hoelzl@41689
   704
    moreover from F have "\<And>i. (\<lambda>x. measure M2 (Pair x -` F i)) \<in> borel_measurable M1"
hoelzl@40859
   705
      by (intro measure_cut_measurable_fst) auto
hoelzl@40859
   706
    moreover have "\<And>x. disjoint_family (\<lambda>i. Pair x -` F i)"
hoelzl@40859
   707
      by (intro disjoint_family_on_bisimulation[OF F(2)]) auto
hoelzl@40859
   708
    moreover have "\<And>x. x \<in> space M1 \<Longrightarrow> range (\<lambda>i. Pair x -` F i) \<subseteq> sets M2"
hoelzl@41981
   709
      using F by auto
hoelzl@41981
   710
    ultimately show "(\<Sum>n. measure P (F n)) = measure P (\<Union>i. F i)"
hoelzl@41981
   711
      by (simp add: pair_measure_alt vimage_UN M1.positive_integral_suminf[symmetric]
hoelzl@40859
   712
                    M2.measure_countably_additive
hoelzl@40859
   713
               cong: M1.positive_integral_cong)
hoelzl@40859
   714
  qed
hoelzl@40859
   715
hoelzl@41689
   716
  from sigma_finite_up_in_pair_measure_generator guess F :: "nat \<Rightarrow> ('a \<times> 'b) set" .. note F = this
hoelzl@41981
   717
  show "\<exists>F::nat \<Rightarrow> ('a \<times> 'b) set. range F \<subseteq> sets P \<and> (\<Union>i. F i) = space P \<and> (\<forall>i. measure P (F i) \<noteq> \<infinity>)"
hoelzl@40859
   718
  proof (rule exI[of _ F], intro conjI)
hoelzl@41689
   719
    show "range F \<subseteq> sets P" using F by (auto simp: pair_measure_def)
hoelzl@40859
   720
    show "(\<Union>i. F i) = space P"
hoelzl@41981
   721
      using F by (auto simp: pair_measure_def pair_measure_generator_def)
hoelzl@41981
   722
    show "\<forall>i. measure P (F i) \<noteq> \<infinity>" using F by auto
hoelzl@40859
   723
  qed
hoelzl@40859
   724
qed
hoelzl@39088
   725
hoelzl@41661
   726
lemma (in pair_sigma_algebra) sets_swap:
hoelzl@41661
   727
  assumes "A \<in> sets P"
hoelzl@41689
   728
  shows "(\<lambda>(x, y). (y, x)) -` A \<inter> space (M2 \<Otimes>\<^isub>M M1) \<in> sets (M2 \<Otimes>\<^isub>M M1)"
hoelzl@41661
   729
    (is "_ -` A \<inter> space ?Q \<in> sets ?Q")
hoelzl@41661
   730
proof -
hoelzl@41689
   731
  have *: "(\<lambda>(x, y). (y, x)) -` A \<inter> space ?Q = (\<lambda>(x, y). (y, x)) -` A"
hoelzl@41689
   732
    using `A \<in> sets P` sets_into_space by (auto simp: space_pair_measure)
hoelzl@41661
   733
  show ?thesis
hoelzl@41661
   734
    unfolding * using assms by (rule sets_pair_sigma_algebra_swap)
hoelzl@41661
   735
qed
hoelzl@41661
   736
hoelzl@40859
   737
lemma (in pair_sigma_finite) pair_measure_alt2:
hoelzl@41706
   738
  assumes A: "A \<in> sets P"
hoelzl@41689
   739
  shows "\<mu> A = (\<integral>\<^isup>+y. M1.\<mu> ((\<lambda>x. (x, y)) -` A) \<partial>M2)"
hoelzl@40859
   740
    (is "_ = ?\<nu> A")
hoelzl@40859
   741
proof -
hoelzl@41706
   742
  interpret Q: pair_sigma_finite M2 M1 by default
hoelzl@41689
   743
  from sigma_finite_up_in_pair_measure_generator guess F :: "nat \<Rightarrow> ('a \<times> 'b) set" .. note F = this
hoelzl@41689
   744
  have [simp]: "\<And>m. \<lparr> space = space E, sets = sets (sigma E), measure = m \<rparr> = P\<lparr> measure := m \<rparr>"
hoelzl@41689
   745
    unfolding pair_measure_def by simp
hoelzl@41706
   746
hoelzl@41706
   747
  have "\<mu> A = Q.\<mu> ((\<lambda>(y, x). (x, y)) -` A \<inter> space Q.P)"
hoelzl@41706
   748
  proof (rule measure_unique_Int_stable_vimage[OF Int_stable_pair_measure_generator])
hoelzl@41706
   749
    show "measure_space P" "measure_space Q.P" by default
hoelzl@41706
   750
    show "(\<lambda>(y, x). (x, y)) \<in> measurable Q.P P" by (rule Q.pair_sigma_algebra_swap_measurable)
hoelzl@41706
   751
    show "sets (sigma E) = sets P" "space E = space P" "A \<in> sets (sigma E)"
hoelzl@41706
   752
      using assms unfolding pair_measure_def by auto
hoelzl@41981
   753
    show "range F \<subseteq> sets E" "incseq F" "(\<Union>i. F i) = space E" "\<And>i. \<mu> (F i) \<noteq> \<infinity>"
hoelzl@41689
   754
      using F `A \<in> sets P` by (auto simp: pair_measure_def)
hoelzl@40859
   755
    fix X assume "X \<in> sets E"
hoelzl@41706
   756
    then obtain A B where X[simp]: "X = A \<times> B" and AB: "A \<in> sets M1" "B \<in> sets M2"
hoelzl@41689
   757
      unfolding pair_measure_def pair_measure_generator_def by auto
hoelzl@41706
   758
    then have "(\<lambda>(y, x). (x, y)) -` X \<inter> space Q.P = B \<times> A"
hoelzl@41706
   759
      using M1.sets_into_space M2.sets_into_space by (auto simp: space_pair_measure)
hoelzl@41706
   760
    then show "\<mu> X = Q.\<mu> ((\<lambda>(y, x). (x, y)) -` X \<inter> space Q.P)"
hoelzl@41706
   761
      using AB by (simp add: pair_measure_times Q.pair_measure_times ac_simps)
hoelzl@41689
   762
  qed
hoelzl@41706
   763
  then show ?thesis
hoelzl@41706
   764
    using sets_into_space[OF A] Q.pair_measure_alt[OF sets_swap[OF A]]
hoelzl@41706
   765
    by (auto simp add: Q.pair_measure_alt space_pair_measure
hoelzl@41706
   766
             intro!: M2.positive_integral_cong arg_cong[where f="M1.\<mu>"])
hoelzl@41689
   767
qed
hoelzl@41689
   768
hoelzl@41689
   769
lemma pair_sigma_algebra_sigma:
hoelzl@41981
   770
  assumes 1: "incseq S1" "(\<Union>i. S1 i) = space E1" "range S1 \<subseteq> sets E1" and E1: "sets E1 \<subseteq> Pow (space E1)"
hoelzl@41981
   771
  assumes 2: "decseq S2" "(\<Union>i. S2 i) = space E2" "range S2 \<subseteq> sets E2" and E2: "sets E2 \<subseteq> Pow (space E2)"
hoelzl@41689
   772
  shows "sets (sigma (pair_measure_generator (sigma E1) (sigma E2))) = sets (sigma (pair_measure_generator E1 E2))"
hoelzl@41689
   773
    (is "sets ?S = sets ?E")
hoelzl@41689
   774
proof -
hoelzl@41689
   775
  interpret M1: sigma_algebra "sigma E1" using E1 by (rule sigma_algebra_sigma)
hoelzl@41689
   776
  interpret M2: sigma_algebra "sigma E2" using E2 by (rule sigma_algebra_sigma)
hoelzl@41689
   777
  have P: "sets (pair_measure_generator E1 E2) \<subseteq> Pow (space E1 \<times> space E2)"
hoelzl@41689
   778
    using E1 E2 by (auto simp add: pair_measure_generator_def)
hoelzl@41689
   779
  interpret E: sigma_algebra ?E unfolding pair_measure_generator_def
hoelzl@41689
   780
    using E1 E2 by (intro sigma_algebra_sigma) auto
hoelzl@41689
   781
  { fix A assume "A \<in> sets E1"
hoelzl@41689
   782
    then have "fst -` A \<inter> space ?E = A \<times> (\<Union>i. S2 i)"
hoelzl@41981
   783
      using E1 2 unfolding pair_measure_generator_def by auto
hoelzl@41689
   784
    also have "\<dots> = (\<Union>i. A \<times> S2 i)" by auto
hoelzl@41689
   785
    also have "\<dots> \<in> sets ?E" unfolding pair_measure_generator_def sets_sigma
hoelzl@41689
   786
      using 2 `A \<in> sets E1`
hoelzl@41689
   787
      by (intro sigma_sets.Union)
hoelzl@41981
   788
         (force simp: image_subset_iff intro!: sigma_sets.Basic)
hoelzl@41689
   789
    finally have "fst -` A \<inter> space ?E \<in> sets ?E" . }
hoelzl@41689
   790
  moreover
hoelzl@41689
   791
  { fix B assume "B \<in> sets E2"
hoelzl@41689
   792
    then have "snd -` B \<inter> space ?E = (\<Union>i. S1 i) \<times> B"
hoelzl@41981
   793
      using E2 1 unfolding pair_measure_generator_def by auto
hoelzl@41689
   794
    also have "\<dots> = (\<Union>i. S1 i \<times> B)" by auto
hoelzl@41689
   795
    also have "\<dots> \<in> sets ?E"
hoelzl@41689
   796
      using 1 `B \<in> sets E2` unfolding pair_measure_generator_def sets_sigma
hoelzl@41689
   797
      by (intro sigma_sets.Union)
hoelzl@41981
   798
         (force simp: image_subset_iff intro!: sigma_sets.Basic)
hoelzl@41689
   799
    finally have "snd -` B \<inter> space ?E \<in> sets ?E" . }
hoelzl@41689
   800
  ultimately have proj:
hoelzl@41689
   801
    "fst \<in> measurable ?E (sigma E1) \<and> snd \<in> measurable ?E (sigma E2)"
hoelzl@41689
   802
    using E1 E2 by (subst (1 2) E.measurable_iff_sigma)
hoelzl@41689
   803
                   (auto simp: pair_measure_generator_def sets_sigma)
hoelzl@41689
   804
  { fix A B assume A: "A \<in> sets (sigma E1)" and B: "B \<in> sets (sigma E2)"
hoelzl@41689
   805
    with proj have "fst -` A \<inter> space ?E \<in> sets ?E" "snd -` B \<inter> space ?E \<in> sets ?E"
hoelzl@41689
   806
      unfolding measurable_def by simp_all
hoelzl@41689
   807
    moreover have "A \<times> B = (fst -` A \<inter> space ?E) \<inter> (snd -` B \<inter> space ?E)"
hoelzl@41689
   808
      using A B M1.sets_into_space M2.sets_into_space
hoelzl@41689
   809
      by (auto simp: pair_measure_generator_def)
hoelzl@41689
   810
    ultimately have "A \<times> B \<in> sets ?E" by auto }
hoelzl@41689
   811
  then have "sigma_sets (space ?E) (sets (pair_measure_generator (sigma E1) (sigma E2))) \<subseteq> sets ?E"
hoelzl@41689
   812
    by (intro E.sigma_sets_subset) (auto simp add: pair_measure_generator_def sets_sigma)
hoelzl@41689
   813
  then have subset: "sets ?S \<subseteq> sets ?E"
hoelzl@41689
   814
    by (simp add: sets_sigma pair_measure_generator_def)
hoelzl@41689
   815
  show "sets ?S = sets ?E"
hoelzl@41689
   816
  proof (intro set_eqI iffI)
hoelzl@41689
   817
    fix A assume "A \<in> sets ?E" then show "A \<in> sets ?S"
hoelzl@41689
   818
      unfolding sets_sigma
hoelzl@41689
   819
    proof induct
hoelzl@41689
   820
      case (Basic A) then show ?case
hoelzl@41689
   821
        by (auto simp: pair_measure_generator_def sets_sigma intro: sigma_sets.Basic)
hoelzl@41689
   822
    qed (auto intro: sigma_sets.intros simp: pair_measure_generator_def)
hoelzl@41689
   823
  next
hoelzl@41689
   824
    fix A assume "A \<in> sets ?S" then show "A \<in> sets ?E" using subset by auto
hoelzl@41689
   825
  qed
hoelzl@40859
   826
qed
hoelzl@40859
   827
hoelzl@40859
   828
section "Fubinis theorem"
hoelzl@40859
   829
hoelzl@40859
   830
lemma (in pair_sigma_finite) simple_function_cut:
hoelzl@41981
   831
  assumes f: "simple_function P f" "\<And>x. 0 \<le> f x"
hoelzl@41689
   832
  shows "(\<lambda>x. \<integral>\<^isup>+y. f (x, y) \<partial>M2) \<in> borel_measurable M1"
hoelzl@41689
   833
    and "(\<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. f (x, y) \<partial>M2) \<partial>M1) = integral\<^isup>P P f"
hoelzl@40859
   834
proof -
hoelzl@40859
   835
  have f_borel: "f \<in> borel_measurable P"
hoelzl@41981
   836
    using f(1) by (rule borel_measurable_simple_function)
hoelzl@40859
   837
  let "?F z" = "f -` {z} \<inter> space P"
hoelzl@40859
   838
  let "?F' x z" = "Pair x -` ?F z"
hoelzl@40859
   839
  { fix x assume "x \<in> space M1"
hoelzl@40859
   840
    have [simp]: "\<And>z y. indicator (?F z) (x, y) = indicator (?F' x z) y"
hoelzl@40859
   841
      by (auto simp: indicator_def)
hoelzl@40859
   842
    have "\<And>y. y \<in> space M2 \<Longrightarrow> (x, y) \<in> space P" using `x \<in> space M1`
hoelzl@41689
   843
      by (simp add: space_pair_measure)
hoelzl@40859
   844
    moreover have "\<And>x z. ?F' x z \<in> sets M2" using f_borel
hoelzl@40859
   845
      by (intro borel_measurable_vimage measurable_cut_fst)
hoelzl@41689
   846
    ultimately have "simple_function M2 (\<lambda> y. f (x, y))"
hoelzl@40859
   847
      apply (rule_tac M2.simple_function_cong[THEN iffD2, OF _])
hoelzl@41981
   848
      apply (rule simple_function_indicator_representation[OF f(1)])
hoelzl@40859
   849
      using `x \<in> space M1` by (auto simp del: space_sigma) }
hoelzl@40859
   850
  note M2_sf = this
hoelzl@40859
   851
  { fix x assume x: "x \<in> space M1"
hoelzl@41689
   852
    then have "(\<integral>\<^isup>+y. f (x, y) \<partial>M2) = (\<Sum>z\<in>f ` space P. z * M2.\<mu> (?F' x z))"
hoelzl@41981
   853
      unfolding M2.positive_integral_eq_simple_integral[OF M2_sf[OF x] f(2)]
hoelzl@41689
   854
      unfolding simple_integral_def
hoelzl@40859
   855
    proof (safe intro!: setsum_mono_zero_cong_left)
hoelzl@41981
   856
      from f(1) show "finite (f ` space P)" by (rule simple_functionD)
hoelzl@40859
   857
    next
hoelzl@40859
   858
      fix y assume "y \<in> space M2" then show "f (x, y) \<in> f ` space P"
hoelzl@41689
   859
        using `x \<in> space M1` by (auto simp: space_pair_measure)
hoelzl@40859
   860
    next
hoelzl@40859
   861
      fix x' y assume "(x', y) \<in> space P"
hoelzl@40859
   862
        "f (x', y) \<notin> (\<lambda>y. f (x, y)) ` space M2"
hoelzl@40859
   863
      then have *: "?F' x (f (x', y)) = {}"
hoelzl@41689
   864
        by (force simp: space_pair_measure)
hoelzl@41689
   865
      show  "f (x', y) * M2.\<mu> (?F' x (f (x', y))) = 0"
hoelzl@40859
   866
        unfolding * by simp
hoelzl@40859
   867
    qed (simp add: vimage_compose[symmetric] comp_def
hoelzl@41689
   868
                   space_pair_measure) }
hoelzl@40859
   869
  note eq = this
hoelzl@40859
   870
  moreover have "\<And>z. ?F z \<in> sets P"
hoelzl@40859
   871
    by (auto intro!: f_borel borel_measurable_vimage simp del: space_sigma)
hoelzl@41689
   872
  moreover then have "\<And>z. (\<lambda>x. M2.\<mu> (?F' x z)) \<in> borel_measurable M1"
hoelzl@40859
   873
    by (auto intro!: measure_cut_measurable_fst simp del: vimage_Int)
hoelzl@41981
   874
  moreover have *: "\<And>i x. 0 \<le> M2.\<mu> (Pair x -` (f -` {i} \<inter> space P))"
hoelzl@41981
   875
    using f(1)[THEN simple_functionD(2)] f(2) by (intro M2.positive_measure measurable_cut_fst)
hoelzl@41981
   876
  moreover { fix i assume "i \<in> f`space P"
hoelzl@41981
   877
    with * have "\<And>x. 0 \<le> i * M2.\<mu> (Pair x -` (f -` {i} \<inter> space P))"
hoelzl@41981
   878
      using f(2) by auto }
hoelzl@40859
   879
  ultimately
hoelzl@41689
   880
  show "(\<lambda>x. \<integral>\<^isup>+y. f (x, y) \<partial>M2) \<in> borel_measurable M1"
hoelzl@41981
   881
    and "(\<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. f (x, y) \<partial>M2) \<partial>M1) = integral\<^isup>P P f" using f(2)
hoelzl@40859
   882
    by (auto simp del: vimage_Int cong: measurable_cong
hoelzl@41981
   883
             intro!: M1.borel_measurable_extreal_setsum setsum_cong
hoelzl@40859
   884
             simp add: M1.positive_integral_setsum simple_integral_def
hoelzl@40859
   885
                       M1.positive_integral_cmult
hoelzl@40859
   886
                       M1.positive_integral_cong[OF eq]
hoelzl@40859
   887
                       positive_integral_eq_simple_integral[OF f]
hoelzl@40859
   888
                       pair_measure_alt[symmetric])
hoelzl@40859
   889
qed
hoelzl@40859
   890
hoelzl@40859
   891
lemma (in pair_sigma_finite) positive_integral_fst_measurable:
hoelzl@40859
   892
  assumes f: "f \<in> borel_measurable P"
hoelzl@41689
   893
  shows "(\<lambda>x. \<integral>\<^isup>+ y. f (x, y) \<partial>M2) \<in> borel_measurable M1"
hoelzl@40859
   894
      (is "?C f \<in> borel_measurable M1")
hoelzl@41689
   895
    and "(\<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. f (x, y) \<partial>M2) \<partial>M1) = integral\<^isup>P P f"
hoelzl@40859
   896
proof -
hoelzl@41981
   897
  from borel_measurable_implies_simple_function_sequence'[OF f] guess F . note F = this
hoelzl@40859
   898
  then have F_borel: "\<And>i. F i \<in> borel_measurable P"
hoelzl@40859
   899
    by (auto intro: borel_measurable_simple_function)
hoelzl@41981
   900
  note sf = simple_function_cut[OF F(1,5)]
hoelzl@41097
   901
  then have "(\<lambda>x. SUP i. ?C (F i) x) \<in> borel_measurable M1"
hoelzl@41097
   902
    using F(1) by auto
hoelzl@40859
   903
  moreover
hoelzl@40859
   904
  { fix x assume "x \<in> space M1"
hoelzl@41981
   905
    from F measurable_pair_image_snd[OF F_borel`x \<in> space M1`]
hoelzl@41981
   906
    have "(\<integral>\<^isup>+y. (SUP i. F i (x, y)) \<partial>M2) = (SUP i. ?C (F i) x)"
hoelzl@41981
   907
      by (intro M2.positive_integral_monotone_convergence_SUP)
hoelzl@41981
   908
         (auto simp: incseq_Suc_iff le_fun_def)
hoelzl@41981
   909
    then have "(SUP i. ?C (F i) x) = ?C f x"
hoelzl@41981
   910
      unfolding F(4) positive_integral_max_0 by simp }
hoelzl@40859
   911
  note SUPR_C = this
hoelzl@40859
   912
  ultimately show "?C f \<in> borel_measurable M1"
hoelzl@41097
   913
    by (simp cong: measurable_cong)
hoelzl@41689
   914
  have "(\<integral>\<^isup>+x. (SUP i. F i x) \<partial>P) = (SUP i. integral\<^isup>P P (F i))"
hoelzl@41981
   915
    using F_borel F
hoelzl@41981
   916
    by (intro positive_integral_monotone_convergence_SUP) auto
hoelzl@41689
   917
  also have "(SUP i. integral\<^isup>P P (F i)) = (SUP i. \<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. F i (x, y) \<partial>M2) \<partial>M1)"
hoelzl@40859
   918
    unfolding sf(2) by simp
hoelzl@41981
   919
  also have "\<dots> = \<integral>\<^isup>+ x. (SUP i. \<integral>\<^isup>+ y. F i (x, y) \<partial>M2) \<partial>M1" using F sf(1)
hoelzl@41981
   920
    by (intro M1.positive_integral_monotone_convergence_SUP[symmetric])
hoelzl@41981
   921
       (auto intro!: M2.positive_integral_mono M2.positive_integral_positive
hoelzl@41981
   922
                simp: incseq_Suc_iff le_fun_def)
hoelzl@41689
   923
  also have "\<dots> = \<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. (SUP i. F i (x, y)) \<partial>M2) \<partial>M1"
hoelzl@41981
   924
    using F_borel F(2,5)
hoelzl@41981
   925
    by (auto intro!: M1.positive_integral_cong M2.positive_integral_monotone_convergence_SUP[symmetric]
hoelzl@41981
   926
             simp: incseq_Suc_iff le_fun_def measurable_pair_image_snd)
hoelzl@41689
   927
  finally show "(\<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. f (x, y) \<partial>M2) \<partial>M1) = integral\<^isup>P P f"
hoelzl@41981
   928
    using F by (simp add: positive_integral_max_0)
hoelzl@40859
   929
qed
hoelzl@40859
   930
hoelzl@41831
   931
lemma (in pair_sigma_finite) measure_preserving_swap:
hoelzl@41831
   932
  "(\<lambda>(x,y). (y, x)) \<in> measure_preserving (M1 \<Otimes>\<^isub>M M2) (M2 \<Otimes>\<^isub>M M1)"
hoelzl@41831
   933
proof
hoelzl@41831
   934
  interpret Q: pair_sigma_finite M2 M1 by default
hoelzl@41831
   935
  show *: "(\<lambda>(x,y). (y, x)) \<in> measurable (M1 \<Otimes>\<^isub>M M2) (M2 \<Otimes>\<^isub>M M1)"
hoelzl@41831
   936
    using pair_sigma_algebra_swap_measurable .
hoelzl@41831
   937
  fix X assume "X \<in> sets (M2 \<Otimes>\<^isub>M M1)"
hoelzl@41831
   938
  from measurable_sets[OF * this] this Q.sets_into_space[OF this]
hoelzl@41831
   939
  show "measure (M1 \<Otimes>\<^isub>M M2) ((\<lambda>(x, y). (y, x)) -` X \<inter> space P) = measure (M2 \<Otimes>\<^isub>M M1) X"
hoelzl@41831
   940
    by (auto intro!: M1.positive_integral_cong arg_cong[where f="M2.\<mu>"]
hoelzl@41831
   941
      simp: pair_measure_alt Q.pair_measure_alt2 space_pair_measure)
hoelzl@41831
   942
qed
hoelzl@41831
   943
hoelzl@41661
   944
lemma (in pair_sigma_finite) positive_integral_product_swap:
hoelzl@41661
   945
  assumes f: "f \<in> borel_measurable P"
hoelzl@41689
   946
  shows "(\<integral>\<^isup>+x. f (case x of (x,y)\<Rightarrow>(y,x)) \<partial>(M2 \<Otimes>\<^isub>M M1)) = integral\<^isup>P P f"
hoelzl@41661
   947
proof -
hoelzl@41689
   948
  interpret Q: pair_sigma_finite M2 M1 by default
hoelzl@41689
   949
  have "sigma_algebra P" by default
hoelzl@41831
   950
  with f show ?thesis
hoelzl@41831
   951
    by (subst Q.positive_integral_vimage[OF _ Q.measure_preserving_swap]) auto
hoelzl@41661
   952
qed
hoelzl@41661
   953
hoelzl@40859
   954
lemma (in pair_sigma_finite) positive_integral_snd_measurable:
hoelzl@40859
   955
  assumes f: "f \<in> borel_measurable P"
hoelzl@41689
   956
  shows "(\<integral>\<^isup>+ y. (\<integral>\<^isup>+ x. f (x, y) \<partial>M1) \<partial>M2) = integral\<^isup>P P f"
hoelzl@40859
   957
proof -
hoelzl@41689
   958
  interpret Q: pair_sigma_finite M2 M1 by default
hoelzl@40859
   959
  note pair_sigma_algebra_measurable[OF f]
hoelzl@40859
   960
  from Q.positive_integral_fst_measurable[OF this]
hoelzl@41689
   961
  have "(\<integral>\<^isup>+ y. (\<integral>\<^isup>+ x. f (x, y) \<partial>M1) \<partial>M2) = (\<integral>\<^isup>+ (x, y). f (y, x) \<partial>Q.P)"
hoelzl@40859
   962
    by simp
hoelzl@41689
   963
  also have "(\<integral>\<^isup>+ (x, y). f (y, x) \<partial>Q.P) = integral\<^isup>P P f"
hoelzl@41661
   964
    unfolding positive_integral_product_swap[OF f, symmetric]
hoelzl@41661
   965
    by (auto intro!: Q.positive_integral_cong)
hoelzl@40859
   966
  finally show ?thesis .
hoelzl@40859
   967
qed
hoelzl@40859
   968
hoelzl@40859
   969
lemma (in pair_sigma_finite) Fubini:
hoelzl@40859
   970
  assumes f: "f \<in> borel_measurable P"
hoelzl@41689
   971
  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
   972
  unfolding positive_integral_snd_measurable[OF assms]
hoelzl@40859
   973
  unfolding positive_integral_fst_measurable[OF assms] ..
hoelzl@40859
   974
hoelzl@40859
   975
lemma (in pair_sigma_finite) AE_pair:
hoelzl@41981
   976
  assumes "AE x in P. Q x"
hoelzl@41981
   977
  shows "AE x in M1. (AE y in M2. Q (x, y))"
hoelzl@40859
   978
proof -
hoelzl@41689
   979
  obtain N where N: "N \<in> sets P" "\<mu> N = 0" "{x\<in>space P. \<not> Q x} \<subseteq> N"
hoelzl@40859
   980
    using assms unfolding almost_everywhere_def by auto
hoelzl@40859
   981
  show ?thesis
hoelzl@40859
   982
  proof (rule M1.AE_I)
hoelzl@40859
   983
    from N measure_cut_measurable_fst[OF `N \<in> sets P`]
hoelzl@41689
   984
    show "M1.\<mu> {x\<in>space M1. M2.\<mu> (Pair x -` N) \<noteq> 0} = 0"
hoelzl@41981
   985
      by (auto simp: pair_measure_alt M1.positive_integral_0_iff)
hoelzl@41689
   986
    show "{x \<in> space M1. M2.\<mu> (Pair x -` N) \<noteq> 0} \<in> sets M1"
hoelzl@41981
   987
      by (intro M1.borel_measurable_extreal_neq_const measure_cut_measurable_fst N)
hoelzl@41689
   988
    { fix x assume "x \<in> space M1" "M2.\<mu> (Pair x -` N) = 0"
hoelzl@40859
   989
      have "M2.almost_everywhere (\<lambda>y. Q (x, y))"
hoelzl@40859
   990
      proof (rule M2.AE_I)
hoelzl@41689
   991
        show "M2.\<mu> (Pair x -` N) = 0" by fact
hoelzl@40859
   992
        show "Pair x -` N \<in> sets M2" by (intro measurable_cut_fst N)
hoelzl@40859
   993
        show "{y \<in> space M2. \<not> Q (x, y)} \<subseteq> Pair x -` N"
hoelzl@41689
   994
          using N `x \<in> space M1` unfolding space_sigma space_pair_measure by auto
hoelzl@40859
   995
      qed }
hoelzl@41689
   996
    then show "{x \<in> space M1. \<not> M2.almost_everywhere (\<lambda>y. Q (x, y))} \<subseteq> {x \<in> space M1. M2.\<mu> (Pair x -` N) \<noteq> 0}"
hoelzl@40859
   997
      by auto
hoelzl@39088
   998
  qed
hoelzl@39088
   999
qed
hoelzl@35833
  1000
hoelzl@41026
  1001
lemma (in pair_sigma_algebra) measurable_product_swap:
hoelzl@41689
  1002
  "f \<in> measurable (M2 \<Otimes>\<^isub>M M1) M \<longleftrightarrow> (\<lambda>(x,y). f (y,x)) \<in> measurable P M"
hoelzl@41026
  1003
proof -
hoelzl@41026
  1004
  interpret Q: pair_sigma_algebra M2 M1 by default
hoelzl@41026
  1005
  show ?thesis
hoelzl@41026
  1006
    using pair_sigma_algebra_measurable[of "\<lambda>(x,y). f (y, x)"]
hoelzl@41026
  1007
    by (auto intro!: pair_sigma_algebra_measurable Q.pair_sigma_algebra_measurable iffI)
hoelzl@41026
  1008
qed
hoelzl@41026
  1009
hoelzl@41026
  1010
lemma (in pair_sigma_finite) integrable_product_swap:
hoelzl@41689
  1011
  assumes "integrable P f"
hoelzl@41689
  1012
  shows "integrable (M2 \<Otimes>\<^isub>M M1) (\<lambda>(x,y). f (y,x))"
hoelzl@41026
  1013
proof -
hoelzl@41689
  1014
  interpret Q: pair_sigma_finite M2 M1 by default
hoelzl@41661
  1015
  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
  1016
  show ?thesis unfolding *
hoelzl@41689
  1017
    using assms unfolding integrable_def
hoelzl@41661
  1018
    apply (subst (1 2) positive_integral_product_swap)
hoelzl@41689
  1019
    using `integrable P f` unfolding integrable_def
hoelzl@41661
  1020
    by (auto simp: *[symmetric] Q.measurable_product_swap[symmetric])
hoelzl@41661
  1021
qed
hoelzl@41661
  1022
hoelzl@41661
  1023
lemma (in pair_sigma_finite) integrable_product_swap_iff:
hoelzl@41689
  1024
  "integrable (M2 \<Otimes>\<^isub>M M1) (\<lambda>(x,y). f (y,x)) \<longleftrightarrow> integrable P f"
hoelzl@41661
  1025
proof -
hoelzl@41689
  1026
  interpret Q: pair_sigma_finite M2 M1 by default
hoelzl@41661
  1027
  from Q.integrable_product_swap[of "\<lambda>(x,y). f (y,x)"] integrable_product_swap[of f]
hoelzl@41661
  1028
  show ?thesis by auto
hoelzl@41026
  1029
qed
hoelzl@41026
  1030
hoelzl@41026
  1031
lemma (in pair_sigma_finite) integral_product_swap:
hoelzl@41689
  1032
  assumes "integrable P f"
hoelzl@41689
  1033
  shows "(\<integral>(x,y). f (y,x) \<partial>(M2 \<Otimes>\<^isub>M M1)) = integral\<^isup>L P f"
hoelzl@41026
  1034
proof -
hoelzl@41689
  1035
  interpret Q: pair_sigma_finite M2 M1 by default
hoelzl@41661
  1036
  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@41026
  1037
  show ?thesis
hoelzl@41689
  1038
    unfolding lebesgue_integral_def *
hoelzl@41661
  1039
    apply (subst (1 2) positive_integral_product_swap)
hoelzl@41689
  1040
    using `integrable P f` unfolding integrable_def
hoelzl@41661
  1041
    by (auto simp: *[symmetric] Q.measurable_product_swap[symmetric])
hoelzl@41026
  1042
qed
hoelzl@41026
  1043
hoelzl@41026
  1044
lemma (in pair_sigma_finite) integrable_fst_measurable:
hoelzl@41689
  1045
  assumes f: "integrable P f"
hoelzl@41689
  1046
  shows "M1.almost_everywhere (\<lambda>x. integrable M2 (\<lambda> y. f (x, y)))" (is "?AE")
hoelzl@41689
  1047
    and "(\<integral>x. (\<integral>y. f (x, y) \<partial>M2) \<partial>M1) = integral\<^isup>L P f" (is "?INT")
hoelzl@41026
  1048
proof -
hoelzl@41981
  1049
  let "?pf x" = "extreal (f x)" and "?nf x" = "extreal (- f x)"
hoelzl@41026
  1050
  have
hoelzl@41026
  1051
    borel: "?nf \<in> borel_measurable P""?pf \<in> borel_measurable P" and
hoelzl@41981
  1052
    int: "integral\<^isup>P P ?nf \<noteq> \<infinity>" "integral\<^isup>P P ?pf \<noteq> \<infinity>"
hoelzl@41026
  1053
    using assms by auto
hoelzl@41981
  1054
  have "(\<integral>\<^isup>+x. (\<integral>\<^isup>+y. extreal (f (x, y)) \<partial>M2) \<partial>M1) \<noteq> \<infinity>"
hoelzl@41981
  1055
     "(\<integral>\<^isup>+x. (\<integral>\<^isup>+y. extreal (- f (x, y)) \<partial>M2) \<partial>M1) \<noteq> \<infinity>"
hoelzl@41026
  1056
    using borel[THEN positive_integral_fst_measurable(1)] int
hoelzl@41026
  1057
    unfolding borel[THEN positive_integral_fst_measurable(2)] by simp_all
hoelzl@41026
  1058
  with borel[THEN positive_integral_fst_measurable(1)]
hoelzl@41981
  1059
  have AE_pos: "AE x in M1. (\<integral>\<^isup>+y. extreal (f (x, y)) \<partial>M2) \<noteq> \<infinity>"
hoelzl@41981
  1060
    "AE x in M1. (\<integral>\<^isup>+y. extreal (- f (x, y)) \<partial>M2) \<noteq> \<infinity>"
hoelzl@41981
  1061
    by (auto intro!: M1.positive_integral_PInf_AE )
hoelzl@41981
  1062
  then have AE: "AE x in M1. \<bar>\<integral>\<^isup>+y. extreal (f (x, y)) \<partial>M2\<bar> \<noteq> \<infinity>"
hoelzl@41981
  1063
    "AE x in M1. \<bar>\<integral>\<^isup>+y. extreal (- f (x, y)) \<partial>M2\<bar> \<noteq> \<infinity>"
hoelzl@41981
  1064
    by (auto simp: M2.positive_integral_positive)
hoelzl@41981
  1065
  from AE_pos show ?AE using assms
hoelzl@41705
  1066
    by (simp add: measurable_pair_image_snd integrable_def)
hoelzl@41981
  1067
  { fix f have "(\<integral>\<^isup>+ x. - \<integral>\<^isup>+ y. extreal (f x y) \<partial>M2 \<partial>M1) = (\<integral>\<^isup>+x. 0 \<partial>M1)"
hoelzl@41981
  1068
      using M2.positive_integral_positive
hoelzl@41981
  1069
      by (intro M1.positive_integral_cong_pos) (auto simp: extreal_uminus_le_reorder)
hoelzl@41981
  1070
    then have "(\<integral>\<^isup>+ x. - \<integral>\<^isup>+ y. extreal (f x y) \<partial>M2 \<partial>M1) = 0" by simp }
hoelzl@41981
  1071
  note this[simp]
hoelzl@41981
  1072
  { fix f assume borel: "(\<lambda>x. extreal (f x)) \<in> borel_measurable P"
hoelzl@41981
  1073
      and int: "integral\<^isup>P P (\<lambda>x. extreal (f x)) \<noteq> \<infinity>"
hoelzl@41981
  1074
      and AE: "M1.almost_everywhere (\<lambda>x. (\<integral>\<^isup>+y. extreal (f (x, y)) \<partial>M2) \<noteq> \<infinity>)"
hoelzl@41981
  1075
    have "integrable M1 (\<lambda>x. real (\<integral>\<^isup>+y. extreal (f (x, y)) \<partial>M2))" (is "integrable M1 ?f")
hoelzl@41705
  1076
    proof (intro integrable_def[THEN iffD2] conjI)
hoelzl@41705
  1077
      show "?f \<in> borel_measurable M1"
hoelzl@41981
  1078
        using borel by (auto intro!: M1.borel_measurable_real_of_extreal positive_integral_fst_measurable)
hoelzl@41981
  1079
      have "(\<integral>\<^isup>+x. extreal (?f x) \<partial>M1) = (\<integral>\<^isup>+x. (\<integral>\<^isup>+y. extreal (f (x, y))  \<partial>M2) \<partial>M1)"
hoelzl@41981
  1080
        using AE M2.positive_integral_positive
hoelzl@41981
  1081
        by (auto intro!: M1.positive_integral_cong_AE simp: extreal_real)
hoelzl@41981
  1082
      then show "(\<integral>\<^isup>+x. extreal (?f x) \<partial>M1) \<noteq> \<infinity>"
hoelzl@41705
  1083
        using positive_integral_fst_measurable[OF borel] int by simp
hoelzl@41981
  1084
      have "(\<integral>\<^isup>+x. extreal (- ?f x) \<partial>M1) = (\<integral>\<^isup>+x. 0 \<partial>M1)"
hoelzl@41981
  1085
        by (intro M1.positive_integral_cong_pos)
hoelzl@41981
  1086
           (simp add: M2.positive_integral_positive real_of_extreal_pos)
hoelzl@41981
  1087
      then show "(\<integral>\<^isup>+x. extreal (- ?f x) \<partial>M1) \<noteq> \<infinity>" by simp
hoelzl@41705
  1088
    qed }
hoelzl@41981
  1089
  with this[OF borel(1) int(1) AE_pos(2)] this[OF borel(2) int(2) AE_pos(1)]
hoelzl@41705
  1090
  show ?INT
hoelzl@41689
  1091
    unfolding lebesgue_integral_def[of P] lebesgue_integral_def[of M2]
hoelzl@41026
  1092
      borel[THEN positive_integral_fst_measurable(2), symmetric]
hoelzl@41981
  1093
    using AE[THEN M1.integral_real]
hoelzl@41981
  1094
    by simp
hoelzl@41026
  1095
qed
hoelzl@41026
  1096
hoelzl@41026
  1097
lemma (in pair_sigma_finite) integrable_snd_measurable:
hoelzl@41689
  1098
  assumes f: "integrable P f"
hoelzl@41689
  1099
  shows "M2.almost_everywhere (\<lambda>y. integrable M1 (\<lambda>x. f (x, y)))" (is "?AE")
hoelzl@41689
  1100
    and "(\<integral>y. (\<integral>x. f (x, y) \<partial>M1) \<partial>M2) = integral\<^isup>L P f" (is "?INT")
hoelzl@41026
  1101
proof -
hoelzl@41689
  1102
  interpret Q: pair_sigma_finite M2 M1 by default
hoelzl@41689
  1103
  have Q_int: "integrable Q.P (\<lambda>(x, y). f (y, x))"
hoelzl@41661
  1104
    using f unfolding integrable_product_swap_iff .
hoelzl@41026
  1105
  show ?INT
hoelzl@41026
  1106
    using Q.integrable_fst_measurable(2)[OF Q_int]
hoelzl@41661
  1107
    using integral_product_swap[OF f] by simp
hoelzl@41026
  1108
  show ?AE
hoelzl@41026
  1109
    using Q.integrable_fst_measurable(1)[OF Q_int]
hoelzl@41026
  1110
    by simp
hoelzl@41026
  1111
qed
hoelzl@41026
  1112
hoelzl@41026
  1113
lemma (in pair_sigma_finite) Fubini_integral:
hoelzl@41689
  1114
  assumes f: "integrable P f"
hoelzl@41689
  1115
  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
  1116
  unfolding integrable_snd_measurable[OF assms]
hoelzl@41026
  1117
  unfolding integrable_fst_measurable[OF assms] ..
hoelzl@41026
  1118
hoelzl@40859
  1119
section "Finite product spaces"
hoelzl@40859
  1120
hoelzl@40859
  1121
section "Products"
hoelzl@40859
  1122
hoelzl@40859
  1123
locale product_sigma_algebra =
hoelzl@41689
  1124
  fixes M :: "'i \<Rightarrow> ('a, 'b) measure_space_scheme"
hoelzl@40859
  1125
  assumes sigma_algebras: "\<And>i. sigma_algebra (M i)"
hoelzl@40859
  1126
hoelzl@41689
  1127
locale finite_product_sigma_algebra = product_sigma_algebra M
hoelzl@41689
  1128
  for M :: "'i \<Rightarrow> ('a, 'b) measure_space_scheme" +
hoelzl@40859
  1129
  fixes I :: "'i set"
hoelzl@40859
  1130
  assumes finite_index: "finite I"
hoelzl@40859
  1131
hoelzl@41689
  1132
definition
hoelzl@41689
  1133
  "product_algebra_generator I M = \<lparr> space = (\<Pi>\<^isub>E i \<in> I. space (M i)),
hoelzl@41689
  1134
    sets = Pi\<^isub>E I ` (\<Pi> i \<in> I. sets (M i)),
hoelzl@41689
  1135
    measure = \<lambda>A. (\<Prod>i\<in>I. measure (M i) ((SOME F. A = Pi\<^isub>E I F) i)) \<rparr>"
hoelzl@41689
  1136
hoelzl@41689
  1137
definition product_algebra_def:
hoelzl@41689
  1138
  "Pi\<^isub>M I M = sigma (product_algebra_generator I M)
hoelzl@41689
  1139
    \<lparr> measure := (SOME \<mu>. sigma_finite_measure (sigma (product_algebra_generator I M) \<lparr> measure := \<mu> \<rparr>) \<and>
hoelzl@41689
  1140
      (\<forall>A\<in>\<Pi> i\<in>I. sets (M i). \<mu> (Pi\<^isub>E I A) = (\<Prod>i\<in>I. measure (M i) (A i))))\<rparr>"
hoelzl@41689
  1141
hoelzl@40859
  1142
syntax
hoelzl@41689
  1143
  "_PiM"  :: "[pttrn, 'i set, ('a, 'b) measure_space_scheme] =>
hoelzl@41689
  1144
              ('i => 'a, 'b) measure_space_scheme"  ("(3PIM _:_./ _)" 10)
hoelzl@40859
  1145
hoelzl@40859
  1146
syntax (xsymbols)
hoelzl@41689
  1147
  "_PiM" :: "[pttrn, 'i set, ('a, 'b) measure_space_scheme] =>
hoelzl@41689
  1148
             ('i => 'a, 'b) measure_space_scheme"  ("(3\<Pi>\<^isub>M _\<in>_./ _)"   10)
hoelzl@40859
  1149
hoelzl@40859
  1150
syntax (HTML output)
hoelzl@41689
  1151
  "_PiM" :: "[pttrn, 'i set, ('a, 'b) measure_space_scheme] =>
hoelzl@41689
  1152
             ('i => 'a, 'b) measure_space_scheme"  ("(3\<Pi>\<^isub>M _\<in>_./ _)"   10)
hoelzl@40859
  1153
hoelzl@40859
  1154
translations
hoelzl@41689
  1155
  "PIM x:I. M" == "CONST Pi\<^isub>M I (%x. M)"
hoelzl@40859
  1156
hoelzl@41689
  1157
abbreviation (in finite_product_sigma_algebra) "G \<equiv> product_algebra_generator I M"
hoelzl@41689
  1158
abbreviation (in finite_product_sigma_algebra) "P \<equiv> Pi\<^isub>M I M"
hoelzl@40859
  1159
hoelzl@40859
  1160
sublocale product_sigma_algebra \<subseteq> M: sigma_algebra "M i" for i by (rule sigma_algebras)
hoelzl@40859
  1161
hoelzl@41689
  1162
lemma sigma_into_space:
hoelzl@41689
  1163
  assumes "sets M \<subseteq> Pow (space M)"
hoelzl@41689
  1164
  shows "sets (sigma M) \<subseteq> Pow (space M)"
hoelzl@41689
  1165
  using sigma_sets_into_sp[OF assms] unfolding sigma_def by auto
hoelzl@41689
  1166
hoelzl@41689
  1167
lemma (in product_sigma_algebra) product_algebra_generator_into_space:
hoelzl@41689
  1168
  "sets (product_algebra_generator I M) \<subseteq> Pow (space (product_algebra_generator I M))"
hoelzl@41689
  1169
  using M.sets_into_space unfolding product_algebra_generator_def
hoelzl@40859
  1170
  by auto blast
hoelzl@40859
  1171
hoelzl@41689
  1172
lemma (in product_sigma_algebra) product_algebra_into_space:
hoelzl@41689
  1173
  "sets (Pi\<^isub>M I M) \<subseteq> Pow (space (Pi\<^isub>M I M))"
hoelzl@41689
  1174
  using product_algebra_generator_into_space
hoelzl@41689
  1175
  by (auto intro!: sigma_into_space simp add: product_algebra_def)
hoelzl@41689
  1176
hoelzl@41689
  1177
lemma (in product_sigma_algebra) sigma_algebra_product_algebra: "sigma_algebra (Pi\<^isub>M I M)"
hoelzl@41689
  1178
  using product_algebra_generator_into_space unfolding product_algebra_def
hoelzl@41689
  1179
  by (rule sigma_algebra.sigma_algebra_cong[OF sigma_algebra_sigma]) simp_all
hoelzl@41689
  1180
hoelzl@40859
  1181
sublocale finite_product_sigma_algebra \<subseteq> sigma_algebra P
hoelzl@41689
  1182
  using sigma_algebra_product_algebra .
hoelzl@40859
  1183
hoelzl@41095
  1184
lemma product_algebraE:
hoelzl@41689
  1185
  assumes "A \<in> sets (product_algebra_generator I M)"
hoelzl@41095
  1186
  obtains E where "A = Pi\<^isub>E I E" "E \<in> (\<Pi> i\<in>I. sets (M i))"
hoelzl@41689
  1187
  using assms unfolding product_algebra_generator_def by auto
hoelzl@41095
  1188
hoelzl@41689
  1189
lemma product_algebra_generatorI[intro]:
hoelzl@41095
  1190
  assumes "E \<in> (\<Pi> i\<in>I. sets (M i))"
hoelzl@41689
  1191
  shows "Pi\<^isub>E I E \<in> sets (product_algebra_generator I M)"
hoelzl@41689
  1192
  using assms unfolding product_algebra_generator_def by auto
hoelzl@41689
  1193
hoelzl@41689
  1194
lemma space_product_algebra_generator[simp]:
hoelzl@41689
  1195
  "space (product_algebra_generator I M) = Pi\<^isub>E I (\<lambda>i. space (M i))"
hoelzl@41689
  1196
  unfolding product_algebra_generator_def by simp
hoelzl@41095
  1197
hoelzl@40859
  1198
lemma space_product_algebra[simp]:
hoelzl@41689
  1199
  "space (Pi\<^isub>M I M) = (\<Pi>\<^isub>E i\<in>I. space (M i))"
hoelzl@41689
  1200
  unfolding product_algebra_def product_algebra_generator_def by simp
hoelzl@40859
  1201
hoelzl@41689
  1202
lemma sets_product_algebra:
hoelzl@41689
  1203
  "sets (Pi\<^isub>M I M) = sets (sigma (product_algebra_generator I M))"
hoelzl@41689
  1204
  unfolding product_algebra_def sigma_def by simp
hoelzl@41689
  1205
hoelzl@41689
  1206
lemma product_algebra_generator_sets_into_space:
hoelzl@41095
  1207
  assumes "\<And>i. i\<in>I \<Longrightarrow> sets (M i) \<subseteq> Pow (space (M i))"
hoelzl@41689
  1208
  shows "sets (product_algebra_generator I M) \<subseteq> Pow (space (product_algebra_generator I M))"
hoelzl@41689
  1209
  using assms by (auto simp: product_algebra_generator_def) blast
hoelzl@40859
  1210
hoelzl@40859
  1211
lemma (in finite_product_sigma_algebra) in_P[simp, intro]:
hoelzl@40859
  1212
  "\<lbrakk> \<And>i. i \<in> I \<Longrightarrow> A i \<in> sets (M i) \<rbrakk> \<Longrightarrow> Pi\<^isub>E I A \<in> sets P"
hoelzl@41689
  1213
  by (auto simp: sets_product_algebra)
hoelzl@41026
  1214
hoelzl@40859
  1215
section "Generating set generates also product algebra"
hoelzl@40859
  1216
hoelzl@40859
  1217
lemma sigma_product_algebra_sigma_eq:
hoelzl@40859
  1218
  assumes "finite I"
hoelzl@41981
  1219
  assumes mono: "\<And>i. i \<in> I \<Longrightarrow> incseq (S i)"
hoelzl@41981
  1220
  assumes union: "\<And>i. i \<in> I \<Longrightarrow> (\<Union>j. S i j) = space (E i)"
hoelzl@40859
  1221
  assumes sets_into: "\<And>i. i \<in> I \<Longrightarrow> range (S i) \<subseteq> sets (E i)"
hoelzl@40859
  1222
  and E: "\<And>i. sets (E i) \<subseteq> Pow (space (E i))"
hoelzl@41689
  1223
  shows "sets (\<Pi>\<^isub>M i\<in>I. sigma (E i)) = sets (\<Pi>\<^isub>M i\<in>I. E i)"
hoelzl@41689
  1224
    (is "sets ?S = sets ?E")
hoelzl@40859
  1225
proof cases
hoelzl@41689
  1226
  assume "I = {}" then show ?thesis
hoelzl@41689
  1227
    by (simp add: product_algebra_def product_algebra_generator_def)
hoelzl@40859
  1228
next
hoelzl@40859
  1229
  assume "I \<noteq> {}"
hoelzl@40859
  1230
  interpret E: sigma_algebra "sigma (E i)" for i
hoelzl@40859
  1231
    using E by (rule sigma_algebra_sigma)
hoelzl@40859
  1232
  have into_space[intro]: "\<And>i x A. A \<in> sets (E i) \<Longrightarrow> x i \<in> A \<Longrightarrow> x i \<in> space (E i)"
hoelzl@40859
  1233
    using E by auto
hoelzl@40859
  1234
  interpret G: sigma_algebra ?E
hoelzl@41689
  1235
    unfolding product_algebra_def product_algebra_generator_def using E
hoelzl@41689
  1236
    by (intro sigma_algebra.sigma_algebra_cong[OF sigma_algebra_sigma]) (auto dest: Pi_mem)
hoelzl@40859
  1237
  { fix A i assume "i \<in> I" and A: "A \<in> sets (E i)"
hoelzl@40859
  1238
    then have "(\<lambda>x. x i) -` A \<inter> space ?E = (\<Pi>\<^isub>E j\<in>I. if j = i then A else \<Union>n. S j n) \<inter> space ?E"
hoelzl@41981
  1239
      using mono union unfolding incseq_Suc_iff space_product_algebra
hoelzl@41689
  1240
      by (auto dest: Pi_mem)
hoelzl@40859
  1241
    also have "\<dots> = (\<Union>n. (\<Pi>\<^isub>E j\<in>I. if j = i then A else S j n))"
hoelzl@41689
  1242
      unfolding space_product_algebra
hoelzl@40859
  1243
      apply simp
hoelzl@40859
  1244
      apply (subst Pi_UN[OF `finite I`])
hoelzl@41981
  1245
      using mono[THEN incseqD] apply simp
hoelzl@40859
  1246
      apply (simp add: PiE_Int)
hoelzl@40859
  1247
      apply (intro PiE_cong)
hoelzl@40859
  1248
      using A sets_into by (auto intro!: into_space)
hoelzl@41689
  1249
    also have "\<dots> \<in> sets ?E"
hoelzl@40859
  1250
      using sets_into `A \<in> sets (E i)`
hoelzl@41689
  1251
      unfolding sets_product_algebra sets_sigma
hoelzl@40859
  1252
      by (intro sigma_sets.Union)
hoelzl@40859
  1253
         (auto simp: image_subset_iff intro!: sigma_sets.Basic)
hoelzl@40859
  1254
    finally have "(\<lambda>x. x i) -` A \<inter> space ?E \<in> sets ?E" . }
hoelzl@40859
  1255
  then have proj:
hoelzl@40859
  1256
    "\<And>i. i\<in>I \<Longrightarrow> (\<lambda>x. x i) \<in> measurable ?E (sigma (E i))"
hoelzl@40859
  1257
    using E by (subst G.measurable_iff_sigma)
hoelzl@41689
  1258
               (auto simp: sets_product_algebra sets_sigma)
hoelzl@40859
  1259
  { fix A assume A: "\<And>i. i \<in> I \<Longrightarrow> A i \<in> sets (sigma (E i))"
hoelzl@40859
  1260
    with proj have basic: "\<And>i. i \<in> I \<Longrightarrow> (\<lambda>x. x i) -` (A i) \<inter> space ?E \<in> sets ?E"
hoelzl@40859
  1261
      unfolding measurable_def by simp
hoelzl@40859
  1262
    have "Pi\<^isub>E I A = (\<Inter>i\<in>I. (\<lambda>x. x i) -` (A i) \<inter> space ?E)"
hoelzl@40859
  1263
      using A E.sets_into_space `I \<noteq> {}` unfolding product_algebra_def by auto blast
hoelzl@40859
  1264
    then have "Pi\<^isub>E I A \<in> sets ?E"
hoelzl@40859
  1265
      using G.finite_INT[OF `finite I` `I \<noteq> {}` basic, of "\<lambda>i. i"] by simp }
hoelzl@41689
  1266
  then have "sigma_sets (space ?E) (sets (product_algebra_generator I (\<lambda>i. sigma (E i)))) \<subseteq> sets ?E"
hoelzl@41689
  1267
    by (intro G.sigma_sets_subset) (auto simp add: product_algebra_generator_def)
hoelzl@40859
  1268
  then have subset: "sets ?S \<subseteq> sets ?E"
hoelzl@41689
  1269
    by (simp add: sets_sigma sets_product_algebra)
hoelzl@41689
  1270
  show "sets ?S = sets ?E"
hoelzl@40859
  1271
  proof (intro set_eqI iffI)
hoelzl@40859
  1272
    fix A assume "A \<in> sets ?E" then show "A \<in> sets ?S"
hoelzl@41689
  1273
      unfolding sets_sigma sets_product_algebra
hoelzl@40859
  1274
    proof induct
hoelzl@40859
  1275
      case (Basic A) then show ?case
hoelzl@41689
  1276
        by (auto simp: sets_sigma product_algebra_generator_def intro: sigma_sets.Basic)
hoelzl@41689
  1277
    qed (auto intro: sigma_sets.intros simp: product_algebra_generator_def)
hoelzl@40859
  1278
  next
hoelzl@40859
  1279
    fix A assume "A \<in> sets ?S" then show "A \<in> sets ?E" using subset by auto
hoelzl@40859
  1280
  qed
hoelzl@41689
  1281
qed
hoelzl@41689
  1282
hoelzl@41689
  1283
lemma product_algebraI[intro]:
hoelzl@41689
  1284
    "E \<in> (\<Pi> i\<in>I. sets (M i)) \<Longrightarrow> Pi\<^isub>E I E \<in> sets (Pi\<^isub>M I M)"
hoelzl@41689
  1285
  using assms unfolding product_algebra_def by (auto intro: product_algebra_generatorI)
hoelzl@41689
  1286
hoelzl@41689
  1287
lemma (in product_sigma_algebra) measurable_component_update:
hoelzl@41689
  1288
  assumes "x \<in> space (Pi\<^isub>M I M)" and "i \<notin> I"
hoelzl@41689
  1289
  shows "(\<lambda>v. x(i := v)) \<in> measurable (M i) (Pi\<^isub>M (insert i I) M)" (is "?f \<in> _")
hoelzl@41689
  1290
  unfolding product_algebra_def apply simp
hoelzl@41689
  1291
proof (intro measurable_sigma)
hoelzl@41689
  1292
  let ?G = "product_algebra_generator (insert i I) M"
hoelzl@41689
  1293
  show "sets ?G \<subseteq> Pow (space ?G)" using product_algebra_generator_into_space .
hoelzl@41689
  1294
  show "?f \<in> space (M i) \<rightarrow> space ?G"
hoelzl@41689
  1295
    using M.sets_into_space assms by auto
hoelzl@41689
  1296
  fix A assume "A \<in> sets ?G"
hoelzl@41689
  1297
  from product_algebraE[OF this] guess E . note E = this
hoelzl@41689
  1298
  then have "?f -` A \<inter> space (M i) = E i \<or> ?f -` A \<inter> space (M i) = {}"
hoelzl@41689
  1299
    using M.sets_into_space assms by auto
hoelzl@41689
  1300
  then show "?f -` A \<inter> space (M i) \<in> sets (M i)"
hoelzl@41689
  1301
    using E by (auto intro!: product_algebraI)
hoelzl@40859
  1302
qed
hoelzl@40859
  1303
hoelzl@41689
  1304
lemma (in product_sigma_algebra) measurable_add_dim:
hoelzl@41689
  1305
  assumes "i \<notin> I"
hoelzl@41689
  1306
  shows "(\<lambda>(f, y). f(i := y)) \<in> measurable (Pi\<^isub>M I M \<Otimes>\<^isub>M M i) (Pi\<^isub>M (insert i I) M)"
hoelzl@41689
  1307
proof -
hoelzl@41689
  1308
  let ?f = "(\<lambda>(f, y). f(i := y))" and ?G = "product_algebra_generator (insert i I) M"
hoelzl@41689
  1309
  interpret Ii: pair_sigma_algebra "Pi\<^isub>M I M" "M i"
hoelzl@41689
  1310
    unfolding pair_sigma_algebra_def
hoelzl@41689
  1311
    by (intro sigma_algebra_product_algebra sigma_algebras conjI)
hoelzl@41689
  1312
  have "?f \<in> measurable Ii.P (sigma ?G)"
hoelzl@41689
  1313
  proof (rule Ii.measurable_sigma)
hoelzl@41689
  1314
    show "sets ?G \<subseteq> Pow (space ?G)"
hoelzl@41689
  1315
      using product_algebra_generator_into_space .
hoelzl@41689
  1316
    show "?f \<in> space (Pi\<^isub>M I M \<Otimes>\<^isub>M M i) \<rightarrow> space ?G"
hoelzl@41689
  1317
      by (auto simp: space_pair_measure)
hoelzl@41689
  1318
  next
hoelzl@41689
  1319
    fix A assume "A \<in> sets ?G"
hoelzl@41689
  1320
    then obtain F where "A = Pi\<^isub>E (insert i I) F"
hoelzl@41689
  1321
      and F: "\<And>j. j \<in> I \<Longrightarrow> F j \<in> sets (M j)" "F i \<in> sets (M i)"
hoelzl@41689
  1322
      by (auto elim!: product_algebraE)
hoelzl@41689
  1323
    then have "?f -` A \<inter> space (Pi\<^isub>M I M \<Otimes>\<^isub>M M i) = Pi\<^isub>E I F \<times> (F i)"
hoelzl@41689
  1324
      using sets_into_space `i \<notin> I`
hoelzl@41689
  1325
      by (auto simp add: space_pair_measure) blast+
hoelzl@41689
  1326
    then show "?f -` A \<inter> space (Pi\<^isub>M I M \<Otimes>\<^isub>M M i) \<in> sets (Pi\<^isub>M I M \<Otimes>\<^isub>M M i)"
hoelzl@41689
  1327
      using F by (auto intro!: pair_measureI)
hoelzl@41689
  1328
  qed
hoelzl@41689
  1329
  then show ?thesis
hoelzl@41689
  1330
    by (simp add: product_algebra_def)
hoelzl@41689
  1331
qed
hoelzl@41095
  1332
hoelzl@41095
  1333
lemma (in product_sigma_algebra) measurable_merge:
hoelzl@41095
  1334
  assumes [simp]: "I \<inter> J = {}"
hoelzl@41689
  1335
  shows "(\<lambda>(x, y). merge I x J y) \<in> measurable (Pi\<^isub>M I M \<Otimes>\<^isub>M Pi\<^isub>M J M) (Pi\<^isub>M (I \<union> J) M)"
hoelzl@40859
  1336
proof -
hoelzl@41689
  1337
  let ?I = "Pi\<^isub>M I M" and ?J = "Pi\<^isub>M J M"
hoelzl@41689
  1338
  interpret P: sigma_algebra "?I \<Otimes>\<^isub>M ?J"
hoelzl@41689
  1339
    by (intro sigma_algebra_pair_measure product_algebra_into_space)
hoelzl@41689
  1340
  let ?f = "\<lambda>(x, y). merge I x J y"
hoelzl@41689
  1341
  let ?G = "product_algebra_generator (I \<union> J) M"
hoelzl@41689
  1342
  have "?f \<in> measurable (?I \<Otimes>\<^isub>M ?J) (sigma ?G)"
hoelzl@41689
  1343
  proof (rule P.measurable_sigma)
hoelzl@41689
  1344
    fix A assume "A \<in> sets ?G"
hoelzl@41689
  1345
    from product_algebraE[OF this]
hoelzl@41689
  1346
    obtain