src/HOL/Probability/Measurable.thy
author wenzelm
Tue, 03 Sep 2013 01:12:40 +0200
changeset 53374 a14d2a854c02
parent 53043 8cbfbeb566a4
child 56021 e0c9d76c2a6d
permissions -rw-r--r--
tuned proofs -- clarified flow of facts wrt. calculation;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50530
6266e44b3396 updated some headers;
wenzelm
parents: 50387
diff changeset
     1
(*  Title:      HOL/Probability/Measurable.thy
50387
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
     2
    Author:     Johannes Hölzl <hoelzl@in.tum.de>
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
     3
*)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
     4
theory Measurable
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
     5
  imports Sigma_Algebra
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
     6
begin
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
     7
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
     8
subsection {* Measurability prover *}
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
     9
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    10
lemma (in algebra) sets_Collect_finite_All:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    11
  assumes "\<And>i. i \<in> S \<Longrightarrow> {x\<in>\<Omega>. P i x} \<in> M" "finite S"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    12
  shows "{x\<in>\<Omega>. \<forall>i\<in>S. P i x} \<in> M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    13
proof -
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    14
  have "{x\<in>\<Omega>. \<forall>i\<in>S. P i x} = (if S = {} then \<Omega> else \<Inter>i\<in>S. {x\<in>\<Omega>. P i x})"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    15
    by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    16
  with assms show ?thesis by (auto intro!: sets_Collect_finite_All')
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    17
qed
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    18
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    19
abbreviation "pred M P \<equiv> P \<in> measurable M (count_space (UNIV::bool set))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    20
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    21
lemma pred_def: "pred M P \<longleftrightarrow> {x\<in>space M. P x} \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    22
proof
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    23
  assume "pred M P"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    24
  then have "P -` {True} \<inter> space M \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    25
    by (auto simp: measurable_count_space_eq2)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    26
  also have "P -` {True} \<inter> space M = {x\<in>space M. P x}" by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    27
  finally show "{x\<in>space M. P x} \<in> sets M" .
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    28
next
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    29
  assume P: "{x\<in>space M. P x} \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    30
  moreover
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    31
  { fix X
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    32
    have "X \<in> Pow (UNIV :: bool set)" by simp
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    33
    then have "P -` X \<inter> space M = {x\<in>space M. ((X = {True} \<longrightarrow> P x) \<and> (X = {False} \<longrightarrow> \<not> P x) \<and> X \<noteq> {})}"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    34
      unfolding UNIV_bool Pow_insert Pow_empty by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    35
    then have "P -` X \<inter> space M \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    36
      by (auto intro!: sets.sets_Collect_neg sets.sets_Collect_imp sets.sets_Collect_conj sets.sets_Collect_const P) }
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    37
  then show "pred M P"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    38
    by (auto simp: measurable_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    39
qed
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    40
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    41
lemma pred_sets1: "{x\<in>space M. P x} \<in> sets M \<Longrightarrow> f \<in> measurable N M \<Longrightarrow> pred N (\<lambda>x. P (f x))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    42
  by (rule measurable_compose[where f=f and N=M]) (auto simp: pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    43
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    44
lemma pred_sets2: "A \<in> sets N \<Longrightarrow> f \<in> measurable M N \<Longrightarrow> pred M (\<lambda>x. f x \<in> A)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    45
  by (rule measurable_compose[where f=f and N=N]) (auto simp: pred_def Int_def[symmetric])
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    46
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    47
ML_file "measurable.ML"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    48
53043
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    49
attribute_setup measurable = {*
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    50
  Scan.lift (Scan.optional (Args.parens (Scan.optional (Args.$$$ "raw" >> K true) false --
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    51
    Scan.optional (Args.$$$ "generic" >> K Measurable.Generic) Measurable.Concrete))
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    52
    (false, Measurable.Concrete) >> (Thm.declaration_attribute o Measurable.add_thm))
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    53
*} "declaration of measurability theorems"
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    54
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    55
attribute_setup measurable_dest = {*
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    56
  Scan.lift (Scan.succeed (Thm.declaration_attribute Measurable.add_dest))
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    57
*} "add dest rule for measurability prover"
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    58
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    59
attribute_setup measurable_app = {*
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    60
  Scan.lift (Scan.succeed (Thm.declaration_attribute Measurable.add_app))
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    61
*} "add application rule for measurability prover"
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    62
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    63
method_setup measurable = {*
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    64
  Scan.lift (Scan.succeed (fn ctxt => METHOD (fn facts => Measurable.measurable_tac ctxt facts)))
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    65
*} "measurability prover"
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    66
50387
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    67
simproc_setup measurable ("A \<in> sets M" | "f \<in> measurable M N") = {* K Measurable.simproc *}
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    68
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    69
declare
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    70
  measurable_compose_rev[measurable_dest]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    71
  pred_sets1[measurable_dest]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    72
  pred_sets2[measurable_dest]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    73
  sets.sets_into_space[measurable_dest]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    74
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    75
declare
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    76
  sets.top[measurable]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    77
  sets.empty_sets[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    78
  sets.Un[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    79
  sets.Diff[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    80
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    81
declare
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    82
  measurable_count_space[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    83
  measurable_ident[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    84
  measurable_ident_sets[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    85
  measurable_const[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    86
  measurable_If[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    87
  measurable_comp[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    88
  measurable_sets[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    89
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    90
lemma predE[measurable (raw)]: 
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    91
  "pred M P \<Longrightarrow> {x\<in>space M. P x} \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    92
  unfolding pred_def .
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    93
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    94
lemma pred_intros_imp'[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    95
  "(K \<Longrightarrow> pred M (\<lambda>x. P x)) \<Longrightarrow> pred M (\<lambda>x. K \<longrightarrow> P x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    96
  by (cases K) auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    97
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    98
lemma pred_intros_conj1'[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    99
  "(K \<Longrightarrow> pred M (\<lambda>x. P x)) \<Longrightarrow> pred M (\<lambda>x. K \<and> P x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   100
  by (cases K) auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   101
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   102
lemma pred_intros_conj2'[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   103
  "(K \<Longrightarrow> pred M (\<lambda>x. P x)) \<Longrightarrow> pred M (\<lambda>x. P x \<and> K)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   104
  by (cases K) auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   105
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   106
lemma pred_intros_disj1'[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   107
  "(\<not> K \<Longrightarrow> pred M (\<lambda>x. P x)) \<Longrightarrow> pred M (\<lambda>x. K \<or> P x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   108
  by (cases K) auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   109
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   110
lemma pred_intros_disj2'[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   111
  "(\<not> K \<Longrightarrow> pred M (\<lambda>x. P x)) \<Longrightarrow> pred M (\<lambda>x. P x \<or> K)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   112
  by (cases K) auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   113
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   114
lemma pred_intros_logic[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   115
  "pred M (\<lambda>x. x \<in> space M)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   116
  "pred M (\<lambda>x. P x) \<Longrightarrow> pred M (\<lambda>x. \<not> P x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   117
  "pred M (\<lambda>x. Q x) \<Longrightarrow> pred M (\<lambda>x. P x) \<Longrightarrow> pred M (\<lambda>x. Q x \<and> P x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   118
  "pred M (\<lambda>x. Q x) \<Longrightarrow> pred M (\<lambda>x. P x) \<Longrightarrow> pred M (\<lambda>x. Q x \<longrightarrow> P x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   119
  "pred M (\<lambda>x. Q x) \<Longrightarrow> pred M (\<lambda>x. P x) \<Longrightarrow> pred M (\<lambda>x. Q x \<or> P x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   120
  "pred M (\<lambda>x. Q x) \<Longrightarrow> pred M (\<lambda>x. P x) \<Longrightarrow> pred M (\<lambda>x. Q x = P x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   121
  "pred M (\<lambda>x. f x \<in> UNIV)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   122
  "pred M (\<lambda>x. f x \<in> {})"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   123
  "pred M (\<lambda>x. P' (f x) x) \<Longrightarrow> pred M (\<lambda>x. f x \<in> {y. P' y x})"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   124
  "pred M (\<lambda>x. f x \<in> (B x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> - (B x))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   125
  "pred M (\<lambda>x. f x \<in> (A x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (B x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (A x) - (B x))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   126
  "pred M (\<lambda>x. f x \<in> (A x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (B x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (A x) \<inter> (B x))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   127
  "pred M (\<lambda>x. f x \<in> (A x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (B x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (A x) \<union> (B x))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   128
  "pred M (\<lambda>x. g x (f x) \<in> (X x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (g x) -` (X x))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   129
  by (auto simp: iff_conv_conj_imp pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   130
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   131
lemma pred_intros_countable[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   132
  fixes P :: "'a \<Rightarrow> 'i :: countable \<Rightarrow> bool"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   133
  shows 
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   134
    "(\<And>i. pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<forall>i. P x i)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   135
    "(\<And>i. pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<exists>i. P x i)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   136
  by (auto intro!: sets.sets_Collect_countable_All sets.sets_Collect_countable_Ex simp: pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   137
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   138
lemma pred_intros_countable_bounded[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   139
  fixes X :: "'i :: countable set"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   140
  shows 
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   141
    "(\<And>i. i \<in> X \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Inter>i\<in>X. N x i))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   142
    "(\<And>i. i \<in> X \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Union>i\<in>X. N x i))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   143
    "(\<And>i. i \<in> X \<Longrightarrow> pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<forall>i\<in>X. P x i)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   144
    "(\<And>i. i \<in> X \<Longrightarrow> pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<exists>i\<in>X. P x i)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   145
  by (auto simp: Bex_def Ball_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   146
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   147
lemma pred_intros_finite[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   148
  "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Inter>i\<in>I. N x i))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   149
  "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Union>i\<in>I. N x i))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   150
  "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<forall>i\<in>I. P x i)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   151
  "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<exists>i\<in>I. P x i)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   152
  by (auto intro!: sets.sets_Collect_finite_Ex sets.sets_Collect_finite_All simp: iff_conv_conj_imp pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   153
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   154
lemma countable_Un_Int[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   155
  "(\<And>i :: 'i :: countable. i \<in> I \<Longrightarrow> N i \<in> sets M) \<Longrightarrow> (\<Union>i\<in>I. N i) \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   156
  "I \<noteq> {} \<Longrightarrow> (\<And>i :: 'i :: countable. i \<in> I \<Longrightarrow> N i \<in> sets M) \<Longrightarrow> (\<Inter>i\<in>I. N i) \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   157
  by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   158
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   159
declare
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   160
  finite_UN[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   161
  finite_INT[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   162
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   163
lemma sets_Int_pred[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   164
  assumes space: "A \<inter> B \<subseteq> space M" and [measurable]: "pred M (\<lambda>x. x \<in> A)" "pred M (\<lambda>x. x \<in> B)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   165
  shows "A \<inter> B \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   166
proof -
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   167
  have "{x\<in>space M. x \<in> A \<inter> B} \<in> sets M" by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   168
  also have "{x\<in>space M. x \<in> A \<inter> B} = A \<inter> B"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   169
    using space by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   170
  finally show ?thesis .
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   171
qed
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   172
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   173
lemma [measurable (raw generic)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   174
  assumes f: "f \<in> measurable M N" and c: "c \<in> space N \<Longrightarrow> {c} \<in> sets N"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   175
  shows pred_eq_const1: "pred M (\<lambda>x. f x = c)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   176
    and pred_eq_const2: "pred M (\<lambda>x. c = f x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   177
proof -
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   178
  show "pred M (\<lambda>x. f x = c)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   179
  proof cases
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   180
    assume "c \<in> space N"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   181
    with measurable_sets[OF f c] show ?thesis
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   182
      by (auto simp: Int_def conj_commute pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   183
  next
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   184
    assume "c \<notin> space N"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   185
    with f[THEN measurable_space] have "{x \<in> space M. f x = c} = {}" by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   186
    then show ?thesis by (auto simp: pred_def cong: conj_cong)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   187
  qed
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   188
  then show "pred M (\<lambda>x. c = f x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   189
    by (simp add: eq_commute)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   190
qed
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   191
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   192
lemma pred_le_const[measurable (raw generic)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   193
  assumes f: "f \<in> measurable M N" and c: "{.. c} \<in> sets N" shows "pred M (\<lambda>x. f x \<le> c)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   194
  using measurable_sets[OF f c]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   195
  by (auto simp: Int_def conj_commute eq_commute pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   196
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   197
lemma pred_const_le[measurable (raw generic)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   198
  assumes f: "f \<in> measurable M N" and c: "{c ..} \<in> sets N" shows "pred M (\<lambda>x. c \<le> f x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   199
  using measurable_sets[OF f c]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   200
  by (auto simp: Int_def conj_commute eq_commute pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   201
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   202
lemma pred_less_const[measurable (raw generic)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   203
  assumes f: "f \<in> measurable M N" and c: "{..< c} \<in> sets N" shows "pred M (\<lambda>x. f x < c)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   204
  using measurable_sets[OF f c]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   205
  by (auto simp: Int_def conj_commute eq_commute pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   206
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   207
lemma pred_const_less[measurable (raw generic)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   208
  assumes f: "f \<in> measurable M N" and c: "{c <..} \<in> sets N" shows "pred M (\<lambda>x. c < f x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   209
  using measurable_sets[OF f c]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   210
  by (auto simp: Int_def conj_commute eq_commute pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   211
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   212
declare
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   213
  sets.Int[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   214
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   215
lemma pred_in_If[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   216
  "(P \<Longrightarrow> pred M (\<lambda>x. x \<in> A x)) \<Longrightarrow> (\<not> P \<Longrightarrow> pred M (\<lambda>x. x \<in> B x)) \<Longrightarrow>
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   217
    pred M (\<lambda>x. x \<in> (if P then A x else B x))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   218
  by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   219
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   220
lemma sets_range[measurable_dest]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   221
  "A ` I \<subseteq> sets M \<Longrightarrow> i \<in> I \<Longrightarrow> A i \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   222
  by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   223
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   224
lemma pred_sets_range[measurable_dest]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   225
  "A ` I \<subseteq> sets N \<Longrightarrow> i \<in> I \<Longrightarrow> f \<in> measurable M N \<Longrightarrow> pred M (\<lambda>x. f x \<in> A i)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   226
  using pred_sets2[OF sets_range] by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   227
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   228
lemma sets_All[measurable_dest]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   229
  "\<forall>i. A i \<in> sets (M i) \<Longrightarrow> A i \<in> sets (M i)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   230
  by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   231
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   232
lemma pred_sets_All[measurable_dest]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   233
  "\<forall>i. A i \<in> sets (N i) \<Longrightarrow> f \<in> measurable M (N i) \<Longrightarrow> pred M (\<lambda>x. f x \<in> A i)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   234
  using pred_sets2[OF sets_All, of A N f] by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   235
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   236
lemma sets_Ball[measurable_dest]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   237
  "\<forall>i\<in>I. A i \<in> sets (M i) \<Longrightarrow> i\<in>I \<Longrightarrow> A i \<in> sets (M i)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   238
  by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   239
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   240
lemma pred_sets_Ball[measurable_dest]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   241
  "\<forall>i\<in>I. A i \<in> sets (N i) \<Longrightarrow> i\<in>I \<Longrightarrow> f \<in> measurable M (N i) \<Longrightarrow> pred M (\<lambda>x. f x \<in> A i)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   242
  using pred_sets2[OF sets_Ball, of _ _ _ f] by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   243
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   244
lemma measurable_finite[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   245
  fixes S :: "'a \<Rightarrow> nat set"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   246
  assumes [measurable]: "\<And>i. {x\<in>space M. i \<in> S x} \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   247
  shows "pred M (\<lambda>x. finite (S x))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   248
  unfolding finite_nat_set_iff_bounded by (simp add: Ball_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   249
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   250
lemma measurable_Least[measurable]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   251
  assumes [measurable]: "(\<And>i::nat. (\<lambda>x. P i x) \<in> measurable M (count_space UNIV))"q
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   252
  shows "(\<lambda>x. LEAST i. P i x) \<in> measurable M (count_space UNIV)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   253
  unfolding measurable_def by (safe intro!: sets_Least) simp_all
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   254
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   255
lemma measurable_count_space_insert[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   256
  "s \<in> S \<Longrightarrow> A \<in> sets (count_space S) \<Longrightarrow> insert s A \<in> sets (count_space S)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   257
  by simp
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   258
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   259
hide_const (open) pred
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   260
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   261
end