src/HOL/Probability/Measurable.thy
author hoelzl
Mon, 24 Nov 2014 12:20:14 +0100
changeset 59048 7dc8ac6f0895
parent 59047 8d7cec9b861d
child 59088 ff2bd4a14ddb
permissions -rw-r--r--
add congruence solver to measurability prover
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
56021
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
     5
  imports
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
     6
    Sigma_Algebra
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
     7
    "~~/src/HOL/Library/Order_Continuity"
50387
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
     8
begin
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
     9
56021
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
    10
hide_const (open) Order_Continuity.continuous
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
    11
50387
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    12
subsection {* Measurability prover *}
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    13
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    14
lemma (in algebra) sets_Collect_finite_All:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    15
  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
    16
  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
    17
proof -
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    18
  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
    19
    by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    20
  with assms show ?thesis by (auto intro!: sets_Collect_finite_All')
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    21
qed
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    22
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    23
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
    24
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    25
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
    26
proof
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    27
  assume "pred M P"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    28
  then have "P -` {True} \<inter> space M \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    29
    by (auto simp: measurable_count_space_eq2)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    30
  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
    31
  finally show "{x\<in>space M. P x} \<in> sets M" .
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    32
next
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    33
  assume P: "{x\<in>space M. P x} \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    34
  moreover
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    35
  { fix X
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    36
    have "X \<in> Pow (UNIV :: bool set)" by simp
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    37
    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
    38
      unfolding UNIV_bool Pow_insert Pow_empty by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    39
    then have "P -` X \<inter> space M \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    40
      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
    41
  then show "pred M P"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    42
    by (auto simp: measurable_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    43
qed
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    44
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    45
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
    46
  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
    47
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    48
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
    49
  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
    50
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    51
ML_file "measurable.ML"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    52
53043
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    53
attribute_setup measurable = {*
59047
8d7cec9b861d cleanup measurability prover
hoelzl
parents: 59000
diff changeset
    54
  Scan.lift (
8d7cec9b861d cleanup measurability prover
hoelzl
parents: 59000
diff changeset
    55
    (Args.add >> K true || Args.del >> K false || Scan.succeed true) --
8d7cec9b861d cleanup measurability prover
hoelzl
parents: 59000
diff changeset
    56
    Scan.optional (Args.parens (
8d7cec9b861d cleanup measurability prover
hoelzl
parents: 59000
diff changeset
    57
      Scan.optional (Args.$$$ "raw" >> K true) false --
58965
a62cdcc5344b add del option to measurable;
Andreas Lochbihler
parents: 57025
diff changeset
    58
      Scan.optional (Args.$$$ "generic" >> K Measurable.Generic) Measurable.Concrete))
59047
8d7cec9b861d cleanup measurability prover
hoelzl
parents: 59000
diff changeset
    59
    (false, Measurable.Concrete) >>
8d7cec9b861d cleanup measurability prover
hoelzl
parents: 59000
diff changeset
    60
    Measurable.measurable_thm_attr)
53043
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    61
*} "declaration of measurability theorems"
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    62
59047
8d7cec9b861d cleanup measurability prover
hoelzl
parents: 59000
diff changeset
    63
attribute_setup measurable_dest = Measurable.dest_thm_attr
59048
7dc8ac6f0895 add congruence solver to measurability prover
hoelzl
parents: 59047
diff changeset
    64
  "add dest rule to measurability prover"
53043
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    65
59047
8d7cec9b861d cleanup measurability prover
hoelzl
parents: 59000
diff changeset
    66
attribute_setup measurable_app = Measurable.app_thm_attr
59048
7dc8ac6f0895 add congruence solver to measurability prover
hoelzl
parents: 59047
diff changeset
    67
  "add application rule to measurability prover"
7dc8ac6f0895 add congruence solver to measurability prover
hoelzl
parents: 59047
diff changeset
    68
7dc8ac6f0895 add congruence solver to measurability prover
hoelzl
parents: 59047
diff changeset
    69
attribute_setup measurable_cong = Measurable.cong_thm_attr
7dc8ac6f0895 add congruence solver to measurability prover
hoelzl
parents: 59047
diff changeset
    70
  "add congurence rules to measurability prover"
53043
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    71
59047
8d7cec9b861d cleanup measurability prover
hoelzl
parents: 59000
diff changeset
    72
method_setup measurable = \<open> Scan.lift (Scan.succeed (METHOD o Measurable.measurable_tac)) \<close>
8d7cec9b861d cleanup measurability prover
hoelzl
parents: 59000
diff changeset
    73
  "measurability prover"
53043
8cbfbeb566a4 more standard attribute_setup / method_setup -- export key ML operations instead of parsers;
wenzelm
parents: 50530
diff changeset
    74
50387
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    75
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
    76
58965
a62cdcc5344b add del option to measurable;
Andreas Lochbihler
parents: 57025
diff changeset
    77
setup {*
59048
7dc8ac6f0895 add congruence solver to measurability prover
hoelzl
parents: 59047
diff changeset
    78
  Global_Theory.add_thms_dynamic (@{binding measurable}, Measurable.get_all)
58965
a62cdcc5344b add del option to measurable;
Andreas Lochbihler
parents: 57025
diff changeset
    79
*}
a62cdcc5344b add del option to measurable;
Andreas Lochbihler
parents: 57025
diff changeset
    80
50387
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_compose_rev[measurable_dest]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    83
  pred_sets1[measurable_dest]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    84
  pred_sets2[measurable_dest]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    85
  sets.sets_into_space[measurable_dest]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    86
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    87
declare
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    88
  sets.top[measurable]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    89
  sets.empty_sets[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    90
  sets.Un[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    91
  sets.Diff[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    92
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    93
declare
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    94
  measurable_count_space[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    95
  measurable_ident[measurable (raw)]
59048
7dc8ac6f0895 add congruence solver to measurability prover
hoelzl
parents: 59047
diff changeset
    96
  measurable_id[measurable (raw)]
50387
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    97
  measurable_const[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    98
  measurable_If[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
    99
  measurable_comp[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   100
  measurable_sets[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   101
59048
7dc8ac6f0895 add congruence solver to measurability prover
hoelzl
parents: 59047
diff changeset
   102
declare measurable_cong_sets[measurable_cong]
7dc8ac6f0895 add congruence solver to measurability prover
hoelzl
parents: 59047
diff changeset
   103
declare sets_restrict_space_cong[measurable_cong]
7dc8ac6f0895 add congruence solver to measurability prover
hoelzl
parents: 59047
diff changeset
   104
50387
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   105
lemma predE[measurable (raw)]: 
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   106
  "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
   107
  unfolding pred_def .
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   108
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   109
lemma pred_intros_imp'[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   110
  "(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
   111
  by (cases K) auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   112
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   113
lemma pred_intros_conj1'[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   114
  "(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
   115
  by (cases K) auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   116
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   117
lemma pred_intros_conj2'[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   118
  "(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
   119
  by (cases K) auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   120
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   121
lemma pred_intros_disj1'[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   122
  "(\<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
   123
  by (cases K) auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   124
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   125
lemma pred_intros_disj2'[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   126
  "(\<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
   127
  by (cases K) auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   128
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   129
lemma pred_intros_logic[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   130
  "pred M (\<lambda>x. x \<in> space M)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   131
  "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
   132
  "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
   133
  "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
   134
  "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
   135
  "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
   136
  "pred M (\<lambda>x. f x \<in> UNIV)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   137
  "pred M (\<lambda>x. f x \<in> {})"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   138
  "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
   139
  "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
   140
  "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
   141
  "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
   142
  "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
   143
  "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
   144
  by (auto simp: iff_conv_conj_imp pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   145
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   146
lemma pred_intros_countable[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   147
  fixes P :: "'a \<Rightarrow> 'i :: countable \<Rightarrow> bool"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   148
  shows 
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   149
    "(\<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
   150
    "(\<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
   151
  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
   152
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   153
lemma pred_intros_countable_bounded[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   154
  fixes X :: "'i :: countable set"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   155
  shows 
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   156
    "(\<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
   157
    "(\<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
   158
    "(\<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
   159
    "(\<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
   160
  by (auto simp: Bex_def Ball_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   161
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   162
lemma pred_intros_finite[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   163
  "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
   164
  "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
   165
  "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
   166
  "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
   167
  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
   168
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   169
lemma countable_Un_Int[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   170
  "(\<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
   171
  "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
   172
  by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   173
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   174
declare
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   175
  finite_UN[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   176
  finite_INT[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   177
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   178
lemma sets_Int_pred[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   179
  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
   180
  shows "A \<inter> B \<in> sets M"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   181
proof -
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   182
  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
   183
  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
   184
    using space by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   185
  finally show ?thesis .
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   186
qed
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   187
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   188
lemma [measurable (raw generic)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   189
  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
   190
  shows pred_eq_const1: "pred M (\<lambda>x. f x = c)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   191
    and pred_eq_const2: "pred M (\<lambda>x. c = f x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   192
proof -
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   193
  show "pred M (\<lambda>x. f x = c)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   194
  proof cases
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   195
    assume "c \<in> space N"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   196
    with measurable_sets[OF f c] show ?thesis
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   197
      by (auto simp: Int_def conj_commute pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   198
  next
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   199
    assume "c \<notin> space N"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   200
    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
   201
    then show ?thesis by (auto simp: pred_def cong: conj_cong)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   202
  qed
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   203
  then show "pred M (\<lambda>x. c = f x)"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   204
    by (simp add: eq_commute)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   205
qed
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   206
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   207
lemma pred_count_space_const1[measurable (raw)]:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   208
  "f \<in> measurable M (count_space UNIV) \<Longrightarrow> Measurable.pred M (\<lambda>x. f x = c)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   209
  by (intro pred_eq_const1[where N="count_space UNIV"]) (auto )
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   210
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   211
lemma pred_count_space_const2[measurable (raw)]:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   212
  "f \<in> measurable M (count_space UNIV) \<Longrightarrow> Measurable.pred M (\<lambda>x. c = f x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   213
  by (intro pred_eq_const2[where N="count_space UNIV"]) (auto )
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   214
50387
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   215
lemma pred_le_const[measurable (raw generic)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   216
  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
   217
  using measurable_sets[OF f c]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   218
  by (auto simp: Int_def conj_commute eq_commute pred_def)
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 pred_const_le[measurable (raw generic)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   221
  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
   222
  using measurable_sets[OF f c]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   223
  by (auto simp: Int_def conj_commute eq_commute pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   224
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   225
lemma pred_less_const[measurable (raw generic)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   226
  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
   227
  using measurable_sets[OF f c]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   228
  by (auto simp: Int_def conj_commute eq_commute pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   229
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   230
lemma pred_const_less[measurable (raw generic)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   231
  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
   232
  using measurable_sets[OF f c]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   233
  by (auto simp: Int_def conj_commute eq_commute pred_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   234
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   235
declare
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   236
  sets.Int[measurable (raw)]
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   237
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   238
lemma pred_in_If[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   239
  "(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
   240
    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
   241
  by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   242
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   243
lemma sets_range[measurable_dest]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   244
  "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
   245
  by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   246
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   247
lemma pred_sets_range[measurable_dest]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   248
  "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
   249
  using pred_sets2[OF sets_range] by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   250
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   251
lemma sets_All[measurable_dest]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   252
  "\<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
   253
  by auto
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 pred_sets_All[measurable_dest]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   256
  "\<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
   257
  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
   258
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   259
lemma sets_Ball[measurable_dest]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   260
  "\<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
   261
  by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   262
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   263
lemma pred_sets_Ball[measurable_dest]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   264
  "\<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
   265
  using pred_sets2[OF sets_Ball, of _ _ _ f] by auto
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   266
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   267
lemma measurable_finite[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   268
  fixes S :: "'a \<Rightarrow> nat set"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   269
  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
   270
  shows "pred M (\<lambda>x. finite (S x))"
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   271
  unfolding finite_nat_set_iff_bounded by (simp add: Ball_def)
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   272
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   273
lemma measurable_Least[measurable]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   274
  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
   275
  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
   276
  unfolding measurable_def by (safe intro!: sets_Least) simp_all
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   277
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   278
lemma measurable_Max_nat[measurable (raw)]: 
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   279
  fixes P :: "nat \<Rightarrow> 'a \<Rightarrow> bool"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   280
  assumes [measurable]: "\<And>i. Measurable.pred M (P i)"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   281
  shows "(\<lambda>x. Max {i. P i x}) \<in> measurable M (count_space UNIV)"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   282
  unfolding measurable_count_space_eq2_countable
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   283
proof safe
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   284
  fix n
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   285
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   286
  { fix x assume "\<forall>i. \<exists>n\<ge>i. P n x"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   287
    then have "infinite {i. P i x}"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   288
      unfolding infinite_nat_iff_unbounded_le by auto
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   289
    then have "Max {i. P i x} = the None"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   290
      by (rule Max.infinite) }
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   291
  note 1 = this
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   292
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   293
  { fix x i j assume "P i x" "\<forall>n\<ge>j. \<not> P n x"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   294
    then have "finite {i. P i x}"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   295
      by (auto simp: subset_eq not_le[symmetric] finite_nat_iff_bounded)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   296
    with `P i x` have "P (Max {i. P i x}) x" "i \<le> Max {i. P i x}" "finite {i. P i x}"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   297
      using Max_in[of "{i. P i x}"] by auto }
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   298
  note 2 = this
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   299
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   300
  have "(\<lambda>x. Max {i. P i x}) -` {n} \<inter> space M = {x\<in>space M. Max {i. P i x} = n}"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   301
    by auto
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   302
  also have "\<dots> = 
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   303
    {x\<in>space M. if (\<forall>i. \<exists>n\<ge>i. P n x) then the None = n else 
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   304
      if (\<exists>i. P i x) then P n x \<and> (\<forall>i>n. \<not> P i x)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   305
      else Max {} = n}"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   306
    by (intro arg_cong[where f=Collect] ext conj_cong)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   307
       (auto simp add: 1 2 not_le[symmetric] intro!: Max_eqI)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   308
  also have "\<dots> \<in> sets M"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   309
    by measurable
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   310
  finally show "(\<lambda>x. Max {i. P i x}) -` {n} \<inter> space M \<in> sets M" .
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   311
qed simp
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   312
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   313
lemma measurable_Min_nat[measurable (raw)]: 
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   314
  fixes P :: "nat \<Rightarrow> 'a \<Rightarrow> bool"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   315
  assumes [measurable]: "\<And>i. Measurable.pred M (P i)"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   316
  shows "(\<lambda>x. Min {i. P i x}) \<in> measurable M (count_space UNIV)"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   317
  unfolding measurable_count_space_eq2_countable
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   318
proof safe
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   319
  fix n
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   320
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   321
  { fix x assume "\<forall>i. \<exists>n\<ge>i. P n x"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   322
    then have "infinite {i. P i x}"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   323
      unfolding infinite_nat_iff_unbounded_le by auto
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   324
    then have "Min {i. P i x} = the None"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   325
      by (rule Min.infinite) }
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   326
  note 1 = this
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   327
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   328
  { fix x i j assume "P i x" "\<forall>n\<ge>j. \<not> P n x"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   329
    then have "finite {i. P i x}"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   330
      by (auto simp: subset_eq not_le[symmetric] finite_nat_iff_bounded)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   331
    with `P i x` have "P (Min {i. P i x}) x" "Min {i. P i x} \<le> i" "finite {i. P i x}"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   332
      using Min_in[of "{i. P i x}"] by auto }
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   333
  note 2 = this
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   334
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   335
  have "(\<lambda>x. Min {i. P i x}) -` {n} \<inter> space M = {x\<in>space M. Min {i. P i x} = n}"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   336
    by auto
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   337
  also have "\<dots> = 
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   338
    {x\<in>space M. if (\<forall>i. \<exists>n\<ge>i. P n x) then the None = n else 
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   339
      if (\<exists>i. P i x) then P n x \<and> (\<forall>i<n. \<not> P i x)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   340
      else Min {} = n}"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   341
    by (intro arg_cong[where f=Collect] ext conj_cong)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   342
       (auto simp add: 1 2 not_le[symmetric] intro!: Min_eqI)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   343
  also have "\<dots> \<in> sets M"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   344
    by measurable
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   345
  finally show "(\<lambda>x. Min {i. P i x}) -` {n} \<inter> space M \<in> sets M" .
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   346
qed simp
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56045
diff changeset
   347
50387
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   348
lemma measurable_count_space_insert[measurable (raw)]:
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   349
  "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
   350
  by simp
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   351
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   352
lemma sets_UNIV [measurable (raw)]: "A \<in> sets (count_space UNIV)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   353
  by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   354
57025
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   355
lemma measurable_card[measurable]:
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   356
  fixes S :: "'a \<Rightarrow> nat set"
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   357
  assumes [measurable]: "\<And>i. {x\<in>space M. i \<in> S x} \<in> sets M"
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   358
  shows "(\<lambda>x. card (S x)) \<in> measurable M (count_space UNIV)"
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   359
  unfolding measurable_count_space_eq2_countable
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   360
proof safe
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   361
  fix n show "(\<lambda>x. card (S x)) -` {n} \<inter> space M \<in> sets M"
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   362
  proof (cases n)
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   363
    case 0
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   364
    then have "(\<lambda>x. card (S x)) -` {n} \<inter> space M = {x\<in>space M. infinite (S x) \<or> (\<forall>i. i \<notin> S x)}"
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   365
      by auto
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   366
    also have "\<dots> \<in> sets M"
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   367
      by measurable
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   368
    finally show ?thesis .
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   369
  next
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   370
    case (Suc i)
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   371
    then have "(\<lambda>x. card (S x)) -` {n} \<inter> space M =
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   372
      (\<Union>F\<in>{A\<in>{A. finite A}. card A = n}. {x\<in>space M. (\<forall>i. i \<in> S x \<longleftrightarrow> i \<in> F)})"
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   373
      unfolding set_eq_iff[symmetric] Collect_bex_eq[symmetric] by (auto intro: card_ge_0_finite)
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   374
    also have "\<dots> \<in> sets M"
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   375
      by (intro sets.countable_UN' countable_Collect countable_Collect_finite) auto
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   376
    finally show ?thesis .
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   377
  qed
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   378
qed rule
e7fd64f82876 add various lemmas
hoelzl
parents: 56993
diff changeset
   379
56021
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   380
subsection {* Measurability for (co)inductive predicates *}
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   381
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   382
lemma measurable_lfp:
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   383
  assumes "Order_Continuity.continuous F"
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   384
  assumes *: "\<And>A. pred M A \<Longrightarrow> pred M (F A)"
56045
1ca060139a59 measurable_lfp/gfp: indirection not necessary
hoelzl
parents: 56021
diff changeset
   385
  shows "pred M (lfp F)"
56021
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   386
proof -
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   387
  { fix i have "Measurable.pred M (\<lambda>x. (F ^^ i) (\<lambda>x. False) x)"
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   388
      by (induct i) (auto intro!: *) }
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   389
  then have "Measurable.pred M (\<lambda>x. \<exists>i. (F ^^ i) (\<lambda>x. False) x)"
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   390
    by measurable
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   391
  also have "(\<lambda>x. \<exists>i. (F ^^ i) (\<lambda>x. False) x) = (SUP i. (F ^^ i) bot)"
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   392
    by (auto simp add: bot_fun_def)
56045
1ca060139a59 measurable_lfp/gfp: indirection not necessary
hoelzl
parents: 56021
diff changeset
   393
  also have "\<dots> = lfp F"
1ca060139a59 measurable_lfp/gfp: indirection not necessary
hoelzl
parents: 56021
diff changeset
   394
    by (rule continuous_lfp[symmetric]) fact
56021
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   395
  finally show ?thesis .
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   396
qed
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   397
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   398
lemma measurable_gfp:
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   399
  assumes "Order_Continuity.down_continuous F"
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   400
  assumes *: "\<And>A. pred M A \<Longrightarrow> pred M (F A)"
56045
1ca060139a59 measurable_lfp/gfp: indirection not necessary
hoelzl
parents: 56021
diff changeset
   401
  shows "pred M (gfp F)"
56021
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   402
proof -
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   403
  { fix i have "Measurable.pred M (\<lambda>x. (F ^^ i) (\<lambda>x. True) x)"
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   404
      by (induct i) (auto intro!: *) }
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   405
  then have "Measurable.pred M (\<lambda>x. \<forall>i. (F ^^ i) (\<lambda>x. True) x)"
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   406
    by measurable
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   407
  also have "(\<lambda>x. \<forall>i. (F ^^ i) (\<lambda>x. True) x) = (INF i. (F ^^ i) top)"
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   408
    by (auto simp add: top_fun_def)
56045
1ca060139a59 measurable_lfp/gfp: indirection not necessary
hoelzl
parents: 56021
diff changeset
   409
  also have "\<dots> = gfp F"
1ca060139a59 measurable_lfp/gfp: indirection not necessary
hoelzl
parents: 56021
diff changeset
   410
    by (rule down_continuous_gfp[symmetric]) fact
56021
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   411
  finally show ?thesis .
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   412
qed
e0c9d76c2a6d add measurability rule for (co)inductive predicates
hoelzl
parents: 53043
diff changeset
   413
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   414
lemma measurable_lfp_coinduct[consumes 1, case_names continuity step]:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   415
  assumes "P M"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   416
  assumes "Order_Continuity.continuous F"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   417
  assumes *: "\<And>M A. P M \<Longrightarrow> (\<And>N. P N \<Longrightarrow> Measurable.pred N A) \<Longrightarrow> Measurable.pred M (F A)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   418
  shows "Measurable.pred M (lfp F)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   419
proof -
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   420
  { fix i from `P M` have "Measurable.pred M (\<lambda>x. (F ^^ i) (\<lambda>x. False) x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   421
      by (induct i arbitrary: M) (auto intro!: *) }
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   422
  then have "Measurable.pred M (\<lambda>x. \<exists>i. (F ^^ i) (\<lambda>x. False) x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   423
    by measurable
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   424
  also have "(\<lambda>x. \<exists>i. (F ^^ i) (\<lambda>x. False) x) = (SUP i. (F ^^ i) bot)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   425
    by (auto simp add: bot_fun_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   426
  also have "\<dots> = lfp F"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   427
    by (rule continuous_lfp[symmetric]) fact
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   428
  finally show ?thesis .
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   429
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   430
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   431
lemma measurable_gfp_coinduct[consumes 1, case_names continuity step]:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   432
  assumes "P M"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   433
  assumes "Order_Continuity.down_continuous F"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   434
  assumes *: "\<And>M A. P M \<Longrightarrow> (\<And>N. P N \<Longrightarrow> Measurable.pred N A) \<Longrightarrow> Measurable.pred M (F A)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   435
  shows "Measurable.pred M (gfp F)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   436
proof -
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   437
  { fix i from `P M` have "Measurable.pred M (\<lambda>x. (F ^^ i) (\<lambda>x. True) x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   438
      by (induct i arbitrary: M) (auto intro!: *) }
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   439
  then have "Measurable.pred M (\<lambda>x. \<forall>i. (F ^^ i) (\<lambda>x. True) x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   440
    by measurable
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   441
  also have "(\<lambda>x. \<forall>i. (F ^^ i) (\<lambda>x. True) x) = (INF i. (F ^^ i) top)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   442
    by (auto simp add: top_fun_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   443
  also have "\<dots> = gfp F"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   444
    by (rule down_continuous_gfp[symmetric]) fact
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   445
  finally show ?thesis .
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   446
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   447
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   448
lemma measurable_lfp2_coinduct[consumes 1, case_names continuity step]:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   449
  assumes "P M s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   450
  assumes "Order_Continuity.continuous F"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   451
  assumes *: "\<And>M A s. P M s \<Longrightarrow> (\<And>N t. P N t \<Longrightarrow> Measurable.pred N (A t)) \<Longrightarrow> Measurable.pred M (F A s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   452
  shows "Measurable.pred M (lfp F s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   453
proof -
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   454
  { fix i from `P M s` have "Measurable.pred M (\<lambda>x. (F ^^ i) (\<lambda>t x. False) s x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   455
      by (induct i arbitrary: M s) (auto intro!: *) }
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   456
  then have "Measurable.pred M (\<lambda>x. \<exists>i. (F ^^ i) (\<lambda>t x. False) s x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   457
    by measurable
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   458
  also have "(\<lambda>x. \<exists>i. (F ^^ i) (\<lambda>t x. False) s x) = (SUP i. (F ^^ i) bot) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   459
    by (auto simp add: bot_fun_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   460
  also have "(SUP i. (F ^^ i) bot) = lfp F"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   461
    by (rule continuous_lfp[symmetric]) fact
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   462
  finally show ?thesis .
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   463
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   464
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   465
lemma measurable_gfp2_coinduct[consumes 1, case_names continuity step]:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   466
  assumes "P M s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   467
  assumes "Order_Continuity.down_continuous F"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   468
  assumes *: "\<And>M A s. P M s \<Longrightarrow> (\<And>N t. P N t \<Longrightarrow> Measurable.pred N (A t)) \<Longrightarrow> Measurable.pred M (F A s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   469
  shows "Measurable.pred M (gfp F s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   470
proof -
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   471
  { fix i from `P M s` have "Measurable.pred M (\<lambda>x. (F ^^ i) (\<lambda>t x. True) s x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   472
      by (induct i arbitrary: M s) (auto intro!: *) }
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   473
  then have "Measurable.pred M (\<lambda>x. \<forall>i. (F ^^ i) (\<lambda>t x. True) s x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   474
    by measurable
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   475
  also have "(\<lambda>x. \<forall>i. (F ^^ i) (\<lambda>t x. True) s x) = (INF i. (F ^^ i) top) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   476
    by (auto simp add: top_fun_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   477
  also have "(INF i. (F ^^ i) top) = gfp F"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   478
    by (rule down_continuous_gfp[symmetric]) fact
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   479
  finally show ?thesis .
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   480
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   481
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   482
lemma measurable_enat_coinduct:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   483
  fixes f :: "'a \<Rightarrow> enat"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   484
  assumes "R f"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   485
  assumes *: "\<And>f. R f \<Longrightarrow> \<exists>g h i P. R g \<and> f = (\<lambda>x. if P x then h x else eSuc (g (i x))) \<and> 
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   486
    Measurable.pred M P \<and>
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   487
    i \<in> measurable M M \<and>
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   488
    h \<in> measurable M (count_space UNIV)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   489
  shows "f \<in> measurable M (count_space UNIV)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   490
proof (simp add: measurable_count_space_eq2_countable, rule )
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   491
  fix a :: enat
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   492
  have "f -` {a} \<inter> space M = {x\<in>space M. f x = a}"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   493
    by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   494
  { fix i :: nat
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   495
    from `R f` have "Measurable.pred M (\<lambda>x. f x = enat i)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   496
    proof (induction i arbitrary: f)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   497
      case 0
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   498
      from *[OF this] obtain g h i P
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   499
        where f: "f = (\<lambda>x. if P x then h x else eSuc (g (i x)))" and
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   500
          [measurable]: "Measurable.pred M P" "i \<in> measurable M M" "h \<in> measurable M (count_space UNIV)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   501
        by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   502
      have "Measurable.pred M (\<lambda>x. P x \<and> h x = 0)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   503
        by measurable
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   504
      also have "(\<lambda>x. P x \<and> h x = 0) = (\<lambda>x. f x = enat 0)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   505
        by (auto simp: f zero_enat_def[symmetric])
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   506
      finally show ?case .
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   507
    next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   508
      case (Suc n)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   509
      from *[OF Suc.prems] obtain g h i P
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   510
        where f: "f = (\<lambda>x. if P x then h x else eSuc (g (i x)))" and "R g" and
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   511
          M[measurable]: "Measurable.pred M P" "i \<in> measurable M M" "h \<in> measurable M (count_space UNIV)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   512
        by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   513
      have "(\<lambda>x. f x = enat (Suc n)) =
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   514
        (\<lambda>x. (P x \<longrightarrow> h x = enat (Suc n)) \<and> (\<not> P x \<longrightarrow> g (i x) = enat n))"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   515
        by (auto simp: f zero_enat_def[symmetric] eSuc_enat[symmetric])
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   516
      also have "Measurable.pred M \<dots>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   517
        by (intro pred_intros_logic measurable_compose[OF M(2)] Suc `R g`) measurable
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   518
      finally show ?case .
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   519
    qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   520
    then have "f -` {enat i} \<inter> space M \<in> sets M"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   521
      by (simp add: pred_def Int_def conj_commute) }
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   522
  note fin = this
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   523
  show "f -` {a} \<inter> space M \<in> sets M"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   524
  proof (cases a)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   525
    case infinity
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   526
    then have "f -` {a} \<inter> space M = space M - (\<Union>n. f -` {enat n} \<inter> space M)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   527
      by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   528
    also have "\<dots> \<in> sets M"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   529
      by (intro sets.Diff sets.top sets.Un sets.countable_UN) (auto intro!: fin)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   530
    finally show ?thesis .
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   531
  qed (simp add: fin)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   532
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   533
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   534
lemma measurable_pred_countable[measurable (raw)]:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   535
  assumes "countable X"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   536
  shows 
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   537
    "(\<And>i. i \<in> X \<Longrightarrow> Measurable.pred M (\<lambda>x. P x i)) \<Longrightarrow> Measurable.pred M (\<lambda>x. \<forall>i\<in>X. P x i)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   538
    "(\<And>i. i \<in> X \<Longrightarrow> Measurable.pred M (\<lambda>x. P x i)) \<Longrightarrow> Measurable.pred M (\<lambda>x. \<exists>i\<in>X. P x i)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   539
  unfolding pred_def
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   540
  by (auto intro!: sets.sets_Collect_countable_All' sets.sets_Collect_countable_Ex' assms)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   541
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   542
lemma measurable_THE:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   543
  fixes P :: "'a \<Rightarrow> 'b \<Rightarrow> bool"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   544
  assumes [measurable]: "\<And>i. Measurable.pred M (P i)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   545
  assumes I[simp]: "countable I" "\<And>i x. x \<in> space M \<Longrightarrow> P i x \<Longrightarrow> i \<in> I"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   546
  assumes unique: "\<And>x i j. x \<in> space M \<Longrightarrow> P i x \<Longrightarrow> P j x \<Longrightarrow> i = j"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   547
  shows "(\<lambda>x. THE i. P i x) \<in> measurable M (count_space UNIV)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   548
  unfolding measurable_def
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   549
proof safe
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   550
  fix X
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   551
  def f \<equiv> "\<lambda>x. THE i. P i x" def undef \<equiv> "THE i::'a. False"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   552
  { fix i x assume "x \<in> space M" "P i x" then have "f x = i"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   553
      unfolding f_def using unique by auto }
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   554
  note f_eq = this
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   555
  { fix x assume "x \<in> space M" "\<forall>i\<in>I. \<not> P i x"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   556
    then have "\<And>i. \<not> P i x"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   557
      using I(2)[of x] by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   558
    then have "f x = undef"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   559
      by (auto simp: undef_def f_def) }
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   560
  then have "f -` X \<inter> space M = (\<Union>i\<in>I \<inter> X. {x\<in>space M. P i x}) \<union>
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   561
     (if undef \<in> X then space M - (\<Union>i\<in>I. {x\<in>space M. P i x}) else {})"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   562
    by (auto dest: f_eq)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   563
  also have "\<dots> \<in> sets M"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   564
    by (auto intro!: sets.Diff sets.countable_UN')
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   565
  finally show "f -` X \<inter> space M \<in> sets M" .
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   566
qed simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   567
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   568
lemma measurable_bot[measurable]: "Measurable.pred M bot"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   569
  by (simp add: bot_fun_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   570
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   571
lemma measurable_top[measurable]: "Measurable.pred M top"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   572
  by (simp add: top_fun_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   573
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   574
lemma measurable_Ex1[measurable (raw)]:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   575
  assumes [simp]: "countable I" and [measurable]: "\<And>i. i \<in> I \<Longrightarrow> Measurable.pred M (P i)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   576
  shows "Measurable.pred M (\<lambda>x. \<exists>!i\<in>I. P i x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   577
  unfolding bex1_def by measurable
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   578
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   579
lemma measurable_split_if[measurable (raw)]:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   580
  "(c \<Longrightarrow> Measurable.pred M f) \<Longrightarrow> (\<not> c \<Longrightarrow> Measurable.pred M g) \<Longrightarrow>
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   581
   Measurable.pred M (if c then f else g)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   582
  by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   583
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   584
lemma pred_restrict_space:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   585
  assumes "S \<in> sets M"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   586
  shows "Measurable.pred (restrict_space M S) P \<longleftrightarrow> Measurable.pred M (\<lambda>x. x \<in> S \<and> P x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   587
  unfolding pred_def sets_Collect_restrict_space_iff[OF assms] ..
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   588
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   589
lemma measurable_predpow[measurable]:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   590
  assumes "Measurable.pred M T"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   591
  assumes "\<And>Q. Measurable.pred M Q \<Longrightarrow> Measurable.pred M (R Q)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   592
  shows "Measurable.pred M ((R ^^ n) T)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   593
  by (induct n) (auto intro: assms)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58965
diff changeset
   594
50387
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   595
hide_const (open) pred
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   596
3d8863c41fe8 Move the measurability prover to its own file
hoelzl
parents:
diff changeset
   597
end
59048
7dc8ac6f0895 add congruence solver to measurability prover
hoelzl
parents: 59047
diff changeset
   598