src/HOL/Multivariate_Analysis/Gauge_Measure.thy
author boehmes
Tue, 26 Oct 2010 11:46:19 +0200
changeset 40163 a462d5207aa6
parent 38794 2d638e963357
permissions -rw-r--r--
changed SMT configuration options; updated SMT certificates
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     1
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     2
header {* Lebsegue measure (defined via the gauge integral). *}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     3
(*  Author:                     John Harrison
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     4
    Translation from HOL light: Robert Himmelmann, TU Muenchen *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     5
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     6
theory Gauge_Measure
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     7
  imports Integration 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     8
begin
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     9
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    10
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    11
(* Lebesgue measure (in the case where the measure is finite).               *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    12
(* For the non-finite version, please see Probability/Lebesgue_Measure.thy   *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    13
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    14
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    15
definition has_gmeasure (infixr "has'_gmeasure" 80) where
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    16
  "s has_gmeasure m \<equiv> ((\<lambda>x. 1::real) has_integral m) s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    17
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    18
definition gmeasurable :: "('n::ordered_euclidean_space) set \<Rightarrow> bool" where 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    19
  "gmeasurable s \<equiv> (\<exists>m. s has_gmeasure m)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    20
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    21
lemma gmeasurableI[dest]:"s has_gmeasure m \<Longrightarrow> gmeasurable s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    22
  unfolding gmeasurable_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    23
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    24
definition gmeasure where
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    25
  "gmeasure s \<equiv> (if gmeasurable s then (SOME m. s has_gmeasure m) else 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    26
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    27
lemma has_gmeasure_measure: "gmeasurable s \<longleftrightarrow> s has_gmeasure (gmeasure s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    28
  unfolding gmeasure_def gmeasurable_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    29
  apply meson apply(subst if_P) defer apply(rule someI) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    30
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    31
lemma has_gmeasure_measureI[intro]:"gmeasurable s \<Longrightarrow> s has_gmeasure (gmeasure s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    32
  using has_gmeasure_measure by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    33
  
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    34
lemma has_gmeasure_unique: "s has_gmeasure m1 \<Longrightarrow> s has_gmeasure m2 \<Longrightarrow> m1 = m2"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    35
  unfolding has_gmeasure_def apply(rule has_integral_unique) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    36
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    37
lemma measure_unique[intro]: assumes "s has_gmeasure m" shows "gmeasure s = m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    38
  apply(rule has_gmeasure_unique[OF _ assms]) using assms 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    39
  unfolding has_gmeasure_measure[THEN sym] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    40
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    41
lemma has_gmeasure_measurable_measure:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    42
 "s has_gmeasure m \<longleftrightarrow> gmeasurable s \<and> gmeasure s = m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    43
  by(auto intro!:measure_unique simp:has_gmeasure_measure[THEN sym])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    44
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    45
lemmas has_gmeasure_imp_measurable = gmeasurableI
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    46
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    47
lemma has_gmeasure:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    48
 "s has_gmeasure m \<longleftrightarrow> ((\<lambda>x. if x \<in> s then 1 else 0) has_integral m) UNIV"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    49
  unfolding has_integral_restrict_univ has_gmeasure_def ..
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    50
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    51
lemma gmeasurable: "gmeasurable s \<longleftrightarrow> (\<lambda>x. 1::real) integrable_on s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    52
  unfolding gmeasurable_def integrable_on_def has_gmeasure_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    53
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    54
lemma gmeasurable_integrable:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    55
 "gmeasurable s \<longleftrightarrow> (\<lambda>x. if x \<in> s then 1 else (0::real)) integrable_on UNIV"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    56
  unfolding gmeasurable_def integrable_on_def has_gmeasure ..
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    57
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    58
lemma measure_integral:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    59
  assumes "gmeasurable s" shows "gmeasure s = (integral s (\<lambda>x. 1))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    60
  apply(rule integral_unique[THEN sym])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    61
  unfolding has_gmeasure_def[symmetric] using assms by auto 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    62
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    63
lemma measure_integral_univ: assumes "gmeasurable s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    64
  shows "gmeasure s = (integral UNIV (\<lambda>x. if x \<in> s then 1 else 0))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    65
  apply(rule integral_unique[THEN sym])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    66
  using assms by(auto simp:has_gmeasure[THEN sym])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    67
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    68
lemmas integral_measure = measure_integral[THEN sym]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    69
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    70
lemmas integral_measure_univ = measure_integral_univ[THEN sym]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    71
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    72
lemma has_gmeasure_interval[intro]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    73
  "{a..b} has_gmeasure content{a..b}" (is ?t1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    74
  "{a<..<b} has_gmeasure content{a..b}" (is ?t2)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    75
proof- show ?t1 unfolding has_gmeasure_def using has_integral_const[where c="1::real"] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    76
  show ?t2 unfolding has_gmeasure apply(rule has_integral_spike[of "{a..b} - {a<..<b}",
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    77
    where f="\<lambda>x. (if x \<in> {a..b} then 1 else 0)"]) apply(rule negligible_frontier_interval) 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    78
    using interval_open_subset_closed[of a b]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    79
    using `?t1` unfolding has_gmeasure by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    80
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    81
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    82
lemma gmeasurable_interval[intro]: "gmeasurable {a..b}" "gmeasurable {a<..<b}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    83
  by(auto intro:gmeasurableI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    84
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    85
lemma measure_interval[simp]: "gmeasure{a..b} = content{a..b}"  "gmeasure({a<..<b}) = content{a..b}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    86
  by(auto intro:measure_unique)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    87
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    88
lemma nonnegative_absolutely_integrable: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    89
  assumes "\<forall>x\<in>s. \<forall>i<DIM('m). 0 \<le> f(x)$$i" "f integrable_on s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    90
  shows "f absolutely_integrable_on s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    91
  unfolding absolutely_integrable_abs_eq apply rule defer
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    92
  apply(rule integrable_eq[of _ f]) using assms apply-apply(subst euclidean_eq) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    93
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    94
lemma gmeasurable_inter[dest]: assumes "gmeasurable s" "gmeasurable t" shows "gmeasurable (s \<inter> t)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    95
proof- have *:"(\<lambda>x. if x \<in> s \<inter> t then 1 else (0::real)) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    96
    (\<lambda>x. \<chi>\<chi> i. min (((if x \<in> s then 1 else 0)::real)$$i) (((if x \<in> t then 1 else 0)::real)$$i))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    97
    apply(rule ext) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    98
  show ?thesis unfolding gmeasurable_integrable apply(rule absolutely_integrable_onD)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    99
    unfolding * apply(rule absolutely_integrable_min)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   100
    apply(rule_tac[!] nonnegative_absolutely_integrable)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   101
    using assms unfolding gmeasurable_integrable by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   102
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   103
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   104
lemma gmeasurable_union: assumes "gmeasurable s" "gmeasurable t"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   105
  shows "gmeasurable (s \<union> t)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   106
proof- have *:"(\<lambda>x. if x \<in> s \<union> t then 1 else (0::real)) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   107
    (\<lambda>x. \<chi>\<chi> i. max (((if x \<in> s then 1 else 0)::real)$$i) (((if x \<in> t then 1 else 0)::real)$$i)) "
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   108
    by(rule ext,auto)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   109
  show ?thesis unfolding gmeasurable_integrable apply(rule absolutely_integrable_onD)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   110
    unfolding * apply(rule absolutely_integrable_max)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   111
    apply(rule_tac[!]nonnegative_absolutely_integrable)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   112
    using assms unfolding gmeasurable_integrable by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   113
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   114
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   115
lemma has_gmeasure_disjoint_union: 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   116
  assumes "s1 has_gmeasure m1" "s2 has_gmeasure m2" "s1 \<inter> s2 = {}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   117
  shows "(s1 \<union> s2) has_gmeasure (m1 + m2)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   118
proof- have *:"\<And>x. (if x \<in> s1 then 1 else 0) + (if x \<in> s2 then 1 else 0) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   119
    (if x \<in> s1 \<union> s2 then 1 else (0::real))" using assms(3) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   120
  show ?thesis using has_integral_add[OF assms(1-2)[unfolded has_gmeasure]]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   121
    unfolding has_gmeasure * .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   122
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   123
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   124
lemma measure_disjoint_union: assumes "gmeasurable s" "gmeasurable t" "s \<inter> t = {}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   125
  shows "gmeasure(s \<union> t) = gmeasure s + gmeasure t"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   126
  apply rule apply(rule has_gmeasure_disjoint_union) using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   127
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   128
lemma has_gmeasure_pos_le[dest]: assumes "s has_gmeasure m" shows "0 \<le> m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   129
  apply(rule has_integral_nonneg) using assms unfolding has_gmeasure by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   130
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   131
lemma not_measurable_measure:"\<not> gmeasurable s \<Longrightarrow> gmeasure s = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   132
  unfolding gmeasure_def if_not_P ..
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   133
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   134
lemma measure_pos_le[intro]: "0 <= gmeasure s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   135
  apply(cases "gmeasurable s") unfolding not_measurable_measure
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   136
  unfolding has_gmeasure_measure by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   137
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   138
lemma has_gmeasure_subset[dest]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   139
  assumes "s1 has_gmeasure m1" "s2 has_gmeasure m2" "s1 \<subseteq> s2"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   140
  shows "m1 <= m2"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   141
  using has_integral_subset_le[OF assms(3,1,2)[unfolded has_gmeasure_def]] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   142
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   143
lemma measure_subset[dest]: assumes "gmeasurable s" "gmeasurable t" "s \<subseteq> t"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   144
  shows "gmeasure s \<le> gmeasure t"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   145
  using assms unfolding has_gmeasure_measure by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   146
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   147
lemma has_gmeasure_0:"s has_gmeasure 0 \<longleftrightarrow> negligible s" (is "?l = ?r")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   148
proof assume ?r thus ?l unfolding indicator_def_raw negligible apply(erule_tac x="UNIV" in allE)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   149
    unfolding has_integral_restrict_univ has_gmeasure_def .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   150
next assume ?l note this[unfolded has_gmeasure_def has_integral_alt']
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   151
  note * = conjunctD2[OF this,rule_format]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   152
  show ?r unfolding negligible_def 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   153
  proof safe case goal1
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   154
    from *(1)[of a b,unfolded integrable_on_def] guess y apply-
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   155
      apply(subst (asm) has_integral_restrict_univ[THEN sym]) by (erule exE) note y=this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   156
    have "0 \<le> y" apply(rule has_integral_nonneg[OF y]) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   157
    moreover have "y \<le> 0" apply(rule has_integral_le[OF y]) 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   158
      apply(rule `?l`[unfolded has_gmeasure_def has_integral_restrict_univ[THEN sym,of"\<lambda>x. 1"]]) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   159
    ultimately have "y = 0" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   160
    thus ?case using y unfolding has_integral_restrict_univ indicator_def_raw by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   161
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   162
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   163
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   164
lemma measure_eq_0: "negligible s ==> gmeasure s = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   165
  apply(rule measure_unique) unfolding has_gmeasure_0 by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   166
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   167
lemma has_gmeasure_empty[intro]: "{} has_gmeasure 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   168
  unfolding has_gmeasure_0 by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   169
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   170
lemma measure_empty[simp]: "gmeasure {} = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   171
  apply(rule measure_eq_0) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   172
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   173
lemma gmeasurable_empty[intro]: "gmeasurable {}" by(auto intro:gmeasurableI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   174
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   175
lemma gmeasurable_measure_eq_0:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   176
  "gmeasurable s ==> (gmeasure s = 0 \<longleftrightarrow> negligible s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   177
  unfolding has_gmeasure_measure has_gmeasure_0[THEN sym] by(auto intro:measure_unique)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   178
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   179
lemma gmeasurable_measure_pos_lt:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   180
 "gmeasurable s ==> (0 < gmeasure s \<longleftrightarrow> ~negligible s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   181
  unfolding gmeasurable_measure_eq_0[THEN sym]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   182
  using measure_pos_le[of s] unfolding le_less by fastsimp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   183
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   184
lemma negligible_interval:True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   185
 "(!a b. negligible{a..b} \<longleftrightarrow> {a<..<b} = {}) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   186
   (!a b. negligible({a<..<b}) \<longleftrightarrow> {a<..<b} = {})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   187
qed   REWRITE_TAC[GSYM HAS_GMEASURE_0] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   188
  MESON_TAC[HAS_GMEASURE_INTERVAL; CONTENT_EQ_0_INTERIOR;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   189
            INTERIOR_CLOSED_INTERVAL; HAS_GMEASURE_UNIQUE]);;*)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   190
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   191
lemma gmeasurable_finite_unions:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   192
  assumes "finite f" "\<And>s. s \<in> f \<Longrightarrow> gmeasurable s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   193
  shows "gmeasurable (\<Union> f)" using assms(1,2) 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   194
proof induct case (insert s F)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   195
  show ?case unfolding Union_insert apply(rule gmeasurable_union)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   196
    using insert by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   197
qed auto  
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   198
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   199
lemma has_gmeasure_diff_subset: assumes "s1 has_gmeasure m1" "s2 has_gmeasure m2" "s2 \<subseteq> s1"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   200
  shows "(s1 - s2) has_gmeasure (m1 - m2)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   201
proof- have *:"(\<lambda>x. (if x \<in> s1 then 1 else 0) - (if x \<in> s2 then 1 else (0::real))) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   202
    (\<lambda>x. if x \<in> s1 - s2 then 1 else 0)" apply(rule ext) using assms(3) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   203
  show ?thesis using has_integral_sub[OF assms(1-2)[unfolded has_gmeasure]] 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   204
    unfolding has_gmeasure * . 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   205
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   206
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   207
lemma gmeasurable_diff: assumes "gmeasurable s" "gmeasurable t" 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   208
  shows "gmeasurable (s - t)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   209
proof- have *:"\<And>s t. gmeasurable s \<Longrightarrow> gmeasurable t \<Longrightarrow> t \<subseteq> s ==> gmeasurable (s - t)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   210
    unfolding gmeasurable_def apply(erule exE)+ apply(rule,rule has_gmeasure_diff_subset)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   211
    by assumption+
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   212
  have **:"s - t = s - (s \<inter> t)" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   213
  show ?thesis unfolding ** apply(rule *) using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   214
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   215
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   216
lemma measure_diff_subset: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   217
 "!s t. gmeasurable s \<and> gmeasurable t \<and> t \<subseteq> s
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   218
         ==> measure(s DIFF t) = gmeasure s - gmeasure t"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   219
qed   REPEAT STRIP_TAC THEN MATCH_MP_TAC MEASURE_UNIQUE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   220
  ASM_SIMP_TAC[HAS_GMEASURE_DIFF_SUBSET; GSYM HAS_GMEASURE_MEASURE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   221
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   222
lemma has_gmeasure_union_negligible[dest]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   223
  assumes "s has_gmeasure m" "negligible t"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   224
  shows "(s \<union> t) has_gmeasure m" unfolding has_gmeasure
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   225
  apply(rule has_integral_spike[OF assms(2) _ assms(1)[unfolded has_gmeasure]]) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   226
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   227
lemma has_gmeasure_diff_negligible[dest]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   228
  assumes "s has_gmeasure m" "negligible t" 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   229
  shows "(s - t) has_gmeasure m" unfolding has_gmeasure
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   230
  apply(rule has_integral_spike[OF assms(2) _ assms(1)[unfolded has_gmeasure]]) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   231
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   232
lemma has_gmeasure_union_negligible_eq: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   233
 "!s t:real^N->bool m.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   234
     negligible t ==> ((s \<union> t) has_gmeasure m \<longleftrightarrow> s has_gmeasure m)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   235
qed   REPEAT STRIP_TAC THEN EQ_TAC THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   236
  ASM_SIMP_TAC[HAS_GMEASURE_UNION_NEGLIGIBLE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   237
  SUBST1_TAC(SET_RULE `s:real^N->bool = (s \<union> t) DIFF (t DIFF s)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   238
  MATCH_MP_TAC HAS_GMEASURE_DIFF_NEGLIGIBLE THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   239
  MATCH_MP_TAC NEGLIGIBLE_DIFF THEN ASM_REWRITE_TAC[]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   240
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   241
lemma has_gmeasure_diff_negligible_eq: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   242
 "!s t:real^N->bool m.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   243
     negligible t ==> ((s DIFF t) has_gmeasure m \<longleftrightarrow> s has_gmeasure m)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   244
qed   REPEAT STRIP_TAC THEN EQ_TAC THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   245
  ASM_SIMP_TAC[HAS_GMEASURE_DIFF_NEGLIGIBLE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   246
  SUBST1_TAC(SET_RULE `s:real^N->bool = (s DIFF t) \<union> (t \<inter> s)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   247
  MATCH_MP_TAC HAS_GMEASURE_UNION_NEGLIGIBLE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   248
  ASM_SIMP_TAC[NEGLIGIBLE_INTER]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   249
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   250
lemma has_gmeasure_almost: assumes "s has_gmeasure m" "negligible t" "s \<union> t = s' \<union> t"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   251
  shows "s' has_gmeasure m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   252
proof- have *:"s' \<union> t - (t - s') = s'" by blast
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   253
  show ?thesis using has_gmeasure_union_negligible[OF assms(1-2)] unfolding assms(3)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   254
    apply-apply(drule has_gmeasure_diff_negligible[where t="t - s'"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   255
    apply(rule negligible_diff) using assms(2) unfolding * by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   256
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   257
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   258
lemma has_gmeasure_almost_eq: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   259
 "!s s' t. negligible t \<and> s \<union> t = s' \<union> t
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   260
            ==> (s has_gmeasure m \<longleftrightarrow> s' has_gmeasure m)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   261
qed   MESON_TAC[HAS_GMEASURE_ALMOST]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   262
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   263
lemma gmeasurable_almost: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   264
 "!s s' t. gmeasurable s \<and> negligible t \<and> s \<union> t = s' \<union> t
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   265
            ==> gmeasurable s'"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   266
qed   REWRITE_TAC[measurable] THEN MESON_TAC[HAS_GMEASURE_ALMOST]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   267
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   268
lemma has_gmeasure_negligible_union:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   269
  assumes "s1 has_gmeasure m1" "s2 has_gmeasure m2" "negligible(s1 \<inter> s2)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   270
  shows "(s1 \<union> s2) has_gmeasure (m1 + m2)" 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   271
  apply(rule has_gmeasure_almost[of "(s1 - (s1 \<inter> s2)) \<union> (s2 - (s1 \<inter> s2))" _ "s1 \<inter> s2"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   272
  apply(rule has_gmeasure_disjoint_union)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   273
  apply(rule has_gmeasure_almost[of s1,OF _ assms(3)]) prefer 3
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   274
  apply(rule has_gmeasure_almost[of s2,OF _ assms(3)])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   275
  using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   276
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   277
lemma measure_negligible_union: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   278
  "!s t. gmeasurable s \<and> gmeasurable t \<and> negligible(s \<inter> t)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   279
         ==> measure(s \<union> t) = gmeasure s + gmeasure t"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   280
qed   REPEAT STRIP_TAC THEN MATCH_MP_TAC MEASURE_UNIQUE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   281
  ASM_SIMP_TAC[HAS_GMEASURE_NEGLIGIBLE_UNION; GSYM HAS_GMEASURE_MEASURE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   282
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   283
lemma has_gmeasure_negligible_symdiff: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   284
 "!s t:real^N->bool m.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   285
        s has_gmeasure m \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   286
        negligible((s DIFF t) \<union> (t DIFF s))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   287
        ==> t has_gmeasure m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   288
qed   REPEAT STRIP_TAC THEN MATCH_MP_TAC HAS_GMEASURE_ALMOST THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   289
  MAP_EVERY EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   290
   [`s:real^N->bool`; `(s DIFF t) \<union> (t DIFF s):real^N->bool`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   291
  ASM_REWRITE_TAC[] THEN SET_TAC[]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   292
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   293
lemma gmeasurable_negligible_symdiff: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   294
 "!s t:real^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   295
        gmeasurable s \<and> negligible((s DIFF t) \<union> (t DIFF s))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   296
        ==> gmeasurable t"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   297
qed   REWRITE_TAC[measurable] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   298
  MESON_TAC[HAS_GMEASURE_NEGLIGIBLE_SYMDIFF]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   299
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   300
lemma measure_negligible_symdiff: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   301
 "!s t:real^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   302
        (measurable s \/ gmeasurable t) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   303
        negligible((s DIFF t) \<union> (t DIFF s))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   304
        ==> gmeasure s = gmeasure t"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   305
qed   MESON_TAC[HAS_GMEASURE_NEGLIGIBLE_SYMDIFF; MEASURE_UNIQUE; UNION_COMM;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   306
                HAS_GMEASURE_MEASURE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   307
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   308
lemma has_gmeasure_negligible_unions: assumes "finite f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   309
  "\<And>s. s \<in> f ==> s has_gmeasure (m s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   310
  "\<And>s t. s \<in> f \<Longrightarrow> t \<in> f \<Longrightarrow> ~(s = t) ==> negligible(s \<inter> t)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   311
  shows "(\<Union> f) has_gmeasure (setsum m f)" using assms
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   312
proof induct case (insert x s)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   313
  have *:"(x \<inter> \<Union>s) = \<Union>{x \<inter> y| y. y\<in>s}"by auto
38794
2d638e963357 tuned fact reference
haftmann
parents: 38656
diff changeset
   314
  show ?case unfolding Union_insert setsum.insert [OF insert(1-2)] 
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   315
    apply(rule has_gmeasure_negligible_union) unfolding *
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   316
    apply(rule insert) defer apply(rule insert) apply(rule insert) defer
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   317
    apply(rule insert) prefer 4 apply(rule negligible_unions)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   318
    defer apply safe apply(rule insert) using insert by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   319
qed auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   320
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   321
lemma measure_negligible_unions: 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   322
  assumes "finite f" "\<And>s. s \<in> f ==> s has_gmeasure (m s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   323
  "\<And>s t. s \<in> f \<Longrightarrow> t \<in> f \<Longrightarrow> s \<noteq> t ==> negligible(s \<inter> t)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   324
  shows "gmeasure(\<Union> f) = setsum m f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   325
  apply rule apply(rule has_gmeasure_negligible_unions)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   326
  using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   327
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   328
lemma has_gmeasure_disjoint_unions:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   329
  assumes"finite f" "\<And>s. s \<in> f ==> s has_gmeasure (m s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   330
  "\<And>s t. s \<in> f \<Longrightarrow> t \<in> f \<Longrightarrow> s \<noteq> t ==> s \<inter> t = {}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   331
  shows "(\<Union> f) has_gmeasure (setsum m f)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   332
  apply(rule has_gmeasure_negligible_unions[OF assms(1-2)]) using assms(3) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   333
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   334
lemma measure_disjoint_unions: 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   335
  assumes "finite f" "\<And>s. s \<in> f ==> s has_gmeasure (m s)" 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   336
  "\<And>s t. s \<in> f \<Longrightarrow> t \<in> f \<Longrightarrow> s \<noteq> t ==> s \<inter> t = {}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   337
  shows "gmeasure(\<Union> f) = setsum m f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   338
  apply rule apply(rule has_gmeasure_disjoint_unions[OF assms]) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   339
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   340
lemma has_gmeasure_negligible_unions_image:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   341
  assumes "finite s" "\<And>x. x \<in> s ==> gmeasurable(f x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   342
  "\<And>x y. x \<in> s \<Longrightarrow> y \<in> s \<Longrightarrow> x \<noteq> y \<Longrightarrow> negligible((f x) \<inter> (f y))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   343
  shows "(\<Union> (f ` s)) has_gmeasure (setsum (\<lambda>x. gmeasure(f x)) s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   344
proof- have *:"setsum (\<lambda>x. gmeasure(f x)) s = setsum gmeasure (f ` s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   345
    apply(subst setsum_reindex_nonzero) defer
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   346
    apply(subst gmeasurable_measure_eq_0)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   347
  proof- case goal2 thus ?case using assms(3)[of x y] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   348
  qed(insert assms, auto)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   349
  show ?thesis unfolding * apply(rule has_gmeasure_negligible_unions) using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   350
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   351
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   352
lemma measure_negligible_unions_image: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   353
 "!f:A->real^N->bool s.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   354
        FINITE s \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   355
        (!x. x \<in> s ==> gmeasurable(f x)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   356
        (!x y. x \<in> s \<and> y \<in> s \<and> ~(x = y) ==> negligible((f x) \<inter> (f y)))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   357
        ==> measure(UNIONS (IMAGE f s)) = sum s (\<lambda>x. measure(f x))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   358
qed   REPEAT STRIP_TAC THEN MATCH_MP_TAC MEASURE_UNIQUE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   359
  ASM_SIMP_TAC[HAS_GMEASURE_NEGLIGIBLE_UNIONS_IMAGE]);;*)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   360
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   361
lemma has_gmeasure_disjoint_unions_image: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   362
 "!f:A->real^N->bool s.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   363
        FINITE s \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   364
        (!x. x \<in> s ==> gmeasurable(f x)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   365
        (!x y. x \<in> s \<and> y \<in> s \<and> ~(x = y) ==> DISJOINT (f x) (f y))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   366
        ==> (UNIONS (IMAGE f s)) has_gmeasure (sum s (\<lambda>x. measure(f x)))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   367
qed   REWRITE_TAC[DISJOINT] THEN REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   368
  MATCH_MP_TAC HAS_GMEASURE_NEGLIGIBLE_UNIONS_IMAGE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   369
  ASM_SIMP_TAC[NEGLIGIBLE_EMPTY]);;*)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   370
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   371
lemma measure_disjoint_unions_image: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   372
 "!f:A->real^N->bool s.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   373
        FINITE s \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   374
        (!x. x \<in> s ==> gmeasurable(f x)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   375
        (!x y. x \<in> s \<and> y \<in> s \<and> ~(x = y) ==> DISJOINT (f x) (f y))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   376
        ==> measure(UNIONS (IMAGE f s)) = sum s (\<lambda>x. measure(f x))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   377
qed   REPEAT STRIP_TAC THEN MATCH_MP_TAC MEASURE_UNIQUE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   378
  ASM_SIMP_TAC[HAS_GMEASURE_DISJOINT_UNIONS_IMAGE]);;*)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   379
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   380
lemma has_gmeasure_negligible_unions_image_strong: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   381
 "!f:A->real^N->bool s.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   382
        FINITE {x | x \<in> s \<and> ~(f x = {})} \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   383
        (!x. x \<in> s ==> gmeasurable(f x)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   384
        (!x y. x \<in> s \<and> y \<in> s \<and> ~(x = y) ==> negligible((f x) \<inter> (f y)))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   385
        ==> (UNIONS (IMAGE f s)) has_gmeasure (sum s (\<lambda>x. measure(f x)))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   386
qed   REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   387
  MP_TAC(ISPECL [`f:A->real^N->bool`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   388
                 `{x | x \<in> s \<and> ~((f:A->real^N->bool) x = {})}`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   389
        HAS_GMEASURE_NEGLIGIBLE_UNIONS_IMAGE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   390
  ASM_SIMP_TAC[IN_ELIM_THM; FINITE_RESTRICT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   391
  MATCH_MP_TAC EQ_IMP THEN BINOP_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   392
   [GEN_REWRITE_TAC I [EXTENSION] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   393
    REWRITE_TAC[IN_UNIONS; IN_IMAGE; IN_ELIM_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   394
    MESON_TAC[NOT_IN_EMPTY];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   395
    CONV_TAC SYM_CONV THEN MATCH_MP_TAC SUM_SUPERSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   396
    SIMP_TAC[SUBSET; IN_ELIM_THM; TAUT `a \<and> ~(a \<and> b) \<longleftrightarrow> a \<and> ~b`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   397
    REWRITE_TAC[MEASURE_EMPTY]]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   398
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   399
lemma measure_negligible_unions_image_strong: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   400
 "!f:A->real^N->bool s.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   401
        FINITE {x | x \<in> s \<and> ~(f x = {})} \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   402
        (!x. x \<in> s ==> gmeasurable(f x)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   403
        (!x y. x \<in> s \<and> y \<in> s \<and> ~(x = y) ==> negligible((f x) \<inter> (f y)))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   404
        ==> measure(UNIONS (IMAGE f s)) = sum s (\<lambda>x. measure(f x))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   405
qed   REPEAT STRIP_TAC THEN MATCH_MP_TAC MEASURE_UNIQUE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   406
  ASM_SIMP_TAC[HAS_GMEASURE_NEGLIGIBLE_UNIONS_IMAGE_STRONG]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   407
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   408
lemma has_gmeasure_disjoint_unions_image_strong: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   409
 "!f:A->real^N->bool s.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   410
        FINITE {x | x \<in> s \<and> ~(f x = {})} \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   411
        (!x. x \<in> s ==> gmeasurable(f x)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   412
        (!x y. x \<in> s \<and> y \<in> s \<and> ~(x = y) ==> DISJOINT (f x) (f y))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   413
        ==> (UNIONS (IMAGE f s)) has_gmeasure (sum s (\<lambda>x. measure(f x)))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   414
qed   REWRITE_TAC[DISJOINT] THEN REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   415
  MATCH_MP_TAC HAS_GMEASURE_NEGLIGIBLE_UNIONS_IMAGE_STRONG THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   416
  ASM_SIMP_TAC[NEGLIGIBLE_EMPTY]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   417
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   418
lemma measure_disjoint_unions_image_strong: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   419
 "!f:A->real^N->bool s.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   420
        FINITE {x | x \<in> s \<and> ~(f x = {})} \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   421
        (!x. x \<in> s ==> gmeasurable(f x)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   422
        (!x y. x \<in> s \<and> y \<in> s \<and> ~(x = y) ==> DISJOINT (f x) (f y))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   423
        ==> measure(UNIONS (IMAGE f s)) = sum s (\<lambda>x. measure(f x))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   424
qed   REPEAT STRIP_TAC THEN MATCH_MP_TAC MEASURE_UNIQUE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   425
  ASM_SIMP_TAC[HAS_GMEASURE_DISJOINT_UNIONS_IMAGE_STRONG]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   426
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   427
lemma measure_union: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   428
 "!s t:real^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   429
        gmeasurable s \<and> gmeasurable t
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   430
        ==> measure(s \<union> t) = measure(s) + measure(t) - measure(s \<inter> t)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   431
qed   REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   432
  ONCE_REWRITE_TAC[SET_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   433
   `s \<union> t = (s \<inter> t) \<union> (s DIFF t) \<union> (t DIFF s)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   434
  ONCE_REWRITE_TAC[REAL_ARITH `a + b - c = c + (a - c) + (b - c)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   435
  MP_TAC(ISPECL [`s DIFF t:real^N->bool`; `t DIFF s:real^N->bool`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   436
        MEASURE_DISJOINT_UNION) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   437
  ASM_SIMP_TAC[MEASURABLE_DIFF] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   438
  ANTS_TAC THENL [SET_TAC[]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   439
  MP_TAC(ISPECL [`s \<inter> t:real^N->bool`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   440
                 `(s DIFF t) \<union> (t DIFF s):real^N->bool`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   441
                MEASURE_DISJOINT_UNION) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   442
  ASM_SIMP_TAC[MEASURABLE_DIFF; GMEASURABLE_UNION; GMEASURABLE_INTER] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   443
  ANTS_TAC THENL [SET_TAC[]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   444
  REPEAT(DISCH_THEN SUBST1_TAC) THEN AP_TERM_TAC THEN BINOP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   445
  REWRITE_TAC[REAL_EQ_SUB_LADD] THEN MATCH_MP_TAC EQ_TRANS THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   446
   [EXISTS_TAC `measure((s DIFF t) \<union> (s \<inter> t):real^N->bool)`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   447
    EXISTS_TAC `measure((t DIFF s) \<union> (s \<inter> t):real^N->bool)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   448
  (CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   449
    [CONV_TAC SYM_CONV THEN MATCH_MP_TAC MEASURE_DISJOINT_UNION THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   450
     ASM_SIMP_TAC[MEASURABLE_DIFF; GMEASURABLE_INTER];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   451
     AP_TERM_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   452
   SET_TAC[]));; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   453
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   454
lemma measure_union_le: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   455
 "!s t:real^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   456
        gmeasurable s \<and> gmeasurable t
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   457
        ==> measure(s \<union> t) <= gmeasure s + gmeasure t"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   458
qed   REPEAT STRIP_TAC THEN ASM_SIMP_TAC[MEASURE_UNION] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   459
  REWRITE_TAC[REAL_ARITH `a + b - c <= a + b \<longleftrightarrow> 0 <= c`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   460
  MATCH_MP_TAC MEASURE_POS_LE THEN ASM_SIMP_TAC[MEASURABLE_INTER]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   461
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   462
lemma measure_unions_le: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   463
 "!f:(real^N->bool)->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   464
        FINITE f \<and> (!s. s \<in> f ==> gmeasurable s)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   465
        ==> measure(UNIONS f) <= sum f (\<lambda>s. gmeasure s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   466
qed   REWRITE_TAC[IMP_CONJ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   467
  MATCH_MP_TAC FINITE_INDUCT_STRONG THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   468
  SIMP_TAC[UNIONS_0; UNIONS_INSERT; SUM_CLAUSES] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   469
  REWRITE_TAC[MEASURE_EMPTY; REAL_LE_REFL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   470
  MAP_EVERY X_GEN_TAC [`s:real^N->bool`; `f:(real^N->bool)->bool`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   471
  REWRITE_TAC[IN_INSERT] THEN REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   472
  MATCH_MP_TAC REAL_LE_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   473
  EXISTS_TAC `measure(s:real^N->bool) + measure(UNIONS f:real^N->bool)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   474
  ASM_SIMP_TAC[MEASURE_UNION_LE; GMEASURABLE_UNIONS] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   475
  REWRITE_TAC[REAL_LE_LADD] THEN FIRST_X_ASSUM MATCH_MP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   476
  ASM_SIMP_TAC[]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   477
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   478
lemma measure_unions_le_image: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   479
 "!f:A->bool s:A->(real^N->bool).
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   480
        FINITE f \<and> (!a. a \<in> f ==> gmeasurable(s a))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   481
        ==> measure(UNIONS (IMAGE s f)) <= sum f (\<lambda>a. measure(s a))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   482
qed   REPEAT STRIP_TAC THEN MATCH_MP_TAC REAL_LE_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   483
  EXISTS_TAC `sum (IMAGE s (f:A->bool)) (\<lambda>k:real^N->bool. gmeasure k)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   484
  ASM_SIMP_TAC[MEASURE_UNIONS_LE; FORALL_IN_IMAGE; FINITE_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   485
  GEN_REWRITE_TAC (RAND_CONV o RAND_CONV) [GSYM o_DEF] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   486
  REWRITE_TAC[ETA_AX] THEN MATCH_MP_TAC SUM_IMAGE_LE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   487
  ASM_SIMP_TAC[MEASURE_POS_LE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   488
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   489
lemma gmeasurable_inner_outer: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   490
 "!s:real^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   491
        gmeasurable s \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   492
                !e. 0 < e
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   493
                    ==> ?t u. t \<subseteq> s \<and> s \<subseteq> u \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   494
                              gmeasurable t \<and> gmeasurable u \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   495
                              abs(measure t - gmeasure u) < e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   496
qed   GEN_TAC THEN EQ_TAC THEN DISCH_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   497
   [GEN_TAC THEN DISCH_TAC THEN REPEAT(EXISTS_TAC `s:real^N->bool`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   498
    ASM_REWRITE_TAC[SUBSET_REFL; REAL_SUB_REFL; REAL_ABS_NUM];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   499
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   500
  REWRITE_TAC[MEASURABLE_INTEGRABLE] THEN MATCH_MP_TAC INTEGRABLE_STRADDLE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   501
  X_GEN_TAC `e:real` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   502
  FIRST_X_ASSUM(MP_TAC o SPEC `e:real`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   503
  ASM_REWRITE_TAC[LEFT_IMP_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   504
  MAP_EVERY X_GEN_TAC [`t:real^N->bool`; `u:real^N->bool`] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   505
  MAP_EVERY EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   506
   [`(\<lambda>x. if x \<in> t then 1 else 0):real^N->real^1`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   507
    `(\<lambda>x. if x \<in> u then 1 else 0):real^N->real^1`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   508
    `lift(measure(t:real^N->bool))`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   509
    `lift(measure(u:real^N->bool))`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   510
  ASM_REWRITE_TAC[GSYM HAS_GMEASURE; GSYM HAS_GMEASURE_MEASURE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   511
  ASM_REWRITE_TAC[GSYM LIFT_SUB; NORM_LIFT] THEN REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   512
  REPEAT(COND_CASES_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   513
         ASM_REWRITE_TAC[_VEC; REAL_POS; REAL_LE_REFL]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   514
  ASM SET_TAC[]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   515
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   516
lemma has_gmeasure_inner_outer: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   517
 "!s:real^N->bool m.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   518
        s has_gmeasure m \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   519
                (!e. 0 < e ==> ?t. t \<subseteq> s \<and> gmeasurable t \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   520
                                    m - e < gmeasure t) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   521
                (!e. 0 < e ==> ?u. s \<subseteq> u \<and> gmeasurable u \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   522
                                    gmeasure u < m + e)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   523
qed   REPEAT GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   524
  GEN_REWRITE_TAC LAND_CONV [HAS_GMEASURE_MEASURABLE_MEASURE] THEN EQ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   525
   [REPEAT STRIP_TAC THEN EXISTS_TAC `s:real^N->bool` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   526
    ASM_REWRITE_TAC[SUBSET_REFL] THEN ASM_REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   527
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   528
  DISCH_THEN(CONJUNCTS_THEN2 (LABEL_TAC "t") (LABEL_TAC "u")) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   529
  MATCH_MP_TAC(TAUT `a \<and> (a ==> b) ==> a \<and> b`) THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   530
   [GEN_REWRITE_TAC I [MEASURABLE_INNER_OUTER] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   531
    X_GEN_TAC `e:real` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   532
    REMOVE_THEN "u" (MP_TAC o SPEC `e / 2`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   533
    REMOVE_THEN "t" (MP_TAC o SPEC `e / 2`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   534
    ASM_SIMP_TAC[REAL_LT_DIV; REAL_OF_NUM_LT; ARITH] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   535
    REWRITE_TAC[IMP_IMP; LEFT_AND_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   536
    REWRITE_TAC[RIGHT_AND_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   537
    REPEAT(MATCH_MP_TAC MONO_EXISTS THEN GEN_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   538
    STRIP_TAC THEN ASM_REWRITE_TAC[] THEN MATCH_MP_TAC(REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   539
     `0 < e \<and> t <= u \<and> m - e / 2 < t \<and> u < m + e / 2
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   540
                          ==> abs(t - u) < e`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   541
    ASM_REWRITE_TAC[] THEN MATCH_MP_TAC MEASURE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   542
    ASM_REWRITE_TAC[] THEN ASM SET_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   543
    DISCH_TAC THEN MATCH_MP_TAC(REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   544
     `~(0 < x - y) \<and> ~(0 < y - x) ==> x = y`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   545
    CONJ_TAC THEN DISCH_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   546
     [REMOVE_THEN "u" (MP_TAC o SPEC `measure(s:real^N->bool) - m`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   547
      ASM_REWRITE_TAC[REAL_SUB_ADD2; GSYM REAL_NOT_LE];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   548
      REMOVE_THEN "t" (MP_TAC o SPEC `m - measure(s:real^N->bool)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   549
      ASM_REWRITE_TAC[REAL_SUB_SUB2; GSYM REAL_NOT_LE]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   550
    ASM_MESON_TAC[MEASURE_SUBSET]]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   551
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   552
lemma has_gmeasure_inner_outer_le: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   553
 "!s:real^N->bool m.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   554
        s has_gmeasure m \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   555
                (!e. 0 < e ==> ?t. t \<subseteq> s \<and> gmeasurable t \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   556
                                    m - e <= gmeasure t) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   557
                (!e. 0 < e ==> ?u. s \<subseteq> u \<and> gmeasurable u \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   558
                                    gmeasure u <= m + e)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   559
qed   REWRITE_TAC[HAS_GMEASURE_INNER_OUTER] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   560
  MESON_TAC[REAL_ARITH `0 < e \<and> m - e / 2 <= t ==> m - e < t`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   561
            REAL_ARITH `0 < e \<and> u <= m + e / 2 ==> u < m + e`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   562
            REAL_ARITH `0 < e \<longleftrightarrow> 0 < e / 2`; REAL_LT_IMP_LE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   563
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   564
lemma has_gmeasure_limit: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   565
 "!s. s has_gmeasure m \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   566
        !e. 0 < e
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   567
            ==> ?B. 0 < B \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   568
                    !a b. ball(0,B) \<subseteq> {a..b}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   569
                          ==> ?z. (s \<inter> {a..b}) has_gmeasure z \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   570
                                  abs(z - m) < e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   571
qed   GEN_TAC THEN REWRITE_TAC[HAS_GMEASURE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   572
  GEN_REWRITE_TAC LAND_CONV [HAS_INTEGRAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   573
  REWRITE_TAC[IN_UNIV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   574
  GEN_REWRITE_TAC (LAND_CONV o ONCE_DEPTH_CONV)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   575
    [GSYM HAS_INTEGRAL_RESTRICT_UNIV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   576
  REWRITE_TAC[MESON[IN_INTER]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   577
        `(if x \<in> k \<inter> s then a else b) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   578
         (if x \<in> s then if x \<in> k then a else b else b)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   579
  REWRITE_TAC[EXISTS_LIFT; GSYM LIFT_SUB; NORM_LIFT]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   580
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   581
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   582
(* properties of gmeasure under simple affine transformations.                *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   583
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   584
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   585
lemma has_gmeasure_affinity: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   586
 "!s m c y. s has_gmeasure y
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   587
             ==> (IMAGE (\<lambda>x:real^N. m % x + c) s)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   588
                 has_gmeasure abs(m) pow (dimindex(:N)) * y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   589
qed   REPEAT GEN_TAC THEN ASM_CASES_TAC `m = 0` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   590
   [ASM_REWRITE_TAC[REAL_ABS_NUM; VECTOR_ADD_LID; VECTOR_MUL_LZERO] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   591
    ONCE_REWRITE_TAC[MATCH_MP (ARITH_RULE `~(x = 0) ==> x = SUC(x - 1)`)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   592
     (SPEC_ALL DIMINDEX_NONZERO)] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   593
    REWRITE_TAC[real_pow; REAL_MUL_LZERO; HAS_GMEASURE_0] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   594
    MATCH_MP_TAC NEGLIGIBLE_SUBSET THEN EXISTS_TAC `{c:real^N}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   595
    SIMP_TAC[NEGLIGIBLE_FINITE; FINITE_RULES] THEN SET_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   596
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   597
  REWRITE_TAC[HAS_GMEASURE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   598
  ONCE_REWRITE_TAC[HAS_INTEGRAL] THEN REWRITE_TAC[IN_UNIV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   599
  DISCH_TAC THEN X_GEN_TAC `e:real` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   600
  FIRST_X_ASSUM(MP_TAC o SPEC `e:real / abs(m) pow dimindex(:N)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   601
  ASM_SIMP_TAC[REAL_LT_DIV; REAL_POW_LT; GSYM REAL_ABS_NZ; REAL_POW_LT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   602
  DISCH_THEN(X_CHOOSE_THEN `B:real` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   603
  EXISTS_TAC `abs(m) * B + norm(c:real^N)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   604
  ASM_SIMP_TAC[REAL_ARITH `0 < B \<and> 0 <= x ==> 0 < B + x`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   605
               NORM_POS_LE; REAL_LT_MUL; GSYM REAL_ABS_NZ; REAL_POW_LT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   606
  MAP_EVERY X_GEN_TAC [`u:real^N`; `v:real^N`] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   607
  REWRITE_TAC[IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   608
  ASM_SIMP_TAC[VECTOR_EQ_AFFINITY; UNWIND_THM1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   609
  FIRST_X_ASSUM(MP_TAC o SPECL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   610
    [`if 0 <= m then inv m % u + --(inv m % c):real^N
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   611
                 else inv m % v + --(inv m % c)`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   612
     `if 0 <= m then inv m % v + --(inv m % c):real^N
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   613
                 else inv m % u + --(inv m % c)`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   614
  MATCH_MP_TAC(TAUT `a \<and> (a ==> b ==> c) ==> (a ==> b) ==> c`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   615
  CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   616
   [REWRITE_TAC[SUBSET] THEN X_GEN_TAC `x:real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   617
    FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [SUBSET]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   618
    DISCH_THEN(MP_TAC o SPEC `m % x + c:real^N`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   619
    MATCH_MP_TAC MONO_IMP THEN REWRITE_TAC[IN_BALL; IN_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   620
    CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   621
     [REWRITE_TAC[NORM_ARITH `dist(0,x) = norm(x:real^N)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   622
      DISCH_TAC THEN MATCH_MP_TAC(NORM_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   623
       `norm(x:real^N) < a ==> norm(x + y) < a + norm(y)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   624
      ASM_SIMP_TAC[NORM_MUL; REAL_LT_LMUL; GSYM REAL_ABS_NZ];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   625
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   626
    SIMP_TAC[VECTOR_ADD_COMPONENT; VECTOR_MUL_COMPONENT; VECTOR_NEG_COMPONENT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   627
             COND_COMPONENT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   628
    MATCH_MP_TAC MONO_FORALL THEN GEN_TAC THEN MATCH_MP_TAC MONO_IMP THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   629
    REWRITE_TAC[REAL_ARITH `m * u + --(m * c):real = (u - c) * m`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   630
    SUBST1_TAC(REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   631
      `inv(m) = if 0 <= inv(m) then abs(inv m) else --(abs(inv m))`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   632
    SIMP_TAC[REAL_LE_INV_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   633
    REWRITE_TAC[REAL_ARITH `(x - y:real) * --z = (y - x) * z`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   634
    REWRITE_TAC[REAL_ABS_INV; GSYM real_div] THEN COND_CASES_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   635
    ASM_SIMP_TAC[REAL_LE_LDIV_EQ; REAL_LE_RDIV_EQ; GSYM REAL_ABS_NZ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   636
    ASM_REWRITE_TAC[real_abs] THEN REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   637
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   638
  REWRITE_TAC[SUBSET] THEN DISCH_THEN(MP_TAC o SPEC `0:real^N`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   639
  ASM_REWRITE_TAC[CENTRE_IN_BALL] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   640
  DISCH_THEN(X_CHOOSE_THEN `z:real^1`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   641
   (fun th -> EXISTS_TAC `(abs m pow dimindex (:N)) % z:real^1` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   642
              MP_TAC th)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   643
  DISCH_THEN(CONJUNCTS_THEN2 MP_TAC ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   644
  FIRST_ASSUM(MP_TAC o MATCH_MP(REAL_FIELD `~(x = 0) ==> ~(inv x = 0)`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   645
  REWRITE_TAC[TAUT `a ==> b ==> c \<longleftrightarrow> b \<and> a ==> c`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   646
  DISCH_THEN(MP_TAC o SPEC `--(inv m % c):real^N` o
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   647
    MATCH_MP HAS_INTEGRAL_AFFINITY) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   648
  ASM_REWRITE_TAC[IMAGE_AFFINITY_INTERVAL; REAL_INV_INV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   649
  SIMP_TAC[COND_ID] THEN COND_CASES_TAC THENL [ASM SET_TAC[]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   650
  REWRITE_TAC[VECTOR_ADD_LDISTRIB; VECTOR_MUL_ASSOC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   651
               VECTOR_MUL_LNEG; VECTOR_MUL_RNEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   652
  ASM_SIMP_TAC[REAL_MUL_RINV; VECTOR_MUL_LID; VECTOR_NEG_NEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   653
  REWRITE_TAC[VECTOR_ARITH `(u + --c) + c:real^N = u`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   654
  REWRITE_TAC[REAL_ABS_INV; REAL_INV_INV; GSYM REAL_POW_INV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   655
  DISCH_THEN(fun th -> REWRITE_TAC[th]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   656
  REWRITE_TAC[LIFT_CMUL; GSYM VECTOR_SUB_LDISTRIB] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   657
  REWRITE_TAC[NORM_MUL; REAL_ABS_POW; REAL_ABS_ABS] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   658
  ONCE_REWRITE_TAC[REAL_MUL_SYM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   659
  ASM_SIMP_TAC[GSYM REAL_LT_RDIV_EQ; REAL_POW_LT; GSYM REAL_ABS_NZ]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   660
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   661
lemma stretch_galois: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   662
 "!x:real^N y:real^N m.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   663
        (!k. 1 <= k \<and> k <= dimindex(:N) ==>  ~(m k = 0))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   664
        ==> ((y = (lambda k. m k * x$k)) \<longleftrightarrow> (lambda k. inv(m k) * y$k) = x)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   665
qed   REPEAT GEN_TAC THEN SIMP_TAC[CART_EQ; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   666
  MATCH_MP_TAC(MESON[]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   667
   `(!x. p x ==> (q x \<longleftrightarrow> r x))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   668
    ==> (!x. p x) ==> ((!x. q x) \<longleftrightarrow> (!x. r x))`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   669
  GEN_TAC THEN ASM_CASES_TAC `1 <= k \<and> k <= dimindex(:N)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   670
  ASM_REWRITE_TAC[] THEN CONV_TAC REAL_FIELD);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   671
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   672
lemma has_gmeasure_stretch: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   673
 "!s m y. s has_gmeasure y
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   674
           ==> (IMAGE (\<lambda>x:real^N. lambda k. m k * x$k) s :real^N->bool)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   675
               has_gmeasure abs(product (1..dimindex(:N)) m) * y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   676
qed   REPEAT STRIP_TAC THEN ASM_CASES_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   677
   `!k. 1 <= k \<and> k <= dimindex(:N) ==> ~(m k = 0)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   678
  THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   679
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   680
    FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [NOT_FORALL_THM]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   681
    REWRITE_TAC[NOT_IMP; GSYM CONJ_ASSOC; LEFT_IMP_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   682
    X_GEN_TAC `k:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   683
    SUBGOAL_THEN `product(1..dimindex (:N)) m = 0` SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   684
     [ASM_MESON_TAC[PRODUCT_EQ_0_NUMSEG]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   685
    REWRITE_TAC[REAL_ABS_NUM; REAL_MUL_LZERO; HAS_GMEASURE_0] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   686
    MATCH_MP_TAC NEGLIGIBLE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   687
    EXISTS_TAC `{x:real^N | x$k = 0}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   688
    ASM_SIMP_TAC[NEGLIGIBLE_STANDARD_HYPERPLANE; SUBSET; FORALL_IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   689
    ASM_SIMP_TAC[IN_ELIM_THM; LAMBDA_BETA; REAL_MUL_LZERO]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   690
  UNDISCH_TAC `(s:real^N->bool) has_gmeasure y` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   691
  REWRITE_TAC[HAS_GMEASURE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   692
  ONCE_REWRITE_TAC[HAS_INTEGRAL] THEN REWRITE_TAC[IN_UNIV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   693
  DISCH_TAC THEN X_GEN_TAC `e:real` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   694
  SUBGOAL_THEN `0 < abs(product(1..dimindex(:N)) m)` ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   695
   [ASM_MESON_TAC[REAL_ABS_NZ; REAL_LT_DIV; PRODUCT_EQ_0_NUMSEG];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   696
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   697
  FIRST_X_ASSUM(MP_TAC o SPEC `e:real / abs(product(1..dimindex(:N)) m)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   698
  ASM_SIMP_TAC[REAL_LT_DIV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   699
  DISCH_THEN(X_CHOOSE_THEN `B:real` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   700
  EXISTS_TAC `sup(IMAGE (\<lambda>k. abs(m k) * B) (1..dimindex(:N)))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   701
  MATCH_MP_TAC(TAUT `a \<and> (a ==> b) ==> a \<and> b`) THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   702
   [ASM_SIMP_TAC[REAL_LT_SUP_FINITE; FINITE_IMAGE; NUMSEG_EMPTY; FINITE_NUMSEG;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   703
                 IN_NUMSEG; GSYM NOT_LE; DIMINDEX_GE_1; IMAGE_EQ_EMPTY;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   704
                 EXISTS_IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   705
    ASM_MESON_TAC[IN_NUMSEG; DIMINDEX_GE_1; LE_REFL; REAL_LT_MUL; REAL_ABS_NZ];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   706
    DISCH_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   707
  MAP_EVERY X_GEN_TAC [`u:real^N`; `v:real^N`] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   708
  ASM_SIMP_TAC[IN_IMAGE; STRETCH_GALOIS; UNWIND_THM1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   709
  FIRST_X_ASSUM(MP_TAC o SPECL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   710
    [`(lambda k. min (inv(m k) * (u:real^N)$k)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   711
                     (inv(m k) * (v:real^N)$k)):real^N`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   712
     `(lambda k. max (inv(m k) * (u:real^N)$k)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   713
                 (inv(m k) * (v:real^N)$k)):real^N`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   714
  MATCH_MP_TAC(TAUT `a \<and> (b ==> a ==> c) ==> (a ==> b) ==> c`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   715
  CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   716
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   717
    REWRITE_TAC[LEFT_IMP_EXISTS_THM] THEN X_GEN_TAC `z:real^1` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   718
    DISCH_THEN(CONJUNCTS_THEN2 MP_TAC ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   719
    SUBGOAL_THEN `!k. 1 <= k \<and> k <= dimindex (:N) ==> ~(inv(m k) = 0)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   720
    MP_TAC THENL [ASM_SIMP_TAC[REAL_INV_EQ_0]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   721
    ONCE_REWRITE_TAC[GSYM IMP_CONJ_ALT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   722
    DISCH_THEN(MP_TAC o MATCH_MP HAS_INTEGRAL_STRETCH)] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   723
  (MP_TAC(ISPECL [`u:real^N`; `v:real^N`; `\i:num. inv(m i)`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   724
    IMAGE_STRETCH_INTERVAL) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   725
   SUBGOAL_THEN `~(interval[u:real^N,v] = {})` ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   726
    [FIRST_ASSUM(MATCH_MP_TAC o MATCH_MP (SET_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   727
      `s \<subseteq> t ==> ~(s = {}) ==> ~(t = {})`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   728
     ASM_REWRITE_TAC[BALL_EQ_EMPTY; GSYM REAL_NOT_LT];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   729
     ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   730
   ASM_REWRITE_TAC[] THEN DISCH_THEN(SUBST1_TAC o SYM))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   731
  THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   732
   [FIRST_X_ASSUM(MATCH_MP_TAC o MATCH_MP (SET_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   733
     `b \<subseteq> s ==> b' \<subseteq> IMAGE f b ==> b' \<subseteq> IMAGE f s`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   734
    REWRITE_TAC[IN_BALL; SUBSET; NORM_ARITH `dist(0,x) = norm x`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   735
                IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   736
    ASM_SIMP_TAC[STRETCH_GALOIS; REAL_INV_EQ_0; UNWIND_THM1; REAL_INV_INV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   737
    X_GEN_TAC `x:real^N` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   738
    MATCH_MP_TAC REAL_LET_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   739
    EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   740
     `norm(sup(IMAGE(\<lambda>k. abs(m k)) (1..dimindex(:N))) % x:real^N)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   741
    CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   742
     [MATCH_MP_TAC NORM_LE_COMPONENTWISE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   743
      SIMP_TAC[LAMBDA_BETA; VECTOR_MUL_COMPONENT; REAL_ABS_MUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   744
      REPEAT STRIP_TAC THEN MATCH_MP_TAC REAL_LE_RMUL THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   745
      REWRITE_TAC[REAL_ABS_POS] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   746
      MATCH_MP_TAC(REAL_ARITH `x <= y ==> x <= abs y`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   747
      ASM_SIMP_TAC[REAL_LE_SUP_FINITE; FINITE_IMAGE; IMAGE_EQ_EMPTY;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   748
                  NUMSEG_EMPTY; FINITE_NUMSEG; GSYM NOT_LE; DIMINDEX_GE_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   749
      REWRITE_TAC[EXISTS_IN_IMAGE; IN_NUMSEG] THEN ASM_MESON_TAC[REAL_LE_REFL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   750
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   751
    REWRITE_TAC[NORM_MUL] THEN MATCH_MP_TAC REAL_LTE_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   752
    EXISTS_TAC `abs(sup(IMAGE(\<lambda>k. abs(m k)) (1..dimindex(:N)))) * B` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   753
    SUBGOAL_THEN `0 < sup(IMAGE(\<lambda>k. abs(m k)) (1..dimindex(:N)))`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   754
    ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   755
     [ASM_SIMP_TAC[REAL_LT_SUP_FINITE; FINITE_IMAGE; IMAGE_EQ_EMPTY;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   756
                  NUMSEG_EMPTY; FINITE_NUMSEG; GSYM NOT_LE; DIMINDEX_GE_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   757
      REWRITE_TAC[EXISTS_IN_IMAGE; GSYM REAL_ABS_NZ; IN_NUMSEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   758
      ASM_MESON_TAC[DIMINDEX_GE_1; LE_REFL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   759
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   760
    ASM_SIMP_TAC[REAL_LT_LMUL_EQ; REAL_ARITH `0 < x ==> 0 < abs x`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   761
    MATCH_MP_TAC REAL_LE_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   762
    EXISTS_TAC `sup(IMAGE(\<lambda>k. abs(m k)) (1..dimindex(:N))) * B` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   763
    ASM_SIMP_TAC[REAL_LE_RMUL_EQ; REAL_ARITH `0 < x ==> abs x <= x`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   764
    ASM_SIMP_TAC[REAL_LE_SUP_FINITE; FINITE_IMAGE; IMAGE_EQ_EMPTY;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   765
                  NUMSEG_EMPTY; FINITE_NUMSEG; GSYM NOT_LE; DIMINDEX_GE_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   766
    ASM_SIMP_TAC[EXISTS_IN_IMAGE; REAL_LE_RMUL_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   767
    ASM_SIMP_TAC[REAL_SUP_LE_FINITE; FINITE_IMAGE; IMAGE_EQ_EMPTY;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   768
                 NUMSEG_EMPTY; FINITE_NUMSEG; GSYM NOT_LE; DIMINDEX_GE_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   769
    MP_TAC(ISPEC `IMAGE (\<lambda>k. abs (m k)) (1..dimindex(:N))` SUP_FINITE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   770
    REWRITE_TAC[FORALL_IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   771
    ASM_SIMP_TAC[FINITE_IMAGE; FINITE_NUMSEG; IMAGE_EQ_EMPTY; NUMSEG_EMPTY;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   772
                 GSYM NOT_LE; DIMINDEX_GE_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   773
    REWRITE_TAC[IN_IMAGE] THEN MESON_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   774
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   775
    MATCH_MP_TAC(MESON[]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   776
     `s = t \<and> P z ==> (f has_integral z) s ==> Q
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   777
                       ==> ?w. (f has_integral w) t \<and> P w`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   778
    SIMP_TAC[GSYM PRODUCT_INV; FINITE_NUMSEG; GSYM REAL_ABS_INV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   779
    REWRITE_TAC[REAL_INV_INV] THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   780
     [REWRITE_TAC[GSYM IMAGE_o] THEN MATCH_MP_TAC(SET_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   781
       `(!x. f x = x) ==> IMAGE f s = s`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   782
      SIMP_TAC[o_THM; LAMBDA_BETA; CART_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   783
      ASM_SIMP_TAC[REAL_MUL_ASSOC; REAL_MUL_RINV; REAL_MUL_LID];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   784
      REWRITE_TAC[ABS_; _SUB; LIFT_; _CMUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   785
      REWRITE_TAC[GSYM REAL_SUB_LDISTRIB; ETA_AX] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   786
      REWRITE_TAC[REAL_ABS_MUL; REAL_ABS_ABS] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   787
      ONCE_REWRITE_TAC[REAL_MUL_SYM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   788
      ASM_SIMP_TAC[GSYM REAL_LT_RDIV_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   789
      ASM_MESON_TAC[ABS_; _SUB; LIFT_]]]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   790
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   791
lemma has_gmeasure_translation: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   792
 "!s m a. s has_gmeasure m ==> (IMAGE (\<lambda>x:real^N. a + x) s) has_gmeasure m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   793
qed   REPEAT GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   794
  MP_TAC(ISPECL [`s:real^N->bool`; `1`; `a:real^N`; `m:real`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   795
                HAS_GMEASURE_AFFINITY) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   796
  REWRITE_TAC[VECTOR_MUL_LID; REAL_ABS_NUM; REAL_POW_ONE; REAL_MUL_LID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   797
  REWRITE_TAC[VECTOR_ADD_SYM]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   798
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   799
lemma negligible_translation: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   800
 "!s a. negligible s ==> negligible (IMAGE (\<lambda>x:real^N. a + x) s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   801
qed   SIMP_TAC[GSYM HAS_GMEASURE_0; HAS_GMEASURE_TRANSLATION]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   802
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   803
lemma has_gmeasure_translation_eq: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   804
 "!s m. (IMAGE (\<lambda>x:real^N. a + x) s) has_gmeasure m \<longleftrightarrow> s has_gmeasure m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   805
qed   REPEAT GEN_TAC THEN EQ_TAC THEN REWRITE_TAC[HAS_GMEASURE_TRANSLATION] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   806
  DISCH_THEN(MP_TAC o SPEC `--a:real^N` o
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   807
    MATCH_MP HAS_GMEASURE_TRANSLATION) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   808
  MATCH_MP_TAC EQ_IMP THEN AP_THM_TAC THEN AP_TERM_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   809
  REWRITE_TAC[GSYM IMAGE_o; o_DEF; VECTOR_ARITH `--a + a + b:real^N = b`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   810
  SET_TAC[]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   811
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   812
lemma negligible_translation_rev: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   813
 "!s a. negligible (IMAGE (\<lambda>x:real^N. a + x) s) ==> negligible s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   814
qed   SIMP_TAC[GSYM HAS_GMEASURE_0; HAS_GMEASURE_TRANSLATION_EQ]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   815
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   816
lemma negligible_translation_eq: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   817
 "!s a. negligible (IMAGE (\<lambda>x:real^N. a + x) s) \<longleftrightarrow> negligible s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   818
qed   SIMP_TAC[GSYM HAS_GMEASURE_0; HAS_GMEASURE_TRANSLATION_EQ]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   819
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   820
lemma gmeasurable_translation: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   821
 "!s. gmeasurable (IMAGE (\<lambda>x. a + x) s) \<longleftrightarrow> gmeasurable s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   822
qed   REWRITE_TAC[measurable; HAS_GMEASURE_TRANSLATION_EQ]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   823
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   824
lemma measure_translation: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   825
 "!s. gmeasurable s ==> measure(IMAGE (\<lambda>x. a + x) s) = gmeasure s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   826
qed   REWRITE_TAC[HAS_GMEASURE_MEASURE] THEN REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   827
  MATCH_MP_TAC MEASURE_UNIQUE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   828
  ASM_REWRITE_TAC[HAS_GMEASURE_TRANSLATION_EQ]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   829
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   830
lemma has_gmeasure_scaling: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   831
 "!s m c. s has_gmeasure m
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   832
           ==> (IMAGE (\<lambda>x:real^N. c % x) s) has_gmeasure
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   833
               (abs(c) pow dimindex(:N)) * m"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   834
qed   REPEAT GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   835
  MP_TAC(ISPECL [`s:real^N->bool`; `c:real`; `0:real^N`; `m:real`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   836
                HAS_GMEASURE_AFFINITY) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   837
  REWRITE_TAC[VECTOR_ADD_RID]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   838
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   839
lemma has_gmeasure_scaling_eq: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   840
 "!s m c. ~(c = 0)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   841
           ==> (IMAGE (\<lambda>x:real^N. c % x) s
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   842
                  has_gmeasure (abs(c) pow dimindex(:N)) * m \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   843
                s has_gmeasure m)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   844
qed   REPEAT STRIP_TAC THEN EQ_TAC THEN REWRITE_TAC[HAS_GMEASURE_SCALING] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   845
  DISCH_THEN(MP_TAC o SPEC `inv(c)` o MATCH_MP HAS_GMEASURE_SCALING) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   846
  REWRITE_TAC[GSYM IMAGE_o; o_DEF; GSYM REAL_ABS_MUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   847
  REWRITE_TAC[GSYM REAL_POW_MUL; VECTOR_MUL_ASSOC; REAL_MUL_ASSOC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   848
  ASM_SIMP_TAC[GSYM REAL_ABS_MUL; REAL_MUL_LINV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   849
  REWRITE_TAC[REAL_POW_ONE; REAL_ABS_NUM; REAL_MUL_LID; VECTOR_MUL_LID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   850
  MATCH_MP_TAC EQ_IMP THEN AP_THM_TAC THEN AP_TERM_TAC THEN SET_TAC[]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   851
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   852
lemma gmeasurable_scaling: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   853
 "!s c. gmeasurable s ==> gmeasurable (IMAGE (\<lambda>x. c % x) s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   854
qed   REWRITE_TAC[measurable] THEN MESON_TAC[HAS_GMEASURE_SCALING]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   855
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   856
lemma gmeasurable_scaling_eq: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   857
 "!s c. ~(c = 0) ==> (measurable (IMAGE (\<lambda>x. c % x) s) \<longleftrightarrow> gmeasurable s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   858
qed   REPEAT STRIP_TAC THEN EQ_TAC THEN REWRITE_TAC[MEASURABLE_SCALING] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   859
  DISCH_THEN(MP_TAC o SPEC `inv c` o MATCH_MP GMEASURABLE_SCALING) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   860
  REWRITE_TAC[GSYM IMAGE_o; o_DEF; GSYM REAL_ABS_MUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   861
  MATCH_MP_TAC EQ_IMP THEN AP_TERM_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   862
  ASM_SIMP_TAC[VECTOR_MUL_ASSOC; REAL_MUL_LINV; VECTOR_MUL_LID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   863
  SET_TAC[]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   864
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   865
lemma measure_scaling: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   866
 "!s. gmeasurable s
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   867
       ==> measure(IMAGE (\<lambda>x:real^N. c % x) s) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   868
              (abs(c) pow dimindex(:N)) * gmeasure s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   869
qed   REWRITE_TAC[HAS_GMEASURE_MEASURE] THEN REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   870
  MATCH_MP_TAC MEASURE_UNIQUE THEN ASM_SIMP_TAC[HAS_GMEASURE_SCALING]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   871
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   872
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   873
(* Measurability of countable unions and intersections of various kinds.     *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   874
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   875
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   876
lemma has_gmeasure_nested_unions:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   877
  assumes "\<And>n. gmeasurable(s n)" "\<And>n. gmeasure(s n) \<le> B" "\<And>n. s(n) \<subseteq> s(Suc n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   878
  shows "gmeasurable(\<Union> { s n | n. n \<in> UNIV }) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   879
  (\<lambda>n. gmeasure(s n)) ----> gmeasure(\<Union> { s(n) | n. n \<in> UNIV })"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   880
proof- let ?g = "\<lambda>x. if x \<in> \<Union>{s n |n. n \<in> UNIV} then 1 else (0::real)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   881
  have "?g integrable_on UNIV \<and> (\<lambda>k. integral UNIV (\<lambda>x. if x \<in> s k then 1 else 0)) ----> integral UNIV ?g"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   882
  proof(rule monotone_convergence_increasing)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   883
    case goal1 show ?case using assms(1) unfolding gmeasurable_integrable by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   884
    case goal2 show ?case using assms(3) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   885
    have "\<forall>m n. m\<le>n \<longrightarrow> s m \<subseteq> s n" apply(subst transitive_stepwise_le_eq)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   886
      using assms(3) by auto note * = this[rule_format]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   887
    have **:"\<And>x e n. \<lbrakk>x \<in> s n; 0 < e\<rbrakk> \<Longrightarrow> \<exists>N. \<forall>n. x \<notin> s n \<longrightarrow> N \<le> n \<longrightarrow> dist 0 1 < e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   888
      apply(rule_tac x=n in exI) using * by auto 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   889
    case goal3 show ?case unfolding Lim_sequentially by(auto intro!: **) 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   890
    case goal4 show ?case unfolding bounded_def apply(rule_tac x=0 in exI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   891
      apply(rule_tac x=B in exI) unfolding dist_real_def apply safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   892
      unfolding measure_integral_univ[OF assms(1),THEN sym]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   893
      apply(subst abs_of_nonpos) using assms(1,2) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   894
  qed note conjunctD2[OF this]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   895
  thus ?thesis unfolding gmeasurable_integrable[THEN sym] measure_integral_univ[OF assms(1)]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   896
    apply- unfolding measure_integral_univ by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   897
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   898
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   899
lemmas gmeasurable_nested_unions = has_gmeasure_nested_unions(1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   900
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   901
lemma sums_alt:"f sums s = (\<lambda>n. setsum f {0..n}) ----> s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   902
proof- have *:"\<And>n. {0..<Suc n} = {0..n}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   903
  show ?thesis unfolding sums_def apply(subst LIMSEQ_Suc_iff[THEN sym]) unfolding * ..
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   904
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   905
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   906
lemma has_gmeasure_countable_negligible_unions: 
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   907
  assumes "\<And>n. gmeasurable(s n)" "\<And>m n. m \<noteq> n \<Longrightarrow> negligible(s m \<inter> s n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   908
  "\<And>n. setsum (\<lambda>k. gmeasure(s k)) {0..n}  <= B"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   909
  shows "gmeasurable(\<Union> { s(n) |n. n \<in> UNIV })" (is ?m)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   910
  "((\<lambda>n. gmeasure(s n)) sums (gmeasure(\<Union> { s(n) |n. n \<in> UNIV })))" (is ?s)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   911
proof- have *:"\<And>n. (\<Union> (s ` {0..n})) has_gmeasure (setsum (\<lambda>k. gmeasure(s k)) {0..n})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   912
    apply(rule has_gmeasure_negligible_unions_image) using assms by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   913
  have **:"(\<Union>{\<Union>s ` {0..n} |n. n \<in> UNIV}) = (\<Union>{s n |n. n \<in> UNIV})" unfolding simple_image by fastsimp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   914
  have "gmeasurable (\<Union>{\<Union>s ` {0..n} |n. n \<in> UNIV}) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   915
    (\<lambda>n. gmeasure (\<Union>(s ` {0..n}))) ----> gmeasure (\<Union>{\<Union>s ` {0..n} |n. n \<in> UNIV})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   916
    apply(rule has_gmeasure_nested_unions) apply(rule gmeasurableI,rule *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   917
    unfolding measure_unique[OF *] defer apply(rule Union_mono,rule image_mono) using assms(3) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   918
  note lem = conjunctD2[OF this,unfolded **]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   919
  show ?m using lem(1) .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   920
  show ?s using lem(2) unfolding sums_alt measure_unique[OF *] .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   921
qed     
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   922
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   923
lemma negligible_countable_unions: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   924
 "!s:num->real^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   925
        (!n. negligible(s n)) ==> negligible(UNIONS {s(n) | n \<in> (:num)})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   926
qed   REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   927
  MP_TAC(ISPECL [`s:num->real^N->bool`; `0`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   928
    HAS_GMEASURE_COUNTABLE_NEGLIGIBLE_UNIONS) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   929
  ASM_SIMP_TAC[MEASURE_EQ_0; SUM_0; REAL_LE_REFL; LIFT_NUM] THEN ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   930
   [ASM_MESON_TAC[HAS_GMEASURE_0; gmeasurable; INTER_SUBSET; NEGLIGIBLE_SUBSET];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   931
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   932
  SIMP_TAC[GSYM GMEASURABLE_MEASURE_EQ_0] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   933
  STRIP_TAC THEN REWRITE_TAC[GSYM LIFT_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   934
  MATCH_MP_TAC SERIES_UNIQUE THEN REWRITE_TAC[LIFT_NUM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   935
  MAP_EVERY EXISTS_TAC [`(\<lambda>k. 0):num->real^1`; `from 0`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   936
  ASM_REWRITE_TAC[SERIES_0]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   937
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   938
lemma gmeasurable_countable_unions_strong:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   939
  assumes "\<And>n. gmeasurable(s n)" "\<And>n::nat. gmeasure(\<Union>{s k |k. k \<le> n}) \<le> B"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   940
  shows "gmeasurable(\<Union>{ s(n) |n. n \<in> UNIV })"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   941
proof- have *:"\<Union>{\<Union>s ` {0..n} |n. n \<in> UNIV} = \<Union>range s" unfolding simple_image by fastsimp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   942
  show ?thesis unfolding simple_image
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   943
    apply(rule gmeasurable_nested_unions[of "\<lambda>n. \<Union>(s ` {0..n})", THEN conjunct1,unfolded *])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   944
  proof- fix n::nat show "gmeasurable (\<Union>s ` {0..n})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   945
      apply(rule gmeasurable_finite_unions) using assms(1) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   946
    show "gmeasure (\<Union>s ` {0..n}) \<le> B"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   947
      using assms(2)[of n] unfolding simple_image[THEN sym] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   948
    show "\<Union>s ` {0..n} \<subseteq> \<Union>s ` {0..Suc n}" apply(rule Union_mono) by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   949
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   950
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   951
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   952
lemma has_gmeasure_countable_negligible_unions_bounded: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   953
 "!s:num->real^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   954
        (!n. gmeasurable(s n)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   955
        (!m n. ~(m = n) ==> negligible(s m \<inter> s n)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   956
        bounded(\<Union>{ s(n) | n \<in> (:num) })
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   957
        ==> gmeasurable(\<Union>{ s(n) | n \<in> (:num) }) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   958
            ((\<lambda>n. lift(measure(s n))) sums
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   959
             lift(measure(\<Union>{ s(n) | n \<in> (:num) }))) (from 0)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   960
qed   REPEAT GEN_TAC THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   961
  FIRST_ASSUM(MP_TAC o MATCH_MP BOUNDED_SUBSET_CLOSED_INTERVAL) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   962
  REWRITE_TAC[LEFT_IMP_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   963
  MAP_EVERY X_GEN_TAC [`a:real^N`; `b:real^N`] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   964
  MATCH_MP_TAC HAS_GMEASURE_COUNTABLE_NEGLIGIBLE_UNIONS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   965
  EXISTS_TAC `measure(interval[a:real^N,b])` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   966
  ASM_REWRITE_TAC[] THEN X_GEN_TAC `n:num` THEN MATCH_MP_TAC REAL_LE_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   967
  EXISTS_TAC `measure(UNIONS (IMAGE (s:num->real^N->bool) (0..n)))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   968
  CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   969
   [MATCH_MP_TAC REAL_EQ_IMP_LE THEN CONV_TAC SYM_CONV THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   970
    MATCH_MP_TAC MEASURE_NEGLIGIBLE_UNIONS_IMAGE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   971
    ASM_SIMP_TAC[FINITE_NUMSEG];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   972
    MATCH_MP_TAC MEASURE_SUBSET THEN REWRITE_TAC[MEASURABLE_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   973
    CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   974
     [MATCH_MP_TAC GMEASURABLE_UNIONS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   975
      ASM_SIMP_TAC[FINITE_IMAGE; FINITE_NUMSEG; FORALL_IN_IMAGE];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   976
      ASM SET_TAC[]]]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   977
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   978
lemma gmeasurable_countable_negligible_unions_bounded: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   979
 "!s:num->real^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   980
        (!n. gmeasurable(s n)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   981
        (!m n. ~(m = n) ==> negligible(s m \<inter> s n)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   982
        bounded(\<Union>{ s(n) | n \<in> (:num) })
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   983
        ==> gmeasurable(\<Union>{ s(n) | n \<in> (:num) })"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   984
qed   SIMP_TAC[HAS_GMEASURE_COUNTABLE_NEGLIGIBLE_UNIONS_BOUNDED]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   985
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   986
lemma gmeasurable_countable_unions: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   987
 "!s:num->real^N->bool B.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   988
        (!n. gmeasurable(s n)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   989
        (!n. sum (0..n) (\<lambda>k. measure(s k)) \<le> B)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   990
        ==> gmeasurable(\<Union>{ s(n) | n \<in> (:num) })"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   991
qed   REPEAT STRIP_TAC THEN MATCH_MP_TAC GMEASURABLE_COUNTABLE_UNIONS_STRONG THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   992
  EXISTS_TAC `B:real` THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   993
  X_GEN_TAC `n:num` THEN MATCH_MP_TAC REAL_LE_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   994
  EXISTS_TAC `sum(0..n) (\<lambda>k. measure(s k:real^N->bool))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   995
  ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   996
  W(MP_TAC o PART_MATCH (rand o rand) MEASURE_UNIONS_LE_IMAGE o
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   997
       rand o snd) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   998
  ASM_REWRITE_TAC[FINITE_NUMSEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   999
  ONCE_REWRITE_TAC[GSYM SIMPLE_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1000
  REWRITE_TAC[IN_NUMSEG; LE_0]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1001
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1002
lemma gmeasurable_countable_inters: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1003
 "!s:num->real^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1004
        (!n. gmeasurable(s n))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1005
        ==> gmeasurable(INTERS { s(n) | n \<in> (:num) })"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1006
qed   REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1007
  SUBGOAL_THEN `INTERS { s(n):real^N->bool | n \<in> (:num) } =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1008
                s 0 DIFF (\<Union>{s 0 DIFF s n | n \<in> (:num)})`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1009
  SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1010
   [GEN_REWRITE_TAC I [EXTENSION] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1011
    REWRITE_TAC[IN_INTERS; IN_DIFF; IN_UNIONS] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1012
    REWRITE_TAC[SIMPLE_IMAGE; FORALL_IN_IMAGE; EXISTS_IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1013
    ASM SET_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1014
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1015
  MATCH_MP_TAC GMEASURABLE_DIFF THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1016
  MATCH_MP_TAC GMEASURABLE_COUNTABLE_UNIONS_STRONG THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1017
  EXISTS_TAC `measure(s 0:real^N->bool)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1018
  ASM_SIMP_TAC[MEASURABLE_DIFF; LE_0] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1019
  GEN_TAC THEN MATCH_MP_TAC MEASURE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1020
  ASM_REWRITE_TAC[] THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1021
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1022
    REWRITE_TAC[SUBSET; FORALL_IN_UNIONS; IN_ELIM_THM; IN_DIFF] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1023
    MESON_TAC[IN_DIFF]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1024
  ONCE_REWRITE_TAC[GSYM IN_NUMSEG_0] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1025
  ONCE_REWRITE_TAC[SIMPLE_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1026
  ASM_SIMP_TAC[FORALL_IN_IMAGE; FINITE_IMAGE; FINITE_NUMSEG;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1027
               GMEASURABLE_DIFF; GMEASURABLE_UNIONS]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1028
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1029
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1030
(* measurability of compact and bounded open sets.                           *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1031
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1032
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1033
lemma gmeasurable_compact: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1034
 "!s:real^N->bool. compact s ==> gmeasurable s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1035
qed   lemma lemma = prove
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1036
   (`!f s:real^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1037
          (!n. FINITE(f n)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1038
          (!n. s \<subseteq> UNIONS(f n)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1039
          (!x. ~(x \<in> s) ==> ?n. ~(x \<in> UNIONS(f n))) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1040
          (!n a. a \<in> f(SUC n) ==> ?b. b \<in> f(n) \<and> a \<subseteq> b) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1041
          (!n a. a \<in> f(n) ==> gmeasurable a)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1042
          ==> gmeasurable s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1043
qed     REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1044
    SUBGOAL_THEN `!n. UNIONS(f(SUC n):(real^N->bool)->bool) \<subseteq> UNIONS(f n)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1045
    ASSUME_TAC THENL [ASM SET_TAC[]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1046
    SUBGOAL_THEN `s = INTERS { UNIONS(f n) | n \<in> (:num) }:real^N->bool`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1047
    SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1048
     [ONCE_REWRITE_TAC[SIMPLE_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1049
      MATCH_MP_TAC SUBSET_ANTISYM THEN CONJ_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1050
      REWRITE_TAC[SUBSET; IN_INTERS; FORALL_IN_IMAGE; IN_UNIV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1051
      REWRITE_TAC[IN_IMAGE] THEN ASM SET_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1052
      MATCH_MP_TAC GMEASURABLE_COUNTABLE_INTERS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1053
      ASM_REWRITE_TAC[] THEN GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1054
      MATCH_MP_TAC GMEASURABLE_UNIONS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1055
      ASM_MESON_TAC[]]) in
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1056
  REPEAT STRIP_TAC THEN MATCH_MP_TAC lemma THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1057
  EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1058
   `\n. { k | ?u:real^N. (!i. 1 \<le> i \<and> i \<le> dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1059
                              ==> integer(u$i)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1060
                  k = { x:real^N | !i. 1 \<le> i \<and> i \<le> dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1061
                                       ==> u$i / 2 pow n \<le> x$i \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1062
                                           x$i < (u$i + 1) / 2 pow n } \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1063
                  ~(s \<inter> k = {})}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1064
  REWRITE_TAC[IN_ELIM_THM] THEN REPEAT CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1065
   [X_GEN_TAC `n:num` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1066
    SIMP_TAC[REAL_LE_LDIV_EQ; REAL_LT_RDIV_EQ; REAL_LT_POW2] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1067
    SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1068
     `?N. !x:real^N i. x \<in> s \<and> 1 \<le> i \<and> i \<le> dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1069
                       ==> abs(x$i * 2 pow n) < N`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1070
    STRIP_ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1071
     [FIRST_ASSUM(MP_TAC o MATCH_MP COMPACT_IMP_BOUNDED) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1072
      REWRITE_TAC[BOUNDED_POS; LEFT_IMP_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1073
      X_GEN_TAC `B:real` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1074
      MP_TAC(SPEC `B * 2 pow n` (MATCH_MP REAL_ARCH REAL_LT_01)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1075
      MATCH_MP_TAC MONO_EXISTS THEN REWRITE_TAC[REAL_MUL_RID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1076
      X_GEN_TAC `N:num` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1077
      REWRITE_TAC[REAL_ABS_MUL; REAL_ABS_POW; REAL_ABS_NUM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1078
      SIMP_TAC[GSYM REAL_LT_RDIV_EQ; REAL_LT_POW2] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1079
      ASM_MESON_TAC[COMPONENT_LE_NORM; REAL_LE_TRANS; REAL_LET_TRANS];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1080
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1081
    MATCH_MP_TAC FINITE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1082
    EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1083
     `IMAGE (\<lambda>u. {x | !i. 1 \<le> i \<and> i \<le> dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1084
                          ==> (u:real^N)$i \<le> (x:real^N)$i * 2 pow n \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1085
                              x$i * 2 pow n < u$i + 1})
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1086
            {u | !i. 1 \<le> i \<and> i \<le> dimindex(:N) ==> integer (u$i) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1087
                                                     abs(u$i) \<le> N}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1088
    CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1089
     [MATCH_MP_TAC FINITE_IMAGE THEN MATCH_MP_TAC FINITE_CART THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1090
      REWRITE_TAC[GSYM REAL_BOUNDS_LE; FINITE_INTSEG];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1091
      REWRITE_TAC[SUBSET; IN_ELIM_THM; IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1092
      X_GEN_TAC `l:real^N->bool` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1093
      MATCH_MP_TAC MONO_EXISTS THEN X_GEN_TAC `u:real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1094
      STRIP_TAC THEN FIRST_X_ASSUM SUBST_ALL_TAC THEN ASM_SIMP_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1095
      X_GEN_TAC `k:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1096
      MATCH_MP_TAC REAL_LE_REVERSE_INTEGERS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1097
      ASM_SIMP_TAC[INTEGER_CLOSED] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1098
      FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [GSYM MEMBER_NOT_EMPTY]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1099
      DISCH_THEN(X_CHOOSE_THEN `x:real^N` MP_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1100
      REWRITE_TAC[IN_INTER; IN_ELIM_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1101
      DISCH_THEN(CONJUNCTS_THEN2 ASSUME_TAC (MP_TAC o SPEC `k:num`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1102
      ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1103
      FIRST_X_ASSUM(MP_TAC o SPECL [`x:real^N`; `k:num`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1104
      ASM_REWRITE_TAC[] THEN REAL_ARITH_TAC];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1105
    X_GEN_TAC `n:num` THEN REWRITE_TAC[SUBSET; IN_UNIONS; IN_ELIM_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1106
    X_GEN_TAC `x:real^N` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1107
    REWRITE_TAC[LEFT_AND_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1108
    ONCE_REWRITE_TAC[SWAP_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1109
    EXISTS_TAC `(lambda i. floor(2 pow n * (x:real^N)$i)):real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1110
    ONCE_REWRITE_TAC[TAUT `(a \<and> b \<and> c) \<and> d \<longleftrightarrow> b \<and> a \<and> c \<and> d`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1111
    REWRITE_TAC[UNWIND_THM2] THEN SIMP_TAC[LAMBDA_BETA; FLOOR] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1112
    REWRITE_TAC[GSYM MEMBER_NOT_EMPTY; IN_INTER] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1113
    REWRITE_TAC[LEFT_AND_EXISTS_THM] THEN EXISTS_TAC `x:real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1114
    ASM_REWRITE_TAC[IN_ELIM_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1115
    SIMP_TAC[REAL_LE_LDIV_EQ; REAL_LT_RDIV_EQ; REAL_LT_POW2] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1116
    REWRITE_TAC[REAL_MUL_SYM; FLOOR];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1117
    X_GEN_TAC `x:real^N` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1118
    FIRST_ASSUM(MP_TAC o MATCH_MP COMPACT_IMP_CLOSED) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1119
    REWRITE_TAC[closed; open_def] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1120
    DISCH_THEN(MP_TAC o SPEC `x:real^N`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1121
    ASM_REWRITE_TAC[IN_DIFF; IN_UNIV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1122
    DISCH_THEN(X_CHOOSE_THEN `e:real` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1123
    MP_TAC(SPECL [`inv(2)`; `e / (dimindex(:N))`] REAL_ARCH_POW_INV) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1124
    ASM_SIMP_TAC[REAL_LT_DIV; REAL_LT_RDIV_EQ; REAL_OF_NUM_LT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1125
                 DIMINDEX_GE_1; ARITH_RULE `0 < x \<longleftrightarrow> 1 \<le> x`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1126
    CONV_TAC REAL_RAT_REDUCE_CONV THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1127
    MATCH_MP_TAC MONO_EXISTS THEN X_GEN_TAC `n:num` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1128
    REWRITE_TAC[IN_UNIONS; IN_ELIM_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1129
    REWRITE_TAC[LEFT_AND_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1130
    ONCE_REWRITE_TAC[SWAP_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1131
    ONCE_REWRITE_TAC[TAUT `(a \<and> b \<and> c) \<and> d \<longleftrightarrow> b \<and> a \<and> c \<and> d`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1132
    REWRITE_TAC[UNWIND_THM2] THEN REWRITE_TAC[NOT_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1133
    X_GEN_TAC `u:real^N` THEN REWRITE_TAC[GSYM MEMBER_NOT_EMPTY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1134
    REWRITE_TAC[IN_INTER; IN_ELIM_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1135
    DISCH_THEN(CONJUNCTS_THEN2 MP_TAC ASSUME_TAC o CONJUNCT2) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1136
    DISCH_THEN(X_CHOOSE_THEN `y:real^N`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1137
     (CONJUNCTS_THEN2 MP_TAC ASSUME_TAC)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1138
    REWRITE_TAC[] THEN FIRST_X_ASSUM MATCH_MP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1139
    FIRST_X_ASSUM(MATCH_MP_TAC o MATCH_MP (REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1140
     `d < e ==> x \<le> d ==> x < e`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1141
    REWRITE_TAC[dist] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1142
    W(MP_TAC o PART_MATCH lhand NORM_LE_L1 o lhand o snd) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1143
    MATCH_MP_TAC(REAL_ARITH `a \<le> b ==> x \<le> a ==> x \<le> b`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1144
    GEN_REWRITE_TAC (funpow 3 RAND_CONV) [GSYM CARD_NUMSEG_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1145
    ONCE_REWRITE_TAC[REAL_MUL_SYM] THEN MATCH_MP_TAC SUM_BOUND THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1146
    SIMP_TAC[FINITE_NUMSEG; IN_NUMSEG; VECTOR_SUB_COMPONENT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1147
    X_GEN_TAC `k:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1148
    REPEAT(FIRST_X_ASSUM(MP_TAC o SPEC `k:num`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1149
    ASM_REWRITE_TAC[real_div; REAL_ADD_RDISTRIB] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1150
    REWRITE_TAC[REAL_MUL_LID; GSYM REAL_POW_INV] THEN REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1151
    MAP_EVERY X_GEN_TAC [`n:num`; `a:real^N->bool`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1152
    DISCH_THEN(X_CHOOSE_THEN `u:real^N`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1153
     (CONJUNCTS_THEN2 ASSUME_TAC MP_TAC)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1154
    DISCH_THEN(CONJUNCTS_THEN2 (ASSUME_TAC o SYM) ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1155
    REWRITE_TAC[LEFT_AND_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1156
    ONCE_REWRITE_TAC[SWAP_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1157
    ONCE_REWRITE_TAC[TAUT `(a \<and> b \<and> c) \<and> d \<longleftrightarrow> b \<and> a \<and> c \<and> d`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1158
    REWRITE_TAC[UNWIND_THM2] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1159
    EXISTS_TAC `(lambda i. floor((u:real^N)$i / 2)):real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1160
    ASM_SIMP_TAC[VECTOR_MUL_COMPONENT; LAMBDA_BETA; FLOOR] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1161
    MATCH_MP_TAC(SET_RULE `~(s \<inter> a = {}) \<and> a \<subseteq> b
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1162
                           ==> ~(s \<inter> b = {}) \<and> a \<subseteq> b`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1163
    ASM_REWRITE_TAC[] THEN EXPAND_TAC "a" THEN REWRITE_TAC[SUBSET] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1164
    X_GEN_TAC `x:real^N` THEN REWRITE_TAC[IN_ELIM_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1165
    MATCH_MP_TAC MONO_FORALL THEN X_GEN_TAC `k:num` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1166
    DISCH_THEN(fun th -> STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1167
    REWRITE_TAC[real_pow; real_div; REAL_INV_MUL; REAL_MUL_ASSOC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1168
    REWRITE_TAC[GSYM real_div] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1169
    SIMP_TAC[REAL_LE_LDIV_EQ; REAL_LT_RDIV_EQ; REAL_LT_POW2] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1170
    MP_TAC(SPEC `(u:real^N)$k / 2` FLOOR) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1171
    REWRITE_TAC[REAL_ARITH `u / 2 < floor(u / 2) + 1 \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1172
                            u < 2 * floor(u / 2) + 2`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1173
    ASM_SIMP_TAC[REAL_LT_INTEGERS; INTEGER_CLOSED; FLOOR_FRAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1174
    REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1175
    REWRITE_TAC[LEFT_IMP_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1176
    MAP_EVERY X_GEN_TAC [`n:num`; `a:real^N->bool`; `u:real^N`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1177
    DISCH_THEN(SUBST1_TAC o CONJUNCT1 o CONJUNCT2) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1178
    ONCE_REWRITE_TAC[MEASURABLE_INNER_OUTER] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1179
    GEN_TAC THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1180
    EXISTS_TAC `interval(inv(2 pow n) % u:real^N,
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1181
                         inv(2 pow n) % (u + 1))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1182
    EXISTS_TAC `interval[inv(2 pow n) % u:real^N,
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1183
                         inv(2 pow n) % (u + 1)]` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1184
    REWRITE_TAC[MEASURABLE_INTERVAL; MEASURE_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1185
    ASM_REWRITE_TAC[REAL_SUB_REFL; REAL_ABS_0] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1186
    REWRITE_TAC[SUBSET; IN_INTERVAL; IN_ELIM_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1187
    CONJ_TAC THEN X_GEN_TAC `y:real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1188
    MATCH_MP_TAC MONO_FORALL THEN X_GEN_TAC `k:num` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1189
    DISCH_THEN(fun th -> STRIP_TAC THEN MP_TAC th) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1190
    ASM_SIMP_TAC[VECTOR_MUL_COMPONENT; VECTOR_ADD_COMPONENT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1191
                 VEC_COMPONENT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1192
    REAL_ARITH_TAC]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1193
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1194
lemma gmeasurable_open: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1195
 "!s:real^N->bool. bounded s \<and> open s ==> gmeasurable s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1196
qed   REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1197
  FIRST_X_ASSUM(MP_TAC o MATCH_MP BOUNDED_SUBSET_CLOSED_INTERVAL) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1198
  REWRITE_TAC[LEFT_IMP_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1199
  MAP_EVERY X_GEN_TAC [`a:real^N`; `b:real^N`] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1200
  FIRST_ASSUM(SUBST1_TAC o MATCH_MP (SET_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1201
   `s \<subseteq> t ==> s = t DIFF (t DIFF s)`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1202
  MATCH_MP_TAC GMEASURABLE_DIFF THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1203
  REWRITE_TAC[MEASURABLE_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1204
  MATCH_MP_TAC GMEASURABLE_COMPACT THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1205
  SIMP_TAC[COMPACT_EQ_BOUNDED_CLOSED; BOUNDED_DIFF; BOUNDED_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1206
  MATCH_MP_TAC CLOSED_DIFF THEN ASM_REWRITE_TAC[CLOSED_INTERVAL]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1207
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1208
lemma gmeasurable_closure: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1209
 "!s. bounded s ==> gmeasurable(closure s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1210
qed   SIMP_TAC[MEASURABLE_COMPACT; COMPACT_EQ_BOUNDED_CLOSED; CLOSED_CLOSURE;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1211
           BOUNDED_CLOSURE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1212
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1213
lemma gmeasurable_interior: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1214
 "!s. bounded s ==> gmeasurable(interior s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1215
qed   SIMP_TAC[MEASURABLE_OPEN; OPEN_INTERIOR; BOUNDED_INTERIOR]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1216
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1217
lemma gmeasurable_frontier: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1218
 "!s:real^N->bool. bounded s ==> gmeasurable(frontier s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1219
qed   REPEAT STRIP_TAC THEN REWRITE_TAC[frontier] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1220
  MATCH_MP_TAC GMEASURABLE_DIFF THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1221
  ASM_SIMP_TAC[MEASURABLE_CLOSURE; GMEASURABLE_INTERIOR] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1222
  MATCH_MP_TAC SUBSET_TRANS THEN EXISTS_TAC `s:real^N->bool` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1223
  REWRITE_TAC[INTERIOR_SUBSET; CLOSURE_SUBSET]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1224
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1225
lemma measure_frontier: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1226
 "!s:real^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1227
        bounded s
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1228
        ==> measure(frontier s) = measure(closure s) - measure(interior s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1229
qed   REPEAT STRIP_TAC THEN REWRITE_TAC[frontier] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1230
  MATCH_MP_TAC MEASURE_DIFF_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1231
  ASM_SIMP_TAC[MEASURABLE_CLOSURE; GMEASURABLE_INTERIOR] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1232
  MATCH_MP_TAC SUBSET_TRANS THEN EXISTS_TAC `s:real^N->bool` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1233
  REWRITE_TAC[INTERIOR_SUBSET; CLOSURE_SUBSET]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1234
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1235
lemma gmeasurable_jordan: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1236
 "!s:real^N->bool. bounded s \<and> negligible(frontier s) ==> gmeasurable s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1237
qed   REPEAT STRIP_TAC THEN ONCE_REWRITE_TAC[MEASURABLE_INNER_OUTER] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1238
  GEN_TAC THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1239
  EXISTS_TAC `interior(s):real^N->bool` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1240
  EXISTS_TAC `closure(s):real^N->bool` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1241
  ASM_SIMP_TAC[MEASURABLE_INTERIOR; GMEASURABLE_CLOSURE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1242
  REWRITE_TAC[INTERIOR_SUBSET; CLOSURE_SUBSET] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1243
  ONCE_REWRITE_TAC[REAL_ABS_SUB] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1244
  ASM_SIMP_TAC[GSYM MEASURE_FRONTIER; REAL_ABS_NUM; MEASURE_EQ_0]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1245
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1246
lemma has_gmeasure_elementary: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1247
 "!d s. d division_of s ==> s has_gmeasure (sum d content)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1248
qed   REPEAT STRIP_TAC THEN REWRITE_TAC[has_gmeasure] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1249
  FIRST_ASSUM(ASSUME_TAC o MATCH_MP DIVISION_OF_FINITE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1250
  ASM_SIMP_TAC[LIFT_SUM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1251
  MATCH_MP_TAC HAS_INTEGRAL_COMBINE_DIVISION THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1252
  ASM_REWRITE_TAC[o_THM] THEN REWRITE_TAC[GSYM has_gmeasure] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1253
  ASM_MESON_TAC[HAS_GMEASURE_INTERVAL; division_of]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1254
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1255
lemma gmeasurable_elementary: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1256
 "!d s. d division_of s ==> gmeasurable s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1257
qed   REWRITE_TAC[measurable] THEN MESON_TAC[HAS_GMEASURE_ELEMENTARY]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1258
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1259
lemma measure_elementary: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1260
 "!d s. d division_of s ==> gmeasure s = sum d content"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1261
qed   MESON_TAC[HAS_GMEASURE_ELEMENTARY; MEASURE_UNIQUE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1262
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1263
lemma gmeasurable_inter_interval: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1264
 "!s a b:real^N. gmeasurable s ==> gmeasurable (s \<inter> {a..b})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1265
qed   SIMP_TAC[MEASURABLE_INTER; GMEASURABLE_INTERVAL]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1266
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1267
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1268
(* A nice lemma for negligibility proofs.                                    *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1269
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1270
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1271
lemma STARLIKE_NEGLIGIBLE_BOUNDED_MEASURABLE: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1272
 "!s. gmeasurable s \<and> bounded s \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1273
       (!c x:real^N. 0 \<le> c \<and> x \<in> s \<and> (c % x) \<in> s ==> c = 1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1274
       ==> negligible s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1275
qed   REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1276
  SUBGOAL_THEN `~(0 < measure(s:real^N->bool))`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1277
   (fun th -> ASM_MESON_TAC[th; GMEASURABLE_MEASURE_POS_LT]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1278
  DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1279
  MP_TAC(SPEC `(0:real^N) INSERT s`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1280
      BOUNDED_SUBSET_CLOSED_INTERVAL_SYMMETRIC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1281
  ASM_SIMP_TAC[BOUNDED_INSERT; COMPACT_IMP_BOUNDED; NOT_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1282
  X_GEN_TAC `a:real^N` THEN REWRITE_TAC[INSERT_SUBSET] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1283
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1284
   `?N. EVEN N \<and> 0 < N \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1285
        measure(interval[--a:real^N,a])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1286
         < (N * measure(s:real^N->bool)) / 4 pow dimindex (:N)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1287
  STRIP_ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1288
   [FIRST_ASSUM(MP_TAC o SPEC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1289
     `measure(interval[--a:real^N,a]) * 4 pow (dimindex(:N))` o
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1290
     MATCH_MP REAL_ARCH) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1291
    SIMP_TAC[REAL_LT_RDIV_EQ; REAL_POW_LT; REAL_OF_NUM_LT; ARITH] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1292
    SIMP_TAC[GSYM REAL_LT_LDIV_EQ; ASSUME `0 < measure(s:real^N->bool)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1293
    DISCH_THEN(X_CHOOSE_THEN `N:num` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1294
    EXISTS_TAC `2 * (N DIV 2 + 1)` THEN REWRITE_TAC[EVEN_MULT; ARITH] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1295
    CONJ_TAC THENL [ARITH_TAC; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1296
    FIRST_X_ASSUM(MATCH_MP_TAC o MATCH_MP (REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1297
     `x < a ==> a \<le> b ==> x < b`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1298
    REWRITE_TAC[REAL_OF_NUM_LE] THEN ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1299
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1300
  MP_TAC(ISPECL [`\<Union>(IMAGE (\<lambda>m. IMAGE (\<lambda>x:real^N. (m / N) % x) s)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1301
                                (1..N))`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1302
                  `interval[--a:real^N,a]`] MEASURE_SUBSET) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1303
  MP_TAC(ISPECL [`measure:(real^N->bool)->real`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1304
                 `IMAGE (\<lambda>m. IMAGE (\<lambda>x:real^N. (m / N) % x) s) (1..N)`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1305
                HAS_GMEASURE_DISJOINT_UNIONS) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1306
  SIMP_TAC[FINITE_IMAGE; FINITE_NUMSEG; IMP_CONJ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1307
  REWRITE_TAC[RIGHT_FORALL_IMP_THM; FORALL_IN_IMAGE] THEN ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1308
   [REPEAT STRIP_TAC THEN REWRITE_TAC[GSYM HAS_GMEASURE_MEASURE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1309
    MATCH_MP_TAC GMEASURABLE_SCALING THEN ASM_REWRITE_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1310
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1311
  REWRITE_TAC[RIGHT_IMP_FORALL_THM; IMP_IMP] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1312
  ONCE_REWRITE_TAC[TAUT `(a \<and> b) \<and> ~c ==> d \<longleftrightarrow> a \<and> b \<and> ~d ==> c`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1313
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1314
   `!m n. m \<in> 1..N \<and> n \<in> 1..N \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1315
          ~(DISJOINT (IMAGE (\<lambda>x:real^N. m / N % x) s)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1316
                     (IMAGE (\<lambda>x. n / N % x) s))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1317
          ==> m = n`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1318
  ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1319
   [MAP_EVERY X_GEN_TAC [`m:num`; `n:num`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1320
    REPEAT(DISCH_THEN(CONJUNCTS_THEN2 ASSUME_TAC MP_TAC)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1321
    REWRITE_TAC[DISJOINT; GSYM MEMBER_NOT_EMPTY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1322
    REWRITE_TAC[EXISTS_IN_IMAGE; IN_INTER] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1323
    DISCH_THEN(X_CHOOSE_THEN `x:real^N`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1324
     (CONJUNCTS_THEN2 ASSUME_TAC MP_TAC)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1325
    REWRITE_TAC[IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1326
    DISCH_THEN(X_CHOOSE_THEN `y:real^N`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1327
     (CONJUNCTS_THEN2 MP_TAC ASSUME_TAC)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1328
    DISCH_THEN(MP_TAC o AP_TERM `(%) (N / m) :real^N->real^N`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1329
    SUBGOAL_THEN `~(N = 0) \<and> ~(m = 0)` STRIP_ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1330
     [REWRITE_TAC[REAL_OF_NUM_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1331
      REPEAT(FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [IN_NUMSEG])) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1332
      ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1333
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1334
    FIRST_X_ASSUM(ASSUME_TAC o GEN_REWRITE_RULE (BINDER_CONV o BINDER_CONV)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1335
     [GSYM CONTRAPOS_THM]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1336
    ASM_SIMP_TAC[VECTOR_MUL_ASSOC; REAL_FIELD
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1337
     `~(x = 0) \<and> ~(y = 0) ==> x / y * y / x = 1`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1338
    ASM_SIMP_TAC[REAL_FIELD
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1339
     `~(x = 0) \<and> ~(y = 0) ==> x / y * z / x = z / y`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1340
    REWRITE_TAC[VECTOR_MUL_LID] THEN DISCH_THEN SUBST_ALL_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1341
    FIRST_X_ASSUM(MP_TAC o SPECL [`n / m`; `y:real^N`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1342
    ASM_SIMP_TAC[REAL_LE_DIV; REAL_POS; REAL_FIELD
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1343
     `~(y = 0) ==> (x / y = 1 \<longleftrightarrow> x = y)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1344
    REWRITE_TAC[REAL_OF_NUM_EQ; EQ_SYM_EQ];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1345
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1346
  ANTS_TAC THENL [ASM_MESON_TAC[]; DISCH_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1347
  REWRITE_TAC[NOT_IMP] THEN REPEAT CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1348
   [REWRITE_TAC[measurable] THEN ASM_MESON_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1349
    REWRITE_TAC[MEASURABLE_INTERVAL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1350
    REWRITE_TAC[UNIONS_SUBSET; FORALL_IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1351
    REWRITE_TAC[SUBSET; FORALL_IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1352
    X_GEN_TAC `n:num` THEN DISCH_TAC THEN X_GEN_TAC `x:real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1353
    DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1354
    MP_TAC(ISPECL [`--a:real^N`; `a:real^N`] CONVEX_INTERVAL) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1355
    DISCH_THEN(MP_TAC o REWRITE_RULE[CONVEX_ALT] o CONJUNCT1) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1356
    DISCH_THEN(MP_TAC o SPECL [`0:real^N`; `x:real^N`; `n / N`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1357
    ASM_REWRITE_TAC[VECTOR_MUL_RZERO; VECTOR_ADD_LID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1358
    DISCH_THEN MATCH_MP_TAC THEN SIMP_TAC[REAL_LE_DIV; REAL_POS] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1359
    CONJ_TAC THENL [ASM SET_TAC[]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1360
    FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [IN_NUMSEG]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1361
    DISCH_THEN(MP_TAC o MATCH_MP (ARITH_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1362
     `1 \<le> n \<and> n \<le> N ==> 0 < N \<and> n \<le> N`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1363
    SIMP_TAC[GSYM REAL_OF_NUM_LE; GSYM REAL_OF_NUM_LT; REAL_LE_LDIV_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1364
    SIMP_TAC[REAL_MUL_LID];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1365
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1366
  FIRST_X_ASSUM(SUBST1_TAC o MATCH_MP MEASURE_UNIQUE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1367
  ASM_SIMP_TAC[MEASURE_SCALING; REAL_NOT_LE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1368
  FIRST_X_ASSUM(K ALL_TAC o SPEC `0`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1369
  MATCH_MP_TAC REAL_LTE_TRANS THEN EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1370
   `sum (1..N) (measure o (\<lambda>m. IMAGE (\<lambda>x:real^N. m / N % x) s))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1371
  CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1372
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1373
    MATCH_MP_TAC REAL_EQ_IMP_LE THEN CONV_TAC SYM_CONV THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1374
    MATCH_MP_TAC SUM_IMAGE THEN REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1375
    REPEAT STRIP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1376
    ASM_REWRITE_TAC[SET_RULE `DISJOINT s s \<longleftrightarrow> s = {}`; IMAGE_EQ_EMPTY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1377
    DISCH_THEN SUBST_ALL_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1378
    ASM_MESON_TAC[REAL_LT_REFL; MEASURE_EMPTY]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1379
  FIRST_X_ASSUM(K ALL_TAC o SPEC `0`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1380
  ASM_SIMP_TAC[o_DEF; MEASURE_SCALING; SUM_RMUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1381
  FIRST_ASSUM(MATCH_MP_TAC o MATCH_MP (REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1382
   `x < a ==> a \<le> b ==> x < b`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1383
  ASM_SIMP_TAC[REAL_LE_LDIV_EQ; REAL_POW_LT; REAL_OF_NUM_LT; ARITH] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1384
  ONCE_REWRITE_TAC[REAL_ARITH `(a * b) * c:real = (a * c) * b`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1385
  ASM_SIMP_TAC[REAL_LE_RMUL_EQ] THEN REWRITE_TAC[GSYM SUM_RMUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1386
  REWRITE_TAC[GSYM REAL_POW_MUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1387
  REWRITE_TAC[REAL_ABS_DIV; REAL_ABS_NUM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1388
  FIRST_X_ASSUM(X_CHOOSE_THEN `M:num` SUBST_ALL_TAC o
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1389
        GEN_REWRITE_RULE I [EVEN_EXISTS]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1390
  REWRITE_TAC[GSYM REAL_OF_NUM_MUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1391
  RULE_ASSUM_TAC(REWRITE_RULE[GSYM REAL_OF_NUM_MUL]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1392
  RULE_ASSUM_TAC(REWRITE_RULE[REAL_ARITH `0 < 2 * x \<longleftrightarrow> 0 < x`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1393
  ASM_SIMP_TAC[REAL_FIELD `0 < y ==> x / (2 * y) * 4 = x * 2 / y`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1394
  MATCH_MP_TAC REAL_LE_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1395
  EXISTS_TAC `sum(M..(2*M)) (\<lambda>i. (i * 2 / M) pow dimindex (:N))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1396
  CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1397
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1398
    MATCH_MP_TAC SUM_SUBSET_SIMPLE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1399
    SIMP_TAC[REAL_POW_LE; REAL_LE_MUL; REAL_LE_DIV; REAL_POS] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1400
    REWRITE_TAC[IN_NUMSEG; FINITE_NUMSEG; SUBSET] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1401
    FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [REAL_OF_NUM_LT]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1402
    ARITH_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1403
  MATCH_MP_TAC REAL_LE_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1404
  EXISTS_TAC `sum(M..(2*M)) (\<lambda>i. 2)` THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1405
   [REWRITE_TAC[SUM_CONST_NUMSEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1406
    REWRITE_TAC[ARITH_RULE `(2 * M + 1) - M = M + 1`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1407
    REWRITE_TAC[GSYM REAL_OF_NUM_ADD] THEN REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1408
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1409
  MATCH_MP_TAC SUM_LE THEN REWRITE_TAC[FINITE_NUMSEG; IN_NUMSEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1410
  X_GEN_TAC `n:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1411
  MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `2 pow (dimindex(:N))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1412
  CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1413
   [GEN_REWRITE_TAC LAND_CONV [GSYM REAL_POW_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1414
    MATCH_MP_TAC REAL_POW_MONO THEN REWRITE_TAC[DIMINDEX_GE_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1415
    ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1416
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1417
  MATCH_MP_TAC REAL_POW_LE2 THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1418
  REWRITE_TAC[REAL_POS; ARITH; real_div; REAL_MUL_ASSOC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1419
  ASM_SIMP_TAC[GSYM real_div; REAL_LE_RDIV_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1420
  REWRITE_TAC[REAL_OF_NUM_MUL; REAL_OF_NUM_LE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1421
  UNDISCH_TAC `M:num \<le> n` THEN ARITH_TAC);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1422
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1423
lemma STARLIKE_NEGLIGIBLE_LEMMA: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1424
 "!s. compact s \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1425
       (!c x:real^N. 0 \<le> c \<and> x \<in> s \<and> (c % x) \<in> s ==> c = 1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1426
       ==> negligible s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1427
qed   REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1428
  MATCH_MP_TAC STARLIKE_NEGLIGIBLE_BOUNDED_MEASURABLE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1429
  ASM_MESON_TAC[MEASURABLE_COMPACT; COMPACT_IMP_BOUNDED]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1430
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1431
lemma STARLIKE_NEGLIGIBLE: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1432
 "!s a. closed s \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1433
         (!c x:real^N. 0 \<le> c \<and> (a + x) \<in> s \<and> (a + c % x) \<in> s ==> c = 1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1434
         ==> negligible s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1435
qed   REPEAT STRIP_TAC THEN MATCH_MP_TAC NEGLIGIBLE_TRANSLATION_REV THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1436
  EXISTS_TAC `--a:real^N` THEN ONCE_REWRITE_TAC[NEGLIGIBLE_ON_INTERVALS] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1437
  MAP_EVERY X_GEN_TAC [`u:real^N`; `v:real^N`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1438
  MATCH_MP_TAC STARLIKE_NEGLIGIBLE_LEMMA THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1439
   [MATCH_MP_TAC CLOSED_INTER_COMPACT THEN REWRITE_TAC[COMPACT_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1440
    ASM_SIMP_TAC[CLOSED_TRANSLATION];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1441
    REWRITE_TAC[IN_IMAGE; IN_INTER] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1442
    ONCE_REWRITE_TAC[VECTOR_ARITH `x:real^N = --a + y \<longleftrightarrow> y = a + x`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1443
    REWRITE_TAC[UNWIND_THM2] THEN ASM MESON_TAC[]]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1444
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1445
lemma STARLIKE_NEGLIGIBLE_STRONG: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1446
 "!s a. closed s \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1447
         (!c x:real^N. 0 \<le> c \<and> c < 1 \<and> (a + x) \<in> s
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1448
                       ==> ~((a + c % x) \<in> s))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1449
         ==> negligible s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1450
qed   REPEAT GEN_TAC THEN STRIP_TAC THEN MATCH_MP_TAC STARLIKE_NEGLIGIBLE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1451
  EXISTS_TAC `a:real^N` THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1452
  MAP_EVERY X_GEN_TAC [`c:real`; `x:real^N`] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1453
  MATCH_MP_TAC(REAL_ARITH `~(x < y) \<and> ~(y < x) ==> x = y`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1454
  STRIP_TAC THENL [ASM_MESON_TAC[]; ALL_TAC] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1455
  FIRST_X_ASSUM(MP_TAC o SPECL [`inv c`; `c % x:real^N`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1456
  ASM_REWRITE_TAC[REAL_LE_INV_EQ; VECTOR_MUL_ASSOC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1457
  ASM_SIMP_TAC[REAL_MUL_LINV; REAL_ARITH `1 < c ==> ~(c = 0)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1458
  ASM_REWRITE_TAC[VECTOR_MUL_LID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1459
  GEN_REWRITE_TAC RAND_CONV [GSYM REAL_INV_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1460
  MATCH_MP_TAC REAL_LT_INV2 THEN ASM_REWRITE_TAC[REAL_LT_01]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1461
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1462
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1463
(* In particular.                                                            *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1464
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1465
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1466
lemma NEGLIGIBLE_HYPERPLANE: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1467
 "!a b. ~(a = 0 \<and> b = 0) ==> negligible {x:real^N | a dot x = b}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1468
qed   REPEAT GEN_TAC THEN ASM_CASES_TAC `a:real^N = 0` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1469
  ASM_SIMP_TAC[DOT_LZERO; SET_RULE `{x | F} = {}`; NEGLIGIBLE_EMPTY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1470
  MATCH_MP_TAC STARLIKE_NEGLIGIBLE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1471
  SUBGOAL_THEN `?x:real^N. ~(a dot x = b)` MP_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1472
   [MATCH_MP_TAC(MESON[] `!a:real^N. P a \/ P(--a) ==> ?x. P x`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1473
    EXISTS_TAC `a:real^N` THEN REWRITE_TAC[DOT_RNEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1474
    MATCH_MP_TAC(REAL_ARITH `~(a = 0) ==> ~(a = b) \/ ~(--a = b)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1475
    ASM_REWRITE_TAC[DOT_EQ_0];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1476
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1477
  MATCH_MP_TAC MONO_EXISTS THEN X_GEN_TAC `c:real^N` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1478
  REWRITE_TAC[CLOSED_HYPERPLANE; IN_ELIM_THM; DOT_RADD; DOT_RMUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1479
  MAP_EVERY X_GEN_TAC [`t:real`; `y:real^N`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1480
  DISCH_THEN(MP_TAC o MATCH_MP (REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1481
   `0 \<le> t \<and> ac + ay = b \<and> ac + t * ay = b
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1482
    ==> ((ay = 0 ==> ac = b) \<and> (t - 1) * ay = 0)`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1483
  ASM_SIMP_TAC[REAL_ENTIRE; REAL_SUB_0] THEN CONV_TAC TAUT);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1484
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1485
lemma NEGLIGIBLE_LOWDIM: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1486
 "!s:real^N->bool. dim(s) < dimindex(:N) ==> negligible s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1487
qed   GEN_TAC THEN DISCH_THEN(MP_TAC o MATCH_MP LOWDIM_SUBSET_HYPERPLANE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1488
  DISCH_THEN(X_CHOOSE_THEN `a:real^N` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1489
  MATCH_MP_TAC NEGLIGIBLE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1490
  EXISTS_TAC `span(s):real^N->bool` THEN REWRITE_TAC[SPAN_INC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1491
  MATCH_MP_TAC NEGLIGIBLE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1492
  EXISTS_TAC `{x:real^N | a dot x = 0}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1493
  ASM_SIMP_TAC[NEGLIGIBLE_HYPERPLANE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1494
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1495
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1496
(* Measurability of bounded convex sets.                                     *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1497
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1498
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1499
lemma NEGLIGIBLE_CONVEX_FRONTIER: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1500
 "!s:real^N->bool. convex s ==> negligible(frontier s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1501
qed   SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1502
   `!s:real^N->bool. convex s \<and> (0) \<in> s ==> negligible(frontier s)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1503
  ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1504
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1505
    X_GEN_TAC `s:real^N->bool` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1506
    ASM_CASES_TAC `s:real^N->bool = {}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1507
    ASM_REWRITE_TAC[FRONTIER_EMPTY; NEGLIGIBLE_EMPTY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1508
    FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [GSYM MEMBER_NOT_EMPTY]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1509
    DISCH_THEN(X_CHOOSE_TAC `a:real^N`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1510
    FIRST_X_ASSUM(MP_TAC o SPEC `IMAGE (\<lambda>x:real^N. --a + x) s`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1511
    ASM_SIMP_TAC[CONVEX_TRANSLATION; IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1512
    ASM_REWRITE_TAC[UNWIND_THM2;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1513
                    VECTOR_ARITH `0:real^N = --a + x \<longleftrightarrow> x = a`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1514
    REWRITE_TAC[FRONTIER_TRANSLATION; NEGLIGIBLE_TRANSLATION_EQ]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1515
  REPEAT STRIP_TAC THEN MP_TAC(ISPEC `s:real^N->bool` DIM_SUBSET_UNIV) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1516
  REWRITE_TAC[ARITH_RULE `d:num \<le> e \<longleftrightarrow> d < e \/ d = e`] THEN STRIP_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1517
   [MATCH_MP_TAC NEGLIGIBLE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1518
    EXISTS_TAC `closure s:real^N->bool` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1519
    REWRITE_TAC[frontier; SUBSET_DIFF] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1520
    MATCH_MP_TAC NEGLIGIBLE_LOWDIM THEN ASM_REWRITE_TAC[DIM_CLOSURE];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1521
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1522
  SUBGOAL_THEN `?a:real^N. a \<in> interior s` CHOOSE_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1523
   [X_CHOOSE_THEN `b:real^N->bool` STRIP_ASSUME_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1524
     (ISPEC `s:real^N->bool` BASIS_EXISTS) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1525
    FIRST_X_ASSUM SUBST_ALL_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1526
    MP_TAC(ISPEC `b:real^N->bool` INTERIOR_SIMPLEX_NONEMPTY) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1527
    ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1528
    MATCH_MP_TAC MONO_EXISTS THEN REWRITE_TAC[GSYM SUBSET] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1529
    MATCH_MP_TAC SUBSET_INTERIOR THEN MATCH_MP_TAC HULL_MINIMAL THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1530
    ASM_REWRITE_TAC[INSERT_SUBSET];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1531
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1532
  MATCH_MP_TAC STARLIKE_NEGLIGIBLE_STRONG THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1533
  EXISTS_TAC `a:real^N` THEN REWRITE_TAC[FRONTIER_CLOSED] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1534
  REPEAT GEN_TAC THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1535
  REWRITE_TAC[frontier; IN_DIFF; DE_MORGAN_THM] THEN DISJ2_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1536
  SIMP_TAC[VECTOR_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1537
   `a + c % x:real^N = (a + x) - (1 - c) % ((a + x) - a)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1538
  MATCH_MP_TAC IN_INTERIOR_CLOSURE_CONVEX_SHRINK THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1539
  RULE_ASSUM_TAC(REWRITE_RULE[frontier; IN_DIFF]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1540
  ASM_REWRITE_TAC[] THEN ASM_REAL_ARITH_TAC);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1541
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1542
lemma GMEASURABLE_CONVEX: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1543
 "!s:real^N->bool. convex s \<and> bounded s ==> gmeasurable s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1544
qed   REPEAT STRIP_TAC THEN MATCH_MP_TAC GMEASURABLE_JORDAN THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1545
  ASM_SIMP_TAC[NEGLIGIBLE_CONVEX_FRONTIER]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1546
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1547
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1548
(* Various special cases.                                                    *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1549
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1550
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1551
lemma NEGLIGIBLE_SPHERE: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1552
 "!a r. negligible {x:real^N | dist(a,x) = r}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1553
qed   REWRITE_TAC[GSYM FRONTIER_CBALL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1554
  SIMP_TAC[NEGLIGIBLE_CONVEX_FRONTIER; CONVEX_CBALL]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1555
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1556
lemma GMEASURABLE_BALL: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1557
 "!a r. gmeasurable(ball(a,r))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1558
qed   SIMP_TAC[MEASURABLE_OPEN; BOUNDED_BALL; OPEN_BALL]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1559
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1560
lemma GMEASURABLE_CBALL: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1561
 "!a r. gmeasurable(cball(a,r))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1562
qed   SIMP_TAC[MEASURABLE_COMPACT; COMPACT_CBALL]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1563
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1564
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1565
(* Negligibility of image under non-injective linear map.                    *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1566
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1567
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1568
lemma NEGLIGIBLE_LINEAR_SINGULAR_IMAGE: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1569
 "!f:real^N->real^N s.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1570
        linear f \<and> ~(!x y. f(x) = f(y) ==> x = y)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1571
        ==> negligible(IMAGE f s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1572
qed   REPEAT GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1573
  DISCH_THEN(MP_TAC o MATCH_MP LINEAR_SINGULAR_IMAGE_HYPERPLANE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1574
  DISCH_THEN(X_CHOOSE_THEN `a:real^N` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1575
  MATCH_MP_TAC NEGLIGIBLE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1576
  EXISTS_TAC `{x:real^N | a dot x = 0}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1577
  ASM_SIMP_TAC[NEGLIGIBLE_HYPERPLANE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1578
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1579
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1580
(* Approximation of gmeasurable set by union of intervals.                    *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1581
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1582
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1583
lemma COVERING_LEMMA: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1584
 "!a b:real^N s g.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1585
        s \<subseteq> {a..b} \<and> ~({a<..<b} = {}) \<and> gauge g
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1586
        ==> ?d. COUNTABLE d \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1587
                (!k. k \<in> d ==> k \<subseteq> {a..b} \<and> ~(k = {}) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1588
                                (\<exists>c d. k = {c..d})) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1589
                (!k1 k2. k1 \<in> d \<and> k2 \<in> d \<and> ~(k1 = k2)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1590
                         ==> interior k1 \<inter> interior k2 = {}) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1591
                (!k. k \<in> d ==> ?x. x \<in> (s \<inter> k) \<and> k \<subseteq> g(x)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1592
                s \<subseteq> \<Union>d"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1593
qed   REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1594
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1595
   `?d. COUNTABLE d \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1596
        (!k. k \<in> d ==> k \<subseteq> {a..b} \<and> ~(k = {}) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1597
                        (\<exists>c d:real^N. k = {c..d})) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1598
        (!k1 k2. k1 \<in> d \<and> k2 \<in> d
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1599
                 ==> k1 \<subseteq> k2 \/ k2 \<subseteq> k1 \/
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1600
                     interior k1 \<inter> interior k2 = {}) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1601
        (!x. x \<in> s ==> ?k. k \<in> d \<and> x \<in> k \<and> k \<subseteq> g(x)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1602
        (!k. k \<in> d ==> FINITE {l | l \<in> d \<and> k \<subseteq> l})`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1603
  ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1604
   [EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1605
     `IMAGE (\<lambda>(n,v).
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1606
             interval[(lambda i. a$i + (v$i) / 2 pow n *
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1607
                                       ((b:real^N)$i - (a:real^N)$i)):real^N,
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1608
                      (lambda i. a$i + ((v$i) + 1) / 2 pow n * (b$i - a$i))])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1609
            {n,v | n \<in> (:num) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1610
                   v \<in> {v:num^N | !i. 1 \<le> i \<and> i \<le> dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1611
                                       ==> v$i < 2 EXP n}}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1612
    CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1613
     [MATCH_MP_TAC COUNTABLE_IMAGE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1614
      MATCH_MP_TAC COUNTABLE_PRODUCT_DEPENDENT THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1615
      REWRITE_TAC[NUM_COUNTABLE; IN_UNIV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1616
      GEN_TAC THEN MATCH_MP_TAC FINITE_IMP_COUNTABLE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1617
      MATCH_MP_TAC FINITE_CART THEN REWRITE_TAC[FINITE_NUMSEG_LT];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1618
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1619
    CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1620
     [REWRITE_TAC[FORALL_IN_IMAGE; FORALL_PAIR_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1621
      MAP_EVERY X_GEN_TAC [`n:num`; `v:num^N`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1622
      REWRITE_TAC[IN_ELIM_PAIR_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1623
      REWRITE_TAC[IN_ELIM_THM; IN_UNIV] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1624
      REWRITE_TAC[CONJ_ASSOC] THEN CONJ_TAC THENL [ALL_TAC; MESON_TAC[]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1625
      SIMP_TAC[INTERVAL_NE_EMPTY; SUBSET_INTERVAL; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1626
      REWRITE_TAC[REAL_LE_LADD; REAL_LE_ADDR; REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1627
        `a + x * (b - a) \<le> b \<longleftrightarrow> 0 \<le> (1 - x) * (b - a)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1628
      RULE_ASSUM_TAC(REWRITE_RULE[INTERVAL_NE_EMPTY]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1629
      REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1630
      (MATCH_MP_TAC REAL_LE_MUL ORELSE MATCH_MP_TAC REAL_LE_RMUL) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1631
      ASM_SIMP_TAC[REAL_SUB_LE; REAL_LE_DIV2_EQ; REAL_LT_POW2] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1632
      ASM_SIMP_TAC[REAL_LE_LDIV_EQ; REAL_LE_RDIV_EQ; REAL_LT_POW2] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1633
      REWRITE_TAC[REAL_MUL_LZERO; REAL_POS; REAL_MUL_LID; REAL_LE_ADDR] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1634
      SIMP_TAC[REAL_OF_NUM_ADD; REAL_OF_NUM_POW; REAL_OF_NUM_LE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1635
      ASM_SIMP_TAC[ARITH_RULE `x + 1 \<le> y \<longleftrightarrow> x < y`; REAL_LT_IMP_LE];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1636
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1637
    CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1638
     [ONCE_REWRITE_TAC[IMP_CONJ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1639
      REWRITE_TAC[FORALL_IN_IMAGE; FORALL_PAIR_THM; RIGHT_FORALL_IMP_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1640
      REWRITE_TAC[IN_ELIM_PAIR_THM; IN_UNIV] THEN REWRITE_TAC[IN_ELIM_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1641
      REWRITE_TAC[RIGHT_IMP_FORALL_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1642
      GEN_REWRITE_TAC BINDER_CONV [SWAP_FORALL_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1643
      MATCH_MP_TAC WLOG_LE THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1644
       [REPEAT GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1645
        GEN_REWRITE_TAC RAND_CONV [SWAP_FORALL_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1646
        REPEAT(AP_TERM_TAC THEN ABS_TAC) THEN SET_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1647
        ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1648
      MAP_EVERY X_GEN_TAC [`m:num`; `n:num`] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1649
      MAP_EVERY X_GEN_TAC [`v:num^N`; `w:num^N`] THEN REPEAT DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1650
      REWRITE_TAC[INTERIOR_CLOSED_INTERVAL; SUBSET_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1651
      SIMP_TAC[DISJOINT_INTERVAL; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1652
      MATCH_MP_TAC(TAUT `p \/ q \/ r ==> (a ==> p) \/ (b ==> q) \/ r`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1653
      ONCE_REWRITE_TAC[TAUT `a \<and> b \<and> c \<longleftrightarrow> ~(a \<and> b ==> ~c)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1654
      RULE_ASSUM_TAC(REWRITE_RULE[INTERVAL_NE_EMPTY]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1655
      ASM_SIMP_TAC[REAL_LE_LADD; REAL_LE_RMUL_EQ; REAL_SUB_LT; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1656
      REWRITE_TAC[NOT_IMP; REAL_LE_LADD] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1657
      ASM_SIMP_TAC[REAL_LE_DIV2_EQ; REAL_LT_POW2] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1658
      REWRITE_TAC[REAL_ARITH `~(x + 1 \<le> x)`] THEN DISJ2_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1659
      MATCH_MP_TAC(MESON[]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1660
       `(!i. ~P i ==> Q i) ==> (!i. Q i) \/ (\<exists>i. P i)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1661
      X_GEN_TAC `i:num` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1662
      DISCH_THEN(fun th -> STRIP_TAC THEN MP_TAC th) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1663
      ASM_REWRITE_TAC[DE_MORGAN_THM; REAL_NOT_LE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1664
      UNDISCH_TAC `m:num \<le> n` THEN REWRITE_TAC[LE_EXISTS] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1665
      DISCH_THEN(X_CHOOSE_THEN `p:num` SUBST1_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1666
      ONCE_REWRITE_TAC[ADD_SYM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1667
      REWRITE_TAC[REAL_POW_ADD; real_div; REAL_INV_MUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1668
      REWRITE_TAC[REAL_MUL_ASSOC] THEN REWRITE_TAC[GSYM real_div] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1669
      ASM_SIMP_TAC[REAL_LE_DIV2_EQ; REAL_LT_POW2; REAL_LT_DIV2_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1670
      ASM_SIMP_TAC[REAL_LE_LDIV_EQ; REAL_LE_RDIV_EQ; REAL_LT_POW2;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1671
                   REAL_LT_LDIV_EQ; REAL_LT_RDIV_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1672
      SIMP_TAC[REAL_LT_INTEGERS; INTEGER_CLOSED] THEN REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1673
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1674
    CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1675
     [X_GEN_TAC `x:real^N` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1676
      SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1677
        `?e. 0 < e \<and> !y. (!i. 1 \<le> i \<and> i \<le> dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1678
                                ==> abs((x:real^N)$i - (y:real^N)$i) \<le> e)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1679
                           ==> y \<in> g(x)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1680
      STRIP_ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1681
       [FIRST_ASSUM(MP_TAC o SPEC `x:real^N` o GEN_REWRITE_RULE I [gauge]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1682
        STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1683
        FIRST_ASSUM(MP_TAC o GEN_REWRITE_RULE I [OPEN_CONTAINS_BALL]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1684
        DISCH_THEN(MP_TAC o SPEC `x:real^N`) THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1685
        DISCH_THEN(X_CHOOSE_THEN `e:real` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1686
        EXISTS_TAC `e / 2 / (dimindex(:N))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1687
        ASM_SIMP_TAC[REAL_LT_DIV; REAL_OF_NUM_LT; LE_1; DIMINDEX_GE_1;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1688
                     ARITH] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1689
        X_GEN_TAC `y:real^N` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1690
        MATCH_MP_TAC(SET_RULE `!s. s \<subseteq> t \<and> x \<in> s ==> x \<in> t`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1691
        EXISTS_TAC `ball(x:real^N,e)` THEN ASM_REWRITE_TAC[IN_BALL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1692
        MATCH_MP_TAC(REAL_ARITH `0 < e \<and> x \<le> e / 2 ==> x < e`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1693
        ASM_REWRITE_TAC[dist] THEN MATCH_MP_TAC REAL_LE_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1694
        EXISTS_TAC `sum(1..dimindex(:N)) (\<lambda>i. abs((x - y:real^N)$i))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1695
        REWRITE_TAC[NORM_LE_L1] THEN MATCH_MP_TAC SUM_BOUND_GEN THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1696
        ASM_SIMP_TAC[IN_NUMSEG; FINITE_NUMSEG; NUMSEG_EMPTY; NOT_LT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1697
                     DIMINDEX_GE_1; VECTOR_SUB_COMPONENT; CARD_NUMSEG_1];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1698
        ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1699
      REWRITE_TAC[EXISTS_IN_IMAGE; EXISTS_PAIR_THM; IN_ELIM_PAIR_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1700
      MP_TAC(SPECL [`1 / 2`; `e / norm(b - a:real^N)`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1701
        REAL_ARCH_POW_INV) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1702
      SUBGOAL_THEN `0 < norm(b - a:real^N)` ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1703
       [ASM_MESON_TAC[VECTOR_SUB_EQ; NORM_POS_LT; INTERVAL_SING]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1704
      CONV_TAC REAL_RAT_REDUCE_CONV THEN ASM_SIMP_TAC[REAL_LT_DIV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1705
      MATCH_MP_TAC MONO_EXISTS THEN X_GEN_TAC `n:num` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1706
      REWRITE_TAC[real_div; REAL_MUL_LID; REAL_POW_INV] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1707
      SIMP_TAC[IN_ELIM_THM; IN_INTERVAL; SUBSET; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1708
      MATCH_MP_TAC(MESON[]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1709
       `(!x. Q x ==> R x) \<and> (\<exists>x. P x \<and> Q x) ==> ?x. P x \<and> Q x \<and> R x`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1710
      CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1711
       [REWRITE_TAC[RIGHT_IMP_FORALL_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1712
        MAP_EVERY X_GEN_TAC [`w:num^N`; `y:real^N`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1713
        REWRITE_TAC[IMP_IMP; AND_FORALL_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1714
        DISCH_THEN(fun th -> FIRST_X_ASSUM MATCH_MP_TAC THEN MP_TAC th) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1715
        MATCH_MP_TAC MONO_FORALL THEN X_GEN_TAC `i:num` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1716
        DISCH_THEN(fun th -> STRIP_TAC THEN MP_TAC th) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1717
        ASM_REWRITE_TAC[] THEN DISCH_THEN(MP_TAC o MATCH_MP (REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1718
         `(a + n \<le> x \<and> x \<le> a + m) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1719
          (a + n \<le> y \<and> y \<le> a + m) ==> abs(x - y) \<le> m - n`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1720
        MATCH_MP_TAC(REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1721
         `y * z \<le> e
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1722
          ==> a \<le> ((x + 1) * y) * z - ((x * y) * z) ==> a \<le> e`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1723
        RULE_ASSUM_TAC(REWRITE_RULE[INTERVAL_NE_EMPTY]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1724
        ASM_SIMP_TAC[GSYM REAL_LE_RDIV_EQ; REAL_SUB_LT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1725
        FIRST_X_ASSUM(MATCH_MP_TAC o MATCH_MP
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1726
        (REAL_ARITH `n < e * x ==> 0 \<le> e * (inv y - x) ==> n \<le> e / y`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1727
        MATCH_MP_TAC REAL_LE_MUL THEN ASM_SIMP_TAC[REAL_LT_IMP_LE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1728
        REWRITE_TAC[REAL_SUB_LE] THEN MATCH_MP_TAC REAL_LE_INV2 THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1729
        ASM_SIMP_TAC[REAL_SUB_LT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1730
        MP_TAC(SPECL [`b - a:real^N`; `i:num`] COMPONENT_LE_NORM) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1731
        ASM_SIMP_TAC[VECTOR_SUB_COMPONENT] THEN REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1732
        ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1733
      REWRITE_TAC[IN_UNIV; AND_FORALL_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1734
      REWRITE_TAC[TAUT `(a ==> c) \<and> (a ==> b) \<longleftrightarrow> a ==> b \<and> c`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1735
      REWRITE_TAC[GSYM LAMBDA_SKOLEM] THEN X_GEN_TAC `i:num` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1736
      STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1737
      SUBGOAL_THEN `(x:real^N) \<in> {a..b}` MP_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1738
       [ASM SET_TAC[]; ALL_TAC] THEN REWRITE_TAC[IN_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1739
      DISCH_THEN(MP_TAC o SPEC `i:num`) THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1740
      RULE_ASSUM_TAC(REWRITE_RULE[INTERVAL_NE_EMPTY]) THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1741
      DISJ_CASES_TAC(MATCH_MP (REAL_ARITH `x \<le> y ==> x = y \/ x < y`)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1742
       (ASSUME `(x:real^N)$i \<le> (b:real^N)$i`))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1743
      THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1744
       [EXISTS_TAC `2 EXP n - 1` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1745
        SIMP_TAC[GSYM REAL_OF_NUM_SUB; GSYM REAL_OF_NUM_LT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1746
                 EXP_LT_0; LE_1; ARITH] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1747
        ASM_REWRITE_TAC[REAL_SUB_ADD; REAL_ARITH `a - 1 < a`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1748
        MATCH_MP_TAC(REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1749
         `1 * (b - a) = x \<and> y \<le> x ==> a + y \<le> b \<and> b \<le> a + x`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1750
        ASM_SIMP_TAC[REAL_EQ_MUL_RCANCEL; REAL_LT_IMP_NZ; REAL_LE_RMUL_EQ;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1751
                     REAL_SUB_LT; REAL_LT_INV_EQ; REAL_LT_POW2] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1752
        SIMP_TAC[GSYM REAL_OF_NUM_POW; REAL_MUL_RINV; REAL_POW_EQ_0;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1753
                 REAL_OF_NUM_EQ; ARITH_EQ] THEN REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1754
        ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1755
      MP_TAC(SPEC `2 pow n * ((x:real^N)$i - (a:real^N)$i) /
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1756
                              ((b:real^N)$i - (a:real^N)$i)` FLOOR_POS) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1757
      ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1758
       [ASM_MESON_TAC[REAL_LE_MUL; REAL_LE_MUL; REAL_POW_LE; REAL_POS;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1759
                      REAL_SUB_LE; REAL_LT_IMP_LE; REAL_LE_DIV];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1760
        ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1761
      MATCH_MP_TAC MONO_EXISTS THEN X_GEN_TAC `m:num` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1762
      REWRITE_TAC[GSYM REAL_OF_NUM_LT; GSYM REAL_OF_NUM_POW] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1763
      DISCH_THEN(SUBST_ALL_TAC o SYM) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1764
      REWRITE_TAC[REAL_ARITH `a + b * c \<le> x \<and> x \<le> a + b' * c \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1765
                              b * c \<le> x - a \<and> x - a \<le> b' * c`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1766
      ASM_SIMP_TAC[GSYM REAL_LE_LDIV_EQ; GSYM REAL_LE_RDIV_EQ;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1767
                   REAL_SUB_LT; GSYM real_div] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1768
      ONCE_REWRITE_TAC[REAL_MUL_SYM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1769
      SIMP_TAC[REAL_LE_LDIV_EQ; REAL_LE_RDIV_EQ; REAL_LT_POW2] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1770
      SIMP_TAC[FLOOR; REAL_LT_IMP_LE] THEN MATCH_MP_TAC REAL_LET_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1771
      EXISTS_TAC `((x:real^N)$i - (a:real^N)$i) /
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1772
                  ((b:real^N)$i - (a:real^N)$i) *
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1773
                  2 pow n` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1774
      REWRITE_TAC[FLOOR] THEN GEN_REWRITE_TAC RAND_CONV [GSYM REAL_MUL_LID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1775
      ASM_SIMP_TAC[REAL_LT_RMUL_EQ; REAL_LT_POW2] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1776
      ASM_SIMP_TAC[REAL_LT_LDIV_EQ; REAL_MUL_LID; REAL_SUB_LT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1777
      ASM_REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1778
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1779
    REWRITE_TAC[FORALL_IN_IMAGE; FORALL_PAIR_THM; IN_ELIM_PAIR_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1780
    MAP_EVERY X_GEN_TAC [`n:num`; `v:num^N`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1781
    REWRITE_TAC[IN_ELIM_THM; IN_UNIV] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1782
    MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1783
     `IMAGE (\<lambda>(n,v).
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1784
            interval[(lambda i. a$i + (v$i) / 2 pow n *
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1785
                                      ((b:real^N)$i - (a:real^N)$i)):real^N,
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1786
                     (lambda i. a$i + ((v$i) + 1) / 2 pow n * (b$i - a$i))])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1787
            {m,v | m \<in> 0..n \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1788
                   v \<in> {v:num^N | !i. 1 \<le> i \<and> i \<le> dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1789
                                       ==> v$i < 2 EXP m}}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1790
    CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1791
     [MATCH_MP_TAC FINITE_IMAGE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1792
      MATCH_MP_TAC FINITE_PRODUCT_DEPENDENT THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1793
      REWRITE_TAC[FINITE_NUMSEG] THEN REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1794
      MATCH_MP_TAC FINITE_CART THEN REWRITE_TAC[FINITE_NUMSEG_LT];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1795
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1796
    GEN_REWRITE_TAC I [SUBSET] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1797
    REWRITE_TAC[IN_ELIM_THM] THEN ONCE_REWRITE_TAC[IMP_CONJ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1798
    REWRITE_TAC[FORALL_IN_IMAGE; FORALL_PAIR_THM; IN_ELIM_PAIR_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1799
    MAP_EVERY X_GEN_TAC [`m:num`; `w:num^N`] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1800
    DISCH_TAC THEN SIMP_TAC[IN_IMAGE; EXISTS_PAIR_THM; IN_ELIM_PAIR_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1801
    MAP_EVERY EXISTS_TAC [`m:num`; `w:num^N`] THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1802
    REWRITE_TAC[IN_NUMSEG; GSYM NOT_LT; LT] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1803
    FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [SUBSET_INTERVAL]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1804
    SIMP_TAC[NOT_IMP; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1805
    RULE_ASSUM_TAC(REWRITE_RULE[INTERVAL_NE_EMPTY]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1806
    ASM_SIMP_TAC[REAL_LE_LADD; REAL_LE_RMUL_EQ; REAL_SUB_LT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1807
    ASM_SIMP_TAC[REAL_LE_DIV2_EQ; REAL_LT_POW2] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1808
    REWRITE_TAC[REAL_ARITH `x \<le> x + 1`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1809
    DISCH_THEN(MP_TAC o SPEC `1`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1810
    REWRITE_TAC[LE_REFL; DIMINDEX_GE_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1811
    DISCH_THEN(MP_TAC o MATCH_MP (REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1812
     `w / m \<le> v / n \<and> (v + 1) / n \<le> (w + 1) / m
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1813
      ==> inv n \<le> inv m`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1814
    REWRITE_TAC[REAL_NOT_LE] THEN MATCH_MP_TAC REAL_LT_INV2 THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1815
    ASM_REWRITE_TAC[REAL_LT_POW2] THEN MATCH_MP_TAC REAL_POW_MONO_LT THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1816
    ASM_REWRITE_TAC[] THEN CONV_TAC REAL_RAT_REDUCE_CONV;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1817
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1818
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1819
   `?d. COUNTABLE d \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1820
        (!k. k \<in> d ==> k \<subseteq> {a..b} \<and> ~(k = {}) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1821
                        (\<exists>c d:real^N. k = {c..d})) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1822
        (!k1 k2. k1 \<in> d \<and> k2 \<in> d
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1823
                 ==> k1 \<subseteq> k2 \/ k2 \<subseteq> k1 \/
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1824
                     interior k1 \<inter> interior k2 = {}) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1825
        (!k. k \<in> d ==> (\<exists>x. x \<in> s \<inter> k \<and> k \<subseteq> g x)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1826
        (!k. k \<in> d ==> FINITE {l | l \<in> d \<and> k \<subseteq> l}) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1827
        s \<subseteq> \<Union>d`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1828
  MP_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1829
   [FIRST_X_ASSUM(X_CHOOSE_THEN `d:(real^N->bool)->bool` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1830
    EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1831
     `{k:real^N->bool | k \<in> d \<and> ?x. x \<in> (s \<inter> k) \<and> k \<subseteq> g x}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1832
    ASM_SIMP_TAC[IN_ELIM_THM] THEN REPEAT CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1833
     [MATCH_MP_TAC COUNTABLE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1834
      EXISTS_TAC `d:(real^N->bool)->bool` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1835
      ASM_REWRITE_TAC[] THEN SET_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1836
      X_GEN_TAC `k:real^N->bool` THEN REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1837
      MATCH_MP_TAC FINITE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1838
      EXISTS_TAC `{l:real^N->bool | l \<in> d \<and> k \<subseteq> l}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1839
      ASM_REWRITE_TAC[] THEN SET_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1840
      ASM SET_TAC[]];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1841
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1842
  DISCH_THEN(X_CHOOSE_THEN `d:(real^N->bool)->bool` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1843
  EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1844
   `{k:real^N->bool | k \<in> d \<and> !k'. k' \<in> d \<and> ~(k = k')
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1845
                                     ==> ~(k \<subseteq> k')}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1846
  ASM_SIMP_TAC[IN_ELIM_THM] THEN REPEAT CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1847
   [MATCH_MP_TAC COUNTABLE_SUBSET THEN EXISTS_TAC `d:(real^N->bool)->bool` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1848
    ASM_REWRITE_TAC[] THEN SET_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1849
    ASM SET_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1850
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1851
  FIRST_X_ASSUM(MATCH_MP_TAC o MATCH_MP
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1852
   (REWRITE_RULE[IMP_CONJ] SUBSET_TRANS)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1853
  GEN_REWRITE_TAC I [SUBSET] THEN REWRITE_TAC[FORALL_IN_UNIONS] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1854
  MAP_EVERY X_GEN_TAC [`k:real^N->bool`; `x:real^N`] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1855
  REWRITE_TAC[IN_UNIONS; IN_ELIM_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1856
  MP_TAC(ISPEC `\k l:real^N->bool. k \<in> d \<and> l \<in> d \<and> l \<subseteq> k \<and> ~(k = l)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1857
     WF_FINITE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1858
  REWRITE_TAC[WF] THEN ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1859
   [CONJ_TAC THENL [SET_TAC[]; ALL_TAC] THEN X_GEN_TAC `l:real^N->bool` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1860
    ASM_CASES_TAC `(l:real^N->bool) \<in> d` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1861
    ASM_REWRITE_TAC[EMPTY_GSPEC; FINITE_RULES] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1862
    MATCH_MP_TAC FINITE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1863
    EXISTS_TAC `{m:real^N->bool | m \<in> d \<and> l \<subseteq> m}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1864
    ASM_SIMP_TAC[] THEN SET_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1865
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1866
  DISCH_THEN(MP_TAC o SPEC `\l:real^N->bool. l \<in> d \<and> x \<in> l`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1867
  REWRITE_TAC[] THEN ANTS_TAC THENL [SET_TAC[]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1868
  MATCH_MP_TAC MONO_EXISTS THEN ASM SET_TAC[]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1869
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1870
lemma GMEASURABLE_OUTER_INTERVALS_BOUNDED: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1871
 "!s a b:real^N e.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1872
        gmeasurable s \<and> s \<subseteq> {a..b} \<and> 0 < e
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1873
        ==> ?d. COUNTABLE d \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1874
                (!k. k \<in> d ==> k \<subseteq> {a..b} \<and> ~(k = {}) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1875
                                (\<exists>c d. k = {c..d})) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1876
                (!k1 k2. k1 \<in> d \<and> k2 \<in> d \<and> ~(k1 = k2)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1877
                         ==> interior k1 \<inter> interior k2 = {}) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1878
                s \<subseteq> \<Union>d \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1879
                gmeasurable (\<Union>d) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1880
                gmeasure (\<Union>d) \<le> gmeasure s + e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1881
qed   lemma lemma = prove
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1882
   (`(!x y. (x,y) \<in> IMAGE (\<lambda>z. f z,g z) s ==> P x y) \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1883
     (!z. z \<in> s ==> P (f z) (g z))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1884
qed   REWRITE_TAC[IN_IMAGE; PAIR_EQ] THEN MESON_TAC[]) in
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1885
  REPEAT GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1886
  ASM_CASES_TAC `interval[a:real^N,b] = {}` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1887
   [ASM_REWRITE_TAC[SUBSET_EMPTY] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1888
    EXISTS_TAC `{}:(real^N->bool)->bool` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1889
    ASM_REWRITE_TAC[NOT_IN_EMPTY; UNIONS_0; MEASURE_EMPTY; REAL_ADD_LID;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1890
                    SUBSET_REFL; COUNTABLE_EMPTY; GMEASURABLE_EMPTY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1891
    ASM_SIMP_TAC[REAL_LT_IMP_LE];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1892
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1893
  STRIP_TAC THEN ASM_CASES_TAC `interval(a:real^N,b) = {}` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1894
   [EXISTS_TAC `{interval[a:real^N,b]}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1895
    REWRITE_TAC[UNIONS_1; COUNTABLE_SING] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1896
    ASM_REWRITE_TAC[IMP_CONJ; RIGHT_FORALL_IMP_THM; FORALL_IN_INSERT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1897
                    NOT_IN_EMPTY; SUBSET_REFL; GMEASURABLE_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1898
    CONJ_TAC THENL [MESON_TAC[]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1899
    SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1900
     `measure(interval[a:real^N,b]) = 0 \<and> measure(s:real^N->bool) = 0`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1901
     (fun th -> ASM_SIMP_TAC[th; REAL_LT_IMP_LE; REAL_ADD_LID]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1902
    SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1903
      `interval[a:real^N,b] has_gmeasure 0 \<and> (s:real^N->bool) has_gmeasure 0`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1904
      (fun th -> MESON_TAC[th; MEASURE_UNIQUE]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1905
    REWRITE_TAC[HAS_GMEASURE_0] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1906
    MATCH_MP_TAC(TAUT `a \<and> (a ==> b) ==> a \<and> b`) THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1907
     [ASM_REWRITE_TAC[NEGLIGIBLE_INTERVAL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1908
      ASM_MESON_TAC[NEGLIGIBLE_SUBSET]];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1909
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1910
  FIRST_ASSUM(MP_TAC o GEN_REWRITE_RULE I [measurable]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1911
  DISCH_THEN(X_CHOOSE_TAC `m:real`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1912
  FIRST_ASSUM(ASSUME_TAC o MATCH_MP MEASURE_UNIQUE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1913
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1914
   `((\<lambda>x:real^N. if x \<in> s then 1 else 0) has_integral (lift m))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1915
    {a..b}`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1916
  ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1917
   [ONCE_REWRITE_TAC[GSYM HAS_INTEGRAL_RESTRICT_UNIV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1918
    FIRST_ASSUM(MP_TAC o GEN_REWRITE_RULE I [HAS_GMEASURE]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1919
    MATCH_MP_TAC(REWRITE_RULE[IMP_CONJ] HAS_INTEGRAL_EQ) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1920
    ASM SET_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1921
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1922
  FIRST_ASSUM(ASSUME_TAC o MATCH_MP HAS_INTEGRAL_INTEGRABLE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1923
  FIRST_ASSUM(MP_TAC o GEN_REWRITE_RULE I [has_integral]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1924
  DISCH_THEN(MP_TAC o SPEC `e:real`) THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1925
  DISCH_THEN(X_CHOOSE_THEN `g:real^N->real^N->bool` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1926
  MP_TAC(SPECL [`a:real^N`; `b:real^N`; `s:real^N->bool`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1927
                `g:real^N->real^N->bool`] COVERING_LEMMA) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1928
  ASM_REWRITE_TAC[] THEN MATCH_MP_TAC MONO_EXISTS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1929
  X_GEN_TAC `d:(real^N->bool)->bool` THEN STRIP_TAC THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1930
  MP_TAC(ISPECL [`(\<lambda>x. if x \<in> s then 1 else 0):real^N->real^1`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1931
                 `a:real^N`; `b:real^N`; `g:real^N->real^N->bool`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1932
                 `e:real`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1933
                HENSTOCK_LEMMA_PART1) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1934
  ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1935
  FIRST_ASSUM(SUBST1_TAC o MATCH_MP INTEGRAL_UNIQUE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1936
  ASM_REWRITE_TAC[] THEN DISCH_THEN(LABEL_TAC "*") THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1937
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1938
   `!k l:real^N->bool. k \<in> d \<and> l \<in> d \<and> ~(k = l)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1939
                       ==> negligible(k \<inter> l)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1940
  ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1941
   [REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1942
    FIRST_X_ASSUM(MP_TAC o SPECL [`k:real^N->bool`; `l:real^N->bool`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1943
    ASM_SIMP_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1944
    SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1945
     `?x y:real^N u v:real^N. k = {x..y} \<and> l = {u..v}`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1946
    MP_TAC THENL [ASM_MESON_TAC[SUBSET]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1947
    DISCH_THEN(REPEAT_TCL CHOOSE_THEN (CONJUNCTS_THEN SUBST_ALL_TAC)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1948
    REWRITE_TAC[INTERIOR_CLOSED_INTERVAL] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1949
    MATCH_MP_TAC NEGLIGIBLE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1950
    EXISTS_TAC `(interval[x:real^N,y] DIFF {x<..<y}) UNION
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1951
                (interval[u:real^N,v] DIFF {u<..<v}) UNION
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1952
                (interval (x,y) \<inter> interval (u,v))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1953
    CONJ_TAC THENL [ALL_TAC; SET_TAC[]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1954
    ASM_REWRITE_TAC[UNION_EMPTY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1955
    SIMP_TAC[NEGLIGIBLE_UNION; NEGLIGIBLE_FRONTIER_INTERVAL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1956
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1957
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1958
   `!D. FINITE D \<and> D \<subseteq> d
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1959
         ==> gmeasurable(\<Union>D :real^N->bool) \<and> measure(\<Union>D) \<le> m + e`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1960
  ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1961
   [GEN_TAC THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1962
    SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1963
     `?t:(real^N->bool)->real^N. !k. k \<in> D ==> t(k) \<in> (s \<inter> k) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1964
                                                k \<subseteq> (g(t k))`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1965
    (CHOOSE_THEN (LABEL_TAC "+")) THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1966
     [REWRITE_TAC[GSYM SKOLEM_THM] THEN ASM SET_TAC[]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1967
    REMOVE_THEN "*" (MP_TAC o SPEC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1968
     `IMAGE (\<lambda>k. (t:(real^N->bool)->real^N) k,k) D`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1969
    ASM_SIMP_TAC[VSUM_IMAGE; PAIR_EQ] THEN REWRITE_TAC[o_DEF] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1970
    ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1971
     [REWRITE_TAC[tagged_partial_division_of; fine] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1972
      ASM_SIMP_TAC[FINITE_IMAGE; FORALL_IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1973
      REWRITE_TAC[lemma; RIGHT_FORALL_IMP_THM; IMP_CONJ; PAIR_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1974
      ASM_SIMP_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1975
      CONJ_TAC THENL [ASM SET_TAC[]; ASM_MESON_TAC[SUBSET]];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1976
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1977
    USE_THEN "+" (MP_TAC o REWRITE_RULE[IN_INTER]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1978
    SIMP_TAC[] THEN DISCH_THEN(K ALL_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1979
    ASM_SIMP_TAC[VSUM_SUB] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1980
    SUBGOAL_THEN `D division_of (\<Union>D:real^N->bool)` ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1981
     [REWRITE_TAC[division_of] THEN ASM SET_TAC[]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1982
    FIRST_ASSUM(ASSUME_TAC o MATCH_MP GMEASURABLE_ELEMENTARY) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1983
    SUBGOAL_THEN `vsum D (\<lambda>k:real^N->bool. content k % 1) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1984
                  lift(measure(\<Union>D))`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1985
    SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1986
     [ONCE_REWRITE_TAC[GSYM _EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1987
      ASM_SIMP_TAC[LIFT_; _VSUM; o_DEF; _CMUL; _VEC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1988
      SIMP_TAC[REAL_MUL_RID; ETA_AX] THEN ASM_MESON_TAC[MEASURE_ELEMENTARY];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1989
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1990
    SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1991
     `vsum D (\<lambda>k. integral k (\<lambda>x:real^N. if x \<in> s then 1 else 0)) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1992
      lift(sum D (\<lambda>k. measure(k \<inter> s)))`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1993
    SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1994
     [ASM_SIMP_TAC[LIFT_SUM; o_DEF] THEN MATCH_MP_TAC VSUM_EQ THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1995
      X_GEN_TAC `k:real^N->bool` THEN DISCH_TAC THEN REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1996
      SUBGOAL_THEN `measurable(k:real^N->bool)` ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1997
       [ASM_MESON_TAC[SUBSET; GMEASURABLE_INTERVAL]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1998
      ASM_SIMP_TAC[GSYM INTEGRAL_MEASURE_UNIV; GMEASURABLE_INTER] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1999
      REWRITE_TAC[MESON[IN_INTER]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2000
        `(if x \<in> k \<inter> s then a else b) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2001
         (if x \<in> k then if x \<in> s then a else b else b)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2002
      CONV_TAC SYM_CONV THEN MATCH_MP_TAC INTEGRAL_RESTRICT_UNIV THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2003
      ONCE_REWRITE_TAC[GSYM INTEGRABLE_RESTRICT_UNIV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2004
      REWRITE_TAC[MESON[IN_INTER]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2005
       `(if x \<in> k then if x \<in> s then a else b else b) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2006
        (if x \<in> k \<inter> s then a else b)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2007
      ASM_SIMP_TAC[GSYM GMEASURABLE_INTEGRABLE; GMEASURABLE_INTER];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2008
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2009
    ASM_REWRITE_TAC[GSYM LIFT_SUB; NORM_LIFT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2010
    MATCH_MP_TAC(REAL_ARITH `y \<le> m ==> abs(x - y) \<le> e ==> x \<le> m + e`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2011
    MATCH_MP_TAC REAL_LE_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2012
    EXISTS_TAC `measure(\<Union>D \<inter> s:real^N->bool)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2013
    CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2014
     [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2015
      EXPAND_TAC "m" THEN MATCH_MP_TAC MEASURE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2016
      ASM_REWRITE_TAC[] THEN CONJ_TAC THENL [ALL_TAC; SET_TAC[]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2017
      MATCH_MP_TAC GMEASURABLE_INTER THEN ASM_REWRITE_TAC[]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2018
    REWRITE_TAC[INTER_UNIONS] THEN MATCH_MP_TAC REAL_EQ_IMP_LE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2019
    ONCE_REWRITE_TAC[SIMPLE_IMAGE] THEN CONV_TAC SYM_CONV THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2020
    MATCH_MP_TAC MEASURE_NEGLIGIBLE_UNIONS_IMAGE_STRONG THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2021
    ASM_SIMP_TAC[FINITE_RESTRICT] THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2022
     [ASM_MESON_TAC[SUBSET; GMEASURABLE_INTERVAL; GMEASURABLE_INTER];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2023
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2024
    MAP_EVERY X_GEN_TAC [`k:real^N->bool`; `l:real^N->bool`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2025
    STRIP_TAC THEN MATCH_MP_TAC NEGLIGIBLE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2026
    EXISTS_TAC `k \<inter> l:real^N->bool` THEN ASM_SIMP_TAC[] THEN SET_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2027
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2028
  ASM_CASES_TAC `FINITE(d:(real^N->bool)->bool)` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2029
   [ASM_MESON_TAC[SUBSET_REFL]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2030
  MP_TAC(ISPEC `d:(real^N->bool)->bool` COUNTABLE_AS_INJECTIVE_IMAGE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2031
  ASM_REWRITE_TAC[INFINITE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2032
  DISCH_THEN(X_CHOOSE_THEN `s:num->real^N->bool`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2033
   (CONJUNCTS_THEN2 SUBST_ALL_TAC ASSUME_TAC)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2034
  MP_TAC(ISPECL [`s:num->real^N->bool`; `m + e:real`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2035
    HAS_GMEASURE_COUNTABLE_NEGLIGIBLE_UNIONS) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2036
  MATCH_MP_TAC(TAUT `a \<and> (a \<and> b ==> c) ==> (a ==> b) ==> c`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2037
  REWRITE_TAC[GSYM CONJ_ASSOC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2038
  RULE_ASSUM_TAC(REWRITE_RULE[IMP_CONJ; RIGHT_FORALL_IMP_THM;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2039
                              FORALL_IN_IMAGE; IN_UNIV]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2040
  RULE_ASSUM_TAC(REWRITE_RULE[IMP_IMP; RIGHT_IMP_FORALL_THM]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2041
  REPEAT CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2042
   [ASM_MESON_TAC[MEASURABLE_INTERVAL; GMEASURABLE_INTER];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2043
    ASM_MESON_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2044
    X_GEN_TAC `n:num` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2045
    FIRST_X_ASSUM(MP_TAC o SPEC `IMAGE (s:num->real^N->bool) (0..n)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2046
    SIMP_TAC[FINITE_IMAGE; FINITE_NUMSEG; IMAGE_SUBSET; SUBSET_UNIV] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2047
    DISCH_THEN(CONJUNCTS_THEN2 ASSUME_TAC MP_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2048
    MATCH_MP_TAC(REAL_ARITH `x = y ==> x \<le> e ==> y \<le> e`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2049
    MATCH_MP_TAC MEASURE_NEGLIGIBLE_UNIONS_IMAGE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2050
    ASM_MESON_TAC[FINITE_NUMSEG; GMEASURABLE_INTERVAL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2051
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2052
  ONCE_REWRITE_TAC[SIMPLE_IMAGE] THEN STRIP_TAC THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2053
  GEN_REWRITE_TAC LAND_CONV [GSYM(CONJUNCT2 LIFT_)] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2054
  REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2055
  MATCH_MP_TAC(ISPEC `sequentially` LIM_COMPONENT_UBOUND) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2056
  EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2057
   `\n. vsum(from 0 \<inter> (0..n)) (\<lambda>n. lift(measure(s n:real^N->bool)))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2058
  ASM_REWRITE_TAC[GSYM sums; TRIVIAL_LIMIT_SEQUENTIALLY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2059
  REWRITE_TAC[DIMINDEX_1; ARITH; EVENTUALLY_SEQUENTIALLY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2060
  SIMP_TAC[VSUM_COMPONENT; ARITH; DIMINDEX_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2061
  ASM_REWRITE_TAC[GSYM ; LIFT_; FROM_INTER_NUMSEG]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2062
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2063
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2064
(* Hence for linear transformation, suffices to check compact intervals.     *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2065
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2066
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2067
lemma GMEASURABLE_LINEAR_IMAGE_INTERVAL: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2068
 "!f a b. linear f ==> gmeasurable(IMAGE f {a..b})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2069
qed   REPEAT STRIP_TAC THEN MATCH_MP_TAC GMEASURABLE_CONVEX THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2070
   [MATCH_MP_TAC CONVEX_LINEAR_IMAGE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2071
    ASM_MESON_TAC[CONVEX_INTERVAL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2072
    MATCH_MP_TAC BOUNDED_LINEAR_IMAGE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2073
    ASM_MESON_TAC[BOUNDED_INTERVAL]]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2074
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2075
lemma HAS_GMEASURE_LINEAR_SUFFICIENT: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2076
 "!f:real^N->real^N m.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2077
        linear f \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2078
        (!a b. IMAGE f {a..b} has_gmeasure
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2079
               (m * measure{a..b}))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2080
        ==> !s. gmeasurable s ==> (IMAGE f s) has_gmeasure (m * gmeasure s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2081
qed   REPEAT GEN_TAC THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2082
  DISJ_CASES_TAC(REAL_ARITH `m < 0 \/ 0 \<le> m`) THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2083
   [FIRST_X_ASSUM(MP_TAC o SPECL [`0:real^N`; `1:real^N`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2084
    DISCH_THEN(MP_TAC o MATCH_MP HAS_GMEASURE_POS_LE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2085
    MATCH_MP_TAC(TAUT `~a ==> a ==> b`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2086
    MATCH_MP_TAC(REAL_ARITH `0 < --m * x ==> ~(0 \<le> m * x)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2087
    MATCH_MP_TAC REAL_LT_MUL THEN ASM_REWRITE_TAC[REAL_NEG_GT0] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2088
    REWRITE_TAC[MEASURE_INTERVAL] THEN MATCH_MP_TAC CONTENT_POS_LT THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2089
    SIMP_TAC[VEC_COMPONENT; REAL_LT_01];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2090
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2091
  ASM_CASES_TAC `!x y. (f:real^N->real^N) x = f y ==> x = y` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2092
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2093
    SUBGOAL_THEN `!s. negligible(IMAGE (f:real^N->real^N) s)` ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2094
     [ASM_MESON_TAC[NEGLIGIBLE_LINEAR_SINGULAR_IMAGE]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2095
    SUBGOAL_THEN `m * measure(interval[0:real^N,1]) = 0` MP_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2096
     [MATCH_MP_TAC(ISPEC `IMAGE (f:real^N->real^N) {0..1}`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2097
        HAS_GMEASURE_UNIQUE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2098
      ASM_REWRITE_TAC[HAS_GMEASURE_0];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2099
      REWRITE_TAC[REAL_ENTIRE; MEASURE_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2100
      MATCH_MP_TAC(TAUT `~b \<and> (a ==> c) ==> a \/ b ==> c`) THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2101
       [SIMP_TAC[CONTENT_EQ_0_INTERIOR; INTERIOR_CLOSED_INTERVAL;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2102
                 INTERVAL_NE_EMPTY; VEC_COMPONENT; REAL_LT_01];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2103
        ASM_SIMP_TAC[REAL_MUL_LZERO; HAS_GMEASURE_0]]]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2104
  MP_TAC(ISPEC `f:real^N->real^N` LINEAR_INJECTIVE_ISOMORPHISM) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2105
  ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2106
  DISCH_THEN(X_CHOOSE_THEN `h:real^N->real^N` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2107
  UNDISCH_THEN `!x y. (f:real^N->real^N) x = f y ==> x = y` (K ALL_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2108
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2109
   `!s. bounded s \<and> gmeasurable s
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2110
        ==> (IMAGE (f:real^N->real^N) s) has_gmeasure (m * gmeasure s)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2111
  ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2112
   [REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2113
    FIRST_ASSUM(MP_TAC o MATCH_MP BOUNDED_SUBSET_CLOSED_INTERVAL) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2114
    REWRITE_TAC[LEFT_IMP_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2115
    MAP_EVERY X_GEN_TAC [`a:real^N`; `b:real^N`] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2116
    SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2117
     `!d. COUNTABLE d \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2118
          (!k. k \<in> d ==> k \<subseteq> {a..b} \<and> ~(k = {}) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2119
                          (\<exists>c d. k = {c..d})) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2120
          (!k1 k2. k1 \<in> d \<and> k2 \<in> d \<and> ~(k1 = k2)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2121
                   ==> interior k1 \<inter> interior k2 = {})
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2122
          ==> IMAGE (f:real^N->real^N) (\<Union>d) has_gmeasure
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2123
                    (m * measure(\<Union>d))`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2124
    ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2125
     [REWRITE_TAC[IMAGE_UNIONS] THEN REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2126
      SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2127
       `!g:real^N->real^N.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2128
          linear g
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2129
          ==> !k l. k \<in> d \<and> l \<in> d \<and> ~(k = l)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2130
                    ==> negligible((IMAGE g k) \<inter> (IMAGE g l))`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2131
      MP_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2132
       [REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2133
        ASM_CASES_TAC `!x y. (g:real^N->real^N) x = g y ==> x = y` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2134
         [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2135
          ASM_MESON_TAC[NEGLIGIBLE_LINEAR_SINGULAR_IMAGE;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2136
                        NEGLIGIBLE_INTER]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2137
        MATCH_MP_TAC NEGLIGIBLE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2138
        EXISTS_TAC `frontier(IMAGE (g:real^N->real^N) k \<inter> IMAGE g l) UNION
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2139
                    interior(IMAGE g k \<inter> IMAGE g l)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2140
        CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2141
         [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2142
          REWRITE_TAC[frontier] THEN MATCH_MP_TAC(SET_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2143
           `s \<subseteq> t ==> s \<subseteq> (t DIFF u) \<union> u`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2144
          REWRITE_TAC[CLOSURE_SUBSET]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2145
        MATCH_MP_TAC NEGLIGIBLE_UNION THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2146
         [MATCH_MP_TAC NEGLIGIBLE_CONVEX_FRONTIER THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2147
          MATCH_MP_TAC CONVEX_INTER THEN CONJ_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2148
          MATCH_MP_TAC CONVEX_LINEAR_IMAGE THEN ASM_MESON_TAC[CONVEX_INTERVAL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2149
          ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2150
        REWRITE_TAC[INTERIOR_INTER] THEN MATCH_MP_TAC NEGLIGIBLE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2151
        EXISTS_TAC `IMAGE (g:real^N->real^N) (interior k) INTER
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2152
                    IMAGE g (interior l)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2153
        CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2154
         [MATCH_MP_TAC NEGLIGIBLE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2155
          EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2156
           `IMAGE (g:real^N->real^N) (interior k \<inter> interior l)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2157
          CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2158
           [ASM_SIMP_TAC[IMAGE_CLAUSES; NEGLIGIBLE_EMPTY]; SET_TAC[]];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2159
          MATCH_MP_TAC(SET_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2160
           `s \<subseteq> u \<and> t \<subseteq> v ==> (s \<inter> t) \<subseteq> (u \<inter> v)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2161
          CONJ_TAC THEN MATCH_MP_TAC INTERIOR_IMAGE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2162
          ASM_MESON_TAC[LINEAR_CONTINUOUS_AT]];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2163
        ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2164
      DISCH_THEN(fun th -> MP_TAC(SPEC `f:real^N->real^N` th) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2165
          MP_TAC(SPEC `\x:real^N. x` th)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2166
      ASM_REWRITE_TAC[LINEAR_ID; SET_RULE `IMAGE (\<lambda>x. x) s = s`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2167
      REPEAT STRIP_TAC THEN ASM_CASES_TAC `FINITE(d:(real^N->bool)->bool)` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2168
       [MP_TAC(ISPECL [`IMAGE (f:real^N->real^N)`; `d:(real^N->bool)->bool`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2169
                  HAS_GMEASURE_NEGLIGIBLE_UNIONS_IMAGE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2170
        ANTS_TAC THENL [ASM_MESON_TAC[measurable]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2171
        MATCH_MP_TAC EQ_IMP THEN AP_TERM_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2172
        MATCH_MP_TAC EQ_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2173
        EXISTS_TAC `sum d (\<lambda>k:real^N->bool. m * gmeasure k)` THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2174
         [MATCH_MP_TAC SUM_EQ THEN ASM_MESON_TAC[MEASURE_UNIQUE]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2175
        REWRITE_TAC[SUM_LMUL] THEN AP_TERM_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2176
        CONV_TAC SYM_CONV THEN MATCH_MP_TAC MEASURE_NEGLIGIBLE_UNIONS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2177
        ASM_REWRITE_TAC[GSYM HAS_GMEASURE_MEASURE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2178
        ASM_MESON_TAC[MEASURABLE_INTERVAL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2179
        ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2180
      MP_TAC(ISPEC `d:(real^N->bool)->bool` COUNTABLE_AS_INJECTIVE_IMAGE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2181
      ASM_REWRITE_TAC[INFINITE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2182
      DISCH_THEN(X_CHOOSE_THEN `s:num->real^N->bool`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2183
       (CONJUNCTS_THEN2 SUBST_ALL_TAC ASSUME_TAC)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2184
      MP_TAC(ISPEC `s:num->real^N->bool`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2185
        HAS_GMEASURE_COUNTABLE_NEGLIGIBLE_UNIONS_BOUNDED) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2186
      MP_TAC(ISPEC `\n:num. IMAGE (f:real^N->real^N) (s n)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2187
        HAS_GMEASURE_COUNTABLE_NEGLIGIBLE_UNIONS_BOUNDED) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2188
      RULE_ASSUM_TAC(REWRITE_RULE[IMP_CONJ; RIGHT_FORALL_IMP_THM;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2189
                                  FORALL_IN_IMAGE; IN_UNIV]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2190
      RULE_ASSUM_TAC(REWRITE_RULE[IMP_IMP; RIGHT_IMP_FORALL_THM]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2191
      ASM_SIMP_TAC[] THEN ONCE_REWRITE_TAC[SIMPLE_IMAGE] THEN ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2192
       [REPEAT CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2193
         [ASM_MESON_TAC[MEASURABLE_LINEAR_IMAGE_INTERVAL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2194
          ASM_MESON_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2195
          ONCE_REWRITE_TAC[GSYM o_DEF] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2196
          REWRITE_TAC[GSYM IMAGE_UNIONS; IMAGE_o] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2197
          MATCH_MP_TAC BOUNDED_LINEAR_IMAGE THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2198
          MATCH_MP_TAC BOUNDED_SUBSET THEN REWRITE_TAC[UNIONS_SUBSET] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2199
          EXISTS_TAC `interval[a:real^N,b]` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2200
          REWRITE_TAC[BOUNDED_INTERVAL] THEN ASM SET_TAC[]];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2201
        ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2202
      STRIP_TAC THEN ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2203
       [REPEAT CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2204
         [ASM_MESON_TAC[MEASURABLE_INTERVAL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2205
          ASM_MESON_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2206
          MATCH_MP_TAC BOUNDED_SUBSET THEN REWRITE_TAC[UNIONS_SUBSET] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2207
          EXISTS_TAC `interval[a:real^N,b]` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2208
          REWRITE_TAC[BOUNDED_INTERVAL] THEN ASM SET_TAC[]];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2209
        ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2210
      STRIP_TAC THEN REWRITE_TAC[GSYM IMAGE_o; o_DEF] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2211
      SUBGOAL_THEN `m * gmeasure (\<Union>(IMAGE s (:num)):real^N->bool) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2212
             measure(\<Union>(IMAGE (\<lambda>x. IMAGE f (s x)) (:num)):real^N->bool)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2213
       (fun th -> ASM_REWRITE_TAC[GSYM HAS_GMEASURE_MEASURE; th]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2214
      ONCE_REWRITE_TAC[GSYM LIFT_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2215
      MATCH_MP_TAC SERIES_UNIQUE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2216
      EXISTS_TAC `\n:num. lift(measure(IMAGE (f:real^N->real^N) (s n)))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2217
      EXISTS_TAC `from 0` THEN ASM_REWRITE_TAC[] THEN MATCH_MP_TAC SUMS_EQ THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2218
      EXISTS_TAC `\n:num. m % lift(measure(s n:real^N->bool))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2219
      CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2220
       [REWRITE_TAC[GSYM LIFT_CMUL; LIFT_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2221
        ASM_MESON_TAC[MEASURE_UNIQUE];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2222
        REWRITE_TAC[LIFT_CMUL] THEN MATCH_MP_TAC SERIES_CMUL THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2223
        ASM_REWRITE_TAC[]];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2224
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2225
    REWRITE_TAC[HAS_GMEASURE_INNER_OUTER_LE] THEN CONJ_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2226
    X_GEN_TAC `e:real` THEN DISCH_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2227
     [MP_TAC(ISPECL [`{a..b} DIFF s:real^N->bool`; `a:real^N`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2228
       `b:real^N`; `e / (1 + abs m)`] GMEASURABLE_OUTER_INTERVALS_BOUNDED) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2229
      ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2230
       [ASM_SIMP_TAC[MEASURABLE_DIFF; GMEASURABLE_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2231
        ASM_SIMP_TAC[REAL_ARITH `0 < 1 + abs x`; REAL_LT_DIV] THEN SET_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2232
        ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2233
      DISCH_THEN(X_CHOOSE_THEN `d:(real^N->bool)->bool` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2234
      EXISTS_TAC `IMAGE f {a..b} DIFF
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2235
                  IMAGE (f:real^N->real^N) (\<Union>d)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2236
      FIRST_X_ASSUM(MP_TAC o SPEC `d:(real^N->bool)->bool`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2237
      ASM_SIMP_TAC[IMAGE_SUBSET] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2238
      CONJ_TAC THENL [ASM SET_TAC[]; ALL_TAC] THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2239
       [ASM_MESON_TAC[MEASURABLE_DIFF; gmeasurable]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2240
      MATCH_MP_TAC REAL_LE_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2241
      EXISTS_TAC `measure(IMAGE f {a..b}) -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2242
                  measure(IMAGE (f:real^N->real^N) (\<Union>d))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2243
      CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2244
       [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2245
        MATCH_MP_TAC REAL_EQ_IMP_LE THEN CONV_TAC SYM_CONV THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2246
        MATCH_MP_TAC MEASURE_DIFF_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2247
        REPEAT(CONJ_TAC THENL [ASM_MESON_TAC[measurable]; ALL_TAC]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2248
        MATCH_MP_TAC IMAGE_SUBSET THEN ASM_SIMP_TAC[UNIONS_SUBSET]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2249
      FIRST_ASSUM(ASSUME_TAC o SPECL [`a:real^N`; `b:real^N`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2250
      REPEAT(FIRST_X_ASSUM(SUBST1_TAC o MATCH_MP MEASURE_UNIQUE)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2251
      MATCH_MP_TAC REAL_LE_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2252
      EXISTS_TAC `m * measure(s:real^N->bool) - m * e / (1 + abs m)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2253
      CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2254
       [REWRITE_TAC[REAL_ARITH `a - x \<le> a - y \<longleftrightarrow> y \<le> x`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2255
        REWRITE_TAC[real_div; REAL_MUL_ASSOC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2256
        REWRITE_TAC[GSYM real_div] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2257
        ASM_SIMP_TAC[REAL_LE_LDIV_EQ; REAL_ARITH `0 < 1 + abs x`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2258
        GEN_REWRITE_TAC RAND_CONV [REAL_MUL_SYM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2259
        ASM_SIMP_TAC[REAL_LE_RMUL_EQ] THEN REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2260
        ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2261
      REWRITE_TAC[GSYM REAL_SUB_LDISTRIB] THEN MATCH_MP_TAC REAL_LE_LMUL THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2262
      ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2263
      FIRST_X_ASSUM(MATCH_MP_TAC o MATCH_MP (REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2264
        `d \<le> a + e ==> a = i - s ==> s - e \<le> i - d`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2265
      MATCH_MP_TAC MEASURE_DIFF_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2266
      ASM_REWRITE_TAC[MEASURABLE_INTERVAL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2267
      MP_TAC(ISPECL [`s:real^N->bool`; `a:real^N`; `b:real^N`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2268
                `e / (1 + abs m)`] GMEASURABLE_OUTER_INTERVALS_BOUNDED) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2269
      ASM_SIMP_TAC[REAL_LT_DIV; REAL_ARITH `0 < 1 + abs x`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2270
      DISCH_THEN(X_CHOOSE_THEN `d:(real^N->bool)->bool` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2271
      EXISTS_TAC `IMAGE (f:real^N->real^N) (\<Union>d)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2272
      FIRST_X_ASSUM(MP_TAC o SPEC `d:(real^N->bool)->bool`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2273
      ASM_SIMP_TAC[IMAGE_SUBSET] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2274
      SIMP_TAC[HAS_GMEASURE_MEASURABLE_MEASURE] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2275
      MATCH_MP_TAC REAL_LE_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2276
      EXISTS_TAC `m * measure(s:real^N->bool) + m * e / (1 + abs m)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2277
      CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2278
       [REWRITE_TAC[GSYM REAL_ADD_LDISTRIB] THEN ASM_SIMP_TAC[REAL_LE_LMUL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2279
        REWRITE_TAC[REAL_LE_LADD] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2280
        REWRITE_TAC[real_div; REAL_MUL_ASSOC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2281
        REWRITE_TAC[GSYM real_div] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2282
        ASM_SIMP_TAC[REAL_LE_LDIV_EQ; REAL_ARITH `0 < 1 + abs x`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2283
        GEN_REWRITE_TAC RAND_CONV [REAL_MUL_SYM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2284
        ASM_SIMP_TAC[REAL_LE_RMUL_EQ] THEN REAL_ARITH_TAC]];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2285
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2286
  REPEAT STRIP_TAC THEN ONCE_REWRITE_TAC[HAS_GMEASURE_LIMIT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2287
  X_GEN_TAC `e:real` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2288
  FIRST_ASSUM(MP_TAC o GEN_REWRITE_RULE I [HAS_GMEASURE_MEASURE]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2289
  GEN_REWRITE_TAC LAND_CONV [HAS_GMEASURE_LIMIT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2290
  DISCH_THEN(MP_TAC o SPEC `e / (1 + abs m)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2291
  ASM_SIMP_TAC[REAL_LT_DIV; REAL_ARITH `0 < 1 + abs x`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2292
  DISCH_THEN(X_CHOOSE_THEN `B:real`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2293
   (CONJUNCTS_THEN2 ASSUME_TAC (LABEL_TAC "*"))) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2294
  MP_TAC(ISPEC `ball(0:real^N,B)` BOUNDED_SUBSET_CLOSED_INTERVAL) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2295
  REWRITE_TAC[BOUNDED_BALL; LEFT_IMP_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2296
  REMOVE_THEN "*" MP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2297
  MATCH_MP_TAC MONO_FORALL THEN X_GEN_TAC `c:real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2298
  MATCH_MP_TAC MONO_FORALL THEN X_GEN_TAC `d:real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2299
  DISCH_THEN(fun th -> DISCH_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2300
  DISCH_THEN(X_CHOOSE_THEN `z:real` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2301
  MP_TAC(ISPECL [`interval[c:real^N,d]`; `0:real^N`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2302
    BOUNDED_SUBSET_BALL) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2303
  REWRITE_TAC[BOUNDED_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2304
  DISCH_THEN(X_CHOOSE_THEN `D:real` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2305
  MP_TAC(ISPEC `f:real^N->real^N` LINEAR_BOUNDED_POS) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2306
  ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2307
  DISCH_THEN(X_CHOOSE_THEN `C:real` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2308
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2309
  EXISTS_TAC `D * C` THEN ASM_SIMP_TAC[REAL_LT_MUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2310
  MAP_EVERY X_GEN_TAC [`a:real^N`; `b:real^N`] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2311
  FIRST_X_ASSUM(MP_TAC o SPEC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2312
   `s \<inter> (IMAGE (h:real^N->real^N) {a..b})`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2313
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2314
   `IMAGE (f:real^N->real^N) (s \<inter> IMAGE h (interval [a,b])) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2315
    (IMAGE f s) \<inter> {a..b}`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2316
  SUBST1_TAC THENL [ASM SET_TAC[]; ALL_TAC] THEN ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2317
   [ASM_SIMP_TAC[BOUNDED_INTER; BOUNDED_LINEAR_IMAGE; BOUNDED_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2318
    ASM_SIMP_TAC[MEASURABLE_INTER; GMEASURABLE_LINEAR_IMAGE_INTERVAL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2319
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2320
  DISCH_TAC THEN EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2321
   `m * measure(s \<inter> (IMAGE (h:real^N->real^N) {a..b}))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2322
  ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2323
  MATCH_MP_TAC REAL_LET_TRANS THEN EXISTS_TAC `m * e / (1 + abs m)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2324
  CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2325
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2326
    REWRITE_TAC[real_div; REAL_MUL_ASSOC] THEN REWRITE_TAC[GSYM real_div] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2327
    ASM_SIMP_TAC[REAL_LT_LDIV_EQ; REAL_ARITH `0 < 1 + abs x`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2328
    GEN_REWRITE_TAC RAND_CONV [REAL_MUL_SYM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2329
    ASM_SIMP_TAC[REAL_LT_RMUL_EQ] THEN REAL_ARITH_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2330
  REWRITE_TAC[GSYM REAL_SUB_LDISTRIB; REAL_ABS_MUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2331
  GEN_REWRITE_TAC (LAND_CONV o LAND_CONV) [real_abs] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2332
  ASM_REWRITE_TAC[] THEN MATCH_MP_TAC REAL_LE_LMUL THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2333
  FIRST_ASSUM(MATCH_MP_TAC o MATCH_MP (REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2334
   `abs(z - m) < e ==> z \<le> w \<and> w \<le> m ==> abs(w - m) \<le> e`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2335
  SUBST1_TAC(SYM(MATCH_MP MEASURE_UNIQUE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2336
   (ASSUME `s \<inter> interval [c:real^N,d] has_gmeasure z`))) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2337
  CONJ_TAC THEN MATCH_MP_TAC MEASURE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2338
  ASM_SIMP_TAC[MEASURABLE_INTER; GMEASURABLE_LINEAR_IMAGE_INTERVAL;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2339
               GMEASURABLE_INTERVAL; INTER_SUBSET] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2340
  MATCH_MP_TAC(SET_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2341
   `!v. t \<subseteq> v \<and> v \<subseteq> u ==> s \<inter> t \<subseteq> s \<inter> u`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2342
  EXISTS_TAC `ball(0:real^N,D)` THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2343
  MATCH_MP_TAC(SET_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2344
   `!f. (!x. h(f x) = x) \<and> IMAGE f s \<subseteq> t ==> s \<subseteq> IMAGE h t`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2345
  EXISTS_TAC `f:real^N->real^N` THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2346
  MATCH_MP_TAC SUBSET_TRANS THEN EXISTS_TAC `ball(0:real^N,D * C)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2347
  ASM_REWRITE_TAC[SUBSET; FORALL_IN_IMAGE; IN_BALL_0] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2348
  X_GEN_TAC `x:real^N` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2349
  MATCH_MP_TAC REAL_LET_TRANS THEN EXISTS_TAC `C * norm(x:real^N)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2350
  ASM_REWRITE_TAC[] THEN GEN_REWRITE_TAC RAND_CONV [REAL_MUL_SYM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2351
  ASM_SIMP_TAC[REAL_LT_LMUL_EQ]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2352
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2353
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2354
(* Some inductions by expressing mapping in terms of elementary matrices.    *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2355
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2356
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2357
lemma INDUCT_MATRIX_ROW_OPERATIONS: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2358
 "!P:real^N^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2359
        (!A i. 1 \<le> i \<and> i \<le> dimindex(:N) \<and> row i A = 0 ==> P A) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2360
        (!A. (!i j. 1 \<le> i \<and> i \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2361
                    1 \<le> j \<and> j \<le> dimindex(:N) \<and> ~(i = j)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2362
                    ==> A$i$j = 0) ==> P A) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2363
        (!A m n. P A \<and> 1 \<le> m \<and> m \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2364
                 1 \<le> n \<and> n \<le> dimindex(:N) \<and> ~(m = n)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2365
                 ==> P(lambda i j. A$i$(swap(m,n) j))) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2366
        (!A m n c. P A \<and> 1 \<le> m \<and> m \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2367
                   1 \<le> n \<and> n \<le> dimindex(:N) \<and> ~(m = n)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2368
                   ==> P(lambda i. if i = m then row m A + c % row n A
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2369
                                   else row i A))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2370
        ==> !A. P A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2371
qed   GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2372
  DISCH_THEN(CONJUNCTS_THEN2 (LABEL_TAC "zero_row") MP_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2373
  DISCH_THEN(CONJUNCTS_THEN2 (LABEL_TAC "diagonal") MP_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2374
  DISCH_THEN(CONJUNCTS_THEN2 (LABEL_TAC "swap_cols") (LABEL_TAC "row_op")) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2375
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2376
   `!k A:real^N^N.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2377
        (!i j. 1 \<le> i \<and> i \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2378
               k \<le> j \<and> j \<le> dimindex(:N) \<and> ~(i = j)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2379
               ==> A$i$j = 0)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2380
        ==> P A`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2381
   (fun th -> GEN_TAC THEN MATCH_MP_TAC th THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2382
              EXISTS_TAC `dimindex(:N) + 1` THEN ARITH_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2383
  MATCH_MP_TAC num_INDUCTION THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2384
   [REPEAT STRIP_TAC THEN USE_THEN "diagonal" MATCH_MP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2385
    REPEAT STRIP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2386
    ASM_REWRITE_TAC[LE_0];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2387
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2388
  X_GEN_TAC `k:num` THEN DISCH_THEN(LABEL_TAC "ind_hyp") THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2389
  DISJ_CASES_THEN2 SUBST1_TAC ASSUME_TAC (ARITH_RULE `k = 0 \/ 1 \<le> k`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2390
  ASM_REWRITE_TAC[ARITH] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2391
  ASM_CASES_TAC `k \<le> dimindex(:N)` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2392
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2393
    REPEAT STRIP_TAC THEN REMOVE_THEN "ind_hyp" MATCH_MP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2394
    ASM_ARITH_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2395
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2396
   `!A:real^N^N.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2397
        ~(A$k$k = 0) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2398
        (!i j. 1 \<le> i \<and> i \<le> dimindex (:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2399
               SUC k \<le> j \<and> j \<le> dimindex (:N) \<and> ~(i = j)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2400
               ==> A$i$j = 0)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2401
        ==> P A`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2402
  (LABEL_TAC "nonzero_hyp") THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2403
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2404
    X_GEN_TAC `A:real^N^N` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2405
    ASM_CASES_TAC `row k (A:real^N^N) = 0` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2406
     [REMOVE_THEN "zero_row" MATCH_MP_TAC THEN ASM_MESON_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2407
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2408
    FIRST_ASSUM(MP_TAC o GEN_REWRITE_RULE RAND_CONV [CART_EQ]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2409
    SIMP_TAC[VEC_COMPONENT; row; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2410
    REWRITE_TAC[NOT_FORALL_THM; NOT_IMP; LEFT_IMP_EXISTS_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2411
    X_GEN_TAC `l:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2412
    ASM_CASES_TAC `l:num = k` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2413
     [REMOVE_THEN "nonzero_hyp" MATCH_MP_TAC THEN ASM_MESON_TAC[];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2414
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2415
    REMOVE_THEN "swap_cols" (MP_TAC o SPECL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2416
     [`(lambda i j. (A:real^N^N)$i$swap(k,l) j):real^N^N`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2417
      `k:num`; `l:num`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2418
    ASM_SIMP_TAC[LAMBDA_BETA] THEN ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2419
     [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2420
      MATCH_MP_TAC EQ_IMP THEN AP_TERM_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2421
      SIMP_TAC[CART_EQ; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2422
      REPEAT STRIP_TAC THEN REWRITE_TAC[swap] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2423
      REPEAT(COND_CASES_TAC THEN ASM_SIMP_TAC[LAMBDA_BETA])] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2424
    REMOVE_THEN "nonzero_hyp" MATCH_MP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2425
    ONCE_REWRITE_TAC[ARITH_RULE `SUC k \<le> i \<longleftrightarrow> 1 \<le> i \<and> SUC k \<le> i`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2426
    ASM_SIMP_TAC[LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2427
    ASM_REWRITE_TAC[swap] THEN MAP_EVERY X_GEN_TAC [`i:num`; `j:num`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2428
    STRIP_TAC THEN SUBGOAL_THEN `l:num \<le> k` ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2429
     [FIRST_X_ASSUM(MP_TAC o SPECL [`k:num`; `l:num`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2430
      ASM_REWRITE_TAC[] THEN ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2431
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2432
    REPEAT(COND_CASES_TAC THEN ASM_REWRITE_TAC[]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2433
    FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2434
    ASM_ARITH_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2435
   SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2436
   `!l A:real^N^N.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2437
        ~(A$k$k = 0) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2438
        (!i j. 1 \<le> i \<and> i \<le> dimindex (:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2439
               SUC k \<le> j \<and> j \<le> dimindex (:N) \<and> ~(i = j)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2440
               ==> A$i$j = 0) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2441
        (!i. l \<le> i \<and> i \<le> dimindex(:N) \<and> ~(i = k) ==> A$i$k = 0)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2442
        ==> P A`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2443
   MP_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2444
    [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2445
     DISCH_THEN(MP_TAC o SPEC `dimindex(:N) + 1`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2446
     REWRITE_TAC[CONJ_ASSOC; ARITH_RULE `~(n + 1 \<le> i \<and> i \<le> n)`]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2447
   MATCH_MP_TAC num_INDUCTION THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2448
    [GEN_TAC THEN DISCH_THEN(CONJUNCTS_THEN2 ASSUME_TAC MP_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2449
     DISCH_THEN(CONJUNCTS_THEN2 (LABEL_TAC "main") (LABEL_TAC "aux")) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2450
     USE_THEN "ind_hyp" MATCH_MP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2451
     MAP_EVERY X_GEN_TAC [`i:num`; `j:num`] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2452
     ASM_CASES_TAC `j:num = k` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2453
      [ASM_REWRITE_TAC[] THEN USE_THEN "aux" MATCH_MP_TAC THEN ASM_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2454
       REMOVE_THEN "main" MATCH_MP_TAC THEN ASM_ARITH_TAC];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2455
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2456
  X_GEN_TAC `l:num` THEN DISCH_THEN(LABEL_TAC "inner_hyp") THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2457
  GEN_TAC THEN DISCH_THEN(CONJUNCTS_THEN2 ASSUME_TAC MP_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2458
  DISCH_THEN(CONJUNCTS_THEN2 (LABEL_TAC "main") (LABEL_TAC "aux")) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2459
  ASM_CASES_TAC `l:num = k` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2460
   [REMOVE_THEN "inner_hyp" MATCH_MP_TAC THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2461
    REPEAT STRIP_TAC THEN REMOVE_THEN "aux" MATCH_MP_TAC THEN ASM_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2462
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2463
  DISJ_CASES_TAC(ARITH_RULE `l = 0 \/ 1 \<le> l`) THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2464
   [REMOVE_THEN "ind_hyp" MATCH_MP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2465
    MAP_EVERY X_GEN_TAC [`i:num`; `j:num`] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2466
    ASM_CASES_TAC `j:num = k` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2467
     [ASM_REWRITE_TAC[] THEN REMOVE_THEN "aux" MATCH_MP_TAC THEN ASM_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2468
      REMOVE_THEN "main" MATCH_MP_TAC THEN ASM_ARITH_TAC];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2469
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2470
  ASM_CASES_TAC `l \<le> dimindex(:N)` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2471
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2472
    REMOVE_THEN "inner_hyp" MATCH_MP_TAC THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2473
    ASM_ARITH_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2474
  REMOVE_THEN "inner_hyp" (MP_TAC o SPECL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2475
   [`(lambda i. if i = l then row l (A:real^N^N) + --(A$l$k/A$k$k) % row k A
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2476
                else row i A):real^N^N`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2477
  ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2478
   [SUBGOAL_THEN `!i. l \<le> i ==> 1 \<le> i` ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2479
     [ASM_ARITH_TAC; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2480
    ONCE_REWRITE_TAC[ARITH_RULE `SUC k \<le> j \<longleftrightarrow> 1 \<le> j \<and> SUC k \<le> j`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2481
    ASM_SIMP_TAC[LAMBDA_BETA; row; COND_COMPONENT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2482
                 VECTOR_ADD_COMPONENT; VECTOR_MUL_COMPONENT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2483
    ASM_SIMP_TAC[REAL_FIELD `~(y = 0) ==> x + --(x / y) * y = 0`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2484
    REWRITE_TAC[AND_FORALL_THM] THEN X_GEN_TAC `i:num` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2485
    ASM_CASES_TAC `i:num = l` THEN ASM_REWRITE_TAC[] THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2486
     [REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2487
      MATCH_MP_TAC(REAL_RING `x = 0 \<and> y = 0 ==> x + z * y = 0`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2488
      CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2489
      REPEAT STRIP_TAC THEN REMOVE_THEN "aux" MATCH_MP_TAC THEN ASM_ARITH_TAC];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2490
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2491
  DISCH_TAC THEN REMOVE_THEN "row_op" (MP_TAC o SPECL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2492
   [`(lambda i. if i = l then row l A + --(A$l$k / A$k$k) % row k A
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2493
                else row i (A:real^N^N)):real^N^N`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2494
    `l:num`; `k:num`; `(A:real^N^N)$l$k / A$k$k`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2495
  ASM_REWRITE_TAC[] THEN MATCH_MP_TAC EQ_IMP THEN AP_TERM_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2496
  ASM_SIMP_TAC[CART_EQ; LAMBDA_BETA; VECTOR_ADD_COMPONENT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2497
               VECTOR_MUL_COMPONENT; row; COND_COMPONENT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2498
  REPEAT STRIP_TAC THEN COND_CASES_TAC THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2499
  REAL_ARITH_TAC);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2500
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2501
lemma INDUCT_MATRIX_ELEMENTARY: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2502
 "!P:real^N^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2503
        (!A B. P A \<and> P B ==> P(A ** B)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2504
        (!A i. 1 \<le> i \<and> i \<le> dimindex(:N) \<and> row i A = 0 ==> P A) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2505
        (!A. (!i j. 1 \<le> i \<and> i \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2506
                    1 \<le> j \<and> j \<le> dimindex(:N) \<and> ~(i = j)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2507
                    ==> A$i$j = 0) ==> P A) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2508
        (!m n. 1 \<le> m \<and> m \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2509
               1 \<le> n \<and> n \<le> dimindex(:N) \<and> ~(m = n)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2510
               ==> P(lambda i j. (mat 1:real^N^N)$i$(swap(m,n) j))) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2511
        (!m n c. 1 \<le> m \<and> m \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2512
                 1 \<le> n \<and> n \<le> dimindex(:N) \<and> ~(m = n)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2513
                 ==> P(lambda i j. if i = m \<and> j = n then c
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2514
                                   else if i = j then 1 else 0))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2515
        ==> !A. P A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2516
qed   GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2517
  DISCH_THEN(CONJUNCTS_THEN2 ASSUME_TAC MP_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2518
  DISCH_THEN(fun th ->
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2519
    MATCH_MP_TAC INDUCT_MATRIX_ROW_OPERATIONS THEN MP_TAC th) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2520
  REPEAT(MATCH_MP_TAC MONO_AND THEN CONJ_TAC) THEN REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2521
  DISCH_THEN(fun th -> X_GEN_TAC `A:real^N^N` THEN MP_TAC th) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2522
  REPEAT(MATCH_MP_TAC MONO_FORALL THEN GEN_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2523
  DISCH_THEN(fun th -> STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2524
  UNDISCH_TAC `(P:real^N^N->bool) A` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2525
   [REWRITE_TAC[GSYM IMP_CONJ]; REWRITE_TAC[GSYM IMP_CONJ_ALT]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2526
  DISCH_THEN(ANTE_RES_THEN MP_TAC) THEN MATCH_MP_TAC EQ_IMP THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2527
  AP_TERM_TAC THEN REWRITE_TAC[CART_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2528
  X_GEN_TAC `i:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2529
  X_GEN_TAC `j:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2530
  ASM_SIMP_TAC[CART_EQ; LAMBDA_BETA; matrix_mul; row] THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2531
   [ASM_SIMP_TAC[mat; IN_DIMINDEX_SWAP; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2532
    ONCE_REWRITE_TAC[COND_RAND] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2533
    SIMP_TAC[SUM_DELTA; REAL_MUL_RZERO; REAL_MUL_RID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2534
    COND_CASES_TAC THEN REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2535
    RULE_ASSUM_TAC(REWRITE_RULE[swap; IN_NUMSEG]) THEN ASM_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2536
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2537
  ASM_CASES_TAC `i:num = m` THEN ASM_REWRITE_TAC[] THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2538
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2539
    ONCE_REWRITE_TAC[COND_RAND] THEN ONCE_REWRITE_TAC[COND_RATOR] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2540
    REWRITE_TAC[REAL_MUL_LZERO] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2541
    GEN_REWRITE_TAC (LAND_CONV o ONCE_DEPTH_CONV) [EQ_SYM_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2542
    ASM_SIMP_TAC[SUM_DELTA; LAMBDA_BETA; IN_NUMSEG; REAL_MUL_LID]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2543
  ASM_SIMP_TAC[VECTOR_ADD_COMPONENT; VECTOR_MUL_COMPONENT; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2544
  MATCH_MP_TAC EQ_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2545
  EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2546
    `sum {m,n} (\<lambda>k. (if k = n then c else if m = k then 1 else 0) *
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2547
                    (A:real^N^N)$k$j)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2548
  CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2549
   [MATCH_MP_TAC SUM_SUPERSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2550
    ASM_SIMP_TAC[SUBSET; IN_INSERT; NOT_IN_EMPTY; DE_MORGAN_THM;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2551
                 IN_NUMSEG; REAL_MUL_LZERO] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2552
    ASM_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2553
    ASM_SIMP_TAC[SUM_CLAUSES; FINITE_RULES; IN_INSERT; NOT_IN_EMPTY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2554
    REAL_ARITH_TAC]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2555
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2556
lemma INDUCT_MATRIX_ELEMENTARY_ALT: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2557
 "!P:real^N^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2558
        (!A B. P A \<and> P B ==> P(A ** B)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2559
        (!A i. 1 \<le> i \<and> i \<le> dimindex(:N) \<and> row i A = 0 ==> P A) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2560
        (!A. (!i j. 1 \<le> i \<and> i \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2561
                    1 \<le> j \<and> j \<le> dimindex(:N) \<and> ~(i = j)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2562
                    ==> A$i$j = 0) ==> P A) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2563
        (!m n. 1 \<le> m \<and> m \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2564
               1 \<le> n \<and> n \<le> dimindex(:N) \<and> ~(m = n)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2565
               ==> P(lambda i j. (mat 1:real^N^N)$i$(swap(m,n) j))) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2566
        (!m n. 1 \<le> m \<and> m \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2567
               1 \<le> n \<and> n \<le> dimindex(:N) \<and> ~(m = n)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2568
               ==> P(lambda i j. if i = m \<and> j = n \/ i = j then 1 else 0))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2569
        ==> !A. P A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2570
qed   GEN_TAC THEN STRIP_TAC THEN MATCH_MP_TAC INDUCT_MATRIX_ELEMENTARY THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2571
  ASM_REWRITE_TAC[] THEN REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2572
  ASM_CASES_TAC `c = 0` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2573
   [FIRST_X_ASSUM(fun th -> MATCH_MP_TAC th THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2574
        MAP_EVERY X_GEN_TAC [`i:num`; `j:num`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2575
    ASM_SIMP_TAC[LAMBDA_BETA; COND_ID];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2576
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2577
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2578
   `(lambda i j. if i = m \<and> j = n then c else if i = j then 1 else 0) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2579
  ((lambda i j. if i = j then if j = n then inv c else 1 else 0):real^N^N) **
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2580
    ((lambda i j. if i = m \<and> j = n \/ i = j then 1 else 0):real^N^N) **
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2581
    ((lambda i j. if i = j then if j = n then c else 1 else 0):real^N^N)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2582
  SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2583
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2584
    REPEAT(MATCH_MP_TAC(ASSUME `!A B:real^N^N. P A \<and> P B ==> P(A ** B)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2585
           CONJ_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2586
    ASM_SIMP_TAC[] THEN FIRST_X_ASSUM(fun th -> MATCH_MP_TAC th THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2587
        MAP_EVERY X_GEN_TAC [`i:num`; `j:num`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2588
    ASM_SIMP_TAC[LAMBDA_BETA]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2589
  SIMP_TAC[CART_EQ; matrix_mul; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2590
  X_GEN_TAC `i:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2591
  X_GEN_TAC `j:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2592
  ASM_SIMP_TAC[SUM_DELTA; IN_NUMSEG; REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2593
       `(if p then 1 else 0) * (if q then c else 0) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2594
        if q then if p then c else 0 else 0`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2595
  REWRITE_TAC[REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2596
   `(if p then x else 0) * y = (if p then x * y else 0)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2597
  GEN_REWRITE_TAC (RAND_CONV o ONCE_DEPTH_CONV) [EQ_SYM_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2598
  ASM_SIMP_TAC[SUM_DELTA; IN_NUMSEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2599
  ASM_CASES_TAC `i:num = m` THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2600
  ASM_CASES_TAC `j:num = n` THEN ASM_REWRITE_TAC[REAL_MUL_LID; EQ_SYM_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2601
  ASM_CASES_TAC `i:num = n` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2602
  ASM_SIMP_TAC[REAL_MUL_LINV; REAL_MUL_LID; REAL_MUL_RZERO]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2603
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2604
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2605
(* The same thing in mapping form (might have been easier all along).        *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2606
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2607
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2608
lemma INDUCT_LINEAR_ELEMENTARY: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2609
 "!P. (!f g. linear f \<and> linear g \<and> P f \<and> P g ==> P(f o g)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2610
       (!f i. linear f \<and> 1 \<le> i \<and> i \<le> dimindex(:N) \<and> (!x. (f x)$i = 0)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2611
              ==> P f) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2612
       (!c. P(\<lambda>x. lambda i. c i * x$i)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2613
       (!m n. 1 \<le> m \<and> m \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2614
              1 \<le> n \<and> n \<le> dimindex(:N) \<and> ~(m = n)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2615
              ==> P(\<lambda>x. lambda i. x$swap(m,n) i)) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2616
       (!m n. 1 \<le> m \<and> m \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2617
              1 \<le> n \<and> n \<le> dimindex(:N) \<and> ~(m = n)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2618
              ==> P(\<lambda>x. lambda i. if i = m then x$m + x$n else x$i))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2619
       ==> !f:real^N->real^N. linear f ==> P f"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2620
qed   GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2621
  MP_TAC(ISPEC `\A:real^N^N. P(\<lambda>x:real^N. A ** x):bool`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2622
    INDUCT_MATRIX_ELEMENTARY_ALT) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2623
  REWRITE_TAC[] THEN MATCH_MP_TAC MONO_IMP THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2624
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2625
    DISCH_TAC THEN X_GEN_TAC `f:real^N->real^N` THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2626
    FIRST_X_ASSUM(MP_TAC o SPEC `matrix(f:real^N->real^N)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2627
    ASM_SIMP_TAC[MATRIX_WORKS] THEN REWRITE_TAC[ETA_AX]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2628
  MATCH_MP_TAC MONO_AND THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2629
   [DISCH_TAC THEN MAP_EVERY X_GEN_TAC [`A:real^N^N`; `B:real^N^N`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2630
    STRIP_TAC THEN FIRST_X_ASSUM(MP_TAC o SPECL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2631
     [`\x:real^N. (A:real^N^N) ** x`; `\x:real^N. (B:real^N^N) ** x`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2632
    ASM_REWRITE_TAC[MATRIX_VECTOR_MUL_LINEAR; o_DEF] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2633
    REWRITE_TAC[MATRIX_VECTOR_MUL_ASSOC];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2634
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2635
  MATCH_MP_TAC MONO_AND THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2636
   [DISCH_TAC THEN MAP_EVERY X_GEN_TAC [`A:real^N^N`; `m:num`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2637
    STRIP_TAC THEN FIRST_X_ASSUM(MP_TAC o SPECL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2638
     [`\x:real^N. (A:real^N^N) ** x`; `m:num`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2639
    ASM_REWRITE_TAC[MATRIX_VECTOR_MUL_LINEAR] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2640
    DISCH_THEN MATCH_MP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2641
    UNDISCH_TAC `row m (A:real^N^N) = 0` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2642
    ASM_SIMP_TAC[CART_EQ; row; LAMBDA_BETA; VEC_COMPONENT; matrix_vector_mul;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2643
                 REAL_MUL_LZERO; SUM_0];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2644
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2645
  MATCH_MP_TAC MONO_AND THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2646
   [DISCH_TAC THEN X_GEN_TAC `A:real^N^N` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2647
    FIRST_X_ASSUM(MP_TAC o SPEC `\i. (A:real^N^N)$i$i`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2648
    MATCH_MP_TAC EQ_IMP THEN AP_TERM_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2649
    ASM_SIMP_TAC[CART_EQ; matrix_vector_mul; FUN_EQ_THM; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2650
    MAP_EVERY X_GEN_TAC [`x:real^N`; `i:num`] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2651
    MATCH_MP_TAC EQ_TRANS THEN EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2652
     `sum(1..dimindex(:N)) (\<lambda>j. if j = i then (A:real^N^N)$i$j * (x:real^N)$j
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2653
                                else 0)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2654
    CONJ_TAC THENL [ASM_SIMP_TAC[SUM_DELTA; IN_NUMSEG]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2655
    MATCH_MP_TAC SUM_EQ_NUMSEG THEN X_GEN_TAC `j:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2656
    ASM_SIMP_TAC[] THEN COND_CASES_TAC THEN ASM_SIMP_TAC[REAL_MUL_LZERO];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2657
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2658
  MATCH_MP_TAC MONO_AND THEN CONJ_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2659
  MATCH_MP_TAC MONO_FORALL THEN X_GEN_TAC `m:num` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2660
  MATCH_MP_TAC MONO_FORALL THEN X_GEN_TAC `n:num` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2661
  DISCH_THEN(fun th -> STRIP_TAC THEN MP_TAC th) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2662
  ASM_REWRITE_TAC[] THEN MATCH_MP_TAC EQ_IMP THEN AP_TERM_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2663
  ASM_SIMP_TAC[CART_EQ; matrix_vector_mul; FUN_EQ_THM; LAMBDA_BETA;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2664
               mat; IN_DIMINDEX_SWAP]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2665
  THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2666
   [ONCE_REWRITE_TAC[SWAP_GALOIS] THEN ONCE_REWRITE_TAC[COND_RAND] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2667
    ONCE_REWRITE_TAC[COND_RATOR] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2668
    SIMP_TAC[SUM_DELTA; REAL_MUL_LID; REAL_MUL_LZERO; IN_NUMSEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2669
    REPEAT STRIP_TAC THEN REWRITE_TAC[swap] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2670
    COND_CASES_TAC THEN ASM_REWRITE_TAC[] THEN ASM_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2671
    MAP_EVERY X_GEN_TAC [`x:real^N`; `i:num`] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2672
    ASM_CASES_TAC `i:num = m` THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2673
    ONCE_REWRITE_TAC[COND_RAND] THEN ONCE_REWRITE_TAC[COND_RATOR] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2674
    GEN_REWRITE_TAC (RAND_CONV o ONCE_DEPTH_CONV) [EQ_SYM_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2675
    ASM_SIMP_TAC[SUM_DELTA; REAL_MUL_LZERO; REAL_MUL_LID; IN_NUMSEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2676
    MATCH_MP_TAC EQ_TRANS THEN EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2677
     `sum {m,n} (\<lambda>j. if n = j \/ j = m then (x:real^N)$j else 0)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2678
    CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2679
     [SIMP_TAC[SUM_CLAUSES; FINITE_RULES; IN_INSERT; NOT_IN_EMPTY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2680
      ASM_REWRITE_TAC[REAL_ADD_RID];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2681
      CONV_TAC SYM_CONV THEN MATCH_MP_TAC SUM_SUPERSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2682
      ASM_SIMP_TAC[SUBSET; IN_INSERT; NOT_IN_EMPTY; DE_MORGAN_THM;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2683
                   IN_NUMSEG; REAL_MUL_LZERO] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2684
      ASM_ARITH_TAC]]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2685
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2686
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2687
(* Hence the effect of an arbitrary linear map on a gmeasurable set.          *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2688
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2689
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2690
lemma LAMBDA_SWAP_GALOIS: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2691
 "!x:real^N y:real^N.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2692
        1 \<le> m \<and> m \<le> dimindex(:N) \<and> 1 \<le> n \<and> n \<le> dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2693
        ==> (x = (lambda i. y$swap(m,n) i) \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2694
             (lambda i. x$swap(m,n) i) = y)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2695
qed   SIMP_TAC[CART_EQ; LAMBDA_BETA; IN_DIMINDEX_SWAP] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2696
  REPEAT GEN_TAC THEN STRIP_TAC THEN EQ_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2697
  DISCH_TAC THEN X_GEN_TAC `i:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2698
  FIRST_X_ASSUM(MP_TAC o SPEC `swap(m,n) (i:num)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2699
  ASM_SIMP_TAC[IN_DIMINDEX_SWAP] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2700
  ASM_MESON_TAC[REWRITE_RULE[FUN_EQ_THM; o_THM; I_THM] SWAP_IDEMPOTENT]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2701
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2702
lemma LAMBDA_ADD_GALOIS: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2703
 "!x:real^N y:real^N.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2704
        1 \<le> m \<and> m \<le> dimindex(:N) \<and> 1 \<le> n \<and> n \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2705
        ~(m = n)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2706
        ==> (x = (lambda i. if i = m then y$m + y$n else y$i) \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2707
             (lambda i. if i = m then x$m - x$n else x$i) = y)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2708
qed   SIMP_TAC[CART_EQ; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2709
  REPEAT GEN_TAC THEN STRIP_TAC THEN EQ_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2710
  DISCH_TAC THEN X_GEN_TAC `i:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2711
  FIRST_ASSUM(MP_TAC o SPEC `n:num`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2712
  FIRST_X_ASSUM(MP_TAC o SPEC `i:num`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2713
  ASM_REWRITE_TAC[] THEN COND_CASES_TAC THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2714
  REAL_ARITH_TAC);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2715
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2716
lemma HAS_GMEASURE_SHEAR_INTERVAL: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2717
 "!a b:real^N m n.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2718
        1 \<le> m \<and> m \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2719
        1 \<le> n \<and> n \<le> dimindex(:N) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2720
        ~(m = n) \<and> ~({a..b} = {}) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2721
        0 \<le> a$n
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2722
        ==> (IMAGE (\<lambda>x. (lambda i. if i = m then x$m + x$n else x$i))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2723
                   {a..b}:real^N->bool)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2724
            has_gmeasure gmeasure (interval [a,b])"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2725
qed   lemma lemma = prove
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2726
   (`!s t u v:real^N->bool.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2727
          gmeasurable s \<and> gmeasurable t \<and> gmeasurable u \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2728
          negligible(s \<inter> t) \<and> negligible(s \<inter> u) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2729
          negligible(t \<inter> u) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2730
          s \<union> t \<union> u = v
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2731
          ==> v has_gmeasure (measure s) + (measure t) + (measure u)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2732
qed     REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2733
    ASM_SIMP_TAC[HAS_GMEASURE_MEASURABLE_MEASURE; GMEASURABLE_UNION] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2734
    FIRST_X_ASSUM(SUBST1_TAC o SYM) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2735
    ASM_SIMP_TAC[MEASURE_UNION; GMEASURABLE_UNION] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2736
    ASM_SIMP_TAC[MEASURE_EQ_0; UNION_OVER_INTER; MEASURE_UNION;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2737
                 GMEASURABLE_UNION; NEGLIGIBLE_INTER; GMEASURABLE_INTER] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2738
    REAL_ARITH_TAC)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2739
  and lemma' = prove
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2740
   (`!s t u a.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2741
          gmeasurable s \<and> gmeasurable t \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2742
          s \<union> (IMAGE (\<lambda>x. a + x) t) = u \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2743
          negligible(s \<inter> (IMAGE (\<lambda>x. a + x) t))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2744
          ==> gmeasure s + gmeasure t = gmeasure u"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2745
qed     REPEAT STRIP_TAC THEN FIRST_X_ASSUM(SUBST_ALL_TAC o SYM) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2746
    ASM_SIMP_TAC[MEASURE_NEGLIGIBLE_UNION; GMEASURABLE_TRANSLATION;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2747
                 MEASURE_TRANSLATION]) in
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2748
  REWRITE_TAC[INTERVAL_NE_EMPTY] THEN REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2749
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2750
   `linear((\<lambda>x. lambda i. if i = m then x$m + x$n else x$i):real^N->real^N)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2751
  ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2752
   [ASM_SIMP_TAC[linear; LAMBDA_BETA; VECTOR_ADD_COMPONENT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2753
                 VECTOR_MUL_COMPONENT; CART_EQ] THEN REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2754
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2755
  MP_TAC(ISPECL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2756
   [`IMAGE (\<lambda>x. lambda i. if i = m then x$m + x$n else x$i)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2757
            (interval[a:real^N,b]):real^N->bool`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2758
    `interval[a,(lambda i. if i = m then (b:real^N)$m + b$n else b$i)] INTER
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2759
       {x:real^N | (basis m - basis n) dot x \<le> a$m}`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2760
    `interval[a,(lambda i. if i = m then b$m + b$n else b$i)] INTER
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2761
       {x:real^N | (basis m - basis n) dot x >= (b:real^N)$m}`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2762
    `interval[a:real^N,
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2763
              (lambda i. if i = m then (b:real^N)$m + b$n else b$i)]`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2764
     lemma) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2765
  ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2766
   [ASM_SIMP_TAC[CONVEX_LINEAR_IMAGE; CONVEX_INTERVAL;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2767
                 CONVEX_HALFSPACE_LE; CONVEX_HALFSPACE_GE;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2768
                 CONVEX_INTER; GMEASURABLE_CONVEX; BOUNDED_INTER;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2769
                 BOUNDED_LINEAR_IMAGE; BOUNDED_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2770
    REWRITE_TAC[INTER] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2771
    REWRITE_TAC[EXTENSION; IN_UNION; IN_INTER; IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2772
    ASM_SIMP_TAC[LAMBDA_ADD_GALOIS; UNWIND_THM1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2773
    ASM_SIMP_TAC[IN_INTERVAL; IN_ELIM_THM; LAMBDA_BETA;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2774
                 DOT_BASIS; DOT_LSUB] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2775
    ONCE_REWRITE_TAC[MESON[]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2776
       `(!i:num. P i) \<longleftrightarrow> P m \<and> (!i. ~(i = m) ==> P i)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2777
    ASM_SIMP_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2778
    REWRITE_TAC[TAUT `(p \<and> x) \<and> (q \<and> x) \<and> r \<longleftrightarrow> x \<and> p \<and> q \<and> r`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2779
                TAUT `(p \<and> x) \<and> q \<and> (r \<and> x) \<longleftrightarrow> x \<and> p \<and> q \<and> r`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2780
                TAUT `((p \<and> x) \<and> q) \<and> (r \<and> x) \<and> s \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2781
                            x \<and> p \<and> q \<and> r \<and> s`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2782
            TAUT `(a \<and> x \/ (b \<and> x) \<and> c \/ (d \<and> x) \<and> e \<longleftrightarrow> f \<and> x) \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2783
                  x ==> (a \/ b \<and> c \/ d \<and> e \<longleftrightarrow> f)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2784
    ONCE_REWRITE_TAC[SET_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2785
     `{x | P x \<and> Q x} = {x | P x} \<inter> {x | Q x}`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2786
    REWRITE_TAC[CONJ_ASSOC] THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2787
     [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2788
      GEN_TAC THEN DISCH_THEN(MP_TAC o SPEC `n:num`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2789
      ASM_REWRITE_TAC[] THEN ASM_REAL_ARITH_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2790
    REWRITE_TAC[GSYM CONJ_ASSOC] THEN REPEAT CONJ_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2791
    MATCH_MP_TAC NEGLIGIBLE_INTER THEN DISJ2_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2792
    MATCH_MP_TAC NEGLIGIBLE_SUBSET THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2793
     [EXISTS_TAC `{x:real^N | (basis m - basis n) dot x = (a:real^N)$m}`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2794
      EXISTS_TAC `{x:real^N | (basis m - basis n) dot x = (b:real^N)$m}`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2795
      EXISTS_TAC `{x:real^N | (basis m - basis n) dot x = (b:real^N)$m}`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2796
    THEN (CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2797
      [MATCH_MP_TAC NEGLIGIBLE_HYPERPLANE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2798
       REWRITE_TAC[VECTOR_SUB_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2799
       ASM_MESON_TAC[BASIS_INJ];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2800
       ASM_SIMP_TAC[DOT_LSUB; DOT_BASIS; SUBSET; IN_ELIM_THM;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2801
                    NOT_IN_EMPTY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2802
       FIRST_X_ASSUM(MP_TAC o SPEC `m:num`) THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2803
       ASM_REAL_ARITH_TAC]);
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2804
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2805
  ASM_SIMP_TAC[HAS_GMEASURE_MEASURABLE_MEASURE;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2806
               GMEASURABLE_LINEAR_IMAGE_INTERVAL;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2807
               GMEASURABLE_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2808
  MP_TAC(ISPECL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2809
   [`interval[a,(lambda i. if i = m then (b:real^N)$m + b$n else b$i)] INTER
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2810
       {x:real^N | (basis m - basis n) dot x \<le> a$m}`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2811
    `interval[a,(lambda i. if i = m then b$m + b$n else b$i)] INTER
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2812
       {x:real^N | (basis m - basis n) dot x >= (b:real^N)$m}`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2813
    `interval[a:real^N,
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2814
              (lambda i. if i = m then (a:real^N)$m + b$n
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2815
                         else (b:real^N)$i)]`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2816
    `(lambda i. if i = m then (a:real^N)$m - (b:real^N)$m
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2817
                else 0):real^N`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2818
     lemma') THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2819
  ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2820
   [ASM_SIMP_TAC[CONVEX_LINEAR_IMAGE; CONVEX_INTERVAL;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2821
                 CONVEX_HALFSPACE_LE; CONVEX_HALFSPACE_GE;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2822
                 CONVEX_INTER; GMEASURABLE_CONVEX; BOUNDED_INTER;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2823
                 BOUNDED_LINEAR_IMAGE; BOUNDED_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2824
    REWRITE_TAC[INTER] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2825
    REWRITE_TAC[EXTENSION; IN_UNION; IN_INTER; IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2826
    ONCE_REWRITE_TAC[VECTOR_ARITH `x:real^N = (lambda i. p i) + y \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2827
                                   x - (lambda i. p i) = y`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2828
    ASM_SIMP_TAC[IN_INTERVAL; IN_ELIM_THM; LAMBDA_BETA;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2829
                 DOT_BASIS; DOT_LSUB; UNWIND_THM1;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2830
                 VECTOR_SUB_COMPONENT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2831
    ONCE_REWRITE_TAC[MESON[]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2832
       `(!i:num. P i) \<longleftrightarrow> P m \<and> (!i. ~(i = m) ==> P i)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2833
    ASM_SIMP_TAC[REAL_SUB_RZERO] THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2834
     [X_GEN_TAC `x:real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2835
      FIRST_ASSUM(MP_TAC o SPEC `n:num`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2836
      FIRST_X_ASSUM(MP_TAC o SPEC `m:num`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2837
      ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2838
      ASM_CASES_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2839
       `!i. ~(i = m)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2840
            ==> 1 \<le> i \<and> i \<le> dimindex (:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2841
                ==> (a:real^N)$i \<le> (x:real^N)$i \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2842
                    x$i \<le> (b:real^N)$i` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2843
      ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2844
      FIRST_X_ASSUM(MP_TAC o SPEC `n:num`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2845
      ASM_REWRITE_TAC[] THEN ASM_REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2846
      ONCE_REWRITE_TAC[TAUT `((a \<and> b) \<and> c) \<and> (d \<and> e) \<and> f \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2847
                             (b \<and> e) \<and> a \<and> c \<and> d \<and> f`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2848
      ONCE_REWRITE_TAC[SET_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2849
       `{x | P x \<and> Q x} = {x | P x} \<inter> {x | Q x}`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2850
      MATCH_MP_TAC NEGLIGIBLE_INTER THEN DISJ2_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2851
      MATCH_MP_TAC NEGLIGIBLE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2852
      EXISTS_TAC `{x:real^N | (basis m - basis n) dot x = (a:real^N)$m}`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2853
      THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2854
       [MATCH_MP_TAC NEGLIGIBLE_HYPERPLANE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2855
        REWRITE_TAC[VECTOR_SUB_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2856
        ASM_MESON_TAC[BASIS_INJ];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2857
        ASM_SIMP_TAC[DOT_LSUB; DOT_BASIS; SUBSET; IN_ELIM_THM;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2858
                     NOT_IN_EMPTY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2859
        FIRST_ASSUM(MP_TAC o SPEC `n:num`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2860
        FIRST_X_ASSUM(MP_TAC o SPEC `m:num`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2861
        ASM_REWRITE_TAC[] THEN ASM_REAL_ARITH_TAC]];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2862
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2863
  DISCH_THEN SUBST1_TAC THEN MATCH_MP_TAC(REAL_ARITH
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2864
   `a = b + c ==> a = x + b ==> x = c`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2865
  ASM_SIMP_TAC[MEASURE_INTERVAL; CONTENT_CLOSED_INTERVAL_CASES;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2866
               LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2867
  REPEAT(COND_CASES_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2868
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2869
    FIRST_X_ASSUM(MP_TAC o check (is_neg o concl)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2870
    MATCH_MP_TAC(TAUT `p ==> ~p ==> q`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2871
    X_GEN_TAC `i:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2872
    COND_CASES_TAC THEN ASM_SIMP_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2873
    FIRST_ASSUM(MP_TAC o SPEC `n:num`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2874
    FIRST_X_ASSUM(MP_TAC o SPEC `m:num`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2875
    ASM_REWRITE_TAC[] THEN ASM_REAL_ARITH_TAC]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2876
  SUBGOAL_THEN `1..dimindex(:N) = m INSERT ((1..dimindex(:N)) DELETE m)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2877
  SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2878
   [REWRITE_TAC[EXTENSION; IN_INSERT; IN_DELETE; IN_NUMSEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2879
    ASM_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2880
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2881
  SIMP_TAC[PRODUCT_CLAUSES; FINITE_DELETE; FINITE_NUMSEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2882
  ASM_SIMP_TAC[IN_DELETE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2883
  MATCH_MP_TAC(REAL_RING
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2884
   `s1 = s3 \<and> s2 = s3
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2885
    ==> ((bm + bn) - am) * s1 =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2886
        ((am + bn) - am) * s2 + (bm - am) * s3`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2887
  CONJ_TAC THEN MATCH_MP_TAC PRODUCT_EQ THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2888
  SIMP_TAC[IN_DELETE] THEN REAL_ARITH_TAC);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2889
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2890
lemma HAS_GMEASURE_LINEAR_IMAGE: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2891
 "!f:real^N->real^N s.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2892
        linear f \<and> gmeasurable s
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2893
        ==> (IMAGE f s) has_gmeasure (abs(det(matrix f)) * gmeasure s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2894
qed   REWRITE_TAC[IMP_CONJ; RIGHT_FORALL_IMP_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2895
  MATCH_MP_TAC INDUCT_LINEAR_ELEMENTARY THEN REPEAT CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2896
   [MAP_EVERY X_GEN_TAC [`f:real^N->real^N`; `g:real^N->real^N`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2897
    REPLICATE_TAC 2 (DISCH_THEN(CONJUNCTS_THEN2 ASSUME_TAC MP_TAC)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2898
    DISCH_THEN(fun th -> REPEAT STRIP_TAC THEN MP_TAC th) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2899
    DISCH_THEN(CONJUNCTS_THEN2
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2900
     (MP_TAC o SPEC `IMAGE (g:real^N->real^N) s`)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2901
     (MP_TAC o SPEC `s:real^N->bool`)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2902
    ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2903
    GEN_REWRITE_TAC LAND_CONV [HAS_GMEASURE_MEASURABLE_MEASURE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2904
    STRIP_TAC THEN ASM_SIMP_TAC[MATRIX_COMPOSE; DET_MUL; REAL_ABS_MUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2905
    REWRITE_TAC[IMAGE_o; GSYM REAL_MUL_ASSOC];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2906
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2907
    MAP_EVERY X_GEN_TAC [`f:real^N->real^N`; `m:num`] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2908
    SUBGOAL_THEN `~(!x y. (f:real^N->real^N) x = f y ==> x = y)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2909
    ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2910
     [ASM_SIMP_TAC[LINEAR_SINGULAR_INTO_HYPERPLANE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2911
      EXISTS_TAC `basis m:real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2912
      ASM_SIMP_TAC[BASIS_NONZERO; DOT_BASIS];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2913
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2914
    MP_TAC(ISPEC `matrix f:real^N^N` INVERTIBLE_DET_NZ) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2915
    ASM_SIMP_TAC[INVERTIBLE_LEFT_INVERSE; MATRIX_LEFT_INVERTIBLE_INJECTIVE;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2916
                 MATRIX_WORKS; REAL_ABS_NUM; REAL_MUL_LZERO] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2917
    DISCH_THEN(K ALL_TAC) THEN REWRITE_TAC[HAS_GMEASURE_0] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2918
    ASM_SIMP_TAC[NEGLIGIBLE_LINEAR_SINGULAR_IMAGE];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2919
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2920
    MAP_EVERY X_GEN_TAC [`c:num->real`; `s:real^N->bool`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2921
    DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2922
    FIRST_ASSUM(ASSUME_TAC o REWRITE_RULE[HAS_GMEASURE_MEASURE]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2923
    FIRST_ASSUM(MP_TAC o SPEC `c:num->real` o
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2924
     MATCH_MP HAS_GMEASURE_STRETCH) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2925
    MATCH_MP_TAC EQ_IMP THEN AP_TERM_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2926
    AP_THM_TAC THEN AP_TERM_TAC THEN AP_TERM_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2927
    SIMP_TAC[matrix; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2928
    W(MP_TAC o PART_MATCH (lhs o rand) DET_DIAGONAL o rand o snd) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2929
    SIMP_TAC[LAMBDA_BETA; BASIS_COMPONENT; REAL_MUL_RZERO] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2930
    DISCH_THEN(K ALL_TAC) THEN MATCH_MP_TAC PRODUCT_EQ_NUMSEG THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2931
    REWRITE_TAC[REAL_MUL_RID];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2932
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2933
    MAP_EVERY X_GEN_TAC [`m:num`; `n:num`] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2934
    MATCH_MP_TAC HAS_GMEASURE_LINEAR_SUFFICIENT THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2935
    ASM_SIMP_TAC[linear; LAMBDA_BETA; IN_DIMINDEX_SWAP; VECTOR_ADD_COMPONENT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2936
                 VECTOR_MUL_COMPONENT; CART_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2937
    MAP_EVERY X_GEN_TAC [`a:real^N`; `b:real^N`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2938
    SUBGOAL_THEN `matrix (\<lambda>x:real^N. lambda i. x$swap (m,n) i):real^N^N =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2939
                  transp(lambda i j. (mat 1:real^N^N)$i$swap (m,n) j)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2940
    SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2941
     [ASM_SIMP_TAC[MATRIX_EQ; LAMBDA_BETA; IN_DIMINDEX_SWAP;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2942
                    matrix_vector_mul; CART_EQ; matrix; mat; basis;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2943
                    COND_COMPONENT; transp] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2944
      REWRITE_TAC[EQ_SYM_EQ];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2945
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2946
    REWRITE_TAC[DET_TRANSP] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2947
    W(MP_TAC o PART_MATCH (lhs o rand) DET_PERMUTE_COLUMNS o
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2948
        rand o lhand o rand o snd) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2949
    ASM_SIMP_TAC[PERMUTES_SWAP; IN_NUMSEG; ETA_AX] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2950
    DISCH_THEN(K ALL_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2951
    REWRITE_TAC[DET_I; REAL_ABS_SIGN; REAL_MUL_RID; REAL_MUL_LID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2952
    ASM_CASES_TAC `interval[a:real^N,b] = {}` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2953
     [ASM_SIMP_TAC[IMAGE_CLAUSES; HAS_GMEASURE_EMPTY; MEASURE_EMPTY];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2954
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2955
    SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2956
     `~(IMAGE (\<lambda>x:real^N. lambda i. x$swap (m,n) i)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2957
              {a..b}:real^N->bool = {})`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2958
    MP_TAC THENL [ASM_REWRITE_TAC[IMAGE_EQ_EMPTY]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2959
    SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2960
     `IMAGE (\<lambda>x:real^N. lambda i. x$swap (m,n) i)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2961
              {a..b}:real^N->bool =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2962
      interval[(lambda i. a$swap (m,n) i),
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2963
               (lambda i. b$swap (m,n) i)]`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2964
    SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2965
     [REWRITE_TAC[EXTENSION; IN_INTERVAL; IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2966
      ASM_SIMP_TAC[LAMBDA_SWAP_GALOIS; UNWIND_THM1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2967
      SIMP_TAC[LAMBDA_BETA] THEN GEN_TAC THEN EQ_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2968
      DISCH_TAC THEN X_GEN_TAC `i:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2969
      FIRST_X_ASSUM(MP_TAC o SPEC `swap(m,n) (i:num)`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2970
      ASM_SIMP_TAC[IN_DIMINDEX_SWAP] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2971
      ASM_MESON_TAC[REWRITE_RULE[FUN_EQ_THM; o_THM; I_THM] SWAP_IDEMPOTENT];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2972
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2973
    REWRITE_TAC[HAS_GMEASURE_MEASURABLE_MEASURE; GMEASURABLE_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2974
    REWRITE_TAC[MEASURE_INTERVAL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2975
    ASM_SIMP_TAC[CONTENT_CLOSED_INTERVAL; GSYM INTERVAL_NE_EMPTY] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2976
    DISCH_THEN(K ALL_TAC) THEN SIMP_TAC[LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2977
    ASM_SIMP_TAC[GSYM VECTOR_SUB_COMPONENT; IN_DIMINDEX_SWAP] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2978
    MP_TAC(ISPECL [`\i. (b - a:real^N)$i`; `swap(m:num,n)`; `1..dimindex(:N)`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2979
                (GSYM PRODUCT_PERMUTE)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2980
    REWRITE_TAC[o_DEF] THEN DISCH_THEN MATCH_MP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2981
    ASM_SIMP_TAC[PERMUTES_SWAP; IN_NUMSEG];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2982
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2983
    MAP_EVERY X_GEN_TAC [`m:num`; `n:num`] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2984
    MATCH_MP_TAC HAS_GMEASURE_LINEAR_SUFFICIENT THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2985
    MATCH_MP_TAC(TAUT `a \<and> (a ==> b) ==> a \<and> b`) THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2986
     [ASM_SIMP_TAC[linear; LAMBDA_BETA; VECTOR_ADD_COMPONENT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2987
                   VECTOR_MUL_COMPONENT; CART_EQ] THEN REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2988
      DISCH_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2989
    MAP_EVERY X_GEN_TAC [`a:real^N`; `b:real^N`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2990
    SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2991
      `det(matrix(\<lambda>x. lambda i. if i = m then (x:real^N)$m + x$n
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2992
                                else x$i):real^N^N) = 1`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2993
    SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2994
     [ASM_SIMP_TAC[matrix; basis; COND_COMPONENT; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2995
      FIRST_ASSUM(DISJ_CASES_TAC o MATCH_MP (ARITH_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2996
       `~(m:num = n) ==> m < n \/ n < m`))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2997
      THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2998
       [W(MP_TAC o PART_MATCH (lhs o rand) DET_UPPERTRIANGULAR o lhs o snd);
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  2999
        W(MP_TAC o PART_MATCH (lhs o rand) DET_LOWERTRIANGULAR o lhs o snd)]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3000
      THEN ASM_SIMP_TAC[LAMBDA_BETA; BASIS_COMPONENT; COND_COMPONENT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3001
                        matrix; REAL_ADD_RID; COND_ID;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3002
                        PRODUCT_CONST_NUMSEG; REAL_POW_ONE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3003
      DISCH_THEN MATCH_MP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3004
      REPEAT GEN_TAC THEN REPEAT(COND_CASES_TAC THEN ASM_REWRITE_TAC[]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3005
      ASM_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3006
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3007
    REWRITE_TAC[REAL_ABS_NUM; REAL_MUL_LID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3008
    ASM_CASES_TAC `interval[a:real^N,b] = {}` THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3009
     [ASM_SIMP_TAC[IMAGE_CLAUSES; HAS_GMEASURE_EMPTY; MEASURE_EMPTY];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3010
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3011
    SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3012
     `IMAGE (\<lambda>x. lambda i. if i = m then x$m + x$n else x$i) (interval [a,b]) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3013
      IMAGE (\<lambda>x:real^N. (lambda i. if i = m \/ i = n then a$n else 0) +
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3014
                        x)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3015
            (IMAGE (\<lambda>x:real^N. lambda i. if i = m then x$m + x$n else x$i)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3016
                   (IMAGE (\<lambda>x. (lambda i. if i = n then --(a$n) else 0) + x)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3017
                          {a..b}))`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3018
    SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3019
     [REWRITE_TAC[GSYM IMAGE_o] THEN AP_THM_TAC THEN AP_TERM_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3020
      ASM_SIMP_TAC[FUN_EQ_THM; o_THM; VECTOR_ADD_COMPONENT; LAMBDA_BETA;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3021
                   CART_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3022
      MAP_EVERY X_GEN_TAC [`x:real^N`; `i:num`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3023
      STRIP_TAC THEN ASM_CASES_TAC `i:num = m` THEN ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3024
      ASM_CASES_TAC `i:num = n` THEN ASM_REWRITE_TAC[] THEN REAL_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3025
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3026
    MATCH_MP_TAC HAS_GMEASURE_TRANSLATION THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3027
    SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3028
     `measure{a..b} =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3029
      measure(IMAGE (\<lambda>x:real^N. (lambda i. if i = n then --(a$n) else 0) + x)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3030
                    {a..b}:real^N->bool)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3031
    SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3032
     [CONV_TAC SYM_CONV THEN MATCH_MP_TAC MEASURE_TRANSLATION THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3033
      REWRITE_TAC[MEASURABLE_INTERVAL];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3034
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3035
    SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3036
     `~(IMAGE (\<lambda>x:real^N. (lambda i. if i = n then --(a$n) else 0) + x)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3037
                    {a..b}:real^N->bool = {})`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3038
    MP_TAC THENL [ASM_SIMP_TAC[IMAGE_EQ_EMPTY]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3039
    ONCE_REWRITE_TAC[VECTOR_ARITH `c + x = 1 % x + c`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3040
    ASM_REWRITE_TAC[IMAGE_AFFINITY_INTERVAL; REAL_POS] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3041
    DISCH_TAC THEN MATCH_MP_TAC HAS_GMEASURE_SHEAR_INTERVAL THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3042
    ASM_SIMP_TAC[LAMBDA_BETA; VECTOR_ADD_COMPONENT; VECTOR_MUL_COMPONENT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3043
    REAL_ARITH_TAC]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3044
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3045
lemma GMEASURABLE_LINEAR_IMAGE: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3046
 "!f:real^N->real^N s.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3047
        linear f \<and> gmeasurable s ==> gmeasurable(IMAGE f s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3048
qed   REPEAT GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3049
  DISCH_THEN(MP_TAC o MATCH_MP HAS_GMEASURE_LINEAR_IMAGE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3050
  SIMP_TAC[HAS_GMEASURE_MEASURABLE_MEASURE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3051
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3052
lemma MEASURE_LINEAR_IMAGE: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3053
 "!f:real^N->real^N s.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3054
        linear f \<and> gmeasurable s
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3055
        ==> measure(IMAGE f s) = abs(det(matrix f)) * gmeasure s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3056
qed   REPEAT GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3057
  DISCH_THEN(MP_TAC o MATCH_MP HAS_GMEASURE_LINEAR_IMAGE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3058
  SIMP_TAC[HAS_GMEASURE_MEASURABLE_MEASURE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3059
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3060
lemma HAS_GMEASURE_LINEAR_IMAGE_SAME: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3061
 "!f s. linear f \<and> gmeasurable s \<and> abs(det(matrix f)) = 1
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3062
         ==> (IMAGE f s) has_gmeasure (measure s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3063
qed   MESON_TAC[HAS_GMEASURE_LINEAR_IMAGE; REAL_MUL_LID]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3064
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3065
lemma MEASURE_LINEAR_IMAGE_SAME: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3066
 "!f:real^N->real^N s.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3067
        linear f \<and> gmeasurable s \<and> abs(det(matrix f)) = 1
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3068
        ==> measure(IMAGE f s) = gmeasure s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3069
qed   REPEAT GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3070
  DISCH_THEN(MP_TAC o MATCH_MP HAS_GMEASURE_LINEAR_IMAGE_SAME) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3071
  SIMP_TAC[HAS_GMEASURE_MEASURABLE_MEASURE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3072
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3073
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3074
(* gmeasure of a standard simplex.                                            *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3075
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3076
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3077
lemma CONGRUENT_IMAGE_STD_SIMPLEX: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3078
 "!p. p permutes 1..dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3079
       ==> {x:real^N | 0 \<le> x$(p 1) \<and> x$(p(dimindex(:N))) \<le> 1 \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3080
                       (!i. 1 \<le> i \<and> i < dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3081
                            ==> x$(p i) \<le> x$(p(i + 1)))} =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3082
           IMAGE (\<lambda>x:real^N. lambda i. sum(1..inverse p(i)) (\<lambda>j. x$j))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3083
                 {x | (!i. 1 \<le> i \<and> i \<le> dimindex (:N) ==> 0 \<le> x$i) \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3084
                      sum (1..dimindex (:N)) (\<lambda>i. x$i) \<le> 1}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3085
qed   REPEAT STRIP_TAC THEN MATCH_MP_TAC SUBSET_ANTISYM THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3086
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3087
    REWRITE_TAC[SUBSET; FORALL_IN_IMAGE] THEN X_GEN_TAC `x:real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3088
    ASM_SIMP_TAC[IN_ELIM_THM; LAMBDA_BETA; LAMBDA_BETA_PERM; LE_REFL;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3089
                 ARITH_RULE `i < n ==> i \<le> n \<and> i + 1 \<le> n`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3090
                 ARITH_RULE `1 \<le> n + 1`; DIMINDEX_GE_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3091
    STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3092
    FIRST_ASSUM(fun th -> REWRITE_TAC[MATCH_MP PERMUTES_INVERSES th]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3093
    ASM_SIMP_TAC[SUM_SING_NUMSEG; DIMINDEX_GE_1; LE_REFL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3094
    REWRITE_TAC[GSYM ADD1; SUM_CLAUSES_NUMSEG; ARITH_RULE `1 \<le> SUC n`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3095
    ASM_SIMP_TAC[REAL_LE_ADDR] THEN REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3096
    FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_ARITH_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3097
  REWRITE_TAC[SUBSET; IN_IMAGE; IN_ELIM_THM] THEN X_GEN_TAC `x:real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3098
  STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3099
  EXISTS_TAC `(lambda i. if i = 1 then x$(p 1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3100
                         else (x:real^N)$p(i) - x$p(i - 1)):real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3101
  ASM_SIMP_TAC[IN_ELIM_THM; LAMBDA_BETA; LAMBDA_BETA_PERM; LE_REFL;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3102
               ARITH_RULE `i < n ==> i \<le> n \<and> i + 1 \<le> n`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3103
               ARITH_RULE `1 \<le> n + 1`; DIMINDEX_GE_1; CART_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3104
  REPEAT CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3105
   [X_GEN_TAC `i:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3106
    SUBGOAL_THEN `1 \<le> inverse (p:num->num) i \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3107
                  !x. x \<le> inverse p i ==> x \<le> dimindex(:N)`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3108
    ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3109
     [ASM_MESON_TAC[PERMUTES_INVERSE; IN_NUMSEG; LE_TRANS; PERMUTES_IN_IMAGE];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3110
      ASM_SIMP_TAC[LAMBDA_BETA] THEN ASM_SIMP_TAC[SUM_CLAUSES_LEFT; ARITH]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3111
    SIMP_TAC[ARITH_RULE `2 \<le> n ==> ~(n = 1)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3112
    GEN_REWRITE_TAC (RAND_CONV o RAND_CONV o BINDER_CONV)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3113
                [GSYM REAL_MUL_LID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3114
    ONCE_REWRITE_TAC[SUM_PARTIAL_PRE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3115
    REWRITE_TAC[REAL_SUB_REFL; REAL_MUL_RZERO; SUM_0; COND_ID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3116
    REWRITE_TAC[REAL_MUL_LID; ARITH; REAL_SUB_RZERO] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3117
    FIRST_ASSUM(DISJ_CASES_TAC o MATCH_MP (ARITH_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3118
     `1 \<le> p ==> p = 1 \/ 2 \<le> p`) o CONJUNCT1) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3119
    ASM_SIMP_TAC[ARITH] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3120
    FIRST_ASSUM(fun th -> REWRITE_TAC[MATCH_MP PERMUTES_INVERSES th]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3121
    REWRITE_TAC[REAL_ADD_RID] THEN TRY REAL_ARITH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3122
    ASM_MESON_TAC[PERMUTES_INVERSE_EQ; PERMUTES_INVERSE];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3123
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3124
    X_GEN_TAC `i:num` THEN STRIP_TAC THEN COND_CASES_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3125
    ASM_REWRITE_TAC[REAL_SUB_LE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3126
    FIRST_X_ASSUM(MP_TAC o SPEC `i - 1`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3127
    ASM_SIMP_TAC[SUB_ADD] THEN DISCH_THEN MATCH_MP_TAC THEN ASM_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3128
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3129
    SIMP_TAC[SUM_CLAUSES_LEFT; DIMINDEX_GE_1; ARITH;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3130
             ARITH_RULE `2 \<le> n ==> ~(n = 1)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3131
    GEN_REWRITE_TAC (LAND_CONV o RAND_CONV o RAND_CONV o BINDER_CONV)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3132
                [GSYM REAL_MUL_LID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3133
    ONCE_REWRITE_TAC[SUM_PARTIAL_PRE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3134
    REWRITE_TAC[REAL_SUB_REFL; REAL_MUL_RZERO; SUM_0; COND_ID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3135
    REWRITE_TAC[REAL_MUL_LID; ARITH; REAL_SUB_RZERO] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3136
    COND_CASES_TAC THEN ASM_SIMP_TAC[REAL_ADD_RID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3137
    ASM_REWRITE_TAC[REAL_ARITH `x + y - x:real = y`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3138
    ASM_MESON_TAC[DIMINDEX_GE_1;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3139
                  ARITH_RULE `1 \<le> n \<and> ~(2 \<le> n) ==> n = 1`]]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3140
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3141
lemma HAS_GMEASURE_IMAGE_STD_SIMPLEX: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3142
 "!p. p permutes 1..dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3143
       ==> {x:real^N | 0 \<le> x$(p 1) \<and> x$(p(dimindex(:N))) \<le> 1 \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3144
                       (!i. 1 \<le> i \<and> i < dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3145
                            ==> x$(p i) \<le> x$(p(i + 1)))}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3146
           has_gmeasure
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3147
           (measure (convex hull
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3148
             (0 INSERT {basis i:real^N | 1 \<le> i \<and> i \<le> dimindex(:N)})))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3149
qed   REPEAT STRIP_TAC THEN ASM_SIMP_TAC[CONGRUENT_IMAGE_STD_SIMPLEX] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3150
  ASM_SIMP_TAC[GSYM STD_SIMPLEX] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3151
  MATCH_MP_TAC HAS_GMEASURE_LINEAR_IMAGE_SAME THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3152
  REPEAT CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3153
   [REWRITE_TAC[linear; CART_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3154
    ASM_SIMP_TAC[LAMBDA_BETA; VECTOR_ADD_COMPONENT; VECTOR_MUL_COMPONENT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3155
                 GSYM SUM_ADD_NUMSEG; GSYM SUM_LMUL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3156
    REPEAT STRIP_TAC THEN MATCH_MP_TAC SUM_EQ_NUMSEG THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3157
    REPEAT STRIP_TAC THEN REWRITE_TAC[] THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3158
     [MATCH_MP_TAC VECTOR_ADD_COMPONENT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3159
      MATCH_MP_TAC VECTOR_MUL_COMPONENT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3160
    ASM_MESON_TAC[PERMUTES_INVERSE; IN_NUMSEG; LE_TRANS; PERMUTES_IN_IMAGE];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3161
    MATCH_MP_TAC GMEASURABLE_CONVEX THEN REWRITE_TAC[CONVEX_CONVEX_HULL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3162
    MATCH_MP_TAC BOUNDED_CONVEX_HULL THEN REWRITE_TAC[BOUNDED_INSERT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3163
    ONCE_REWRITE_TAC[SIMPLE_IMAGE_GEN] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3164
    MATCH_MP_TAC FINITE_IMP_BOUNDED THEN MATCH_MP_TAC FINITE_IMAGE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3165
    REWRITE_TAC[GSYM numseg; FINITE_NUMSEG];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3166
    MATCH_MP_TAC EQ_TRANS THEN EXISTS_TAC
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3167
     `abs(det
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3168
       ((lambda i. ((lambda i j. if j \<le> i then 1 else 0):real^N^N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3169
                   $inverse p i)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3170
        :real^N^N))` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3171
    CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3172
     [AP_TERM_TAC THEN AP_TERM_TAC THEN REWRITE_TAC[CART_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3173
      ASM_SIMP_TAC[matrix; LAMBDA_BETA; BASIS_COMPONENT; COND_COMPONENT;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3174
                   LAMBDA_BETA_PERM; PERMUTES_INVERSE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3175
      X_GEN_TAC `i:num` THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3176
      X_GEN_TAC `j:num` THEN STRIP_TAC THEN MATCH_MP_TAC EQ_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3177
      EXISTS_TAC `sum (1..inverse (p:num->num) i)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3178
                      (\<lambda>k. if k = j then 1 else 0)` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3179
      CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3180
       [MATCH_MP_TAC SUM_EQ THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3181
        ASM_SIMP_TAC[IN_NUMSEG; PERMUTES_IN_IMAGE; basis] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3182
        REPEAT STRIP_TAC THEN MATCH_MP_TAC LAMBDA_BETA THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3183
        ASM_MESON_TAC[PERMUTES_IN_IMAGE; IN_NUMSEG; LE_TRANS;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3184
                      PERMUTES_INVERSE];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3185
        ASM_SIMP_TAC[SUM_DELTA; IN_NUMSEG]];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3186
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3187
    ASM_SIMP_TAC[PERMUTES_INVERSE; DET_PERMUTE_ROWS; ETA_AX] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3188
    REWRITE_TAC[REAL_ABS_MUL; REAL_ABS_SIGN; REAL_MUL_LID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3189
    MATCH_MP_TAC(REAL_ARITH `x = 1 ==> abs x = 1`) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3190
    ASM_SIMP_TAC[DET_LOWERTRIANGULAR; GSYM NOT_LT; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3191
    REWRITE_TAC[LT_REFL; PRODUCT_CONST_NUMSEG; REAL_POW_ONE]]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3192
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3193
lemma HAS_GMEASURE_STD_SIMPLEX: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3194
 "(convex hull (0:real^N INSERT {basis i | 1 \<le> i \<and> i \<le> dimindex(:N)}))
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3195
   has_gmeasure inv((FACT(dimindex(:N))))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3196
qed   lemma lemma = prove
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3197
   (`!f:num->real. (!i. 1 \<le> i \<and> i < n ==> f i \<le> f(i + 1)) \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3198
                   (!i j. 1 \<le> i \<and> i \<le> j \<and> j \<le> n ==> f i \<le> f j)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3199
qed     GEN_TAC THEN EQ_TAC THEN DISCH_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3200
     [GEN_TAC THEN INDUCT_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3201
      SIMP_TAC[LE; REAL_LE_REFL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3202
      STRIP_TAC THEN ASM_SIMP_TAC[REAL_LE_REFL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3203
      MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `(f:num->real) j` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3204
      ASM_SIMP_TAC[ARITH_RULE `SUC x \<le> y ==> x \<le> y`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3205
      REWRITE_TAC[ADD1] THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3206
      REPEAT STRIP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_ARITH_TAC]) in
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3207
  MP_TAC(ISPECL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3208
   [`\p. {x:real^N | 0 \<le> x$(p 1) \<and> x$(p(dimindex(:N))) \<le> 1 \<and>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3209
                     (!i. 1 \<le> i \<and> i < dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3210
                          ==> x$(p i) \<le> x$(p(i + 1)))}`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3211
    `{p | p permutes 1..dimindex(:N)}`]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3212
    HAS_GMEASURE_NEGLIGIBLE_UNIONS_IMAGE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3213
  ASM_SIMP_TAC[REWRITE_RULE[HAS_GMEASURE_MEASURABLE_MEASURE]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3214
                            HAS_GMEASURE_IMAGE_STD_SIMPLEX; IN_ELIM_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3215
  ASM_SIMP_TAC[SUM_CONST; FINITE_PERMUTATIONS; FINITE_NUMSEG;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3216
               CARD_PERMUTATIONS; CARD_NUMSEG_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3217
  ANTS_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3218
   [MAP_EVERY X_GEN_TAC [`p:num->num`; `q:num->num`] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3219
    SUBGOAL_THEN `?i. i \<in> 1..dimindex(:N) \<and> ~(p i:num = q i)` MP_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3220
     [ASM_MESON_TAC[permutes; FUN_EQ_THM]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3221
    GEN_REWRITE_TAC LAND_CONV [num_WOP] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3222
    REWRITE_TAC[TAUT `a ==> ~(b \<and> ~c) \<longleftrightarrow> a \<and> b ==> c`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3223
    REWRITE_TAC[IN_NUMSEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3224
    DISCH_THEN(X_CHOOSE_THEN `k:num` STRIP_ASSUME_TAC) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3225
    MATCH_MP_TAC NEGLIGIBLE_SUBSET THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3226
    EXISTS_TAC `{x:real^N | (basis(p(k:num)) - basis(q k)) dot x = 0}` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3227
    CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3228
     [MATCH_MP_TAC NEGLIGIBLE_HYPERPLANE THEN REWRITE_TAC[VECTOR_SUB_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3229
      MATCH_MP_TAC BASIS_NE THEN ASM_MESON_TAC[PERMUTES_IN_IMAGE; IN_NUMSEG];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3230
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3231
    REWRITE_TAC[SUBSET; IN_INTER; IN_ELIM_THM; DOT_LSUB; VECTOR_SUB_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3232
    ASM_SIMP_TAC[DOT_BASIS; GSYM IN_NUMSEG; PERMUTES_IN_IMAGE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3233
    SUBGOAL_THEN `?l. (q:num->num) l = p(k:num)` STRIP_ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3234
     [ASM_MESON_TAC[permutes]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3235
    SUBGOAL_THEN `1 \<le> l \<and> l \<le> dimindex(:N)` STRIP_ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3236
     [ASM_MESON_TAC[PERMUTES_IN_IMAGE; IN_NUMSEG]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3237
    SUBGOAL_THEN `k:num < l` ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3238
     [REWRITE_TAC[GSYM NOT_LE] THEN REWRITE_TAC[LE_LT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3239
      ASM_MESON_TAC[PERMUTES_INJECTIVE; IN_NUMSEG];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3240
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3241
    SUBGOAL_THEN `?m. (p:num->num) m = q(k:num)` STRIP_ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3242
     [ASM_MESON_TAC[permutes]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3243
    SUBGOAL_THEN `1 \<le> m \<and> m \<le> dimindex(:N)` STRIP_ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3244
     [ASM_MESON_TAC[PERMUTES_IN_IMAGE; IN_NUMSEG]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3245
    SUBGOAL_THEN `k:num < m` ASSUME_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3246
     [REWRITE_TAC[GSYM NOT_LE] THEN REWRITE_TAC[LE_LT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3247
      ASM_MESON_TAC[PERMUTES_INJECTIVE; IN_NUMSEG];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3248
      ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3249
    X_GEN_TAC `x:real^N` THEN REWRITE_TAC[lemma] THEN STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3250
    FIRST_X_ASSUM(MP_TAC o SPECL [`k:num`; `l:num`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3251
    FIRST_X_ASSUM(MP_TAC o SPECL [`k:num`; `m:num`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3252
    ASM_SIMP_TAC[LT_IMP_LE; IMP_IMP; REAL_LE_ANTISYM; REAL_SUB_0] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3253
    MATCH_MP_TAC EQ_IMP THEN BINOP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3254
    ASM_MESON_TAC[PERMUTES_IN_IMAGE; IN_NUMSEG; DOT_BASIS];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3255
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3256
  REWRITE_TAC[HAS_GMEASURE_MEASURABLE_MEASURE] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3257
  DISCH_THEN(ASSUME_TAC o CONJUNCT2) THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3258
   [MATCH_MP_TAC GMEASURABLE_CONVEX THEN REWRITE_TAC[CONVEX_CONVEX_HULL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3259
    MATCH_MP_TAC BOUNDED_CONVEX_HULL THEN REWRITE_TAC[BOUNDED_INSERT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3260
    ONCE_REWRITE_TAC[SIMPLE_IMAGE_GEN] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3261
    MATCH_MP_TAC FINITE_IMP_BOUNDED THEN MATCH_MP_TAC FINITE_IMAGE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3262
    REWRITE_TAC[GSYM numseg; FINITE_NUMSEG];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3263
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3264
  ASM_SIMP_TAC[REAL_FIELD `~(y = 0) ==> (x = inv y \<longleftrightarrow> y * x = 1)`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3265
               REAL_OF_NUM_EQ; FACT_NZ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3266
  FIRST_X_ASSUM(SUBST1_TAC o SYM) THEN MATCH_MP_TAC EQ_TRANS THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3267
  EXISTS_TAC `measure(interval[0:real^N,1])` THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3268
   [AP_TERM_TAC; REWRITE_TAC[MEASURE_INTERVAL; CONTENT_UNIT]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3269
  REWRITE_TAC[lemma] THEN MATCH_MP_TAC SUBSET_ANTISYM THEN CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3270
   [REWRITE_TAC[SUBSET; FORALL_IN_UNIONS; FORALL_IN_IMAGE; IMP_CONJ;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3271
                RIGHT_FORALL_IMP_THM; IN_ELIM_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3272
    SIMP_TAC[IMP_IMP; IN_INTERVAL; LAMBDA_BETA; VEC_COMPONENT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3273
    X_GEN_TAC `p:num->num` THEN STRIP_TAC THEN X_GEN_TAC `x:real^N` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3274
    STRIP_TAC THEN X_GEN_TAC `i:num` THEN REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3275
    MATCH_MP_TAC REAL_LE_TRANS THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3276
     [EXISTS_TAC `(x:real^N)$(p 1)`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3277
      EXISTS_TAC `(x:real^N)$(p(dimindex(:N)))`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3278
    ASM_REWRITE_TAC[] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3279
    FIRST_ASSUM(MP_TAC o SPEC `i:num` o MATCH_MP PERMUTES_SURJECTIVE) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3280
    ASM_MESON_TAC[LE_REFL; PERMUTES_IN_IMAGE; IN_NUMSEG];
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3281
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3282
  REWRITE_TAC[SET_RULE `s \<subseteq> UNIONS(IMAGE f t) \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3283
                        !x. x \<in> s ==> ?y. y \<in> t \<and> x \<in> f y`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3284
  X_GEN_TAC `x:real^N` THEN REWRITE_TAC[IN_INTERVAL; IN_ELIM_THM] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3285
  SIMP_TAC[VEC_COMPONENT] THEN DISCH_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3286
  MP_TAC(ISPEC `\i j. ~((x:real^N)$j \<le> x$i)` TOPOLOGICAL_SORT) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3287
  REWRITE_TAC[REAL_NOT_LE; REAL_NOT_LT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3288
  ANTS_TAC THENL [REAL_ARITH_TAC; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3289
  DISCH_THEN(MP_TAC o SPECL [`dimindex(:N)`; `1..dimindex(:N)`]) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3290
  REWRITE_TAC[HAS_SIZE_NUMSEG_1; EXTENSION; IN_IMAGE; IN_NUMSEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3291
  DISCH_THEN(X_CHOOSE_THEN `f:num->num` (CONJUNCTS_THEN2
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3292
   (ASSUME_TAC o GSYM) ASSUME_TAC)) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3293
  EXISTS_TAC `\i. if i \<in> 1..dimindex(:N) then f(i) else i` THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3294
  REWRITE_TAC[] THEN ONCE_REWRITE_TAC[ARITH_RULE
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3295
    `1 \<le> i \<and> i \<le> j \<and> j \<le> n \<longleftrightarrow>
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3296
     1 \<le> i \<and> 1 \<le> j \<and> i \<le> n \<and> j \<le> n \<and> i \<le> j`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3297
  ASM_SIMP_TAC[IN_NUMSEG; LE_REFL; DIMINDEX_GE_1] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3298
  CONJ_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3299
   [ALL_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3300
    ASM_MESON_TAC[LE_REFL; DIMINDEX_GE_1; LE_LT; REAL_LE_LT]] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3301
  SIMP_TAC[PERMUTES_FINITE_SURJECTIVE; FINITE_NUMSEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3302
  SIMP_TAC[IN_NUMSEG] THEN ASM_MESON_TAC[]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3303
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3304
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3305
(* Hence the gmeasure of a general simplex.                                   *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3306
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3307
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3308
lemma HAS_GMEASURE_SIMPLEX_0: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3309
 "!l:(real^N)list.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3310
        LENGTH l = dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3311
        ==> (convex hull (0 INSERT set_of_list l)) has_gmeasure
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3312
            abs(det(vector l)) / (FACT(dimindex(:N)))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3313
qed   REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3314
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3315
   `0 INSERT (set_of_list l) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3316
        IMAGE (\<lambda>x:real^N. transp(vector l:real^N^N) ** x)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3317
              (0 INSERT {basis i:real^N | 1 \<le> i \<and> i \<le> dimindex(:N)})`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3318
  SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3319
   [ONCE_REWRITE_TAC[SIMPLE_IMAGE_GEN] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3320
    REWRITE_TAC[IMAGE_CLAUSES; GSYM IMAGE_o; o_DEF] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3321
    REWRITE_TAC[MATRIX_VECTOR_MUL_RZERO] THEN AP_TERM_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3322
    SIMP_TAC[matrix_vector_mul; vector; transp; LAMBDA_BETA; basis] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3323
    ONCE_REWRITE_TAC[COND_RAND] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3324
    SIMP_TAC[REAL_MUL_RZERO; SUM_DELTA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3325
    REWRITE_TAC[EXTENSION; IN_IMAGE; IN_ELIM_THM; IN_NUMSEG] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3326
    ONCE_REWRITE_TAC[TAUT `a \<and> b \<and> c \<longleftrightarrow> ~(b \<and> c ==> ~a)`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3327
    X_GEN_TAC `y:real^N` THEN SIMP_TAC[LAMBDA_BETA; REAL_MUL_RID] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3328
    SIMP_TAC[CART_EQ; LAMBDA_BETA] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3329
    REWRITE_TAC[NOT_IMP; REAL_MUL_RID; GSYM CART_EQ] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3330
    ASM_REWRITE_TAC[IN_SET_OF_LIST; MEM_EXISTS_EL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3331
    EQ_TAC THEN DISCH_THEN(X_CHOOSE_THEN `i:num` STRIP_ASSUME_TAC) THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3332
     [EXISTS_TAC `SUC i`; EXISTS_TAC `i - 1`] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3333
    ASM_REWRITE_TAC[SUC_SUB1] THEN ASM_ARITH_TAC;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3334
    ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3335
  ASM_SIMP_TAC[GSYM CONVEX_HULL_LINEAR_IMAGE; MATRIX_VECTOR_MUL_LINEAR] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3336
  SUBGOAL_THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3337
   `det(vector l:real^N^N) = det(matrix(\<lambda>x:real^N. transp(vector l) ** x))`
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3338
  SUBST1_TAC THENL
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3339
   [REWRITE_TAC[MATRIX_OF_MATRIX_VECTOR_MUL; DET_TRANSP]; ALL_TAC] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3340
  REWRITE_TAC[real_div] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3341
  ASM_SIMP_TAC[GSYM(REWRITE_RULE[HAS_GMEASURE_MEASURABLE_MEASURE]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3342
                 HAS_GMEASURE_STD_SIMPLEX)] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3343
  MATCH_MP_TAC HAS_GMEASURE_LINEAR_IMAGE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3344
  REWRITE_TAC[MATRIX_VECTOR_MUL_LINEAR] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3345
  MATCH_MP_TAC GMEASURABLE_CONVEX THEN REWRITE_TAC[CONVEX_CONVEX_HULL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3346
  MATCH_MP_TAC BOUNDED_CONVEX_HULL THEN REWRITE_TAC[BOUNDED_INSERT] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3347
  ONCE_REWRITE_TAC[SIMPLE_IMAGE_GEN] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3348
  MATCH_MP_TAC FINITE_IMP_BOUNDED THEN MATCH_MP_TAC FINITE_IMAGE THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3349
  REWRITE_TAC[GSYM numseg; FINITE_NUMSEG]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3350
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3351
lemma HAS_GMEASURE_SIMPLEX: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3352
 "!a l:(real^N)list.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3353
        LENGTH l = dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3354
        ==> (convex hull (set_of_list(CONS a l))) has_gmeasure
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3355
            abs(det(vector(MAP (\<lambda>x. x - a) l))) / (FACT(dimindex(:N)))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3356
qed   REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3357
  MP_TAC(ISPEC `MAP (\<lambda>x:real^N. x - a) l` HAS_GMEASURE_SIMPLEX_0) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3358
  ASM_REWRITE_TAC[LENGTH_MAP; set_of_list] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3359
  DISCH_THEN(MP_TAC o SPEC `a:real^N` o MATCH_MP HAS_GMEASURE_TRANSLATION) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3360
  REWRITE_TAC[GSYM CONVEX_HULL_TRANSLATION] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3361
  MATCH_MP_TAC EQ_IMP THEN AP_THM_TAC THEN AP_TERM_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3362
  REWRITE_TAC[IMAGE_CLAUSES; VECTOR_ADD_RID; SET_OF_LIST_MAP] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3363
  REWRITE_TAC[GSYM IMAGE_o; o_DEF; VECTOR_ARITH `a + x - a:real^N = x`;
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3364
              SET_RULE `IMAGE (\<lambda>x. x) s = s`]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3365
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3366
lemma GMEASURABLE_SIMPLEX: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3367
 "!l. gmeasurable(convex hull (set_of_list l))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3368
qed   GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3369
  MATCH_MP_TAC GMEASURABLE_CONVEX THEN REWRITE_TAC[CONVEX_CONVEX_HULL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3370
  MATCH_MP_TAC BOUNDED_CONVEX_HULL THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3371
  MATCH_MP_TAC FINITE_IMP_BOUNDED THEN REWRITE_TAC[FINITE_SET_OF_LIST]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3372
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3373
lemma MEASURE_SIMPLEX: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3374
 "!a l:(real^N)list.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3375
        LENGTH l = dimindex(:N)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3376
        ==> measure(convex hull (set_of_list(CONS a l))) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3377
            abs(det(vector(MAP (\<lambda>x. x - a) l))) / (FACT(dimindex(:N)))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3378
qed   MESON_TAC[HAS_GMEASURE_SIMPLEX; HAS_GMEASURE_MEASURABLE_MEASURE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3379
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3380
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3381
(* Area of a triangle.                                                       *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3382
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3383
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3384
lemma HAS_GMEASURE_TRIANGLE: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3385
 "!a b c:real^2.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3386
        convex hull {a,b,c} has_gmeasure
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3387
        abs((b$1 - a$1) * (c$2 - a$2) - (b$2 - a$2) * (c$1 - a$1)) / 2"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3388
qed   REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3389
  MP_TAC(ISPECL [`a:real^2`; `[b;c]:(real^2)list`] HAS_GMEASURE_SIMPLEX) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3390
  REWRITE_TAC[LENGTH; DIMINDEX_2; ARITH; set_of_list; MAP] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3391
  CONV_TAC NUM_REDUCE_CONV THEN SIMP_TAC[DET_2; VECTOR_2] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3392
  SIMP_TAC[VECTOR_SUB_COMPONENT; DIMINDEX_2; ARITH]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3393
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3394
lemma GMEASURABLE_TRIANGLE: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3395
 "!a b c:real^N. gmeasurable(convex hull {a,b,c})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3396
qed   REPEAT GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3397
  MATCH_MP_TAC GMEASURABLE_CONVEX THEN REWRITE_TAC[CONVEX_CONVEX_HULL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3398
  MATCH_MP_TAC BOUNDED_CONVEX_HULL THEN MATCH_MP_TAC FINITE_IMP_BOUNDED THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3399
  REWRITE_TAC[FINITE_INSERT; FINITE_RULES]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3400
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3401
lemma MEASURE_TRIANGLE: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3402
 "!a b c:real^2.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3403
        measure(convex hull {a,b,c}) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3404
        abs((b$1 - a$1) * (c$2 - a$2) - (b$2 - a$2) * (c$1 - a$1)) / 2"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3405
qed   REWRITE_TAC[REWRITE_RULE[HAS_GMEASURE_MEASURABLE_MEASURE]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3406
               HAS_GMEASURE_TRIANGLE]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3407
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3408
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3409
(* Volume of a tetrahedron.                                                  *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3410
(* ------------------------------------------------------------------------- *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3411
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3412
lemma HAS_GMEASURE_TETRAHEDRON: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3413
 "!a b c d:real^3.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3414
        convex hull {a,b,c,d} has_gmeasure
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3415
        abs((b$1 - a$1) * (c$2 - a$2) * (d$3 - a$3) +
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3416
            (b$2 - a$2) * (c$3 - a$3) * (d$1 - a$1) +
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3417
            (b$3 - a$3) * (c$1 - a$1) * (d$2 - a$2) -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3418
            (b$1 - a$1) * (c$3 - a$3) * (d$2 - a$2) -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3419
            (b$2 - a$2) * (c$1 - a$1) * (d$3 - a$3) -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3420
            (b$3 - a$3) * (c$2 - a$2) * (d$1 - a$1)) /
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3421
           6"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3422
qed   REPEAT STRIP_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3423
  MP_TAC(ISPECL [`a:real^3`; `[b;c;d]:(real^3)list`] HAS_GMEASURE_SIMPLEX) THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3424
  REWRITE_TAC[LENGTH; DIMINDEX_3; ARITH; set_of_list; MAP] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3425
  CONV_TAC NUM_REDUCE_CONV THEN SIMP_TAC[DET_3; VECTOR_3] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3426
  SIMP_TAC[VECTOR_SUB_COMPONENT; DIMINDEX_3; ARITH]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3427
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3428
lemma GMEASURABLE_TETRAHEDRON: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3429
 "!a b c d:real^N. gmeasurable(convex hull {a,b,c,d})"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3430
qed   REPEAT GEN_TAC THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3431
  MATCH_MP_TAC GMEASURABLE_CONVEX THEN REWRITE_TAC[CONVEX_CONVEX_HULL] THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3432
  MATCH_MP_TAC BOUNDED_CONVEX_HULL THEN MATCH_MP_TAC FINITE_IMP_BOUNDED THEN
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3433
  REWRITE_TAC[FINITE_INSERT; FINITE_RULES]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3434
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3435
lemma MEASURE_TETRAHEDRON: True .. (*
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3436
 "!a b c d:real^3.
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3437
        measure(convex hull {a,b,c,d}) =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3438
        abs((b$1 - a$1) * (c$2 - a$2) * (d$3 - a$3) +
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3439
            (b$2 - a$2) * (c$3 - a$3) * (d$1 - a$1) +
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3440
            (b$3 - a$3) * (c$1 - a$1) * (d$2 - a$2) -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3441
            (b$1 - a$1) * (c$3 - a$3) * (d$2 - a$2) -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3442
            (b$2 - a$2) * (c$1 - a$1) * (d$3 - a$3) -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3443
            (b$3 - a$3) * (c$2 - a$2) * (d$1 - a$1)) / 6"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3444
qed   REWRITE_TAC[REWRITE_RULE[HAS_GMEASURE_MEASURABLE_MEASURE]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3445
               HAS_GMEASURE_TETRAHEDRON]);; *)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3446
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  3447
end