src/HOL/Probability/Fin_Map.thy
author hoelzl
Mon, 19 Nov 2012 12:29:02 +0100
changeset 50123 69b35a75caf3
parent 50100 9af8721ecd20
child 50124 4161c834c2fd
permissions -rw-r--r--
merge extensional dependent function space from FuncSet with the one in Finite_Product_Measure
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50091
b3b5dc2350b7 corrected headers
immler
parents: 50088
diff changeset
     1
(*  Title:      HOL/Probability/Fin_Map.thy
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
     2
    Author:     Fabian Immler, TU M√ľnchen
32d1795cc77a added projective limit;
immler
parents:
diff changeset
     3
*)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
     4
50091
b3b5dc2350b7 corrected headers
immler
parents: 50088
diff changeset
     5
header {* Finite Maps *}
b3b5dc2350b7 corrected headers
immler
parents: 50088
diff changeset
     6
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
     7
theory Fin_Map
32d1795cc77a added projective limit;
immler
parents:
diff changeset
     8
imports Finite_Product_Measure
32d1795cc77a added projective limit;
immler
parents:
diff changeset
     9
begin
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    10
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    11
text {* Auxiliary type that is instantiated to @{class polish_space}, needed for the proof of
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    12
  projective limit. @{const extensional} functions are used for the representation in order to
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    13
  stay close to the developments of (finite) products @{const Pi\<^isub>E} and their sigma-algebra
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    14
  @{const Pi\<^isub>M}. *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    15
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    16
typedef ('i, 'a) finmap ("(_ \<Rightarrow>\<^isub>F /_)" [22, 21] 21) =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    17
  "{(I::'i set, f::'i \<Rightarrow> 'a). finite I \<and> f \<in> extensional I}" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    18
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    19
subsection {* Domain and Application *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    20
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    21
definition domain where "domain P = fst (Rep_finmap P)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    22
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    23
lemma finite_domain[simp, intro]: "finite (domain P)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    24
  by (cases P) (auto simp: domain_def Abs_finmap_inverse)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    25
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    26
definition proj ("_\<^isub>F" [1000] 1000) where "proj P i = snd (Rep_finmap P) i"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    27
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    28
declare [[coercion proj]]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    29
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    30
lemma extensional_proj[simp, intro]: "(P)\<^isub>F \<in> extensional (domain P)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    31
  by (cases P) (auto simp: domain_def Abs_finmap_inverse proj_def[abs_def])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    32
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    33
lemma proj_undefined[simp, intro]: "i \<notin> domain P \<Longrightarrow> P i = undefined"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    34
  using extensional_proj[of P] unfolding extensional_def by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    35
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    36
lemma finmap_eq_iff: "P = Q \<longleftrightarrow> (domain P = domain Q \<and> (\<forall>i\<in>domain P. P i = Q i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    37
  by (cases P, cases Q)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    38
     (auto simp add: Abs_finmap_inject extensional_def domain_def proj_def Abs_finmap_inverse
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    39
              intro: extensionalityI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    40
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    41
subsection {* Countable Finite Maps *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    42
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    43
instance finmap :: (countable, countable) countable
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    44
proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    45
  obtain mapper where mapper: "\<And>fm :: 'a \<Rightarrow>\<^isub>F 'b. set (mapper fm) = domain fm"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    46
    by (metis finite_list[OF finite_domain])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    47
  have "inj (\<lambda>fm. map (\<lambda>i. (i, (fm)\<^isub>F i)) (mapper fm))" (is "inj ?F")
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    48
  proof (rule inj_onI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    49
    fix f1 f2 assume "?F f1 = ?F f2"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    50
    then have "map fst (?F f1) = map fst (?F f2)" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    51
    then have "mapper f1 = mapper f2" by (simp add: comp_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    52
    then have "domain f1 = domain f2" by (simp add: mapper[symmetric])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    53
    with `?F f1 = ?F f2` show "f1 = f2"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    54
      unfolding `mapper f1 = mapper f2` map_eq_conv mapper
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    55
      by (simp add: finmap_eq_iff)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    56
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    57
  then show "\<exists>to_nat :: 'a \<Rightarrow>\<^isub>F 'b \<Rightarrow> nat. inj to_nat"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    58
    by (intro exI[of _ "to_nat \<circ> ?F"] inj_comp) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    59
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    60
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    61
subsection {* Constructor of Finite Maps *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    62
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    63
definition "finmap_of inds f = Abs_finmap (inds, restrict f inds)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    64
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    65
lemma proj_finmap_of[simp]:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    66
  assumes "finite inds"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    67
  shows "(finmap_of inds f)\<^isub>F = restrict f inds"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    68
  using assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    69
  by (auto simp: Abs_finmap_inverse finmap_of_def proj_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    70
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    71
lemma domain_finmap_of[simp]:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    72
  assumes "finite inds"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    73
  shows "domain (finmap_of inds f) = inds"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    74
  using assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    75
  by (auto simp: Abs_finmap_inverse finmap_of_def domain_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    76
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    77
lemma finmap_of_eq_iff[simp]:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    78
  assumes "finite i" "finite j"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    79
  shows "finmap_of i m = finmap_of j n \<longleftrightarrow> i = j \<and> restrict m i = restrict n i"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    80
  using assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    81
  apply (auto simp: finmap_eq_iff restrict_def) by metis
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    82
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    83
lemma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    84
  finmap_of_inj_on_extensional_finite:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    85
  assumes "finite K"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    86
  assumes "S \<subseteq> extensional K"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    87
  shows "inj_on (finmap_of K) S"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    88
proof (rule inj_onI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    89
  fix x y::"'a \<Rightarrow> 'b"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    90
  assume "finmap_of K x = finmap_of K y"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    91
  hence "(finmap_of K x)\<^isub>F = (finmap_of K y)\<^isub>F" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    92
  moreover
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    93
  assume "x \<in> S" "y \<in> S" hence "x \<in> extensional K" "y \<in> extensional K" using assms by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    94
  ultimately
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    95
  show "x = y" using assms by (simp add: extensional_restrict)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    96
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    97
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    98
lemma finmap_choice:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
    99
  assumes *: "\<And>i. i \<in> I \<Longrightarrow> \<exists>x. P i x" and I: "finite I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   100
  shows "\<exists>fm. domain fm = I \<and> (\<forall>i\<in>I. P i (fm i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   101
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   102
  have "\<exists>f. \<forall>i\<in>I. P i (f i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   103
    unfolding bchoice_iff[symmetric] using * by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   104
  then guess f ..
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   105
  with I show ?thesis
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   106
    by (intro exI[of _ "finmap_of I f"]) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   107
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   108
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   109
subsection {* Product set of Finite Maps *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   110
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   111
text {* This is @{term Pi} for Finite Maps, most of this is copied *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   112
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   113
definition Pi' :: "'i set \<Rightarrow> ('i \<Rightarrow> 'a set) \<Rightarrow> ('i \<Rightarrow>\<^isub>F 'a) set" where
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   114
  "Pi' I A = { P. domain P = I \<and> (\<forall>i. i \<in> I \<longrightarrow> (P)\<^isub>F i \<in> A i) } "
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   115
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   116
syntax
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   117
  "_Pi'"  :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3PI' _:_./ _)" 10)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   118
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   119
syntax (xsymbols)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   120
  "_Pi'" :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3\<Pi>' _\<in>_./ _)"   10)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   121
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   122
syntax (HTML output)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   123
  "_Pi'" :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3\<Pi>' _\<in>_./ _)"   10)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   124
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   125
translations
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   126
  "PI' x:A. B" == "CONST Pi' A (%x. B)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   127
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   128
abbreviation
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   129
  finmapset :: "['a set, 'b set] => ('a \<Rightarrow>\<^isub>F 'b) set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   130
    (infixr "~>" 60) where
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   131
  "A ~> B \<equiv> Pi' A (%_. B)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   132
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   133
notation (xsymbols)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   134
  finmapset  (infixr "\<leadsto>" 60)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   135
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   136
subsubsection{*Basic Properties of @{term Pi'}*}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   137
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   138
lemma Pi'_I[intro!]: "domain f = A \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> f x \<in> B x) \<Longrightarrow> f \<in> Pi' A B"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   139
  by (simp add: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   140
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   141
lemma Pi'_I'[simp]: "domain f = A \<Longrightarrow> (\<And>x. x \<in> A \<longrightarrow> f x \<in> B x) \<Longrightarrow> f \<in> Pi' A B"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   142
  by (simp add:Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   143
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   144
lemma finmapsetI: "domain f = A \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> f x \<in> B) \<Longrightarrow> f \<in> A \<leadsto> B"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   145
  by (simp add: Pi_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   146
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   147
lemma Pi'_mem: "f\<in> Pi' A B \<Longrightarrow> x \<in> A \<Longrightarrow> f x \<in> B x"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   148
  by (simp add: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   149
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   150
lemma Pi'_iff: "f \<in> Pi' I X \<longleftrightarrow> domain f = I \<and> (\<forall>i\<in>I. f i \<in> X i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   151
  unfolding Pi'_def by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   152
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   153
lemma Pi'E [elim]:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   154
  "f \<in> Pi' A B \<Longrightarrow> (f x \<in> B x \<Longrightarrow> domain f = A \<Longrightarrow> Q) \<Longrightarrow> (x \<notin> A \<Longrightarrow> Q) \<Longrightarrow> Q"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   155
  by(auto simp: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   156
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   157
lemma in_Pi'_cong:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   158
  "domain f = domain g \<Longrightarrow> (\<And> w. w \<in> A \<Longrightarrow> f w = g w) \<Longrightarrow> f \<in> Pi' A B \<longleftrightarrow> g \<in> Pi' A B"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   159
  by (auto simp: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   160
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   161
lemma funcset_mem: "[|f \<in> A \<leadsto> B; x \<in> A|] ==> f x \<in> B"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   162
  by (simp add: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   163
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   164
lemma funcset_image: "f \<in> A \<leadsto> B ==> f ` A \<subseteq> B"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   165
by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   166
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   167
lemma Pi'_eq_empty[simp]:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   168
  assumes "finite A" shows "(Pi' A B) = {} \<longleftrightarrow> (\<exists>x\<in>A. B x = {})"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   169
  using assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   170
  apply (simp add: Pi'_def, auto)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   171
  apply (drule_tac x = "finmap_of A (\<lambda>u. SOME y. y \<in> B u)" in spec, auto)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   172
  apply (cut_tac P= "%y. y \<in> B i" in some_eq_ex, auto)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   173
  done
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   174
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   175
lemma Pi'_mono: "(\<And>x. x \<in> A \<Longrightarrow> B x \<subseteq> C x) \<Longrightarrow> Pi' A B \<subseteq> Pi' A C"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   176
  by (auto simp: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   177
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   178
lemma Pi_Pi': "finite A \<Longrightarrow> (Pi\<^isub>E A B) = proj ` Pi' A B"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   179
  apply (auto simp: Pi'_def Pi_def extensional_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   180
  apply (rule_tac x = "finmap_of A (restrict x A)" in image_eqI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   181
  apply auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   182
  done
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   183
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   184
subsection {* Metric Space of Finite Maps *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   185
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   186
instantiation finmap :: (type, metric_space) metric_space
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   187
begin
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   188
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   189
definition dist_finmap where
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   190
  "dist P Q = (\<Sum>i\<in>domain P \<union> domain Q. dist ((P)\<^isub>F i) ((Q)\<^isub>F i)) +
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   191
    card ((domain P - domain Q) \<union> (domain Q - domain P))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   192
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   193
lemma dist_finmap_extend:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   194
  assumes "finite X"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   195
  shows "dist P Q = (\<Sum>i\<in>domain P \<union> domain Q \<union> X. dist ((P)\<^isub>F i) ((Q)\<^isub>F i)) +
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   196
    card ((domain P - domain Q) \<union> (domain Q - domain P))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   197
    unfolding dist_finmap_def add_right_cancel
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   198
    using assms extensional_arb[of "(P)\<^isub>F"] extensional_arb[of "(Q)\<^isub>F" "domain Q"]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   199
    by (intro setsum_mono_zero_cong_left) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   200
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   201
definition open_finmap :: "('a \<Rightarrow>\<^isub>F 'b) set \<Rightarrow> bool" where
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   202
  "open_finmap S = (\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   203
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   204
lemma add_eq_zero_iff[simp]:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   205
  fixes a b::real
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   206
  assumes "a \<ge> 0" "b \<ge> 0"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   207
  shows "a + b = 0 \<longleftrightarrow> a = 0 \<and> b = 0"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   208
using assms by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   209
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   210
lemma dist_le_1_imp_domain_eq:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   211
  assumes "dist P Q < 1"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   212
  shows "domain P = domain Q"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   213
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   214
  have "0 \<le> (\<Sum>i\<in>domain P \<union> domain Q. dist (P i) (Q i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   215
    by (simp add: setsum_nonneg)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   216
  with assms have "card (domain P - domain Q \<union> (domain Q - domain P)) = 0"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   217
    unfolding dist_finmap_def by arith
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   218
  thus "domain P = domain Q" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   219
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   220
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   221
lemma dist_proj:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   222
  shows "dist ((x)\<^isub>F i) ((y)\<^isub>F i) \<le> dist x y"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   223
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   224
  have "dist (x i) (y i) = (\<Sum>i\<in>{i}. dist (x i) (y i))" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   225
  also have "\<dots> \<le> (\<Sum>i\<in>domain x \<union> domain y \<union> {i}. dist (x i) (y i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   226
    by (intro setsum_mono2) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   227
  also have "\<dots> \<le> dist x y" by (simp add: dist_finmap_extend[of "{i}"])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   228
  finally show ?thesis by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   229
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   230
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   231
lemma open_Pi'I:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   232
  assumes open_component: "\<And>i. i \<in> I \<Longrightarrow> open (A i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   233
  shows "open (Pi' I A)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   234
proof (subst open_finmap_def, safe)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   235
  fix x assume x: "x \<in> Pi' I A"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   236
  hence dim_x: "domain x = I" by (simp add: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   237
  hence [simp]: "finite I" unfolding dim_x[symmetric] by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   238
  have "\<exists>ei. \<forall>i\<in>I. 0 < ei i \<and> (\<forall>y. dist y (x i) < ei i \<longrightarrow> y \<in> A i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   239
  proof (safe intro!: bchoice)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   240
    fix i assume i: "i \<in> I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   241
    moreover with open_component have "open (A i)" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   242
    moreover have "x i \<in> A i" using x i
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   243
      by (auto simp: proj_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   244
    ultimately show "\<exists>e>0. \<forall>y. dist y (x i) < e \<longrightarrow> y \<in> A i"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   245
      using x by (auto simp: open_dist Ball_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   246
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   247
  then guess ei .. note ei = this
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   248
  def es \<equiv> "ei ` I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   249
  def e \<equiv> "if es = {} then 0.5 else min 0.5 (Min es)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   250
  from ei have "e > 0" using x
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   251
    by (auto simp add: e_def es_def Pi'_def Ball_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   252
  moreover have "\<forall>y. dist y x < e \<longrightarrow> y \<in> Pi' I A"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   253
  proof (intro allI impI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   254
    fix y
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   255
    assume "dist y x < e"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   256
    also have "\<dots> < 1" by (auto simp: e_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   257
    finally have "domain y = domain x" by (rule dist_le_1_imp_domain_eq)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   258
    with dim_x have dims: "domain y = domain x" "domain x = I" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   259
    show "y \<in> Pi' I A"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   260
    proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   261
      show "domain y = I" using dims by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   262
    next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   263
      fix i
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   264
      assume "i \<in> I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   265
      have "dist (y i) (x i) \<le> dist y x" using dims `i \<in> I`
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   266
        by (auto intro: dist_proj)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   267
      also have "\<dots> < e" using `dist y x < e` dims
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   268
        by (simp add: dist_finmap_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   269
      also have "e \<le> Min (ei ` I)" using dims `i \<in> I`
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   270
        by (auto simp: e_def es_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   271
      also have "\<dots> \<le> ei i" using `i \<in> I` by (simp add: e_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   272
      finally have "dist (y i) (x i) < ei i" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   273
      with ei `i \<in> I` show "y i \<in> A  i" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   274
    qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   275
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   276
  ultimately
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   277
  show "\<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> Pi' I A" by blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   278
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   279
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   280
instance
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   281
proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   282
  fix S::"('a \<Rightarrow>\<^isub>F 'b) set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   283
  show "open S = (\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   284
    unfolding open_finmap_def ..
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   285
next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   286
  fix P Q::"'a \<Rightarrow>\<^isub>F 'b"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   287
  show "dist P Q = 0 \<longleftrightarrow> P = Q"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   288
    by (auto simp: finmap_eq_iff dist_finmap_def setsum_nonneg setsum_nonneg_eq_0_iff)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   289
next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   290
  fix P Q R::"'a \<Rightarrow>\<^isub>F 'b"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   291
  let ?symdiff = "\<lambda>a b. domain a - domain b \<union> (domain b - domain a)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   292
  def E \<equiv> "domain P \<union> domain Q \<union> domain R"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   293
  hence "finite E" by (simp add: E_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   294
  have "card (?symdiff P Q) \<le> card (?symdiff P R \<union> ?symdiff Q R)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   295
    by (auto intro: card_mono)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   296
  also have "\<dots> \<le> card (?symdiff P R) + card (?symdiff Q R)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   297
    by (subst card_Un_Int) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   298
  finally have "dist P Q \<le> (\<Sum>i\<in>E. dist (P i) (R i) + dist (Q i) (R i)) +
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   299
    real (card (?symdiff P R) + card (?symdiff Q R))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   300
    unfolding dist_finmap_extend[OF `finite E`]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   301
    by (intro add_mono) (auto simp: E_def intro: setsum_mono dist_triangle_le)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   302
  also have "\<dots> \<le> dist P R + dist Q R"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   303
    unfolding dist_finmap_extend[OF `finite E`] by (simp add: ac_simps E_def setsum_addf[symmetric])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   304
  finally show "dist P Q \<le> dist P R + dist Q R" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   305
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   306
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   307
end
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   308
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   309
lemma open_restricted_space:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   310
  shows "open {m. P (domain m)}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   311
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   312
  have "{m. P (domain m)} = (\<Union>i \<in> Collect P. {m. domain m = i})" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   313
  also have "open \<dots>"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   314
  proof (rule, safe, cases)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   315
    fix i::"'a set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   316
    assume "finite i"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   317
    hence "{m. domain m = i} = Pi' i (\<lambda>_. UNIV)" by (auto simp: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   318
    also have "open \<dots>" by (auto intro: open_Pi'I simp: `finite i`)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   319
    finally show "open {m. domain m = i}" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   320
  next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   321
    fix i::"'a set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   322
    assume "\<not> finite i" hence "{m. domain m = i} = {}" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   323
    also have "open \<dots>" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   324
    finally show "open {m. domain m = i}" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   325
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   326
  finally show ?thesis .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   327
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   328
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   329
lemma closed_restricted_space:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   330
  shows "closed {m. P (domain m)}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   331
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   332
  have "{m. P (domain m)} = - (\<Union>i \<in> - Collect P. {m. domain m = i})" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   333
  also have "closed \<dots>"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   334
  proof (rule, rule, rule, cases)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   335
    fix i::"'a set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   336
    assume "finite i"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   337
    hence "{m. domain m = i} = Pi' i (\<lambda>_. UNIV)" by (auto simp: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   338
    also have "open \<dots>" by (auto intro: open_Pi'I simp: `finite i`)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   339
    finally show "open {m. domain m = i}" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   340
  next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   341
    fix i::"'a set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   342
    assume "\<not> finite i" hence "{m. domain m = i} = {}" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   343
    also have "open \<dots>" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   344
    finally show "open {m. domain m = i}" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   345
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   346
  finally show ?thesis .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   347
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   348
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   349
lemma continuous_proj:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   350
  shows "continuous_on s (\<lambda>x. (x)\<^isub>F i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   351
  unfolding continuous_on_topological
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   352
proof safe
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   353
  fix x B assume "x \<in> s" "open B" "x i \<in> B"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   354
  let ?A = "Pi' (domain x) (\<lambda>j. if i = j then B else UNIV)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   355
  have "open ?A" using `open B` by (auto intro: open_Pi'I)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   356
  moreover have "x \<in> ?A" using `x i \<in> B` by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   357
  moreover have "(\<forall>y\<in>s. y \<in> ?A \<longrightarrow> y i \<in> B)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   358
  proof (cases, safe)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   359
    fix y assume "y \<in> s"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   360
    assume "i \<notin> domain x" hence "undefined \<in> B" using `x i \<in> B`
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   361
      by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   362
    moreover
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   363
    assume "y \<in> ?A" hence "domain y = domain x" by (simp add: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   364
    hence "y i = undefined" using `i \<notin> domain x` by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   365
    ultimately
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   366
    show "y i \<in> B" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   367
  qed force
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   368
  ultimately
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   369
  show "\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> y i \<in> B)" by blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   370
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   371
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   372
subsection {* Complete Space of Finite Maps *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   373
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   374
lemma tendsto_dist_zero:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   375
  assumes "(\<lambda>i. dist (f i) g) ----> 0"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   376
  shows "f ----> g"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   377
  using assms by (auto simp: tendsto_iff dist_real_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   378
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   379
lemma tendsto_dist_zero':
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   380
  assumes "(\<lambda>i. dist (f i) g) ----> x"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   381
  assumes "0 = x"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   382
  shows "f ----> g"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   383
  using assms tendsto_dist_zero by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   384
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   385
lemma tendsto_finmap:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   386
  fixes f::"nat \<Rightarrow> ('i \<Rightarrow>\<^isub>F ('a::metric_space))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   387
  assumes ind_f:  "\<And>n. domain (f n) = domain g"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   388
  assumes proj_g:  "\<And>i. i \<in> domain g \<Longrightarrow> (\<lambda>n. (f n) i) ----> g i"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   389
  shows "f ----> g"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   390
  apply (rule tendsto_dist_zero')
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   391
  unfolding dist_finmap_def assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   392
  apply (rule tendsto_intros proj_g | simp)+
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   393
  done
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   394
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   395
instance finmap :: (type, complete_space) complete_space
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   396
proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   397
  fix P::"nat \<Rightarrow> 'a \<Rightarrow>\<^isub>F 'b"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   398
  assume "Cauchy P"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   399
  then obtain Nd where Nd: "\<And>n. n \<ge> Nd \<Longrightarrow> dist (P n) (P Nd) < 1"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   400
    by (force simp: cauchy)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   401
  def d \<equiv> "domain (P Nd)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   402
  with Nd have dim: "\<And>n. n \<ge> Nd \<Longrightarrow> domain (P n) = d" using dist_le_1_imp_domain_eq by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   403
  have [simp]: "finite d" unfolding d_def by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   404
  def p \<equiv> "\<lambda>i n. (P n) i"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   405
  def q \<equiv> "\<lambda>i. lim (p i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   406
  def Q \<equiv> "finmap_of d q"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   407
  have q: "\<And>i. i \<in> d \<Longrightarrow> q i = Q i" by (auto simp add: Q_def Abs_finmap_inverse)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   408
  {
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   409
    fix i assume "i \<in> d"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   410
    have "Cauchy (p i)" unfolding cauchy p_def
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   411
    proof safe
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   412
      fix e::real assume "0 < e"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   413
      with `Cauchy P` obtain N where N: "\<And>n. n\<ge>N \<Longrightarrow> dist (P n) (P N) < min e 1"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   414
        by (force simp: cauchy min_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   415
      hence "\<And>n. n \<ge> N \<Longrightarrow> domain (P n) = domain (P N)" using dist_le_1_imp_domain_eq by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   416
      with dim have dim: "\<And>n. n \<ge> N \<Longrightarrow> domain (P n) = d" by (metis nat_le_linear)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   417
      show "\<exists>N. \<forall>n\<ge>N. dist ((P n) i) ((P N) i) < e"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   418
      proof (safe intro!: exI[where x="N"])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   419
        fix n assume "N \<le> n" have "N \<le> N" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   420
        have "dist ((P n) i) ((P N) i) \<le> dist (P n) (P N)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   421
          using dim[OF `N \<le> n`]  dim[OF `N \<le> N`] `i \<in> d`
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   422
          by (auto intro!: dist_proj)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   423
        also have "\<dots> < e" using N[OF `N \<le> n`] by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   424
        finally show "dist ((P n) i) ((P N) i) < e" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   425
      qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   426
    qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   427
    hence "convergent (p i)" by (metis Cauchy_convergent_iff)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   428
    hence "p i ----> q i" unfolding q_def convergent_def by (metis limI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   429
  } note p = this
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   430
  have "P ----> Q"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   431
  proof (rule metric_LIMSEQ_I)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   432
    fix e::real assume "0 < e"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   433
    def e' \<equiv> "min 1 (e / (card d + 1))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   434
    hence "0 < e'" using `0 < e` by (auto simp: e'_def intro: divide_pos_pos)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   435
    have "\<exists>ni. \<forall>i\<in>d. \<forall>n\<ge>ni i. dist (p i n) (q i) < e'"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   436
    proof (safe intro!: bchoice)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   437
      fix i assume "i \<in> d"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   438
      from p[OF `i \<in> d`, THEN metric_LIMSEQ_D, OF `0 < e'`]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   439
      show "\<exists>no. \<forall>n\<ge>no. dist (p i n) (q i) < e'" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   440
    qed then guess ni .. note ni = this
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   441
    def N \<equiv> "max Nd (Max (ni ` d))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   442
    show "\<exists>N. \<forall>n\<ge>N. dist (P n) Q < e"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   443
    proof (safe intro!: exI[where x="N"])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   444
      fix n assume "N \<le> n"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   445
      hence "domain (P n) = d" "domain Q = d" "domain (P n) = domain Q"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   446
        using dim by (simp_all add: N_def Q_def dim_def Abs_finmap_inverse)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   447
      hence "dist (P n) Q = (\<Sum>i\<in>d. dist ((P n) i) (Q i))" by (simp add: dist_finmap_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   448
      also have "\<dots> \<le> (\<Sum>i\<in>d. e')"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   449
      proof (intro setsum_mono less_imp_le)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   450
        fix i assume "i \<in> d"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   451
        hence "ni i \<le> Max (ni ` d)" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   452
        also have "\<dots> \<le> N" by (simp add: N_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   453
        also have "\<dots> \<le> n" using `N \<le> n` .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   454
        finally
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   455
        show "dist ((P n) i) (Q i) < e'"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   456
          using ni `i \<in> d` by (auto simp: p_def q N_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   457
      qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   458
      also have "\<dots> = card d * e'" by (simp add: real_eq_of_nat)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   459
      also have "\<dots> < e" using `0 < e` by (simp add: e'_def field_simps min_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   460
      finally show "dist (P n) Q < e" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   461
    qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   462
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   463
  thus "convergent P" by (auto simp: convergent_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   464
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   465
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   466
subsection {* Polish Space of Finite Maps *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   467
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   468
instantiation finmap :: (countable, polish_space) polish_space
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   469
begin
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   470
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   471
definition enum_basis_finmap :: "nat \<Rightarrow> ('a \<Rightarrow>\<^isub>F 'b) set" where
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   472
  "enum_basis_finmap n =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   473
  (let m = from_nat n::('a \<Rightarrow>\<^isub>F nat) in Pi' (domain m) (enum_basis o (m)\<^isub>F))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   474
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   475
lemma range_enum_basis_eq:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   476
  "range enum_basis_finmap = {Pi' I S|I S. finite I \<and> (\<forall>i \<in> I. S i \<in> range enum_basis)}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   477
proof (auto simp: enum_basis_finmap_def[abs_def])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   478
  fix S::"('a \<Rightarrow> 'b set)" and I
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   479
  assume "\<forall>i\<in>I. S i \<in> range enum_basis"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   480
  hence "\<forall>i\<in>I. \<exists>n. S i = enum_basis n" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   481
  then obtain n where n: "\<forall>i\<in>I. S i = enum_basis (n i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   482
    unfolding bchoice_iff by blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   483
  assume [simp]: "finite I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   484
  have "\<exists>fm. domain fm = I \<and> (\<forall>i\<in>I. n i = (fm i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   485
    by (rule finmap_choice) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   486
  then obtain m where "Pi' I S = Pi' (domain m) (enum_basis o m)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   487
    using n by (auto simp: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   488
  hence "Pi' I S = (let m = from_nat (to_nat m) in Pi' (domain m) (enum_basis \<circ> m))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   489
    by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   490
  thus "Pi' I S \<in> range (\<lambda>n. let m = from_nat n in Pi' (domain m) (enum_basis \<circ> m))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   491
    by blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   492
qed (metis finite_domain o_apply rangeI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   493
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   494
lemma in_enum_basis_finmapI:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   495
  assumes "finite I" assumes "\<And>i. i \<in> I \<Longrightarrow> S i \<in> range enum_basis"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   496
  shows "Pi' I S \<in> range enum_basis_finmap"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   497
  using assms unfolding range_enum_basis_eq by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   498
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   499
lemma finmap_topological_basis:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   500
  "topological_basis (range (enum_basis_finmap))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   501
proof (subst topological_basis_iff, safe)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   502
  fix n::nat
50094
84ddcf5364b4 allow arbitrary enumerations of basis in locale for generation of borel sets
immler
parents: 50091
diff changeset
   503
  show "open (enum_basis_finmap n::('a \<Rightarrow>\<^isub>F 'b) set)" using enum_basis_basis
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   504
    by (auto intro!: open_Pi'I simp: topological_basis_def enum_basis_finmap_def Let_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   505
next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   506
  fix O'::"('a \<Rightarrow>\<^isub>F 'b) set" and x
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   507
  assume "open O'" "x \<in> O'"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   508
  then obtain e where e: "e > 0" "\<And>y. dist y x < e \<Longrightarrow> y \<in> O'"  unfolding open_dist by blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   509
  def e' \<equiv> "e / (card (domain x) + 1)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   510
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   511
  have "\<exists>B.
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   512
    (\<forall>i\<in>domain x. x i \<in> enum_basis (B i) \<and> enum_basis (B i) \<subseteq> ball (x i) e')"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   513
  proof (rule bchoice, safe)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   514
    fix i assume "i \<in> domain x"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   515
    have "open (ball (x i) e')" "x i \<in> ball (x i) e'" using e
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   516
      by (auto simp add: e'_def intro!: divide_pos_pos)
50094
84ddcf5364b4 allow arbitrary enumerations of basis in locale for generation of borel sets
immler
parents: 50091
diff changeset
   517
    from topological_basisE[OF enum_basis_basis this] guess b' .
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   518
    thus "\<exists>y. x i \<in> enum_basis y \<and>
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   519
            enum_basis y \<subseteq> ball (x i) e'" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   520
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   521
  then guess B .. note B = this
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   522
  def B' \<equiv> "Pi' (domain x) (\<lambda>i. enum_basis (B i)::'b set)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   523
  hence "B' \<in> range enum_basis_finmap" unfolding B'_def
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   524
    by (intro in_enum_basis_finmapI) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   525
  moreover have "x \<in> B'" unfolding B'_def using B by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   526
  moreover have "B' \<subseteq> O'"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   527
  proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   528
    fix y assume "y \<in> B'" with B have "domain y = domain x" unfolding B'_def
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   529
      by (simp add: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   530
    show "y \<in> O'"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   531
    proof (rule e)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   532
      have "dist y x = (\<Sum>i \<in> domain x. dist (y i) (x i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   533
        using `domain y = domain x` by (simp add: dist_finmap_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   534
      also have "\<dots> \<le> (\<Sum>i \<in> domain x. e')"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   535
      proof (rule setsum_mono)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   536
        fix i assume "i \<in> domain x"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   537
        with `y \<in> B'` B have "y i \<in> enum_basis (B i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   538
          by (simp add: Pi'_def B'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   539
        hence "y i \<in> ball (x i) e'" using B `domain y = domain x` `i \<in> domain x`
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   540
          by force
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   541
        thus "dist (y i) (x i) \<le> e'" by (simp add: dist_commute)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   542
      qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   543
      also have "\<dots> = card (domain x) * e'" by (simp add: real_eq_of_nat)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   544
      also have "\<dots> < e" using e by (simp add: e'_def field_simps)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   545
      finally show "dist y x < e" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   546
    qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   547
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   548
  ultimately
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   549
  show "\<exists>B'\<in>range enum_basis_finmap. x \<in> B' \<and> B' \<subseteq> O'" by blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   550
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   551
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   552
lemma range_enum_basis_finmap_imp_open:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   553
  assumes "x \<in> range enum_basis_finmap"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   554
  shows "open x"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   555
  using finmap_topological_basis assms by (auto simp: topological_basis_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   556
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   557
lemma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   558
  open_imp_ex_UNION_of_enum:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   559
  fixes X::"('a \<Rightarrow>\<^isub>F 'b) set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   560
  assumes "open X" assumes "X \<noteq> {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   561
  shows "\<exists>A::nat\<Rightarrow>'a set. \<exists>B::nat\<Rightarrow>('a \<Rightarrow> 'b set) . X = UNION UNIV (\<lambda>i. Pi' (A i) (B i)) \<and>
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   562
    (\<forall>n. \<forall>i\<in>A n. (B n) i \<in> range enum_basis) \<and> (\<forall>n. finite (A n))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   563
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   564
  from `open X` obtain B' where B': "B'\<subseteq>range enum_basis_finmap" "\<Union>B' = X"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   565
    using finmap_topological_basis by (force simp add: topological_basis_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   566
  then obtain B where B: "B' = enum_basis_finmap ` B" by (auto simp: subset_image_iff)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   567
  show ?thesis
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   568
  proof cases
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   569
    assume "B = {}" with B have "B' = {}" by simp hence False using B' assms by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   570
    thus ?thesis by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   571
  next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   572
    assume "B \<noteq> {}" then obtain b where b: "b \<in> B" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   573
    def NA \<equiv> "\<lambda>n::nat. if n \<in> B
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   574
      then domain ((from_nat::_\<Rightarrow>'a \<Rightarrow>\<^isub>F nat) n)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   575
      else domain ((from_nat::_\<Rightarrow>'a\<Rightarrow>\<^isub>F nat) b)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   576
    def NB \<equiv> "\<lambda>n::nat. if n \<in> B
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   577
      then (\<lambda>i. (enum_basis::nat\<Rightarrow>'b set) (((from_nat::_\<Rightarrow>'a \<Rightarrow>\<^isub>F nat) n) i))
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   578
      else (\<lambda>i. (enum_basis::nat\<Rightarrow>'b set) (((from_nat::_\<Rightarrow>'a \<Rightarrow>\<^isub>F nat) b) i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   579
    have "X = UNION UNIV (\<lambda>i. Pi' (NA i) (NB i))" unfolding B'(2)[symmetric] using b
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   580
      unfolding B
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   581
      by safe
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   582
         (auto simp add: NA_def NB_def enum_basis_finmap_def Let_def o_def split: split_if_asm)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   583
    moreover
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   584
    have "(\<forall>n. \<forall>i\<in>NA n. (NB n) i \<in> range enum_basis)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   585
      using enumerable_basis by (auto simp: topological_basis_def NA_def NB_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   586
    moreover have "(\<forall>n. finite (NA n))" by (simp add: NA_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   587
    ultimately show ?thesis by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   588
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   589
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   590
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   591
lemma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   592
  open_imp_ex_UNION:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   593
  fixes X::"('a \<Rightarrow>\<^isub>F 'b) set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   594
  assumes "open X" assumes "X \<noteq> {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   595
  shows "\<exists>A::nat\<Rightarrow>'a set. \<exists>B::nat\<Rightarrow>('a \<Rightarrow> 'b set) . X = UNION UNIV (\<lambda>i. Pi' (A i) (B i)) \<and>
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   596
    (\<forall>n. \<forall>i\<in>A n. open ((B n) i)) \<and> (\<forall>n. finite (A n))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   597
  using open_imp_ex_UNION_of_enum[OF assms]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   598
  apply auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   599
  apply (rule_tac x = A in exI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   600
  apply (rule_tac x = B in exI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   601
  apply (auto simp: open_enum_basis)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   602
  done
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   603
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   604
lemma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   605
  open_basisE:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   606
  assumes "open X" assumes "X \<noteq> {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   607
  obtains A::"nat\<Rightarrow>'a set" and B::"nat\<Rightarrow>('a \<Rightarrow> 'b set)" where
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   608
  "X = UNION UNIV (\<lambda>i. Pi' (A i) (B i))" "\<And>n i. i\<in>A n \<Longrightarrow> open ((B n) i)" "\<And>n. finite (A n)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   609
using open_imp_ex_UNION[OF assms] by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   610
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   611
lemma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   612
  open_basis_of_enumE:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   613
  assumes "open X" assumes "X \<noteq> {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   614
  obtains A::"nat\<Rightarrow>'a set" and B::"nat\<Rightarrow>('a \<Rightarrow> 'b set)" where
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   615
  "X = UNION UNIV (\<lambda>i. Pi' (A i) (B i))" "\<And>n i. i\<in>A n \<Longrightarrow> (B n) i \<in> range enum_basis"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   616
  "\<And>n. finite (A n)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   617
using open_imp_ex_UNION_of_enum[OF assms] by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   618
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   619
instance proof qed (blast intro: finmap_topological_basis)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   620
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   621
end
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   622
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   623
subsection {* Product Measurable Space of Finite Maps *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   624
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   625
definition "PiF I M \<equiv>
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   626
  sigma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   627
    (\<Union>J \<in> I. (\<Pi>' j\<in>J. space (M j)))
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   628
    {(\<Pi>' j\<in>J. X j) |X J. J \<in> I \<and> X \<in> (\<Pi> j\<in>J. sets (M j))}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   629
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   630
abbreviation
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   631
  "Pi\<^isub>F I M \<equiv> PiF I M"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   632
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   633
syntax
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   634
  "_PiF" :: "pttrn \<Rightarrow> 'i set \<Rightarrow> 'a measure \<Rightarrow> ('i => 'a) measure"  ("(3PIF _:_./ _)" 10)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   635
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   636
syntax (xsymbols)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   637
  "_PiF" :: "pttrn \<Rightarrow> 'i set \<Rightarrow> 'a measure \<Rightarrow> ('i => 'a) measure"  ("(3\<Pi>\<^isub>F _\<in>_./ _)"  10)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   638
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   639
syntax (HTML output)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   640
  "_PiF" :: "pttrn \<Rightarrow> 'i set \<Rightarrow> 'a measure \<Rightarrow> ('i => 'a) measure"  ("(3\<Pi>\<^isub>F _\<in>_./ _)"  10)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   641
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   642
translations
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   643
  "PIF x:I. M" == "CONST PiF I (%x. M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   644
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   645
lemma PiF_gen_subset: "{(\<Pi>' j\<in>J. X j) |X J. J \<in> I \<and> X \<in> (\<Pi> j\<in>J. sets (M j))} \<subseteq>
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   646
    Pow (\<Union>J \<in> I. (\<Pi>' j\<in>J. space (M j)))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   647
  by (auto simp: Pi'_def) (blast dest: sets_into_space)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   648
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   649
lemma space_PiF: "space (PiF I M) = (\<Union>J \<in> I. (\<Pi>' j\<in>J. space (M j)))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   650
  unfolding PiF_def using PiF_gen_subset by (rule space_measure_of)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   651
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   652
lemma sets_PiF:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   653
  "sets (PiF I M) = sigma_sets (\<Union>J \<in> I. (\<Pi>' j\<in>J. space (M j)))
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   654
    {(\<Pi>' j\<in>J. X j) |X J. J \<in> I \<and> X \<in> (\<Pi> j\<in>J. sets (M j))}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   655
  unfolding PiF_def using PiF_gen_subset by (rule sets_measure_of)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   656
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   657
lemma sets_PiF_singleton:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   658
  "sets (PiF {I} M) = sigma_sets (\<Pi>' j\<in>I. space (M j))
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   659
    {(\<Pi>' j\<in>I. X j) |X. X \<in> (\<Pi> j\<in>I. sets (M j))}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   660
  unfolding sets_PiF by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   661
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   662
lemma in_sets_PiFI:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   663
  assumes "X = (Pi' J S)" "J \<in> I" "\<And>i. i\<in>J \<Longrightarrow> S i \<in> sets (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   664
  shows "X \<in> sets (PiF I M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   665
  unfolding sets_PiF
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   666
  using assms by blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   667
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   668
lemma product_in_sets_PiFI:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   669
  assumes "J \<in> I" "\<And>i. i\<in>J \<Longrightarrow> S i \<in> sets (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   670
  shows "(Pi' J S) \<in> sets (PiF I M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   671
  unfolding sets_PiF
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   672
  using assms by blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   673
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   674
lemma singleton_space_subset_in_sets:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   675
  fixes J
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   676
  assumes "J \<in> I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   677
  assumes "finite J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   678
  shows "space (PiF {J} M) \<in> sets (PiF I M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   679
  using assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   680
  by (intro in_sets_PiFI[where J=J and S="\<lambda>i. space (M i)"])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   681
      (auto simp: product_def space_PiF)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   682
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   683
lemma singleton_subspace_set_in_sets:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   684
  assumes A: "A \<in> sets (PiF {J} M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   685
  assumes "finite J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   686
  assumes "J \<in> I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   687
  shows "A \<in> sets (PiF I M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   688
  using A[unfolded sets_PiF]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   689
  apply (induct A)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   690
  unfolding sets_PiF[symmetric] unfolding space_PiF[symmetric]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   691
  using assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   692
  by (auto intro: in_sets_PiFI intro!: singleton_space_subset_in_sets)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   693
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   694
lemma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   695
  finite_measurable_singletonI:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   696
  assumes "finite I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   697
  assumes "\<And>J. J \<in> I \<Longrightarrow> finite J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   698
  assumes MN: "\<And>J. J \<in> I \<Longrightarrow> A \<in> measurable (PiF {J} M) N"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   699
  shows "A \<in> measurable (PiF I M) N"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   700
  unfolding measurable_def
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   701
proof safe
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   702
  fix y assume "y \<in> sets N"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   703
  have "A -` y \<inter> space (PiF I M) = (\<Union>J\<in>I. A -` y \<inter> space (PiF {J} M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   704
    by (auto simp: space_PiF)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   705
  also have "\<dots> \<in> sets (PiF I M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   706
  proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   707
    show "finite I" by fact
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   708
    fix J assume "J \<in> I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   709
    with assms have "finite J" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   710
    show "A -` y \<inter> space (PiF {J} M) \<in> sets (PiF I M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   711
      by (rule singleton_subspace_set_in_sets[OF measurable_sets[OF assms(3)]]) fact+
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   712
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   713
  finally show "A -` y \<inter> space (PiF I M) \<in> sets (PiF I M)" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   714
next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   715
  fix x assume "x \<in> space (PiF I M)" thus "A x \<in> space N"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   716
    using MN[of "domain x"]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   717
    by (auto simp: space_PiF measurable_space Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   718
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   719
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   720
lemma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   721
  countable_finite_comprehension:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   722
  fixes f :: "'a::countable set \<Rightarrow> _"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   723
  assumes "\<And>s. P s \<Longrightarrow> finite s"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   724
  assumes "\<And>s. P s \<Longrightarrow> f s \<in> sets M"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   725
  shows "\<Union>{f s|s. P s} \<in> sets M"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   726
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   727
  have "\<Union>{f s|s. P s} = (\<Union>n::nat. let s = set (from_nat n) in if P s then f s else {})"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   728
  proof safe
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   729
    fix x X s assume "x \<in> f s" "P s"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   730
    moreover with assms obtain l where "s = set l" using finite_list by blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   731
    ultimately show "x \<in> (\<Union>n. let s = set (from_nat n) in if P s then f s else {})" using `P s`
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   732
      by (auto intro!: exI[where x="to_nat l"])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   733
  next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   734
    fix x n assume "x \<in> (let s = set (from_nat n) in if P s then f s else {})"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   735
    thus "x \<in> \<Union>{f s|s. P s}" using assms by (auto simp: Let_def split: split_if_asm)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   736
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   737
  hence "\<Union>{f s|s. P s} = (\<Union>n. let s = set (from_nat n) in if P s then f s else {})" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   738
  also have "\<dots> \<in> sets M" using assms by (auto simp: Let_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   739
  finally show ?thesis .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   740
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   741
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   742
lemma space_subset_in_sets:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   743
  fixes J::"'a::countable set set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   744
  assumes "J \<subseteq> I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   745
  assumes "\<And>j. j \<in> J \<Longrightarrow> finite j"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   746
  shows "space (PiF J M) \<in> sets (PiF I M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   747
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   748
  have "space (PiF J M) = \<Union>{space (PiF {j} M)|j. j \<in> J}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   749
    unfolding space_PiF by blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   750
  also have "\<dots> \<in> sets (PiF I M)" using assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   751
    by (intro countable_finite_comprehension) (auto simp: singleton_space_subset_in_sets)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   752
  finally show ?thesis .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   753
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   754
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   755
lemma subspace_set_in_sets:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   756
  fixes J::"'a::countable set set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   757
  assumes A: "A \<in> sets (PiF J M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   758
  assumes "J \<subseteq> I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   759
  assumes "\<And>j. j \<in> J \<Longrightarrow> finite j"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   760
  shows "A \<in> sets (PiF I M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   761
  using A[unfolded sets_PiF]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   762
  apply (induct A)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   763
  unfolding sets_PiF[symmetric] unfolding space_PiF[symmetric]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   764
  using assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   765
  by (auto intro: in_sets_PiFI intro!: space_subset_in_sets)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   766
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   767
lemma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   768
  countable_measurable_PiFI:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   769
  fixes I::"'a::countable set set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   770
  assumes MN: "\<And>J. J \<in> I \<Longrightarrow> finite J \<Longrightarrow> A \<in> measurable (PiF {J} M) N"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   771
  shows "A \<in> measurable (PiF I M) N"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   772
  unfolding measurable_def
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   773
proof safe
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   774
  fix y assume "y \<in> sets N"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   775
  have "A -` y = (\<Union>{A -` y \<inter> {x. domain x = J}|J. finite J})" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   776
  hence "A -` y \<inter> space (PiF I M) = (\<Union>n. A -` y \<inter> space (PiF ({set (from_nat n)}\<inter>I) M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   777
    apply (auto simp: space_PiF Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   778
  proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   779
    case goal1
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   780
    from finite_list[of "domain x"] obtain xs where "set xs = domain x" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   781
    thus ?case
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   782
      apply (intro exI[where x="to_nat xs"])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   783
      apply auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   784
      done
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   785
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   786
  also have "\<dots> \<in> sets (PiF I M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   787
    apply (intro Int countable_nat_UN subsetI, safe)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   788
    apply (case_tac "set (from_nat i) \<in> I")
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   789
    apply simp_all
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   790
    apply (rule singleton_subspace_set_in_sets[OF measurable_sets[OF MN]])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   791
    using assms `y \<in> sets N`
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   792
    apply (auto simp: space_PiF)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   793
    done
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   794
  finally show "A -` y \<inter> space (PiF I M) \<in> sets (PiF I M)" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   795
next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   796
  fix x assume "x \<in> space (PiF I M)" thus "A x \<in> space N"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   797
    using MN[of "domain x"] by (auto simp: space_PiF measurable_space Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   798
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   799
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   800
lemma measurable_PiF:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   801
  assumes f: "\<And>x. x \<in> space N \<Longrightarrow> domain (f x) \<in> I \<and> (\<forall>i\<in>domain (f x). (f x) i \<in> space (M i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   802
  assumes S: "\<And>J S. J \<in> I \<Longrightarrow> (\<And>i. i \<in> J \<Longrightarrow> S i \<in> sets (M i)) \<Longrightarrow>
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   803
    f -` (Pi' J S) \<inter> space N \<in> sets N"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   804
  shows "f \<in> measurable N (PiF I M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   805
  unfolding PiF_def
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   806
  using PiF_gen_subset
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   807
  apply (rule measurable_measure_of)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   808
  using f apply force
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   809
  apply (insert S, auto)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   810
  done
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   811
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   812
lemma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   813
  restrict_sets_measurable:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   814
  assumes A: "A \<in> sets (PiF I M)" and "J \<subseteq> I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   815
  shows "A \<inter> {m. domain m \<in> J} \<in> sets (PiF J M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   816
  using A[unfolded sets_PiF]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   817
  apply (induct A)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   818
  unfolding sets_PiF[symmetric] unfolding space_PiF[symmetric]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   819
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   820
  fix a assume "a \<in> {Pi' J X |X J. J \<in> I \<and> X \<in> (\<Pi> j\<in>J. sets (M j))}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   821
  then obtain K S where S: "a = Pi' K S" "K \<in> I" "(\<forall>i\<in>K. S i \<in> sets (M i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   822
    by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   823
  show "a \<inter> {m. domain m \<in> J} \<in> sets (PiF J M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   824
  proof cases
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   825
    assume "K \<in> J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   826
    hence "a \<inter> {m. domain m \<in> J} \<in> {Pi' K X |X K. K \<in> J \<and> X \<in> (\<Pi> j\<in>K. sets (M j))}" using S
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   827
      by (auto intro!: exI[where x=K] exI[where x=S] simp: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   828
    also have "\<dots> \<subseteq> sets (PiF J M)" unfolding sets_PiF by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   829
    finally show ?thesis .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   830
  next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   831
    assume "K \<notin> J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   832
    hence "a \<inter> {m. domain m \<in> J} = {}" using S by (auto simp: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   833
    also have "\<dots> \<in> sets (PiF J M)" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   834
    finally show ?thesis .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   835
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   836
next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   837
  show "{} \<inter> {m. domain m \<in> J} \<in> sets (PiF J M)" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   838
next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   839
  fix a :: "nat \<Rightarrow> _"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   840
  assume a: "(\<And>i. a i \<inter> {m. domain m \<in> J} \<in> sets (PiF J M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   841
  have "UNION UNIV a \<inter> {m. domain m \<in> J} = (\<Union>i. (a i \<inter> {m. domain m \<in> J}))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   842
    by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   843
  also have "\<dots> \<in> sets (PiF J M)" using a by (intro countable_nat_UN) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   844
  finally show "UNION UNIV a \<inter> {m. domain m \<in> J} \<in> sets (PiF J M)" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   845
next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   846
  fix a assume a: "a \<inter> {m. domain m \<in> J} \<in> sets (PiF J M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   847
  have "(space (PiF I M) - a) \<inter> {m. domain m \<in> J} = (space (PiF J M) - (a \<inter> {m. domain m \<in> J}))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   848
    using `J \<subseteq> I` by (auto simp: space_PiF Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   849
  also have "\<dots> \<in> sets (PiF J M)" using a by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   850
  finally show "(space (PiF I M) - a) \<inter> {m. domain m \<in> J} \<in> sets (PiF J M)" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   851
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   852
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   853
lemma measurable_finmap_of:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   854
  assumes f: "\<And>i. (\<exists>x \<in> space N. i \<in> J x) \<Longrightarrow> (\<lambda>x. f x i) \<in> measurable N (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   855
  assumes J: "\<And>x. x \<in> space N \<Longrightarrow> J x \<in> I" "\<And>x. x \<in> space N \<Longrightarrow> finite (J x)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   856
  assumes JN: "\<And>S. {x. J x = S} \<inter> space N \<in> sets N"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   857
  shows "(\<lambda>x. finmap_of (J x) (f x)) \<in> measurable N (PiF I M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   858
proof (rule measurable_PiF)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   859
  fix x assume "x \<in> space N"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   860
  with J[of x] measurable_space[OF f]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   861
  show "domain (finmap_of (J x) (f x)) \<in> I \<and>
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   862
        (\<forall>i\<in>domain (finmap_of (J x) (f x)). (finmap_of (J x) (f x)) i \<in> space (M i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   863
    by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   864
next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   865
  fix K S assume "K \<in> I" and *: "\<And>i. i \<in> K \<Longrightarrow> S i \<in> sets (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   866
  with J have eq: "(\<lambda>x. finmap_of (J x) (f x)) -` Pi' K S \<inter> space N =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   867
    (if \<exists>x \<in> space N. K = J x \<and> finite K then if K = {} then {x \<in> space N. J x = K}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   868
      else (\<Inter>i\<in>K. (\<lambda>x. f x i) -` S i \<inter> {x \<in> space N. J x = K}) else {})"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   869
    by (auto simp: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   870
  have r: "{x \<in> space N. J x = K} = space N \<inter> ({x. J x = K} \<inter> space N)" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   871
  show "(\<lambda>x. finmap_of (J x) (f x)) -` Pi' K S \<inter> space N \<in> sets N"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   872
    unfolding eq r
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   873
    apply (simp del: INT_simps add: )
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   874
    apply (intro conjI impI finite_INT JN Int[OF top])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   875
    apply simp apply assumption
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   876
    apply (subst Int_assoc[symmetric])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   877
    apply (rule Int)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   878
    apply (intro measurable_sets[OF f] *) apply force apply assumption
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   879
    apply (intro JN)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   880
    done
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   881
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   882
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   883
lemma measurable_PiM_finmap_of:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   884
  assumes "finite J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   885
  shows "finmap_of J \<in> measurable (Pi\<^isub>M J M) (PiF {J} M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   886
  apply (rule measurable_finmap_of)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   887
  apply (rule measurable_component_singleton)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   888
  apply simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   889
  apply rule
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   890
  apply (rule `finite J`)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   891
  apply simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   892
  done
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   893
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   894
lemma proj_measurable_singleton:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   895
  assumes "A \<in> sets (M i)" "finite I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   896
  shows "(\<lambda>x. (x)\<^isub>F i) -` A \<inter> space (PiF {I} M) \<in> sets (PiF {I} M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   897
proof cases
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   898
  assume "i \<in> I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   899
  hence "(\<lambda>x. (x)\<^isub>F i) -` A \<inter> space (PiF {I} M) =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   900
    Pi' I (\<lambda>x. if x = i then A else space (M x))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   901
    using sets_into_space[OF ] `A \<in> sets (M i)` assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   902
    by (auto simp: space_PiF Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   903
  thus ?thesis  using assms `A \<in> sets (M i)`
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   904
    by (intro in_sets_PiFI) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   905
next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   906
  assume "i \<notin> I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   907
  hence "(\<lambda>x. (x)\<^isub>F i) -` A \<inter> space (PiF {I} M) =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   908
    (if undefined \<in> A then space (PiF {I} M) else {})" by (auto simp: space_PiF Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   909
  thus ?thesis by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   910
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   911
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   912
lemma measurable_proj_singleton:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   913
  fixes I
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   914
  assumes "finite I" "i \<in> I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   915
  shows "(\<lambda>x. (x)\<^isub>F i) \<in> measurable (PiF {I} M) (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   916
proof (unfold measurable_def, intro CollectI conjI ballI proj_measurable_singleton assms)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   917
qed (insert `i \<in> I`, auto simp: space_PiF)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   918
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   919
lemma measurable_proj_countable:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   920
  fixes I::"'a::countable set set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   921
  assumes "y \<in> space (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   922
  shows "(\<lambda>x. if i \<in> domain x then (x)\<^isub>F i else y) \<in> measurable (PiF I M) (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   923
proof (rule countable_measurable_PiFI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   924
  fix J assume "J \<in> I" "finite J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   925
  show "(\<lambda>x. if i \<in> domain x then x i else y) \<in> measurable (PiF {J} M) (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   926
    unfolding measurable_def
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   927
  proof safe
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   928
    fix z assume "z \<in> sets (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   929
    have "(\<lambda>x. if i \<in> domain x then x i else y) -` z \<inter> space (PiF {J} M) =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   930
      (\<lambda>x. if i \<in> J then (x)\<^isub>F i else y) -` z \<inter> space (PiF {J} M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   931
      by (auto simp: space_PiF Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   932
    also have "\<dots> \<in> sets (PiF {J} M)" using `z \<in> sets (M i)` `finite J`
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   933
      by (cases "i \<in> J") (auto intro!: measurable_sets[OF measurable_proj_singleton])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   934
    finally show "(\<lambda>x. if i \<in> domain x then x i else y) -` z \<inter> space (PiF {J} M) \<in>
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   935
      sets (PiF {J} M)" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   936
  qed (insert `y \<in> space (M i)`, auto simp: space_PiF Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   937
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   938
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   939
lemma measurable_restrict_proj:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   940
  assumes "J \<in> II" "finite J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   941
  shows "finmap_of J \<in> measurable (PiM J M) (PiF II M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   942
  using assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   943
  by (intro measurable_finmap_of measurable_component_singleton) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   944
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   945
lemma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   946
  measurable_proj_PiM:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   947
  fixes J K ::"'a::countable set" and I::"'a set set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   948
  assumes "finite J" "J \<in> I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   949
  assumes "x \<in> space (PiM J M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   950
  shows "proj \<in>
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   951
    measurable (PiF {J} M) (PiM J M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   952
proof (rule measurable_PiM_single)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   953
  show "proj \<in> space (PiF {J} M) \<rightarrow> (\<Pi>\<^isub>E i \<in> J. space (M i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   954
    using assms by (auto simp add: space_PiM space_PiF extensional_def sets_PiF Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   955
next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   956
  fix A i assume A: "i \<in> J" "A \<in> sets (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   957
  show "{\<omega> \<in> space (PiF {J} M). (\<omega>)\<^isub>F i \<in> A} \<in> sets (PiF {J} M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   958
  proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   959
    have "{\<omega> \<in> space (PiF {J} M). (\<omega>)\<^isub>F i \<in> A} =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   960
      (\<lambda>\<omega>. (\<omega>)\<^isub>F i) -` A \<inter> space (PiF {J} M)" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   961
    also have "\<dots> \<in> sets (PiF {J} M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   962
      using assms A by (auto intro: measurable_sets[OF measurable_proj_singleton] simp: space_PiM)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   963
    finally show ?thesis .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   964
  qed simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   965
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   966
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   967
lemma sets_subspaceI:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   968
  assumes "A \<inter> space M \<in> sets M"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   969
  assumes "B \<in> sets M"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   970
  shows "A \<inter> B \<in> sets M" using assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   971
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   972
  have "A \<inter> B = (A \<inter> space M) \<inter> B"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   973
    using assms sets_into_space by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   974
  thus ?thesis using assms by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   975
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   976
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   977
lemma space_PiF_singleton_eq_product:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   978
  assumes "finite I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   979
  shows "space (PiF {I} M) = (\<Pi>' i\<in>I. space (M i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   980
  by (auto simp: product_def space_PiF assms)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   981
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   982
text {* adapted from @{thm sets_PiM_single} *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   983
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   984
lemma sets_PiF_single:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   985
  assumes "finite I" "I \<noteq> {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   986
  shows "sets (PiF {I} M) =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   987
    sigma_sets (\<Pi>' i\<in>I. space (M i))
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   988
      {{f\<in>\<Pi>' i\<in>I. space (M i). f i \<in> A} | i A. i \<in> I \<and> A \<in> sets (M i)}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   989
    (is "_ = sigma_sets ?\<Omega> ?R")
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   990
  unfolding sets_PiF_singleton
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   991
proof (rule sigma_sets_eqI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   992
  interpret R: sigma_algebra ?\<Omega> "sigma_sets ?\<Omega> ?R" by (rule sigma_algebra_sigma_sets) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   993
  fix A assume "A \<in> {Pi' I X |X. X \<in> (\<Pi> j\<in>I. sets (M j))}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   994
  then obtain X where X: "A = Pi' I X" "X \<in> (\<Pi> j\<in>I. sets (M j))" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   995
  show "A \<in> sigma_sets ?\<Omega> ?R"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   996
  proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   997
    from `I \<noteq> {}` X have "A = (\<Inter>j\<in>I. {f\<in>space (PiF {I} M). f j \<in> X j})"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   998
      using sets_into_space
32d1795cc77a added projective limit;
immler
parents:
diff changeset
   999
      by (auto simp: space_PiF product_def) blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1000
    also have "\<dots> \<in> sigma_sets ?\<Omega> ?R"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1001
      using X `I \<noteq> {}` assms by (intro R.finite_INT) (auto simp: space_PiF)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1002
    finally show "A \<in> sigma_sets ?\<Omega> ?R" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1003
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1004
next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1005
  fix A assume "A \<in> ?R"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1006
  then obtain i B where A: "A = {f\<in>\<Pi>' i\<in>I. space (M i). f i \<in> B}" "i \<in> I" "B \<in> sets (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1007
    by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1008
  then have "A = (\<Pi>' j \<in> I. if j = i then B else space (M j))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1009
    using sets_into_space[OF A(3)]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1010
    apply (auto simp: Pi'_iff split: split_if_asm)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1011
    apply blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1012
    done
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1013
  also have "\<dots> \<in> sigma_sets ?\<Omega> {Pi' I X |X. X \<in> (\<Pi> j\<in>I. sets (M j))}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1014
    using A
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1015
    by (intro sigma_sets.Basic )
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1016
       (auto intro: exI[where x="\<lambda>j. if j = i then B else space (M j)"])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1017
  finally show "A \<in> sigma_sets ?\<Omega> {Pi' I X |X. X \<in> (\<Pi> j\<in>I. sets (M j))}" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1018
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1019
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1020
text {* adapted from @{thm PiE_cong} *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1021
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1022
lemma Pi'_cong:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1023
  assumes "finite I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1024
  assumes "\<And>i. i \<in> I \<Longrightarrow> f i = g i"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1025
  shows "Pi' I f = Pi' I g"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1026
using assms by (auto simp: Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1027
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1028
text {* adapted from @{thm Pi_UN} *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1029
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1030
lemma Pi'_UN:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1031
  fixes A :: "nat \<Rightarrow> 'i \<Rightarrow> 'a set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1032
  assumes "finite I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1033
  assumes mono: "\<And>i n m. i \<in> I \<Longrightarrow> n \<le> m \<Longrightarrow> A n i \<subseteq> A m i"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1034
  shows "(\<Union>n. Pi' I (A n)) = Pi' I (\<lambda>i. \<Union>n. A n i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1035
proof (intro set_eqI iffI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1036
  fix f assume "f \<in> Pi' I (\<lambda>i. \<Union>n. A n i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1037
  then have "\<forall>i\<in>I. \<exists>n. f i \<in> A n i" "domain f = I" by (auto simp: `finite I` Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1038
  from bchoice[OF this(1)] obtain n where n: "\<And>i. i \<in> I \<Longrightarrow> f i \<in> (A (n i) i)" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1039
  obtain k where k: "\<And>i. i \<in> I \<Longrightarrow> n i \<le> k"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1040
    using `finite I` finite_nat_set_iff_bounded_le[of "n`I"] by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1041
  have "f \<in> Pi' I (\<lambda>i. A k i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1042
  proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1043
    fix i assume "i \<in> I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1044
    from mono[OF this, of "n i" k] k[OF this] n[OF this] `domain f = I` `i \<in> I`
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1045
    show "f i \<in> A k i " by (auto simp: `finite I`)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1046
  qed (simp add: `domain f = I` `finite I`)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1047
  then show "f \<in> (\<Union>n. Pi' I (A n))" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1048
qed (auto simp: Pi'_def `finite I`)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1049
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1050
text {* adapted from @{thm sigma_prod_algebra_sigma_eq} *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1051
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1052
lemma sigma_fprod_algebra_sigma_eq:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1053
  fixes E :: "'i \<Rightarrow> 'a set set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1054
  assumes [simp]: "finite I" "I \<noteq> {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1055
  assumes S_mono: "\<And>i. i \<in> I \<Longrightarrow> incseq (S i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1056
    and S_union: "\<And>i. i \<in> I \<Longrightarrow> (\<Union>j. S i j) = space (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1057
    and S_in_E: "\<And>i. i \<in> I \<Longrightarrow> range (S i) \<subseteq> E i"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1058
  assumes E_closed: "\<And>i. i \<in> I \<Longrightarrow> E i \<subseteq> Pow (space (M i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1059
    and E_generates: "\<And>i. i \<in> I \<Longrightarrow> sets (M i) = sigma_sets (space (M i)) (E i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1060
  defines "P == { Pi' I F | F. \<forall>i\<in>I. F i \<in> E i }"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1061
  shows "sets (PiF {I} M) = sigma_sets (space (PiF {I} M)) P"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1062
proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1063
  let ?P = "sigma (space (Pi\<^isub>F {I} M)) P"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1064
  have P_closed: "P \<subseteq> Pow (space (Pi\<^isub>F {I} M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1065
    using E_closed by (auto simp: space_PiF P_def Pi'_iff subset_eq)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1066
  then have space_P: "space ?P = (\<Pi>' i\<in>I. space (M i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1067
    by (simp add: space_PiF)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1068
  have "sets (PiF {I} M) =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1069
      sigma_sets (space ?P) {{f \<in> \<Pi>' i\<in>I. space (M i). f i \<in> A} |i A. i \<in> I \<and> A \<in> sets (M i)}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1070
    using sets_PiF_single[of I M] by (simp add: space_P)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1071
  also have "\<dots> \<subseteq> sets (sigma (space (PiF {I} M)) P)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1072
  proof (safe intro!: sigma_sets_subset)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1073
    fix i A assume "i \<in> I" and A: "A \<in> sets (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1074
    have "(\<lambda>x. (x)\<^isub>F i) \<in> measurable ?P (sigma (space (M i)) (E i))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1075
    proof (subst measurable_iff_measure_of)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1076
      show "E i \<subseteq> Pow (space (M i))" using `i \<in> I` by fact
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1077
      from space_P `i \<in> I` show "(\<lambda>x. (x)\<^isub>F i) \<in> space ?P \<rightarrow> space (M i)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1078
        by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1079
      show "\<forall>A\<in>E i. (\<lambda>x. (x)\<^isub>F i) -` A \<inter> space ?P \<in> sets ?P"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1080
      proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1081
        fix A assume A: "A \<in> E i"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1082
        then have "(\<lambda>x. (x)\<^isub>F i) -` A \<inter> space ?P = (\<Pi>' j\<in>I. if i = j then A else space (M j))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1083
          using E_closed `i \<in> I` by (auto simp: space_P Pi_iff subset_eq split: split_if_asm)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1084
        also have "\<dots> = (\<Pi>' j\<in>I. \<Union>n. if i = j then A else S j n)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1085
          by (intro Pi'_cong) (simp_all add: S_union)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1086
        also have "\<dots> = (\<Union>n. \<Pi>' j\<in>I. if i = j then A else S j n)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1087
          using S_mono
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1088
          by (subst Pi'_UN[symmetric, OF `finite I`]) (auto simp: incseq_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1089
        also have "\<dots> \<in> sets ?P"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1090
        proof (safe intro!: countable_UN)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1091
          fix n show "(\<Pi>' j\<in>I. if i = j then A else S j n) \<in> sets ?P"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1092
            using A S_in_E
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1093
            by (simp add: P_closed)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1094
               (auto simp: P_def subset_eq intro!: exI[of _ "\<lambda>j. if i = j then A else S j n"])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1095
        qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1096
        finally show "(\<lambda>x. (x)\<^isub>F i) -` A \<inter> space ?P \<in> sets ?P"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1097
          using P_closed by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1098
      qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1099
    qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1100
    from measurable_sets[OF this, of A] A `i \<in> I` E_closed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1101
    have "(\<lambda>x. (x)\<^isub>F i) -` A \<inter> space ?P \<in> sets ?P"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1102
      by (simp add: E_generates)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1103
    also have "(\<lambda>x. (x)\<^isub>F i) -` A \<inter> space ?P = {f \<in> \<Pi>' i\<in>I. space (M i). f i \<in> A}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1104
      using P_closed by (auto simp: space_PiF)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1105
    finally show "\<dots> \<in> sets ?P" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1106
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1107
  finally show "sets (PiF {I} M) \<subseteq> sigma_sets (space (PiF {I} M)) P"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1108
    by (simp add: P_closed)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1109
  show "sigma_sets (space (PiF {I} M)) P \<subseteq> sets (PiF {I} M)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1110
    using `finite I` `I \<noteq> {}`
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1111
    by (auto intro!: sigma_sets_subset product_in_sets_PiFI simp: E_generates P_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1112
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1113
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1114
lemma enumerable_sigma_fprod_algebra_sigma_eq:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1115
  assumes "I \<noteq> {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1116
  assumes [simp]: "finite I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1117
  shows "sets (PiF {I} (\<lambda>_. borel)) = sigma_sets (space (PiF {I} (\<lambda>_. borel)))
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1118
    {Pi' I F |F. (\<forall>i\<in>I. F i \<in> range enum_basis)}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1119
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1120
  from open_incseqE[OF open_UNIV] guess S::"nat \<Rightarrow> 'b set" . note S = this
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1121
  show ?thesis
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1122
  proof (rule sigma_fprod_algebra_sigma_eq)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1123
    show "finite I" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1124
    show "I \<noteq> {}" by fact
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1125
    show "incseq S" "(\<Union>j. S j) = space borel" "range S \<subseteq> range enum_basis"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1126
      using S by simp_all
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1127
    show "range enum_basis \<subseteq> Pow (space borel)" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1128
    show "sets borel = sigma_sets (space borel) (range enum_basis)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1129
      by (simp add: borel_eq_enum_basis)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1130
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1131
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1132
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1133
text {* adapted from @{thm enumerable_sigma_fprod_algebra_sigma_eq} *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1134
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1135
lemma enumerable_sigma_prod_algebra_sigma_eq:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1136
  assumes "I \<noteq> {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1137
  assumes [simp]: "finite I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1138
  shows "sets (PiM I (\<lambda>_. borel)) = sigma_sets (space (PiM I (\<lambda>_. borel)))
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1139
    {Pi\<^isub>E I F |F. \<forall>i\<in>I. F i \<in> range enum_basis}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1140
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1141
  from open_incseqE[OF open_UNIV] guess S::"nat \<Rightarrow> 'b set" . note S = this
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1142
  show ?thesis
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1143
  proof (rule sigma_prod_algebra_sigma_eq)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1144
    show "finite I" by simp note[[show_types]]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1145
    fix i show "(\<Union>j. S j) = space borel" "range S \<subseteq> range enum_basis"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1146
      using S by simp_all
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1147
    show "range enum_basis \<subseteq> Pow (space borel)" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1148
    show "sets borel = sigma_sets (space borel) (range enum_basis)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1149
      by (simp add: borel_eq_enum_basis)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1150
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1151
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1152
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1153
lemma product_open_generates_sets_PiF_single:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1154
  assumes "I \<noteq> {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1155
  assumes [simp]: "finite I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1156
  shows "sets (PiF {I} (\<lambda>_. borel::'b::enumerable_basis measure)) =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1157
    sigma_sets (space (PiF {I} (\<lambda>_. borel))) {Pi' I F |F. (\<forall>i\<in>I. F i \<in> Collect open)}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1158
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1159
  from open_incseqE[OF open_UNIV] guess S::"nat \<Rightarrow> 'b set" . note S = this
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1160
  show ?thesis
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1161
  proof (rule sigma_fprod_algebra_sigma_eq)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1162
    show "finite I" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1163
    show "I \<noteq> {}" by fact
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1164
    show "incseq S" "(\<Union>j. S j) = space borel" "range S \<subseteq> Collect open"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1165
      using S by (auto simp: open_enum_basis)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1166
    show "Collect open \<subseteq> Pow (space borel)" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1167
    show "sets borel = sigma_sets (space borel) (Collect open)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1168
      by (simp add: borel_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1169
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1170
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1171
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1172
lemma product_open_generates_sets_PiM:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1173
  assumes "I \<noteq> {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1174
  assumes [simp]: "finite I"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1175
  shows "sets (PiM I (\<lambda>_. borel::'b::enumerable_basis measure)) =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1176
    sigma_sets (space (PiM I (\<lambda>_. borel))) {Pi\<^isub>E I F |F. \<forall>i\<in>I. F i \<in> Collect open}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1177
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1178
  from open_incseqE[OF open_UNIV] guess S::"nat \<Rightarrow> 'b set" . note S = this
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1179
  show ?thesis
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1180
  proof (rule sigma_prod_algebra_sigma_eq)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1181
    show "finite I" by simp note[[show_types]]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1182
    fix i show "(\<Union>j. S j) = space borel" "range S \<subseteq> Collect open"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1183
      using S by (auto simp: open_enum_basis)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1184
    show "Collect open \<subseteq> Pow (space borel)" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1185
    show "sets borel = sigma_sets (space borel) (Collect open)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1186
      by (simp add: borel_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1187
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1188
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1189
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1190
lemma finmap_UNIV[simp]: "(\<Union>J\<in>Collect finite. J \<leadsto> UNIV) = UNIV" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1191
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1192
lemma borel_eq_PiF_borel:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1193
  shows "(borel :: ('i::countable \<Rightarrow>\<^isub>F 'a::polish_space) measure) =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1194
  PiF (Collect finite) (\<lambda>_. borel :: 'a measure)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1195
proof (rule measure_eqI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1196
  have C: "Collect finite \<noteq> {}" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1197
  show "sets (borel::('i \<Rightarrow>\<^isub>F 'a) measure) = sets (PiF (Collect finite) (\<lambda>_. borel))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1198
  proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1199
    show "sets (borel::('i \<Rightarrow>\<^isub>F 'a) measure) \<subseteq> sets (PiF (Collect finite) (\<lambda>_. borel))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1200
      apply (simp add: borel_def sets_PiF)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1201
    proof (rule sigma_sets_mono, safe, cases)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1202
      fix X::"('i \<Rightarrow>\<^isub>F 'a) set" assume "open X" "X \<noteq> {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1203
      from open_basisE[OF this] guess NA NB . note N = this
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1204
      hence "X = (\<Union>i. Pi' (NA i) (NB i))" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1205
      also have "\<dots> \<in>
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1206
        sigma_sets UNIV {Pi' J S |S J. finite J \<and> S \<in> J \<rightarrow> sigma_sets UNIV (Collect open)}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1207
        using N by (intro Union sigma_sets.Basic) blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1208
      finally show "X \<in> sigma_sets UNIV
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1209
        {Pi' J X |X J. finite J \<and> X \<in> J \<rightarrow> sigma_sets UNIV (Collect open)}" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1210
    qed (auto simp: Empty)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1211
  next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1212
    show "sets (PiF (Collect finite) (\<lambda>_. borel)) \<subseteq> sets (borel::('i \<Rightarrow>\<^isub>F 'a) measure)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1213
    proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1214
      fix x assume x: "x \<in> sets (PiF (Collect finite::'i set set) (\<lambda>_. borel::'a measure))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1215
      hence x_sp: "x \<subseteq> space (PiF (Collect finite) (\<lambda>_. borel))" by (rule sets_into_space)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1216
      let ?x = "\<lambda>J. x \<inter> {x. domain x = J}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1217
      have "x = \<Union>{?x J |J. finite J}" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1218
      also have "\<dots> \<in> sets borel"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1219
      proof (rule countable_finite_comprehension, assumption)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1220
        fix J::"'i set" assume "finite J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1221
        { assume ef: "J = {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1222
          { assume e: "?x J = {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1223
            hence "?x J \<in> sets borel" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1224
          } moreover {
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1225
            assume "?x J \<noteq> {}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1226
            then obtain f where "f \<in> x" "domain f = {}" using ef by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1227
            hence "?x J = {f}" using `J = {}`
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1228
              by (auto simp: finmap_eq_iff)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1229
            also have "{f} \<in> sets borel" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1230
            finally have "?x J \<in> sets borel" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1231
          } ultimately have "?x J \<in> sets borel" by blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1232
        } moreover {
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1233
          assume "J \<noteq> ({}::'i set)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1234
          from open_incseqE[OF open_UNIV] guess S::"nat \<Rightarrow> 'a set" . note S = this
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1235
          have "(?x J) = x \<inter> {m. domain m \<in> {J}}" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1236
          also have "\<dots> \<in> sets (PiF {J} (\<lambda>_. borel))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1237
            using x by (rule restrict_sets_measurable) (auto simp: `finite J`)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1238
          also have "\<dots> = sigma_sets (space (PiF {J} (\<lambda>_. borel)))
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1239
            {Pi' (J) F |F. (\<forall>j\<in>J. F j \<in> range enum_basis)}"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1240
            (is "_ = sigma_sets _ ?P")
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1241
            by (rule enumerable_sigma_fprod_algebra_sigma_eq[OF `J \<noteq> {}` `finite J`])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1242
          also have "\<dots> \<subseteq> sets borel"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1243
          proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1244
            fix x
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1245
            assume "x \<in> sigma_sets (space (PiF {J} (\<lambda>_. borel))) ?P"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1246
            thus "x \<in> sets borel"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1247
            proof (rule sigma_sets.induct, safe)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1248
              fix F::"'i \<Rightarrow> 'a set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1249
              assume "\<forall>j\<in>J. F j \<in> range enum_basis"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1250
              hence "Pi' J F \<in> range enum_basis_finmap"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1251
                unfolding range_enum_basis_eq
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1252
                by (auto simp: `finite J` intro!: exI[where x=J] exI[where x=F])
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1253
              hence "open (Pi' (J) F)" by (rule range_enum_basis_finmap_imp_open)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1254
              thus "Pi' (J) F \<in> sets borel" by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1255
            next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1256
              fix a::"('i \<Rightarrow>\<^isub>F 'a) set"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1257
              have "space (PiF {J::'i set} (\<lambda>_. borel::'a measure)) =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1258
                Pi' (J) (\<lambda>_. UNIV)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1259
                by (auto simp: space_PiF product_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1260
              moreover have "open (Pi' (J::'i set) (\<lambda>_. UNIV::'a set))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1261
                by (intro open_Pi'I) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1262
              ultimately
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1263
              have "space (PiF {J::'i set} (\<lambda>_. borel::'a measure)) \<in> sets borel"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1264
                by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1265
              moreover
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1266
              assume "a \<in> sets borel"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1267
              ultimately show "space (PiF {J} (\<lambda>_. borel)) - a \<in> sets borel" ..
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1268
            qed auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1269
          qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1270
          finally have "(?x J) \<in> sets borel" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1271
        } ultimately show "(?x J) \<in> sets borel" by blast
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1272
      qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1273
      finally show "x \<in> sets (borel)" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1274
    qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1275
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1276
qed (simp add: emeasure_sigma borel_def PiF_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1277
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1278
subsection {* Isomorphism between Functions and Finite Maps *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1279
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1280
lemma
50100
9af8721ecd20 renamed measurable_compose -> measurable_finmap_compose, clashed with Sigma_Algebra.measurable_compose
hoelzl
parents: 50094
diff changeset
  1281
  measurable_finmap_compose:
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1282
  fixes f::"'a \<Rightarrow> 'b"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1283
  assumes inj: "\<And>j. j \<in> J \<Longrightarrow> f' (f j) = j"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1284
  assumes "finite J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1285
  shows "(\<lambda>m. compose J m f) \<in> measurable (PiM (f ` J) (\<lambda>_. M)) (PiM J (\<lambda>_. M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1286
proof (rule measurable_PiM)
50123
69b35a75caf3 merge extensional dependent function space from FuncSet with the one in Finite_Product_Measure
hoelzl
parents: 50100
diff changeset
  1287
  show "(\<lambda>m. compose J m f) \<in> space (Pi\<^isub>M (f ` J) (\<lambda>_. M)) \<rightarrow> (J \<rightarrow>\<^isub>E space M)"
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1288
  proof safe
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1289
    fix x and i
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1290
    assume x: "x \<in> space (PiM (f ` J) (\<lambda>_. M))" "i \<in> J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1291
    with inj show  "compose J x f i \<in> space M"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1292
      by (auto simp: space_PiM compose_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1293
  next
50123
69b35a75caf3 merge extensional dependent function space from FuncSet with the one in Finite_Product_Measure
hoelzl
parents: 50100
diff changeset
  1294
    fix x i assume "i \<notin> J"
69b35a75caf3 merge extensional dependent function space from FuncSet with the one in Finite_Product_Measure
hoelzl
parents: 50100
diff changeset
  1295
    with compose_extensional[of J x f]
69b35a75caf3 merge extensional dependent function space from FuncSet with the one in Finite_Product_Measure
hoelzl
parents: 50100
diff changeset
  1296
    show "compose J x f i = undefined" by (auto simp: extensional_def)
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1297
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1298
next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1299
  fix S X
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1300
  have inv: "\<And>j. j \<in> f ` J \<Longrightarrow> f (f' j) = j" using assms by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1301
  assume S: "S \<noteq> {} \<or> J = {}" "finite S" "S \<subseteq> J" and P: "\<And>i. i \<in> S \<Longrightarrow> X i \<in> sets M"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1302
  have "(\<lambda>m. compose J m f) -` prod_emb J (\<lambda>_. M) S (Pi\<^isub>E S X) \<inter>
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1303
    space (Pi\<^isub>M (f ` J) (\<lambda>_. M)) = prod_emb (f ` J) (\<lambda>_. M) (f ` S) (Pi\<^isub>E (f ` S) (\<lambda>b. X (f' b)))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1304
    using assms inv S sets_into_space[OF P]
50123
69b35a75caf3 merge extensional dependent function space from FuncSet with the one in Finite_Product_Measure
hoelzl
parents: 50100
diff changeset
  1305
    by (force simp: prod_emb_iff compose_def space_PiM extensional_def Pi_def PiE_def intro: imageI)
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1306
  also have "\<dots> \<in> sets (Pi\<^isub>M (f ` J) (\<lambda>_. M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1307
  proof
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1308
    from S show "f ` S \<subseteq> f `  J" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1309
    show "(\<Pi>\<^isub>E b\<in>f ` S. X (f' b)) \<in> sets (Pi\<^isub>M (f ` S) (\<lambda>_. M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1310
    proof (rule sets_PiM_I_finite)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1311
      show "finite (f ` S)" using S by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1312
      fix i assume "i \<in> f ` S" hence "f' i \<in> S" using S assms by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1313
      thus "X (f' i) \<in> sets M" by (rule P)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1314
    qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1315
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1316
  finally show "(\<lambda>m. compose J m f) -` prod_emb J (\<lambda>_. M) S (Pi\<^isub>E S X) \<inter>
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1317
    space (Pi\<^isub>M (f ` J) (\<lambda>_. M)) \<in> sets (Pi\<^isub>M (f ` J) (\<lambda>_. M))" .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1318
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1319
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1320
lemma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1321
  measurable_compose_inv:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1322
  fixes f::"'a \<Rightarrow> 'b"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1323
  assumes inj: "\<And>j. j \<in> J \<Longrightarrow> f' (f j) = j"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1324
  assumes "finite J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1325
  shows "(\<lambda>m. compose (f ` J) m f') \<in> measurable (PiM J (\<lambda>_. M)) (PiM (f ` J) (\<lambda>_. M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1326
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1327
  have "(\<lambda>m. compose (f ` J) m f') \<in> measurable (Pi\<^isub>M (f' ` f ` J) (\<lambda>_. M)) (Pi\<^isub>M (f ` J) (\<lambda>_. M))"
50100
9af8721ecd20 renamed measurable_compose -> measurable_finmap_compose, clashed with Sigma_Algebra.measurable_compose
hoelzl
parents: 50094
diff changeset
  1328
    using assms by (auto intro: measurable_finmap_compose)
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1329
  moreover
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1330
  from inj have "f' ` f ` J = J" by (metis (hide_lams, mono_tags) image_iff set_eqI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1331
  ultimately show ?thesis by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1332
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1333
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1334
locale function_to_finmap =
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1335
  fixes J::"'a set" and f :: "'a \<Rightarrow> 'b::countable" and f'
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1336
  assumes [simp]: "finite J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1337
  assumes inv: "i \<in> J \<Longrightarrow> f' (f i) = i"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1338
begin
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1339
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1340
text {* to measure finmaps *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1341
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1342
definition "fm = (finmap_of (f ` J)) o (\<lambda>g. compose (f ` J) g f')"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1343
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1344
lemma domain_fm[simp]: "domain (fm x) = f ` J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1345
  unfolding fm_def by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1346
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1347
lemma fm_restrict[simp]: "fm (restrict y J) = fm y"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1348
  unfolding fm_def by (auto simp: compose_def inv intro: restrict_ext)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1349
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1350
lemma fm_product:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1351
  assumes "\<And>i. space (M i) = UNIV"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1352
  shows "fm -` Pi' (f ` J) S \<inter> space (Pi\<^isub>M J M) = (\<Pi>\<^isub>E j \<in> J. S (f j))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1353
  using assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1354
  by (auto simp: inv fm_def compose_def space_PiM Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1355
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1356
lemma fm_measurable:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1357
  assumes "f ` J \<in> N"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1358
  shows "fm \<in> measurable (Pi\<^isub>M J (\<lambda>_. M)) (Pi\<^isub>F N (\<lambda>_. M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1359
  unfolding fm_def
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1360
proof (rule measurable_comp, rule measurable_compose_inv)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1361
  show "finmap_of (f ` J) \<in> measurable (Pi\<^isub>M (f ` J) (\<lambda>_. M)) (PiF N (\<lambda>_. M)) "
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1362
    using assms by (intro measurable_finmap_of measurable_component_singleton) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1363
qed (simp_all add: inv)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1364
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1365
lemma proj_fm:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1366
  assumes "x \<in> J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1367
  shows "fm m (f x) = m x"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1368
  using assms by (auto simp: fm_def compose_def o_def inv)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1369
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1370
lemma inj_on_compose_f': "inj_on (\<lambda>g. compose (f ` J) g f') (extensional J)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1371
proof (rule inj_on_inverseI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1372
  fix x::"'a \<Rightarrow> 'c" assume "x \<in> extensional J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1373
  thus "(\<lambda>x. compose J x f) (compose (f ` J) x f') = x"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1374
    by (auto simp: compose_def inv extensional_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1375
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1376
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1377
lemma inj_on_fm:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1378
  assumes "\<And>i. space (M i) = UNIV"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1379
  shows "inj_on fm (space (Pi\<^isub>M J M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1380
  using assms
50123
69b35a75caf3 merge extensional dependent function space from FuncSet with the one in Finite_Product_Measure
hoelzl
parents: 50100
diff changeset
  1381
  apply (auto simp: fm_def space_PiM PiE_def)
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1382
  apply (rule comp_inj_on)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1383
  apply (rule inj_on_compose_f')
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1384
  apply (rule finmap_of_inj_on_extensional_finite)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1385
  apply simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1386
  apply (auto)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1387
  done
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1388
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1389
text {* to measure functions *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1390
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1391
definition "mf = (\<lambda>g. compose J g f) o proj"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1392
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1393
lemma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1394
  assumes "x \<in> space (Pi\<^isub>M J (\<lambda>_. M))" "finite J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1395
  shows "proj (finmap_of J x) = x"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1396
  using assms by (auto simp: space_PiM extensional_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1397
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1398
lemma
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1399
  assumes "x \<in> space (Pi\<^isub>F {J} (\<lambda>_. M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1400
  shows "finmap_of J (proj x) = x"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1401
  using assms by (auto simp: space_PiF Pi'_def finmap_eq_iff)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1402
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1403
lemma mf_fm:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1404
  assumes "x \<in> space (Pi\<^isub>M J (\<lambda>_. M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1405
  shows "mf (fm x) = x"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1406
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1407
  have "mf (fm x) \<in> extensional J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1408
    by (auto simp: mf_def extensional_def compose_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1409
  moreover
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1410
  have "x \<in> extensional J" using assms sets_into_space
50123
69b35a75caf3 merge extensional dependent function space from FuncSet with the one in Finite_Product_Measure
hoelzl
parents: 50100
diff changeset
  1411
    by (force simp: space_PiM PiE_def)
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1412
  moreover
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1413
  { fix i assume "i \<in> J"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1414
    hence "mf (fm x) i = x i"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1415
      by (auto simp: inv mf_def compose_def fm_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1416
  }
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1417
  ultimately
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1418
  show ?thesis by (rule extensionalityI)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1419
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1420
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1421
lemma mf_measurable:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1422
  assumes "space M = UNIV"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1423
  shows "mf \<in> measurable (PiF {f ` J} (\<lambda>_. M)) (PiM J (\<lambda>_. M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1424
  unfolding mf_def
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1425
proof (rule measurable_comp, rule measurable_proj_PiM)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1426
  show "(\<lambda>g. compose J g f) \<in>
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1427
    measurable (Pi\<^isub>M (f ` J) (\<lambda>x. M)) (Pi\<^isub>M J (\<lambda>_. M))"
50100
9af8721ecd20 renamed measurable_compose -> measurable_finmap_compose, clashed with Sigma_Algebra.measurable_compose
hoelzl
parents: 50094
diff changeset
  1428
    by (rule measurable_finmap_compose, rule inv) auto
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1429
qed (auto simp add: space_PiM extensional_def assms)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1430
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1431
lemma fm_image_measurable:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1432
  assumes "space M = UNIV"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1433
  assumes "X \<in> sets (Pi\<^isub>M J (\<lambda>_. M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1434
  shows "fm ` X \<in> sets (PiF {f ` J} (\<lambda>_. M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1435
proof -
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1436
  have "fm ` X = (mf) -` X \<inter> space (PiF {f ` J} (\<lambda>_. M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1437
  proof safe
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1438
    fix x assume "x \<in> X"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1439
    with mf_fm[of x] sets_into_space[OF assms(2)] show "fm x \<in> mf -` X" by auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1440
    show "fm x \<in> space (PiF {f ` J} (\<lambda>_. M))" by (simp add: space_PiF assms)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1441
  next
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1442
    fix y x
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1443
    assume x: "mf y \<in> X"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1444
    assume y: "y \<in> space (PiF {f ` J} (\<lambda>_. M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1445
    thus "y \<in> fm ` X"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1446
      by (intro image_eqI[OF _ x], unfold finmap_eq_iff)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1447
         (auto simp: space_PiF fm_def mf_def compose_def inv Pi'_def)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1448
  qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1449
  also have "\<dots> \<in> sets (PiF {f ` J} (\<lambda>_. M))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1450
    using assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1451
    by (intro measurable_sets[OF mf_measurable]) auto
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1452
  finally show ?thesis .
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1453
qed
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1454
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1455
lemma fm_image_measurable_finite:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1456
  assumes "space M = UNIV"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1457
  assumes "X \<in> sets (Pi\<^isub>M J (\<lambda>_. M::'c measure))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1458
  shows "fm ` X \<in> sets (PiF (Collect finite) (\<lambda>_. M::'c measure))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1459
  using fm_image_measurable[OF assms]
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1460
  by (rule subspace_set_in_sets) (auto simp: finite_subset)
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1461
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1462
text {* measure on finmaps *}
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1463
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1464
definition "mapmeasure M N = distr M (PiF (Collect finite) N) (fm)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1465
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1466
lemma sets_mapmeasure[simp]: "sets (mapmeasure M N) = sets (PiF (Collect finite) N)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1467
  unfolding mapmeasure_def by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1468
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1469
lemma space_mapmeasure[simp]: "space (mapmeasure M N) = space (PiF (Collect finite) N)"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1470
  unfolding mapmeasure_def by simp
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1471
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1472
lemma mapmeasure_PiF:
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1473
  assumes s1: "space M = space (Pi\<^isub>M J (\<lambda>_. N))"
50123
69b35a75caf3 merge extensional dependent function space from FuncSet with the one in Finite_Product_Measure
hoelzl
parents: 50100
diff changeset
  1474
  assumes s2: "sets M = sets (Pi\<^isub>M J (\<lambda>_. N))"
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1475
  assumes "space N = UNIV"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1476
  assumes "X \<in> sets (PiF (Collect finite) (\<lambda>_. N))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1477
  shows "emeasure (mapmeasure M (\<lambda>_. N)) X = emeasure M ((fm -` X \<inter> extensional J))"
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1478
  using assms
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1479
  by (auto simp: measurable_eqI[OF s1 refl s2 refl] mapmeasure_def emeasure_distr
50123
69b35a75caf3 merge extensional dependent function space from FuncSet with the one in Finite_Product_Measure
hoelzl
parents: 50100
diff changeset
  1480
    fm_measurable space_PiM PiE_def)
50088
32d1795cc77a added projective limit;
immler
parents:
diff changeset
  1481
32d1795cc77a added projective limit;
immler
parents: