src/HOL/Probability/Borel_Space.thy
author hoelzl
Mon Dec 06 19:54:56 2010 +0100 (2010-12-06)
changeset 41026 bea75746dc9d
parent 41025 8b2cd85ecf11
child 41080 294956ff285b
permissions -rw-r--r--
folding on arbitrary Lebesgue integrable functions
hoelzl@38656
     1
(* Author: Armin Heller, Johannes Hoelzl, TU Muenchen *)
hoelzl@38656
     2
hoelzl@38656
     3
header {*Borel spaces*}
paulson@33533
     4
hoelzl@40859
     5
theory Borel_Space
hoelzl@41023
     6
  imports Sigma_Algebra Positive_Extended_Real Multivariate_Analysis
paulson@33533
     7
begin
paulson@33533
     8
hoelzl@39092
     9
lemma LIMSEQ_max:
hoelzl@39092
    10
  "u ----> (x::real) \<Longrightarrow> (\<lambda>i. max (u i) 0) ----> max x 0"
hoelzl@39092
    11
  by (fastsimp intro!: LIMSEQ_I dest!: LIMSEQ_D)
hoelzl@39092
    12
hoelzl@38656
    13
section "Generic Borel spaces"
paulson@33533
    14
hoelzl@40859
    15
definition "borel = sigma \<lparr> space = UNIV::'a::topological_space set, sets = open\<rparr>"
hoelzl@40859
    16
abbreviation "borel_measurable M \<equiv> measurable M borel"
paulson@33533
    17
hoelzl@40859
    18
interpretation borel: sigma_algebra borel
hoelzl@40859
    19
  by (auto simp: borel_def intro!: sigma_algebra_sigma)
paulson@33533
    20
paulson@33533
    21
lemma in_borel_measurable:
paulson@33533
    22
   "f \<in> borel_measurable M \<longleftrightarrow>
hoelzl@40859
    23
    (\<forall>S \<in> sets (sigma \<lparr> space = UNIV, sets = open\<rparr>).
hoelzl@38656
    24
      f -` S \<inter> space M \<in> sets M)"
hoelzl@40859
    25
  by (auto simp add: measurable_def borel_def)
paulson@33533
    26
hoelzl@40859
    27
lemma in_borel_measurable_borel:
hoelzl@38656
    28
   "f \<in> borel_measurable M \<longleftrightarrow>
hoelzl@40859
    29
    (\<forall>S \<in> sets borel.
hoelzl@38656
    30
      f -` S \<inter> space M \<in> sets M)"
hoelzl@40859
    31
  by (auto simp add: measurable_def borel_def)
paulson@33533
    32
hoelzl@40859
    33
lemma space_borel[simp]: "space borel = UNIV"
hoelzl@40859
    34
  unfolding borel_def by auto
hoelzl@38656
    35
hoelzl@40859
    36
lemma borel_open[simp]:
hoelzl@40859
    37
  assumes "open A" shows "A \<in> sets borel"
hoelzl@38656
    38
proof -
hoelzl@38656
    39
  have "A \<in> open" unfolding mem_def using assms .
hoelzl@40859
    40
  thus ?thesis unfolding borel_def sigma_def by (auto intro!: sigma_sets.Basic)
paulson@33533
    41
qed
paulson@33533
    42
hoelzl@40859
    43
lemma borel_closed[simp]:
hoelzl@40859
    44
  assumes "closed A" shows "A \<in> sets borel"
paulson@33533
    45
proof -
hoelzl@40859
    46
  have "space borel - (- A) \<in> sets borel"
hoelzl@40859
    47
    using assms unfolding closed_def by (blast intro: borel_open)
hoelzl@38656
    48
  thus ?thesis by simp
paulson@33533
    49
qed
paulson@33533
    50
hoelzl@38656
    51
lemma (in sigma_algebra) borel_measurable_vimage:
hoelzl@38656
    52
  fixes f :: "'a \<Rightarrow> 'x::t2_space"
hoelzl@38656
    53
  assumes borel: "f \<in> borel_measurable M"
hoelzl@38656
    54
  shows "f -` {x} \<inter> space M \<in> sets M"
hoelzl@38656
    55
proof (cases "x \<in> f ` space M")
hoelzl@38656
    56
  case True then obtain y where "x = f y" by auto
hoelzl@38656
    57
  from closed_sing[of "f y"]
hoelzl@40859
    58
  have "{f y} \<in> sets borel" by (rule borel_closed)
hoelzl@38656
    59
  with assms show ?thesis
hoelzl@40859
    60
    unfolding in_borel_measurable_borel `x = f y` by auto
hoelzl@38656
    61
next
hoelzl@38656
    62
  case False hence "f -` {x} \<inter> space M = {}" by auto
hoelzl@38656
    63
  thus ?thesis by auto
paulson@33533
    64
qed
paulson@33533
    65
hoelzl@38656
    66
lemma (in sigma_algebra) borel_measurableI:
hoelzl@38656
    67
  fixes f :: "'a \<Rightarrow> 'x\<Colon>topological_space"
hoelzl@38656
    68
  assumes "\<And>S. open S \<Longrightarrow> f -` S \<inter> space M \<in> sets M"
hoelzl@38656
    69
  shows "f \<in> borel_measurable M"
hoelzl@40859
    70
  unfolding borel_def
hoelzl@40859
    71
proof (rule measurable_sigma, simp_all)
hoelzl@38656
    72
  fix S :: "'x set" assume "S \<in> open" thus "f -` S \<inter> space M \<in> sets M"
hoelzl@38656
    73
    using assms[of S] by (simp add: mem_def)
hoelzl@40859
    74
qed
paulson@33533
    75
hoelzl@40859
    76
lemma borel_singleton[simp, intro]:
hoelzl@38656
    77
  fixes x :: "'a::t1_space"
hoelzl@40859
    78
  shows "A \<in> sets borel \<Longrightarrow> insert x A \<in> sets borel"
hoelzl@40859
    79
  proof (rule borel.insert_in_sets)
hoelzl@40859
    80
    show "{x} \<in> sets borel"
hoelzl@40859
    81
      using closed_sing[of x] by (rule borel_closed)
hoelzl@38656
    82
  qed simp
hoelzl@38656
    83
hoelzl@38656
    84
lemma (in sigma_algebra) borel_measurable_const[simp, intro]:
hoelzl@38656
    85
  "(\<lambda>x. c) \<in> borel_measurable M"
hoelzl@38656
    86
  by (auto intro!: measurable_const)
paulson@33533
    87
hoelzl@39083
    88
lemma (in sigma_algebra) borel_measurable_indicator[simp, intro!]:
hoelzl@38656
    89
  assumes A: "A \<in> sets M"
hoelzl@38656
    90
  shows "indicator A \<in> borel_measurable M"
hoelzl@38656
    91
  unfolding indicator_def_raw using A
hoelzl@38656
    92
  by (auto intro!: measurable_If_set borel_measurable_const)
paulson@33533
    93
hoelzl@40859
    94
lemma (in sigma_algebra) borel_measurable_indicator_iff:
hoelzl@40859
    95
  "(indicator A :: 'a \<Rightarrow> 'x::{t1_space, zero_neq_one}) \<in> borel_measurable M \<longleftrightarrow> A \<inter> space M \<in> sets M"
hoelzl@40859
    96
    (is "?I \<in> borel_measurable M \<longleftrightarrow> _")
hoelzl@40859
    97
proof
hoelzl@40859
    98
  assume "?I \<in> borel_measurable M"
hoelzl@40859
    99
  then have "?I -` {1} \<inter> space M \<in> sets M"
hoelzl@40859
   100
    unfolding measurable_def by auto
hoelzl@40859
   101
  also have "?I -` {1} \<inter> space M = A \<inter> space M"
hoelzl@40859
   102
    unfolding indicator_def_raw by auto
hoelzl@40859
   103
  finally show "A \<inter> space M \<in> sets M" .
hoelzl@40859
   104
next
hoelzl@40859
   105
  assume "A \<inter> space M \<in> sets M"
hoelzl@40859
   106
  moreover have "?I \<in> borel_measurable M \<longleftrightarrow>
hoelzl@40859
   107
    (indicator (A \<inter> space M) :: 'a \<Rightarrow> 'x) \<in> borel_measurable M"
hoelzl@40859
   108
    by (intro measurable_cong) (auto simp: indicator_def)
hoelzl@40859
   109
  ultimately show "?I \<in> borel_measurable M" by auto
hoelzl@40859
   110
qed
hoelzl@40859
   111
hoelzl@38656
   112
lemma borel_measurable_translate:
hoelzl@40859
   113
  assumes "A \<in> sets borel" and trans: "\<And>B. open B \<Longrightarrow> f -` B \<in> sets borel"
hoelzl@40859
   114
  shows "f -` A \<in> sets borel"
hoelzl@38656
   115
proof -
hoelzl@38656
   116
  have "A \<in> sigma_sets UNIV open" using assms
hoelzl@40859
   117
    by (simp add: borel_def sigma_def)
hoelzl@38656
   118
  thus ?thesis
hoelzl@38656
   119
  proof (induct rule: sigma_sets.induct)
hoelzl@38656
   120
    case (Basic a) thus ?case using trans[of a] by (simp add: mem_def)
hoelzl@38656
   121
  next
hoelzl@38656
   122
    case (Compl a)
hoelzl@40859
   123
    moreover have "UNIV \<in> sets borel"
hoelzl@40859
   124
      using borel.top by simp
hoelzl@38656
   125
    ultimately show ?case
hoelzl@40859
   126
      by (auto simp: vimage_Diff borel.Diff)
hoelzl@38656
   127
  qed (auto simp add: vimage_UN)
paulson@33533
   128
qed
paulson@33533
   129
hoelzl@39092
   130
lemma (in sigma_algebra) borel_measurable_restricted:
hoelzl@39092
   131
  fixes f :: "'a \<Rightarrow> 'x\<Colon>{topological_space, semiring_1}" assumes "A \<in> sets M"
hoelzl@39092
   132
  shows "f \<in> borel_measurable (restricted_space A) \<longleftrightarrow>
hoelzl@39092
   133
    (\<lambda>x. f x * indicator A x) \<in> borel_measurable M"
hoelzl@39092
   134
    (is "f \<in> borel_measurable ?R \<longleftrightarrow> ?f \<in> borel_measurable M")
hoelzl@39092
   135
proof -
hoelzl@39092
   136
  interpret R: sigma_algebra ?R by (rule restricted_sigma_algebra[OF `A \<in> sets M`])
hoelzl@39092
   137
  have *: "f \<in> borel_measurable ?R \<longleftrightarrow> ?f \<in> borel_measurable ?R"
hoelzl@39092
   138
    by (auto intro!: measurable_cong)
hoelzl@39092
   139
  show ?thesis unfolding *
hoelzl@40859
   140
    unfolding in_borel_measurable_borel
hoelzl@39092
   141
  proof (simp, safe)
hoelzl@40859
   142
    fix S :: "'x set" assume "S \<in> sets borel"
hoelzl@40859
   143
      "\<forall>S\<in>sets borel. ?f -` S \<inter> A \<in> op \<inter> A ` sets M"
hoelzl@39092
   144
    then have "?f -` S \<inter> A \<in> op \<inter> A ` sets M" by auto
hoelzl@39092
   145
    then have f: "?f -` S \<inter> A \<in> sets M"
hoelzl@39092
   146
      using `A \<in> sets M` sets_into_space by fastsimp
hoelzl@39092
   147
    show "?f -` S \<inter> space M \<in> sets M"
hoelzl@39092
   148
    proof cases
hoelzl@39092
   149
      assume "0 \<in> S"
hoelzl@39092
   150
      then have "?f -` S \<inter> space M = ?f -` S \<inter> A \<union> (space M - A)"
hoelzl@39092
   151
        using `A \<in> sets M` sets_into_space by auto
hoelzl@39092
   152
      then show ?thesis using f `A \<in> sets M` by (auto intro!: Un Diff)
hoelzl@39092
   153
    next
hoelzl@39092
   154
      assume "0 \<notin> S"
hoelzl@39092
   155
      then have "?f -` S \<inter> space M = ?f -` S \<inter> A"
hoelzl@39092
   156
        using `A \<in> sets M` sets_into_space
hoelzl@39092
   157
        by (auto simp: indicator_def split: split_if_asm)
hoelzl@39092
   158
      then show ?thesis using f by auto
hoelzl@39092
   159
    qed
hoelzl@39092
   160
  next
hoelzl@40859
   161
    fix S :: "'x set" assume "S \<in> sets borel"
hoelzl@40859
   162
      "\<forall>S\<in>sets borel. ?f -` S \<inter> space M \<in> sets M"
hoelzl@39092
   163
    then have f: "?f -` S \<inter> space M \<in> sets M" by auto
hoelzl@39092
   164
    then show "?f -` S \<inter> A \<in> op \<inter> A ` sets M"
hoelzl@39092
   165
      using `A \<in> sets M` sets_into_space
hoelzl@39092
   166
      apply (simp add: image_iff)
hoelzl@39092
   167
      apply (rule bexI[OF _ f])
hoelzl@39092
   168
      by auto
hoelzl@39092
   169
  qed
hoelzl@39092
   170
qed
hoelzl@39092
   171
hoelzl@39092
   172
lemma (in sigma_algebra) borel_measurable_subalgebra:
hoelzl@39092
   173
  assumes "N \<subseteq> sets M" "f \<in> borel_measurable (M\<lparr>sets:=N\<rparr>)"
hoelzl@39092
   174
  shows "f \<in> borel_measurable M"
hoelzl@39092
   175
  using assms unfolding measurable_def by auto
hoelzl@39092
   176
hoelzl@38656
   177
section "Borel spaces on euclidean spaces"
hoelzl@38656
   178
hoelzl@38656
   179
lemma lessThan_borel[simp, intro]:
hoelzl@38656
   180
  fixes a :: "'a\<Colon>ordered_euclidean_space"
hoelzl@40859
   181
  shows "{..< a} \<in> sets borel"
hoelzl@40859
   182
  by (blast intro: borel_open)
hoelzl@38656
   183
hoelzl@38656
   184
lemma greaterThan_borel[simp, intro]:
hoelzl@38656
   185
  fixes a :: "'a\<Colon>ordered_euclidean_space"
hoelzl@40859
   186
  shows "{a <..} \<in> sets borel"
hoelzl@40859
   187
  by (blast intro: borel_open)
hoelzl@38656
   188
hoelzl@38656
   189
lemma greaterThanLessThan_borel[simp, intro]:
hoelzl@38656
   190
  fixes a b :: "'a\<Colon>ordered_euclidean_space"
hoelzl@40859
   191
  shows "{a<..<b} \<in> sets borel"
hoelzl@40859
   192
  by (blast intro: borel_open)
hoelzl@38656
   193
hoelzl@38656
   194
lemma atMost_borel[simp, intro]:
hoelzl@38656
   195
  fixes a :: "'a\<Colon>ordered_euclidean_space"
hoelzl@40859
   196
  shows "{..a} \<in> sets borel"
hoelzl@40859
   197
  by (blast intro: borel_closed)
hoelzl@38656
   198
hoelzl@38656
   199
lemma atLeast_borel[simp, intro]:
hoelzl@38656
   200
  fixes a :: "'a\<Colon>ordered_euclidean_space"
hoelzl@40859
   201
  shows "{a..} \<in> sets borel"
hoelzl@40859
   202
  by (blast intro: borel_closed)
hoelzl@38656
   203
hoelzl@38656
   204
lemma atLeastAtMost_borel[simp, intro]:
hoelzl@38656
   205
  fixes a b :: "'a\<Colon>ordered_euclidean_space"
hoelzl@40859
   206
  shows "{a..b} \<in> sets borel"
hoelzl@40859
   207
  by (blast intro: borel_closed)
paulson@33533
   208
hoelzl@38656
   209
lemma greaterThanAtMost_borel[simp, intro]:
hoelzl@38656
   210
  fixes a b :: "'a\<Colon>ordered_euclidean_space"
hoelzl@40859
   211
  shows "{a<..b} \<in> sets borel"
hoelzl@38656
   212
  unfolding greaterThanAtMost_def by blast
hoelzl@38656
   213
hoelzl@38656
   214
lemma atLeastLessThan_borel[simp, intro]:
hoelzl@38656
   215
  fixes a b :: "'a\<Colon>ordered_euclidean_space"
hoelzl@40859
   216
  shows "{a..<b} \<in> sets borel"
hoelzl@38656
   217
  unfolding atLeastLessThan_def by blast
hoelzl@38656
   218
hoelzl@38656
   219
lemma hafspace_less_borel[simp, intro]:
hoelzl@38656
   220
  fixes a :: real
hoelzl@40859
   221
  shows "{x::'a::euclidean_space. a < x $$ i} \<in> sets borel"
hoelzl@40859
   222
  by (auto intro!: borel_open open_halfspace_component_gt)
paulson@33533
   223
hoelzl@38656
   224
lemma hafspace_greater_borel[simp, intro]:
hoelzl@38656
   225
  fixes a :: real
hoelzl@40859
   226
  shows "{x::'a::euclidean_space. x $$ i < a} \<in> sets borel"
hoelzl@40859
   227
  by (auto intro!: borel_open open_halfspace_component_lt)
paulson@33533
   228
hoelzl@38656
   229
lemma hafspace_less_eq_borel[simp, intro]:
hoelzl@38656
   230
  fixes a :: real
hoelzl@40859
   231
  shows "{x::'a::euclidean_space. a \<le> x $$ i} \<in> sets borel"
hoelzl@40859
   232
  by (auto intro!: borel_closed closed_halfspace_component_ge)
paulson@33533
   233
hoelzl@38656
   234
lemma hafspace_greater_eq_borel[simp, intro]:
hoelzl@38656
   235
  fixes a :: real
hoelzl@40859
   236
  shows "{x::'a::euclidean_space. x $$ i \<le> a} \<in> sets borel"
hoelzl@40859
   237
  by (auto intro!: borel_closed closed_halfspace_component_le)
paulson@33533
   238
hoelzl@38656
   239
lemma (in sigma_algebra) borel_measurable_less[simp, intro]:
hoelzl@38656
   240
  fixes f :: "'a \<Rightarrow> real"
paulson@33533
   241
  assumes f: "f \<in> borel_measurable M"
paulson@33533
   242
  assumes g: "g \<in> borel_measurable M"
paulson@33533
   243
  shows "{w \<in> space M. f w < g w} \<in> sets M"
paulson@33533
   244
proof -
paulson@33533
   245
  have "{w \<in> space M. f w < g w} =
hoelzl@38656
   246
        (\<Union>r. (f -` {..< of_rat r} \<inter> space M) \<inter> (g -` {of_rat r <..} \<inter> space M))"
hoelzl@38656
   247
    using Rats_dense_in_real by (auto simp add: Rats_def)
hoelzl@38656
   248
  then show ?thesis using f g
hoelzl@38656
   249
    by simp (blast intro: measurable_sets)
paulson@33533
   250
qed
hoelzl@38656
   251
hoelzl@38656
   252
lemma (in sigma_algebra) borel_measurable_le[simp, intro]:
hoelzl@38656
   253
  fixes f :: "'a \<Rightarrow> real"
paulson@33533
   254
  assumes f: "f \<in> borel_measurable M"
paulson@33533
   255
  assumes g: "g \<in> borel_measurable M"
paulson@33533
   256
  shows "{w \<in> space M. f w \<le> g w} \<in> sets M"
paulson@33533
   257
proof -
hoelzl@38656
   258
  have "{w \<in> space M. f w \<le> g w} = space M - {w \<in> space M. g w < f w}"
hoelzl@38656
   259
    by auto
hoelzl@38656
   260
  thus ?thesis using f g
hoelzl@38656
   261
    by simp blast
paulson@33533
   262
qed
paulson@33533
   263
hoelzl@38656
   264
lemma (in sigma_algebra) borel_measurable_eq[simp, intro]:
hoelzl@38656
   265
  fixes f :: "'a \<Rightarrow> real"
paulson@33533
   266
  assumes f: "f \<in> borel_measurable M"
paulson@33533
   267
  assumes g: "g \<in> borel_measurable M"
paulson@33533
   268
  shows "{w \<in> space M. f w = g w} \<in> sets M"
paulson@33533
   269
proof -
paulson@33533
   270
  have "{w \<in> space M. f w = g w} =
wenzelm@33536
   271
        {w \<in> space M. f w \<le> g w} \<inter> {w \<in> space M. g w \<le> f w}"
paulson@33533
   272
    by auto
hoelzl@38656
   273
  thus ?thesis using f g by auto
paulson@33533
   274
qed
paulson@33533
   275
hoelzl@38656
   276
lemma (in sigma_algebra) borel_measurable_neq[simp, intro]:
hoelzl@38656
   277
  fixes f :: "'a \<Rightarrow> real"
paulson@33533
   278
  assumes f: "f \<in> borel_measurable M"
paulson@33533
   279
  assumes g: "g \<in> borel_measurable M"
paulson@33533
   280
  shows "{w \<in> space M. f w \<noteq> g w} \<in> sets M"
paulson@33533
   281
proof -
paulson@33533
   282
  have "{w \<in> space M. f w \<noteq> g w} = space M - {w \<in> space M. f w = g w}"
paulson@33533
   283
    by auto
hoelzl@38656
   284
  thus ?thesis using f g by auto
hoelzl@38656
   285
qed
hoelzl@38656
   286
hoelzl@38656
   287
subsection "Borel space equals sigma algebras over intervals"
hoelzl@38656
   288
hoelzl@38656
   289
lemma rational_boxes:
hoelzl@38656
   290
  fixes x :: "'a\<Colon>ordered_euclidean_space"
hoelzl@38656
   291
  assumes "0 < e"
hoelzl@38656
   292
  shows "\<exists>a b. (\<forall>i. a $$ i \<in> \<rat>) \<and> (\<forall>i. b $$ i \<in> \<rat>) \<and> x \<in> {a <..< b} \<and> {a <..< b} \<subseteq> ball x e"
hoelzl@38656
   293
proof -
hoelzl@38656
   294
  def e' \<equiv> "e / (2 * sqrt (real (DIM ('a))))"
hoelzl@38656
   295
  then have e: "0 < e'" using assms by (auto intro!: divide_pos_pos)
hoelzl@38656
   296
  have "\<forall>i. \<exists>y. y \<in> \<rat> \<and> y < x $$ i \<and> x $$ i - y < e'" (is "\<forall>i. ?th i")
hoelzl@38656
   297
  proof
hoelzl@38656
   298
    fix i from Rats_dense_in_real[of "x $$ i - e'" "x $$ i"] e
hoelzl@38656
   299
    show "?th i" by auto
hoelzl@38656
   300
  qed
hoelzl@38656
   301
  from choice[OF this] guess a .. note a = this
hoelzl@38656
   302
  have "\<forall>i. \<exists>y. y \<in> \<rat> \<and> x $$ i < y \<and> y - x $$ i < e'" (is "\<forall>i. ?th i")
hoelzl@38656
   303
  proof
hoelzl@38656
   304
    fix i from Rats_dense_in_real[of "x $$ i" "x $$ i + e'"] e
hoelzl@38656
   305
    show "?th i" by auto
hoelzl@38656
   306
  qed
hoelzl@38656
   307
  from choice[OF this] guess b .. note b = this
hoelzl@38656
   308
  { fix y :: 'a assume *: "Chi a < y" "y < Chi b"
hoelzl@38656
   309
    have "dist x y = sqrt (\<Sum>i<DIM('a). (dist (x $$ i) (y $$ i))\<twosuperior>)"
hoelzl@38656
   310
      unfolding setL2_def[symmetric] by (rule euclidean_dist_l2)
hoelzl@38656
   311
    also have "\<dots> < sqrt (\<Sum>i<DIM('a). e^2 / real (DIM('a)))"
hoelzl@38656
   312
    proof (rule real_sqrt_less_mono, rule setsum_strict_mono)
hoelzl@38656
   313
      fix i assume i: "i \<in> {..<DIM('a)}"
hoelzl@38656
   314
      have "a i < y$$i \<and> y$$i < b i" using * i eucl_less[where 'a='a] by auto
hoelzl@38656
   315
      moreover have "a i < x$$i" "x$$i - a i < e'" using a by auto
hoelzl@38656
   316
      moreover have "x$$i < b i" "b i - x$$i < e'" using b by auto
hoelzl@38656
   317
      ultimately have "\<bar>x$$i - y$$i\<bar> < 2 * e'" by auto
hoelzl@38656
   318
      then have "dist (x $$ i) (y $$ i) < e/sqrt (real (DIM('a)))"
hoelzl@38656
   319
        unfolding e'_def by (auto simp: dist_real_def)
hoelzl@38656
   320
      then have "(dist (x $$ i) (y $$ i))\<twosuperior> < (e/sqrt (real (DIM('a))))\<twosuperior>"
hoelzl@38656
   321
        by (rule power_strict_mono) auto
hoelzl@38656
   322
      then show "(dist (x $$ i) (y $$ i))\<twosuperior> < e\<twosuperior> / real DIM('a)"
hoelzl@38656
   323
        by (simp add: power_divide)
hoelzl@38656
   324
    qed auto
hoelzl@38656
   325
    also have "\<dots> = e" using `0 < e` by (simp add: real_eq_of_nat DIM_positive)
hoelzl@38656
   326
    finally have "dist x y < e" . }
hoelzl@38656
   327
  with a b show ?thesis
hoelzl@38656
   328
    apply (rule_tac exI[of _ "Chi a"])
hoelzl@38656
   329
    apply (rule_tac exI[of _ "Chi b"])
hoelzl@38656
   330
    using eucl_less[where 'a='a] by auto
hoelzl@38656
   331
qed
hoelzl@38656
   332
hoelzl@38656
   333
lemma ex_rat_list:
hoelzl@38656
   334
  fixes x :: "'a\<Colon>ordered_euclidean_space"
hoelzl@38656
   335
  assumes "\<And> i. x $$ i \<in> \<rat>"
hoelzl@38656
   336
  shows "\<exists> r. length r = DIM('a) \<and> (\<forall> i < DIM('a). of_rat (r ! i) = x $$ i)"
hoelzl@38656
   337
proof -
hoelzl@38656
   338
  have "\<forall>i. \<exists>r. x $$ i = of_rat r" using assms unfolding Rats_def by blast
hoelzl@38656
   339
  from choice[OF this] guess r ..
hoelzl@38656
   340
  then show ?thesis by (auto intro!: exI[of _ "map r [0 ..< DIM('a)]"])
hoelzl@38656
   341
qed
hoelzl@38656
   342
hoelzl@38656
   343
lemma open_UNION:
hoelzl@38656
   344
  fixes M :: "'a\<Colon>ordered_euclidean_space set"
hoelzl@38656
   345
  assumes "open M"
hoelzl@38656
   346
  shows "M = UNION {(a, b) | a b. {Chi (of_rat \<circ> op ! a) <..< Chi (of_rat \<circ> op ! b)} \<subseteq> M}
hoelzl@38656
   347
                   (\<lambda> (a, b). {Chi (of_rat \<circ> op ! a) <..< Chi (of_rat \<circ> op ! b)})"
hoelzl@38656
   348
    (is "M = UNION ?idx ?box")
hoelzl@38656
   349
proof safe
hoelzl@38656
   350
  fix x assume "x \<in> M"
hoelzl@38656
   351
  obtain e where e: "e > 0" "ball x e \<subseteq> M"
hoelzl@38656
   352
    using openE[OF assms `x \<in> M`] by auto
hoelzl@38656
   353
  then obtain a b where ab: "x \<in> {a <..< b}" "\<And>i. a $$ i \<in> \<rat>" "\<And>i. b $$ i \<in> \<rat>" "{a <..< b} \<subseteq> ball x e"
hoelzl@38656
   354
    using rational_boxes[OF e(1)] by blast
hoelzl@38656
   355
  then obtain p q where pq: "length p = DIM ('a)"
hoelzl@38656
   356
                            "length q = DIM ('a)"
hoelzl@38656
   357
                            "\<forall> i < DIM ('a). of_rat (p ! i) = a $$ i \<and> of_rat (q ! i) = b $$ i"
hoelzl@38656
   358
    using ex_rat_list[OF ab(2)] ex_rat_list[OF ab(3)] by blast
hoelzl@38656
   359
  hence p: "Chi (of_rat \<circ> op ! p) = a"
hoelzl@38656
   360
    using euclidean_eq[of "Chi (of_rat \<circ> op ! p)" a]
hoelzl@38656
   361
    unfolding o_def by auto
hoelzl@38656
   362
  from pq have q: "Chi (of_rat \<circ> op ! q) = b"
hoelzl@38656
   363
    using euclidean_eq[of "Chi (of_rat \<circ> op ! q)" b]
hoelzl@38656
   364
    unfolding o_def by auto
hoelzl@38656
   365
  have "x \<in> ?box (p, q)"
hoelzl@38656
   366
    using p q ab by auto
hoelzl@38656
   367
  thus "x \<in> UNION ?idx ?box" using ab e p q exI[of _ p] exI[of _ q] by auto
hoelzl@38656
   368
qed auto
hoelzl@38656
   369
hoelzl@38656
   370
lemma halfspace_span_open:
hoelzl@40859
   371
  "sigma_sets UNIV (range (\<lambda> (a, i). {x\<Colon>'a\<Colon>ordered_euclidean_space. x $$ i < a}))
hoelzl@40859
   372
    \<subseteq> sets borel"
hoelzl@40859
   373
  by (auto intro!: borel.sigma_sets_subset[simplified] borel_open
hoelzl@40859
   374
                   open_halfspace_component_lt)
hoelzl@38656
   375
hoelzl@38656
   376
lemma halfspace_lt_in_halfspace:
hoelzl@40859
   377
  "{x\<Colon>'a. x $$ i < a} \<in> sets (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x\<Colon>'a\<Colon>ordered_euclidean_space. x $$ i < a})\<rparr>)"
hoelzl@40859
   378
  by (auto intro!: sigma_sets.Basic simp: sets_sigma)
hoelzl@38656
   379
hoelzl@38656
   380
lemma halfspace_gt_in_halfspace:
hoelzl@40859
   381
  "{x\<Colon>'a. a < x $$ i} \<in> sets (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x\<Colon>'a\<Colon>ordered_euclidean_space. x $$ i < a})\<rparr>)"
hoelzl@40859
   382
  (is "?set \<in> sets ?SIGMA")
hoelzl@38656
   383
proof -
hoelzl@40859
   384
  interpret sigma_algebra "?SIGMA"
hoelzl@40859
   385
    by (intro sigma_algebra_sigma_sets) (simp_all add: sets_sigma)
hoelzl@38656
   386
  have *: "?set = (\<Union>n. space ?SIGMA - {x\<Colon>'a. x $$ i < a + 1 / real (Suc n)})"
hoelzl@38656
   387
  proof (safe, simp_all add: not_less)
hoelzl@38656
   388
    fix x assume "a < x $$ i"
hoelzl@38656
   389
    with reals_Archimedean[of "x $$ i - a"]
hoelzl@38656
   390
    obtain n where "a + 1 / real (Suc n) < x $$ i"
hoelzl@38656
   391
      by (auto simp: inverse_eq_divide field_simps)
hoelzl@38656
   392
    then show "\<exists>n. a + 1 / real (Suc n) \<le> x $$ i"
hoelzl@38656
   393
      by (blast intro: less_imp_le)
hoelzl@38656
   394
  next
hoelzl@38656
   395
    fix x n
hoelzl@38656
   396
    have "a < a + 1 / real (Suc n)" by auto
hoelzl@38656
   397
    also assume "\<dots> \<le> x"
hoelzl@38656
   398
    finally show "a < x" .
hoelzl@38656
   399
  qed
hoelzl@38656
   400
  show "?set \<in> sets ?SIGMA" unfolding *
hoelzl@38656
   401
    by (safe intro!: countable_UN Diff halfspace_lt_in_halfspace)
paulson@33533
   402
qed
paulson@33533
   403
hoelzl@38656
   404
lemma open_span_halfspace:
hoelzl@40859
   405
  "sets borel \<subseteq> sets (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x::'a::ordered_euclidean_space. x $$ i < a})\<rparr>)"
hoelzl@38656
   406
    (is "_ \<subseteq> sets ?SIGMA")
hoelzl@40859
   407
proof -
hoelzl@40859
   408
  have "sigma_algebra ?SIGMA" by (rule sigma_algebra_sigma) simp
hoelzl@38656
   409
  then interpret sigma_algebra ?SIGMA .
hoelzl@40859
   410
  { fix S :: "'a set" assume "S \<in> open" then have "open S" unfolding mem_def .
hoelzl@40859
   411
    from open_UNION[OF this]
hoelzl@40859
   412
    obtain I where *: "S =
hoelzl@40859
   413
      (\<Union>(a, b)\<in>I.
hoelzl@40859
   414
          (\<Inter> i<DIM('a). {x. (Chi (real_of_rat \<circ> op ! a)::'a) $$ i < x $$ i}) \<inter>
hoelzl@40859
   415
          (\<Inter> i<DIM('a). {x. x $$ i < (Chi (real_of_rat \<circ> op ! b)::'a) $$ i}))"
hoelzl@40859
   416
      unfolding greaterThanLessThan_def
hoelzl@40859
   417
      unfolding eucl_greaterThan_eq_halfspaces[where 'a='a]
hoelzl@40859
   418
      unfolding eucl_lessThan_eq_halfspaces[where 'a='a]
hoelzl@40859
   419
      by blast
hoelzl@40859
   420
    have "S \<in> sets ?SIGMA"
hoelzl@40859
   421
      unfolding *
hoelzl@40859
   422
      by (auto intro!: countable_UN Int countable_INT halfspace_lt_in_halfspace halfspace_gt_in_halfspace) }
hoelzl@40859
   423
  then show ?thesis unfolding borel_def
hoelzl@40859
   424
    by (intro sets_sigma_subset) auto
hoelzl@40859
   425
qed
hoelzl@38656
   426
hoelzl@38656
   427
lemma halfspace_span_halfspace_le:
hoelzl@40859
   428
  "sets (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x\<Colon>'a\<Colon>ordered_euclidean_space. x $$ i < a})\<rparr>) \<subseteq>
hoelzl@40859
   429
   sets (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x. x $$ i \<le> a})\<rparr>)"
hoelzl@38656
   430
  (is "_ \<subseteq> sets ?SIGMA")
hoelzl@40859
   431
proof -
hoelzl@40859
   432
  have "sigma_algebra ?SIGMA" by (rule sigma_algebra_sigma) auto
hoelzl@38656
   433
  then interpret sigma_algebra ?SIGMA .
hoelzl@40859
   434
  { fix a i
hoelzl@40859
   435
    have *: "{x::'a. x$$i < a} = (\<Union>n. {x. x$$i \<le> a - 1/real (Suc n)})"
hoelzl@40859
   436
    proof (safe, simp_all)
hoelzl@40859
   437
      fix x::'a assume *: "x$$i < a"
hoelzl@40859
   438
      with reals_Archimedean[of "a - x$$i"]
hoelzl@40859
   439
      obtain n where "x $$ i < a - 1 / (real (Suc n))"
hoelzl@40859
   440
        by (auto simp: field_simps inverse_eq_divide)
hoelzl@40859
   441
      then show "\<exists>n. x $$ i \<le> a - 1 / (real (Suc n))"
hoelzl@40859
   442
        by (blast intro: less_imp_le)
hoelzl@40859
   443
    next
hoelzl@40859
   444
      fix x::'a and n
hoelzl@40859
   445
      assume "x$$i \<le> a - 1 / real (Suc n)"
hoelzl@40859
   446
      also have "\<dots> < a" by auto
hoelzl@40859
   447
      finally show "x$$i < a" .
hoelzl@40859
   448
    qed
hoelzl@40859
   449
    have "{x. x$$i < a} \<in> sets ?SIGMA" unfolding *
hoelzl@40859
   450
      by (safe intro!: countable_UN)
hoelzl@40859
   451
         (auto simp: sets_sigma intro!: sigma_sets.Basic) }
hoelzl@40859
   452
  then show ?thesis by (intro sets_sigma_subset) auto
hoelzl@40859
   453
qed
hoelzl@38656
   454
hoelzl@38656
   455
lemma halfspace_span_halfspace_ge:
hoelzl@40859
   456
  "sets (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x\<Colon>'a\<Colon>ordered_euclidean_space. x $$ i < a})\<rparr>) \<subseteq>
hoelzl@40859
   457
   sets (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x. a \<le> x $$ i})\<rparr>)"
hoelzl@38656
   458
  (is "_ \<subseteq> sets ?SIGMA")
hoelzl@40859
   459
proof -
hoelzl@40859
   460
  have "sigma_algebra ?SIGMA" by (rule sigma_algebra_sigma) auto
hoelzl@38656
   461
  then interpret sigma_algebra ?SIGMA .
hoelzl@40859
   462
  { fix a i have *: "{x::'a. x$$i < a} = space ?SIGMA - {x::'a. a \<le> x$$i}" by auto
hoelzl@40859
   463
    have "{x. x$$i < a} \<in> sets ?SIGMA" unfolding *
hoelzl@40859
   464
      by (safe intro!: Diff)
hoelzl@40859
   465
         (auto simp: sets_sigma intro!: sigma_sets.Basic) }
hoelzl@40859
   466
  then show ?thesis by (intro sets_sigma_subset) auto
hoelzl@40859
   467
qed
hoelzl@38656
   468
hoelzl@38656
   469
lemma halfspace_le_span_halfspace_gt:
hoelzl@40859
   470
  "sets (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x\<Colon>'a\<Colon>ordered_euclidean_space. x $$ i \<le> a})\<rparr>) \<subseteq>
hoelzl@40859
   471
   sets (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x. a < x $$ i})\<rparr>)"
hoelzl@38656
   472
  (is "_ \<subseteq> sets ?SIGMA")
hoelzl@40859
   473
proof -
hoelzl@40859
   474
  have "sigma_algebra ?SIGMA" by (rule sigma_algebra_sigma) auto
hoelzl@38656
   475
  then interpret sigma_algebra ?SIGMA .
hoelzl@40859
   476
  { fix a i have *: "{x::'a. x$$i \<le> a} = space ?SIGMA - {x::'a. a < x$$i}" by auto
hoelzl@40859
   477
    have "{x. x$$i \<le> a} \<in> sets ?SIGMA" unfolding *
hoelzl@40859
   478
      by (safe intro!: Diff)
hoelzl@40859
   479
         (auto simp: sets_sigma intro!: sigma_sets.Basic) }
hoelzl@40859
   480
  then show ?thesis by (intro sets_sigma_subset) auto
hoelzl@40859
   481
qed
hoelzl@38656
   482
hoelzl@38656
   483
lemma halfspace_le_span_atMost:
hoelzl@40859
   484
  "sets (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x\<Colon>'a\<Colon>ordered_euclidean_space. x $$ i \<le> a})\<rparr>) \<subseteq>
hoelzl@40859
   485
   sets (sigma \<lparr>space=UNIV, sets=range (\<lambda>a. {..a\<Colon>'a\<Colon>ordered_euclidean_space})\<rparr>)"
hoelzl@38656
   486
  (is "_ \<subseteq> sets ?SIGMA")
hoelzl@40859
   487
proof -
hoelzl@40859
   488
  have "sigma_algebra ?SIGMA" by (rule sigma_algebra_sigma) auto
hoelzl@38656
   489
  then interpret sigma_algebra ?SIGMA .
hoelzl@40859
   490
  have "\<And>a i. {x. x$$i \<le> a} \<in> sets ?SIGMA"
hoelzl@38656
   491
  proof cases
hoelzl@40859
   492
    fix a i assume "i < DIM('a)"
hoelzl@38656
   493
    then have *: "{x::'a. x$$i \<le> a} = (\<Union>k::nat. {.. (\<chi>\<chi> n. if n = i then a else real k)})"
hoelzl@38656
   494
    proof (safe, simp_all add: eucl_le[where 'a='a] split: split_if_asm)
hoelzl@38656
   495
      fix x
hoelzl@38656
   496
      from real_arch_simple[of "Max ((\<lambda>i. x$$i)`{..<DIM('a)})"] guess k::nat ..
hoelzl@38656
   497
      then have "\<And>i. i < DIM('a) \<Longrightarrow> x$$i \<le> real k"
hoelzl@38656
   498
        by (subst (asm) Max_le_iff) auto
hoelzl@38656
   499
      then show "\<exists>k::nat. \<forall>ia. ia \<noteq> i \<longrightarrow> ia < DIM('a) \<longrightarrow> x $$ ia \<le> real k"
hoelzl@38656
   500
        by (auto intro!: exI[of _ k])
hoelzl@38656
   501
    qed
hoelzl@38656
   502
    show "{x. x$$i \<le> a} \<in> sets ?SIGMA" unfolding *
hoelzl@38656
   503
      by (safe intro!: countable_UN)
hoelzl@38656
   504
         (auto simp: sets_sigma intro!: sigma_sets.Basic)
hoelzl@38656
   505
  next
hoelzl@40859
   506
    fix a i assume "\<not> i < DIM('a)"
hoelzl@38656
   507
    then show "{x. x$$i \<le> a} \<in> sets ?SIGMA"
hoelzl@38656
   508
      using top by auto
hoelzl@38656
   509
  qed
hoelzl@40859
   510
  then show ?thesis by (intro sets_sigma_subset) auto
hoelzl@40859
   511
qed
hoelzl@38656
   512
hoelzl@38656
   513
lemma halfspace_le_span_greaterThan:
hoelzl@40859
   514
  "sets (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x\<Colon>'a\<Colon>ordered_euclidean_space. x $$ i \<le> a})\<rparr>) \<subseteq>
hoelzl@40859
   515
   sets (sigma \<lparr>space=UNIV, sets=range (\<lambda>a. {a<..})\<rparr>)"
hoelzl@38656
   516
  (is "_ \<subseteq> sets ?SIGMA")
hoelzl@40859
   517
proof -
hoelzl@40859
   518
  have "sigma_algebra ?SIGMA" by (rule sigma_algebra_sigma) auto
hoelzl@38656
   519
  then interpret sigma_algebra ?SIGMA .
hoelzl@40859
   520
  have "\<And>a i. {x. x$$i \<le> a} \<in> sets ?SIGMA"
hoelzl@38656
   521
  proof cases
hoelzl@40859
   522
    fix a i assume "i < DIM('a)"
hoelzl@38656
   523
    have "{x::'a. x$$i \<le> a} = space ?SIGMA - {x::'a. a < x$$i}" by auto
hoelzl@38656
   524
    also have *: "{x::'a. a < x$$i} = (\<Union>k::nat. {(\<chi>\<chi> n. if n = i then a else -real k) <..})" using `i <DIM('a)`
hoelzl@38656
   525
    proof (safe, simp_all add: eucl_less[where 'a='a] split: split_if_asm)
hoelzl@38656
   526
      fix x
hoelzl@38656
   527
      from real_arch_lt[of "Max ((\<lambda>i. -x$$i)`{..<DIM('a)})"]
hoelzl@38656
   528
      guess k::nat .. note k = this
hoelzl@38656
   529
      { fix i assume "i < DIM('a)"
hoelzl@38656
   530
        then have "-x$$i < real k"
hoelzl@38656
   531
          using k by (subst (asm) Max_less_iff) auto
hoelzl@38656
   532
        then have "- real k < x$$i" by simp }
hoelzl@38656
   533
      then show "\<exists>k::nat. \<forall>ia. ia \<noteq> i \<longrightarrow> ia < DIM('a) \<longrightarrow> -real k < x $$ ia"
hoelzl@38656
   534
        by (auto intro!: exI[of _ k])
hoelzl@38656
   535
    qed
hoelzl@38656
   536
    finally show "{x. x$$i \<le> a} \<in> sets ?SIGMA"
hoelzl@38656
   537
      apply (simp only:)
hoelzl@38656
   538
      apply (safe intro!: countable_UN Diff)
hoelzl@38656
   539
      by (auto simp: sets_sigma intro!: sigma_sets.Basic)
hoelzl@38656
   540
  next
hoelzl@40859
   541
    fix a i assume "\<not> i < DIM('a)"
hoelzl@38656
   542
    then show "{x. x$$i \<le> a} \<in> sets ?SIGMA"
hoelzl@38656
   543
      using top by auto
hoelzl@38656
   544
  qed
hoelzl@40859
   545
  then show ?thesis by (intro sets_sigma_subset) auto
hoelzl@40859
   546
qed
hoelzl@40859
   547
hoelzl@40859
   548
lemma halfspace_le_span_lessThan:
hoelzl@40859
   549
  "sets (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x\<Colon>'a\<Colon>ordered_euclidean_space. a \<le> x $$ i})\<rparr>) \<subseteq>
hoelzl@40859
   550
   sets (sigma \<lparr>space=UNIV, sets=range (\<lambda>a. {..<a})\<rparr>)"
hoelzl@40859
   551
  (is "_ \<subseteq> sets ?SIGMA")
hoelzl@40859
   552
proof -
hoelzl@40859
   553
  have "sigma_algebra ?SIGMA" by (rule sigma_algebra_sigma) auto
hoelzl@40859
   554
  then interpret sigma_algebra ?SIGMA .
hoelzl@40859
   555
  have "\<And>a i. {x. a \<le> x$$i} \<in> sets ?SIGMA"
hoelzl@40859
   556
  proof cases
hoelzl@40859
   557
    fix a i assume "i < DIM('a)"
hoelzl@40859
   558
    have "{x::'a. a \<le> x$$i} = space ?SIGMA - {x::'a. x$$i < a}" by auto
hoelzl@40859
   559
    also have *: "{x::'a. x$$i < a} = (\<Union>k::nat. {..< (\<chi>\<chi> n. if n = i then a else real k)})" using `i <DIM('a)`
hoelzl@40859
   560
    proof (safe, simp_all add: eucl_less[where 'a='a] split: split_if_asm)
hoelzl@40859
   561
      fix x
hoelzl@40859
   562
      from real_arch_lt[of "Max ((\<lambda>i. x$$i)`{..<DIM('a)})"]
hoelzl@40859
   563
      guess k::nat .. note k = this
hoelzl@40859
   564
      { fix i assume "i < DIM('a)"
hoelzl@40859
   565
        then have "x$$i < real k"
hoelzl@40859
   566
          using k by (subst (asm) Max_less_iff) auto
hoelzl@40859
   567
        then have "x$$i < real k" by simp }
hoelzl@40859
   568
      then show "\<exists>k::nat. \<forall>ia. ia \<noteq> i \<longrightarrow> ia < DIM('a) \<longrightarrow> x $$ ia < real k"
hoelzl@40859
   569
        by (auto intro!: exI[of _ k])
hoelzl@40859
   570
    qed
hoelzl@40859
   571
    finally show "{x. a \<le> x$$i} \<in> sets ?SIGMA"
hoelzl@40859
   572
      apply (simp only:)
hoelzl@40859
   573
      apply (safe intro!: countable_UN Diff)
hoelzl@40859
   574
      by (auto simp: sets_sigma intro!: sigma_sets.Basic)
hoelzl@40859
   575
  next
hoelzl@40859
   576
    fix a i assume "\<not> i < DIM('a)"
hoelzl@40859
   577
    then show "{x. a \<le> x$$i} \<in> sets ?SIGMA"
hoelzl@40859
   578
      using top by auto
hoelzl@40859
   579
  qed
hoelzl@40859
   580
  then show ?thesis by (intro sets_sigma_subset) auto
hoelzl@40859
   581
qed
hoelzl@40859
   582
hoelzl@40859
   583
lemma atMost_span_atLeastAtMost:
hoelzl@40859
   584
  "sets (sigma \<lparr>space=UNIV, sets=range (\<lambda>a. {..a\<Colon>'a\<Colon>ordered_euclidean_space})\<rparr>) \<subseteq>
hoelzl@40859
   585
   sets (sigma \<lparr>space=UNIV, sets=range (\<lambda>(a,b). {a..b})\<rparr>)"
hoelzl@40859
   586
  (is "_ \<subseteq> sets ?SIGMA")
hoelzl@40859
   587
proof -
hoelzl@40859
   588
  have "sigma_algebra ?SIGMA" by (rule sigma_algebra_sigma) auto
hoelzl@40859
   589
  then interpret sigma_algebra ?SIGMA .
hoelzl@40859
   590
  { fix a::'a
hoelzl@40859
   591
    have *: "{..a} = (\<Union>n::nat. {- real n *\<^sub>R One .. a})"
hoelzl@40859
   592
    proof (safe, simp_all add: eucl_le[where 'a='a])
hoelzl@40859
   593
      fix x
hoelzl@40859
   594
      from real_arch_simple[of "Max ((\<lambda>i. - x$$i)`{..<DIM('a)})"]
hoelzl@40859
   595
      guess k::nat .. note k = this
hoelzl@40859
   596
      { fix i assume "i < DIM('a)"
hoelzl@40859
   597
        with k have "- x$$i \<le> real k"
hoelzl@40859
   598
          by (subst (asm) Max_le_iff) (auto simp: field_simps)
hoelzl@40859
   599
        then have "- real k \<le> x$$i" by simp }
hoelzl@40859
   600
      then show "\<exists>n::nat. \<forall>i<DIM('a). - real n \<le> x $$ i"
hoelzl@40859
   601
        by (auto intro!: exI[of _ k])
hoelzl@40859
   602
    qed
hoelzl@40859
   603
    have "{..a} \<in> sets ?SIGMA" unfolding *
hoelzl@40859
   604
      by (safe intro!: countable_UN)
hoelzl@40859
   605
         (auto simp: sets_sigma intro!: sigma_sets.Basic) }
hoelzl@40859
   606
  then show ?thesis by (intro sets_sigma_subset) auto
hoelzl@40859
   607
qed
hoelzl@40859
   608
hoelzl@40859
   609
lemma borel_eq_atMost:
hoelzl@40859
   610
  "borel = (sigma \<lparr>space=UNIV, sets=range (\<lambda> a. {.. a::'a\<Colon>ordered_euclidean_space})\<rparr>)"
hoelzl@40859
   611
    (is "_ = ?SIGMA")
hoelzl@40869
   612
proof (intro algebra.equality antisym)
hoelzl@40859
   613
  show "sets borel \<subseteq> sets ?SIGMA"
hoelzl@40859
   614
    using halfspace_le_span_atMost halfspace_span_halfspace_le open_span_halfspace
hoelzl@40859
   615
    by auto
hoelzl@40859
   616
  show "sets ?SIGMA \<subseteq> sets borel"
hoelzl@40859
   617
    by (rule borel.sets_sigma_subset) auto
hoelzl@40859
   618
qed auto
hoelzl@40859
   619
hoelzl@40859
   620
lemma borel_eq_atLeastAtMost:
hoelzl@40859
   621
  "borel = (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a :: 'a\<Colon>ordered_euclidean_space, b). {a .. b})\<rparr>)"
hoelzl@40859
   622
   (is "_ = ?SIGMA")
hoelzl@40869
   623
proof (intro algebra.equality antisym)
hoelzl@40859
   624
  show "sets borel \<subseteq> sets ?SIGMA"
hoelzl@40859
   625
    using atMost_span_atLeastAtMost halfspace_le_span_atMost
hoelzl@40859
   626
      halfspace_span_halfspace_le open_span_halfspace
hoelzl@40859
   627
    by auto
hoelzl@40859
   628
  show "sets ?SIGMA \<subseteq> sets borel"
hoelzl@40859
   629
    by (rule borel.sets_sigma_subset) auto
hoelzl@40859
   630
qed auto
hoelzl@40859
   631
hoelzl@40859
   632
lemma borel_eq_greaterThan:
hoelzl@40859
   633
  "borel = (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a :: 'a\<Colon>ordered_euclidean_space). {a <..})\<rparr>)"
hoelzl@40859
   634
   (is "_ = ?SIGMA")
hoelzl@40869
   635
proof (intro algebra.equality antisym)
hoelzl@40859
   636
  show "sets borel \<subseteq> sets ?SIGMA"
hoelzl@40859
   637
    using halfspace_le_span_greaterThan
hoelzl@40859
   638
      halfspace_span_halfspace_le open_span_halfspace
hoelzl@40859
   639
    by auto
hoelzl@40859
   640
  show "sets ?SIGMA \<subseteq> sets borel"
hoelzl@40859
   641
    by (rule borel.sets_sigma_subset) auto
hoelzl@40859
   642
qed auto
hoelzl@40859
   643
hoelzl@40859
   644
lemma borel_eq_lessThan:
hoelzl@40859
   645
  "borel = (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a :: 'a\<Colon>ordered_euclidean_space). {..< a})\<rparr>)"
hoelzl@40859
   646
   (is "_ = ?SIGMA")
hoelzl@40869
   647
proof (intro algebra.equality antisym)
hoelzl@40859
   648
  show "sets borel \<subseteq> sets ?SIGMA"
hoelzl@40859
   649
    using halfspace_le_span_lessThan
hoelzl@40859
   650
      halfspace_span_halfspace_ge open_span_halfspace
hoelzl@40859
   651
    by auto
hoelzl@40859
   652
  show "sets ?SIGMA \<subseteq> sets borel"
hoelzl@40859
   653
    by (rule borel.sets_sigma_subset) auto
hoelzl@40859
   654
qed auto
hoelzl@40859
   655
hoelzl@40859
   656
lemma borel_eq_greaterThanLessThan:
hoelzl@40859
   657
  "borel = (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, b). {a <..< (b :: 'a \<Colon> ordered_euclidean_space)})\<rparr>)"
hoelzl@40859
   658
    (is "_ = ?SIGMA")
hoelzl@40869
   659
proof (intro algebra.equality antisym)
hoelzl@40859
   660
  show "sets ?SIGMA \<subseteq> sets borel"
hoelzl@40859
   661
    by (rule borel.sets_sigma_subset) auto
hoelzl@40859
   662
  show "sets borel \<subseteq> sets ?SIGMA"
hoelzl@40859
   663
  proof -
hoelzl@40859
   664
    have "sigma_algebra ?SIGMA" by (rule sigma_algebra_sigma) auto
hoelzl@40859
   665
    then interpret sigma_algebra ?SIGMA .
hoelzl@40859
   666
    { fix M :: "'a set" assume "M \<in> open"
hoelzl@40859
   667
      then have "open M" by (simp add: mem_def)
hoelzl@40859
   668
      have "M \<in> sets ?SIGMA"
hoelzl@40859
   669
        apply (subst open_UNION[OF `open M`])
hoelzl@40859
   670
        apply (safe intro!: countable_UN)
hoelzl@40859
   671
        by (auto simp add: sigma_def intro!: sigma_sets.Basic) }
hoelzl@40859
   672
    then show ?thesis
hoelzl@40859
   673
      unfolding borel_def by (intro sets_sigma_subset) auto
hoelzl@40859
   674
  qed
hoelzl@38656
   675
qed auto
hoelzl@38656
   676
hoelzl@40859
   677
lemma borel_eq_halfspace_le:
hoelzl@40859
   678
  "borel = (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x::'a::ordered_euclidean_space. x$$i \<le> a})\<rparr>)"
hoelzl@40859
   679
   (is "_ = ?SIGMA")
hoelzl@40869
   680
proof (intro algebra.equality antisym)
hoelzl@40859
   681
  show "sets borel \<subseteq> sets ?SIGMA"
hoelzl@40859
   682
    using open_span_halfspace halfspace_span_halfspace_le by auto
hoelzl@40859
   683
  show "sets ?SIGMA \<subseteq> sets borel"
hoelzl@40859
   684
    by (rule borel.sets_sigma_subset) auto
hoelzl@40859
   685
qed auto
hoelzl@40859
   686
hoelzl@40859
   687
lemma borel_eq_halfspace_less:
hoelzl@40859
   688
  "borel = (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x::'a::ordered_euclidean_space. x$$i < a})\<rparr>)"
hoelzl@40859
   689
   (is "_ = ?SIGMA")
hoelzl@40869
   690
proof (intro algebra.equality antisym)
hoelzl@40859
   691
  show "sets borel \<subseteq> sets ?SIGMA"
hoelzl@40859
   692
    using open_span_halfspace .
hoelzl@40859
   693
  show "sets ?SIGMA \<subseteq> sets borel"
hoelzl@40859
   694
    by (rule borel.sets_sigma_subset) auto
hoelzl@38656
   695
qed auto
hoelzl@38656
   696
hoelzl@40859
   697
lemma borel_eq_halfspace_gt:
hoelzl@40859
   698
  "borel = (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x::'a::ordered_euclidean_space. a < x$$i})\<rparr>)"
hoelzl@40859
   699
   (is "_ = ?SIGMA")
hoelzl@40869
   700
proof (intro algebra.equality antisym)
hoelzl@40859
   701
  show "sets borel \<subseteq> sets ?SIGMA"
hoelzl@40859
   702
    using halfspace_le_span_halfspace_gt open_span_halfspace halfspace_span_halfspace_le by auto
hoelzl@40859
   703
  show "sets ?SIGMA \<subseteq> sets borel"
hoelzl@40859
   704
    by (rule borel.sets_sigma_subset) auto
hoelzl@40859
   705
qed auto
hoelzl@38656
   706
hoelzl@40859
   707
lemma borel_eq_halfspace_ge:
hoelzl@40859
   708
  "borel = (sigma \<lparr>space=UNIV, sets=range (\<lambda> (a, i). {x::'a::ordered_euclidean_space. a \<le> x$$i})\<rparr>)"
hoelzl@40859
   709
   (is "_ = ?SIGMA")
hoelzl@40869
   710
proof (intro algebra.equality antisym)
hoelzl@40859
   711
  show "sets borel \<subseteq> sets ?SIGMA"
hoelzl@38656
   712
    using halfspace_span_halfspace_ge open_span_halfspace by auto
hoelzl@40859
   713
  show "sets ?SIGMA \<subseteq> sets borel"
hoelzl@40859
   714
    by (rule borel.sets_sigma_subset) auto
hoelzl@40859
   715
qed auto
hoelzl@38656
   716
hoelzl@38656
   717
lemma (in sigma_algebra) borel_measurable_halfspacesI:
hoelzl@38656
   718
  fixes f :: "'a \<Rightarrow> 'c\<Colon>ordered_euclidean_space"
hoelzl@40859
   719
  assumes "borel = (sigma \<lparr>space=UNIV, sets=range F\<rparr>)"
hoelzl@38656
   720
  and "\<And>a i. S a i = f -` F (a,i) \<inter> space M"
hoelzl@38656
   721
  and "\<And>a i. \<not> i < DIM('c) \<Longrightarrow> S a i \<in> sets M"
hoelzl@38656
   722
  shows "f \<in> borel_measurable M = (\<forall>i<DIM('c). \<forall>a::real. S a i \<in> sets M)"
hoelzl@38656
   723
proof safe
hoelzl@38656
   724
  fix a :: real and i assume i: "i < DIM('c)" and f: "f \<in> borel_measurable M"
hoelzl@38656
   725
  then show "S a i \<in> sets M" unfolding assms
hoelzl@38656
   726
    by (auto intro!: measurable_sets sigma_sets.Basic simp: assms(1) sigma_def)
hoelzl@38656
   727
next
hoelzl@38656
   728
  assume a: "\<forall>i<DIM('c). \<forall>a. S a i \<in> sets M"
hoelzl@38656
   729
  { fix a i have "S a i \<in> sets M"
hoelzl@38656
   730
    proof cases
hoelzl@38656
   731
      assume "i < DIM('c)"
hoelzl@38656
   732
      with a show ?thesis unfolding assms(2) by simp
hoelzl@38656
   733
    next
hoelzl@38656
   734
      assume "\<not> i < DIM('c)"
hoelzl@38656
   735
      from assms(3)[OF this] show ?thesis .
hoelzl@38656
   736
    qed }
hoelzl@40859
   737
  then have "f \<in> measurable M (sigma \<lparr>space=UNIV, sets=range F\<rparr>)"
hoelzl@38656
   738
    by (auto intro!: measurable_sigma simp: assms(2))
hoelzl@38656
   739
  then show "f \<in> borel_measurable M" unfolding measurable_def
hoelzl@38656
   740
    unfolding assms(1) by simp
hoelzl@38656
   741
qed
hoelzl@38656
   742
hoelzl@38656
   743
lemma (in sigma_algebra) borel_measurable_iff_halfspace_le:
hoelzl@38656
   744
  fixes f :: "'a \<Rightarrow> 'c\<Colon>ordered_euclidean_space"
hoelzl@38656
   745
  shows "f \<in> borel_measurable M = (\<forall>i<DIM('c). \<forall>a. {w \<in> space M. f w $$ i \<le> a} \<in> sets M)"
hoelzl@40859
   746
  by (rule borel_measurable_halfspacesI[OF borel_eq_halfspace_le]) auto
hoelzl@38656
   747
hoelzl@38656
   748
lemma (in sigma_algebra) borel_measurable_iff_halfspace_less:
hoelzl@38656
   749
  fixes f :: "'a \<Rightarrow> 'c\<Colon>ordered_euclidean_space"
hoelzl@38656
   750
  shows "f \<in> borel_measurable M \<longleftrightarrow> (\<forall>i<DIM('c). \<forall>a. {w \<in> space M. f w $$ i < a} \<in> sets M)"
hoelzl@40859
   751
  by (rule borel_measurable_halfspacesI[OF borel_eq_halfspace_less]) auto
hoelzl@38656
   752
hoelzl@38656
   753
lemma (in sigma_algebra) borel_measurable_iff_halfspace_ge:
hoelzl@38656
   754
  fixes f :: "'a \<Rightarrow> 'c\<Colon>ordered_euclidean_space"
hoelzl@38656
   755
  shows "f \<in> borel_measurable M = (\<forall>i<DIM('c). \<forall>a. {w \<in> space M. a \<le> f w $$ i} \<in> sets M)"
hoelzl@40859
   756
  by (rule borel_measurable_halfspacesI[OF borel_eq_halfspace_ge]) auto
hoelzl@38656
   757
hoelzl@38656
   758
lemma (in sigma_algebra) borel_measurable_iff_halfspace_greater:
hoelzl@38656
   759
  fixes f :: "'a \<Rightarrow> 'c\<Colon>ordered_euclidean_space"
hoelzl@38656
   760
  shows "f \<in> borel_measurable M \<longleftrightarrow> (\<forall>i<DIM('c). \<forall>a. {w \<in> space M. a < f w $$ i} \<in> sets M)"
hoelzl@40859
   761
  by (rule borel_measurable_halfspacesI[OF borel_eq_halfspace_gt]) auto
hoelzl@38656
   762
hoelzl@38656
   763
lemma (in sigma_algebra) borel_measurable_iff_le:
hoelzl@38656
   764
  "(f::'a \<Rightarrow> real) \<in> borel_measurable M = (\<forall>a. {w \<in> space M. f w \<le> a} \<in> sets M)"
hoelzl@38656
   765
  using borel_measurable_iff_halfspace_le[where 'c=real] by simp
hoelzl@38656
   766
hoelzl@38656
   767
lemma (in sigma_algebra) borel_measurable_iff_less:
hoelzl@38656
   768
  "(f::'a \<Rightarrow> real) \<in> borel_measurable M = (\<forall>a. {w \<in> space M. f w < a} \<in> sets M)"
hoelzl@38656
   769
  using borel_measurable_iff_halfspace_less[where 'c=real] by simp
hoelzl@38656
   770
hoelzl@38656
   771
lemma (in sigma_algebra) borel_measurable_iff_ge:
hoelzl@38656
   772
  "(f::'a \<Rightarrow> real) \<in> borel_measurable M = (\<forall>a. {w \<in> space M. a \<le> f w} \<in> sets M)"
hoelzl@38656
   773
  using borel_measurable_iff_halfspace_ge[where 'c=real] by simp
hoelzl@38656
   774
hoelzl@38656
   775
lemma (in sigma_algebra) borel_measurable_iff_greater:
hoelzl@38656
   776
  "(f::'a \<Rightarrow> real) \<in> borel_measurable M = (\<forall>a. {w \<in> space M. a < f w} \<in> sets M)"
hoelzl@38656
   777
  using borel_measurable_iff_halfspace_greater[where 'c=real] by simp
hoelzl@38656
   778
hoelzl@41025
   779
lemma borel_measurable_euclidean_component:
hoelzl@40859
   780
  "(\<lambda>x::'a::euclidean_space. x $$ i) \<in> borel_measurable borel"
hoelzl@40859
   781
  unfolding borel_def[where 'a=real]
hoelzl@40859
   782
proof (rule borel.measurable_sigma, simp_all)
hoelzl@39087
   783
  fix S::"real set" assume "S \<in> open" then have "open S" unfolding mem_def .
hoelzl@39087
   784
  from open_vimage_euclidean_component[OF this]
hoelzl@40859
   785
  show "(\<lambda>x. x $$ i) -` S \<in> sets borel"
hoelzl@40859
   786
    by (auto intro: borel_open)
hoelzl@40859
   787
qed
hoelzl@39087
   788
hoelzl@41025
   789
lemma (in sigma_algebra) borel_measurable_euclidean_space:
hoelzl@39087
   790
  fixes f :: "'a \<Rightarrow> 'c::ordered_euclidean_space"
hoelzl@39087
   791
  shows "f \<in> borel_measurable M \<longleftrightarrow> (\<forall>i<DIM('c). (\<lambda>x. f x $$ i) \<in> borel_measurable M)"
hoelzl@39087
   792
proof safe
hoelzl@39087
   793
  fix i assume "f \<in> borel_measurable M"
hoelzl@39087
   794
  then show "(\<lambda>x. f x $$ i) \<in> borel_measurable M"
hoelzl@39087
   795
    using measurable_comp[of f _ _ "\<lambda>x. x $$ i", unfolded comp_def]
hoelzl@41025
   796
    by (auto intro: borel_measurable_euclidean_component)
hoelzl@39087
   797
next
hoelzl@39087
   798
  assume f: "\<forall>i<DIM('c). (\<lambda>x. f x $$ i) \<in> borel_measurable M"
hoelzl@39087
   799
  then show "f \<in> borel_measurable M"
hoelzl@39087
   800
    unfolding borel_measurable_iff_halfspace_le by auto
hoelzl@39087
   801
qed
hoelzl@39087
   802
hoelzl@38656
   803
subsection "Borel measurable operators"
hoelzl@38656
   804
hoelzl@38656
   805
lemma (in sigma_algebra) affine_borel_measurable_vector:
hoelzl@38656
   806
  fixes f :: "'a \<Rightarrow> 'x::real_normed_vector"
hoelzl@38656
   807
  assumes "f \<in> borel_measurable M"
hoelzl@38656
   808
  shows "(\<lambda>x. a + b *\<^sub>R f x) \<in> borel_measurable M"
hoelzl@38656
   809
proof (rule borel_measurableI)
hoelzl@38656
   810
  fix S :: "'x set" assume "open S"
hoelzl@38656
   811
  show "(\<lambda>x. a + b *\<^sub>R f x) -` S \<inter> space M \<in> sets M"
hoelzl@38656
   812
  proof cases
hoelzl@38656
   813
    assume "b \<noteq> 0"
hoelzl@38656
   814
    with `open S` have "((\<lambda>x. (- a + x) /\<^sub>R b) ` S) \<in> open" (is "?S \<in> open")
hoelzl@38656
   815
      by (auto intro!: open_affinity simp: scaleR.add_right mem_def)
hoelzl@40859
   816
    hence "?S \<in> sets borel"
hoelzl@40859
   817
      unfolding borel_def by (auto simp: sigma_def intro!: sigma_sets.Basic)
hoelzl@38656
   818
    moreover
hoelzl@38656
   819
    from `b \<noteq> 0` have "(\<lambda>x. a + b *\<^sub>R f x) -` S = f -` ?S"
hoelzl@38656
   820
      apply auto by (rule_tac x="a + b *\<^sub>R f x" in image_eqI, simp_all)
hoelzl@40859
   821
    ultimately show ?thesis using assms unfolding in_borel_measurable_borel
hoelzl@38656
   822
      by auto
hoelzl@38656
   823
  qed simp
hoelzl@38656
   824
qed
hoelzl@38656
   825
hoelzl@38656
   826
lemma (in sigma_algebra) affine_borel_measurable:
hoelzl@38656
   827
  fixes g :: "'a \<Rightarrow> real"
hoelzl@38656
   828
  assumes g: "g \<in> borel_measurable M"
hoelzl@38656
   829
  shows "(\<lambda>x. a + (g x) * b) \<in> borel_measurable M"
hoelzl@38656
   830
  using affine_borel_measurable_vector[OF assms] by (simp add: mult_commute)
hoelzl@38656
   831
hoelzl@38656
   832
lemma (in sigma_algebra) borel_measurable_add[simp, intro]:
hoelzl@38656
   833
  fixes f :: "'a \<Rightarrow> real"
paulson@33533
   834
  assumes f: "f \<in> borel_measurable M"
paulson@33533
   835
  assumes g: "g \<in> borel_measurable M"
paulson@33533
   836
  shows "(\<lambda>x. f x + g x) \<in> borel_measurable M"
paulson@33533
   837
proof -
hoelzl@38656
   838
  have 1: "\<And>a. {w\<in>space M. a \<le> f w + g w} = {w \<in> space M. a + g w * -1 \<le> f w}"
paulson@33533
   839
    by auto
hoelzl@38656
   840
  have "\<And>a. (\<lambda>w. a + (g w) * -1) \<in> borel_measurable M"
hoelzl@38656
   841
    by (rule affine_borel_measurable [OF g])
hoelzl@38656
   842
  then have "\<And>a. {w \<in> space M. (\<lambda>w. a + (g w) * -1)(w) \<le> f w} \<in> sets M" using f
hoelzl@38656
   843
    by auto
hoelzl@38656
   844
  then have "\<And>a. {w \<in> space M. a \<le> f w + g w} \<in> sets M"
hoelzl@38656
   845
    by (simp add: 1)
hoelzl@38656
   846
  then show ?thesis
hoelzl@38656
   847
    by (simp add: borel_measurable_iff_ge)
paulson@33533
   848
qed
paulson@33533
   849
hoelzl@41026
   850
lemma (in sigma_algebra) borel_measurable_setsum[simp, intro]:
hoelzl@41026
   851
  fixes f :: "'c \<Rightarrow> 'a \<Rightarrow> real"
hoelzl@41026
   852
  assumes "\<And>i. i \<in> S \<Longrightarrow> f i \<in> borel_measurable M"
hoelzl@41026
   853
  shows "(\<lambda>x. \<Sum>i\<in>S. f i x) \<in> borel_measurable M"
hoelzl@41026
   854
proof cases
hoelzl@41026
   855
  assume "finite S"
hoelzl@41026
   856
  thus ?thesis using assms by induct auto
hoelzl@41026
   857
qed simp
hoelzl@41026
   858
hoelzl@38656
   859
lemma (in sigma_algebra) borel_measurable_square:
hoelzl@38656
   860
  fixes f :: "'a \<Rightarrow> real"
paulson@33533
   861
  assumes f: "f \<in> borel_measurable M"
paulson@33533
   862
  shows "(\<lambda>x. (f x)^2) \<in> borel_measurable M"
paulson@33533
   863
proof -
paulson@33533
   864
  {
paulson@33533
   865
    fix a
paulson@33533
   866
    have "{w \<in> space M. (f w)\<twosuperior> \<le> a} \<in> sets M"
paulson@33533
   867
    proof (cases rule: linorder_cases [of a 0])
paulson@33533
   868
      case less
hoelzl@38656
   869
      hence "{w \<in> space M. (f w)\<twosuperior> \<le> a} = {}"
paulson@33533
   870
        by auto (metis less order_le_less_trans power2_less_0)
paulson@33533
   871
      also have "... \<in> sets M"
hoelzl@38656
   872
        by (rule empty_sets)
paulson@33533
   873
      finally show ?thesis .
paulson@33533
   874
    next
paulson@33533
   875
      case equal
hoelzl@38656
   876
      hence "{w \<in> space M. (f w)\<twosuperior> \<le> a} =
paulson@33533
   877
             {w \<in> space M. f w \<le> 0} \<inter> {w \<in> space M. 0 \<le> f w}"
paulson@33533
   878
        by auto
paulson@33533
   879
      also have "... \<in> sets M"
hoelzl@38656
   880
        apply (insert f)
hoelzl@38656
   881
        apply (rule Int)
hoelzl@38656
   882
        apply (simp add: borel_measurable_iff_le)
hoelzl@38656
   883
        apply (simp add: borel_measurable_iff_ge)
paulson@33533
   884
        done
paulson@33533
   885
      finally show ?thesis .
paulson@33533
   886
    next
paulson@33533
   887
      case greater
paulson@33533
   888
      have "\<forall>x. (f x ^ 2 \<le> sqrt a ^ 2) = (- sqrt a  \<le> f x & f x \<le> sqrt a)"
paulson@33533
   889
        by (metis abs_le_interval_iff abs_of_pos greater real_sqrt_abs
paulson@33533
   890
                  real_sqrt_le_iff real_sqrt_power)
paulson@33533
   891
      hence "{w \<in> space M. (f w)\<twosuperior> \<le> a} =
hoelzl@38656
   892
             {w \<in> space M. -(sqrt a) \<le> f w} \<inter> {w \<in> space M. f w \<le> sqrt a}"
paulson@33533
   893
        using greater by auto
paulson@33533
   894
      also have "... \<in> sets M"
hoelzl@38656
   895
        apply (insert f)
hoelzl@38656
   896
        apply (rule Int)
hoelzl@38656
   897
        apply (simp add: borel_measurable_iff_ge)
hoelzl@38656
   898
        apply (simp add: borel_measurable_iff_le)
paulson@33533
   899
        done
paulson@33533
   900
      finally show ?thesis .
paulson@33533
   901
    qed
paulson@33533
   902
  }
hoelzl@38656
   903
  thus ?thesis by (auto simp add: borel_measurable_iff_le)
paulson@33533
   904
qed
paulson@33533
   905
paulson@33533
   906
lemma times_eq_sum_squares:
paulson@33533
   907
   fixes x::real
paulson@33533
   908
   shows"x*y = ((x+y)^2)/4 - ((x-y)^ 2)/4"
hoelzl@38656
   909
by (simp add: power2_eq_square ring_distribs diff_divide_distrib [symmetric])
paulson@33533
   910
hoelzl@38656
   911
lemma (in sigma_algebra) borel_measurable_uminus[simp, intro]:
hoelzl@38656
   912
  fixes g :: "'a \<Rightarrow> real"
paulson@33533
   913
  assumes g: "g \<in> borel_measurable M"
paulson@33533
   914
  shows "(\<lambda>x. - g x) \<in> borel_measurable M"
paulson@33533
   915
proof -
paulson@33533
   916
  have "(\<lambda>x. - g x) = (\<lambda>x. 0 + (g x) * -1)"
paulson@33533
   917
    by simp
hoelzl@38656
   918
  also have "... \<in> borel_measurable M"
hoelzl@38656
   919
    by (fast intro: affine_borel_measurable g)
paulson@33533
   920
  finally show ?thesis .
paulson@33533
   921
qed
paulson@33533
   922
hoelzl@38656
   923
lemma (in sigma_algebra) borel_measurable_times[simp, intro]:
hoelzl@38656
   924
  fixes f :: "'a \<Rightarrow> real"
paulson@33533
   925
  assumes f: "f \<in> borel_measurable M"
paulson@33533
   926
  assumes g: "g \<in> borel_measurable M"
paulson@33533
   927
  shows "(\<lambda>x. f x * g x) \<in> borel_measurable M"
paulson@33533
   928
proof -
paulson@33533
   929
  have 1: "(\<lambda>x. 0 + (f x + g x)\<twosuperior> * inverse 4) \<in> borel_measurable M"
hoelzl@38656
   930
    using assms by (fast intro: affine_borel_measurable borel_measurable_square)
hoelzl@38656
   931
  have "(\<lambda>x. -((f x + -g x) ^ 2 * inverse 4)) =
paulson@33533
   932
        (\<lambda>x. 0 + ((f x + -g x) ^ 2 * inverse -4))"
hoelzl@35582
   933
    by (simp add: minus_divide_right)
hoelzl@38656
   934
  also have "... \<in> borel_measurable M"
hoelzl@38656
   935
    using f g by (fast intro: affine_borel_measurable borel_measurable_square f g)
paulson@33533
   936
  finally have 2: "(\<lambda>x. -((f x + -g x) ^ 2 * inverse 4)) \<in> borel_measurable M" .
paulson@33533
   937
  show ?thesis
hoelzl@38656
   938
    apply (simp add: times_eq_sum_squares diff_minus)
hoelzl@38656
   939
    using 1 2 by simp
paulson@33533
   940
qed
paulson@33533
   941
hoelzl@41026
   942
lemma (in sigma_algebra) borel_measurable_setprod[simp, intro]:
hoelzl@41026
   943
  fixes f :: "'c \<Rightarrow> 'a \<Rightarrow> real"
hoelzl@41026
   944
  assumes "\<And>i. i \<in> S \<Longrightarrow> f i \<in> borel_measurable M"
hoelzl@41026
   945
  shows "(\<lambda>x. \<Prod>i\<in>S. f i x) \<in> borel_measurable M"
hoelzl@41026
   946
proof cases
hoelzl@41026
   947
  assume "finite S"
hoelzl@41026
   948
  thus ?thesis using assms by induct auto
hoelzl@41026
   949
qed simp
hoelzl@41026
   950
hoelzl@38656
   951
lemma (in sigma_algebra) borel_measurable_diff[simp, intro]:
hoelzl@38656
   952
  fixes f :: "'a \<Rightarrow> real"
paulson@33533
   953
  assumes f: "f \<in> borel_measurable M"
paulson@33533
   954
  assumes g: "g \<in> borel_measurable M"
paulson@33533
   955
  shows "(\<lambda>x. f x - g x) \<in> borel_measurable M"
hoelzl@38656
   956
  unfolding diff_minus using assms by fast
paulson@33533
   957
hoelzl@38656
   958
lemma (in sigma_algebra) borel_measurable_inverse[simp, intro]:
hoelzl@38656
   959
  fixes f :: "'a \<Rightarrow> real"
hoelzl@35692
   960
  assumes "f \<in> borel_measurable M"
hoelzl@35692
   961
  shows "(\<lambda>x. inverse (f x)) \<in> borel_measurable M"
hoelzl@38656
   962
  unfolding borel_measurable_iff_ge unfolding inverse_eq_divide
hoelzl@38656
   963
proof safe
hoelzl@38656
   964
  fix a :: real
hoelzl@38656
   965
  have *: "{w \<in> space M. a \<le> 1 / f w} =
hoelzl@38656
   966
      ({w \<in> space M. 0 < f w} \<inter> {w \<in> space M. a * f w \<le> 1}) \<union>
hoelzl@38656
   967
      ({w \<in> space M. f w < 0} \<inter> {w \<in> space M. 1 \<le> a * f w}) \<union>
hoelzl@38656
   968
      ({w \<in> space M. f w = 0} \<inter> {w \<in> space M. a \<le> 0})" by (auto simp: le_divide_eq)
hoelzl@38656
   969
  show "{w \<in> space M. a \<le> 1 / f w} \<in> sets M" using assms unfolding *
hoelzl@38656
   970
    by (auto intro!: Int Un)
hoelzl@35692
   971
qed
hoelzl@35692
   972
hoelzl@38656
   973
lemma (in sigma_algebra) borel_measurable_divide[simp, intro]:
hoelzl@38656
   974
  fixes f :: "'a \<Rightarrow> real"
hoelzl@35692
   975
  assumes "f \<in> borel_measurable M"
hoelzl@35692
   976
  and "g \<in> borel_measurable M"
hoelzl@35692
   977
  shows "(\<lambda>x. f x / g x) \<in> borel_measurable M"
hoelzl@35692
   978
  unfolding field_divide_inverse
hoelzl@38656
   979
  by (rule borel_measurable_inverse borel_measurable_times assms)+
hoelzl@38656
   980
hoelzl@38656
   981
lemma (in sigma_algebra) borel_measurable_max[intro, simp]:
hoelzl@38656
   982
  fixes f g :: "'a \<Rightarrow> real"
hoelzl@38656
   983
  assumes "f \<in> borel_measurable M"
hoelzl@38656
   984
  assumes "g \<in> borel_measurable M"
hoelzl@38656
   985
  shows "(\<lambda>x. max (g x) (f x)) \<in> borel_measurable M"
hoelzl@38656
   986
  unfolding borel_measurable_iff_le
hoelzl@38656
   987
proof safe
hoelzl@38656
   988
  fix a
hoelzl@38656
   989
  have "{x \<in> space M. max (g x) (f x) \<le> a} =
hoelzl@38656
   990
    {x \<in> space M. g x \<le> a} \<inter> {x \<in> space M. f x \<le> a}" by auto
hoelzl@38656
   991
  thus "{x \<in> space M. max (g x) (f x) \<le> a} \<in> sets M"
hoelzl@38656
   992
    using assms unfolding borel_measurable_iff_le
hoelzl@38656
   993
    by (auto intro!: Int)
hoelzl@38656
   994
qed
hoelzl@38656
   995
hoelzl@38656
   996
lemma (in sigma_algebra) borel_measurable_min[intro, simp]:
hoelzl@38656
   997
  fixes f g :: "'a \<Rightarrow> real"
hoelzl@38656
   998
  assumes "f \<in> borel_measurable M"
hoelzl@38656
   999
  assumes "g \<in> borel_measurable M"
hoelzl@38656
  1000
  shows "(\<lambda>x. min (g x) (f x)) \<in> borel_measurable M"
hoelzl@38656
  1001
  unfolding borel_measurable_iff_ge
hoelzl@38656
  1002
proof safe
hoelzl@38656
  1003
  fix a
hoelzl@38656
  1004
  have "{x \<in> space M. a \<le> min (g x) (f x)} =
hoelzl@38656
  1005
    {x \<in> space M. a \<le> g x} \<inter> {x \<in> space M. a \<le> f x}" by auto
hoelzl@38656
  1006
  thus "{x \<in> space M. a \<le> min (g x) (f x)} \<in> sets M"
hoelzl@38656
  1007
    using assms unfolding borel_measurable_iff_ge
hoelzl@38656
  1008
    by (auto intro!: Int)
hoelzl@38656
  1009
qed
hoelzl@38656
  1010
hoelzl@38656
  1011
lemma (in sigma_algebra) borel_measurable_abs[simp, intro]:
hoelzl@38656
  1012
  assumes "f \<in> borel_measurable M"
hoelzl@38656
  1013
  shows "(\<lambda>x. \<bar>f x :: real\<bar>) \<in> borel_measurable M"
hoelzl@38656
  1014
proof -
hoelzl@38656
  1015
  have *: "\<And>x. \<bar>f x\<bar> = max 0 (f x) + max 0 (- f x)" by (simp add: max_def)
hoelzl@38656
  1016
  show ?thesis unfolding * using assms by auto
hoelzl@38656
  1017
qed
hoelzl@38656
  1018
hoelzl@41026
  1019
lemma borel_measurable_nth[simp, intro]:
hoelzl@41026
  1020
  "(\<lambda>x::real^'n. x $ i) \<in> borel_measurable borel"
hoelzl@41026
  1021
  using borel_measurable_euclidean_component
hoelzl@41026
  1022
  unfolding nth_conv_component by auto
hoelzl@41026
  1023
hoelzl@38656
  1024
section "Borel space over the real line with infinity"
hoelzl@35692
  1025
hoelzl@40859
  1026
lemma borel_Real_measurable:
hoelzl@40859
  1027
  "A \<in> sets borel \<Longrightarrow> Real -` A \<in> sets borel"
hoelzl@38656
  1028
proof (rule borel_measurable_translate)
hoelzl@41023
  1029
  fix B :: "pextreal set" assume "open B"
hoelzl@38656
  1030
  then obtain T x where T: "open T" "Real ` (T \<inter> {0..}) = B - {\<omega>}" and
hoelzl@38656
  1031
    x: "\<omega> \<in> B \<Longrightarrow> 0 \<le> x" "\<omega> \<in> B \<Longrightarrow> {Real x <..} \<subseteq> B"
hoelzl@41023
  1032
    unfolding open_pextreal_def by blast
hoelzl@38656
  1033
  have "Real -` B = Real -` (B - {\<omega>})" by auto
hoelzl@38656
  1034
  also have "\<dots> = Real -` (Real ` (T \<inter> {0..}))" using T by simp
hoelzl@38656
  1035
  also have "\<dots> = (if 0 \<in> T then T \<union> {.. 0} else T \<inter> {0..})"
hoelzl@38656
  1036
    apply (auto simp add: Real_eq_Real image_iff)
hoelzl@38656
  1037
    apply (rule_tac x="max 0 x" in bexI)
hoelzl@38656
  1038
    by (auto simp: max_def)
hoelzl@40859
  1039
  finally show "Real -` B \<in> sets borel"
hoelzl@38656
  1040
    using `open T` by auto
hoelzl@38656
  1041
qed simp
hoelzl@38656
  1042
hoelzl@40859
  1043
lemma borel_real_measurable:
hoelzl@41023
  1044
  "A \<in> sets borel \<Longrightarrow> (real -` A :: pextreal set) \<in> sets borel"
hoelzl@38656
  1045
proof (rule borel_measurable_translate)
hoelzl@38656
  1046
  fix B :: "real set" assume "open B"
hoelzl@38656
  1047
  { fix x have "0 < real x \<longleftrightarrow> (\<exists>r>0. x = Real r)" by (cases x) auto }
hoelzl@38656
  1048
  note Ex_less_real = this
hoelzl@38656
  1049
  have *: "real -` B = (if 0 \<in> B then real -` (B \<inter> {0 <..}) \<union> {0, \<omega>} else real -` (B \<inter> {0 <..}))"
hoelzl@38656
  1050
    by (force simp: Ex_less_real)
hoelzl@38656
  1051
hoelzl@41023
  1052
  have "open (real -` (B \<inter> {0 <..}) :: pextreal set)"
hoelzl@41023
  1053
    unfolding open_pextreal_def using `open B`
hoelzl@38656
  1054
    by (auto intro!: open_Int exI[of _ "B \<inter> {0 <..}"] simp: image_iff Ex_less_real)
hoelzl@41023
  1055
  then show "(real -` B :: pextreal set) \<in> sets borel" unfolding * by auto
hoelzl@38656
  1056
qed simp
hoelzl@38656
  1057
hoelzl@38656
  1058
lemma (in sigma_algebra) borel_measurable_Real[intro, simp]:
hoelzl@38656
  1059
  assumes "f \<in> borel_measurable M"
hoelzl@38656
  1060
  shows "(\<lambda>x. Real (f x)) \<in> borel_measurable M"
hoelzl@40859
  1061
  unfolding in_borel_measurable_borel
hoelzl@38656
  1062
proof safe
hoelzl@41023
  1063
  fix S :: "pextreal set" assume "S \<in> sets borel"
hoelzl@40859
  1064
  from borel_Real_measurable[OF this]
hoelzl@38656
  1065
  have "(Real \<circ> f) -` S \<inter> space M \<in> sets M"
hoelzl@38656
  1066
    using assms
hoelzl@40859
  1067
    unfolding vimage_compose in_borel_measurable_borel
hoelzl@38656
  1068
    by auto
hoelzl@38656
  1069
  thus "(\<lambda>x. Real (f x)) -` S \<inter> space M \<in> sets M" by (simp add: comp_def)
hoelzl@35748
  1070
qed
hoelzl@35692
  1071
hoelzl@38656
  1072
lemma (in sigma_algebra) borel_measurable_real[intro, simp]:
hoelzl@41023
  1073
  fixes f :: "'a \<Rightarrow> pextreal"
hoelzl@38656
  1074
  assumes "f \<in> borel_measurable M"
hoelzl@38656
  1075
  shows "(\<lambda>x. real (f x)) \<in> borel_measurable M"
hoelzl@40859
  1076
  unfolding in_borel_measurable_borel
hoelzl@38656
  1077
proof safe
hoelzl@40859
  1078
  fix S :: "real set" assume "S \<in> sets borel"
hoelzl@40859
  1079
  from borel_real_measurable[OF this]
hoelzl@38656
  1080
  have "(real \<circ> f) -` S \<inter> space M \<in> sets M"
hoelzl@38656
  1081
    using assms
hoelzl@40859
  1082
    unfolding vimage_compose in_borel_measurable_borel
hoelzl@38656
  1083
    by auto
hoelzl@38656
  1084
  thus "(\<lambda>x. real (f x)) -` S \<inter> space M \<in> sets M" by (simp add: comp_def)
hoelzl@38656
  1085
qed
hoelzl@35692
  1086
hoelzl@38656
  1087
lemma (in sigma_algebra) borel_measurable_Real_eq:
hoelzl@38656
  1088
  assumes "\<And>x. x \<in> space M \<Longrightarrow> 0 \<le> f x"
hoelzl@38656
  1089
  shows "(\<lambda>x. Real (f x)) \<in> borel_measurable M \<longleftrightarrow> f \<in> borel_measurable M"
hoelzl@38656
  1090
proof
hoelzl@38656
  1091
  have [simp]: "(\<lambda>x. Real (f x)) -` {\<omega>} \<inter> space M = {}"
hoelzl@38656
  1092
    by auto
hoelzl@38656
  1093
  assume "(\<lambda>x. Real (f x)) \<in> borel_measurable M"
hoelzl@38656
  1094
  hence "(\<lambda>x. real (Real (f x))) \<in> borel_measurable M"
hoelzl@38656
  1095
    by (rule borel_measurable_real)
hoelzl@38656
  1096
  moreover have "\<And>x. x \<in> space M \<Longrightarrow> real (Real (f x)) = f x"
hoelzl@38656
  1097
    using assms by auto
hoelzl@38656
  1098
  ultimately show "f \<in> borel_measurable M"
hoelzl@38656
  1099
    by (simp cong: measurable_cong)
hoelzl@38656
  1100
qed auto
hoelzl@35692
  1101
hoelzl@41023
  1102
lemma (in sigma_algebra) borel_measurable_pextreal_eq_real:
hoelzl@38656
  1103
  "f \<in> borel_measurable M \<longleftrightarrow>
hoelzl@38656
  1104
    ((\<lambda>x. real (f x)) \<in> borel_measurable M \<and> f -` {\<omega>} \<inter> space M \<in> sets M)"
hoelzl@38656
  1105
proof safe
hoelzl@38656
  1106
  assume "f \<in> borel_measurable M"
hoelzl@38656
  1107
  then show "(\<lambda>x. real (f x)) \<in> borel_measurable M" "f -` {\<omega>} \<inter> space M \<in> sets M"
hoelzl@38656
  1108
    by (auto intro: borel_measurable_vimage borel_measurable_real)
hoelzl@38656
  1109
next
hoelzl@38656
  1110
  assume *: "(\<lambda>x. real (f x)) \<in> borel_measurable M" "f -` {\<omega>} \<inter> space M \<in> sets M"
hoelzl@38656
  1111
  have "f -` {\<omega>} \<inter> space M = {x\<in>space M. f x = \<omega>}" by auto
hoelzl@38656
  1112
  with * have **: "{x\<in>space M. f x = \<omega>} \<in> sets M" by simp
hoelzl@38656
  1113
  have f: "f = (\<lambda>x. if f x = \<omega> then \<omega> else Real (real (f x)))"
nipkow@39302
  1114
    by (simp add: fun_eq_iff Real_real)
hoelzl@38656
  1115
  show "f \<in> borel_measurable M"
hoelzl@38656
  1116
    apply (subst f)
hoelzl@38656
  1117
    apply (rule measurable_If)
hoelzl@38656
  1118
    using * ** by auto
hoelzl@38656
  1119
qed
hoelzl@38656
  1120
hoelzl@38656
  1121
lemma (in sigma_algebra) less_eq_ge_measurable:
hoelzl@38656
  1122
  fixes f :: "'a \<Rightarrow> 'c::linorder"
hoelzl@38656
  1123
  shows "{x\<in>space M. a < f x} \<in> sets M \<longleftrightarrow> {x\<in>space M. f x \<le> a} \<in> sets M"
hoelzl@38656
  1124
proof
hoelzl@38656
  1125
  assume "{x\<in>space M. f x \<le> a} \<in> sets M"
hoelzl@38656
  1126
  moreover have "{x\<in>space M. a < f x} = space M - {x\<in>space M. f x \<le> a}" by auto
hoelzl@38656
  1127
  ultimately show "{x\<in>space M. a < f x} \<in> sets M" by auto
hoelzl@38656
  1128
next
hoelzl@38656
  1129
  assume "{x\<in>space M. a < f x} \<in> sets M"
hoelzl@38656
  1130
  moreover have "{x\<in>space M. f x \<le> a} = space M - {x\<in>space M. a < f x}" by auto
hoelzl@38656
  1131
  ultimately show "{x\<in>space M. f x \<le> a} \<in> sets M" by auto
hoelzl@38656
  1132
qed
hoelzl@35692
  1133
hoelzl@38656
  1134
lemma (in sigma_algebra) greater_eq_le_measurable:
hoelzl@38656
  1135
  fixes f :: "'a \<Rightarrow> 'c::linorder"
hoelzl@38656
  1136
  shows "{x\<in>space M. f x < a} \<in> sets M \<longleftrightarrow> {x\<in>space M. a \<le> f x} \<in> sets M"
hoelzl@38656
  1137
proof
hoelzl@38656
  1138
  assume "{x\<in>space M. a \<le> f x} \<in> sets M"
hoelzl@38656
  1139
  moreover have "{x\<in>space M. f x < a} = space M - {x\<in>space M. a \<le> f x}" by auto
hoelzl@38656
  1140
  ultimately show "{x\<in>space M. f x < a} \<in> sets M" by auto
hoelzl@38656
  1141
next
hoelzl@38656
  1142
  assume "{x\<in>space M. f x < a} \<in> sets M"
hoelzl@38656
  1143
  moreover have "{x\<in>space M. a \<le> f x} = space M - {x\<in>space M. f x < a}" by auto
hoelzl@38656
  1144
  ultimately show "{x\<in>space M. a \<le> f x} \<in> sets M" by auto
hoelzl@38656
  1145
qed
hoelzl@38656
  1146
hoelzl@41023
  1147
lemma (in sigma_algebra) less_eq_le_pextreal_measurable:
hoelzl@41023
  1148
  fixes f :: "'a \<Rightarrow> pextreal"
hoelzl@38656
  1149
  shows "(\<forall>a. {x\<in>space M. a < f x} \<in> sets M) \<longleftrightarrow> (\<forall>a. {x\<in>space M. a \<le> f x} \<in> sets M)"
hoelzl@38656
  1150
proof
hoelzl@38656
  1151
  assume a: "\<forall>a. {x\<in>space M. a \<le> f x} \<in> sets M"
hoelzl@38656
  1152
  show "\<forall>a. {x \<in> space M. a < f x} \<in> sets M"
hoelzl@38656
  1153
  proof
hoelzl@38656
  1154
    fix a show "{x \<in> space M. a < f x} \<in> sets M"
hoelzl@38656
  1155
    proof (cases a)
hoelzl@38656
  1156
      case (preal r)
hoelzl@38656
  1157
      have "{x\<in>space M. a < f x} = (\<Union>i. {x\<in>space M. a + inverse (of_nat (Suc i)) \<le> f x})"
paulson@33533
  1158
      proof safe
hoelzl@38656
  1159
        fix x assume "a < f x" and [simp]: "x \<in> space M"
hoelzl@41023
  1160
        with ex_pextreal_inverse_of_nat_Suc_less[of "f x - a"]
hoelzl@38656
  1161
        obtain n where "a + inverse (of_nat (Suc n)) < f x"
hoelzl@41023
  1162
          by (cases "f x", auto simp: pextreal_minus_order)
hoelzl@38656
  1163
        then have "a + inverse (of_nat (Suc n)) \<le> f x" by simp
hoelzl@38656
  1164
        then show "x \<in> (\<Union>i. {x \<in> space M. a + inverse (of_nat (Suc i)) \<le> f x})"
paulson@33533
  1165
          by auto
paulson@33533
  1166
      next
hoelzl@38656
  1167
        fix i x assume [simp]: "x \<in> space M"
hoelzl@38656
  1168
        have "a < a + inverse (of_nat (Suc i))" using preal by auto
hoelzl@38656
  1169
        also assume "a + inverse (of_nat (Suc i)) \<le> f x"
hoelzl@38656
  1170
        finally show "a < f x" .
paulson@33533
  1171
      qed
hoelzl@38656
  1172
      with a show ?thesis by auto
hoelzl@38656
  1173
    qed simp
hoelzl@35582
  1174
  qed
hoelzl@35582
  1175
next
hoelzl@38656
  1176
  assume a': "\<forall>a. {x \<in> space M. a < f x} \<in> sets M"
hoelzl@38656
  1177
  then have a: "\<forall>a. {x \<in> space M. f x \<le> a} \<in> sets M" unfolding less_eq_ge_measurable .
hoelzl@38656
  1178
  show "\<forall>a. {x \<in> space M. a \<le> f x} \<in> sets M" unfolding greater_eq_le_measurable[symmetric]
hoelzl@38656
  1179
  proof
hoelzl@38656
  1180
    fix a show "{x \<in> space M. f x < a} \<in> sets M"
hoelzl@38656
  1181
    proof (cases a)
hoelzl@38656
  1182
      case (preal r)
hoelzl@38656
  1183
      show ?thesis
hoelzl@38656
  1184
      proof cases
hoelzl@38656
  1185
        assume "a = 0" then show ?thesis by simp
hoelzl@38656
  1186
      next
hoelzl@38656
  1187
        assume "a \<noteq> 0"
hoelzl@38656
  1188
        have "{x\<in>space M. f x < a} = (\<Union>i. {x\<in>space M. f x \<le> a - inverse (of_nat (Suc i))})"
hoelzl@38656
  1189
        proof safe
hoelzl@38656
  1190
          fix x assume "f x < a" and [simp]: "x \<in> space M"
hoelzl@41023
  1191
          with ex_pextreal_inverse_of_nat_Suc_less[of "a - f x"]
hoelzl@38656
  1192
          obtain n where "inverse (of_nat (Suc n)) < a - f x"
hoelzl@38656
  1193
            using preal by (cases "f x") auto
hoelzl@38656
  1194
          then have "f x \<le> a - inverse (of_nat (Suc n)) "
hoelzl@38656
  1195
            using preal by (cases "f x") (auto split: split_if_asm)
hoelzl@38656
  1196
          then show "x \<in> (\<Union>i. {x \<in> space M. f x \<le> a - inverse (of_nat (Suc i))})"
hoelzl@38656
  1197
            by auto
hoelzl@38656
  1198
        next
hoelzl@38656
  1199
          fix i x assume [simp]: "x \<in> space M"
hoelzl@38656
  1200
          assume "f x \<le> a - inverse (of_nat (Suc i))"
hoelzl@38656
  1201
          also have "\<dots> < a" using `a \<noteq> 0` preal by auto
hoelzl@38656
  1202
          finally show "f x < a" .
hoelzl@38656
  1203
        qed
hoelzl@38656
  1204
        with a show ?thesis by auto
hoelzl@38656
  1205
      qed
hoelzl@38656
  1206
    next
hoelzl@38656
  1207
      case infinite
hoelzl@38656
  1208
      have "f -` {\<omega>} \<inter> space M = (\<Inter>n. {x\<in>space M. of_nat n < f x})"
hoelzl@38656
  1209
      proof (safe, simp_all, safe)
hoelzl@38656
  1210
        fix x assume *: "\<forall>n::nat. Real (real n) < f x"
hoelzl@38656
  1211
        show "f x = \<omega>"    proof (rule ccontr)
hoelzl@38656
  1212
          assume "f x \<noteq> \<omega>"
hoelzl@38656
  1213
          with real_arch_lt[of "real (f x)"] obtain n where "f x < of_nat n"
hoelzl@41023
  1214
            by (auto simp: pextreal_noteq_omega_Ex)
hoelzl@38656
  1215
          with *[THEN spec, of n] show False by auto
hoelzl@38656
  1216
        qed
hoelzl@38656
  1217
      qed
hoelzl@38656
  1218
      with a' have \<omega>: "f -` {\<omega>} \<inter> space M \<in> sets M" by auto
hoelzl@38656
  1219
      moreover have "{x \<in> space M. f x < a} = space M - f -` {\<omega>} \<inter> space M"
hoelzl@38656
  1220
        using infinite by auto
hoelzl@38656
  1221
      ultimately show ?thesis by auto
hoelzl@38656
  1222
    qed
hoelzl@35582
  1223
  qed
hoelzl@35582
  1224
qed
hoelzl@35582
  1225
hoelzl@41023
  1226
lemma (in sigma_algebra) borel_measurable_pextreal_iff_greater:
hoelzl@41023
  1227
  "(f::'a \<Rightarrow> pextreal) \<in> borel_measurable M \<longleftrightarrow> (\<forall>a. {x\<in>space M. a < f x} \<in> sets M)"
hoelzl@38656
  1228
proof safe
hoelzl@38656
  1229
  fix a assume f: "f \<in> borel_measurable M"
hoelzl@38656
  1230
  have "{x\<in>space M. a < f x} = f -` {a <..} \<inter> space M" by auto
hoelzl@38656
  1231
  with f show "{x\<in>space M. a < f x} \<in> sets M"
hoelzl@38656
  1232
    by (auto intro!: measurable_sets)
hoelzl@38656
  1233
next
hoelzl@38656
  1234
  assume *: "\<forall>a. {x\<in>space M. a < f x} \<in> sets M"
hoelzl@38656
  1235
  hence **: "\<forall>a. {x\<in>space M. f x < a} \<in> sets M"
hoelzl@41023
  1236
    unfolding less_eq_le_pextreal_measurable
hoelzl@38656
  1237
    unfolding greater_eq_le_measurable .
hoelzl@41023
  1238
  show "f \<in> borel_measurable M" unfolding borel_measurable_pextreal_eq_real borel_measurable_iff_greater
hoelzl@38656
  1239
  proof safe
hoelzl@38656
  1240
    have "f -` {\<omega>} \<inter> space M = space M - {x\<in>space M. f x < \<omega>}" by auto
hoelzl@38656
  1241
    then show \<omega>: "f -` {\<omega>} \<inter> space M \<in> sets M" using ** by auto
hoelzl@38656
  1242
    fix a
hoelzl@38656
  1243
    have "{w \<in> space M. a < real (f w)} =
hoelzl@38656
  1244
      (if 0 \<le> a then {w\<in>space M. Real a < f w} - (f -` {\<omega>} \<inter> space M) else space M)"
hoelzl@38656
  1245
    proof (split split_if, safe del: notI)
hoelzl@38656
  1246
      fix x assume "0 \<le> a"
hoelzl@38656
  1247
      { assume "a < real (f x)" then show "Real a < f x" "x \<notin> f -` {\<omega>} \<inter> space M"
hoelzl@38656
  1248
          using `0 \<le> a` by (cases "f x", auto) }
hoelzl@38656
  1249
      { assume "Real a < f x" "x \<notin> f -` {\<omega>}" then show "a < real (f x)"
hoelzl@38656
  1250
          using `0 \<le> a` by (cases "f x", auto) }
hoelzl@38656
  1251
    next
hoelzl@38656
  1252
      fix x assume "\<not> 0 \<le> a" then show "a < real (f x)" by (cases "f x") auto
hoelzl@38656
  1253
    qed
hoelzl@38656
  1254
    then show "{w \<in> space M. a < real (f w)} \<in> sets M"
hoelzl@38656
  1255
      using \<omega> * by (auto intro!: Diff)
hoelzl@35582
  1256
  qed
hoelzl@35582
  1257
qed
hoelzl@35582
  1258
hoelzl@41023
  1259
lemma (in sigma_algebra) borel_measurable_pextreal_iff_less:
hoelzl@41023
  1260
  "(f::'a \<Rightarrow> pextreal) \<in> borel_measurable M \<longleftrightarrow> (\<forall>a. {x\<in>space M. f x < a} \<in> sets M)"
hoelzl@41023
  1261
  using borel_measurable_pextreal_iff_greater unfolding less_eq_le_pextreal_measurable greater_eq_le_measurable .
hoelzl@38656
  1262
hoelzl@41023
  1263
lemma (in sigma_algebra) borel_measurable_pextreal_iff_le:
hoelzl@41023
  1264
  "(f::'a \<Rightarrow> pextreal) \<in> borel_measurable M \<longleftrightarrow> (\<forall>a. {x\<in>space M. f x \<le> a} \<in> sets M)"
hoelzl@41023
  1265
  using borel_measurable_pextreal_iff_greater unfolding less_eq_ge_measurable .
hoelzl@38656
  1266
hoelzl@41023
  1267
lemma (in sigma_algebra) borel_measurable_pextreal_iff_ge:
hoelzl@41023
  1268
  "(f::'a \<Rightarrow> pextreal) \<in> borel_measurable M \<longleftrightarrow> (\<forall>a. {x\<in>space M. a \<le> f x} \<in> sets M)"
hoelzl@41023
  1269
  using borel_measurable_pextreal_iff_greater unfolding less_eq_le_pextreal_measurable .
hoelzl@38656
  1270
hoelzl@41023
  1271
lemma (in sigma_algebra) borel_measurable_pextreal_eq_const:
hoelzl@41023
  1272
  fixes f :: "'a \<Rightarrow> pextreal" assumes "f \<in> borel_measurable M"
hoelzl@38656
  1273
  shows "{x\<in>space M. f x = c} \<in> sets M"
hoelzl@38656
  1274
proof -
hoelzl@38656
  1275
  have "{x\<in>space M. f x = c} = (f -` {c} \<inter> space M)" by auto
hoelzl@38656
  1276
  then show ?thesis using assms by (auto intro!: measurable_sets)
hoelzl@38656
  1277
qed
hoelzl@38656
  1278
hoelzl@41023
  1279
lemma (in sigma_algebra) borel_measurable_pextreal_neq_const:
hoelzl@41023
  1280
  fixes f :: "'a \<Rightarrow> pextreal"
hoelzl@38656
  1281
  assumes "f \<in> borel_measurable M"
hoelzl@38656
  1282
  shows "{x\<in>space M. f x \<noteq> c} \<in> sets M"
hoelzl@38656
  1283
proof -
hoelzl@38656
  1284
  have "{x\<in>space M. f x \<noteq> c} = space M - (f -` {c} \<inter> space M)" by auto
hoelzl@38656
  1285
  then show ?thesis using assms by (auto intro!: measurable_sets)
hoelzl@38656
  1286
qed
hoelzl@38656
  1287
hoelzl@41023
  1288
lemma (in sigma_algebra) borel_measurable_pextreal_less[intro,simp]:
hoelzl@41023
  1289
  fixes f g :: "'a \<Rightarrow> pextreal"
hoelzl@38656
  1290
  assumes f: "f \<in> borel_measurable M"
hoelzl@38656
  1291
  assumes g: "g \<in> borel_measurable M"
hoelzl@38656
  1292
  shows "{x \<in> space M. f x < g x} \<in> sets M"
hoelzl@38656
  1293
proof -
hoelzl@38656
  1294
  have "(\<lambda>x. real (f x)) \<in> borel_measurable M"
hoelzl@38656
  1295
    "(\<lambda>x. real (g x)) \<in> borel_measurable M"
hoelzl@38656
  1296
    using assms by (auto intro!: borel_measurable_real)
hoelzl@38656
  1297
  from borel_measurable_less[OF this]
hoelzl@38656
  1298
  have "{x \<in> space M. real (f x) < real (g x)} \<in> sets M" .
hoelzl@41023
  1299
  moreover have "{x \<in> space M. f x \<noteq> \<omega>} \<in> sets M" using f by (rule borel_measurable_pextreal_neq_const)
hoelzl@41023
  1300
  moreover have "{x \<in> space M. g x = \<omega>} \<in> sets M" using g by (rule borel_measurable_pextreal_eq_const)
hoelzl@41023
  1301
  moreover have "{x \<in> space M. g x \<noteq> \<omega>} \<in> sets M" using g by (rule borel_measurable_pextreal_neq_const)
hoelzl@38656
  1302
  moreover have "{x \<in> space M. f x < g x} = ({x \<in> space M. g x = \<omega>} \<inter> {x \<in> space M. f x \<noteq> \<omega>}) \<union>
hoelzl@38656
  1303
    ({x \<in> space M. g x \<noteq> \<omega>} \<inter> {x \<in> space M. f x \<noteq> \<omega>} \<inter> {x \<in> space M. real (f x) < real (g x)})"
hoelzl@41023
  1304
    by (auto simp: real_of_pextreal_strict_mono_iff)
hoelzl@38656
  1305
  ultimately show ?thesis by auto
hoelzl@38656
  1306
qed
hoelzl@38656
  1307
hoelzl@41023
  1308
lemma (in sigma_algebra) borel_measurable_pextreal_le[intro,simp]:
hoelzl@41023
  1309
  fixes f :: "'a \<Rightarrow> pextreal"
hoelzl@38656
  1310
  assumes f: "f \<in> borel_measurable M"
hoelzl@38656
  1311
  assumes g: "g \<in> borel_measurable M"
hoelzl@38656
  1312
  shows "{x \<in> space M. f x \<le> g x} \<in> sets M"
hoelzl@38656
  1313
proof -
hoelzl@38656
  1314
  have "{x \<in> space M. f x \<le> g x} = space M - {x \<in> space M. g x < f x}" by auto
hoelzl@38656
  1315
  then show ?thesis using g f by auto
hoelzl@38656
  1316
qed
hoelzl@38656
  1317
hoelzl@41023
  1318
lemma (in sigma_algebra) borel_measurable_pextreal_eq[intro,simp]:
hoelzl@41023
  1319
  fixes f :: "'a \<Rightarrow> pextreal"
hoelzl@38656
  1320
  assumes f: "f \<in> borel_measurable M"
hoelzl@38656
  1321
  assumes g: "g \<in> borel_measurable M"
hoelzl@38656
  1322
  shows "{w \<in> space M. f w = g w} \<in> sets M"
hoelzl@38656
  1323
proof -
hoelzl@38656
  1324
  have "{x \<in> space M. f x = g x} = {x \<in> space M. g x \<le> f x} \<inter> {x \<in> space M. f x \<le> g x}" by auto
hoelzl@38656
  1325
  then show ?thesis using g f by auto
hoelzl@38656
  1326
qed
hoelzl@38656
  1327
hoelzl@41023
  1328
lemma (in sigma_algebra) borel_measurable_pextreal_neq[intro,simp]:
hoelzl@41023
  1329
  fixes f :: "'a \<Rightarrow> pextreal"
hoelzl@38656
  1330
  assumes f: "f \<in> borel_measurable M"
hoelzl@38656
  1331
  assumes g: "g \<in> borel_measurable M"
hoelzl@38656
  1332
  shows "{w \<in> space M. f w \<noteq> g w} \<in> sets M"
hoelzl@35692
  1333
proof -
hoelzl@38656
  1334
  have "{w \<in> space M. f w \<noteq> g w} = space M - {w \<in> space M. f w = g w}" by auto
hoelzl@38656
  1335
  thus ?thesis using f g by auto
hoelzl@38656
  1336
qed
hoelzl@38656
  1337
hoelzl@41023
  1338
lemma (in sigma_algebra) borel_measurable_pextreal_add[intro, simp]:
hoelzl@41023
  1339
  fixes f :: "'a \<Rightarrow> pextreal"
hoelzl@41025
  1340
  assumes "f \<in> borel_measurable M" "g \<in> borel_measurable M"
hoelzl@38656
  1341
  shows "(\<lambda>x. f x + g x) \<in> borel_measurable M"
hoelzl@38656
  1342
proof -
hoelzl@38656
  1343
  have *: "(\<lambda>x. f x + g x) =
hoelzl@38656
  1344
     (\<lambda>x. if f x = \<omega> then \<omega> else if g x = \<omega> then \<omega> else Real (real (f x) + real (g x)))"
hoelzl@41023
  1345
     by (auto simp: fun_eq_iff pextreal_noteq_omega_Ex)
hoelzl@38656
  1346
  show ?thesis using assms unfolding *
hoelzl@38656
  1347
    by (auto intro!: measurable_If)
hoelzl@38656
  1348
qed
hoelzl@38656
  1349
hoelzl@41023
  1350
lemma (in sigma_algebra) borel_measurable_pextreal_times[intro, simp]:
hoelzl@41023
  1351
  fixes f :: "'a \<Rightarrow> pextreal" assumes "f \<in> borel_measurable M" "g \<in> borel_measurable M"
hoelzl@38656
  1352
  shows "(\<lambda>x. f x * g x) \<in> borel_measurable M"
hoelzl@38656
  1353
proof -
hoelzl@38656
  1354
  have *: "(\<lambda>x. f x * g x) =
hoelzl@38656
  1355
     (\<lambda>x. if f x = 0 then 0 else if g x = 0 then 0 else if f x = \<omega> then \<omega> else if g x = \<omega> then \<omega> else
hoelzl@38656
  1356
      Real (real (f x) * real (g x)))"
hoelzl@41023
  1357
     by (auto simp: fun_eq_iff pextreal_noteq_omega_Ex)
hoelzl@38656
  1358
  show ?thesis using assms unfolding *
hoelzl@38656
  1359
    by (auto intro!: measurable_If)
hoelzl@38656
  1360
qed
hoelzl@38656
  1361
hoelzl@41023
  1362
lemma (in sigma_algebra) borel_measurable_pextreal_setsum[simp, intro]:
hoelzl@41023
  1363
  fixes f :: "'c \<Rightarrow> 'a \<Rightarrow> pextreal"
hoelzl@38656
  1364
  assumes "\<And>i. i \<in> S \<Longrightarrow> f i \<in> borel_measurable M"
hoelzl@38656
  1365
  shows "(\<lambda>x. \<Sum>i\<in>S. f i x) \<in> borel_measurable M"
hoelzl@38656
  1366
proof cases
hoelzl@38656
  1367
  assume "finite S"
hoelzl@38656
  1368
  thus ?thesis using assms
hoelzl@38656
  1369
    by induct auto
hoelzl@38656
  1370
qed (simp add: borel_measurable_const)
hoelzl@38656
  1371
hoelzl@41023
  1372
lemma (in sigma_algebra) borel_measurable_pextreal_min[simp, intro]:
hoelzl@41023
  1373
  fixes f g :: "'a \<Rightarrow> pextreal"
hoelzl@38656
  1374
  assumes "f \<in> borel_measurable M"
hoelzl@38656
  1375
  assumes "g \<in> borel_measurable M"
hoelzl@38656
  1376
  shows "(\<lambda>x. min (g x) (f x)) \<in> borel_measurable M"
hoelzl@38656
  1377
  using assms unfolding min_def by (auto intro!: measurable_If)
hoelzl@38656
  1378
hoelzl@41023
  1379
lemma (in sigma_algebra) borel_measurable_pextreal_max[simp, intro]:
hoelzl@41023
  1380
  fixes f g :: "'a \<Rightarrow> pextreal"
hoelzl@38656
  1381
  assumes "f \<in> borel_measurable M"
hoelzl@38656
  1382
  and "g \<in> borel_measurable M"
hoelzl@38656
  1383
  shows "(\<lambda>x. max (g x) (f x)) \<in> borel_measurable M"
hoelzl@38656
  1384
  using assms unfolding max_def by (auto intro!: measurable_If)
hoelzl@38656
  1385
hoelzl@38656
  1386
lemma (in sigma_algebra) borel_measurable_SUP[simp, intro]:
hoelzl@41023
  1387
  fixes f :: "'d\<Colon>countable \<Rightarrow> 'a \<Rightarrow> pextreal"
hoelzl@38656
  1388
  assumes "\<And>i. i \<in> A \<Longrightarrow> f i \<in> borel_measurable M"
hoelzl@38656
  1389
  shows "(SUP i : A. f i) \<in> borel_measurable M" (is "?sup \<in> borel_measurable M")
hoelzl@41023
  1390
  unfolding borel_measurable_pextreal_iff_greater
hoelzl@38656
  1391
proof safe
hoelzl@38656
  1392
  fix a
hoelzl@38656
  1393
  have "{x\<in>space M. a < ?sup x} = (\<Union>i\<in>A. {x\<in>space M. a < f i x})"
hoelzl@41023
  1394
    by (auto simp: less_Sup_iff SUPR_def[where 'a=pextreal] SUPR_fun_expand[where 'c=pextreal])
hoelzl@38656
  1395
  then show "{x\<in>space M. a < ?sup x} \<in> sets M"
hoelzl@38656
  1396
    using assms by auto
hoelzl@38656
  1397
qed
hoelzl@38656
  1398
hoelzl@38656
  1399
lemma (in sigma_algebra) borel_measurable_INF[simp, intro]:
hoelzl@41023
  1400
  fixes f :: "'d :: countable \<Rightarrow> 'a \<Rightarrow> pextreal"
hoelzl@38656
  1401
  assumes "\<And>i. i \<in> A \<Longrightarrow> f i \<in> borel_measurable M"
hoelzl@38656
  1402
  shows "(INF i : A. f i) \<in> borel_measurable M" (is "?inf \<in> borel_measurable M")
hoelzl@41023
  1403
  unfolding borel_measurable_pextreal_iff_less
hoelzl@38656
  1404
proof safe
hoelzl@38656
  1405
  fix a
hoelzl@38656
  1406
  have "{x\<in>space M. ?inf x < a} = (\<Union>i\<in>A. {x\<in>space M. f i x < a})"
hoelzl@41023
  1407
    by (auto simp: Inf_less_iff INFI_def[where 'a=pextreal] INFI_fun_expand)
hoelzl@38656
  1408
  then show "{x\<in>space M. ?inf x < a} \<in> sets M"
hoelzl@38656
  1409
    using assms by auto
hoelzl@38656
  1410
qed
hoelzl@38656
  1411
hoelzl@41023
  1412
lemma (in sigma_algebra) borel_measurable_pextreal_diff[simp, intro]:
hoelzl@41023
  1413
  fixes f g :: "'a \<Rightarrow> pextreal"
hoelzl@38656
  1414
  assumes "f \<in> borel_measurable M"
hoelzl@38656
  1415
  assumes "g \<in> borel_measurable M"
hoelzl@38656
  1416
  shows "(\<lambda>x. f x - g x) \<in> borel_measurable M"
hoelzl@41023
  1417
  unfolding borel_measurable_pextreal_iff_greater
hoelzl@38656
  1418
proof safe
hoelzl@38656
  1419
  fix a
hoelzl@38656
  1420
  have "{x \<in> space M. a < f x - g x} = {x \<in> space M. g x + a < f x}"
hoelzl@41023
  1421
    by (simp add: pextreal_less_minus_iff)
hoelzl@38656
  1422
  then show "{x \<in> space M. a < f x - g x} \<in> sets M"
hoelzl@38656
  1423
    using assms by auto
hoelzl@35692
  1424
qed
hoelzl@35692
  1425
hoelzl@40870
  1426
lemma (in sigma_algebra) borel_measurable_psuminf[simp, intro]:
hoelzl@39092
  1427
  assumes "\<And>i. f i \<in> borel_measurable M"
hoelzl@39092
  1428
  shows "(\<lambda>x. (\<Sum>\<^isub>\<infinity> i. f i x)) \<in> borel_measurable M"
hoelzl@39092
  1429
  using assms unfolding psuminf_def
hoelzl@39092
  1430
  by (auto intro!: borel_measurable_SUP[unfolded SUPR_fun_expand])
hoelzl@39092
  1431
hoelzl@39092
  1432
section "LIMSEQ is borel measurable"
hoelzl@39092
  1433
hoelzl@39092
  1434
lemma (in sigma_algebra) borel_measurable_LIMSEQ:
hoelzl@39092
  1435
  fixes u :: "nat \<Rightarrow> 'a \<Rightarrow> real"
hoelzl@39092
  1436
  assumes u': "\<And>x. x \<in> space M \<Longrightarrow> (\<lambda>i. u i x) ----> u' x"
hoelzl@39092
  1437
  and u: "\<And>i. u i \<in> borel_measurable M"
hoelzl@39092
  1438
  shows "u' \<in> borel_measurable M"
hoelzl@39092
  1439
proof -
hoelzl@39092
  1440
  let "?pu x i" = "max (u i x) 0"
hoelzl@39092
  1441
  let "?nu x i" = "max (- u i x) 0"
hoelzl@39092
  1442
  { fix x assume x: "x \<in> space M"
hoelzl@39092
  1443
    have "(?pu x) ----> max (u' x) 0"
hoelzl@39092
  1444
      "(?nu x) ----> max (- u' x) 0"
hoelzl@39092
  1445
      using u'[OF x] by (auto intro!: LIMSEQ_max LIMSEQ_minus)
hoelzl@39092
  1446
    from LIMSEQ_imp_lim_INF[OF _ this(1)] LIMSEQ_imp_lim_INF[OF _ this(2)]
hoelzl@39092
  1447
    have "(SUP n. INF m. Real (u (n + m) x)) = Real (u' x)"
hoelzl@39092
  1448
      "(SUP n. INF m. Real (- u (n + m) x)) = Real (- u' x)"
hoelzl@39092
  1449
      by (simp_all add: Real_max'[symmetric]) }
hoelzl@39092
  1450
  note eq = this
hoelzl@39092
  1451
  have *: "\<And>x. real (Real (u' x)) - real (Real (- u' x)) = u' x"
hoelzl@39092
  1452
    by auto
hoelzl@39092
  1453
  have "(SUP n. INF m. (\<lambda>x. Real (u (n + m) x))) \<in> borel_measurable M"
hoelzl@39092
  1454
       "(SUP n. INF m. (\<lambda>x. Real (- u (n + m) x))) \<in> borel_measurable M"
hoelzl@39092
  1455
    using u by (auto intro: borel_measurable_SUP borel_measurable_INF borel_measurable_Real)
hoelzl@40859
  1456
  with eq[THEN measurable_cong, of M "\<lambda>x. x" borel]
hoelzl@39092
  1457
  have "(\<lambda>x. Real (u' x)) \<in> borel_measurable M"
hoelzl@39092
  1458
       "(\<lambda>x. Real (- u' x)) \<in> borel_measurable M"
hoelzl@39092
  1459
    unfolding SUPR_fun_expand INFI_fun_expand by auto
hoelzl@39092
  1460
  note this[THEN borel_measurable_real]
hoelzl@39092
  1461
  from borel_measurable_diff[OF this]
hoelzl@39092
  1462
  show ?thesis unfolding * .
hoelzl@39092
  1463
qed
hoelzl@39092
  1464
paulson@33533
  1465
end