src/HOL/Analysis/Tagged_Division.thy
changeset 69677 a06b204527e6
parent 69661 a03a63b81f44
child 69680 96a43caa4902
equal deleted inserted replaced
69661:a03a63b81f44 69677:a06b204527e6
    30   scaleR_zero_right scaleR_minus_right scaleR_right_diff_distrib scaleR_eq_0_iff
    30   scaleR_zero_right scaleR_minus_right scaleR_right_diff_distrib scaleR_eq_0_iff
    31   scaleR_cancel_left scaleR_cancel_right scaleR_add_right scaleR_add_left real_vector_class.scaleR_one
    31   scaleR_cancel_left scaleR_cancel_right scaleR_add_right scaleR_add_left real_vector_class.scaleR_one
    32 
    32 
    33 
    33 
    34 subsection%unimportant \<open>Sundries\<close>
    34 subsection%unimportant \<open>Sundries\<close>
    35 (*FIXME restructure this entire section consists of single lemma *)
    35 
    36 
    36 
    37 text\<open>A transitive relation is well-founded if all initial segments are finite.\<close>
    37 text\<open>A transitive relation is well-founded if all initial segments are finite.\<close>
    38 lemma wf_finite_segments:
    38 lemma wf_finite_segments:
    39   assumes "irrefl r" and "trans r" and "\<And>x. finite {y. (y, x) \<in> r}"
    39   assumes "irrefl r" and "trans r" and "\<And>x. finite {y. (y, x) \<in> r}"
    40   shows "wf (r)"
    40   shows "wf (r)"
    53     by (meson diff_ge_0_iff_ge mult_right_mono \<open>u \<le> v\<close>)
    53     by (meson diff_ge_0_iff_ge mult_right_mono \<open>u \<le> v\<close>)
    54   then show ?thesis
    54   then show ?thesis
    55     by (simp add: field_simps)
    55     by (simp add: field_simps)
    56 qed
    56 qed
    57 
    57 
    58 subsection%unimportant \<open>Some useful lemmas about intervals\<close>
    58 subsection%important \<open>Some useful lemmas about intervals\<close>
    59 
    59 
    60 lemma interior_subset_union_intervals:
    60 lemma interior_subset_union_intervals:
    61   assumes "i = cbox a b"
    61   assumes "i = cbox a b"
    62     and "j = cbox c d"
    62     and "j = cbox c d"
    63     and "interior j \<noteq> {}"
    63     and "interior j \<noteq> {}"
   150   unfolding interval_lowerbound_def euclidean_representation_sum cbox_def
   150   unfolding interval_lowerbound_def euclidean_representation_sum cbox_def
   151   by (safe intro!: cInf_eq) auto
   151   by (safe intro!: cInf_eq) auto
   152 
   152 
   153 lemmas interval_bounds = interval_upperbound interval_lowerbound
   153 lemmas interval_bounds = interval_upperbound interval_lowerbound
   154 
   154 
   155 lemma%important
   155 lemma
   156   fixes X::"real set"
   156   fixes X::"real set"
   157   shows interval_upperbound_real[simp]: "interval_upperbound X = Sup X"
   157   shows interval_upperbound_real[simp]: "interval_upperbound X = Sup X"
   158     and interval_lowerbound_real[simp]: "interval_lowerbound X = Inf X"
   158     and interval_lowerbound_real[simp]: "interval_lowerbound X = Inf X"
   159   by%unimportant (auto simp: interval_upperbound_def interval_lowerbound_def)
   159   by (auto simp: interval_upperbound_def interval_lowerbound_def)
   160 
   160 
   161 lemma%important interval_bounds'[simp]:
   161 lemma interval_bounds'[simp]:
   162   assumes "cbox a b \<noteq> {}"
   162   assumes "cbox a b \<noteq> {}"
   163   shows "interval_upperbound (cbox a b) = b"
   163   shows "interval_upperbound (cbox a b) = b"
   164     and "interval_lowerbound (cbox a b) = a"
   164     and "interval_lowerbound (cbox a b) = a"
   165   using%unimportant assms unfolding box_ne_empty by auto
   165   using assms unfolding box_ne_empty by auto
   166 
   166 
   167 lemma%important interval_upperbound_Times:
   167 lemma interval_upperbound_Times:
   168   assumes "A \<noteq> {}" and "B \<noteq> {}"
   168   assumes "A \<noteq> {}" and "B \<noteq> {}"
   169   shows "interval_upperbound (A \<times> B) = (interval_upperbound A, interval_upperbound B)"
   169   shows "interval_upperbound (A \<times> B) = (interval_upperbound A, interval_upperbound B)"
   170 proof%unimportant-
   170 proof-
   171   from assms have fst_image_times': "A = fst ` (A \<times> B)" by simp
   171   from assms have fst_image_times': "A = fst ` (A \<times> B)" by simp
   172   have "(\<Sum>i\<in>Basis. (SUP x\<in>A \<times> B. x \<bullet> (i, 0)) *\<^sub>R i) = (\<Sum>i\<in>Basis. (SUP x\<in>A. x \<bullet> i) *\<^sub>R i)"
   172   have "(\<Sum>i\<in>Basis. (SUP x\<in>A \<times> B. x \<bullet> (i, 0)) *\<^sub>R i) = (\<Sum>i\<in>Basis. (SUP x\<in>A. x \<bullet> i) *\<^sub>R i)"
   173       by (subst (2) fst_image_times') (simp del: fst_image_times add: o_def inner_Pair_0)
   173       by (subst (2) fst_image_times') (simp del: fst_image_times add: o_def inner_Pair_0)
   174   moreover from assms have snd_image_times': "B = snd ` (A \<times> B)" by simp
   174   moreover from assms have snd_image_times': "B = snd ` (A \<times> B)" by simp
   175   have "(\<Sum>i\<in>Basis. (SUP x\<in>A \<times> B. x \<bullet> (0, i)) *\<^sub>R i) = (\<Sum>i\<in>Basis. (SUP x\<in>B. x \<bullet> i) *\<^sub>R i)"
   175   have "(\<Sum>i\<in>Basis. (SUP x\<in>A \<times> B. x \<bullet> (0, i)) *\<^sub>R i) = (\<Sum>i\<in>Basis. (SUP x\<in>B. x \<bullet> i) *\<^sub>R i)"
   176       by (subst (2) snd_image_times') (simp del: snd_image_times add: o_def inner_Pair_0)
   176       by (subst (2) snd_image_times') (simp del: snd_image_times add: o_def inner_Pair_0)
   177   ultimately show ?thesis unfolding interval_upperbound_def
   177   ultimately show ?thesis unfolding interval_upperbound_def
   178       by (subst sum_Basis_prod_eq) (auto simp add: sum_prod)
   178       by (subst sum_Basis_prod_eq) (auto simp add: sum_prod)
   179 qed
   179 qed
   180 
   180 
   181 lemma%important interval_lowerbound_Times:
   181 lemma interval_lowerbound_Times:
   182   assumes "A \<noteq> {}" and "B \<noteq> {}"
   182   assumes "A \<noteq> {}" and "B \<noteq> {}"
   183   shows "interval_lowerbound (A \<times> B) = (interval_lowerbound A, interval_lowerbound B)"
   183   shows "interval_lowerbound (A \<times> B) = (interval_lowerbound A, interval_lowerbound B)"
   184 proof%unimportant-
   184 proof-
   185   from assms have fst_image_times': "A = fst ` (A \<times> B)" by simp
   185   from assms have fst_image_times': "A = fst ` (A \<times> B)" by simp
   186   have "(\<Sum>i\<in>Basis. (INF x\<in>A \<times> B. x \<bullet> (i, 0)) *\<^sub>R i) = (\<Sum>i\<in>Basis. (INF x\<in>A. x \<bullet> i) *\<^sub>R i)"
   186   have "(\<Sum>i\<in>Basis. (INF x\<in>A \<times> B. x \<bullet> (i, 0)) *\<^sub>R i) = (\<Sum>i\<in>Basis. (INF x\<in>A. x \<bullet> i) *\<^sub>R i)"
   187       by (subst (2) fst_image_times') (simp del: fst_image_times add: o_def inner_Pair_0)
   187       by (subst (2) fst_image_times') (simp del: fst_image_times add: o_def inner_Pair_0)
   188   moreover from assms have snd_image_times': "B = snd ` (A \<times> B)" by simp
   188   moreover from assms have snd_image_times': "B = snd ` (A \<times> B)" by simp
   189   have "(\<Sum>i\<in>Basis. (INF x\<in>A \<times> B. x \<bullet> (0, i)) *\<^sub>R i) = (\<Sum>i\<in>Basis. (INF x\<in>B. x \<bullet> i) *\<^sub>R i)"
   189   have "(\<Sum>i\<in>Basis. (INF x\<in>A \<times> B. x \<bullet> (0, i)) *\<^sub>R i) = (\<Sum>i\<in>Basis. (INF x\<in>B. x \<bullet> i) *\<^sub>R i)"
   224   fixes \<gamma> :: "'a::euclidean_space \<Rightarrow> 'a set"
   224   fixes \<gamma> :: "'a::euclidean_space \<Rightarrow> 'a set"
   225   shows "gauge \<gamma> \<Longrightarrow> gauge (\<lambda>x. uminus ` \<gamma> (- x))"
   225   shows "gauge \<gamma> \<Longrightarrow> gauge (\<lambda>x. uminus ` \<gamma> (- x))"
   226   using equation_minus_iff
   226   using equation_minus_iff
   227   by (auto simp: gauge_def surj_def intro!: open_surjective_linear_image linear_uminus)
   227   by (auto simp: gauge_def surj_def intro!: open_surjective_linear_image linear_uminus)
   228 
   228 
   229 lemma%important gauge_Inter:
   229 lemma gauge_Inter:
   230   assumes "finite S"
   230   assumes "finite S"
   231     and "\<And>u. u\<in>S \<Longrightarrow> gauge (f u)"
   231     and "\<And>u. u\<in>S \<Longrightarrow> gauge (f u)"
   232   shows "gauge (\<lambda>x. \<Inter>{f u x | u. u \<in> S})"
   232   shows "gauge (\<lambda>x. \<Inter>{f u x | u. u \<in> S})"
   233 proof%unimportant -
   233 proof -
   234   have *: "\<And>x. {f u x |u. u \<in> S} = (\<lambda>u. f u x) ` S"
   234   have *: "\<And>x. {f u x |u. u \<in> S} = (\<lambda>u. f u x) ` S"
   235     by auto
   235     by auto
   236   show ?thesis
   236   show ?thesis
   237     unfolding gauge_def unfolding *
   237     unfolding gauge_def unfolding *
   238     using assms unfolding Ball_def Inter_iff mem_Collect_eq gauge_def by auto
   238     using assms unfolding Ball_def Inter_iff mem_Collect_eq gauge_def by auto
   239 qed
   239 qed
   240 
   240 
   241 lemma%important gauge_existence_lemma:
   241 lemma gauge_existence_lemma:
   242   "(\<forall>x. \<exists>d :: real. p x \<longrightarrow> 0 < d \<and> q d x) \<longleftrightarrow> (\<forall>x. \<exists>d>0. p x \<longrightarrow> q d x)"
   242   "(\<forall>x. \<exists>d :: real. p x \<longrightarrow> 0 < d \<and> q d x) \<longleftrightarrow> (\<forall>x. \<exists>d>0. p x \<longrightarrow> q d x)"
   243   by%unimportant (metis zero_less_one)
   243   by (metis zero_less_one)
   244 
   244 
   245 subsection%unimportant \<open>Attempt a systematic general set of "offset" results for components\<close>
   245 subsection%important \<open>Attempt a systematic general set of "offset" results for components\<close>
   246 (*FIXME Restructure *)
   246 (*FIXME Restructure, the subsection consists only of 1 lemma *)
   247 lemma gauge_modify:
   247 lemma gauge_modify:
   248   assumes "(\<forall>S. open S \<longrightarrow> open {x. f(x) \<in> S})" "gauge d"
   248   assumes "(\<forall>S. open S \<longrightarrow> open {x. f(x) \<in> S})" "gauge d"
   249   shows "gauge (\<lambda>x. {y. f y \<in> d (f x)})"
   249   shows "gauge (\<lambda>x. {y. f y \<in> d (f x)})"
   250   using assms unfolding gauge_def by force
   250   using assms unfolding gauge_def by force
   251 
   251 
   603     ultimately show "\<Union>p = cbox a b"
   603     ultimately show "\<Union>p = cbox a b"
   604       by auto
   604       by auto
   605   qed
   605   qed
   606 qed
   606 qed
   607 
   607 
   608 proposition%important partial_division_extend_interval:
   608 proposition partial_division_extend_interval:
   609   assumes "p division_of (\<Union>p)" "(\<Union>p) \<subseteq> cbox a b"
   609   assumes "p division_of (\<Union>p)" "(\<Union>p) \<subseteq> cbox a b"
   610   obtains q where "p \<subseteq> q" "q division_of cbox a (b::'a::euclidean_space)"
   610   obtains q where "p \<subseteq> q" "q division_of cbox a (b::'a::euclidean_space)"
   611 proof%unimportant (cases "p = {}")
   611 proof (cases "p = {}")
   612   case True
   612   case True
   613   obtain q where "q division_of (cbox a b)"
   613   obtain q where "q division_of (cbox a b)"
   614     by (rule elementary_interval)
   614     by (rule elementary_interval)
   615   then show ?thesis
   615   then show ?thesis
   616     using True that by blast
   616     using True that by blast
   685 
   685 
   686 lemma elementary_subset_cbox:
   686 lemma elementary_subset_cbox:
   687   "p division_of S \<Longrightarrow> \<exists>a b. S \<subseteq> cbox a (b::'a::euclidean_space)"
   687   "p division_of S \<Longrightarrow> \<exists>a b. S \<subseteq> cbox a (b::'a::euclidean_space)"
   688   by (meson bounded_subset_cbox_symmetric elementary_bounded)
   688   by (meson bounded_subset_cbox_symmetric elementary_bounded)
   689 
   689 
   690 lemma%important division_union_intervals_exists:
   690 proposition division_union_intervals_exists:
   691   fixes a b :: "'a::euclidean_space"
   691   fixes a b :: "'a::euclidean_space"
   692   assumes "cbox a b \<noteq> {}"
   692   assumes "cbox a b \<noteq> {}"
   693   obtains p where "(insert (cbox a b) p) division_of (cbox a b \<union> cbox c d)"
   693   obtains p where "(insert (cbox a b) p) division_of (cbox a b \<union> cbox c d)"
   694 proof%unimportant (cases "cbox c d = {}")
   694 proof (cases "cbox c d = {}")
   695   case True
   695   case True
   696   with assms that show ?thesis by force
   696   with assms that show ?thesis by force
   697 next
   697 next
   698   case False
   698   case False
   699   show ?thesis
   699   show ?thesis
   737     and "\<And>p. p \<in> f \<Longrightarrow> p division_of (\<Union>p)"
   737     and "\<And>p. p \<in> f \<Longrightarrow> p division_of (\<Union>p)"
   738     and "\<And>k1 k2. k1 \<in> \<Union>f \<Longrightarrow> k2 \<in> \<Union>f \<Longrightarrow> k1 \<noteq> k2 \<Longrightarrow> interior k1 \<inter> interior k2 = {}"
   738     and "\<And>k1 k2. k1 \<in> \<Union>f \<Longrightarrow> k2 \<in> \<Union>f \<Longrightarrow> k1 \<noteq> k2 \<Longrightarrow> interior k1 \<inter> interior k2 = {}"
   739   shows "\<Union>f division_of \<Union>\<Union>f"
   739   shows "\<Union>f division_of \<Union>\<Union>f"
   740   using assms  by (auto intro!: division_ofI)
   740   using assms  by (auto intro!: division_ofI)
   741 
   741 
   742 lemma%important elementary_union_interval:
   742 lemma elementary_union_interval:
   743   fixes a b :: "'a::euclidean_space"
   743   fixes a b :: "'a::euclidean_space"
   744   assumes "p division_of \<Union>p"
   744   assumes "p division_of \<Union>p"
   745   obtains q where "q division_of (cbox a b \<union> \<Union>p)"
   745   obtains q where "q division_of (cbox a b \<union> \<Union>p)"
   746 proof%unimportant (cases "p = {} \<or> cbox a b = {}")
   746 proof (cases "p = {} \<or> cbox a b = {}")
   747   case True
   747   case True
   748   obtain p where "p division_of (cbox a b)"
   748   obtain p where "p division_of (cbox a b)"
   749     by (rule elementary_interval)
   749     by (rule elementary_interval)
   750   then show thesis
   750   then show thesis
   751     using True assms that by auto
   751     using True assms that by auto
   853   qed (insert assms, auto)
   853   qed (insert assms, auto)
   854   then show ?thesis
   854   then show ?thesis
   855     using that by auto
   855     using that by auto
   856 qed
   856 qed
   857 
   857 
   858 lemma%important elementary_union:
   858 lemma elementary_union:
   859   fixes S T :: "'a::euclidean_space set"
   859   fixes S T :: "'a::euclidean_space set"
   860   assumes "ps division_of S" "pt division_of T"
   860   assumes "ps division_of S" "pt division_of T"
   861   obtains p where "p division_of (S \<union> T)"
   861   obtains p where "p division_of (S \<union> T)"
   862 proof%unimportant -
   862 proof -
   863   have *: "S \<union> T = \<Union>ps \<union> \<Union>pt"
   863   have *: "S \<union> T = \<Union>ps \<union> \<Union>pt"
   864     using assms unfolding division_of_def by auto
   864     using assms unfolding division_of_def by auto
   865   show ?thesis
   865   show ?thesis
   866     apply (rule elementary_unions_intervals[of "ps \<union> pt"])
   866     apply (rule elementary_unions_intervals[of "ps \<union> pt"])
   867     using assms apply auto
   867     using assms apply auto
   868     by (simp add: * that)
   868     by (simp add: * that)
   869 qed
   869 qed
   870 
   870 
   871 lemma%important partial_division_extend:
   871 lemma partial_division_extend:
   872   fixes T :: "'a::euclidean_space set"
   872   fixes T :: "'a::euclidean_space set"
   873   assumes "p division_of S"
   873   assumes "p division_of S"
   874     and "q division_of T"
   874     and "q division_of T"
   875     and "S \<subseteq> T"
   875     and "S \<subseteq> T"
   876   obtains r where "p \<subseteq> r" and "r division_of T"
   876   obtains r where "p \<subseteq> r" and "r division_of T"
   877 proof%unimportant -
   877 proof -
   878   note divp = division_ofD[OF assms(1)] and divq = division_ofD[OF assms(2)]
   878   note divp = division_ofD[OF assms(1)] and divq = division_ofD[OF assms(2)]
   879   obtain a b where ab: "T \<subseteq> cbox a b"
   879   obtain a b where ab: "T \<subseteq> cbox a b"
   880     using elementary_subset_cbox[OF assms(2)] by auto
   880     using elementary_subset_cbox[OF assms(2)] by auto
   881   obtain r1 where "p \<subseteq> r1" "r1 division_of (cbox a b)"
   881   obtain r1 where "p \<subseteq> r1" "r1 division_of (cbox a b)"
   882     using assms
   882     using assms
   929      apply (auto simp: div Teq)
   929      apply (auto simp: div Teq)
   930     done
   930     done
   931 qed
   931 qed
   932 
   932 
   933 
   933 
   934 lemma%important division_split:
   934 lemma division_split:
   935   fixes a :: "'a::euclidean_space"
   935   fixes a :: "'a::euclidean_space"
   936   assumes "p division_of (cbox a b)"
   936   assumes "p division_of (cbox a b)"
   937     and k: "k\<in>Basis"
   937     and k: "k\<in>Basis"
   938   shows "{l \<inter> {x. x\<bullet>k \<le> c} | l. l \<in> p \<and> l \<inter> {x. x\<bullet>k \<le> c} \<noteq> {}} division_of(cbox a b \<inter> {x. x\<bullet>k \<le> c})"
   938   shows "{l \<inter> {x. x\<bullet>k \<le> c} | l. l \<in> p \<and> l \<inter> {x. x\<bullet>k \<le> c} \<noteq> {}} division_of(cbox a b \<inter> {x. x\<bullet>k \<le> c})"
   939       (is "?p1 division_of ?I1")
   939       (is "?p1 division_of ?I1")
   940     and "{l \<inter> {x. x\<bullet>k \<ge> c} | l. l \<in> p \<and> l \<inter> {x. x\<bullet>k \<ge> c} \<noteq> {}} division_of (cbox a b \<inter> {x. x\<bullet>k \<ge> c})"
   940     and "{l \<inter> {x. x\<bullet>k \<ge> c} | l. l \<in> p \<and> l \<inter> {x. x\<bullet>k \<ge> c} \<noteq> {}} division_of (cbox a b \<inter> {x. x\<bullet>k \<ge> c})"
   941       (is "?p2 division_of ?I2")
   941       (is "?p2 division_of ?I2")
   942 proof%unimportant (rule_tac[!] division_ofI)
   942 proof (rule_tac[!] division_ofI)
   943   note p = division_ofD[OF assms(1)]
   943   note p = division_ofD[OF assms(1)]
   944   show "finite ?p1" "finite ?p2"
   944   show "finite ?p1" "finite ?p2"
   945     using p(1) by auto
   945     using p(1) by auto
   946   show "\<Union>?p1 = ?I1" "\<Union>?p2 = ?I2"
   946   show "\<Union>?p1 = ?I1" "\<Union>?p2 = ?I2"
   947     unfolding p(6)[symmetric] by auto
   947     unfolding p(6)[symmetric] by auto
  1018   where "s tagged_division_of i \<longleftrightarrow> s tagged_partial_division_of i \<and> (\<Union>{K. \<exists>x. (x,K) \<in> s} = i)"
  1018   where "s tagged_division_of i \<longleftrightarrow> s tagged_partial_division_of i \<and> (\<Union>{K. \<exists>x. (x,K) \<in> s} = i)"
  1019 
  1019 
  1020 lemma tagged_division_of_finite: "s tagged_division_of i \<Longrightarrow> finite s"
  1020 lemma tagged_division_of_finite: "s tagged_division_of i \<Longrightarrow> finite s"
  1021   unfolding tagged_division_of_def tagged_partial_division_of_def by auto
  1021   unfolding tagged_division_of_def tagged_partial_division_of_def by auto
  1022 
  1022 
  1023 lemma%important tagged_division_of:
  1023 lemma tagged_division_of:
  1024   "s tagged_division_of i \<longleftrightarrow>
  1024   "s tagged_division_of i \<longleftrightarrow>
  1025     finite s \<and>
  1025     finite s \<and>
  1026     (\<forall>x K. (x, K) \<in> s \<longrightarrow> x \<in> K \<and> K \<subseteq> i \<and> (\<exists>a b. K = cbox a b)) \<and>
  1026     (\<forall>x K. (x, K) \<in> s \<longrightarrow> x \<in> K \<and> K \<subseteq> i \<and> (\<exists>a b. K = cbox a b)) \<and>
  1027     (\<forall>x1 K1 x2 K2. (x1, K1) \<in> s \<and> (x2, K2) \<in> s \<and> (x1, K1) \<noteq> (x2, K2) \<longrightarrow>
  1027     (\<forall>x1 K1 x2 K2. (x1, K1) \<in> s \<and> (x2, K2) \<in> s \<and> (x1, K1) \<noteq> (x2, K2) \<longrightarrow>
  1028       interior K1 \<inter> interior K2 = {}) \<and>
  1028       interior K1 \<inter> interior K2 = {}) \<and>
  1029     (\<Union>{K. \<exists>x. (x,K) \<in> s} = i)"
  1029     (\<Union>{K. \<exists>x. (x,K) \<in> s} = i)"
  1030   unfolding%unimportant tagged_division_of_def tagged_partial_division_of_def by auto
  1030   unfolding tagged_division_of_def tagged_partial_division_of_def by auto
  1031 
  1031 
  1032 lemma tagged_division_ofI:
  1032 lemma tagged_division_ofI:
  1033   assumes "finite s"
  1033   assumes "finite s"
  1034     and "\<And>x K. (x,K) \<in> s \<Longrightarrow> x \<in> K"
  1034     and "\<And>x K. (x,K) \<in> s \<Longrightarrow> x \<in> K"
  1035     and "\<And>x K. (x,K) \<in> s \<Longrightarrow> K \<subseteq> i"
  1035     and "\<And>x K. (x,K) \<in> s \<Longrightarrow> K \<subseteq> i"
  1050     and "\<And>x1 K1 x2 K2. (x1, K1) \<in> s \<Longrightarrow> (x2, K2) \<in> s \<Longrightarrow> (x1, K1) \<noteq> (x2, K2) \<Longrightarrow>
  1050     and "\<And>x1 K1 x2 K2. (x1, K1) \<in> s \<Longrightarrow> (x2, K2) \<in> s \<Longrightarrow> (x1, K1) \<noteq> (x2, K2) \<Longrightarrow>
  1051       interior K1 \<inter> interior K2 = {}"
  1051       interior K1 \<inter> interior K2 = {}"
  1052     and "(\<Union>{K. \<exists>x. (x,K) \<in> s} = i)"
  1052     and "(\<Union>{K. \<exists>x. (x,K) \<in> s} = i)"
  1053   using assms unfolding tagged_division_of by blast+
  1053   using assms unfolding tagged_division_of by blast+
  1054 
  1054 
  1055 lemma%important division_of_tagged_division:
  1055 lemma division_of_tagged_division:
  1056   assumes "s tagged_division_of i"
  1056   assumes "s tagged_division_of i"
  1057   shows "(snd ` s) division_of i"
  1057   shows "(snd ` s) division_of i"
  1058 proof%unimportant (rule division_ofI)
  1058 proof (rule division_ofI)
  1059   note assm = tagged_division_ofD[OF assms]
  1059   note assm = tagged_division_ofD[OF assms]
  1060   show "\<Union>(snd ` s) = i" "finite (snd ` s)"
  1060   show "\<Union>(snd ` s) = i" "finite (snd ` s)"
  1061     using assm by auto
  1061     using assm by auto
  1062   fix k
  1062   fix k
  1063   assume k: "k \<in> snd ` s"
  1063   assume k: "k \<in> snd ` s"
  1071     by auto
  1071     by auto
  1072   then show "interior k \<inter> interior k' = {}"
  1072   then show "interior k \<inter> interior k' = {}"
  1073     using assm(5) k'(2) xk by blast
  1073     using assm(5) k'(2) xk by blast
  1074 qed
  1074 qed
  1075 
  1075 
  1076 lemma%important partial_division_of_tagged_division:
  1076 lemma partial_division_of_tagged_division:
  1077   assumes "s tagged_partial_division_of i"
  1077   assumes "s tagged_partial_division_of i"
  1078   shows "(snd ` s) division_of \<Union>(snd ` s)"
  1078   shows "(snd ` s) division_of \<Union>(snd ` s)"
  1079 proof%unimportant (rule division_ofI)
  1079 proof (rule division_ofI)
  1080   note assm = tagged_partial_division_ofD[OF assms]
  1080   note assm = tagged_partial_division_ofD[OF assms]
  1081   show "finite (snd ` s)" "\<Union>(snd ` s) = \<Union>(snd ` s)"
  1081   show "finite (snd ` s)" "\<Union>(snd ` s) = \<Union>(snd ` s)"
  1082     using assm by auto
  1082     using assm by auto
  1083   fix k
  1083   fix k
  1084   assume k: "k \<in> snd ` s"
  1084   assume k: "k \<in> snd ` s"
  1119 
  1119 
  1120 lemma tagged_division_of_self_real: "x \<in> {a .. b::real} \<Longrightarrow> {(x,{a .. b})} tagged_division_of {a .. b}"
  1120 lemma tagged_division_of_self_real: "x \<in> {a .. b::real} \<Longrightarrow> {(x,{a .. b})} tagged_division_of {a .. b}"
  1121   unfolding box_real[symmetric]
  1121   unfolding box_real[symmetric]
  1122   by (rule tagged_division_of_self)
  1122   by (rule tagged_division_of_self)
  1123 
  1123 
  1124 lemma%important tagged_division_Un:
  1124 lemma tagged_division_Un:
  1125   assumes "p1 tagged_division_of s1"
  1125   assumes "p1 tagged_division_of s1"
  1126     and "p2 tagged_division_of s2"
  1126     and "p2 tagged_division_of s2"
  1127     and "interior s1 \<inter> interior s2 = {}"
  1127     and "interior s1 \<inter> interior s2 = {}"
  1128   shows "(p1 \<union> p2) tagged_division_of (s1 \<union> s2)"
  1128   shows "(p1 \<union> p2) tagged_division_of (s1 \<union> s2)"
  1129 proof%unimportant (rule tagged_division_ofI)
  1129 proof (rule tagged_division_ofI)
  1130   note p1 = tagged_division_ofD[OF assms(1)]
  1130   note p1 = tagged_division_ofD[OF assms(1)]
  1131   note p2 = tagged_division_ofD[OF assms(2)]
  1131   note p2 = tagged_division_ofD[OF assms(2)]
  1132   show "finite (p1 \<union> p2)"
  1132   show "finite (p1 \<union> p2)"
  1133     using p1(1) p2(1) by auto
  1133     using p1(1) p2(1) by auto
  1134   show "\<Union>{k. \<exists>x. (x, k) \<in> p1 \<union> p2} = s1 \<union> s2"
  1134   show "\<Union>{k. \<exists>x. (x, k) \<in> p1 \<union> p2} = s1 \<union> s2"
  1147     apply (cases "(x, k) \<in> p1")
  1147     apply (cases "(x, k) \<in> p1")
  1148     apply (meson "*" UnE assms(1) assms(2) p1(5) tagged_division_ofD(3) xk'(1) xk'(2))
  1148     apply (meson "*" UnE assms(1) assms(2) p1(5) tagged_division_ofD(3) xk'(1) xk'(2))
  1149     by (metis "*" UnE assms(1) assms(2) inf_sup_aci(1) p2(5) tagged_division_ofD(3) xk xk'(1) xk'(2))
  1149     by (metis "*" UnE assms(1) assms(2) inf_sup_aci(1) p2(5) tagged_division_ofD(3) xk xk'(1) xk'(2))
  1150 qed
  1150 qed
  1151 
  1151 
  1152 lemma%important tagged_division_Union:
  1152 lemma tagged_division_Union:
  1153   assumes "finite I"
  1153   assumes "finite I"
  1154     and tag: "\<And>i. i\<in>I \<Longrightarrow> pfn i tagged_division_of i"
  1154     and tag: "\<And>i. i\<in>I \<Longrightarrow> pfn i tagged_division_of i"
  1155     and disj: "\<And>i1 i2. \<lbrakk>i1 \<in> I; i2 \<in> I; i1 \<noteq> i2\<rbrakk> \<Longrightarrow> interior(i1) \<inter> interior(i2) = {}"
  1155     and disj: "\<And>i1 i2. \<lbrakk>i1 \<in> I; i2 \<in> I; i1 \<noteq> i2\<rbrakk> \<Longrightarrow> interior(i1) \<inter> interior(i2) = {}"
  1156   shows "\<Union>(pfn ` I) tagged_division_of (\<Union>I)"
  1156   shows "\<Union>(pfn ` I) tagged_division_of (\<Union>I)"
  1157 proof%unimportant (rule tagged_division_ofI)
  1157 proof (rule tagged_division_ofI)
  1158   note assm = tagged_division_ofD[OF tag]
  1158   note assm = tagged_division_ofD[OF tag]
  1159   show "finite (\<Union>(pfn ` I))"
  1159   show "finite (\<Union>(pfn ` I))"
  1160     using assms by auto
  1160     using assms by auto
  1161   have "\<Union>{k. \<exists>x. (x, k) \<in> \<Union>(pfn ` I)} = \<Union>((\<lambda>i. \<Union>{k. \<exists>x. (x, k) \<in> pfn i}) ` I)"
  1161   have "\<Union>{k. \<exists>x. (x, k) \<in> \<Union>(pfn ` I)} = \<Union>((\<lambda>i. \<Union>{k. \<exists>x. (x, k) \<in> pfn i}) ` I)"
  1162     by blast
  1162     by blast
  1227   shows "(p1 \<union> p2) tagged_division_of {a .. b}"
  1227   shows "(p1 \<union> p2) tagged_division_of {a .. b}"
  1228   using assms
  1228   using assms
  1229   unfolding box_real[symmetric]
  1229   unfolding box_real[symmetric]
  1230   by (rule tagged_division_Un_interval)
  1230   by (rule tagged_division_Un_interval)
  1231 
  1231 
  1232 lemma%important tagged_division_split_left_inj:
  1232 lemma tagged_division_split_left_inj:
  1233   assumes d: "d tagged_division_of i"
  1233   assumes d: "d tagged_division_of i"
  1234   and tags: "(x1, K1) \<in> d" "(x2, K2) \<in> d"
  1234   and tags: "(x1, K1) \<in> d" "(x2, K2) \<in> d"
  1235   and "K1 \<noteq> K2"
  1235   and "K1 \<noteq> K2"
  1236   and eq: "K1 \<inter> {x. x \<bullet> k \<le> c} = K2 \<inter> {x. x \<bullet> k \<le> c}"
  1236   and eq: "K1 \<inter> {x. x \<bullet> k \<le> c} = K2 \<inter> {x. x \<bullet> k \<le> c}"
  1237     shows "interior (K1 \<inter> {x. x\<bullet>k \<le> c}) = {}"
  1237     shows "interior (K1 \<inter> {x. x\<bullet>k \<le> c}) = {}"
  1238 proof%unimportant -
  1238 proof -
  1239   have "interior (K1 \<inter> K2) = {} \<or> (x2, K2) = (x1, K1)"
  1239   have "interior (K1 \<inter> K2) = {} \<or> (x2, K2) = (x1, K1)"
  1240     using tags d by (metis (no_types) interior_Int tagged_division_ofD(5))
  1240     using tags d by (metis (no_types) interior_Int tagged_division_ofD(5))
  1241   then show ?thesis
  1241   then show ?thesis
  1242     using eq \<open>K1 \<noteq> K2\<close> by (metis (no_types) inf_assoc inf_bot_left inf_left_idem interior_Int old.prod.inject)
  1242     using eq \<open>K1 \<noteq> K2\<close> by (metis (no_types) inf_assoc inf_bot_left inf_left_idem interior_Int old.prod.inject)
  1243 qed
  1243 qed
  1253     using tags d by (metis (no_types) interior_Int tagged_division_ofD(5))
  1253     using tags d by (metis (no_types) interior_Int tagged_division_ofD(5))
  1254   then show ?thesis
  1254   then show ?thesis
  1255     using eq \<open>K1 \<noteq> K2\<close> by (metis (no_types) inf_assoc inf_bot_left inf_left_idem interior_Int old.prod.inject)
  1255     using eq \<open>K1 \<noteq> K2\<close> by (metis (no_types) inf_assoc inf_bot_left inf_left_idem interior_Int old.prod.inject)
  1256 qed
  1256 qed
  1257 
  1257 
  1258 lemma%important (in comm_monoid_set) over_tagged_division_lemma:
  1258 lemma (in comm_monoid_set) over_tagged_division_lemma:
  1259   assumes "p tagged_division_of i"
  1259   assumes "p tagged_division_of i"
  1260     and "\<And>u v. box u v = {} \<Longrightarrow> d (cbox u v) = \<^bold>1"
  1260     and "\<And>u v. box u v = {} \<Longrightarrow> d (cbox u v) = \<^bold>1"
  1261   shows "F (\<lambda>(_, k). d k) p = F d (snd ` p)"
  1261   shows "F (\<lambda>(_, k). d k) p = F d (snd ` p)"
  1262 proof%unimportant -
  1262 proof -
  1263   have *: "(\<lambda>(_ ,k). d k) = d \<circ> snd"
  1263   have *: "(\<lambda>(_ ,k). d k) = d \<circ> snd"
  1264     by (simp add: fun_eq_iff)
  1264     by (simp add: fun_eq_iff)
  1265   note assm = tagged_division_ofD[OF assms(1)]
  1265   note assm = tagged_division_ofD[OF assms(1)]
  1266   show ?thesis
  1266   show ?thesis
  1267     unfolding *
  1267     unfolding *
  1291 text \<open>This auxiliary structure is used to sum up over the elements of a division. Main theorem is
  1291 text \<open>This auxiliary structure is used to sum up over the elements of a division. Main theorem is
  1292   \<open>operative_division\<close>. Instances for the monoid are \<^typ>\<open>'a option\<close>, \<^typ>\<open>real\<close>, and
  1292   \<open>operative_division\<close>. Instances for the monoid are \<^typ>\<open>'a option\<close>, \<^typ>\<open>real\<close>, and
  1293   \<^typ>\<open>bool\<close>.\<close>
  1293   \<^typ>\<open>bool\<close>.\<close>
  1294 
  1294 
  1295 paragraph%important \<open>Using additivity of lifted function to encode definedness.\<close>
  1295 paragraph%important \<open>Using additivity of lifted function to encode definedness.\<close>
  1296 text%important \<open>%whitespace\<close>
  1296 text \<open>%whitespace\<close>
  1297 definition%important lift_option :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'a option \<Rightarrow> 'b option \<Rightarrow> 'c option"
  1297 definition%important lift_option :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'a option \<Rightarrow> 'b option \<Rightarrow> 'c option"
  1298 where
  1298 where
  1299   "lift_option f a' b' = Option.bind a' (\<lambda>a. Option.bind b' (\<lambda>b. Some (f a b)))"
  1299   "lift_option f a' b' = Option.bind a' (\<lambda>a. Option.bind b' (\<lambda>b. Some (f a b)))"
  1300 
  1300 
  1301 lemma lift_option_simps[simp]:
  1301 lemma lift_option_simps[simp]:
  1305   by (auto simp: lift_option_def)
  1305   by (auto simp: lift_option_def)
  1306 
  1306 
  1307 lemma%important comm_monoid_lift_option:
  1307 lemma%important comm_monoid_lift_option:
  1308   assumes "comm_monoid f z"
  1308   assumes "comm_monoid f z"
  1309   shows "comm_monoid (lift_option f) (Some z)"
  1309   shows "comm_monoid (lift_option f) (Some z)"
  1310 proof%unimportant -
  1310 proof -
  1311   from assms interpret comm_monoid f z .
  1311   from assms interpret comm_monoid f z .
  1312   show ?thesis
  1312   show ?thesis
  1313     by standard (auto simp: lift_option_def ac_simps split: bind_split)
  1313     by standard (auto simp: lift_option_def ac_simps split: bind_split)
  1314 qed
  1314 qed
  1315 
  1315 
  1332 lemma bgauge_existence_lemma: "(\<forall>x\<in>s. \<exists>d::real. 0 < d \<and> q d x) \<longleftrightarrow> (\<forall>x. \<exists>d>0. x\<in>s \<longrightarrow> q d x)"
  1332 lemma bgauge_existence_lemma: "(\<forall>x\<in>s. \<exists>d::real. 0 < d \<and> q d x) \<longleftrightarrow> (\<forall>x. \<exists>d>0. x\<in>s \<longrightarrow> q d x)"
  1333   by (meson zero_less_one)
  1333   by (meson zero_less_one)
  1334 
  1334 
  1335 
  1335 
  1336 paragraph \<open>Division points\<close>
  1336 paragraph \<open>Division points\<close>
  1337 text%important \<open>%whitespace\<close>
  1337 text \<open>%whitespace\<close>
  1338 definition%important "division_points (k::('a::euclidean_space) set) d =
  1338 definition%important "division_points (k::('a::euclidean_space) set) d =
  1339    {(j,x). j \<in> Basis \<and> (interval_lowerbound k)\<bullet>j < x \<and> x < (interval_upperbound k)\<bullet>j \<and>
  1339    {(j,x). j \<in> Basis \<and> (interval_lowerbound k)\<bullet>j < x \<and> x < (interval_upperbound k)\<bullet>j \<and>
  1340      (\<exists>i\<in>d. (interval_lowerbound i)\<bullet>j = x \<or> (interval_upperbound i)\<bullet>j = x)}"
  1340      (\<exists>i\<in>d. (interval_lowerbound i)\<bullet>j = x \<or> (interval_upperbound i)\<bullet>j = x)}"
  1341 
  1341 
  1342 lemma%important division_points_finite:
  1342 lemma division_points_finite:
  1343   fixes i :: "'a::euclidean_space set"
  1343   fixes i :: "'a::euclidean_space set"
  1344   assumes "d division_of i"
  1344   assumes "d division_of i"
  1345   shows "finite (division_points i d)"
  1345   shows "finite (division_points i d)"
  1346 proof%unimportant -
  1346 proof -
  1347   note assm = division_ofD[OF assms]
  1347   note assm = division_ofD[OF assms]
  1348   let ?M = "\<lambda>j. {(j,x)|x. (interval_lowerbound i)\<bullet>j < x \<and> x < (interval_upperbound i)\<bullet>j \<and>
  1348   let ?M = "\<lambda>j. {(j,x)|x. (interval_lowerbound i)\<bullet>j < x \<and> x < (interval_upperbound i)\<bullet>j \<and>
  1349     (\<exists>i\<in>d. (interval_lowerbound i)\<bullet>j = x \<or> (interval_upperbound i)\<bullet>j = x)}"
  1349     (\<exists>i\<in>d. (interval_lowerbound i)\<bullet>j = x \<or> (interval_upperbound i)\<bullet>j = x)}"
  1350   have *: "division_points i d = \<Union>(?M ` Basis)"
  1350   have *: "division_points i d = \<Union>(?M ` Basis)"
  1351     unfolding division_points_def by auto
  1351     unfolding division_points_def by auto
  1352   show ?thesis
  1352   show ?thesis
  1353     unfolding * using assm by auto
  1353     unfolding * using assm by auto
  1354 qed
  1354 qed
  1355 
  1355 
  1356 lemma%important division_points_subset:
  1356 lemma division_points_subset:
  1357   fixes a :: "'a::euclidean_space"
  1357   fixes a :: "'a::euclidean_space"
  1358   assumes "d division_of (cbox a b)"
  1358   assumes "d division_of (cbox a b)"
  1359     and "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"  "a\<bullet>k < c" "c < b\<bullet>k"
  1359     and "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"  "a\<bullet>k < c" "c < b\<bullet>k"
  1360     and k: "k \<in> Basis"
  1360     and k: "k \<in> Basis"
  1361   shows "division_points (cbox a b \<inter> {x. x\<bullet>k \<le> c}) {l \<inter> {x. x\<bullet>k \<le> c} | l . l \<in> d \<and> l \<inter> {x. x\<bullet>k \<le> c} \<noteq> {}} \<subseteq>
  1361   shows "division_points (cbox a b \<inter> {x. x\<bullet>k \<le> c}) {l \<inter> {x. x\<bullet>k \<le> c} | l . l \<in> d \<and> l \<inter> {x. x\<bullet>k \<le> c} \<noteq> {}} \<subseteq>
  1362       division_points (cbox a b) d" (is ?t1)
  1362       division_points (cbox a b) d" (is ?t1)
  1363     and "division_points (cbox a b \<inter> {x. x\<bullet>k \<ge> c}) {l \<inter> {x. x\<bullet>k \<ge> c} | l . l \<in> d \<and> \<not>(l \<inter> {x. x\<bullet>k \<ge> c} = {})} \<subseteq>
  1363     and "division_points (cbox a b \<inter> {x. x\<bullet>k \<ge> c}) {l \<inter> {x. x\<bullet>k \<ge> c} | l . l \<in> d \<and> \<not>(l \<inter> {x. x\<bullet>k \<ge> c} = {})} \<subseteq>
  1364       division_points (cbox a b) d" (is ?t2)
  1364       division_points (cbox a b) d" (is ?t2)
  1365 proof%unimportant -
  1365 proof -
  1366   note assm = division_ofD[OF assms(1)]
  1366   note assm = division_ofD[OF assms(1)]
  1367   have *: "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i"
  1367   have *: "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i"
  1368     "\<forall>i\<in>Basis. a\<bullet>i \<le> (\<Sum>i\<in>Basis. (if i = k then min (b \<bullet> k) c else  b \<bullet> i) *\<^sub>R i) \<bullet> i"
  1368     "\<forall>i\<in>Basis. a\<bullet>i \<le> (\<Sum>i\<in>Basis. (if i = k then min (b \<bullet> k) c else  b \<bullet> i) *\<^sub>R i) \<bullet> i"
  1369     "\<forall>i\<in>Basis. (\<Sum>i\<in>Basis. (if i = k then max (a \<bullet> k) c else a \<bullet> i) *\<^sub>R i) \<bullet> i \<le> b\<bullet>i"
  1369     "\<forall>i\<in>Basis. (\<Sum>i\<in>Basis. (if i = k then max (a \<bullet> k) c else a \<bullet> i) *\<^sub>R i) \<bullet> i \<le> b\<bullet>i"
  1370     "min (b \<bullet> k) c = c" "max (a \<bullet> k) c = c"
  1370     "min (b \<bullet> k) c = c" "max (a \<bullet> k) c = c"
  1421     unfolding interval_bounds[OF *(1)] interval_bounds[OF *(2)] interval_bounds[OF *(3)]
  1421     unfolding interval_bounds[OF *(1)] interval_bounds[OF *(2)] interval_bounds[OF *(3)]
  1422     unfolding *
  1422     unfolding *
  1423     by force
  1423     by force
  1424 qed
  1424 qed
  1425 
  1425 
  1426 lemma%important division_points_psubset:
  1426 lemma division_points_psubset:
  1427   fixes a :: "'a::euclidean_space"
  1427   fixes a :: "'a::euclidean_space"
  1428   assumes d: "d division_of (cbox a b)"
  1428   assumes d: "d division_of (cbox a b)"
  1429       and altb: "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"  "a\<bullet>k < c" "c < b\<bullet>k"
  1429       and altb: "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"  "a\<bullet>k < c" "c < b\<bullet>k"
  1430       and "l \<in> d"
  1430       and "l \<in> d"
  1431       and disj: "interval_lowerbound l\<bullet>k = c \<or> interval_upperbound l\<bullet>k = c"
  1431       and disj: "interval_lowerbound l\<bullet>k = c \<or> interval_upperbound l\<bullet>k = c"
  1432       and k: "k \<in> Basis"
  1432       and k: "k \<in> Basis"
  1433   shows "division_points (cbox a b \<inter> {x. x\<bullet>k \<le> c}) {l \<inter> {x. x\<bullet>k \<le> c} | l. l\<in>d \<and> l \<inter> {x. x\<bullet>k \<le> c} \<noteq> {}} \<subset>
  1433   shows "division_points (cbox a b \<inter> {x. x\<bullet>k \<le> c}) {l \<inter> {x. x\<bullet>k \<le> c} | l. l\<in>d \<and> l \<inter> {x. x\<bullet>k \<le> c} \<noteq> {}} \<subset>
  1434          division_points (cbox a b) d" (is "?D1 \<subset> ?D")
  1434          division_points (cbox a b) d" (is "?D1 \<subset> ?D")
  1435     and "division_points (cbox a b \<inter> {x. x\<bullet>k \<ge> c}) {l \<inter> {x. x\<bullet>k \<ge> c} | l. l\<in>d \<and> l \<inter> {x. x\<bullet>k \<ge> c} \<noteq> {}} \<subset>
  1435     and "division_points (cbox a b \<inter> {x. x\<bullet>k \<ge> c}) {l \<inter> {x. x\<bullet>k \<ge> c} | l. l\<in>d \<and> l \<inter> {x. x\<bullet>k \<ge> c} \<noteq> {}} \<subset>
  1436          division_points (cbox a b) d" (is "?D2 \<subset> ?D")
  1436          division_points (cbox a b) d" (is "?D2 \<subset> ?D")
  1437 proof%unimportant -
  1437 proof -
  1438   have ab: "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i"
  1438   have ab: "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i"
  1439     using altb by (auto intro!:less_imp_le)
  1439     using altb by (auto intro!:less_imp_le)
  1440   obtain u v where l: "l = cbox u v"
  1440   obtain u v where l: "l = cbox u v"
  1441     using d \<open>l \<in> d\<close> by blast
  1441     using d \<open>l \<in> d\<close> by blast
  1442   have uv: "\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i" "\<forall>i\<in>Basis. a\<bullet>i \<le> u\<bullet>i \<and> v\<bullet>i \<le> b\<bullet>i"
  1442   have uv: "\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i" "\<forall>i\<in>Basis. a\<bullet>i \<le> u\<bullet>i \<and> v\<bullet>i \<le> b\<bullet>i"
  1483     by (meson div \<open>K2 \<in> \<D>\<close> division_of_def)
  1483     by (meson div \<open>K2 \<in> \<D>\<close> division_of_def)
  1484   ultimately show ?thesis
  1484   ultimately show ?thesis
  1485     using \<open>K1 \<in> \<D>\<close> \<open>K1 \<noteq> K2\<close> by auto
  1485     using \<open>K1 \<in> \<D>\<close> \<open>K1 \<noteq> K2\<close> by auto
  1486 qed
  1486 qed
  1487 
  1487 
  1488 lemma%important division_split_right_inj:
  1488 lemma division_split_right_inj:
  1489   fixes S :: "'a::euclidean_space set"
  1489   fixes S :: "'a::euclidean_space set"
  1490   assumes div: "\<D> division_of S"
  1490   assumes div: "\<D> division_of S"
  1491     and eq: "K1 \<inter> {x::'a. x\<bullet>k \<ge> c} = K2 \<inter> {x. x\<bullet>k \<ge> c}"
  1491     and eq: "K1 \<inter> {x::'a. x\<bullet>k \<ge> c} = K2 \<inter> {x. x\<bullet>k \<ge> c}"
  1492     and "K1 \<in> \<D>" "K2 \<in> \<D>" "K1 \<noteq> K2"
  1492     and "K1 \<in> \<D>" "K2 \<in> \<D>" "K1 \<noteq> K2"
  1493   shows "interior (K1 \<inter> {x. x\<bullet>k \<ge> c}) = {}"
  1493   shows "interior (K1 \<inter> {x. x\<bullet>k \<ge> c}) = {}"
  1494 proof%unimportant -
  1494 proof -
  1495   have "interior K2 \<inter> interior {a. a \<bullet> k \<ge> c} = interior K1 \<inter> interior {a. a \<bullet> k \<ge> c}"
  1495   have "interior K2 \<inter> interior {a. a \<bullet> k \<ge> c} = interior K1 \<inter> interior {a. a \<bullet> k \<ge> c}"
  1496     by (metis (no_types) eq interior_Int)
  1496     by (metis (no_types) eq interior_Int)
  1497   moreover have "\<And>A. interior A \<inter> interior K2 = {} \<or> A = K2 \<or> A \<notin> \<D>"
  1497   moreover have "\<And>A. interior A \<inter> interior K2 = {} \<or> A = K2 \<or> A \<notin> \<D>"
  1498     by (meson div \<open>K2 \<in> \<D>\<close> division_of_def)
  1498     by (meson div \<open>K2 \<in> \<D>\<close> division_of_def)
  1499   ultimately show ?thesis
  1499   ultimately show ?thesis
  1513     by blast
  1513     by blast
  1514   show ?thesis
  1514   show ?thesis
  1515     unfolding * ** interval_split[OF assms] by (rule refl)
  1515     unfolding * ** interval_split[OF assms] by (rule refl)
  1516 qed
  1516 qed
  1517 
  1517 
  1518 lemma%important division_doublesplit:
  1518 lemma division_doublesplit:
  1519   fixes a :: "'a::euclidean_space"
  1519   fixes a :: "'a::euclidean_space"
  1520   assumes "p division_of (cbox a b)"
  1520   assumes "p division_of (cbox a b)"
  1521     and k: "k \<in> Basis"
  1521     and k: "k \<in> Basis"
  1522   shows "(\<lambda>l. l \<inter> {x. \<bar>x\<bullet>k - c\<bar> \<le> e}) ` {l\<in>p. l \<inter> {x. \<bar>x\<bullet>k - c\<bar> \<le> e} \<noteq> {}}
  1522   shows "(\<lambda>l. l \<inter> {x. \<bar>x\<bullet>k - c\<bar> \<le> e}) ` {l\<in>p. l \<inter> {x. \<bar>x\<bullet>k - c\<bar> \<le> e} \<noteq> {}}
  1523          division_of  (cbox a b \<inter> {x. \<bar>x\<bullet>k - c\<bar> \<le> e})"
  1523          division_of  (cbox a b \<inter> {x. \<bar>x\<bullet>k - c\<bar> \<le> e})"
  1524 proof%unimportant -
  1524 proof -
  1525   have *: "\<And>x c. \<bar>x - c\<bar> \<le> e \<longleftrightarrow> x \<ge> c - e \<and> x \<le> c + e"
  1525   have *: "\<And>x c. \<bar>x - c\<bar> \<le> e \<longleftrightarrow> x \<ge> c - e \<and> x \<le> c + e"
  1526     by auto
  1526     by auto
  1527   have **: "\<And>p q p' q'. p division_of q \<Longrightarrow> p = p' \<Longrightarrow> q = q' \<Longrightarrow> p' division_of q'"
  1527   have **: "\<And>p q p' q'. p division_of q \<Longrightarrow> p = p' \<Longrightarrow> q = q' \<Longrightarrow> p' division_of q'"
  1528     by auto
  1528     by auto
  1529   note division_split(1)[OF assms, where c="c+e",unfolded interval_split[OF k]]
  1529   note division_split(1)[OF assms, where c="c+e",unfolded interval_split[OF k]]
  1558     using box_subset_cbox[of One "-One"] by (auto simp: *)
  1558     using box_subset_cbox[of One "-One"] by (auto simp: *)
  1559   ultimately show ?thesis
  1559   ultimately show ?thesis
  1560     using box_empty_imp [of One "-One"] by simp
  1560     using box_empty_imp [of One "-One"] by simp
  1561 qed
  1561 qed
  1562        
  1562        
  1563 lemma%important division:
  1563 lemma division:
  1564   "F g d = g (cbox a b)" if "d division_of (cbox a b)"
  1564   "F g d = g (cbox a b)" if "d division_of (cbox a b)"
  1565 proof%unimportant -
  1565 proof -
  1566   define C where [abs_def]: "C = card (division_points (cbox a b) d)"
  1566   define C where [abs_def]: "C = card (division_points (cbox a b) d)"
  1567   then show ?thesis
  1567   then show ?thesis
  1568   using that proof (induction C arbitrary: a b d rule: less_induct)
  1568   using that proof (induction C arbitrary: a b d rule: less_induct)
  1569     case (less a b d)
  1569     case (less a b d)
  1570     show ?case
  1570     show ?case
  1745       qed
  1745       qed
  1746     qed
  1746     qed
  1747   qed
  1747   qed
  1748 qed
  1748 qed
  1749 
  1749 
  1750 lemma%important tagged_division:
  1750 proposition tagged_division:
  1751   assumes "d tagged_division_of (cbox a b)"
  1751   assumes "d tagged_division_of (cbox a b)"
  1752   shows "F (\<lambda>(_, l). g l) d = g (cbox a b)"
  1752   shows "F (\<lambda>(_, l). g l) d = g (cbox a b)"
  1753 proof%unimportant -
  1753 proof -
  1754   have "F (\<lambda>(_, k). g k) d = F g (snd ` d)"
  1754   have "F (\<lambda>(_, k). g k) d = F g (snd ` d)"
  1755     using assms box_empty_imp by (rule over_tagged_division_lemma)
  1755     using assms box_empty_imp by (rule over_tagged_division_lemma)
  1756   then show ?thesis
  1756   then show ?thesis
  1757     unfolding assms [THEN division_of_tagged_division, THEN division] .
  1757     unfolding assms [THEN division_of_tagged_division, THEN division] .
  1758   qed
  1758   qed
  1828 qed
  1828 qed
  1829 
  1829 
  1830 
  1830 
  1831 subsection%important \<open>Special case of additivity we need for the FTC\<close>
  1831 subsection%important \<open>Special case of additivity we need for the FTC\<close>
  1832 (*fix add explanation here *)
  1832 (*fix add explanation here *)
  1833 lemma%important additive_tagged_division_1:
  1833 lemma additive_tagged_division_1:
  1834   fixes f :: "real \<Rightarrow> 'a::real_normed_vector"
  1834   fixes f :: "real \<Rightarrow> 'a::real_normed_vector"
  1835   assumes "a \<le> b"
  1835   assumes "a \<le> b"
  1836     and "p tagged_division_of {a..b}"
  1836     and "p tagged_division_of {a..b}"
  1837   shows "sum (\<lambda>(x,k). f(Sup k) - f(Inf k)) p = f b - f a"
  1837   shows "sum (\<lambda>(x,k). f(Sup k) - f(Inf k)) p = f b - f a"
  1838 proof%unimportant -
  1838 proof -
  1839   let ?f = "(\<lambda>k::(real) set. if k = {} then 0 else f(interval_upperbound k) - f(interval_lowerbound k))"
  1839   let ?f = "(\<lambda>k::(real) set. if k = {} then 0 else f(interval_upperbound k) - f(interval_lowerbound k))"
  1840   interpret operative_real plus 0 ?f
  1840   interpret operative_real plus 0 ?f
  1841     rewrites "comm_monoid_set.F (+) 0 = sum"
  1841     rewrites "comm_monoid_set.F (+) 0 = sum"
  1842     by standard[1] (auto simp add: sum_def)
  1842     by standard[1] (auto simp add: sum_def)
  1843   have p_td: "p tagged_division_of cbox a b"
  1843   have p_td: "p tagged_division_of cbox a b"
  1879   unfolding fine_def by blast
  1879   unfolding fine_def by blast
  1880 
  1880 
  1881 lemma fine_Un: "d fine p1 \<Longrightarrow> d fine p2 \<Longrightarrow> d fine (p1 \<union> p2)"
  1881 lemma fine_Un: "d fine p1 \<Longrightarrow> d fine p2 \<Longrightarrow> d fine (p1 \<union> p2)"
  1882   unfolding fine_def by blast
  1882   unfolding fine_def by blast
  1883 
  1883 
  1884 lemma%important fine_Union: "(\<And>p. p \<in> ps \<Longrightarrow> d fine p) \<Longrightarrow> d fine (\<Union>ps)"
  1884 lemma fine_Union: "(\<And>p. p \<in> ps \<Longrightarrow> d fine p) \<Longrightarrow> d fine (\<Union>ps)"
  1885   unfolding fine_def by auto
  1885   unfolding fine_def by auto
  1886 
  1886 
  1887 lemma%unimportant fine_subset: "p \<subseteq> q \<Longrightarrow> d fine q \<Longrightarrow> d fine p"
  1887 lemma fine_subset: "p \<subseteq> q \<Longrightarrow> d fine q \<Longrightarrow> d fine p"
  1888   unfolding fine_def by blast
  1888   unfolding fine_def by blast
  1889 
  1889 
  1890 subsection%important \<open>Some basic combining lemmas\<close>
  1890 subsection%important \<open>Some basic combining lemmas\<close>
  1891 
  1891 
  1892 lemma%important tagged_division_Union_exists:
  1892 lemma tagged_division_Union_exists:
  1893   assumes "finite I"
  1893   assumes "finite I"
  1894     and "\<forall>i\<in>I. \<exists>p. p tagged_division_of i \<and> d fine p"
  1894     and "\<forall>i\<in>I. \<exists>p. p tagged_division_of i \<and> d fine p"
  1895     and "\<forall>i1\<in>I. \<forall>i2\<in>I. i1 \<noteq> i2 \<longrightarrow> interior i1 \<inter> interior i2 = {}"
  1895     and "\<forall>i1\<in>I. \<forall>i2\<in>I. i1 \<noteq> i2 \<longrightarrow> interior i1 \<inter> interior i2 = {}"
  1896     and "\<Union>I = i"
  1896     and "\<Union>I = i"
  1897    obtains p where "p tagged_division_of i" and "d fine p"
  1897    obtains p where "p tagged_division_of i" and "d fine p"
  1898 proof%unimportant -
  1898 proof -
  1899   obtain pfn where pfn:
  1899   obtain pfn where pfn:
  1900     "\<And>x. x \<in> I \<Longrightarrow> pfn x tagged_division_of x"
  1900     "\<And>x. x \<in> I \<Longrightarrow> pfn x tagged_division_of x"
  1901     "\<And>x. x \<in> I \<Longrightarrow> d fine pfn x"
  1901     "\<And>x. x \<in> I \<Longrightarrow> d fine pfn x"
  1902     using bchoice[OF assms(2)] by auto
  1902     using bchoice[OF assms(2)] by auto
  1903   show thesis
  1903   show thesis
  1911 
  1911 
  1912 lemma division_of_closed:
  1912 lemma division_of_closed:
  1913   fixes i :: "'n::euclidean_space set"
  1913   fixes i :: "'n::euclidean_space set"
  1914   shows "s division_of i \<Longrightarrow> closed i"
  1914   shows "s division_of i \<Longrightarrow> closed i"
  1915   unfolding division_of_def by fastforce
  1915   unfolding division_of_def by fastforce
  1916 
  1916 (* FIXME structure here, do not have one lemma in each subsection *)
  1917 subsection%important \<open>General bisection principle for intervals; might be useful elsewhere\<close>
  1917 subsection%important \<open>General bisection principle for intervals; might be useful elsewhere\<close>
  1918 
  1918 (* FIXME  move? *)
  1919 lemma%important interval_bisection_step:
  1919 lemma interval_bisection_step:
  1920   fixes type :: "'a::euclidean_space"
  1920   fixes type :: "'a::euclidean_space"
  1921   assumes emp: "P {}"
  1921   assumes emp: "P {}"
  1922     and Un: "\<And>S T. \<lbrakk>P S; P T; interior(S) \<inter> interior(T) = {}\<rbrakk> \<Longrightarrow> P (S \<union> T)"
  1922     and Un: "\<And>S T. \<lbrakk>P S; P T; interior(S) \<inter> interior(T) = {}\<rbrakk> \<Longrightarrow> P (S \<union> T)"
  1923     and non: "\<not> P (cbox a (b::'a))"
  1923     and non: "\<not> P (cbox a (b::'a))"
  1924   obtains c d where "\<not> P (cbox c d)"
  1924   obtains c d where "\<not> P (cbox c d)"
  1925     and "\<And>i. i \<in> Basis \<Longrightarrow> a\<bullet>i \<le> c\<bullet>i \<and> c\<bullet>i \<le> d\<bullet>i \<and> d\<bullet>i \<le> b\<bullet>i \<and> 2 * (d\<bullet>i - c\<bullet>i) \<le> b\<bullet>i - a\<bullet>i"
  1925     and "\<And>i. i \<in> Basis \<Longrightarrow> a\<bullet>i \<le> c\<bullet>i \<and> c\<bullet>i \<le> d\<bullet>i \<and> d\<bullet>i \<le> b\<bullet>i \<and> 2 * (d\<bullet>i - c\<bullet>i) \<le> b\<bullet>i - a\<bullet>i"
  1926 proof%unimportant -
  1926 proof -
  1927   have "cbox a b \<noteq> {}"
  1927   have "cbox a b \<noteq> {}"
  1928     using emp non by metis
  1928     using emp non by metis
  1929   then have ab: "\<And>i. i\<in>Basis \<Longrightarrow> a \<bullet> i \<le> b \<bullet> i"
  1929   then have ab: "\<And>i. i\<in>Basis \<Longrightarrow> a \<bullet> i \<le> b \<bullet> i"
  1930     by (force simp: mem_box)
  1930     by (force simp: mem_box)
  1931   have UN_cases: "\<lbrakk>finite \<F>;
  1931   have UN_cases: "\<lbrakk>finite \<F>;
  2027   qed
  2027   qed
  2028   finally show thesis
  2028   finally show thesis
  2029       by (metis (no_types, lifting) assms(3) that)
  2029       by (metis (no_types, lifting) assms(3) that)
  2030 qed
  2030 qed
  2031 
  2031 
  2032 lemma%important interval_bisection:
  2032 lemma interval_bisection:
  2033   fixes type :: "'a::euclidean_space"
  2033   fixes type :: "'a::euclidean_space"
  2034   assumes "P {}"
  2034   assumes "P {}"
  2035     and Un: "\<And>S T. \<lbrakk>P S; P T; interior(S) \<inter> interior(T) = {}\<rbrakk> \<Longrightarrow> P (S \<union> T)"
  2035     and Un: "\<And>S T. \<lbrakk>P S; P T; interior(S) \<inter> interior(T) = {}\<rbrakk> \<Longrightarrow> P (S \<union> T)"
  2036     and "\<not> P (cbox a (b::'a))"
  2036     and "\<not> P (cbox a (b::'a))"
  2037   obtains x where "x \<in> cbox a b"
  2037   obtains x where "x \<in> cbox a b"
  2038     and "\<forall>e>0. \<exists>c d. x \<in> cbox c d \<and> cbox c d \<subseteq> ball x e \<and> cbox c d \<subseteq> cbox a b \<and> \<not> P (cbox c d)"
  2038     and "\<forall>e>0. \<exists>c d. x \<in> cbox c d \<and> cbox c d \<subseteq> ball x e \<and> cbox c d \<subseteq> cbox a b \<and> \<not> P (cbox c d)"
  2039 proof%unimportant -
  2039 proof -
  2040   have "\<forall>x. \<exists>y. \<not> P (cbox (fst x) (snd x)) \<longrightarrow> (\<not> P (cbox (fst y) (snd y)) \<and>
  2040   have "\<forall>x. \<exists>y. \<not> P (cbox (fst x) (snd x)) \<longrightarrow> (\<not> P (cbox (fst y) (snd y)) \<and>
  2041     (\<forall>i\<in>Basis. fst x\<bullet>i \<le> fst y\<bullet>i \<and> fst y\<bullet>i \<le> snd y\<bullet>i \<and> snd y\<bullet>i \<le> snd x\<bullet>i \<and>
  2041     (\<forall>i\<in>Basis. fst x\<bullet>i \<le> fst y\<bullet>i \<and> fst y\<bullet>i \<le> snd y\<bullet>i \<and> snd y\<bullet>i \<le> snd x\<bullet>i \<and>
  2042        2 * (snd y\<bullet>i - fst y\<bullet>i) \<le> snd x\<bullet>i - fst x\<bullet>i))" (is "\<forall>x. ?P x")
  2042        2 * (snd y\<bullet>i - fst y\<bullet>i) \<le> snd x\<bullet>i - fst x\<bullet>i))" (is "\<forall>x. ?P x")
  2043   proof
  2043   proof
  2044     show "?P x" for x
  2044     show "?P x" for x
  2180 qed
  2180 qed
  2181 
  2181 
  2182 
  2182 
  2183 subsection%important \<open>Cousin's lemma\<close>
  2183 subsection%important \<open>Cousin's lemma\<close>
  2184 
  2184 
  2185 lemma%important fine_division_exists:
  2185 lemma fine_division_exists: (*FIXME rename(?) *)
  2186   fixes a b :: "'a::euclidean_space"
  2186   fixes a b :: "'a::euclidean_space"
  2187   assumes "gauge g"
  2187   assumes "gauge g"
  2188   obtains p where "p tagged_division_of (cbox a b)" "g fine p"
  2188   obtains p where "p tagged_division_of (cbox a b)" "g fine p"
  2189 proof%unimportant (cases "\<exists>p. p tagged_division_of (cbox a b) \<and> g fine p")
  2189 proof (cases "\<exists>p. p tagged_division_of (cbox a b) \<and> g fine p")
  2190   case True
  2190   case True
  2191   then show ?thesis
  2191   then show ?thesis
  2192     using that by auto
  2192     using that by auto
  2193 next
  2193 next
  2194   case False
  2194   case False
  2226   obtains p where "p tagged_division_of {a .. b}" "g fine p"
  2226   obtains p where "p tagged_division_of {a .. b}" "g fine p"
  2227   by (metis assms box_real(2) fine_division_exists)
  2227   by (metis assms box_real(2) fine_division_exists)
  2228 
  2228 
  2229 subsection%important \<open>A technical lemma about "refinement" of division\<close>
  2229 subsection%important \<open>A technical lemma about "refinement" of division\<close>
  2230 
  2230 
  2231 lemma%important tagged_division_finer:
  2231 lemma tagged_division_finer:
  2232   fixes p :: "('a::euclidean_space \<times> ('a::euclidean_space set)) set"
  2232   fixes p :: "('a::euclidean_space \<times> ('a::euclidean_space set)) set"
  2233   assumes ptag: "p tagged_division_of (cbox a b)"
  2233   assumes ptag: "p tagged_division_of (cbox a b)"
  2234     and "gauge d"
  2234     and "gauge d"
  2235   obtains q where "q tagged_division_of (cbox a b)"
  2235   obtains q where "q tagged_division_of (cbox a b)"
  2236     and "d fine q"
  2236     and "d fine q"
  2237     and "\<forall>(x,k) \<in> p. k \<subseteq> d(x) \<longrightarrow> (x,k) \<in> q"
  2237     and "\<forall>(x,k) \<in> p. k \<subseteq> d(x) \<longrightarrow> (x,k) \<in> q"
  2238 proof%unimportant -
  2238 proof -
  2239   have p: "finite p" "p tagged_partial_division_of (cbox a b)"
  2239   have p: "finite p" "p tagged_partial_division_of (cbox a b)"
  2240     using ptag unfolding tagged_division_of_def by auto
  2240     using ptag unfolding tagged_division_of_def by auto
  2241   have "(\<exists>q. q tagged_division_of (\<Union>{k. \<exists>x. (x,k) \<in> p}) \<and> d fine q \<and> (\<forall>(x,k) \<in> p. k \<subseteq> d(x) \<longrightarrow> (x,k) \<in> q))" 
  2241   have "(\<exists>q. q tagged_division_of (\<Union>{k. \<exists>x. (x,k) \<in> p}) \<and> d fine q \<and> (\<forall>(x,k) \<in> p. k \<subseteq> d(x) \<longrightarrow> (x,k) \<in> q))" 
  2242     if "finite p" "p tagged_partial_division_of (cbox a b)" "gauge d" for p
  2242     if "finite p" "p tagged_partial_division_of (cbox a b)" "gauge d" for p
  2243     using that
  2243     using that
  2305 
  2305 
  2306 text\<open> Some technical lemmas used in the approximation results that follow. Proof of the covering
  2306 text\<open> Some technical lemmas used in the approximation results that follow. Proof of the covering
  2307   lemma is an obvious multidimensional generalization of Lemma 3, p65 of Swartz's
  2307   lemma is an obvious multidimensional generalization of Lemma 3, p65 of Swartz's
  2308   "Introduction to Gauge Integrals". \<close>
  2308   "Introduction to Gauge Integrals". \<close>
  2309 
  2309 
  2310 proposition%important covering_lemma:
  2310 proposition covering_lemma:
  2311   assumes "S \<subseteq> cbox a b" "box a b \<noteq> {}" "gauge g"
  2311   assumes "S \<subseteq> cbox a b" "box a b \<noteq> {}" "gauge g"
  2312   obtains \<D> where
  2312   obtains \<D> where
  2313     "countable \<D>"  "\<Union>\<D> \<subseteq> cbox a b"
  2313     "countable \<D>"  "\<Union>\<D> \<subseteq> cbox a b"
  2314     "\<And>K. K \<in> \<D> \<Longrightarrow> interior K \<noteq> {} \<and> (\<exists>c d. K = cbox c d)"
  2314     "\<And>K. K \<in> \<D> \<Longrightarrow> interior K \<noteq> {} \<and> (\<exists>c d. K = cbox c d)"
  2315     "pairwise (\<lambda>A B. interior A \<inter> interior B = {}) \<D>"
  2315     "pairwise (\<lambda>A B. interior A \<inter> interior B = {}) \<D>"
  2316     "\<And>K. K \<in> \<D> \<Longrightarrow> \<exists>x \<in> S \<inter> K. K \<subseteq> g x"
  2316     "\<And>K. K \<in> \<D> \<Longrightarrow> \<exists>x \<in> S \<inter> K. K \<subseteq> g x"
  2317     "\<And>u v. cbox u v \<in> \<D> \<Longrightarrow> \<exists>n. \<forall>i \<in> Basis. v \<bullet> i - u \<bullet> i = (b \<bullet> i - a \<bullet> i) / 2^n"
  2317     "\<And>u v. cbox u v \<in> \<D> \<Longrightarrow> \<exists>n. \<forall>i \<in> Basis. v \<bullet> i - u \<bullet> i = (b \<bullet> i - a \<bullet> i) / 2^n"
  2318     "S \<subseteq> \<Union>\<D>"
  2318     "S \<subseteq> \<Union>\<D>"
  2319 proof%unimportant -
  2319 proof -
  2320   have aibi: "\<And>i. i \<in> Basis \<Longrightarrow> a \<bullet> i \<le> b \<bullet> i" and normab: "0 < norm(b - a)"
  2320   have aibi: "\<And>i. i \<in> Basis \<Longrightarrow> a \<bullet> i \<le> b \<bullet> i" and normab: "0 < norm(b - a)"
  2321     using \<open>box a b \<noteq> {}\<close> box_eq_empty box_sing by fastforce+
  2321     using \<open>box a b \<noteq> {}\<close> box_eq_empty box_sing by fastforce+
  2322   let ?K0 = "\<lambda>(n, f::'a\<Rightarrow>nat).
  2322   let ?K0 = "\<lambda>(n, f::'a\<Rightarrow>nat).
  2323                     cbox (\<Sum>i \<in> Basis. (a \<bullet> i + (f i / 2^n) * (b \<bullet> i - a \<bullet> i)) *\<^sub>R i)
  2323                     cbox (\<Sum>i \<in> Basis. (a \<bullet> i + (f i / 2^n) * (b \<bullet> i - a \<bullet> i)) *\<^sub>R i)
  2324                          (\<Sum>i \<in> Basis. (a \<bullet> i + ((f i + 1) / 2^n) * (b \<bullet> i - a \<bullet> i)) *\<^sub>R i)"
  2324                          (\<Sum>i \<in> Basis. (a \<bullet> i + ((f i + 1) / 2^n) * (b \<bullet> i - a \<bullet> i)) *\<^sub>R i)"
  2576 text \<open>Divisions over all gauges towards finer divisions.\<close>
  2576 text \<open>Divisions over all gauges towards finer divisions.\<close>
  2577 
  2577 
  2578 definition%important division_filter :: "'a::euclidean_space set \<Rightarrow> ('a \<times> 'a set) set filter"
  2578 definition%important division_filter :: "'a::euclidean_space set \<Rightarrow> ('a \<times> 'a set) set filter"
  2579   where "division_filter s = (INF g\<in>{g. gauge g}. principal {p. p tagged_division_of s \<and> g fine p})"
  2579   where "division_filter s = (INF g\<in>{g. gauge g}. principal {p. p tagged_division_of s \<and> g fine p})"
  2580 
  2580 
  2581 lemma%important eventually_division_filter:
  2581 proposition eventually_division_filter:
  2582   "(\<forall>\<^sub>F p in division_filter s. P p) \<longleftrightarrow>
  2582   "(\<forall>\<^sub>F p in division_filter s. P p) \<longleftrightarrow>
  2583     (\<exists>g. gauge g \<and> (\<forall>p. p tagged_division_of s \<and> g fine p \<longrightarrow> P p))"
  2583     (\<exists>g. gauge g \<and> (\<forall>p. p tagged_division_of s \<and> g fine p \<longrightarrow> P p))"
  2584   unfolding%unimportant division_filter_def
  2584   unfolding division_filter_def
  2585 proof%unimportant (subst eventually_INF_base; clarsimp)
  2585 proof (subst eventually_INF_base; clarsimp)
  2586   fix g1 g2 :: "'a \<Rightarrow> 'a set" show "gauge g1 \<Longrightarrow> gauge g2 \<Longrightarrow> \<exists>x. gauge x \<and>
  2586   fix g1 g2 :: "'a \<Rightarrow> 'a set" show "gauge g1 \<Longrightarrow> gauge g2 \<Longrightarrow> \<exists>x. gauge x \<and>
  2587     {p. p tagged_division_of s \<and> x fine p} \<subseteq> {p. p tagged_division_of s \<and> g1 fine p} \<and>
  2587     {p. p tagged_division_of s \<and> x fine p} \<subseteq> {p. p tagged_division_of s \<and> g1 fine p} \<and>
  2588     {p. p tagged_division_of s \<and> x fine p} \<subseteq> {p. p tagged_division_of s \<and> g2 fine p}"
  2588     {p. p tagged_division_of s \<and> x fine p} \<subseteq> {p. p tagged_division_of s \<and> g2 fine p}"
  2589     by (intro exI[of _ "\<lambda>x. g1 x \<inter> g2 x"]) (auto simp: fine_Int)
  2589     by (intro exI[of _ "\<lambda>x. g1 x \<inter> g2 x"]) (auto simp: fine_Int)
  2590 qed (auto simp: eventually_principal)
  2590 qed (auto simp: eventually_principal)
  2591 
  2591 
  2592 lemma division_filter_not_empty: "division_filter (cbox a b) \<noteq> bot"
  2592 lemma division_filter_not_empty: "division_filter (cbox a b) \<noteq> bot"
  2593   unfolding trivial_limit_def eventually_division_filter
  2593   unfolding trivial_limit_def eventually_division_filter
  2594   by (auto elim: fine_division_exists)
  2594   by (auto elim: fine_division_exists)
  2595 
  2595 
  2596 lemma%important eventually_division_filter_tagged_division:
  2596 lemma eventually_division_filter_tagged_division:
  2597   "eventually (\<lambda>p. p tagged_division_of s) (division_filter s)"
  2597   "eventually (\<lambda>p. p tagged_division_of s) (division_filter s)"
  2598   unfolding eventually_division_filter by (intro exI[of _ "\<lambda>x. ball x 1"]) auto
  2598   unfolding eventually_division_filter by (intro exI[of _ "\<lambda>x. ball x 1"]) auto
  2599 
  2599 
  2600 end
  2600 end