src/HOL/Probability/Projective_Limit.thy
author haftmann
Sun Jun 23 21:16:07 2013 +0200 (2013-06-23)
changeset 52435 6646bb548c6b
parent 51351 dd1dd470690b
child 52681 8cc7f76b827a
permissions -rw-r--r--
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
immler@50091
     1
(*  Title:      HOL/Probability/Projective_Limit.thy
immler@50088
     2
    Author:     Fabian Immler, TU M√ľnchen
immler@50088
     3
*)
immler@50088
     4
immler@50088
     5
header {* Projective Limit *}
immler@50088
     6
immler@50088
     7
theory Projective_Limit
immler@50088
     8
  imports
immler@50088
     9
    Caratheodory
immler@50088
    10
    Fin_Map
immler@50088
    11
    Regularity
immler@50088
    12
    Projective_Family
immler@50088
    13
    Infinite_Product_Measure
hoelzl@50971
    14
    "~~/src/HOL/Library/Diagonal_Subsequence"
immler@50088
    15
begin
immler@50088
    16
immler@50088
    17
subsection {* Sequences of Finite Maps in Compact Sets *}
immler@50088
    18
immler@50088
    19
locale finmap_seqs_into_compact =
immler@50088
    20
  fixes K::"nat \<Rightarrow> (nat \<Rightarrow>\<^isub>F 'a::metric_space) set" and f::"nat \<Rightarrow> (nat \<Rightarrow>\<^isub>F 'a)" and M
immler@50088
    21
  assumes compact: "\<And>n. compact (K n)"
immler@50088
    22
  assumes f_in_K: "\<And>n. K n \<noteq> {}"
immler@50088
    23
  assumes domain_K: "\<And>n. k \<in> K n \<Longrightarrow> domain k = domain (f n)"
immler@50088
    24
  assumes proj_in_K:
immler@50088
    25
    "\<And>t n m. m \<ge> n \<Longrightarrow> t \<in> domain (f n) \<Longrightarrow> (f m)\<^isub>F t \<in> (\<lambda>k. (k)\<^isub>F t) ` K n"
immler@50088
    26
begin
immler@50088
    27
immler@50088
    28
lemma proj_in_K': "(\<exists>n. \<forall>m \<ge> n. (f m)\<^isub>F t \<in> (\<lambda>k. (k)\<^isub>F t) ` K n)"
immler@50088
    29
  using proj_in_K f_in_K
immler@50088
    30
proof cases
immler@50088
    31
  obtain k where "k \<in> K (Suc 0)" using f_in_K by auto
immler@50088
    32
  assume "\<forall>n. t \<notin> domain (f n)"
immler@50088
    33
  thus ?thesis
immler@50088
    34
    by (auto intro!: exI[where x=1] image_eqI[OF _ `k \<in> K (Suc 0)`]
immler@50088
    35
      simp: domain_K[OF `k \<in> K (Suc 0)`])
immler@50088
    36
qed blast
immler@50088
    37
immler@50088
    38
lemma proj_in_KE:
immler@50088
    39
  obtains n where "\<And>m. m \<ge> n \<Longrightarrow> (f m)\<^isub>F t \<in> (\<lambda>k. (k)\<^isub>F t) ` K n"
immler@50088
    40
  using proj_in_K' by blast
immler@50088
    41
immler@50088
    42
lemma compact_projset:
immler@50088
    43
  shows "compact ((\<lambda>k. (k)\<^isub>F i) ` K n)"
immler@50088
    44
  using continuous_proj compact by (rule compact_continuous_image)
immler@50088
    45
immler@50088
    46
end
immler@50088
    47
immler@50088
    48
lemma compactE':
hoelzl@50884
    49
  fixes S :: "'a :: metric_space set"
immler@50088
    50
  assumes "compact S" "\<forall>n\<ge>m. f n \<in> S"
immler@50088
    51
  obtains l r where "l \<in> S" "subseq r" "((f \<circ> r) ---> l) sequentially"
immler@50088
    52
proof atomize_elim
immler@50088
    53
  have "subseq (op + m)" by (simp add: subseq_def)
immler@50088
    54
  have "\<forall>n. (f o (\<lambda>i. m + i)) n \<in> S" using assms by auto
hoelzl@50884
    55
  from seq_compactE[OF `compact S`[unfolded compact_eq_seq_compact_metric] this] guess l r .
immler@50088
    56
  hence "l \<in> S" "subseq ((\<lambda>i. m + i) o r) \<and> (f \<circ> ((\<lambda>i. m + i) o r)) ----> l"
immler@50088
    57
    using subseq_o[OF `subseq (op + m)` `subseq r`] by (auto simp: o_def)
immler@50088
    58
  thus "\<exists>l r. l \<in> S \<and> subseq r \<and> (f \<circ> r) ----> l" by blast
immler@50088
    59
qed
immler@50088
    60
immler@50088
    61
sublocale finmap_seqs_into_compact \<subseteq> subseqs "\<lambda>n s. (\<exists>l. (\<lambda>i. ((f o s) i)\<^isub>F n) ----> l)"
immler@50088
    62
proof
immler@50088
    63
  fix n s
immler@50088
    64
  assume "subseq s"
immler@50088
    65
  from proj_in_KE[of n] guess n0 . note n0 = this
immler@50088
    66
  have "\<forall>i \<ge> n0. ((f \<circ> s) i)\<^isub>F n \<in> (\<lambda>k. (k)\<^isub>F n) ` K n0"
immler@50088
    67
  proof safe
immler@50088
    68
    fix i assume "n0 \<le> i"
immler@50088
    69
    also have "\<dots> \<le> s i" by (rule seq_suble) fact
immler@50088
    70
    finally have "n0 \<le> s i" .
immler@50088
    71
    with n0 show "((f \<circ> s) i)\<^isub>F n \<in> (\<lambda>k. (k)\<^isub>F n) ` K n0 "
immler@50088
    72
      by auto
immler@50088
    73
  qed
immler@50088
    74
  from compactE'[OF compact_projset this] guess ls rs .
immler@50088
    75
  thus "\<exists>r'. subseq r' \<and> (\<exists>l. (\<lambda>i. ((f \<circ> (s \<circ> r')) i)\<^isub>F n) ----> l)" by (auto simp: o_def)
immler@50088
    76
qed
immler@50088
    77
hoelzl@50125
    78
lemma (in finmap_seqs_into_compact) diagonal_tendsto: "\<exists>l. (\<lambda>i. (f (diagseq i))\<^isub>F n) ----> l"
immler@50088
    79
proof -
immler@50088
    80
  have "\<And>i n0. (f o seqseq i) i = f (diagseq i)" unfolding diagseq_def by simp
immler@50088
    81
  from reducer_reduces obtain l where l: "(\<lambda>i. ((f \<circ> seqseq (Suc n)) i)\<^isub>F n) ----> l"
immler@50088
    82
    unfolding seqseq_reducer
immler@50088
    83
  by auto
immler@50088
    84
  have "(\<lambda>i. (f (diagseq (i + Suc n)))\<^isub>F n) =
immler@50088
    85
    (\<lambda>i. ((f o (diagseq o (op + (Suc n)))) i)\<^isub>F n)" by (simp add: add_commute)
immler@50088
    86
  also have "\<dots> =
immler@50088
    87
    (\<lambda>i. ((f o ((seqseq (Suc n) o (\<lambda>x. fold_reduce (Suc n) x (Suc n + x))))) i)\<^isub>F n)"
immler@50088
    88
    unfolding diagseq_seqseq by simp
immler@50088
    89
  also have "\<dots> = (\<lambda>i. ((f o ((seqseq (Suc n)))) i)\<^isub>F n) o (\<lambda>x. fold_reduce (Suc n) x (Suc n + x))"
immler@50088
    90
    by (simp add: o_def)
immler@50088
    91
  also have "\<dots> ----> l"
immler@50088
    92
  proof (rule LIMSEQ_subseq_LIMSEQ[OF _ subseq_diagonal_rest], rule tendstoI)
immler@50088
    93
    fix e::real assume "0 < e"
immler@50088
    94
    from tendstoD[OF l `0 < e`]
immler@50088
    95
    show "eventually (\<lambda>x. dist (((f \<circ> seqseq (Suc n)) x)\<^isub>F n) l < e)
immler@50088
    96
      sequentially" .
immler@50088
    97
  qed
immler@50088
    98
  finally show ?thesis by (intro exI) (rule LIMSEQ_offset)
immler@50088
    99
qed
immler@50088
   100
immler@50088
   101
subsection {* Daniell-Kolmogorov Theorem *}
immler@50088
   102
immler@50088
   103
text {* Existence of Projective Limit *}
immler@50088
   104
immler@50088
   105
locale polish_projective = projective_family I P "\<lambda>_. borel::'a::polish_space measure"
immler@50088
   106
  for I::"'i set" and P
immler@50088
   107
begin
immler@50088
   108
immler@50095
   109
abbreviation "lim\<^isub>B \<equiv> (\<lambda>J P. limP J (\<lambda>_. borel) P)"
immler@50088
   110
hoelzl@50125
   111
lemma emeasure_limB_emb_not_empty:
immler@50088
   112
  assumes "I \<noteq> {}"
immler@50088
   113
  assumes X: "J \<noteq> {}" "J \<subseteq> I" "finite J" "\<forall>i\<in>J. B i \<in> sets borel"
immler@50095
   114
  shows "emeasure (lim\<^isub>B I P) (emb I J (Pi\<^isub>E J B)) = emeasure (lim\<^isub>B J P) (Pi\<^isub>E J B)"
immler@50088
   115
proof -
immler@50088
   116
  let ?\<Omega> = "\<Pi>\<^isub>E i\<in>I. space borel"
immler@50088
   117
  let ?G = generator
immler@50088
   118
  interpret G!: algebra ?\<Omega> generator by (intro  algebra_generator) fact
wenzelm@50252
   119
  note mu_G_mono =
wenzelm@50252
   120
    G.additive_increasing[OF positive_mu_G[OF `I \<noteq> {}`] additive_mu_G[OF `I \<noteq> {}`],
wenzelm@50252
   121
      THEN increasingD]
wenzelm@50252
   122
  write mu_G  ("\<mu>G")
wenzelm@50252
   123
immler@50088
   124
  have "\<exists>\<mu>. (\<forall>s\<in>?G. \<mu> s = \<mu>G s) \<and> measure_space ?\<Omega> (sigma_sets ?\<Omega> ?G) \<mu>"
wenzelm@50252
   125
  proof (rule G.caratheodory_empty_continuous[OF positive_mu_G additive_mu_G,
immler@50088
   126
      OF `I \<noteq> {}`, OF `I \<noteq> {}`])
immler@50088
   127
    fix A assume "A \<in> ?G"
immler@50088
   128
    with generatorE guess J X . note JX = this
hoelzl@50101
   129
    interpret prob_space "P J" using proj_prob_space[OF `finite J`] .
immler@50095
   130
    show "\<mu>G A \<noteq> \<infinity>" using JX by (simp add: limP_finite)
immler@50088
   131
  next
immler@50088
   132
    fix Z assume Z: "range Z \<subseteq> ?G" "decseq Z" "(\<Inter>i. Z i) = {}"
immler@50088
   133
    then have "decseq (\<lambda>i. \<mu>G (Z i))"
wenzelm@50252
   134
      by (auto intro!: mu_G_mono simp: decseq_def)
immler@50088
   135
    moreover
immler@50088
   136
    have "(INF i. \<mu>G (Z i)) = 0"
immler@50088
   137
    proof (rule ccontr)
immler@50088
   138
      assume "(INF i. \<mu>G (Z i)) \<noteq> 0" (is "?a \<noteq> 0")
immler@50088
   139
      moreover have "0 \<le> ?a"
wenzelm@50252
   140
        using Z positive_mu_G[OF `I \<noteq> {}`] by (auto intro!: INF_greatest simp: positive_def)
immler@50088
   141
      ultimately have "0 < ?a" by auto
immler@50088
   142
      hence "?a \<noteq> -\<infinity>" by auto
immler@50088
   143
      have "\<forall>n. \<exists>J B. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I \<and> B \<in> sets (Pi\<^isub>M J (\<lambda>_. borel)) \<and>
immler@50095
   144
        Z n = emb I J B \<and> \<mu>G (Z n) = emeasure (lim\<^isub>B J P) B"
immler@50088
   145
        using Z by (intro allI generator_Ex) auto
immler@50088
   146
      then obtain J' B' where J': "\<And>n. J' n \<noteq> {}" "\<And>n. finite (J' n)" "\<And>n. J' n \<subseteq> I"
immler@50088
   147
          "\<And>n. B' n \<in> sets (\<Pi>\<^isub>M i\<in>J' n. borel)"
immler@50088
   148
        and Z_emb: "\<And>n. Z n = emb I (J' n) (B' n)"
immler@50088
   149
        unfolding choice_iff by blast
immler@50088
   150
      moreover def J \<equiv> "\<lambda>n. (\<Union>i\<le>n. J' i)"
immler@50088
   151
      moreover def B \<equiv> "\<lambda>n. emb (J n) (J' n) (B' n)"
immler@50088
   152
      ultimately have J: "\<And>n. J n \<noteq> {}" "\<And>n. finite (J n)" "\<And>n. J n \<subseteq> I"
immler@50088
   153
        "\<And>n. B n \<in> sets (\<Pi>\<^isub>M i\<in>J n. borel)"
immler@50088
   154
        by auto
immler@50088
   155
      have J_mono: "\<And>n m. n \<le> m \<Longrightarrow> J n \<subseteq> J m"
immler@50088
   156
        unfolding J_def by force
immler@50088
   157
      have "\<forall>n. \<exists>j. j \<in> J n" using J by blast
immler@50088
   158
      then obtain j where j: "\<And>n. j n \<in> J n"
immler@50088
   159
        unfolding choice_iff by blast
immler@50088
   160
      note [simp] = `\<And>n. finite (J n)`
immler@50088
   161
      from J  Z_emb have Z_eq: "\<And>n. Z n = emb I (J n) (B n)" "\<And>n. Z n \<in> ?G"
immler@50088
   162
        unfolding J_def B_def by (subst prod_emb_trans) (insert Z, auto)
hoelzl@50101
   163
      interpret prob_space "P (J i)" for i using proj_prob_space by simp
immler@50088
   164
      have "?a \<le> \<mu>G (Z 0)" by (auto intro: INF_lower)
wenzelm@50252
   165
      also have "\<dots> < \<infinity>" using J by (auto simp: Z_eq mu_G_eq limP_finite proj_sets)
immler@50088
   166
      finally have "?a \<noteq> \<infinity>" by simp
immler@50088
   167
      have "\<And>n. \<bar>\<mu>G (Z n)\<bar> \<noteq> \<infinity>" unfolding Z_eq using J J_mono
wenzelm@50252
   168
        by (subst mu_G_eq) (auto simp: limP_finite proj_sets mu_G_eq)
immler@50088
   169
immler@50243
   170
      have countable_UN_J: "countable (\<Union>n. J n)" by (simp add: countable_finite)
immler@50243
   171
      def Utn \<equiv> "to_nat_on (\<Union>n. J n)"
immler@50243
   172
      interpret function_to_finmap "J n" Utn "from_nat_into (\<Union>n. J n)" for n
immler@50243
   173
        by unfold_locales (auto simp: Utn_def intro: from_nat_into_to_nat_on[OF countable_UN_J])
immler@50243
   174
      have inj_on_Utn: "inj_on Utn (\<Union>n. J n)"
immler@50243
   175
        unfolding Utn_def using countable_UN_J by (rule inj_on_to_nat_on)
immler@50243
   176
      hence inj_on_Utn_J: "\<And>n. inj_on Utn (J n)" by (rule subset_inj_on) auto
immler@50088
   177
      def P' \<equiv> "\<lambda>n. mapmeasure n (P (J n)) (\<lambda>_. borel)"
immler@50088
   178
      let ?SUP = "\<lambda>n. SUP K : {K. K \<subseteq> fm n ` (B n) \<and> compact K}. emeasure (P' n) K"
immler@50088
   179
      {
immler@50088
   180
        fix n
immler@50088
   181
        interpret finite_measure "P (J n)" by unfold_locales
immler@50088
   182
        have "emeasure (P (J n)) (B n) = emeasure (P' n) (fm n ` (B n))"
immler@50088
   183
          using J by (auto simp: P'_def mapmeasure_PiM proj_space proj_sets)
immler@50088
   184
        also
immler@50088
   185
        have "\<dots> = ?SUP n"
immler@50088
   186
        proof (rule inner_regular)
immler@50088
   187
          show "emeasure (P' n) (space (P' n)) \<noteq> \<infinity>"
immler@50088
   188
            unfolding P'_def
immler@50088
   189
            by (auto simp: P'_def mapmeasure_PiF fm_measurable proj_space proj_sets)
immler@50088
   190
          show "sets (P' n) = sets borel" by (simp add: borel_eq_PiF_borel P'_def)
immler@50088
   191
        next
immler@50088
   192
          show "fm n ` B n \<in> sets borel"
immler@50088
   193
            unfolding borel_eq_PiF_borel
immler@50088
   194
            by (auto simp del: J(2) simp: P'_def fm_image_measurable_finite proj_sets J)
immler@50088
   195
        qed
immler@50088
   196
        finally
immler@50088
   197
        have "emeasure (P (J n)) (B n) = ?SUP n" "?SUP n \<noteq> \<infinity>" "?SUP n \<noteq> - \<infinity>" by auto
immler@50088
   198
      } note R = this
immler@50088
   199
      have "\<forall>n. \<exists>K. emeasure (P (J n)) (B n) - emeasure (P' n) K \<le> 2 powr (-n) * ?a
immler@50088
   200
        \<and> compact K \<and> K \<subseteq> fm n ` B n"
immler@50088
   201
      proof
immler@50088
   202
        fix n
immler@50088
   203
        have "emeasure (P' n) (space (P' n)) \<noteq> \<infinity>"
immler@50088
   204
          by (simp add: mapmeasure_PiF P'_def proj_space proj_sets)
immler@50088
   205
        then interpret finite_measure "P' n" ..
immler@50088
   206
        show "\<exists>K. emeasure (P (J n)) (B n) - emeasure (P' n) K \<le> ereal (2 powr - real n) * ?a \<and>
immler@50088
   207
            compact K \<and> K \<subseteq> fm n ` B n"
immler@50088
   208
          unfolding R
immler@50088
   209
        proof (rule ccontr)
immler@50088
   210
          assume H: "\<not> (\<exists>K'. ?SUP n - emeasure (P' n) K' \<le> ereal (2 powr - real n)  * ?a \<and>
immler@50088
   211
            compact K' \<and> K' \<subseteq> fm n ` B n)"
immler@50088
   212
          have "?SUP n \<le> ?SUP n - 2 powr (-n) * ?a"
immler@50088
   213
          proof (intro SUP_least)
immler@50088
   214
            fix K
immler@50088
   215
            assume "K \<in> {K. K \<subseteq> fm n ` B n \<and> compact K}"
immler@50088
   216
            with H have "\<not> ?SUP n - emeasure (P' n) K \<le> 2 powr (-n) * ?a"
immler@50088
   217
              by auto
immler@50088
   218
            hence "?SUP n - emeasure (P' n) K > 2 powr (-n) * ?a"
immler@50088
   219
              unfolding not_less[symmetric] by simp
immler@50088
   220
            hence "?SUP n - 2 powr (-n) * ?a > emeasure (P' n) K"
immler@50088
   221
              using `0 < ?a` by (auto simp add: ereal_less_minus_iff ac_simps)
immler@50088
   222
            thus "?SUP n - 2 powr (-n) * ?a \<ge> emeasure (P' n) K" by simp
immler@50088
   223
          qed
immler@50088
   224
          hence "?SUP n + 0 \<le> ?SUP n - (2 powr (-n) * ?a)" using `0 < ?a` by simp
immler@50088
   225
          hence "?SUP n + 0 \<le> ?SUP n + - (2 powr (-n) * ?a)" unfolding minus_ereal_def .
immler@50088
   226
          hence "0 \<le> - (2 powr (-n) * ?a)"
immler@50088
   227
            using `?SUP _ \<noteq> \<infinity>` `?SUP _ \<noteq> - \<infinity>`
immler@50088
   228
            by (subst (asm) ereal_add_le_add_iff) (auto simp:)
immler@50088
   229
          moreover have "ereal (2 powr - real n) * ?a > 0" using `0 < ?a`
immler@50088
   230
            by (auto simp: ereal_zero_less_0_iff)
immler@50088
   231
          ultimately show False by simp
immler@50088
   232
        qed
immler@50088
   233
      qed
immler@50088
   234
      then obtain K' where K':
immler@50088
   235
        "\<And>n. emeasure (P (J n)) (B n) - emeasure (P' n) (K' n) \<le> ereal (2 powr - real n) * ?a"
immler@50088
   236
        "\<And>n. compact (K' n)" "\<And>n. K' n \<subseteq> fm n ` B n"
immler@50088
   237
        unfolding choice_iff by blast
immler@50088
   238
      def K \<equiv> "\<lambda>n. fm n -` K' n \<inter> space (Pi\<^isub>M (J n) (\<lambda>_. borel))"
immler@50088
   239
      have K_sets: "\<And>n. K n \<in> sets (Pi\<^isub>M (J n) (\<lambda>_. borel))"
immler@50088
   240
        unfolding K_def
immler@50088
   241
        using compact_imp_closed[OF `compact (K' _)`]
immler@50088
   242
        by (intro measurable_sets[OF fm_measurable, of _ "Collect finite"])
immler@50088
   243
           (auto simp: borel_eq_PiF_borel[symmetric])
immler@50088
   244
      have K_B: "\<And>n. K n \<subseteq> B n"
immler@50088
   245
      proof
immler@50088
   246
        fix x n
immler@50088
   247
        assume "x \<in> K n" hence fm_in: "fm n x \<in> fm n ` B n"
immler@50088
   248
          using K' by (force simp: K_def)
immler@50088
   249
        show "x \<in> B n"
immler@50244
   250
          using `x \<in> K n` K_sets sets.sets_into_space J[of n]
immler@50244
   251
          by (intro inj_on_image_mem_iff[OF inj_on_fm _ fm_in, of "\<lambda>_. borel"]) auto
immler@50088
   252
      qed
immler@50088
   253
      def Z' \<equiv> "\<lambda>n. emb I (J n) (K n)"
immler@50088
   254
      have Z': "\<And>n. Z' n \<subseteq> Z n"
immler@50088
   255
        unfolding Z_eq unfolding Z'_def
immler@50088
   256
      proof (rule prod_emb_mono, safe)
immler@50088
   257
        fix n x assume "x \<in> K n"
immler@50088
   258
        hence "fm n x \<in> K' n" "x \<in> space (Pi\<^isub>M (J n) (\<lambda>_. borel))"
immler@50088
   259
          by (simp_all add: K_def proj_space)
immler@50088
   260
        note this(1)
immler@50088
   261
        also have "K' n \<subseteq> fm n ` B n" by (simp add: K')
immler@50088
   262
        finally have "fm n x \<in> fm n ` B n" .
immler@50088
   263
        thus "x \<in> B n"
immler@50088
   264
        proof safe
immler@50088
   265
          fix y assume "y \<in> B n"
immler@50088
   266
          moreover
immler@50244
   267
          hence "y \<in> space (Pi\<^isub>M (J n) (\<lambda>_. borel))" using J sets.sets_into_space[of "B n" "P (J n)"]
immler@50088
   268
            by (auto simp add: proj_space proj_sets)
immler@50088
   269
          assume "fm n x = fm n y"
immler@50088
   270
          note inj_onD[OF inj_on_fm[OF space_borel],
immler@50088
   271
            OF `fm n x = fm n y` `x \<in> space _` `y \<in> space _`]
immler@50088
   272
          ultimately show "x \<in> B n" by simp
immler@50088
   273
        qed
immler@50088
   274
      qed
immler@50088
   275
      { fix n
immler@50088
   276
        have "Z' n \<in> ?G" using K' unfolding Z'_def
immler@50088
   277
          apply (intro generatorI'[OF J(1-3)])
immler@50088
   278
          unfolding K_def proj_space
immler@50088
   279
          apply (rule measurable_sets[OF fm_measurable[of _ "Collect finite"]])
immler@50088
   280
          apply (auto simp add: P'_def borel_eq_PiF_borel[symmetric] compact_imp_closed)
immler@50088
   281
          done
immler@50088
   282
      }
immler@50088
   283
      def Y \<equiv> "\<lambda>n. \<Inter>i\<in>{1..n}. Z' i"
immler@50088
   284
      hence "\<And>n k. Y (n + k) \<subseteq> Y n" by (induct_tac k) (auto simp: Y_def)
immler@50088
   285
      hence Y_mono: "\<And>n m. n \<le> m \<Longrightarrow> Y m \<subseteq> Y n" by (auto simp: le_iff_add)
immler@50088
   286
      have Y_Z': "\<And>n. n \<ge> 1 \<Longrightarrow> Y n \<subseteq> Z' n" by (auto simp: Y_def)
immler@50088
   287
      hence Y_Z: "\<And>n. n \<ge> 1 \<Longrightarrow> Y n \<subseteq> Z n" using Z' by auto
immler@50088
   288
      have Y_notempty: "\<And>n. n \<ge> 1 \<Longrightarrow> (Y n) \<noteq> {}"
immler@50088
   289
      proof -
immler@50088
   290
        fix n::nat assume "n \<ge> 1" hence "Y n \<subseteq> Z n" by fact
immler@50088
   291
        have "Y n = (\<Inter> i\<in>{1..n}. emb I (J n) (emb (J n) (J i) (K i)))" using J J_mono
immler@50088
   292
          by (auto simp: Y_def Z'_def)
immler@50088
   293
        also have "\<dots> = prod_emb I (\<lambda>_. borel) (J n) (\<Inter> i\<in>{1..n}. emb (J n) (J i) (K i))"
immler@50088
   294
          using `n \<ge> 1`
immler@50088
   295
          by (subst prod_emb_INT) auto
immler@50088
   296
        finally
immler@50088
   297
        have Y_emb:
immler@50088
   298
          "Y n = prod_emb I (\<lambda>_. borel) (J n)
immler@50088
   299
            (\<Inter> i\<in>{1..n}. prod_emb (J n) (\<lambda>_. borel) (J i) (K i))" .
immler@50088
   300
        hence "Y n \<in> ?G" using J J_mono K_sets `n \<ge> 1` by (intro generatorI[OF _ _ _ _ Y_emb]) auto
immler@50088
   301
        hence "\<bar>\<mu>G (Y n)\<bar> \<noteq> \<infinity>" unfolding Y_emb using J J_mono K_sets `n \<ge> 1`
wenzelm@50252
   302
          by (subst mu_G_eq) (auto simp: limP_finite proj_sets mu_G_eq)
immler@50095
   303
        interpret finite_measure "(limP (J n) (\<lambda>_. borel) P)"
immler@50088
   304
        proof
immler@50095
   305
          have "emeasure (limP (J n) (\<lambda>_. borel) P) (J n \<rightarrow>\<^isub>E space borel) \<noteq> \<infinity>"
immler@50095
   306
            using J by (subst emeasure_limP) auto
immler@50095
   307
          thus  "emeasure (limP (J n) (\<lambda>_. borel) P) (space (limP (J n) (\<lambda>_. borel) P)) \<noteq> \<infinity>"
immler@50088
   308
             by (simp add: space_PiM)
immler@50088
   309
        qed
immler@50095
   310
        have "\<mu>G (Z n) = limP (J n) (\<lambda>_. borel) P (B n)"
wenzelm@50252
   311
          unfolding Z_eq using J by (auto simp: mu_G_eq)
immler@50088
   312
        moreover have "\<mu>G (Y n) =
immler@50095
   313
          limP (J n) (\<lambda>_. borel) P (\<Inter>i\<in>{Suc 0..n}. prod_emb (J n) (\<lambda>_. borel) (J i) (K i))"
wenzelm@50252
   314
          unfolding Y_emb using J J_mono K_sets `n \<ge> 1` by (subst mu_G_eq) auto
immler@50095
   315
        moreover have "\<mu>G (Z n - Y n) = limP (J n) (\<lambda>_. borel) P
immler@50088
   316
          (B n - (\<Inter>i\<in>{Suc 0..n}. prod_emb (J n) (\<lambda>_. borel) (J i) (K i)))"
immler@50088
   317
          unfolding Z_eq Y_emb prod_emb_Diff[symmetric] using J J_mono K_sets `n \<ge> 1`
wenzelm@50252
   318
          by (subst mu_G_eq) (auto intro!: sets.Diff)
immler@50088
   319
        ultimately
immler@50088
   320
        have "\<mu>G (Z n) - \<mu>G (Y n) = \<mu>G (Z n - Y n)"
immler@50088
   321
          using J J_mono K_sets `n \<ge> 1`
immler@50088
   322
          by (simp only: emeasure_eq_measure)
immler@50088
   323
            (auto dest!: bspec[where x=n]
immler@50088
   324
            simp: extensional_restrict emeasure_eq_measure prod_emb_iff
immler@50088
   325
            intro!: measure_Diff[symmetric] set_mp[OF K_B])
immler@50088
   326
        also have subs: "Z n - Y n \<subseteq> (\<Union> i\<in>{1..n}. (Z i - Z' i))" using Z' Z `n \<ge> 1`
immler@50088
   327
          unfolding Y_def by (force simp: decseq_def)
immler@50088
   328
        have "Z n - Y n \<in> ?G" "(\<Union> i\<in>{1..n}. (Z i - Z' i)) \<in> ?G"
immler@50088
   329
          using `Z' _ \<in> ?G` `Z _ \<in> ?G` `Y _ \<in> ?G` by auto
immler@50088
   330
        hence "\<mu>G (Z n - Y n) \<le> \<mu>G (\<Union> i\<in>{1..n}. (Z i - Z' i))"
wenzelm@50252
   331
          using subs G.additive_increasing[OF positive_mu_G[OF `I \<noteq> {}`] additive_mu_G[OF `I \<noteq> {}`]]
immler@50088
   332
          unfolding increasing_def by auto
immler@50088
   333
        also have "\<dots> \<le> (\<Sum> i\<in>{1..n}. \<mu>G (Z i - Z' i))" using `Z _ \<in> ?G` `Z' _ \<in> ?G`
wenzelm@50252
   334
          by (intro G.subadditive[OF positive_mu_G additive_mu_G, OF `I \<noteq> {}` `I \<noteq> {}`]) auto
immler@50088
   335
        also have "\<dots> \<le> (\<Sum> i\<in>{1..n}. 2 powr -real i * ?a)"
immler@50088
   336
        proof (rule setsum_mono)
immler@50088
   337
          fix i assume "i \<in> {1..n}" hence "i \<le> n" by simp
immler@50088
   338
          have "\<mu>G (Z i - Z' i) = \<mu>G (prod_emb I (\<lambda>_. borel) (J i) (B i - K i))"
immler@50088
   339
            unfolding Z'_def Z_eq by simp
immler@50088
   340
          also have "\<dots> = P (J i) (B i - K i)"
wenzelm@50252
   341
            apply (subst mu_G_eq) using J K_sets apply auto
immler@50095
   342
            apply (subst limP_finite) apply auto
immler@50088
   343
            done
immler@50088
   344
          also have "\<dots> = P (J i) (B i) - P (J i) (K i)"
immler@50088
   345
            apply (subst emeasure_Diff) using K_sets J `K _ \<subseteq> B _` apply (auto simp: proj_sets)
immler@50088
   346
            done
immler@50088
   347
          also have "\<dots> = P (J i) (B i) - P' i (K' i)"
immler@50088
   348
            unfolding K_def P'_def
immler@50088
   349
            by (auto simp: mapmeasure_PiF proj_space proj_sets borel_eq_PiF_borel[symmetric]
hoelzl@50123
   350
              compact_imp_closed[OF `compact (K' _)`] space_PiM PiE_def)
immler@50088
   351
          also have "\<dots> \<le> ereal (2 powr - real i) * ?a" using K'(1)[of i] .
immler@50088
   352
          finally show "\<mu>G (Z i - Z' i) \<le> (2 powr - real i) * ?a" .
immler@50088
   353
        qed
immler@50088
   354
        also have "\<dots> = (\<Sum> i\<in>{1..n}. ereal (2 powr -real i) * ereal(real ?a))"
immler@50088
   355
          using `?a \<noteq> \<infinity>` `?a \<noteq> - \<infinity>` by (subst ereal_real') auto
immler@50088
   356
        also have "\<dots> = ereal (\<Sum> i\<in>{1..n}. (2 powr -real i) * (real ?a))" by simp
immler@50088
   357
        also have "\<dots> = ereal ((\<Sum> i\<in>{1..n}. (2 powr -real i)) * real ?a)"
immler@50088
   358
          by (simp add: setsum_left_distrib)
immler@50088
   359
        also have "\<dots> < ereal (1 * real ?a)" unfolding less_ereal.simps
immler@50088
   360
        proof (rule mult_strict_right_mono)
immler@50088
   361
          have "(\<Sum>i\<in>{1..n}. 2 powr - real i) = (\<Sum>i\<in>{1..<Suc n}. (1/2) ^ i)"
immler@50088
   362
            by (rule setsum_cong)
immler@50088
   363
               (auto simp: powr_realpow[symmetric] powr_minus powr_divide inverse_eq_divide)
immler@50088
   364
          also have "{1..<Suc n} = {0..<Suc n} - {0}" by auto
immler@50088
   365
          also have "setsum (op ^ (1 / 2::real)) ({0..<Suc n} - {0}) =
immler@50088
   366
            setsum (op ^ (1 / 2)) ({0..<Suc n}) - 1" by (auto simp: setsum_diff1)
immler@50088
   367
          also have "\<dots> < 1" by (subst sumr_geometric) auto
immler@50088
   368
          finally show "(\<Sum>i = 1..n. 2 powr - real i) < 1" .
immler@50088
   369
        qed (auto simp:
immler@50088
   370
          `0 < ?a` `?a \<noteq> \<infinity>` `?a \<noteq> - \<infinity>` ereal_less_real_iff zero_ereal_def[symmetric])
immler@50088
   371
        also have "\<dots> = ?a" using `0 < ?a` `?a \<noteq> \<infinity>` by (auto simp: ereal_real')
immler@50088
   372
        also have "\<dots> \<le> \<mu>G (Z n)" by (auto intro: INF_lower)
immler@50088
   373
        finally have "\<mu>G (Z n) - \<mu>G (Y n) < \<mu>G (Z n)" .
immler@50088
   374
        hence R: "\<mu>G (Z n) < \<mu>G (Z n) + \<mu>G (Y n)"
immler@50088
   375
          using `\<bar>\<mu>G (Y n)\<bar> \<noteq> \<infinity>` by (simp add: ereal_minus_less)
immler@50088
   376
        have "0 \<le> (- \<mu>G (Z n)) + \<mu>G (Z n)" using `\<bar>\<mu>G (Z n)\<bar> \<noteq> \<infinity>` by auto
immler@50088
   377
        also have "\<dots> < (- \<mu>G (Z n)) + (\<mu>G (Z n) + \<mu>G (Y n))"
immler@50088
   378
          apply (rule ereal_less_add[OF _ R]) using `\<bar>\<mu>G (Z n)\<bar> \<noteq> \<infinity>` by auto
immler@50088
   379
        finally have "\<mu>G (Y n) > 0"
immler@50088
   380
          using `\<bar>\<mu>G (Z n)\<bar> \<noteq> \<infinity>` by (auto simp: ac_simps zero_ereal_def[symmetric])
wenzelm@50252
   381
        thus "Y n \<noteq> {}" using positive_mu_G `I \<noteq> {}` by (auto simp add: positive_def)
immler@50088
   382
      qed
immler@50088
   383
      hence "\<forall>n\<in>{1..}. \<exists>y. y \<in> Y n" by auto
immler@50088
   384
      then obtain y where y: "\<And>n. n \<ge> 1 \<Longrightarrow> y n \<in> Y n" unfolding bchoice_iff by force
immler@50088
   385
      {
immler@50088
   386
        fix t and n m::nat
immler@50088
   387
        assume "1 \<le> n" "n \<le> m" hence "1 \<le> m" by simp
immler@50088
   388
        from Y_mono[OF `m \<ge> n`] y[OF `1 \<le> m`] have "y m \<in> Y n" by auto
immler@50088
   389
        also have "\<dots> \<subseteq> Z' n" using Y_Z'[OF `1 \<le> n`] .
immler@50088
   390
        finally
immler@50088
   391
        have "fm n (restrict (y m) (J n)) \<in> K' n"
immler@50088
   392
          unfolding Z'_def K_def prod_emb_iff by (simp add: Z'_def K_def prod_emb_iff)
immler@50088
   393
        moreover have "finmap_of (J n) (restrict (y m) (J n)) = finmap_of (J n) (y m)"
immler@50088
   394
          using J by (simp add: fm_def)
immler@50088
   395
        ultimately have "fm n (y m) \<in> K' n" by simp
immler@50088
   396
      } note fm_in_K' = this
immler@50088
   397
      interpret finmap_seqs_into_compact "\<lambda>n. K' (Suc n)" "\<lambda>k. fm (Suc k) (y (Suc k))" borel
immler@50088
   398
      proof
immler@50088
   399
        fix n show "compact (K' n)" by fact
immler@50088
   400
      next
immler@50088
   401
        fix n
immler@50088
   402
        from Y_mono[of n "Suc n"] y[of "Suc n"] have "y (Suc n) \<in> Y (Suc n)" by auto
immler@50088
   403
        also have "\<dots> \<subseteq> Z' (Suc n)" using Y_Z' by auto
immler@50088
   404
        finally
immler@50088
   405
        have "fm (Suc n) (restrict (y (Suc n)) (J (Suc n))) \<in> K' (Suc n)"
immler@50088
   406
          unfolding Z'_def K_def prod_emb_iff by (simp add: Z'_def K_def prod_emb_iff)
immler@50088
   407
        thus "K' (Suc n) \<noteq> {}" by auto
immler@50088
   408
        fix k
immler@50088
   409
        assume "k \<in> K' (Suc n)"
immler@50244
   410
        with K'[of "Suc n"] sets.sets_into_space have "k \<in> fm (Suc n) ` B (Suc n)" by auto
immler@50088
   411
        then obtain b where "k = fm (Suc n) b" by auto
immler@50088
   412
        thus "domain k = domain (fm (Suc n) (y (Suc n)))"
immler@50088
   413
          by (simp_all add: fm_def)
immler@50088
   414
      next
immler@50088
   415
        fix t and n m::nat
immler@50088
   416
        assume "n \<le> m" hence "Suc n \<le> Suc m" by simp
immler@50088
   417
        assume "t \<in> domain (fm (Suc n) (y (Suc n)))"
immler@50088
   418
        then obtain j where j: "t = Utn j" "j \<in> J (Suc n)" by auto
immler@50088
   419
        hence "j \<in> J (Suc m)" using J_mono[OF `Suc n \<le> Suc m`] by auto
immler@50088
   420
        have img: "fm (Suc n) (y (Suc m)) \<in> K' (Suc n)" using `n \<le> m`
immler@50088
   421
          by (intro fm_in_K') simp_all
immler@50088
   422
        show "(fm (Suc m) (y (Suc m)))\<^isub>F t \<in> (\<lambda>k. (k)\<^isub>F t) ` K' (Suc n)"
immler@50088
   423
          apply (rule image_eqI[OF _ img])
immler@50088
   424
          using `j \<in> J (Suc n)` `j \<in> J (Suc m)`
immler@50088
   425
          unfolding j by (subst proj_fm, auto)+
immler@50088
   426
      qed
immler@50088
   427
      have "\<forall>t. \<exists>z. (\<lambda>i. (fm (Suc (diagseq i)) (y (Suc (diagseq i))))\<^isub>F t) ----> z"
immler@50088
   428
        using diagonal_tendsto ..
immler@50088
   429
      then obtain z where z:
immler@50088
   430
        "\<And>t. (\<lambda>i. (fm (Suc (diagseq i)) (y (Suc (diagseq i))))\<^isub>F t) ----> z t"
immler@50088
   431
        unfolding choice_iff by blast
immler@50088
   432
      {
immler@50088
   433
        fix n :: nat assume "n \<ge> 1"
immler@50088
   434
        have "\<And>i. domain (fm n (y (Suc (diagseq i)))) = domain (finmap_of (Utn ` J n) z)"
immler@50088
   435
          by simp
immler@50088
   436
        moreover
immler@50088
   437
        {
immler@50088
   438
          fix t
immler@50088
   439
          assume t: "t \<in> domain (finmap_of (Utn ` J n) z)"
immler@50088
   440
          hence "t \<in> Utn ` J n" by simp
immler@50088
   441
          then obtain j where j: "t = Utn j" "j \<in> J n" by auto
immler@50088
   442
          have "(\<lambda>i. (fm n (y (Suc (diagseq i))))\<^isub>F t) ----> z t"
immler@50088
   443
            apply (subst (2) tendsto_iff, subst eventually_sequentially)
immler@50088
   444
          proof safe
immler@50088
   445
            fix e :: real assume "0 < e"
immler@50088
   446
            { fix i x assume "i \<ge> n" "t \<in> domain (fm n x)"
immler@50088
   447
              moreover
immler@50088
   448
              hence "t \<in> domain (fm i x)" using J_mono[OF `i \<ge> n`] by auto
immler@50088
   449
              ultimately have "(fm i x)\<^isub>F t = (fm n x)\<^isub>F t"
immler@50243
   450
                using j by (auto simp: proj_fm dest!: inj_onD[OF inj_on_Utn])
immler@50088
   451
            } note index_shift = this
immler@50088
   452
            have I: "\<And>i. i \<ge> n \<Longrightarrow> Suc (diagseq i) \<ge> n"
immler@50088
   453
              apply (rule le_SucI)
immler@50088
   454
              apply (rule order_trans) apply simp
immler@50088
   455
              apply (rule seq_suble[OF subseq_diagseq])
immler@50088
   456
              done
immler@50088
   457
            from z
immler@50088
   458
            have "\<exists>N. \<forall>i\<ge>N. dist ((fm (Suc (diagseq i)) (y (Suc (diagseq i))))\<^isub>F t) (z t) < e"
immler@50088
   459
              unfolding tendsto_iff eventually_sequentially using `0 < e` by auto
immler@50088
   460
            then obtain N where N: "\<And>i. i \<ge> N \<Longrightarrow>
immler@50088
   461
              dist ((fm (Suc (diagseq i)) (y (Suc (diagseq i))))\<^isub>F t) (z t) < e" by auto
immler@50088
   462
            show "\<exists>N. \<forall>na\<ge>N. dist ((fm n (y (Suc (diagseq na))))\<^isub>F t) (z t) < e "
immler@50088
   463
            proof (rule exI[where x="max N n"], safe)
immler@50088
   464
              fix na assume "max N n \<le> na"
immler@50088
   465
              hence  "dist ((fm n (y (Suc (diagseq na))))\<^isub>F t) (z t) =
immler@50088
   466
                      dist ((fm (Suc (diagseq na)) (y (Suc (diagseq na))))\<^isub>F t) (z t)" using t
immler@50088
   467
                by (subst index_shift[OF I]) auto
immler@50088
   468
              also have "\<dots> < e" using `max N n \<le> na` by (intro N) simp
immler@50088
   469
              finally show "dist ((fm n (y (Suc (diagseq na))))\<^isub>F t) (z t) < e" .
immler@50088
   470
            qed
immler@50088
   471
          qed
immler@50088
   472
          hence "(\<lambda>i. (fm n (y (Suc (diagseq i))))\<^isub>F t) ----> (finmap_of (Utn ` J n) z)\<^isub>F t"
immler@50088
   473
            by (simp add: tendsto_intros)
immler@50088
   474
        } ultimately
immler@50088
   475
        have "(\<lambda>i. fm n (y (Suc (diagseq i)))) ----> finmap_of (Utn ` J n) z"
immler@50088
   476
          by (rule tendsto_finmap)
immler@50088
   477
        hence "((\<lambda>i. fm n (y (Suc (diagseq i)))) o (\<lambda>i. i + n)) ----> finmap_of (Utn ` J n) z"
immler@50088
   478
          by (intro lim_subseq) (simp add: subseq_def)
immler@50088
   479
        moreover
immler@50088
   480
        have "(\<forall>i. ((\<lambda>i. fm n (y (Suc (diagseq i)))) o (\<lambda>i. i + n)) i \<in> K' n)"
immler@50088
   481
          apply (auto simp add: o_def intro!: fm_in_K' `1 \<le> n` le_SucI)
immler@50088
   482
          apply (rule le_trans)
immler@50088
   483
          apply (rule le_add2)
immler@50088
   484
          using seq_suble[OF subseq_diagseq]
immler@50088
   485
          apply auto
immler@50088
   486
          done
immler@50088
   487
        moreover
immler@50088
   488
        from `compact (K' n)` have "closed (K' n)" by (rule compact_imp_closed)
immler@50088
   489
        ultimately
immler@50088
   490
        have "finmap_of (Utn ` J n) z \<in> K' n"
immler@50088
   491
          unfolding closed_sequential_limits by blast
immler@50088
   492
        also have "finmap_of (Utn ` J n) z  = fm n (\<lambda>i. z (Utn i))"
immler@50243
   493
          unfolding finmap_eq_iff
immler@50243
   494
        proof clarsimp
immler@50243
   495
          fix i assume "i \<in> J n"
immler@50243
   496
          moreover hence "from_nat_into (\<Union>n. J n) (Utn i) = i"
immler@50243
   497
            unfolding Utn_def
immler@50243
   498
            by (subst from_nat_into_to_nat_on[OF countable_UN_J]) auto
immler@50243
   499
          ultimately show "z (Utn i) = (fm n (\<lambda>i. z (Utn i)))\<^isub>F (Utn i)"
immler@50243
   500
            by (simp add: finmap_eq_iff fm_def compose_def)
immler@50243
   501
        qed
immler@50088
   502
        finally have "fm n (\<lambda>i. z (Utn i)) \<in> K' n" .
immler@50088
   503
        moreover
immler@50088
   504
        let ?J = "\<Union>n. J n"
immler@50088
   505
        have "(?J \<inter> J n) = J n" by auto
immler@50088
   506
        ultimately have "restrict (\<lambda>i. z (Utn i)) (?J \<inter> J n) \<in> K n"
immler@50088
   507
          unfolding K_def by (auto simp: proj_space space_PiM)
immler@50088
   508
        hence "restrict (\<lambda>i. z (Utn i)) ?J \<in> Z' n" unfolding Z'_def
hoelzl@50123
   509
          using J by (auto simp: prod_emb_def PiE_def extensional_def)
immler@50088
   510
        also have "\<dots> \<subseteq> Z n" using Z' by simp
immler@50088
   511
        finally have "restrict (\<lambda>i. z (Utn i)) ?J \<in> Z n" .
immler@50088
   512
      } note in_Z = this
immler@50088
   513
      hence "(\<Inter>i\<in>{1..}. Z i) \<noteq> {}" by auto
immler@50088
   514
      hence "(\<Inter>i. Z i) \<noteq> {}" using Z INT_decseq_offset[OF `decseq Z`] by simp
immler@50088
   515
      thus False using Z by simp
immler@50088
   516
    qed
immler@50088
   517
    ultimately show "(\<lambda>i. \<mu>G (Z i)) ----> 0"
hoelzl@51351
   518
      using LIMSEQ_INF[of "\<lambda>i. \<mu>G (Z i)"] by simp
immler@50088
   519
  qed
immler@50088
   520
  then guess \<mu> .. note \<mu> = this
immler@50088
   521
  def f \<equiv> "finmap_of J B"
immler@50095
   522
  show "emeasure (lim\<^isub>B I P) (emb I J (Pi\<^isub>E J B)) = emeasure (lim\<^isub>B J P) (Pi\<^isub>E J B)"
immler@50095
   523
  proof (subst emeasure_extend_measure_Pair[OF limP_def, of I "\<lambda>_. borel" \<mu>])
immler@50095
   524
    show "positive (sets (lim\<^isub>B I P)) \<mu>" "countably_additive (sets (lim\<^isub>B I P)) \<mu>"
immler@50095
   525
      using \<mu> unfolding sets_limP sets_PiM_generator by (auto simp: measure_space_def)
immler@50088
   526
  next
immler@50088
   527
    show "(J \<noteq> {} \<or> I = {}) \<and> finite J \<and> J \<subseteq> I \<and> B \<in> J \<rightarrow> sets borel"
immler@50088
   528
      using assms by (auto simp: f_def)
immler@50088
   529
  next
immler@50088
   530
    fix J and X::"'i \<Rightarrow> 'a set"
hoelzl@50123
   531
    show "prod_emb I (\<lambda>_. borel) J (Pi\<^isub>E J X) \<in> Pow (I \<rightarrow>\<^isub>E space borel)"
immler@50088
   532
      by (auto simp: prod_emb_def)
immler@50088
   533
    assume JX: "(J \<noteq> {} \<or> I = {}) \<and> finite J \<and> J \<subseteq> I \<and> X \<in> J \<rightarrow> sets borel"
immler@50088
   534
    hence "emb I J (Pi\<^isub>E J X) \<in> generator" using assms
immler@50088
   535
      by (intro generatorI[where J=J and X="Pi\<^isub>E J X"]) (auto intro: sets_PiM_I_finite)
immler@50088
   536
    hence "\<mu> (emb I J (Pi\<^isub>E J X)) = \<mu>G (emb I J (Pi\<^isub>E J X))" using \<mu> by simp
immler@50088
   537
    also have "\<dots> = emeasure (P J) (Pi\<^isub>E J X)"
immler@50088
   538
      using JX assms proj_sets
wenzelm@50252
   539
      by (subst mu_G_eq) (auto simp: mu_G_eq limP_finite intro: sets_PiM_I_finite)
immler@50088
   540
    finally show "\<mu> (emb I J (Pi\<^isub>E J X)) = emeasure (P J) (Pi\<^isub>E J X)" .
immler@50088
   541
  next
immler@50095
   542
    show "emeasure (P J) (Pi\<^isub>E J B) = emeasure (limP J (\<lambda>_. borel) P) (Pi\<^isub>E J B)"
immler@50095
   543
      using assms by (simp add: f_def limP_finite Pi_def)
immler@50088
   544
  qed
immler@50088
   545
qed
immler@50088
   546
immler@50088
   547
end
immler@50088
   548
immler@50090
   549
hide_const (open) PiF
immler@50090
   550
hide_const (open) Pi\<^isub>F
immler@50090
   551
hide_const (open) Pi'
immler@50090
   552
hide_const (open) Abs_finmap
immler@50090
   553
hide_const (open) Rep_finmap
immler@50090
   554
hide_const (open) finmap_of
immler@50090
   555
hide_const (open) proj
immler@50090
   556
hide_const (open) domain
immler@50245
   557
hide_const (open) basis_finmap
immler@50090
   558
immler@50095
   559
sublocale polish_projective \<subseteq> P!: prob_space "(lim\<^isub>B I P)"
immler@50088
   560
proof
immler@50095
   561
  show "emeasure (lim\<^isub>B I P) (space (lim\<^isub>B I P)) = 1"
immler@50088
   562
  proof cases
immler@50088
   563
    assume "I = {}"
hoelzl@50101
   564
    interpret prob_space "P {}" using proj_prob_space by simp
immler@50088
   565
    show ?thesis
immler@50095
   566
      by (simp add: space_PiM_empty limP_finite emeasure_space_1 `I = {}`)
immler@50088
   567
  next
immler@50088
   568
    assume "I \<noteq> {}"
immler@50088
   569
    then obtain i where "i \<in> I" by auto
hoelzl@50101
   570
    interpret prob_space "P {i}" using proj_prob_space by simp
immler@50095
   571
    have R: "(space (lim\<^isub>B I P)) = (emb I {i} (Pi\<^isub>E {i} (\<lambda>_. space borel)))"
immler@50088
   572
      by (auto simp: prod_emb_def space_PiM)
hoelzl@50123
   573
    moreover have "extensional {i} = space (P {i})" by (simp add: proj_space space_PiM PiE_def)
immler@50088
   574
    ultimately show ?thesis using `i \<in> I`
immler@50088
   575
      apply (subst R)
immler@50095
   576
      apply (subst emeasure_limB_emb_not_empty)
hoelzl@50123
   577
      apply (auto simp: limP_finite emeasure_space_1 PiE_def)
immler@50088
   578
      done
immler@50088
   579
  qed
immler@50088
   580
qed
immler@50088
   581
immler@50088
   582
context polish_projective begin
immler@50088
   583
immler@50095
   584
lemma emeasure_limB_emb:
immler@50088
   585
  assumes X: "J \<subseteq> I" "finite J" "\<forall>i\<in>J. B i \<in> sets borel"
immler@50095
   586
  shows "emeasure (lim\<^isub>B I P) (emb I J (Pi\<^isub>E J B)) = emeasure (P J) (Pi\<^isub>E J B)"
immler@50088
   587
proof cases
hoelzl@50101
   588
  interpret prob_space "P {}" using proj_prob_space by simp
immler@50088
   589
  assume "J = {}"
immler@50095
   590
  moreover have "emb I {} {\<lambda>x. undefined} = space (lim\<^isub>B I P)"
immler@50088
   591
    by (auto simp: space_PiM prod_emb_def)
immler@50095
   592
  moreover have "{\<lambda>x. undefined} = space (lim\<^isub>B {} P)"
immler@50088
   593
    by (auto simp: space_PiM prod_emb_def)
immler@50088
   594
  ultimately show ?thesis
immler@50095
   595
    by (simp add: P.emeasure_space_1 limP_finite emeasure_space_1 del: space_limP)
immler@50088
   596
next
immler@50088
   597
  assume "J \<noteq> {}" with X show ?thesis
immler@50095
   598
    by (subst emeasure_limB_emb_not_empty) (auto simp: limP_finite)
immler@50088
   599
qed
immler@50088
   600
immler@50095
   601
lemma measure_limB_emb:
immler@50088
   602
  assumes "J \<subseteq> I" "finite J" "\<forall>i\<in>J. B i \<in> sets borel"
immler@50095
   603
  shows "measure (lim\<^isub>B I P) (emb I J (Pi\<^isub>E J B)) = measure (P J) (Pi\<^isub>E J B)"
immler@50088
   604
proof -
hoelzl@50101
   605
  interpret prob_space "P J" using proj_prob_space assms by simp
immler@50088
   606
  show ?thesis
immler@50095
   607
    using emeasure_limB_emb[OF assms]
immler@50095
   608
    unfolding emeasure_eq_measure limP_finite[OF `finite J` `J \<subseteq> I`] P.emeasure_eq_measure
immler@50088
   609
    by simp
immler@50088
   610
qed
immler@50088
   611
immler@50088
   612
end
immler@50088
   613
immler@50088
   614
locale polish_product_prob_space =
immler@50088
   615
  product_prob_space "\<lambda>_. borel::('a::polish_space) measure" I for I::"'i set"
immler@50088
   616
immler@50088
   617
sublocale polish_product_prob_space \<subseteq> P: polish_projective I "\<lambda>J. PiM J (\<lambda>_. borel::('a) measure)"
immler@50088
   618
proof qed
immler@50088
   619
hoelzl@50125
   620
lemma (in polish_product_prob_space) limP_eq_PiM:
immler@50095
   621
  "I \<noteq> {} \<Longrightarrow> lim\<^isub>P I (\<lambda>_. borel) (\<lambda>J. PiM J (\<lambda>_. borel::('a) measure)) =
immler@50088
   622
    PiM I (\<lambda>_. borel)"
immler@50095
   623
  by (rule PiM_eq) (auto simp: emeasure_PiM emeasure_limB_emb)
immler@50088
   624
immler@50088
   625
end