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