use cbox to relax class constraints
authorimmler
Tue Mar 18 10:12:57 2014 +0100 (2014-03-18)
changeset 561880268784f60da
parent 56187 2666cd7d380c
child 56189 c4daa97ac57a
use cbox to relax class constraints
src/HOL/Multivariate_Analysis/Brouwer_Fixpoint.thy
src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy
src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy
src/HOL/Multivariate_Analysis/Derivative.thy
src/HOL/Multivariate_Analysis/Fashoda.thy
src/HOL/Multivariate_Analysis/Integration.thy
src/HOL/Multivariate_Analysis/Ordered_Euclidean_Space.thy
src/HOL/Multivariate_Analysis/Path_Connected.thy
src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy
src/HOL/Probability/Lebesgue_Measure.thy
     1.1 --- a/src/HOL/Multivariate_Analysis/Brouwer_Fixpoint.thy	Mon Mar 17 21:56:32 2014 +0100
     1.2 +++ b/src/HOL/Multivariate_Analysis/Brouwer_Fixpoint.thy	Tue Mar 18 10:12:57 2014 +0100
     1.3 @@ -4426,21 +4426,21 @@
     1.4    done
     1.5  
     1.6  lemma in_interval_interval_bij:
     1.7 -  fixes a b u v x :: "'a::ordered_euclidean_space"
     1.8 -  assumes "x \<in> {a..b}"
     1.9 -    and "{u..v} \<noteq> {}"
    1.10 -  shows "interval_bij (a, b) (u, v) x \<in> {u..v}"
    1.11 -  apply (simp only: interval_bij_def split_conv mem_interval inner_setsum_left_Basis cong: ball_cong)
    1.12 +  fixes a b u v x :: "'a::euclidean_space"
    1.13 +  assumes "x \<in> cbox a b"
    1.14 +    and "cbox u v \<noteq> {}"
    1.15 +  shows "interval_bij (a, b) (u, v) x \<in> cbox u v"
    1.16 +  apply (simp only: interval_bij_def split_conv mem_box inner_setsum_left_Basis cong: ball_cong)
    1.17    apply safe
    1.18  proof -
    1.19    fix i :: 'a
    1.20    assume i: "i \<in> Basis"
    1.21 -  have "{a..b} \<noteq> {}"
    1.22 +  have "cbox a b \<noteq> {}"
    1.23      using assms by auto
    1.24    with i have *: "a\<bullet>i \<le> b\<bullet>i" "u\<bullet>i \<le> v\<bullet>i"
    1.25 -    using assms(2) by (auto simp add: interval_eq_empty interval)
    1.26 +    using assms(2) by (auto simp add: box_eq_empty)
    1.27    have x: "a\<bullet>i\<le>x\<bullet>i" "x\<bullet>i\<le>b\<bullet>i"
    1.28 -    using assms(1)[unfolded mem_interval] using i by auto
    1.29 +    using assms(1)[unfolded mem_box] using i by auto
    1.30    have "0 \<le> (x \<bullet> i - a \<bullet> i) / (b \<bullet> i - a \<bullet> i) * (v \<bullet> i - u \<bullet> i)"
    1.31      using * x by (auto intro!: mult_nonneg_nonneg divide_nonneg_nonneg)
    1.32    then show "u \<bullet> i \<le> u \<bullet> i + (x \<bullet> i - a \<bullet> i) / (b \<bullet> i - a \<bullet> i) * (v \<bullet> i - u \<bullet> i)"
     2.1 --- a/src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy	Mon Mar 17 21:56:32 2014 +0100
     2.2 +++ b/src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy	Tue Mar 18 10:12:57 2014 +0100
     2.3 @@ -99,6 +99,9 @@
     2.4  
     2.5  definition "vec x = (\<chi> i. x)"
     2.6  
     2.7 +lemma interval_cbox_cart: "{a::real^'n..b} = cbox a b"
     2.8 +  by (auto simp add: less_eq_vec_def mem_box Basis_vec_def inner_axis)
     2.9 +
    2.10  text{* Also the scalar-vector multiplication. *}
    2.11  
    2.12  definition vector_scalar_mult:: "'a::times \<Rightarrow> 'a ^ 'n \<Rightarrow> 'a ^ 'n" (infixl "*s" 70)
    2.13 @@ -911,19 +914,19 @@
    2.14  lemma interval_cart:
    2.15    fixes a :: "real^'n"
    2.16    shows "box a b = {x::real^'n. \<forall>i. a$i < x$i \<and> x$i < b$i}"
    2.17 -    and "{a .. b} = {x::real^'n. \<forall>i. a$i \<le> x$i \<and> x$i \<le> b$i}"
    2.18 -  by (auto simp add: set_eq_iff less_vec_def less_eq_vec_def mem_interval Basis_vec_def inner_axis)
    2.19 +    and "cbox a b = {x::real^'n. \<forall>i. a$i \<le> x$i \<and> x$i \<le> b$i}"
    2.20 +  by (auto simp add: set_eq_iff less_vec_def less_eq_vec_def mem_box Basis_vec_def inner_axis)
    2.21  
    2.22  lemma mem_interval_cart:
    2.23    fixes a :: "real^'n"
    2.24    shows "x \<in> box a b \<longleftrightarrow> (\<forall>i. a$i < x$i \<and> x$i < b$i)"
    2.25 -    and "x \<in> {a .. b} \<longleftrightarrow> (\<forall>i. a$i \<le> x$i \<and> x$i \<le> b$i)"
    2.26 +    and "x \<in> cbox a b \<longleftrightarrow> (\<forall>i. a$i \<le> x$i \<and> x$i \<le> b$i)"
    2.27    using interval_cart[of a b] by (auto simp add: set_eq_iff less_vec_def less_eq_vec_def)
    2.28  
    2.29  lemma interval_eq_empty_cart:
    2.30    fixes a :: "real^'n"
    2.31    shows "(box a b = {} \<longleftrightarrow> (\<exists>i. b$i \<le> a$i))" (is ?th1)
    2.32 -    and "({a  ..  b} = {} \<longleftrightarrow> (\<exists>i. b$i < a$i))" (is ?th2)
    2.33 +    and "(cbox a b = {} \<longleftrightarrow> (\<exists>i. b$i < a$i))" (is ?th2)
    2.34  proof -
    2.35    { fix i x assume as:"b$i \<le> a$i" and x:"x\<in>box a b"
    2.36      hence "a $ i < x $ i \<and> x $ i < b $ i" unfolding mem_interval_cart by auto
    2.37 @@ -940,7 +943,7 @@
    2.38      hence "box a b \<noteq> {}" using mem_interval_cart(1)[of "?x" a b] by auto }
    2.39    ultimately show ?th1 by blast
    2.40  
    2.41 -  { fix i x assume as:"b$i < a$i" and x:"x\<in>{a .. b}"
    2.42 +  { fix i x assume as:"b$i < a$i" and x:"x\<in>cbox a b"
    2.43      hence "a $ i \<le> x $ i \<and> x $ i \<le> b $ i" unfolding mem_interval_cart by auto
    2.44      hence "a$i \<le> b$i" by auto
    2.45      hence False using as by auto }
    2.46 @@ -952,22 +955,22 @@
    2.47        hence "a$i \<le> ((1/2) *\<^sub>R (a+b)) $ i" "((1/2) *\<^sub>R (a+b)) $ i \<le> b$i"
    2.48          unfolding vector_smult_component and vector_add_component
    2.49          by auto }
    2.50 -    hence "{a .. b} \<noteq> {}" using mem_interval_cart(2)[of "?x" a b] by auto  }
    2.51 +    hence "cbox a b \<noteq> {}" using mem_interval_cart(2)[of "?x" a b] by auto  }
    2.52    ultimately show ?th2 by blast
    2.53  qed
    2.54  
    2.55  lemma interval_ne_empty_cart:
    2.56    fixes a :: "real^'n"
    2.57 -  shows "{a  ..  b} \<noteq> {} \<longleftrightarrow> (\<forall>i. a$i \<le> b$i)"
    2.58 +  shows "cbox a b \<noteq> {} \<longleftrightarrow> (\<forall>i. a$i \<le> b$i)"
    2.59      and "box a b \<noteq> {} \<longleftrightarrow> (\<forall>i. a$i < b$i)"
    2.60    unfolding interval_eq_empty_cart[of a b] by (auto simp add: not_less not_le)
    2.61      (* BH: Why doesn't just "auto" work here? *)
    2.62  
    2.63  lemma subset_interval_imp_cart:
    2.64    fixes a :: "real^'n"
    2.65 -  shows "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> {c .. d} \<subseteq> {a .. b}"
    2.66 -    and "(\<forall>i. a$i < c$i \<and> d$i < b$i) \<Longrightarrow> {c .. d} \<subseteq> box a b"
    2.67 -    and "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> box c d \<subseteq> {a .. b}"
    2.68 +  shows "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> cbox c d \<subseteq> cbox a b"
    2.69 +    and "(\<forall>i. a$i < c$i \<and> d$i < b$i) \<Longrightarrow> cbox c d \<subseteq> box a b"
    2.70 +    and "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> box c d \<subseteq> cbox a b"
    2.71      and "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> box c d \<subseteq> box a b"
    2.72    unfolding subset_eq[unfolded Ball_def] unfolding mem_interval_cart
    2.73    by (auto intro: order_trans less_le_trans le_less_trans less_imp_le) (* BH: Why doesn't just "auto" work here? *)
    2.74 @@ -978,49 +981,28 @@
    2.75    apply (auto simp add: set_eq_iff less_vec_def less_eq_vec_def vec_eq_iff)
    2.76    done
    2.77  
    2.78 -lemma interval_open_subset_closed_cart:
    2.79 -  fixes a :: "real^'n"
    2.80 -  shows "box a b \<subseteq> {a .. b}"
    2.81 -proof (simp add: subset_eq, rule)
    2.82 -  fix x
    2.83 -  assume x: "x \<in>box a b"
    2.84 -  { fix i
    2.85 -    have "a $ i \<le> x $ i"
    2.86 -      using x order_less_imp_le[of "a$i" "x$i"]
    2.87 -      by(simp add: set_eq_iff less_vec_def less_eq_vec_def vec_eq_iff mem_interval Basis_vec_def inner_axis)
    2.88 -  }
    2.89 -  moreover
    2.90 -  { fix i
    2.91 -    have "x $ i \<le> b $ i"
    2.92 -      using x order_less_imp_le[of "x$i" "b$i"]
    2.93 -      by(simp add: set_eq_iff less_vec_def less_eq_vec_def vec_eq_iff mem_interval Basis_vec_def inner_axis)
    2.94 -  }
    2.95 -  ultimately
    2.96 -  show "a \<le> x \<and> x \<le> b"
    2.97 -    by(simp add: set_eq_iff less_vec_def less_eq_vec_def vec_eq_iff)
    2.98 -qed
    2.99 -
   2.100  lemma subset_interval_cart:
   2.101    fixes a :: "real^'n"
   2.102 -  shows "{c .. d} \<subseteq> {a .. b} \<longleftrightarrow> (\<forall>i. c$i \<le> d$i) --> (\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i)" (is ?th1)
   2.103 -    and "{c .. d} \<subseteq> box a b \<longleftrightarrow> (\<forall>i. c$i \<le> d$i) --> (\<forall>i. a$i < c$i \<and> d$i < b$i)" (is ?th2)
   2.104 -    and "box c d \<subseteq> {a .. b} \<longleftrightarrow> (\<forall>i. c$i < d$i) --> (\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i)" (is ?th3)
   2.105 +  shows "cbox c d \<subseteq> cbox a b \<longleftrightarrow> (\<forall>i. c$i \<le> d$i) --> (\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i)" (is ?th1)
   2.106 +    and "cbox c d \<subseteq> box a b \<longleftrightarrow> (\<forall>i. c$i \<le> d$i) --> (\<forall>i. a$i < c$i \<and> d$i < b$i)" (is ?th2)
   2.107 +    and "box c d \<subseteq> cbox a b \<longleftrightarrow> (\<forall>i. c$i < d$i) --> (\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i)" (is ?th3)
   2.108      and "box c d \<subseteq> box a b \<longleftrightarrow> (\<forall>i. c$i < d$i) --> (\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i)" (is ?th4)
   2.109 -  using subset_interval[of c d a b] by (simp_all add: Basis_vec_def inner_axis)
   2.110 +  using subset_box[of c d a b] by (simp_all add: Basis_vec_def inner_axis)
   2.111  
   2.112  lemma disjoint_interval_cart:
   2.113    fixes a::"real^'n"
   2.114 -  shows "{a .. b} \<inter> {c .. d} = {} \<longleftrightarrow> (\<exists>i. (b$i < a$i \<or> d$i < c$i \<or> b$i < c$i \<or> d$i < a$i))" (is ?th1)
   2.115 -    and "{a .. b} \<inter> box c d = {} \<longleftrightarrow> (\<exists>i. (b$i < a$i \<or> d$i \<le> c$i \<or> b$i \<le> c$i \<or> d$i \<le> a$i))" (is ?th2)
   2.116 -    and "box a b \<inter> {c .. d} = {} \<longleftrightarrow> (\<exists>i. (b$i \<le> a$i \<or> d$i < c$i \<or> b$i \<le> c$i \<or> d$i \<le> a$i))" (is ?th3)
   2.117 +  shows "cbox a b \<inter> cbox c d = {} \<longleftrightarrow> (\<exists>i. (b$i < a$i \<or> d$i < c$i \<or> b$i < c$i \<or> d$i < a$i))" (is ?th1)
   2.118 +    and "cbox a b \<inter> box c d = {} \<longleftrightarrow> (\<exists>i. (b$i < a$i \<or> d$i \<le> c$i \<or> b$i \<le> c$i \<or> d$i \<le> a$i))" (is ?th2)
   2.119 +    and "box a b \<inter> cbox c d = {} \<longleftrightarrow> (\<exists>i. (b$i \<le> a$i \<or> d$i < c$i \<or> b$i \<le> c$i \<or> d$i \<le> a$i))" (is ?th3)
   2.120      and "box a b \<inter> box c d = {} \<longleftrightarrow> (\<exists>i. (b$i \<le> a$i \<or> d$i \<le> c$i \<or> b$i \<le> c$i \<or> d$i \<le> a$i))" (is ?th4)
   2.121    using disjoint_interval[of a b c d] by (simp_all add: Basis_vec_def inner_axis)
   2.122  
   2.123  lemma inter_interval_cart:
   2.124    fixes a :: "real^'n"
   2.125 -  shows "{a .. b} \<inter> {c .. d} =  {(\<chi> i. max (a$i) (c$i)) .. (\<chi> i. min (b$i) (d$i))}"
   2.126 -  unfolding set_eq_iff and Int_iff and mem_interval_cart
   2.127 -  by auto
   2.128 +  shows "cbox a b \<inter> cbox c d =  {(\<chi> i. max (a$i) (c$i)) .. (\<chi> i. min (b$i) (d$i))}"
   2.129 +  unfolding inter_interval
   2.130 +  by (auto simp: mem_box less_eq_vec_def)
   2.131 +    (auto simp: Basis_vec_def inner_axis)
   2.132  
   2.133  lemma closed_interval_left_cart:
   2.134    fixes b :: "real^'n"
   2.135 @@ -1158,17 +1140,17 @@
   2.136    by (rule convex_box_cart) (simp add: atLeast_def[symmetric] convex_real_interval)
   2.137  
   2.138  lemma unit_interval_convex_hull_cart:
   2.139 -  "{0::real^'n .. 1} = convex hull {x. \<forall>i. (x$i = 0) \<or> (x$i = 1)}"
   2.140 -  unfolding Cart_1 unit_interval_convex_hull[where 'a="real^'n"]
   2.141 +  "cbox (0::real^'n) 1 = convex hull {x. \<forall>i. (x$i = 0) \<or> (x$i = 1)}"
   2.142 +  unfolding Cart_1 unit_interval_convex_hull[where 'a="real^'n"] box_real[symmetric]
   2.143    by (rule arg_cong[where f="\<lambda>x. convex hull x"]) (simp add: Basis_vec_def inner_axis)
   2.144  
   2.145  lemma cube_convex_hull_cart:
   2.146    assumes "0 < d"
   2.147    obtains s::"(real^'n) set"
   2.148 -    where "finite s" "{x - (\<chi> i. d) .. x + (\<chi> i. d)} = convex hull s"
   2.149 +    where "finite s" "cbox (x - (\<chi> i. d)) (x + (\<chi> i. d)) = convex hull s"
   2.150  proof -
   2.151    from assms obtain s where "finite s"
   2.152 -    and "{x - setsum (op *\<^sub>R d) Basis..x + setsum (op *\<^sub>R d) Basis} = convex hull s"
   2.153 +    and "cbox (x - setsum (op *\<^sub>R d) Basis) (x + setsum (op *\<^sub>R d) Basis) = convex hull s"
   2.154      by (rule cube_convex_hull)
   2.155    with that[of s] show thesis
   2.156      by (simp add: const_vector_cart)
   2.157 @@ -1344,16 +1326,16 @@
   2.158    using component_le_norm_cart[of _ k] unfolding real_norm_def by auto
   2.159  
   2.160  lemma integral_component_eq_cart[simp]:
   2.161 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> real^'m"
   2.162 +  fixes f :: "'n::euclidean_space \<Rightarrow> real^'m"
   2.163    assumes "f integrable_on s"
   2.164    shows "integral s (\<lambda>x. f x $ k) = integral s f $ k"
   2.165    using integral_linear[OF assms(1) bounded_linear_component_cart,unfolded o_def] .
   2.166  
   2.167  lemma interval_split_cart:
   2.168    "{a..b::real^'n} \<inter> {x. x$k \<le> c} = {a .. (\<chi> i. if i = k then min (b$k) c else b$i)}"
   2.169 -  "{a..b} \<inter> {x. x$k \<ge> c} = {(\<chi> i. if i = k then max (a$k) c else a$i) .. b}"
   2.170 +  "cbox a b \<inter> {x. x$k \<ge> c} = {(\<chi> i. if i = k then max (a$k) c else a$i) .. b}"
   2.171    apply (rule_tac[!] set_eqI)
   2.172 -  unfolding Int_iff mem_interval_cart mem_Collect_eq
   2.173 +  unfolding Int_iff mem_interval_cart mem_Collect_eq interval_cbox_cart
   2.174    unfolding vec_lambda_beta
   2.175    by auto
   2.176  
     3.1 --- a/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy	Mon Mar 17 21:56:32 2014 +0100
     3.2 +++ b/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy	Tue Mar 18 10:12:57 2014 +0100
     3.3 @@ -1336,14 +1336,14 @@
     3.4  
     3.5  text {* Balls, being convex, are connected. *}
     3.6  
     3.7 -lemma convex_box:
     3.8 +lemma convex_prod:
     3.9    assumes "\<And>i. i \<in> Basis \<Longrightarrow> convex {x. P i x}"
    3.10    shows "convex {x. \<forall>i\<in>Basis. P i (x\<bullet>i)}"
    3.11    using assms unfolding convex_def
    3.12    by (auto simp: inner_add_left)
    3.13  
    3.14  lemma convex_positive_orthant: "convex {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i)}"
    3.15 -  by (rule convex_box) (simp add: atLeast_def[symmetric] convex_real_interval)
    3.16 +  by (rule convex_prod) (simp add: atLeast_def[symmetric] convex_real_interval)
    3.17  
    3.18  lemma convex_local_global_minimum:
    3.19    fixes s :: "'a::real_normed_vector set"
    3.20 @@ -3361,21 +3361,18 @@
    3.21    ultimately show ?thesis by auto
    3.22  qed
    3.23  
    3.24 -lemma box_real: "box a b = {a<..<b::real}"
    3.25 -  by (force simp add: box_def)
    3.26 -
    3.27 -lemma rel_interior_real_interval:
    3.28 +lemma rel_interior_real_box:
    3.29    fixes a b :: real
    3.30    assumes "a < b"
    3.31 -  shows "rel_interior {a..b} = {a<..<b}"
    3.32 +  shows "rel_interior {a .. b} = {a <..< b}"
    3.33  proof -
    3.34    have "box a b \<noteq> {}"
    3.35      using assms
    3.36      unfolding set_eq_iff
    3.37 -    by (auto intro!: exI[of _ "(a + b) / 2"] simp: box_def)
    3.38 +    by (auto intro!: exI[of _ "(a + b) / 2"] simp: box)
    3.39    then show ?thesis
    3.40 -    using interior_rel_interior_gen[of "{a..b}", symmetric]
    3.41 -    by (simp split: split_if_asm add: interior_closed_interval box_real)
    3.42 +    using interior_rel_interior_gen[of "cbox a b", symmetric]
    3.43 +    by (simp split: split_if_asm del: box_real add: box_real[symmetric] interior_cbox)
    3.44  qed
    3.45  
    3.46  lemma rel_interior_real_semiline:
    3.47 @@ -3825,12 +3822,12 @@
    3.48      apply simp
    3.49      apply auto
    3.50      done
    3.51 -  have "continuous_on ({0..1} \<times> s \<times> t) (\<lambda>z. (1 - fst z) *\<^sub>R fst (snd z) + fst z *\<^sub>R snd (snd z))"
    3.52 +  have "continuous_on ?X (\<lambda>z. (1 - fst z) *\<^sub>R fst (snd z) + fst z *\<^sub>R snd (snd z))"
    3.53      unfolding continuous_on by (rule ballI) (intro tendsto_intros)
    3.54    then show ?thesis
    3.55      unfolding *
    3.56      apply (rule compact_continuous_image)
    3.57 -    apply (intro compact_Times compact_interval assms)
    3.58 +    apply (intro compact_Times compact_Icc assms)
    3.59      done
    3.60  qed
    3.61  
    3.62 @@ -3854,7 +3851,7 @@
    3.63      have "continuous_on ?T ?f"
    3.64        unfolding split_def continuous_on by (intro ballI tendsto_intros)
    3.65      moreover have "compact ?T"
    3.66 -      by (intro compact_Times compact_interval insert)
    3.67 +      by (intro compact_Times compact_Icc insert)
    3.68      ultimately have "compact (?f ` ?T)"
    3.69        by (rule compact_continuous_image)
    3.70      also have "?f ` ?T = convex hull (insert x A)"
    3.71 @@ -5083,7 +5080,7 @@
    3.72      apply (rule continuous_at_imp_continuous_on)
    3.73      apply rule
    3.74      apply (intro continuous_intros)
    3.75 -    apply (rule compact_interval)
    3.76 +    apply (rule compact_Icc)
    3.77      done
    3.78    moreover have "{y. \<exists>u\<ge>0. u \<le> b / norm x \<and> y = u *\<^sub>R x} \<inter> s \<noteq> {}"
    3.79      apply(rule *[OF _ assms(2)])
    3.80 @@ -5673,8 +5670,8 @@
    3.81    shows "is_interval s \<Longrightarrow> connected s"
    3.82    using is_interval_convex convex_connected by auto
    3.83  
    3.84 -lemma convex_interval: "convex {a .. b}" "convex (box a (b::'a::ordered_euclidean_space))"
    3.85 -  apply (rule_tac[!] is_interval_convex)
    3.86 +lemma convex_box: "convex (cbox a b)" "convex (box a (b::'a::euclidean_space))"
    3.87 +  apply (rule_tac[!] is_interval_convex)+
    3.88    using is_interval_interval
    3.89    apply auto
    3.90    done
    3.91 @@ -5741,35 +5738,35 @@
    3.92  lemma ivt_increasing_component_on_1:
    3.93    fixes f :: "real \<Rightarrow> 'a::euclidean_space"
    3.94    assumes "a \<le> b"
    3.95 -    and "continuous_on {a .. b} f"
    3.96 +    and "continuous_on (cbox a b) f"
    3.97      and "(f a)\<bullet>k \<le> y" "y \<le> (f b)\<bullet>k"
    3.98 -  shows "\<exists>x\<in>{a..b}. (f x)\<bullet>k = y"
    3.99 -proof -
   3.100 -  have "f a \<in> f ` {a..b}" "f b \<in> f ` {a..b}"
   3.101 +  shows "\<exists>x\<in>cbox a b. (f x)\<bullet>k = y"
   3.102 +proof -
   3.103 +  have "f a \<in> f ` cbox a b" "f b \<in> f ` cbox a b"
   3.104      apply (rule_tac[!] imageI)
   3.105      using assms(1)
   3.106      apply auto
   3.107      done
   3.108    then show ?thesis
   3.109 -    using connected_ivt_component[of "f ` {a..b}" "f a" "f b" k y]
   3.110 -    using connected_continuous_image[OF assms(2) convex_connected[OF convex_real_interval(5)]]
   3.111 +    using connected_ivt_component[of "f ` cbox a b" "f a" "f b" k y]
   3.112 +    using connected_continuous_image[OF assms(2) convex_connected[OF convex_box(1)]]
   3.113      using assms
   3.114 -    by (auto intro!: imageI)
   3.115 +    by auto
   3.116  qed
   3.117  
   3.118  lemma ivt_increasing_component_1:
   3.119    fixes f :: "real \<Rightarrow> 'a::euclidean_space"
   3.120 -  shows "a \<le> b \<Longrightarrow> \<forall>x\<in>{a .. b}. continuous (at x) f \<Longrightarrow>
   3.121 -    f a\<bullet>k \<le> y \<Longrightarrow> y \<le> f b\<bullet>k \<Longrightarrow> \<exists>x\<in>{a..b}. (f x)\<bullet>k = y"
   3.122 +  shows "a \<le> b \<Longrightarrow> \<forall>x\<in>cbox a b. continuous (at x) f \<Longrightarrow>
   3.123 +    f a\<bullet>k \<le> y \<Longrightarrow> y \<le> f b\<bullet>k \<Longrightarrow> \<exists>x\<in>cbox a b. (f x)\<bullet>k = y"
   3.124    by (rule ivt_increasing_component_on_1) (auto simp add: continuous_at_imp_continuous_on)
   3.125  
   3.126  lemma ivt_decreasing_component_on_1:
   3.127    fixes f :: "real \<Rightarrow> 'a::euclidean_space"
   3.128    assumes "a \<le> b"
   3.129 -    and "continuous_on {a .. b} f"
   3.130 +    and "continuous_on (cbox a b) f"
   3.131      and "(f b)\<bullet>k \<le> y"
   3.132      and "y \<le> (f a)\<bullet>k"
   3.133 -  shows "\<exists>x\<in>{a..b}. (f x)\<bullet>k = y"
   3.134 +  shows "\<exists>x\<in>cbox a b. (f x)\<bullet>k = y"
   3.135    apply (subst neg_equal_iff_equal[symmetric])
   3.136    using ivt_increasing_component_on_1[of a b "\<lambda>x. - f x" k "- y"]
   3.137    using assms using continuous_on_minus
   3.138 @@ -5778,8 +5775,8 @@
   3.139  
   3.140  lemma ivt_decreasing_component_1:
   3.141    fixes f :: "real \<Rightarrow> 'a::euclidean_space"
   3.142 -  shows "a \<le> b \<Longrightarrow> \<forall>x\<in>{a .. b}. continuous (at x) f \<Longrightarrow>
   3.143 -    f b\<bullet>k \<le> y \<Longrightarrow> y \<le> f a\<bullet>k \<Longrightarrow> \<exists>x\<in>{a..b}. (f x)\<bullet>k = y"
   3.144 +  shows "a \<le> b \<Longrightarrow> \<forall>x\<in>cbox a b. continuous (at x) f \<Longrightarrow>
   3.145 +    f b\<bullet>k \<le> y \<Longrightarrow> y \<le> f a\<bullet>k \<Longrightarrow> \<exists>x\<in>cbox a b. (f x)\<bullet>k = y"
   3.146    by (rule ivt_decreasing_component_on_1) (auto simp: continuous_at_imp_continuous_on)
   3.147  
   3.148  
   3.149 @@ -5886,32 +5883,33 @@
   3.150      by (simp add: f.add f.scaleR linear_iff)
   3.151  qed
   3.152  
   3.153 -lemma convex_hull_eq_real_interval:
   3.154 +lemma convex_hull_eq_real_cbox:
   3.155    fixes x y :: real assumes "x \<le> y"
   3.156 -  shows "convex hull {x, y} = {x..y}"
   3.157 +  shows "convex hull {x, y} = cbox x y"
   3.158  proof (rule hull_unique)
   3.159 -  show "{x, y} \<subseteq> {x..y}" using `x \<le> y` by auto
   3.160 -  show "convex {x..y}" by (rule convex_interval)
   3.161 +  show "{x, y} \<subseteq> cbox x y" using `x \<le> y` by auto
   3.162 +  show "convex (cbox x y)"
   3.163 +    by (rule convex_box)
   3.164  next
   3.165    fix s assume "{x, y} \<subseteq> s" and "convex s"
   3.166 -  then show "{x..y} \<subseteq> s"
   3.167 +  then show "cbox x y \<subseteq> s"
   3.168      unfolding is_interval_convex_1 [symmetric] is_interval_def Basis_real_def
   3.169      by - (clarify, simp (no_asm_use), fast)
   3.170  qed
   3.171  
   3.172  lemma unit_interval_convex_hull:
   3.173    defines "One \<equiv> \<Sum>Basis"
   3.174 -  shows "{0::'a::ordered_euclidean_space .. One} = convex hull {x. \<forall>i\<in>Basis. (x\<bullet>i = 0) \<or> (x\<bullet>i = 1)}"
   3.175 +  shows "cbox (0::'a::euclidean_space) One = convex hull {x. \<forall>i\<in>Basis. (x\<bullet>i = 0) \<or> (x\<bullet>i = 1)}"
   3.176    (is "?int = convex hull ?points")
   3.177  proof -
   3.178    have One[simp]: "\<And>i. i \<in> Basis \<Longrightarrow> One \<bullet> i = 1"
   3.179      by (simp add: One_def inner_setsum_left setsum_cases inner_Basis)
   3.180 -  have "?int = {x. \<forall>i\<in>Basis. x \<bullet> i \<in> {0..1}}"
   3.181 -    by (auto simp add: eucl_le [where 'a='a])
   3.182 -  also have "\<dots> = (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` {0..1})"
   3.183 +  have "?int = {x. \<forall>i\<in>Basis. x \<bullet> i \<in> cbox 0 1}"
   3.184 +    by (auto simp: cbox_def)
   3.185 +  also have "\<dots> = (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` cbox 0 1)"
   3.186      by (simp only: box_eq_set_setsum_Basis)
   3.187    also have "\<dots> = (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` (convex hull {0, 1}))"
   3.188 -    by (simp only: convex_hull_eq_real_interval zero_le_one)
   3.189 +    by (simp only: convex_hull_eq_real_cbox zero_le_one)
   3.190    also have "\<dots> = (\<Sum>i\<in>Basis. convex hull ((\<lambda>x. x *\<^sub>R i) ` {0, 1}))"
   3.191      by (simp only: convex_hull_linear_image linear_scaleR_left)
   3.192    also have "\<dots> = convex hull (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` {0, 1})"
   3.193 @@ -5926,8 +5924,8 @@
   3.194  text {* And this is a finite set of vertices. *}
   3.195  
   3.196  lemma unit_cube_convex_hull:
   3.197 -  obtains s :: "'a::ordered_euclidean_space set"
   3.198 -    where "finite s" and "{0 .. \<Sum>Basis} = convex hull s"
   3.199 +  obtains s :: "'a::euclidean_space set"
   3.200 +    where "finite s" and "cbox 0 (\<Sum>Basis) = convex hull s"
   3.201    apply (rule that[of "{x::'a. \<forall>i\<in>Basis. x\<bullet>i=0 \<or> x\<bullet>i=1}"])
   3.202    apply (rule finite_subset[of _ "(\<lambda>s. (\<Sum>i\<in>Basis. (if i\<in>s then 1 else 0) *\<^sub>R i)::'a) ` Pow Basis"])
   3.203    prefer 3
   3.204 @@ -5949,23 +5947,23 @@
   3.205  
   3.206  lemma cube_convex_hull:
   3.207    assumes "d > 0"
   3.208 -  obtains s :: "'a::ordered_euclidean_space set" where
   3.209 -    "finite s" and "{x - (\<Sum>i\<in>Basis. d*\<^sub>Ri) .. x + (\<Sum>i\<in>Basis. d*\<^sub>Ri)} = convex hull s"
   3.210 +  obtains s :: "'a::euclidean_space set" where
   3.211 +    "finite s" and "cbox (x - (\<Sum>i\<in>Basis. d*\<^sub>Ri)) (x + (\<Sum>i\<in>Basis. d*\<^sub>Ri)) = convex hull s"
   3.212  proof -
   3.213    let ?d = "(\<Sum>i\<in>Basis. d*\<^sub>Ri)::'a"
   3.214 -  have *: "{x - ?d .. x + ?d} = (\<lambda>y. x - ?d + (2 * d) *\<^sub>R y) ` {0 .. \<Sum>Basis}"
   3.215 +  have *: "cbox (x - ?d) (x + ?d) = (\<lambda>y. x - ?d + (2 * d) *\<^sub>R y) ` cbox 0 (\<Sum>Basis)"
   3.216      apply (rule set_eqI, rule)
   3.217      unfolding image_iff
   3.218      defer
   3.219      apply (erule bexE)
   3.220    proof -
   3.221      fix y
   3.222 -    assume as: "y\<in>{x - ?d .. x + ?d}"
   3.223 +    assume as: "y\<in>cbox (x - ?d) (x + ?d)"
   3.224      {
   3.225        fix i :: 'a
   3.226        assume i: "i \<in> Basis"
   3.227        have "x \<bullet> i \<le> d + y \<bullet> i" "y \<bullet> i \<le> d + x \<bullet> i"
   3.228 -        using as[unfolded mem_interval, THEN bspec[where x=i]] i
   3.229 +        using as[unfolded mem_box, THEN bspec[where x=i]] i
   3.230          by (auto simp: inner_simps)
   3.231        then have "1 \<ge> inverse d * (x \<bullet> i - y \<bullet> i)" "1 \<ge> inverse d * (y \<bullet> i - x \<bullet> i)"
   3.232          apply (rule_tac[!] mult_left_le_imp_le[OF _ assms])
   3.233 @@ -5975,10 +5973,10 @@
   3.234        then have "inverse d * (x \<bullet> i * 2) \<le> 2 + inverse d * (y \<bullet> i * 2)"
   3.235          "inverse d * (y \<bullet> i * 2) \<le> 2 + inverse d * (x \<bullet> i * 2)"
   3.236          by (auto simp add:field_simps) }
   3.237 -    then have "inverse (2 * d) *\<^sub>R (y - (x - ?d)) \<in> {0..\<Sum>Basis}"
   3.238 -      unfolding mem_interval using assms
   3.239 +    then have "inverse (2 * d) *\<^sub>R (y - (x - ?d)) \<in> cbox 0 (\<Sum>Basis)"
   3.240 +      unfolding mem_box using assms
   3.241        by (auto simp add: field_simps inner_simps)
   3.242 -    then show "\<exists>z\<in>{0..\<Sum>Basis}. y = x - ?d + (2 * d) *\<^sub>R z"
   3.243 +    then show "\<exists>z\<in>cbox 0 (\<Sum>Basis). y = x - ?d + (2 * d) *\<^sub>R z"
   3.244        apply -
   3.245        apply (rule_tac x="inverse (2 * d) *\<^sub>R (y - (x - ?d))" in bexI)
   3.246        using assms
   3.247 @@ -5986,9 +5984,9 @@
   3.248        done
   3.249    next
   3.250      fix y z
   3.251 -    assume as: "z\<in>{0..\<Sum>Basis}" "y = x - ?d + (2*d) *\<^sub>R z"
   3.252 +    assume as: "z\<in>cbox 0 (\<Sum>Basis)" "y = x - ?d + (2*d) *\<^sub>R z"
   3.253      have "\<And>i. i\<in>Basis \<Longrightarrow> 0 \<le> d * (z \<bullet> i) \<and> d * (z \<bullet> i) \<le> d"
   3.254 -      using assms as(1)[unfolded mem_interval]
   3.255 +      using assms as(1)[unfolded mem_box]
   3.256        apply (erule_tac x=i in ballE)
   3.257        apply rule
   3.258        apply (rule mult_nonneg_nonneg)
   3.259 @@ -5997,17 +5995,17 @@
   3.260        using assms
   3.261        apply auto
   3.262        done
   3.263 -    then show "y \<in> {x - ?d..x + ?d}"
   3.264 -      unfolding as(2) mem_interval
   3.265 +    then show "y \<in> cbox (x - ?d) (x + ?d)"
   3.266 +      unfolding as(2) mem_box
   3.267        apply -
   3.268        apply rule
   3.269 -      using as(1)[unfolded mem_interval]
   3.270 +      using as(1)[unfolded mem_box]
   3.271        apply (erule_tac x=i in ballE)
   3.272        using assms
   3.273        apply (auto simp: inner_simps)
   3.274        done
   3.275    qed
   3.276 -  obtain s where "finite s" "{0::'a..\<Sum>Basis} = convex hull s"
   3.277 +  obtain s where "finite s" "cbox 0 (\<Sum>Basis::'a) = convex hull s"
   3.278      using unit_cube_convex_hull by auto
   3.279    then show ?thesis
   3.280      apply (rule_tac that[of "(\<lambda>y. x - ?d + (2 * d) *\<^sub>R y)` s"])
   3.281 @@ -6198,14 +6196,14 @@
   3.282      def c \<equiv> "\<Sum>i\<in>Basis. (\<lambda>a. a *\<^sub>R i) ` {x\<bullet>i - d, x\<bullet>i + d}"
   3.283      show "finite c"
   3.284        unfolding c_def by (simp add: finite_set_setsum)
   3.285 -    have 1: "convex hull c = {a. \<forall>i\<in>Basis. a \<bullet> i \<in> {x \<bullet> i - d..x \<bullet> i + d}}"
   3.286 +    have 1: "convex hull c = {a. \<forall>i\<in>Basis. a \<bullet> i \<in> cbox (x \<bullet> i - d) (x \<bullet> i + d)}"
   3.287        unfolding box_eq_set_setsum_Basis
   3.288        unfolding c_def convex_hull_set_setsum
   3.289        apply (subst convex_hull_linear_image [symmetric])
   3.290        apply (simp add: linear_iff scaleR_add_left)
   3.291        apply (rule setsum_cong [OF refl])
   3.292        apply (rule image_cong [OF _ refl])
   3.293 -      apply (rule convex_hull_eq_real_interval)
   3.294 +      apply (rule convex_hull_eq_real_cbox)
   3.295        apply (cut_tac `0 < d`, simp)
   3.296        done
   3.297      then have 2: "convex hull c = {a. \<forall>i\<in>Basis. a \<bullet> i \<in> cball (x \<bullet> i) d}"
     4.1 --- a/src/HOL/Multivariate_Analysis/Derivative.thy	Mon Mar 17 21:56:32 2014 +0100
     4.2 +++ b/src/HOL/Multivariate_Analysis/Derivative.thy	Tue Mar 18 10:12:57 2014 +0100
     4.3 @@ -458,11 +458,11 @@
     4.4    by (rule has_derivative_unique)
     4.5  
     4.6  lemma frechet_derivative_unique_within_closed_interval:
     4.7 -  fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
     4.8 +  fixes f::"'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
     4.9    assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
    4.10 -    and "x \<in> {a..b}"
    4.11 -    and "(f has_derivative f' ) (at x within {a..b})"
    4.12 -    and "(f has_derivative f'') (at x within {a..b})"
    4.13 +    and "x \<in> cbox a b"
    4.14 +    and "(f has_derivative f' ) (at x within cbox a b)"
    4.15 +    and "(f has_derivative f'') (at x within cbox a b)"
    4.16    shows "f' = f''"
    4.17    apply(rule frechet_derivative_unique_within)
    4.18    apply(rule assms(3,4))+
    4.19 @@ -470,18 +470,18 @@
    4.20    fix e :: real
    4.21    fix i :: 'a
    4.22    assume "e > 0" and i: "i \<in> Basis"
    4.23 -  then show "\<exists>d. 0 < \<bar>d\<bar> \<and> \<bar>d\<bar> < e \<and> x + d *\<^sub>R i \<in> {a..b}"
    4.24 +  then show "\<exists>d. 0 < \<bar>d\<bar> \<and> \<bar>d\<bar> < e \<and> x + d *\<^sub>R i \<in> cbox a b"
    4.25    proof (cases "x\<bullet>i = a\<bullet>i")
    4.26      case True
    4.27      then show ?thesis
    4.28        apply (rule_tac x="(min (b\<bullet>i - a\<bullet>i)  e) / 2" in exI)
    4.29        using assms(1)[THEN bspec[where x=i]] and `e>0` and assms(2)
    4.30 -      unfolding mem_interval
    4.31 +      unfolding mem_box
    4.32        using i
    4.33        apply (auto simp add: field_simps inner_simps inner_Basis)
    4.34        done
    4.35    next
    4.36 -    note * = assms(2)[unfolded mem_interval, THEN bspec, OF i]
    4.37 +    note * = assms(2)[unfolded mem_box, THEN bspec, OF i]
    4.38      case False
    4.39      moreover have "a \<bullet> i < x \<bullet> i"
    4.40        using False * by auto
    4.41 @@ -502,7 +502,7 @@
    4.42      ultimately show ?thesis
    4.43        apply (rule_tac x="- (min (x\<bullet>i - a\<bullet>i) e) / 2" in exI)
    4.44        using assms(1)[THEN bspec, OF i] and `e>0` and assms(2)
    4.45 -      unfolding mem_interval
    4.46 +      unfolding mem_box
    4.47        using i
    4.48        apply (auto simp add: field_simps inner_simps inner_Basis)
    4.49        done
    4.50 @@ -510,14 +510,14 @@
    4.51  qed
    4.52  
    4.53  lemma frechet_derivative_unique_within_open_interval:
    4.54 -  fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
    4.55 +  fixes f::"'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
    4.56    assumes "x \<in> box a b"
    4.57      and "(f has_derivative f' ) (at x within box a b)"
    4.58      and "(f has_derivative f'') (at x within box a b)"
    4.59    shows "f' = f''"
    4.60  proof -
    4.61    from assms(1) have *: "at x within box a b = at x"
    4.62 -    by (metis at_within_interior interior_open open_interval)
    4.63 +    by (metis at_within_interior interior_open open_box)
    4.64    from assms(2,3) [unfolded *] show "f' = f''"
    4.65      by (rule frechet_derivative_unique_at)
    4.66  qed
    4.67 @@ -531,12 +531,12 @@
    4.68    apply auto
    4.69    done
    4.70  
    4.71 -lemma frechet_derivative_within_closed_interval:
    4.72 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
    4.73 +lemma frechet_derivative_within_cbox:
    4.74 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
    4.75    assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
    4.76 -    and "x \<in> {a..b}"
    4.77 -    and "(f has_derivative f') (at x within {a..b})"
    4.78 -  shows "frechet_derivative f (at x within {a..b}) = f'"
    4.79 +    and "x \<in> cbox a b"
    4.80 +    and "(f has_derivative f') (at x within cbox a b)"
    4.81 +  shows "frechet_derivative f (at x within cbox a b) = f'"
    4.82    using assms
    4.83    by (metis Derivative.differentiableI frechet_derivative_unique_within_closed_interval frechet_derivative_works)
    4.84  
    4.85 @@ -641,34 +641,34 @@
    4.86    fixes f :: "real \<Rightarrow> real"
    4.87    assumes "a < b"
    4.88      and "f a = f b"
    4.89 -    and "continuous_on {a..b} f"
    4.90 -    and "\<forall>x\<in>box a b. (f has_derivative f' x) (at x)"
    4.91 -  shows "\<exists>x\<in>box a b. f' x = (\<lambda>v. 0)"
    4.92 +    and "continuous_on {a .. b} f"
    4.93 +    and "\<forall>x\<in>{a <..< b}. (f has_derivative f' x) (at x)"
    4.94 +  shows "\<exists>x\<in>{a <..< b}. f' x = (\<lambda>v. 0)"
    4.95  proof -
    4.96    have "\<exists>x\<in>box a b. (\<forall>y\<in>box a b. f x \<le> f y) \<or> (\<forall>y\<in>box a b. f y \<le> f x)"
    4.97    proof -
    4.98      have "(a + b) / 2 \<in> {a .. b}"
    4.99        using assms(1) by auto
   4.100 -    then have *: "{a..b} \<noteq> {}"
   4.101 +    then have *: "{a .. b} \<noteq> {}"
   4.102        by auto
   4.103      obtain d where d:
   4.104 -        "d \<in> {a..b}"
   4.105 -        "\<forall>y\<in>{a..b}. f y \<le> f d"
   4.106 -      using continuous_attains_sup[OF compact_interval * assms(3)] ..
   4.107 +        "d \<in>cbox a b"
   4.108 +        "\<forall>y\<in>cbox a b. f y \<le> f d"
   4.109 +      using continuous_attains_sup[OF compact_Icc * assms(3)] by auto
   4.110      obtain c where c:
   4.111 -        "c \<in> {a..b}"
   4.112 -        "\<forall>y\<in>{a..b}. f c \<le> f y"
   4.113 -      using continuous_attains_inf[OF compact_interval * assms(3)] ..
   4.114 +        "c \<in> cbox a b"
   4.115 +        "\<forall>y\<in>cbox a b. f c \<le> f y"
   4.116 +      using continuous_attains_inf[OF compact_Icc * assms(3)] by auto
   4.117      show ?thesis
   4.118      proof (cases "d \<in> box a b \<or> c \<in> box a b")
   4.119        case True
   4.120        then show ?thesis
   4.121 -        by (metis c(2) d(2) interval_open_subset_closed subset_iff)
   4.122 +        by (metis c(2) d(2) box_subset_cbox subset_iff)
   4.123      next
   4.124        def e \<equiv> "(a + b) /2"
   4.125        case False
   4.126        then have "f d = f c"
   4.127 -        using d c assms(2) by (auto simp: box_real)
   4.128 +        using d c assms(2) by auto
   4.129        then have "\<And>x. x \<in> {a..b} \<Longrightarrow> f x = f d"
   4.130          using c d
   4.131          by force
   4.132 @@ -676,11 +676,12 @@
   4.133          apply (rule_tac x=e in bexI)
   4.134          unfolding e_def
   4.135          using assms(1)
   4.136 -        apply (auto simp: box_real)
   4.137 +        apply auto
   4.138          done
   4.139      qed
   4.140    qed
   4.141 -  then obtain x where x: "x \<in> box a b" "(\<forall>y\<in>box a b. f x \<le> f y) \<or> (\<forall>y\<in>box a b. f y \<le> f x)" ..
   4.142 +  then obtain x where x: "x \<in> {a <..< b}" "(\<forall>y\<in>{a <..< b}. f x \<le> f y) \<or> (\<forall>y\<in>{a <..< b}. f y \<le> f x)"
   4.143 +    by auto
   4.144    then have "f' x = (\<lambda>v. 0)"
   4.145      apply (rule_tac differential_zero_maxmin[of x "box a b" f "f' x"])
   4.146      using assms
   4.147 @@ -700,19 +701,21 @@
   4.148    assumes "\<forall>x\<in>{a<..<b}. (f has_derivative (f' x)) (at x)"
   4.149    shows "\<exists>x\<in>{a<..<b}. f b - f a = (f' x) (b - a)"
   4.150  proof -
   4.151 -  have "\<exists>x\<in>box a b. (\<lambda>xa. f' x xa - (f b - f a) / (b - a) * xa) = (\<lambda>v. 0)"
   4.152 +  have "\<exists>x\<in>{a <..< b}. (\<lambda>xa. f' x xa - (f b - f a) / (b - a) * xa) = (\<lambda>v. 0)"
   4.153    proof (intro rolle[OF assms(1), of "\<lambda>x. f x - (f b - f a) / (b - a) * x"] ballI)
   4.154      fix x
   4.155 -    assume "x \<in> box a b" hence x: "x \<in> {a<..<b}" by (simp add: box_real)
   4.156 +    assume x: "x \<in> {a <..< b}"
   4.157      show "((\<lambda>x. f x - (f b - f a) / (b - a) * x) has_derivative
   4.158          (\<lambda>xa. f' x xa - (f b - f a) / (b - a) * xa)) (at x)"
   4.159        by (intro has_derivative_intros assms(3)[rule_format,OF x] mult_right_has_derivative)
   4.160    qed (insert assms(1,2), auto intro!: continuous_on_intros simp: field_simps)
   4.161    then obtain x where
   4.162 -    "x \<in> box a b"
   4.163 +    "x \<in> {a <..< b}"
   4.164      "(\<lambda>xa. f' x xa - (f b - f a) / (b - a) * xa) = (\<lambda>v. 0)" ..
   4.165    then show ?thesis
   4.166 -    by (metis (erased, hide_lams) assms(1) box_real diff_less_iff(1) eq_iff_diff_eq_0 linordered_field_class.sign_simps(41) nonzero_mult_divide_cancel_right not_real_square_gt_zero times_divide_eq_left)
   4.167 +    by (metis (erased, hide_lams) assms(1) diff_less_iff(1) eq_iff_diff_eq_0
   4.168 +      linordered_field_class.sign_simps(41) nonzero_mult_divide_cancel_right not_real_square_gt_zero
   4.169 +      times_divide_eq_left)
   4.170  qed
   4.171  
   4.172  lemma mvt_simple:
   4.173 @@ -727,21 +730,21 @@
   4.174    defer
   4.175  proof
   4.176    fix x
   4.177 -  assume x: "x \<in> {a<..<b}" hence x: "x \<in> box a b" by (simp add: box_real)
   4.178 +  assume x: "x \<in> {a <..< b}"
   4.179    show "(f has_derivative f' x) (at x)"
   4.180 -    unfolding has_derivative_within_open[OF x open_interval,symmetric]
   4.181 +    unfolding has_derivative_within_open[OF x open_greaterThanLessThan,symmetric]
   4.182      apply (rule has_derivative_within_subset)
   4.183      apply (rule assms(2)[rule_format])
   4.184      using x
   4.185 -    apply (auto simp: box_real)
   4.186 +    apply auto
   4.187      done
   4.188  qed (insert assms(2), auto)
   4.189  
   4.190  lemma mvt_very_simple:
   4.191    fixes f :: "real \<Rightarrow> real"
   4.192    assumes "a \<le> b"
   4.193 -    and "\<forall>x\<in>{a..b}. (f has_derivative f' x) (at x within {a..b})"
   4.194 -  shows "\<exists>x\<in>{a..b}. f b - f a = f' x (b - a)"
   4.195 +    and "\<forall>x\<in>{a .. b}. (f has_derivative f' x) (at x within {a .. b})"
   4.196 +  shows "\<exists>x\<in>{a .. b}. f b - f a = f' x (b - a)"
   4.197  proof (cases "a = b")
   4.198    interpret bounded_linear "f' b"
   4.199      using assms(2) assms(1) by auto
   4.200 @@ -767,7 +770,7 @@
   4.201  lemma mvt_general:
   4.202    fixes f :: "real \<Rightarrow> 'a::euclidean_space"
   4.203    assumes "a < b"
   4.204 -    and "continuous_on {a..b} f"
   4.205 +    and "continuous_on {a .. b} f"
   4.206      and "\<forall>x\<in>{a<..<b}. (f has_derivative f'(x)) (at x)"
   4.207    shows "\<exists>x\<in>{a<..<b}. norm (f b - f a) \<le> norm (f' x (b - a))"
   4.208  proof -
   4.209 @@ -825,7 +828,7 @@
   4.210      using assms(1)[unfolded convex_alt,rule_format,OF x y]
   4.211      unfolding scaleR_left_diff_distrib scaleR_right_diff_distrib
   4.212      by (auto simp add: algebra_simps)
   4.213 -  then have 1: "continuous_on {0..1} (f \<circ> ?p)"
   4.214 +  then have 1: "continuous_on {0 .. 1} (f \<circ> ?p)"
   4.215      apply -
   4.216      apply (rule continuous_on_intros)+
   4.217      unfolding continuous_on_eq_continuous_within
   4.218 @@ -837,12 +840,12 @@
   4.219      apply (rule assms(2)[rule_format])
   4.220      apply auto
   4.221      done
   4.222 -  have 2: "\<forall>u\<in>{0<..<1}.
   4.223 +  have 2: "\<forall>u\<in>{0 <..< 1}.
   4.224      ((f \<circ> ?p) has_derivative f' (x + u *\<^sub>R (y - x)) \<circ> (\<lambda>u. 0 + u *\<^sub>R (y - x))) (at u)"
   4.225    proof rule
   4.226      case goal1
   4.227      let ?u = "x + u *\<^sub>R (y - x)"
   4.228 -    have "(f \<circ> ?p has_derivative (f' ?u) \<circ> (\<lambda>u. 0 + u *\<^sub>R (y - x))) (at u within {0<..<1})"
   4.229 +    have "(f \<circ> ?p has_derivative (f' ?u) \<circ> (\<lambda>u. 0 + u *\<^sub>R (y - x))) (at u within box 0 1)"
   4.230        apply (rule diff_chain_within)
   4.231        apply (rule has_derivative_intros)+
   4.232        apply (rule has_derivative_within_subset)
   4.233 @@ -851,7 +854,7 @@
   4.234        apply auto
   4.235        done
   4.236      then show ?case
   4.237 -      unfolding has_derivative_within_open[OF goal1 open_greaterThanLessThan] .
   4.238 +      by (simp add: has_derivative_within_open[OF goal1 open_greaterThanLessThan])
   4.239    qed
   4.240    obtain u where u:
   4.241        "u \<in> {0<..<1}"
   4.242 @@ -2051,9 +2054,9 @@
   4.243  
   4.244  lemma vector_derivative_unique_within_closed_interval:
   4.245    assumes "a < b"
   4.246 -    and "x \<in> {a..b}"
   4.247 -  assumes "(f has_vector_derivative f') (at x within {a..b})"
   4.248 -  assumes "(f has_vector_derivative f'') (at x within {a..b})"
   4.249 +    and "x \<in> cbox a b"
   4.250 +  assumes "(f has_vector_derivative f') (at x within cbox a b)"
   4.251 +  assumes "(f has_vector_derivative f'') (at x within cbox a b)"
   4.252    shows "f' = f''"
   4.253  proof -
   4.254    have *: "(\<lambda>x. x *\<^sub>R f') = (\<lambda>x. x *\<^sub>R f'')"
   4.255 @@ -2084,9 +2087,9 @@
   4.256  
   4.257  lemma vector_derivative_within_closed_interval:
   4.258    assumes "a < b"
   4.259 -    and "x \<in> {a..b}"
   4.260 -  assumes "(f has_vector_derivative f') (at x within {a..b})"
   4.261 -  shows "vector_derivative f (at x within {a..b}) = f'"
   4.262 +    and "x \<in> cbox a b"
   4.263 +  assumes "(f has_vector_derivative f') (at x within cbox a b)"
   4.264 +  shows "vector_derivative f (at x within cbox a b) = f'"
   4.265    apply (rule vector_derivative_unique_within_closed_interval)
   4.266    using vector_derivative_works[unfolded differentiable_def]
   4.267    using assms
     5.1 --- a/src/HOL/Multivariate_Analysis/Fashoda.thy	Mon Mar 17 21:56:32 2014 +0100
     5.2 +++ b/src/HOL/Multivariate_Analysis/Fashoda.thy	Tue Mar 18 10:12:57 2014 +0100
     5.3 @@ -38,14 +38,14 @@
     5.4  
     5.5  lemma fashoda_unit:
     5.6    fixes f g :: "real \<Rightarrow> real^2"
     5.7 -  assumes "f ` {- 1..1} \<subseteq> {- 1..1}"
     5.8 -    and "g ` {- 1..1} \<subseteq> {- 1..1}"
     5.9 -    and "continuous_on {- 1..1} f"
    5.10 -    and "continuous_on {- 1..1} g"
    5.11 +  assumes "f ` {-1 .. 1} \<subseteq> cbox (-1) 1"
    5.12 +    and "g ` {-1 .. 1} \<subseteq> cbox (-1) 1"
    5.13 +    and "continuous_on {-1 .. 1} f"
    5.14 +    and "continuous_on {-1 .. 1} g"
    5.15      and "f (- 1)$1 = - 1"
    5.16      and "f 1$1 = 1" "g (- 1) $2 = -1"
    5.17      and "g 1 $2 = 1"
    5.18 -  shows "\<exists>s\<in>{- 1..1}. \<exists>t\<in>{- 1..1}. f s = g t"
    5.19 +  shows "\<exists>s\<in>{-1 .. 1}. \<exists>t\<in>{-1 .. 1}. f s = g t"
    5.20  proof (rule ccontr)
    5.21    assume "\<not> ?thesis"
    5.22    note as = this[unfolded bex_simps,rule_format]
    5.23 @@ -61,9 +61,9 @@
    5.24      apply auto
    5.25      done
    5.26    let ?F = "\<lambda>w::real^2. (f \<circ> (\<lambda>x. x$1)) w - (g \<circ> (\<lambda>x. x$2)) w"
    5.27 -  have *: "\<And>i. (\<lambda>x::real^2. x $ i) ` {- 1..1} = {- 1..1::real}"
    5.28 +  have *: "\<And>i. (\<lambda>x::real^2. x $ i) ` cbox (- 1) 1 = {-1 .. 1}"
    5.29      apply (rule set_eqI)
    5.30 -    unfolding image_iff Bex_def mem_interval_cart
    5.31 +    unfolding image_iff Bex_def mem_interval_cart interval_cbox_cart
    5.32      apply rule
    5.33      defer
    5.34      apply (rule_tac x="vec x" in exI)
    5.35 @@ -71,21 +71,21 @@
    5.36      done
    5.37    {
    5.38      fix x
    5.39 -    assume "x \<in> (\<lambda>w. (f \<circ> (\<lambda>x. x $ 1)) w - (g \<circ> (\<lambda>x. x $ 2)) w) ` {- 1..1::real^2}"
    5.40 +    assume "x \<in> (\<lambda>w. (f \<circ> (\<lambda>x. x $ 1)) w - (g \<circ> (\<lambda>x. x $ 2)) w) ` (cbox (- 1) (1::real^2))"
    5.41      then obtain w :: "real^2" where w:
    5.42 -        "w \<in> {- 1..1}"
    5.43 +        "w \<in> cbox (- 1) 1"
    5.44          "x = (f \<circ> (\<lambda>x. x $ 1)) w - (g \<circ> (\<lambda>x. x $ 2)) w"
    5.45        unfolding image_iff ..
    5.46      then have "x \<noteq> 0"
    5.47        using as[of "w$1" "w$2"]
    5.48 -      unfolding mem_interval_cart
    5.49 +      unfolding mem_interval_cart atLeastAtMost_iff
    5.50        by auto
    5.51    } note x0 = this
    5.52    have 21: "\<And>i::2. i \<noteq> 1 \<Longrightarrow> i = 2"
    5.53      using UNIV_2 by auto
    5.54    have 1: "box (- 1) (1::real^2) \<noteq> {}"
    5.55      unfolding interval_eq_empty_cart by auto
    5.56 -  have 2: "continuous_on {- 1..1} (negatex \<circ> sqprojection \<circ> ?F)"
    5.57 +  have 2: "continuous_on (cbox -1 1) (negatex \<circ> sqprojection \<circ> ?F)"
    5.58      apply (intro continuous_on_intros continuous_on_component)
    5.59      unfolding *
    5.60      apply (rule assms)+
    5.61 @@ -112,13 +112,13 @@
    5.62          done
    5.63      qed
    5.64    qed
    5.65 -  have 3: "(negatex \<circ> sqprojection \<circ> ?F) ` {- 1..1} \<subseteq> {- 1..1}"
    5.66 +  have 3: "(negatex \<circ> sqprojection \<circ> ?F) ` cbox (-1) 1 \<subseteq> cbox (-1) 1"
    5.67      unfolding subset_eq
    5.68      apply rule
    5.69    proof -
    5.70      case goal1
    5.71      then obtain y :: "real^2" where y:
    5.72 -        "y \<in> {- 1..1}"
    5.73 +        "y \<in> cbox -1 1"
    5.74          "x = (negatex \<circ> sqprojection \<circ> (\<lambda>w. (f \<circ> (\<lambda>x. x $ 1)) w - (g \<circ> (\<lambda>x. x $ 2)) w)) y"
    5.75        unfolding image_iff ..
    5.76      have "?F y \<noteq> 0"
    5.77 @@ -132,8 +132,8 @@
    5.78      have "infnorm x = 1"
    5.79        unfolding *[symmetric] y o_def
    5.80        by (rule lem1[rule_format])
    5.81 -    then show "x \<in> {- 1..1}"
    5.82 -      unfolding mem_interval_cart infnorm_2
    5.83 +    then show "x \<in> cbox (-1) 1"
    5.84 +      unfolding mem_interval_cart interval_cbox_cart infnorm_2
    5.85        apply -
    5.86        apply rule
    5.87      proof -
    5.88 @@ -147,11 +147,11 @@
    5.89      qed
    5.90    qed
    5.91    obtain x :: "real^2" where x:
    5.92 -      "x \<in> {- 1..1}"
    5.93 +      "x \<in> cbox -1 1"
    5.94        "(negatex \<circ> sqprojection \<circ> (\<lambda>w. (f \<circ> (\<lambda>x. x $ 1)) w - (g \<circ> (\<lambda>x. x $ 2)) w)) x = x"
    5.95 -    apply (rule brouwer_weak[of "{- 1..1::real^2}" "negatex \<circ> sqprojection \<circ> ?F"])
    5.96 -    apply (rule compact_interval convex_interval)+
    5.97 -    unfolding interior_closed_interval
    5.98 +    apply (rule brouwer_weak[of "cbox -1 (1::real^2)" "negatex \<circ> sqprojection \<circ> ?F"])
    5.99 +    apply (rule compact_cbox convex_box)+
   5.100 +    unfolding interior_cbox
   5.101      apply (rule 1 2 3)+
   5.102      apply blast
   5.103      done
   5.104 @@ -213,7 +213,7 @@
   5.105        unfolding as negatex_def vector_2
   5.106        by auto
   5.107      moreover
   5.108 -    from x1 have "g (x $ 2) \<in> {- 1..1}"
   5.109 +    from x1 have "g (x $ 2) \<in> cbox (-1) 1"
   5.110        apply -
   5.111        apply (rule assms(2)[unfolded subset_eq,rule_format])
   5.112        apply auto
   5.113 @@ -232,7 +232,7 @@
   5.114        unfolding as negatex_def vector_2
   5.115        by auto
   5.116      moreover
   5.117 -    from x1 have "g (x $ 2) \<in> {- 1..1}"
   5.118 +    from x1 have "g (x $ 2) \<in> cbox (-1) 1"
   5.119        apply -
   5.120        apply (rule assms(2)[unfolded subset_eq,rule_format])
   5.121        apply auto
   5.122 @@ -251,7 +251,7 @@
   5.123        unfolding as negatex_def vector_2
   5.124        by auto
   5.125      moreover
   5.126 -    from x1 have "f (x $ 1) \<in> {- 1..1}"
   5.127 +    from x1 have "f (x $ 1) \<in> cbox (-1) 1"
   5.128        apply -
   5.129        apply (rule assms(1)[unfolded subset_eq,rule_format])
   5.130        apply auto
   5.131 @@ -270,7 +270,7 @@
   5.132        unfolding as negatex_def vector_2
   5.133        by auto
   5.134      moreover
   5.135 -    from x1 have "f (x $ 1) \<in> {- 1..1}"
   5.136 +    from x1 have "f (x $ 1) \<in> cbox (-1) 1"
   5.137        apply -
   5.138        apply (rule assms(1)[unfolded subset_eq,rule_format])
   5.139        apply auto
   5.140 @@ -287,8 +287,8 @@
   5.141    fixes f g :: "real \<Rightarrow> real^2"
   5.142    assumes "path f"
   5.143      and "path g"
   5.144 -    and "path_image f \<subseteq> {- 1..1}"
   5.145 -    and "path_image g \<subseteq> {- 1..1}"
   5.146 +    and "path_image f \<subseteq> cbox (-1) 1"
   5.147 +    and "path_image g \<subseteq> cbox (-1) 1"
   5.148      and "(pathstart f)$1 = -1"
   5.149      and "(pathfinish f)$1 = 1"
   5.150      and "(pathstart g)$2 = -1"
   5.151 @@ -301,7 +301,7 @@
   5.152      unfolding iscale_def by auto
   5.153    have "\<exists>s\<in>{- 1..1}. \<exists>t\<in>{- 1..1}. (f \<circ> iscale) s = (g \<circ> iscale) t"
   5.154    proof (rule fashoda_unit)
   5.155 -    show "(f \<circ> iscale) ` {- 1..1} \<subseteq> {- 1..1}" "(g \<circ> iscale) ` {- 1..1} \<subseteq> {- 1..1}"
   5.156 +    show "(f \<circ> iscale) ` {- 1..1} \<subseteq> cbox -1 1" "(g \<circ> iscale) ` {- 1..1} \<subseteq> cbox -1 1"
   5.157        using isc and assms(3-4) by (auto simp add: image_comp [symmetric])
   5.158      have *: "continuous_on {- 1..1} iscale"
   5.159        unfolding iscale_def by (rule continuous_on_intros)+
   5.160 @@ -325,7 +325,7 @@
   5.161        "s \<in> {- 1..1}"
   5.162        "t \<in> {- 1..1}"
   5.163        "(f \<circ> iscale) s = (g \<circ> iscale) t"
   5.164 -    by blast
   5.165 +    by auto
   5.166    show thesis
   5.167      apply (rule_tac z = "f (iscale s)" in that)
   5.168      using st
   5.169 @@ -343,8 +343,8 @@
   5.170    fixes b :: "real^2"
   5.171    assumes "path f"
   5.172      and "path g"
   5.173 -    and "path_image f \<subseteq> {a..b}"
   5.174 -    and "path_image g \<subseteq> {a..b}"
   5.175 +    and "path_image f \<subseteq> cbox a b"
   5.176 +    and "path_image g \<subseteq> cbox a b"
   5.177      and "(pathstart f)$1 = a$1"
   5.178      and "(pathfinish f)$1 = b$1"
   5.179      and "(pathstart g)$2 = a$2"
   5.180 @@ -356,7 +356,7 @@
   5.181    then show thesis
   5.182      by auto
   5.183  next
   5.184 -  have "{a..b} \<noteq> {}"
   5.185 +  have "cbox a b \<noteq> {}"
   5.186      using assms(3) using path_image_nonempty[of f] by auto
   5.187    then have "a \<le> b"
   5.188      unfolding interval_eq_empty_cart less_eq_vec_def by (auto simp add: not_less)
   5.189 @@ -371,13 +371,13 @@
   5.190      apply (rule pathfinish_in_path_image)
   5.191      unfolding assms using assms(3)[unfolded path_image_def subset_eq,rule_format,of "f 0"]
   5.192      unfolding pathstart_def
   5.193 -    apply (auto simp add: less_eq_vec_def)
   5.194 +    apply (auto simp add: less_eq_vec_def mem_interval_cart)
   5.195      done
   5.196    then obtain z :: "real^2" where z: "z \<in> path_image g" "z $ 2 = pathstart f $ 2" ..
   5.197 -  have "z \<in> {a..b}"
   5.198 +  have "z \<in> cbox a b"
   5.199      using z(1) assms(4)
   5.200      unfolding path_image_def
   5.201 -    by blast 
   5.202 +    by blast
   5.203    then have "z = f 0"
   5.204      unfolding vec_eq_iff forall_2
   5.205      unfolding z(2) pathstart_def
   5.206 @@ -403,13 +403,13 @@
   5.207      unfolding assms
   5.208      using assms(4)[unfolded path_image_def subset_eq,rule_format,of "g 0"]
   5.209      unfolding pathstart_def
   5.210 -    apply (auto simp add: less_eq_vec_def)
   5.211 +    apply (auto simp add: less_eq_vec_def mem_interval_cart)
   5.212      done
   5.213    then obtain z where z: "z \<in> path_image f" "z $ 1 = pathstart g $ 1" ..
   5.214 -  have "z \<in> {a..b}"
   5.215 +  have "z \<in> cbox a b"
   5.216      using z(1) assms(3)
   5.217      unfolding path_image_def
   5.218 -    by blast 
   5.219 +    by blast
   5.220    then have "z = g 0"
   5.221      unfolding vec_eq_iff forall_2
   5.222      unfolding z(2) pathstart_def
   5.223 @@ -427,7 +427,7 @@
   5.224      done
   5.225  next
   5.226    assume as: "a $ 1 < b $ 1 \<and> a $ 2 < b $ 2"
   5.227 -  have int_nem: "{- 1..1::real^2} \<noteq> {}"
   5.228 +  have int_nem: "cbox (-1) (1::real^2) \<noteq> {}"
   5.229      unfolding interval_eq_empty_cart by auto
   5.230    obtain z :: "real^2" where z:
   5.231        "z \<in> (interval_bij (a, b) (- 1, 1) \<circ> f) ` {0..1}"
   5.232 @@ -445,7 +445,7 @@
   5.233          "y \<in> {0..1}"
   5.234          "x = (interval_bij (a, b) (- 1, 1) \<circ> f) y"
   5.235        unfolding image_iff ..
   5.236 -    show "x \<in> {- 1..1}"
   5.237 +    show "x \<in> cbox -1 1"
   5.238        unfolding y o_def
   5.239        apply (rule in_interval_interval_bij)
   5.240        using y(1)
   5.241 @@ -459,7 +459,7 @@
   5.242          "y \<in> {0..1}"
   5.243          "x = (interval_bij (a, b) (- 1, 1) \<circ> g) y"
   5.244        unfolding image_iff ..
   5.245 -    show "x \<in> {- 1..1}"
   5.246 +    show "x \<in> cbox -1 1"
   5.247        unfolding y o_def
   5.248        apply (rule in_interval_interval_bij)
   5.249        using y(1)
   5.250 @@ -471,7 +471,7 @@
   5.251        and "(interval_bij (a, b) (- 1, 1) \<circ> f) 1 $ 1 = 1"
   5.252        and "(interval_bij (a, b) (- 1, 1) \<circ> g) 0 $ 2 = -1"
   5.253        and "(interval_bij (a, b) (- 1, 1) \<circ> g) 1 $ 2 = 1"
   5.254 -      using assms as 
   5.255 +      using assms as
   5.256        by (simp_all add: axis_in_Basis cart_eq_inner_axis pathstart_def pathfinish_def interval_bij_def)
   5.257           (simp_all add: inner_axis)
   5.258    qed
   5.259 @@ -669,8 +669,8 @@
   5.260    fixes a :: "real^2"
   5.261    assumes "path f"
   5.262      and "path g"
   5.263 -    and "path_image f \<subseteq> {a..b}"
   5.264 -    and "path_image g \<subseteq> {a..b}"
   5.265 +    and "path_image f \<subseteq> cbox a b"
   5.266 +    and "path_image g \<subseteq> cbox a b"
   5.267      and "(pathstart f)$2 = a$2"
   5.268      and "(pathfinish f)$2 = a$2"
   5.269      and "(pathstart g)$2 = a$2"
   5.270 @@ -680,13 +680,13 @@
   5.271      and "(pathfinish f)$1 < (pathfinish g)$1"
   5.272    obtains z where "z \<in> path_image f" and "z \<in> path_image g"
   5.273  proof -
   5.274 -  have "{a..b} \<noteq> {}"
   5.275 +  have "cbox a b \<noteq> {}"
   5.276      using path_image_nonempty[of f] using assms(3) by auto
   5.277    note ab=this[unfolded interval_eq_empty_cart not_ex forall_2 not_less]
   5.278 -  have "pathstart f \<in> {a..b}"
   5.279 -    and "pathfinish f \<in> {a..b}"
   5.280 -    and "pathstart g \<in> {a..b}"
   5.281 -    and "pathfinish g \<in> {a..b}"
   5.282 +  have "pathstart f \<in> cbox a b"
   5.283 +    and "pathfinish f \<in> cbox a b"
   5.284 +    and "pathstart g \<in> cbox a b"
   5.285 +    and "pathfinish g \<in> cbox a b"
   5.286      using pathstart_in_path_image pathfinish_in_path_image
   5.287      using assms(3-4)
   5.288      by auto
   5.289 @@ -710,7 +710,8 @@
   5.290        path_image(linepath(vector[(pathfinish g)$1,a$2 - 1])(vector[b$1 + 1,a$2 - 1])) \<union>
   5.291        path_image(linepath(vector[b$1 + 1,a$2 - 1])(vector[b$1 + 1,b$2 + 3]))" using assms(1-2)
   5.292        by(auto simp add: path_image_join path_linepath)
   5.293 -  have abab: "{a..b} \<subseteq> {?a..?b}"
   5.294 +  have abab: "cbox a b \<subseteq> cbox ?a ?b"
   5.295 +    unfolding interval_cbox_cart[symmetric]
   5.296      by (auto simp add:less_eq_vec_def forall_2 vector_2)
   5.297    obtain z where
   5.298      "z \<in> path_image
   5.299 @@ -730,30 +731,30 @@
   5.300    proof -
   5.301      show "path ?P1" and "path ?P2"
   5.302        using assms by auto
   5.303 -    have "path_image ?P1 \<subseteq> {?a .. ?b}"
   5.304 +    have "path_image ?P1 \<subseteq> cbox ?a ?b"
   5.305        unfolding P1P2 path_image_linepath
   5.306        apply (rule Un_least)+
   5.307        defer 3
   5.308 -      apply (rule_tac[1-4] convex_interval(1)[unfolded convex_contains_segment,rule_format])
   5.309 +      apply (rule_tac[1-4] convex_box(1)[unfolded convex_contains_segment,rule_format])
   5.310        unfolding mem_interval_cart forall_2 vector_2
   5.311        using ab startfin abab assms(3)
   5.312        using assms(9-)
   5.313        unfolding assms
   5.314 -      apply (auto simp add: field_simps interval)
   5.315 +      apply (auto simp add: field_simps box)
   5.316        done
   5.317 -    then show "path_image ?P1 \<subseteq> {?a .. ?b}" .
   5.318 -    have "path_image ?P2 \<subseteq> {?a .. ?b}"
   5.319 +    then show "path_image ?P1 \<subseteq> cbox ?a ?b" .
   5.320 +    have "path_image ?P2 \<subseteq> cbox ?a ?b"
   5.321        unfolding P1P2 path_image_linepath
   5.322        apply (rule Un_least)+
   5.323        defer 2
   5.324 -      apply (rule_tac[1-4] convex_interval(1)[unfolded convex_contains_segment,rule_format])
   5.325 +      apply (rule_tac[1-4] convex_box(1)[unfolded convex_contains_segment,rule_format])
   5.326        unfolding mem_interval_cart forall_2 vector_2
   5.327        using ab startfin abab assms(4)
   5.328        using assms(9-)
   5.329        unfolding assms
   5.330 -      apply (auto simp add: field_simps interval)
   5.331 +      apply (auto simp add: field_simps box)
   5.332        done
   5.333 -    then show "path_image ?P2 \<subseteq> {?a .. ?b}" .
   5.334 +    then show "path_image ?P2 \<subseteq> cbox ?a ?b" .
   5.335      show "a $ 1 - 2 = a $ 1 - 2"
   5.336        and "b $ 1 + 2 = b $ 1 + 2"
   5.337        and "pathstart g $ 2 - 3 = a $ 2 - 3"
   5.338 @@ -775,7 +776,7 @@
   5.339        apply (simp only: segment_vertical segment_horizontal vector_2)
   5.340      proof -
   5.341        case goal1 note as=this
   5.342 -      have "pathfinish f \<in> {a..b}"
   5.343 +      have "pathfinish f \<in> cbox a b"
   5.344          using assms(3) pathfinish_in_path_image[of f] by auto 
   5.345        then have "1 + b $ 1 \<le> pathfinish f $ 1 \<Longrightarrow> False"
   5.346          unfolding mem_interval_cart forall_2 by auto
   5.347 @@ -783,7 +784,7 @@
   5.348          using as(2)
   5.349          using assms ab
   5.350          by (auto simp add: field_simps)
   5.351 -      moreover have "pathstart f \<in> {a..b}"
   5.352 +      moreover have "pathstart f \<in> cbox a b"
   5.353          using assms(3) pathstart_in_path_image[of f]
   5.354          by auto
   5.355        then have "1 + b $ 1 \<le> pathstart f $ 1 \<Longrightarrow> False"
   5.356 @@ -799,7 +800,7 @@
   5.357          using as(2)
   5.358          using assms ab
   5.359          by (auto simp add: field_simps *)
   5.360 -      moreover have "pathstart g \<in> {a..b}"
   5.361 +      moreover have "pathstart g \<in> cbox a b"
   5.362          using assms(4) pathstart_in_path_image[of g]
   5.363          by auto 
   5.364        note this[unfolded mem_interval_cart forall_2]
   5.365 @@ -816,7 +817,7 @@
   5.366      qed
   5.367      then have "z \<in> path_image f \<or> z \<in> path_image g"
   5.368        using z unfolding Un_iff by blast
   5.369 -    then have z': "z \<in> {a..b}"
   5.370 +    then have z': "z \<in> cbox a b"
   5.371        using assms(3-4)
   5.372        by auto
   5.373      have "a $ 2 = z $ 2 \<Longrightarrow> (z $ 1 = pathstart f $ 1 \<or> z $ 1 = pathfinish f $ 1) \<Longrightarrow>
     6.1 --- a/src/HOL/Multivariate_Analysis/Integration.thy	Mon Mar 17 21:56:32 2014 +0100
     6.2 +++ b/src/HOL/Multivariate_Analysis/Integration.thy	Tue Mar 18 10:12:57 2014 +0100
     6.3 @@ -219,26 +219,27 @@
     6.4  abbreviation One :: "'a::euclidean_space"
     6.5    where "One \<equiv> \<Sum>Basis"
     6.6  
     6.7 -lemma empty_as_interval: "{} = {One..(0::'a::ordered_euclidean_space)}"
     6.8 -  by (auto simp: eucl_le[where 'a='a])
     6.9 +lemma empty_as_interval: "{} = cbox One (0::'a::euclidean_space)"
    6.10 +  using nonempty_Basis
    6.11 +  by (fastforce simp add: set_eq_iff mem_box)
    6.12  
    6.13  lemma One_nonneg: "0 \<le> (One::'a::ordered_euclidean_space)"
    6.14    by (auto intro: setsum_nonneg)
    6.15  
    6.16  lemma interior_subset_union_intervals:
    6.17 -  assumes "i = {a..b::'a::ordered_euclidean_space}"
    6.18 -    and "j = {c..d}"
    6.19 +  assumes "i = cbox a b"
    6.20 +    and "j = cbox c d"
    6.21      and "interior j \<noteq> {}"
    6.22      and "i \<subseteq> j \<union> s"
    6.23      and "interior i \<inter> interior j = {}"
    6.24    shows "interior i \<subseteq> interior s"
    6.25  proof -
    6.26 -  have "box a b \<inter> {c..d} = {}"
    6.27 -    using inter_interval_mixed_eq_empty[of c d a b] and assms(3,5)
    6.28 -    unfolding assms(1,2) interior_closed_interval by auto
    6.29 +  have "box a b \<inter> cbox c d = {}"
    6.30 +     using inter_interval_mixed_eq_empty[of c d a b] and assms(3,5)
    6.31 +     unfolding assms(1,2) interior_cbox by auto
    6.32    moreover
    6.33 -  have "box a b \<subseteq> {c..d} \<union> s"
    6.34 -    apply (rule order_trans,rule interval_open_subset_closed)
    6.35 +  have "box a b \<subseteq> cbox c d \<union> s"
    6.36 +    apply (rule order_trans,rule box_subset_cbox)
    6.37      using assms(4) unfolding assms(1,2)
    6.38      apply auto
    6.39      done
    6.40 @@ -248,16 +249,16 @@
    6.41      apply (rule interior_maximal)
    6.42      defer
    6.43      apply (rule open_interior)
    6.44 -    unfolding assms(1,2) interior_closed_interval
    6.45 +    unfolding assms(1,2) interior_cbox
    6.46      apply auto
    6.47      done
    6.48  qed
    6.49  
    6.50  lemma inter_interior_unions_intervals:
    6.51 -  fixes f::"('a::ordered_euclidean_space) set set"
    6.52 +  fixes f::"('a::euclidean_space) set set"
    6.53    assumes "finite f"
    6.54      and "open s"
    6.55 -    and "\<forall>t\<in>f. \<exists>a b. t = {a..b}"
    6.56 +    and "\<forall>t\<in>f. \<exists>a b. t = cbox a b"
    6.57      and "\<forall>t\<in>f. s \<inter> (interior t) = {}"
    6.58    shows "s \<inter> interior (\<Union>f) = {}"
    6.59  proof (rule ccontr, unfold ex_in_conv[symmetric])
    6.60 @@ -271,7 +272,7 @@
    6.61      apply auto
    6.62      done
    6.63    have lem2: "\<And>x s P. \<exists>x\<in>s. P x \<Longrightarrow> \<exists>x\<in>insert x s. P x" by auto
    6.64 -  have "\<And>f. finite f \<Longrightarrow> \<forall>t\<in>f. \<exists>a b. t = {a..b} \<Longrightarrow>
    6.65 +  have "\<And>f. finite f \<Longrightarrow> \<forall>t\<in>f. \<exists>a b. t = cbox a b \<Longrightarrow>
    6.66      \<exists>x. x \<in> s \<inter> interior (\<Union>f) \<Longrightarrow> \<exists>t\<in>f. \<exists>x. \<exists>e>0. ball x e \<subseteq> s \<inter> t"
    6.67    proof -
    6.68      case goal1
    6.69 @@ -289,16 +290,16 @@
    6.70          using insert(5) ..
    6.71        then obtain e where e: "0 < e \<and> ball x e \<subseteq> s \<inter> interior (\<Union>insert i f)"
    6.72          unfolding open_contains_ball_eq[OF open_Int[OF assms(2) open_interior], rule_format] ..
    6.73 -      obtain a where "\<exists>b. i = {a..b}"
    6.74 +      obtain a where "\<exists>b. i = cbox a b"
    6.75          using insert(4)[rule_format,OF insertI1] ..
    6.76 -      then obtain b where ab: "i = {a..b}" ..
    6.77 +      then obtain b where ab: "i = cbox a b" ..
    6.78        show ?case
    6.79        proof (cases "x \<in> i")
    6.80          case False
    6.81 -        then have "x \<in> UNIV - {a..b}"
    6.82 +        then have "x \<in> UNIV - cbox a b"
    6.83            unfolding ab by auto
    6.84 -        then obtain d where "0 < d \<and> ball x d \<subseteq> UNIV - {a..b}"
    6.85 -          unfolding open_contains_ball_eq[OF open_Diff[OF open_UNIV closed_interval],rule_format] ..
    6.86 +        then obtain d where "0 < d \<and> ball x d \<subseteq> UNIV - cbox a b"
    6.87 +          unfolding open_contains_ball_eq[OF open_Diff[OF open_UNIV closed_cbox],rule_format] ..
    6.88          then have "0 < d" "ball x (min d e) \<subseteq> UNIV - i"
    6.89            unfolding ab ball_min_Int by auto
    6.90          then have "ball x (min d e) \<subseteq> s \<inter> interior (\<Union>f)"
    6.91 @@ -316,19 +317,19 @@
    6.92          proof (cases "x\<in>box a b")
    6.93            case True
    6.94            then obtain d where "0 < d \<and> ball x d \<subseteq> box a b"
    6.95 -            unfolding open_contains_ball_eq[OF open_interval,rule_format] ..
    6.96 +            unfolding open_contains_ball_eq[OF open_box,rule_format] ..
    6.97            then show ?thesis
    6.98              apply (rule_tac x=i in bexI, rule_tac x=x in exI, rule_tac x="min d e" in exI)
    6.99              unfolding ab
   6.100 -            using interval_open_subset_closed[of a b] and e
   6.101 +            using box_subset_cbox[of a b] and e
   6.102              apply fastforce+
   6.103              done
   6.104          next
   6.105            case False
   6.106            then obtain k where "x\<bullet>k \<le> a\<bullet>k \<or> x\<bullet>k \<ge> b\<bullet>k" and k: "k \<in> Basis"
   6.107 -            unfolding mem_interval by (auto simp add: not_less)
   6.108 +            unfolding mem_box by (auto simp add: not_less)
   6.109            then have "x\<bullet>k = a\<bullet>k \<or> x\<bullet>k = b\<bullet>k"
   6.110 -            using True unfolding ab and mem_interval
   6.111 +            using True unfolding ab and mem_box
   6.112                apply (erule_tac x = k in ballE)
   6.113                apply auto
   6.114                done
   6.115 @@ -350,7 +351,7 @@
   6.116                  using e[THEN conjunct1] k
   6.117                  by (auto simp add: field_simps abs_less_iff as inner_Basis inner_simps)
   6.118                then have "y \<notin> i"
   6.119 -                unfolding ab mem_interval by (auto intro!: bexI[OF _ k])
   6.120 +                unfolding ab mem_box by (auto intro!: bexI[OF _ k])
   6.121                then show False using yi by auto
   6.122              qed
   6.123              moreover
   6.124 @@ -399,7 +400,7 @@
   6.125                  using e[THEN conjunct1] k
   6.126                  by (auto simp add:field_simps inner_simps inner_Basis as)
   6.127                then have "y \<notin> i"
   6.128 -                unfolding ab mem_interval by (auto intro!: bexI[OF _ k])
   6.129 +                unfolding ab mem_box by (auto intro!: bexI[OF _ k])
   6.130                then show False using yi by auto
   6.131              qed
   6.132              moreover
   6.133 @@ -452,94 +453,141 @@
   6.134      using `t \<in> f` assms(4) by auto
   6.135  qed
   6.136  
   6.137 -lemma interval_bounds:
   6.138 -  fixes a b::"'a::ordered_euclidean_space"
   6.139 -  shows "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow> Inf {a..b} = a" "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow> Sup {a..b} = b"
   6.140 -  by (auto simp: eucl_le[where 'a='a])
   6.141 -
   6.142 -lemma interval_bounds':
   6.143 -  fixes a b::"'a::ordered_euclidean_space"
   6.144 -  assumes "{a..b} \<noteq> {}"
   6.145 -  shows "Sup {a..b} = b"
   6.146 -    and "Inf {a..b} = a"
   6.147 -  using assms
   6.148 -  by (auto simp: eucl_le[where 'a='a])
   6.149 +subsection {* Bounds on intervals where they exist. *}
   6.150 +
   6.151 +definition interval_upperbound :: "('a::euclidean_space) set \<Rightarrow> 'a"
   6.152 +  where "interval_upperbound s = (\<Sum>i\<in>Basis. (SUP x:s. x\<bullet>i) *\<^sub>R i)"
   6.153 +
   6.154 +definition interval_lowerbound :: "('a::euclidean_space) set \<Rightarrow> 'a"
   6.155 +   where "interval_lowerbound s = (\<Sum>i\<in>Basis. (INF x:s. x\<bullet>i) *\<^sub>R i)"
   6.156 +
   6.157 +lemma interval_upperbound[simp]:
   6.158 +  "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow>
   6.159 +    interval_upperbound (cbox a b) = (b::'a::euclidean_space)"
   6.160 +  unfolding interval_upperbound_def euclidean_representation_setsum cbox_def SUP_def
   6.161 +  by (safe intro!: cSup_eq) auto
   6.162 +
   6.163 +lemma interval_lowerbound[simp]:
   6.164 +  "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow>
   6.165 +    interval_lowerbound (cbox a b) = (a::'a::euclidean_space)"
   6.166 +  unfolding interval_lowerbound_def euclidean_representation_setsum cbox_def INF_def
   6.167 +  by (safe intro!: cInf_eq) auto
   6.168 +
   6.169 +lemmas interval_bounds = interval_upperbound interval_lowerbound
   6.170 +
   6.171 +lemma
   6.172 +  fixes X::"real set"
   6.173 +  shows interval_upperbound_real[simp]: "interval_upperbound X = Sup X"
   6.174 +    and interval_lowerbound_real[simp]: "interval_lowerbound X = Inf X"
   6.175 +  by (auto simp: interval_upperbound_def interval_lowerbound_def SUP_def INF_def)
   6.176 +
   6.177 +lemma interval_bounds'[simp]:
   6.178 +  assumes "cbox a b \<noteq> {}"
   6.179 +  shows "interval_upperbound (cbox a b) = b"
   6.180 +    and "interval_lowerbound (cbox a b) = a"
   6.181 +  using assms unfolding box_ne_empty by auto
   6.182  
   6.183  subsection {* Content (length, area, volume...) of an interval. *}
   6.184  
   6.185 -definition "content (s::('a::ordered_euclidean_space) set) =
   6.186 -  (if s = {} then 0 else (\<Prod>i\<in>Basis. (Sup s)\<bullet>i - (Inf s)\<bullet>i))"
   6.187 -
   6.188 -lemma interval_not_empty: "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow> {a..b::'a::ordered_euclidean_space} \<noteq> {}"
   6.189 -  unfolding interval_eq_empty unfolding not_ex not_less by auto
   6.190 -
   6.191 -lemma content_closed_interval:
   6.192 -  fixes a :: "'a::ordered_euclidean_space"
   6.193 +definition "content (s::('a::euclidean_space) set) =
   6.194 +  (if s = {} then 0 else (\<Prod>i\<in>Basis. (interval_upperbound s)\<bullet>i - (interval_lowerbound s)\<bullet>i))"
   6.195 +
   6.196 +lemma interval_not_empty: "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow> cbox a b \<noteq> {}"
   6.197 +  unfolding box_eq_empty unfolding not_ex not_less by auto
   6.198 +
   6.199 +lemma content_cbox:
   6.200 +  fixes a :: "'a::euclidean_space"
   6.201    assumes "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i"
   6.202 -  shows "content {a..b} = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
   6.203 +  shows "content (cbox a b) = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
   6.204    using interval_not_empty[OF assms]
   6.205    unfolding content_def
   6.206 -  by auto
   6.207 -
   6.208 -lemma content_closed_interval':
   6.209 -  fixes a :: "'a::ordered_euclidean_space"
   6.210 -  assumes "{a..b} \<noteq> {}"
   6.211 -  shows "content {a..b} = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
   6.212 -  apply (rule content_closed_interval)
   6.213 +  by (auto simp: )
   6.214 +
   6.215 +lemma content_cbox':
   6.216 +  fixes a :: "'a::euclidean_space"
   6.217 +  assumes "cbox a b \<noteq> {}"
   6.218 +  shows "content (cbox a b) = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
   6.219 +  apply (rule content_cbox)
   6.220    using assms
   6.221 -  unfolding interval_ne_empty
   6.222 +  unfolding box_ne_empty
   6.223    apply assumption
   6.224    done
   6.225  
   6.226  lemma content_real: "a \<le> b \<Longrightarrow> content {a..b} = b - a"
   6.227 -  unfolding content_def by auto
   6.228 +  by (auto simp: interval_upperbound_def interval_lowerbound_def SUP_def INF_def content_def)
   6.229 +
   6.230 +lemma content_closed_interval:
   6.231 +  fixes a :: "'a::ordered_euclidean_space"
   6.232 +  assumes "a \<le> b"
   6.233 +  shows "content {a .. b} = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
   6.234 +  using content_cbox[of a b] assms
   6.235 +  by (simp add: cbox_interval eucl_le[where 'a='a])
   6.236  
   6.237  lemma content_singleton[simp]: "content {a} = 0"
   6.238  proof -
   6.239 -  have "content {a .. a} = 0"
   6.240 -    by (subst content_closed_interval) (auto simp: ex_in_conv)
   6.241 -  then show ?thesis by simp
   6.242 -qed
   6.243 -
   6.244 -lemma content_unit[intro]: "content{0..One::'a::ordered_euclidean_space} = 1"
   6.245 -  by (auto simp: content_def eucl_le[where 'a='a])
   6.246 +  have "content (cbox a a) = 0"
   6.247 +    by (subst content_cbox) (auto simp: ex_in_conv)
   6.248 +  then show ?thesis by (simp add: cbox_sing)
   6.249 +qed
   6.250 +
   6.251 +lemma content_unit[intro]: "content(cbox 0 (One::'a::euclidean_space)) = 1"
   6.252 + proof -
   6.253 +   have *: "\<forall>i\<in>Basis. (0::'a)\<bullet>i \<le> (One::'a)\<bullet>i"
   6.254 +    by auto
   6.255 +  have "0 \<in> cbox 0 (One::'a)"
   6.256 +    unfolding mem_box by auto
   6.257 +  then show ?thesis
   6.258 +     unfolding content_def interval_bounds[OF *] using setprod_1 by auto
   6.259 + qed
   6.260  
   6.261  lemma content_pos_le[intro]:
   6.262 -  fixes a::"'a::ordered_euclidean_space"
   6.263 -  shows "0 \<le> content {a..b}"
   6.264 -  by (auto simp: content_def eucl_le[where 'a='a] intro!: setprod_nonneg)
   6.265 +  fixes a::"'a::euclidean_space"
   6.266 +  shows "0 \<le> content (cbox a b)"
   6.267 +proof (cases "cbox a b = {}")
   6.268 +  case False
   6.269 +  then have *: "\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i"
   6.270 +    unfolding box_ne_empty .
   6.271 +  have "0 \<le> (\<Prod>i\<in>Basis. interval_upperbound (cbox a b) \<bullet> i - interval_lowerbound (cbox a b) \<bullet> i)"
   6.272 +    apply (rule setprod_nonneg)
   6.273 +    unfolding interval_bounds[OF *]
   6.274 +    using *
   6.275 +    apply auto
   6.276 +    done
   6.277 +  also have "\<dots> = content (cbox a b)" using False by (simp add: content_def)
   6.278 +  finally show ?thesis .
   6.279 +qed (simp add: content_def)
   6.280  
   6.281  lemma content_pos_lt:
   6.282 -  fixes a :: "'a::ordered_euclidean_space"
   6.283 +  fixes a :: "'a::euclidean_space"
   6.284    assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
   6.285 -  shows "0 < content {a..b}"
   6.286 +  shows "0 < content (cbox a b)"
   6.287    using assms
   6.288 -  by (auto simp: content_def eucl_le[where 'a='a] intro!: setprod_pos)
   6.289 +  by (auto simp: content_def box_eq_empty intro!: setprod_pos)
   6.290  
   6.291  lemma content_eq_0:
   6.292 -  "content{a..b::'a::ordered_euclidean_space} = 0 \<longleftrightarrow> (\<exists>i\<in>Basis. b\<bullet>i \<le> a\<bullet>i)"
   6.293 -  by (auto intro!: bexI simp: content_def eucl_le[where 'a='a])
   6.294 +  "content (cbox a b) = 0 \<longleftrightarrow> (\<exists>i\<in>Basis. b\<bullet>i \<le> a\<bullet>i)"
   6.295 +  by (auto simp: content_def box_eq_empty intro!: setprod_pos bexI)
   6.296  
   6.297  lemma cond_cases: "(P \<Longrightarrow> Q x) \<Longrightarrow> (\<not> P \<Longrightarrow> Q y) \<Longrightarrow> Q (if P then x else y)"
   6.298    by auto
   6.299  
   6.300 -lemma content_closed_interval_cases:
   6.301 -  "content {a..b::'a::ordered_euclidean_space} =
   6.302 +lemma content_cbox_cases:
   6.303 +  "content (cbox a (b::'a::euclidean_space)) =
   6.304      (if \<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i then setprod (\<lambda>i. b\<bullet>i - a\<bullet>i) Basis else 0)"
   6.305 -  by (auto simp: not_le content_eq_0 intro: less_imp_le content_closed_interval)
   6.306 -
   6.307 -lemma content_eq_0_interior: "content {a..b} = 0 \<longleftrightarrow> interior({a..b}) = {}"
   6.308 -  unfolding content_eq_0 interior_closed_interval interval_eq_empty
   6.309 +  by (auto simp: not_le content_eq_0 intro: less_imp_le content_cbox)
   6.310 +
   6.311 +lemma content_eq_0_interior: "content (cbox a b) = 0 \<longleftrightarrow> interior(cbox a b) = {}"
   6.312 +  unfolding content_eq_0 interior_cbox box_eq_empty
   6.313    by auto
   6.314  
   6.315  lemma content_pos_lt_eq:
   6.316 -  "0 < content {a..b::'a::ordered_euclidean_space} \<longleftrightarrow> (\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i)"
   6.317 +  "0 < content (cbox a (b::'a::euclidean_space)) \<longleftrightarrow> (\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i)"
   6.318    apply rule
   6.319    defer
   6.320    apply (rule content_pos_lt, assumption)
   6.321  proof -
   6.322 -  assume "0 < content {a..b}"
   6.323 -  then have "content {a..b} \<noteq> 0" by auto
   6.324 +  assume "0 < content (cbox a b)"
   6.325 +  then have "content (cbox a b) \<noteq> 0" by auto
   6.326    then show "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
   6.327      unfolding content_eq_0 not_ex not_le by fastforce
   6.328  qed
   6.329 @@ -548,17 +596,40 @@
   6.330    unfolding content_def by auto
   6.331  
   6.332  lemma content_subset:
   6.333 -  assumes "{a..b} \<subseteq> {c..d}"
   6.334 -  shows "content {a..b::'a::ordered_euclidean_space} \<le> content {c..d}"
   6.335 -proof cases
   6.336 -  assume "{a..b} \<noteq> {}"
   6.337 -  with assms have "c \<le> a" "a \<le> b" "b \<le> d" "b + c \<le> d + a" by (auto intro: add_mono)
   6.338 -  hence "b - a \<le> d - c" "c \<le> d" by (auto simp add: algebra_simps)
   6.339 -  thus ?thesis
   6.340 -    by (auto simp: content_def eucl_le[where 'a='a] inner_diff_left intro!: setprod_nonneg setprod_mono)
   6.341 -qed auto
   6.342 -
   6.343 -lemma content_lt_nz: "0 < content {a..b} \<longleftrightarrow> content {a..b} \<noteq> 0"
   6.344 +  assumes "cbox a b \<subseteq> cbox c d"
   6.345 +  shows "content (cbox a b) \<le> content (cbox c d)"
   6.346 +proof (cases "cbox a b = {}")
   6.347 +  case True
   6.348 +  then show ?thesis
   6.349 +    using content_pos_le[of c d] by auto
   6.350 +next
   6.351 +  case False
   6.352 +  then have ab_ne: "\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i"
   6.353 +    unfolding box_ne_empty by auto
   6.354 +  then have ab_ab: "a\<in>cbox a b" "b\<in>cbox a b"
   6.355 +    unfolding mem_box by auto
   6.356 +  have "cbox c d \<noteq> {}" using assms False by auto
   6.357 +  then have cd_ne: "\<forall>i\<in>Basis. c \<bullet> i \<le> d \<bullet> i"
   6.358 +    using assms unfolding box_ne_empty by auto
   6.359 +  show ?thesis
   6.360 +    unfolding content_def
   6.361 +    unfolding interval_bounds[OF ab_ne] interval_bounds[OF cd_ne]
   6.362 +    unfolding if_not_P[OF False] if_not_P[OF `cbox c d \<noteq> {}`]
   6.363 +    apply (rule setprod_mono)
   6.364 +    apply rule
   6.365 +  proof
   6.366 +    fix i :: 'a
   6.367 +    assume i: "i \<in> Basis"
   6.368 +    show "0 \<le> b \<bullet> i - a \<bullet> i"
   6.369 +      using ab_ne[THEN bspec, OF i] i by auto
   6.370 +    show "b \<bullet> i - a \<bullet> i \<le> d \<bullet> i - c \<bullet> i"
   6.371 +      using assms[unfolded subset_eq mem_box,rule_format,OF ab_ab(2),of i]
   6.372 +      using assms[unfolded subset_eq mem_box,rule_format,OF ab_ab(1),of i]
   6.373 +      using i by auto
   6.374 +  qed
   6.375 +qed
   6.376 +
   6.377 +lemma content_lt_nz: "0 < content (cbox a b) \<longleftrightarrow> content (cbox a b) \<noteq> 0"
   6.378    unfolding content_pos_lt_eq content_eq_0 unfolding not_ex not_le by fastforce
   6.379  
   6.380  
   6.381 @@ -613,7 +684,7 @@
   6.382  where
   6.383    "s division_of i \<longleftrightarrow>
   6.384      finite s \<and>
   6.385 -    (\<forall>k\<in>s. k \<subseteq> i \<and> k \<noteq> {} \<and> (\<exists>a b. k = {a..b})) \<and>
   6.386 +    (\<forall>k\<in>s. k \<subseteq> i \<and> k \<noteq> {} \<and> (\<exists>a b. k = cbox a b)) \<and>
   6.387      (\<forall>k1\<in>s. \<forall>k2\<in>s. k1 \<noteq> k2 \<longrightarrow> interior(k1) \<inter> interior(k2) = {}) \<and>
   6.388      (\<Union>s = i)"
   6.389  
   6.390 @@ -622,7 +693,7 @@
   6.391    shows "finite s"
   6.392      and "\<And>k. k \<in> s \<Longrightarrow> k \<subseteq> i"
   6.393      and "\<And>k. k \<in> s \<Longrightarrow> k \<noteq> {}"
   6.394 -    and "\<And>k. k \<in> s \<Longrightarrow> \<exists>a b. k = {a..b}"
   6.395 +    and "\<And>k. k \<in> s \<Longrightarrow> \<exists>a b. k = cbox a b"
   6.396      and "\<And>k1 k2. k1 \<in> s \<Longrightarrow> k2 \<in> s \<Longrightarrow> k1 \<noteq> k2 \<Longrightarrow> interior(k1) \<inter> interior(k2) = {}"
   6.397      and "\<Union>s = i"
   6.398    using assms unfolding division_of_def by auto
   6.399 @@ -631,7 +702,7 @@
   6.400    assumes "finite s"
   6.401      and "\<And>k. k \<in> s \<Longrightarrow> k \<subseteq> i"
   6.402      and "\<And>k. k \<in> s \<Longrightarrow> k \<noteq> {}"
   6.403 -    and "\<And>k. k \<in> s \<Longrightarrow> \<exists>a b. k = {a..b}"
   6.404 +    and "\<And>k. k \<in> s \<Longrightarrow> \<exists>a b. k = cbox a b"
   6.405      and "\<And>k1 k2. k1 \<in> s \<Longrightarrow> k2 \<in> s \<Longrightarrow> k1 \<noteq> k2 \<Longrightarrow> interior k1 \<inter> interior k2 = {}"
   6.406      and "\<Union>s = i"
   6.407    shows "s division_of i"
   6.408 @@ -640,14 +711,14 @@
   6.409  lemma division_of_finite: "s division_of i \<Longrightarrow> finite s"
   6.410    unfolding division_of_def by auto
   6.411  
   6.412 -lemma division_of_self[intro]: "{a..b} \<noteq> {} \<Longrightarrow> {{a..b}} division_of {a..b}"
   6.413 +lemma division_of_self[intro]: "cbox a b \<noteq> {} \<Longrightarrow> {cbox a b} division_of (cbox a b)"
   6.414    unfolding division_of_def by auto
   6.415  
   6.416  lemma division_of_trivial[simp]: "s division_of {} \<longleftrightarrow> s = {}"
   6.417    unfolding division_of_def by auto
   6.418  
   6.419  lemma division_of_sing[simp]:
   6.420 -  "s division_of {a..a::'a::ordered_euclidean_space} \<longleftrightarrow> s = {{a..a}}"
   6.421 +  "s division_of cbox a (a::'a::euclidean_space) \<longleftrightarrow> s = {cbox a a}"
   6.422    (is "?l = ?r")
   6.423  proof
   6.424    assume ?r
   6.425 @@ -655,17 +726,17 @@
   6.426    {
   6.427      assume "s = {{a}}"
   6.428      moreover fix k assume "k\<in>s"
   6.429 -    ultimately have"\<exists>x y. k = {x..y}"
   6.430 +    ultimately have"\<exists>x y. k = cbox x y"
   6.431        apply (rule_tac x=a in exI)+
   6.432 -      unfolding interval_sing
   6.433 +      unfolding cbox_sing
   6.434        apply auto
   6.435        done
   6.436    }
   6.437    ultimately show ?l
   6.438 -    unfolding division_of_def interval_sing by auto
   6.439 +    unfolding division_of_def cbox_sing by auto
   6.440  next
   6.441    assume ?l
   6.442 -  note * = conjunctD4[OF this[unfolded division_of_def interval_sing]]
   6.443 +  note * = conjunctD4[OF this[unfolded division_of_def cbox_sing]]
   6.444    {
   6.445      fix x
   6.446      assume x: "x \<in> s" have "x = {a}"
   6.447 @@ -674,20 +745,20 @@
   6.448    moreover have "s \<noteq> {}"
   6.449      using *(4) by auto
   6.450    ultimately show ?r
   6.451 -    unfolding interval_sing by auto
   6.452 +    unfolding cbox_sing by auto
   6.453  qed
   6.454  
   6.455  lemma elementary_empty: obtains p where "p division_of {}"
   6.456    unfolding division_of_trivial by auto
   6.457  
   6.458 -lemma elementary_interval: obtains p where "p division_of {a..b}"
   6.459 +lemma elementary_interval: obtains p where "p division_of (cbox a b)"
   6.460    by (metis division_of_trivial division_of_self)
   6.461  
   6.462  lemma division_contains: "s division_of i \<Longrightarrow> \<forall>x\<in>i. \<exists>k\<in>s. x \<in> k"
   6.463    unfolding division_of_def by auto
   6.464  
   6.465  lemma forall_in_division:
   6.466 -  "d division_of i \<Longrightarrow> (\<forall>x\<in>d. P x) \<longleftrightarrow> (\<forall>a b. {a..b} \<in> d \<longrightarrow> P {a..b})"
   6.467 +  "d division_of i \<Longrightarrow> (\<forall>x\<in>d. P x) \<longleftrightarrow> (\<forall>a b. cbox a b \<in> d \<longrightarrow> P (cbox a b))"
   6.468    unfolding division_of_def by fastforce
   6.469  
   6.470  lemma division_of_subset:
   6.471 @@ -708,7 +779,7 @@
   6.472        using assms(2) by auto
   6.473      show "k \<subseteq> \<Union>q"
   6.474        using `k \<in> q` by auto
   6.475 -    show "\<exists>a b. k = {a..b}"
   6.476 +    show "\<exists>a b. k = cbox a b"
   6.477        using *(4)[OF kp] by auto
   6.478      show "k \<noteq> {}"
   6.479        using *(3)[OF kp] by auto
   6.480 @@ -725,7 +796,7 @@
   6.481    unfolding division_of_def by auto
   6.482  
   6.483  lemma division_of_content_0:
   6.484 -  assumes "content {a..b} = 0" "d division_of {a..b}"
   6.485 +  assumes "content (cbox a b) = 0" "d division_of (cbox a b)"
   6.486    shows "\<forall>k\<in>d. content k = 0"
   6.487    unfolding forall_in_division[OF assms(2)]
   6.488    apply (rule,rule,rule)
   6.489 @@ -737,7 +808,7 @@
   6.490  qed
   6.491  
   6.492  lemma division_inter:
   6.493 -  fixes s1 s2 :: "'a::ordered_euclidean_space set"
   6.494 +  fixes s1 s2 :: "'a::euclidean_space set"
   6.495    assumes "p1 division_of s1"
   6.496      and "p2 division_of s2"
   6.497    shows "{k1 \<inter> k2 | k1 k2 .k1 \<in> p1 \<and> k2 \<in> p2 \<and> k1 \<inter> k2 \<noteq> {}} division_of (s1 \<inter> s2)"
   6.498 @@ -771,11 +842,11 @@
   6.499        show "k \<subseteq> s1 \<inter> s2"
   6.500          using division_ofD(2)[OF assms(1) k(2)] and division_ofD(2)[OF assms(2) k(3)]
   6.501          unfolding k by auto
   6.502 -      obtain a1 b1 where k1: "k1 = {a1..b1}"
   6.503 +      obtain a1 b1 where k1: "k1 = cbox a1 b1"
   6.504          using division_ofD(4)[OF assms(1) k(2)] by blast
   6.505 -      obtain a2 b2 where k2: "k2 = {a2..b2}"
   6.506 +      obtain a2 b2 where k2: "k2 = cbox a2 b2"
   6.507          using division_ofD(4)[OF assms(2) k(3)] by blast
   6.508 -      show "\<exists>a b. k = {a..b}"
   6.509 +      show "\<exists>a b. k = cbox a b"
   6.510          unfolding k k1 k2 unfolding inter_interval by auto
   6.511      }
   6.512      fix k1 k2
   6.513 @@ -807,22 +878,22 @@
   6.514  
   6.515  lemma division_inter_1:
   6.516    assumes "d division_of i"
   6.517 -    and "{a..b::'a::ordered_euclidean_space} \<subseteq> i"
   6.518 -  shows "{{a..b} \<inter> k | k. k \<in> d \<and> {a..b} \<inter> k \<noteq> {}} division_of {a..b}"
   6.519 -proof (cases "{a..b} = {}")
   6.520 +    and "cbox a (b::'a::euclidean_space) \<subseteq> i"
   6.521 +  shows "{cbox a b \<inter> k | k. k \<in> d \<and> cbox a b \<inter> k \<noteq> {}} division_of (cbox a b)"
   6.522 +proof (cases "cbox a b = {}")
   6.523    case True
   6.524    show ?thesis
   6.525      unfolding True and division_of_trivial by auto
   6.526  next
   6.527    case False
   6.528 -  have *: "{a..b} \<inter> i = {a..b}" using assms(2) by auto
   6.529 +  have *: "cbox a b \<inter> i = cbox a b" using assms(2) by auto
   6.530    show ?thesis
   6.531      using division_inter[OF division_of_self[OF False] assms(1)]
   6.532      unfolding * by auto
   6.533  qed
   6.534  
   6.535  lemma elementary_inter:
   6.536 -  fixes s t :: "'a::ordered_euclidean_space set"
   6.537 +  fixes s t :: "'a::euclidean_space set"
   6.538    assumes "p1 division_of s"
   6.539      and "p2 division_of t"
   6.540    shows "\<exists>p. p division_of (s \<inter> t)"
   6.541 @@ -833,7 +904,7 @@
   6.542  lemma elementary_inters:
   6.543    assumes "finite f"
   6.544      and "f \<noteq> {}"
   6.545 -    and "\<forall>s\<in>f. \<exists>p. p division_of (s::('a::ordered_euclidean_space) set)"
   6.546 +    and "\<forall>s\<in>f. \<exists>p. p division_of (s::('a::euclidean_space) set)"
   6.547    shows "\<exists>p. p division_of (\<Inter> f)"
   6.548    using assms
   6.549  proof (induct f rule: finite_induct)
   6.550 @@ -898,33 +969,32 @@
   6.551      using k d1(2) d2(2) by auto
   6.552    show "k \<noteq> {}"
   6.553      using k d1(3) d2(3) by auto
   6.554 -  show "\<exists>a b. k = {a..b}"
   6.555 +  show "\<exists>a b. k = cbox a b"
   6.556      using k d1(4) d2(4) by auto
   6.557  qed
   6.558  
   6.559  lemma partial_division_extend_1:
   6.560 -  fixes a b c d :: "'a::ordered_euclidean_space"
   6.561 -  assumes incl: "{c..d} \<subseteq> {a..b}"
   6.562 -    and nonempty: "{c..d} \<noteq> {}"
   6.563 -  obtains p where "p division_of {a..b}" "{c..d} \<in> p"
   6.564 +  fixes a b c d :: "'a::euclidean_space"
   6.565 +  assumes incl: "cbox c d \<subseteq> cbox a b"
   6.566 +    and nonempty: "cbox c d \<noteq> {}"
   6.567 +  obtains p where "p division_of (cbox a b)" "cbox c d \<in> p"
   6.568  proof
   6.569    let ?B = "\<lambda>f::'a\<Rightarrow>'a \<times> 'a.
   6.570 -    {(\<Sum>i\<in>Basis. (fst (f i) \<bullet> i) *\<^sub>R i) .. (\<Sum>i\<in>Basis. (snd (f i) \<bullet> i) *\<^sub>R i)}"
   6.571 +    cbox (\<Sum>i\<in>Basis. (fst (f i) \<bullet> i) *\<^sub>R i) (\<Sum>i\<in>Basis. (snd (f i) \<bullet> i) *\<^sub>R i)"
   6.572    def p \<equiv> "?B ` (Basis \<rightarrow>\<^sub>E {(a, c), (c, d), (d, b)})"
   6.573  
   6.574 -  show "{c .. d} \<in> p"
   6.575 +  show "cbox c d \<in> p"
   6.576      unfolding p_def
   6.577 -    by (auto simp add: interval_eq_empty eucl_le[where 'a='a]
   6.578 -        intro!: image_eqI[where x="\<lambda>(i::'a)\<in>Basis. (c, d)"])
   6.579 +    by (auto simp add: box_eq_empty cbox_def intro!: image_eqI[where x="\<lambda>(i::'a)\<in>Basis. (c, d)"])
   6.580    {
   6.581      fix i :: 'a
   6.582      assume "i \<in> Basis"
   6.583      with incl nonempty have "a \<bullet> i \<le> c \<bullet> i" "c \<bullet> i \<le> d \<bullet> i" "d \<bullet> i \<le> b \<bullet> i"
   6.584 -      unfolding interval_eq_empty subset_interval by (auto simp: not_le)
   6.585 +      unfolding box_eq_empty subset_box by (auto simp: not_le)
   6.586    }
   6.587    note ord = this
   6.588  
   6.589 -  show "p division_of {a..b}"
   6.590 +  show "p division_of (cbox a b)"
   6.591    proof (rule division_ofI)
   6.592      show "finite p"
   6.593        unfolding p_def by (auto intro!: finite_PiE)
   6.594 @@ -933,10 +1003,10 @@
   6.595        assume "k \<in> p"
   6.596        then obtain f where f: "f \<in> Basis \<rightarrow>\<^sub>E {(a, c), (c, d), (d, b)}" and k: "k = ?B f"
   6.597          by (auto simp: p_def)
   6.598 -      then show "\<exists>a b. k = {a..b}"
   6.599 +      then show "\<exists>a b. k = cbox a b"
   6.600          by auto
   6.601 -      have "k \<subseteq> {a..b} \<and> k \<noteq> {}"
   6.602 -      proof (simp add: k interval_eq_empty subset_interval not_less eucl_le[where 'a='a], safe)
   6.603 +      have "k \<subseteq> cbox a b \<and> k \<noteq> {}"
   6.604 +      proof (simp add: k box_eq_empty subset_box not_less, safe)
   6.605          fix i :: 'a
   6.606          assume i: "i \<in> Basis"
   6.607          with f have "f i = (a, c) \<or> f i = (c, d) \<or> f i = (d, b)"
   6.608 @@ -945,7 +1015,7 @@
   6.609          show "a \<bullet> i \<le> fst (f i) \<bullet> i" "snd (f i) \<bullet> i \<le> b \<bullet> i" "fst (f i) \<bullet> i \<le> snd (f i) \<bullet> i"
   6.610            by auto
   6.611        qed
   6.612 -      then show "k \<noteq> {}" "k \<subseteq> {a .. b}"
   6.613 +      then show "k \<noteq> {}" "k \<subseteq> cbox a b"
   6.614          by auto
   6.615        {
   6.616          fix l
   6.617 @@ -966,13 +1036,13 @@
   6.618              "g i = (a, c) \<or> g i = (c, d) \<or> g i = (d, b)"
   6.619            using f g by (auto simp: PiE_iff)
   6.620          with * ord[of i] show "interior l \<inter> interior k = {}"
   6.621 -          by (auto simp add: l k interior_closed_interval disjoint_interval intro!: bexI[of _ i])
   6.622 +          by (auto simp add: l k interior_cbox disjoint_interval intro!: bexI[of _ i])
   6.623        }
   6.624 -      note `k \<subseteq> {a.. b}`
   6.625 +      note `k \<subseteq> cbox a b`
   6.626      }
   6.627      moreover
   6.628      {
   6.629 -      fix x assume x: "x \<in> {a .. b}"
   6.630 +      fix x assume x: "x \<in> cbox a b"
   6.631        have "\<forall>i\<in>Basis. \<exists>l. x \<bullet> i \<in> {fst l \<bullet> i .. snd l \<bullet> i} \<and> l \<in> {(a, c), (c, d), (d, b)}"
   6.632        proof
   6.633          fix i :: 'a
   6.634 @@ -980,7 +1050,7 @@
   6.635          with x ord[of i]
   6.636          have "(a \<bullet> i \<le> x \<bullet> i \<and> x \<bullet> i \<le> c \<bullet> i) \<or> (c \<bullet> i \<le> x \<bullet> i \<and> x \<bullet> i \<le> d \<bullet> i) \<or>
   6.637              (d \<bullet> i \<le> x \<bullet> i \<and> x \<bullet> i \<le> b \<bullet> i)"
   6.638 -          by (auto simp: eucl_le[where 'a='a])
   6.639 +          by (auto simp: cbox_def)
   6.640          then show "\<exists>l. x \<bullet> i \<in> {fst l \<bullet> i .. snd l \<bullet> i} \<and> l \<in> {(a, c), (c, d), (d, b)}"
   6.641            by auto
   6.642        qed
   6.643 @@ -990,21 +1060,21 @@
   6.644        moreover from f have "restrict f Basis \<in> Basis \<rightarrow>\<^sub>E {(a, c), (c, d), (d, b)}"
   6.645          by auto
   6.646        moreover from f have "x \<in> ?B (restrict f Basis)"
   6.647 -        by (auto simp: mem_interval eucl_le[where 'a='a])
   6.648 +        by (auto simp: mem_box)
   6.649        ultimately have "\<exists>k\<in>p. x \<in> k"
   6.650          unfolding p_def by blast
   6.651      }
   6.652 -    ultimately show "\<Union>p = {a..b}"
   6.653 +    ultimately show "\<Union>p = cbox a b"
   6.654        by auto
   6.655    qed
   6.656  qed
   6.657  
   6.658  lemma partial_division_extend_interval:
   6.659 -  assumes "p division_of (\<Union>p)" "(\<Union>p) \<subseteq> {a..b}"
   6.660 -  obtains q where "p \<subseteq> q" "q division_of {a..b::'a::ordered_euclidean_space}"
   6.661 +  assumes "p division_of (\<Union>p)" "(\<Union>p) \<subseteq> cbox a b"
   6.662 +  obtains q where "p \<subseteq> q" "q division_of cbox a (b::'a::euclidean_space)"
   6.663  proof (cases "p = {}")
   6.664    case True
   6.665 -  obtain q where "q division_of {a..b}"
   6.666 +  obtain q where "q division_of (cbox a b)"
   6.667      by (rule elementary_interval)
   6.668    then show ?thesis
   6.669      apply -
   6.670 @@ -1015,20 +1085,20 @@
   6.671  next
   6.672    case False
   6.673    note p = division_ofD[OF assms(1)]
   6.674 -  have *: "\<forall>k\<in>p. \<exists>q. q division_of {a..b} \<and> k \<in> q"
   6.675 +  have *: "\<forall>k\<in>p. \<exists>q. q division_of cbox a b \<and> k \<in> q"
   6.676    proof
   6.677      case goal1
   6.678 -    obtain c d where k: "k = {c..d}"
   6.679 +    obtain c d where k: "k = cbox c d"
   6.680        using p(4)[OF goal1] by blast
   6.681 -    have *: "{c..d} \<subseteq> {a..b}" "{c..d} \<noteq> {}"
   6.682 +    have *: "cbox c d \<subseteq> cbox a b" "cbox c d \<noteq> {}"
   6.683        using p(2,3)[OF goal1, unfolded k] using assms(2)
   6.684        by (blast intro: order.trans)+
   6.685 -    obtain q where "q division_of {a..b}" "{c..d} \<in> q"
   6.686 +    obtain q where "q division_of cbox a b" "cbox c d \<in> q"
   6.687        by (rule partial_division_extend_1[OF *])
   6.688      then show ?case
   6.689        unfolding k by auto
   6.690    qed
   6.691 -  obtain q where q: "\<And>x. x \<in> p \<Longrightarrow> q x division_of {a..b}" "\<And>x. x \<in> p \<Longrightarrow> x \<in> q x"
   6.692 +  obtain q where q: "\<And>x. x \<in> p \<Longrightarrow> q x division_of cbox a b" "\<And>x. x \<in> p \<Longrightarrow> x \<in> q x"
   6.693      using bchoice[OF *] by blast
   6.694    have "\<And>x. x \<in> p \<Longrightarrow> \<exists>d. d division_of \<Union>(q x - {x})"
   6.695      apply rule
   6.696 @@ -1058,15 +1128,15 @@
   6.697      apply (rule that[of "d \<union> p"])
   6.698    proof -
   6.699      have *: "\<And>s f t. s \<noteq> {} \<Longrightarrow> \<forall>i\<in>s. f i \<union> i = t \<Longrightarrow> t = \<Inter>(f ` s) \<union> \<Union>s" by auto
   6.700 -    have *: "{a..b} = \<Inter>((\<lambda>i. \<Union>(q i - {i})) ` p) \<union> \<Union>p"
   6.701 +    have *: "cbox a b = \<Inter>((\<lambda>i. \<Union>(q i - {i})) ` p) \<union> \<Union>p"
   6.702        apply (rule *[OF False])
   6.703      proof
   6.704        fix i
   6.705        assume i: "i \<in> p"
   6.706 -      show "\<Union>(q i - {i}) \<union> i = {a..b}"
   6.707 +      show "\<Union>(q i - {i}) \<union> i = cbox a b"
   6.708          using division_ofD(6)[OF q(1)[OF i]] using q(2)[OF i] by auto
   6.709      qed
   6.710 -    show "d \<union> p division_of {a..b}"
   6.711 +    show "d \<union> p division_of (cbox a b)"
   6.712        unfolding *
   6.713        apply (rule division_disjoint_union[OF d assms(1)])
   6.714        apply (rule inter_interior_unions_intervals)
   6.715 @@ -1084,7 +1154,7 @@
   6.716          apply (rule inter_interior_unions_intervals)
   6.717        proof -
   6.718          note qk=division_ofD[OF q(1)[OF k]]
   6.719 -        show "finite (q k - {k})" "open (interior k)" "\<forall>t\<in>q k - {k}. \<exists>a b. t = {a..b}"
   6.720 +        show "finite (q k - {k})" "open (interior k)" "\<forall>t\<in>q k - {k}. \<exists>a b. t = cbox a b"
   6.721            using qk by auto
   6.722          show "\<forall>t\<in>q k - {k}. interior k \<inter> interior t = {}"
   6.723            using qk(5) using q(2)[OF k] by auto
   6.724 @@ -1101,19 +1171,19 @@
   6.725  qed
   6.726  
   6.727  lemma elementary_bounded[dest]:
   6.728 -  fixes s :: "'a::ordered_euclidean_space set"
   6.729 +  fixes s :: "'a::euclidean_space set"
   6.730    shows "p division_of s \<Longrightarrow> bounded s"
   6.731    unfolding division_of_def by (metis bounded_Union bounded_interval)
   6.732  
   6.733 -lemma elementary_subset_interval:
   6.734 -  "p division_of s \<Longrightarrow> \<exists>a b. s \<subseteq> {a..b::'a::ordered_euclidean_space}"
   6.735 -  by (meson elementary_bounded bounded_subset_closed_interval)
   6.736 +lemma elementary_subset_cbox:
   6.737 +  "p division_of s \<Longrightarrow> \<exists>a b. s \<subseteq> cbox a (b::'a::euclidean_space)"
   6.738 +  by (meson elementary_bounded bounded_subset_cbox)
   6.739  
   6.740  lemma division_union_intervals_exists:
   6.741 -  fixes a b :: "'a::ordered_euclidean_space"
   6.742 -  assumes "{a..b} \<noteq> {}"
   6.743 -  obtains p where "(insert {a..b} p) division_of ({a..b} \<union> {c..d})"
   6.744 -proof (cases "{c..d} = {}")
   6.745 +  fixes a b :: "'a::euclidean_space"
   6.746 +  assumes "cbox a b \<noteq> {}"
   6.747 +  obtains p where "(insert (cbox a b) p) division_of (cbox a b \<union> cbox c d)"
   6.748 +proof (cases "cbox c d = {}")
   6.749    case True
   6.750    show ?thesis
   6.751      apply (rule that[of "{}"])
   6.752 @@ -1124,29 +1194,29 @@
   6.753  next
   6.754    case False
   6.755    show ?thesis
   6.756 -  proof (cases "{a..b} \<inter> {c..d} = {}")
   6.757 +  proof (cases "cbox a b \<inter> cbox c d = {}")
   6.758      case True
   6.759      have *: "\<And>a b. {a, b} = {a} \<union> {b}" by auto
   6.760      show ?thesis
   6.761 -      apply (rule that[of "{{c..d}}"])
   6.762 +      apply (rule that[of "{cbox c d}"])
   6.763        unfolding *
   6.764        apply (rule division_disjoint_union)
   6.765 -      using `{c..d} \<noteq> {}` True assms
   6.766 +      using `cbox c d \<noteq> {}` True assms
   6.767        using interior_subset
   6.768        apply auto
   6.769        done
   6.770    next
   6.771      case False
   6.772 -    obtain u v where uv: "{a..b} \<inter> {c..d} = {u..v}"
   6.773 +    obtain u v where uv: "cbox a b \<inter> cbox c d = cbox u v"
   6.774        unfolding inter_interval by auto
   6.775 -    have *: "{u..v} \<subseteq> {c..d}" using uv by auto
   6.776 -    obtain p where "p division_of {c..d}" "{u..v} \<in> p"
   6.777 +    have *: "cbox u v \<subseteq> cbox c d" using uv by auto
   6.778 +    obtain p where "p division_of cbox c d" "cbox u v \<in> p"
   6.779        by (rule partial_division_extend_1[OF * False[unfolded uv]])
   6.780      note p = this division_ofD[OF this(1)]
   6.781 -    have *: "{a..b} \<union> {c..d} = {a..b} \<union> \<Union>(p - {{u..v}})" "\<And>x s. insert x s = {x} \<union> s"
   6.782 +    have *: "cbox a b \<union> cbox c d = cbox a b \<union> \<Union>(p - {cbox u v})" "\<And>x s. insert x s = {x} \<union> s"
   6.783        using p(8) unfolding uv[symmetric] by auto
   6.784      show ?thesis
   6.785 -      apply (rule that[of "p - {{u..v}}"])
   6.786 +      apply (rule that[of "p - {cbox u v}"])
   6.787        unfolding *(1)
   6.788        apply (subst *(2))
   6.789        apply (rule division_disjoint_union)
   6.790 @@ -1157,7 +1227,7 @@
   6.791        unfolding interior_inter[symmetric]
   6.792      proof -
   6.793        have *: "\<And>cd p uv ab. p \<subseteq> cd \<Longrightarrow> ab \<inter> cd = uv \<Longrightarrow> ab \<inter> p = uv \<inter> p" by auto
   6.794 -      have "interior ({a..b} \<inter> \<Union>(p - {{u..v}})) = interior({u..v} \<inter> \<Union>(p - {{u..v}}))"
   6.795 +      have "interior (cbox a b \<inter> \<Union>(p - {cbox u v})) = interior(cbox u v \<inter> \<Union>(p - {cbox u v}))"
   6.796          apply (rule arg_cong[of _ _ interior])
   6.797          apply (rule *[OF _ uv])
   6.798          using p(8)
   6.799 @@ -1169,7 +1239,7 @@
   6.800          using p(6) p(7)[OF p(2)] p(3)
   6.801          apply auto
   6.802          done
   6.803 -      finally show "interior ({a..b} \<inter> \<Union>(p - {{u..v}})) = {}" .
   6.804 +      finally show "interior (cbox a b \<inter> \<Union>(p - {cbox u v})) = {}" .
   6.805      qed auto
   6.806    qed
   6.807  qed
   6.808 @@ -1191,9 +1261,9 @@
   6.809    done
   6.810  
   6.811  lemma elementary_union_interval:
   6.812 -  fixes a b :: "'a::ordered_euclidean_space"
   6.813 +  fixes a b :: "'a::euclidean_space"
   6.814    assumes "p division_of \<Union>p"
   6.815 -  obtains q where "q division_of ({a..b} \<union> \<Union>p)"
   6.816 +  obtains q where "q division_of (cbox a b \<union> \<Union>p)"
   6.817  proof -
   6.818    note assm = division_ofD[OF assms]
   6.819    have lem1: "\<And>f s. \<Union>\<Union>(f ` s) = \<Union>((\<lambda>x. \<Union>(f x)) ` s)"
   6.820 @@ -1202,13 +1272,13 @@
   6.821      by auto
   6.822    {
   6.823      presume "p = {} \<Longrightarrow> thesis"
   6.824 -      "{a..b} = {} \<Longrightarrow> thesis"
   6.825 -      "{a..b} \<noteq> {} \<Longrightarrow> interior {a..b} = {} \<Longrightarrow> thesis"
   6.826 -      "p \<noteq> {} \<Longrightarrow> interior {a..b}\<noteq>{} \<Longrightarrow> {a..b} \<noteq> {} \<Longrightarrow> thesis"
   6.827 +      "cbox a b = {} \<Longrightarrow> thesis"
   6.828 +      "cbox a b \<noteq> {} \<Longrightarrow> interior (cbox a b) = {} \<Longrightarrow> thesis"
   6.829 +      "p \<noteq> {} \<Longrightarrow> interior (cbox a b)\<noteq>{} \<Longrightarrow> cbox a b \<noteq> {} \<Longrightarrow> thesis"
   6.830      then show thesis by auto
   6.831    next
   6.832      assume as: "p = {}"
   6.833 -    obtain p where "p division_of {a..b}"
   6.834 +    obtain p where "p division_of (cbox a b)"
   6.835        by (rule elementary_interval)
   6.836      then show thesis
   6.837        apply -
   6.838 @@ -1217,7 +1287,7 @@
   6.839        apply auto
   6.840        done
   6.841    next
   6.842 -    assume as: "{a..b} = {}"
   6.843 +    assume as: "cbox a b = {}"
   6.844      show thesis
   6.845        apply (rule that)
   6.846        unfolding as
   6.847 @@ -1225,9 +1295,9 @@
   6.848        apply auto
   6.849        done
   6.850    next
   6.851 -    assume as: "interior {a..b} = {}" "{a..b} \<noteq> {}"
   6.852 +    assume as: "interior (cbox a b) = {}" "cbox a b \<noteq> {}"
   6.853      show thesis
   6.854 -      apply (rule that[of "insert {a..b} p"],rule division_ofI)
   6.855 +      apply (rule that[of "insert (cbox a b) p"],rule division_ofI)
   6.856        unfolding finite_insert
   6.857        apply (rule assm(1)) unfolding Union_insert
   6.858        using assm(2-4) as
   6.859 @@ -1235,25 +1305,25 @@
   6.860        apply (fast dest: assm(5))+
   6.861        done
   6.862    next
   6.863 -    assume as: "p \<noteq> {}" "interior {a..b} \<noteq> {}" "{a..b} \<noteq> {}"
   6.864 -    have "\<forall>k\<in>p. \<exists>q. (insert {a..b} q) division_of ({a..b} \<union> k)"
   6.865 +    assume as: "p \<noteq> {}" "interior (cbox a b) \<noteq> {}" "cbox a b \<noteq> {}"
   6.866 +    have "\<forall>k\<in>p. \<exists>q. (insert (cbox a b) q) division_of (cbox a b \<union> k)"
   6.867      proof
   6.868        case goal1
   6.869 -      from assm(4)[OF this] obtain c d where "k = {c..d}" by blast
   6.870 +      from assm(4)[OF this] obtain c d where "k = cbox c d" by blast
   6.871        then show ?case
   6.872          apply -
   6.873          apply (rule division_union_intervals_exists[OF as(3), of c d])
   6.874          apply auto
   6.875          done
   6.876      qed
   6.877 -    from bchoice[OF this] obtain q where "\<forall>x\<in>p. insert {a..b} (q x) division_of {a..b} \<union> x" ..
   6.878 +    from bchoice[OF this] obtain q where "\<forall>x\<in>p. insert (cbox a b) (q x) division_of (cbox a b) \<union> x" ..
   6.879      note q = division_ofD[OF this[rule_format]]
   6.880 -    let ?D = "\<Union>{insert {a..b} (q k) | k. k \<in> p}"
   6.881 +    let ?D = "\<Union>{insert (cbox a b) (q k) | k. k \<in> p}"
   6.882      show thesis
   6.883        apply (rule that[of "?D"])
   6.884        apply (rule division_ofI)
   6.885      proof -
   6.886 -      have *: "{insert {a..b} (q k) |k. k \<in> p} = (\<lambda>k. insert {a..b} (q k)) ` p"
   6.887 +      have *: "{insert (cbox a b) (q k) |k. k \<in> p} = (\<lambda>k. insert (cbox a b) (q k)) ` p"
   6.888          by auto
   6.889        show "finite ?D"
   6.890          apply (rule finite_Union)
   6.891 @@ -1262,24 +1332,24 @@
   6.892          using assm(1) q(1)
   6.893          apply auto
   6.894          done
   6.895 -      show "\<Union>?D = {a..b} \<union> \<Union>p"
   6.896 +      show "\<Union>?D = cbox a b \<union> \<Union>p"
   6.897          unfolding * lem1
   6.898 -        unfolding lem2[OF as(1), of "{a..b}", symmetric]
   6.899 +        unfolding lem2[OF as(1), of "cbox a b", symmetric]
   6.900          using q(6)
   6.901          by auto
   6.902        fix k
   6.903        assume k: "k \<in> ?D"
   6.904 -      then show "k \<subseteq> {a..b} \<union> \<Union>p"
   6.905 +      then show "k \<subseteq> cbox a b \<union> \<Union>p"
   6.906          using q(2) by auto
   6.907        show "k \<noteq> {}"
   6.908          using q(3) k by auto
   6.909 -      show "\<exists>a b. k = {a..b}"
   6.910 +      show "\<exists>a b. k = cbox a b"
   6.911          using q(4) k by auto
   6.912        fix k'
   6.913        assume k': "k' \<in> ?D" "k \<noteq> k'"
   6.914 -      obtain x where x: "k \<in> insert {a..b} (q x)" "x\<in>p"
   6.915 +      obtain x where x: "k \<in> insert (cbox a b) (q x)" "x\<in>p"
   6.916          using k by auto
   6.917 -      obtain x' where x': "k'\<in>insert {a..b} (q x')" "x'\<in>p"
   6.918 +      obtain x' where x': "k'\<in>insert (cbox a b) (q x')" "x'\<in>p"
   6.919          using k' by auto
   6.920        show "interior k \<inter> interior k' = {}"
   6.921        proof (cases "x = x'")
   6.922 @@ -1293,12 +1363,12 @@
   6.923        next
   6.924          case False
   6.925          {
   6.926 -          presume "k = {a..b} \<Longrightarrow> ?thesis"
   6.927 -            and "k' = {a..b} \<Longrightarrow> ?thesis"
   6.928 -            and "k \<noteq> {a..b} \<Longrightarrow> k' \<noteq> {a..b} \<Longrightarrow> ?thesis"
   6.929 +          presume "k = cbox a b \<Longrightarrow> ?thesis"
   6.930 +            and "k' = cbox a b \<Longrightarrow> ?thesis"
   6.931 +            and "k \<noteq> cbox a b \<Longrightarrow> k' \<noteq> cbox a b \<Longrightarrow> ?thesis"
   6.932            then show ?thesis by auto
   6.933          next
   6.934 -          assume as': "k  = {a..b}"
   6.935 +          assume as': "k  = cbox a b"
   6.936            show ?thesis
   6.937              apply (rule q(5))
   6.938              using x' k'(2)
   6.939 @@ -1306,7 +1376,7 @@
   6.940              apply auto
   6.941              done
   6.942          next
   6.943 -          assume as': "k' = {a..b}"
   6.944 +          assume as': "k' = cbox a b"
   6.945            show ?thesis
   6.946              apply (rule q(5))
   6.947              using x  k'(2)
   6.948 @@ -1314,10 +1384,10 @@
   6.949              apply auto
   6.950              done
   6.951          }
   6.952 -        assume as': "k \<noteq> {a..b}" "k' \<noteq> {a..b}"
   6.953 -        obtain c d where k: "k = {c..d}"
   6.954 +        assume as': "k \<noteq> cbox a b" "k' \<noteq> cbox a b"
   6.955 +        obtain c d where k: "k = cbox c d"
   6.956            using q(4)[OF x(2,1)] by blast
   6.957 -        have "interior k \<inter> interior {a..b} = {}"
   6.958 +        have "interior k \<inter> interior (cbox a b) = {}"
   6.959            apply (rule q(5))
   6.960            using x k'(2)
   6.961            using as'
   6.962 @@ -1329,9 +1399,9 @@
   6.963            apply auto
   6.964            done
   6.965          moreover
   6.966 -        obtain c d where c_d: "k' = {c..d}"
   6.967 +        obtain c d where c_d: "k' = cbox c d"
   6.968            using q(4)[OF x'(2,1)] by blast
   6.969 -        have "interior k' \<inter> interior {a..b} = {}"
   6.970 +        have "interior k' \<inter> interior (cbox a b) = {}"
   6.971            apply (rule q(5))
   6.972            using x' k'(2)
   6.973            using as'
   6.974 @@ -1351,7 +1421,7 @@
   6.975  
   6.976  lemma elementary_unions_intervals:
   6.977    assumes fin: "finite f"
   6.978 -    and "\<And>s. s \<in> f \<Longrightarrow> \<exists>a b. s = {a..b::'a::ordered_euclidean_space}"
   6.979 +    and "\<And>s. s \<in> f \<Longrightarrow> \<exists>a b. s = cbox a (b::'a::euclidean_space)"
   6.980    obtains p where "p division_of (\<Union>f)"
   6.981  proof -
   6.982    have "\<exists>p. p division_of (\<Union>f)"
   6.983 @@ -1361,7 +1431,7 @@
   6.984      fix x F
   6.985      assume as: "finite F" "x \<notin> F" "\<exists>p. p division_of \<Union>F" "x\<in>f"
   6.986      from this(3) obtain p where p: "p division_of \<Union>F" ..
   6.987 -    from assms(2)[OF as(4)] obtain a b where x: "x = {a..b}" by blast
   6.988 +    from assms(2)[OF as(4)] obtain a b where x: "x = cbox a b" by blast
   6.989      have *: "\<Union>F = \<Union>p"
   6.990        using division_ofD[OF p] by auto
   6.991      show "\<exists>p. p division_of \<Union>insert x F"
   6.992 @@ -1377,7 +1447,7 @@
   6.993  qed
   6.994  
   6.995  lemma elementary_union:
   6.996 -  fixes s t :: "'a::ordered_euclidean_space set"
   6.997 +  fixes s t :: "'a::euclidean_space set"
   6.998    assumes "ps division_of s"
   6.999      and "pt division_of t"
  6.1000    obtains p where "p division_of (s \<union> t)"
  6.1001 @@ -1397,16 +1467,16 @@
  6.1002  qed
  6.1003  
  6.1004  lemma partial_division_extend:
  6.1005 -  fixes t :: "'a::ordered_euclidean_space set"
  6.1006 +  fixes t :: "'a::euclidean_space set"
  6.1007    assumes "p division_of s"
  6.1008      and "q division_of t"
  6.1009      and "s \<subseteq> t"
  6.1010    obtains r where "p \<subseteq> r" and "r division_of t"
  6.1011  proof -
  6.1012    note divp = division_ofD[OF assms(1)] and divq = division_ofD[OF assms(2)]
  6.1013 -  obtain a b where ab: "t \<subseteq> {a..b}"
  6.1014 -    using elementary_subset_interval[OF assms(2)] by auto
  6.1015 -  obtain r1 where "p \<subseteq> r1" "r1 division_of {a..b}"
  6.1016 +  obtain a b where ab: "t \<subseteq> cbox a b"
  6.1017 +    using elementary_subset_cbox[OF assms(2)] by auto
  6.1018 +  obtain r1 where "p \<subseteq> r1" "r1 division_of (cbox a b)"
  6.1019      apply (rule partial_division_extend_interval)
  6.1020      apply (rule assms(1)[unfolded divp(6)[symmetric]])
  6.1021      apply (rule subset_trans)
  6.1022 @@ -1452,7 +1522,7 @@
  6.1023    proof -
  6.1024      have "interior s \<inter> interior (\<Union>(r1-p)) = {}"
  6.1025      proof (rule inter_interior_unions_intervals)
  6.1026 -      show "finite (r1 - p)" and "open (interior s)" and "\<forall>t\<in>r1-p. \<exists>a b. t = {a..b}"
  6.1027 +      show "finite (r1 - p)" and "open (interior s)" and "\<forall>t\<in>r1-p. \<exists>a b. t = cbox a b"
  6.1028          using r1 by auto
  6.1029        have *: "\<And>s. (\<And>x. x \<in> s \<Longrightarrow> False) \<Longrightarrow> s = {}"
  6.1030          by auto
  6.1031 @@ -1462,7 +1532,7 @@
  6.1032          assume as: "m \<in> r1 - p"
  6.1033          have "interior m \<inter> interior (\<Union>p) = {}"
  6.1034          proof (rule inter_interior_unions_intervals)
  6.1035 -          show "finite p" and "open (interior m)" and "\<forall>t\<in>p. \<exists>a b. t = {a..b}"
  6.1036 +          show "finite p" and "open (interior m)" and "\<forall>t\<in>p. \<exists>a b. t = cbox a b"
  6.1037              using divp by auto
  6.1038            show "\<forall>t\<in>p. interior m \<inter> interior t = {}"
  6.1039              apply (rule, rule r1(7))
  6.1040 @@ -1486,7 +1556,7 @@
  6.1041  definition tagged_partial_division_of (infixr "tagged'_partial'_division'_of" 40)
  6.1042    where "s tagged_partial_division_of i \<longleftrightarrow>
  6.1043      finite s \<and>
  6.1044 -    (\<forall>x k. (x, k) \<in> s \<longrightarrow> x \<in> k \<and> k \<subseteq> i \<and> (\<exists>a b. k = {a..b})) \<and>
  6.1045 +    (\<forall>x k. (x, k) \<in> s \<longrightarrow> x \<in> k \<and> k \<subseteq> i \<and> (\<exists>a b. k = cbox a b)) \<and>
  6.1046      (\<forall>x1 k1 x2 k2. (x1, k1) \<in> s \<and> (x2, k2) \<in> s \<and> (x1, k1) \<noteq> (x2, k2) \<longrightarrow>
  6.1047        interior k1 \<inter> interior k2 = {})"
  6.1048  
  6.1049 @@ -1495,7 +1565,7 @@
  6.1050    shows "finite s"
  6.1051      and "\<And>x k. (x,k) \<in> s \<Longrightarrow> x \<in> k"
  6.1052      and "\<And>x k. (x,k) \<in> s \<Longrightarrow> k \<subseteq> i"
  6.1053 -    and "\<And>x k. (x,k) \<in> s \<Longrightarrow> \<exists>a b. k = {a..b}"
  6.1054 +    and "\<And>x k. (x,k) \<in> s \<Longrightarrow> \<exists>a b. k = cbox a b"
  6.1055      and "\<And>x1 k1 x2 k2. (x1,k1) \<in> s \<Longrightarrow>
  6.1056        (x2, k2) \<in> s \<Longrightarrow> (x1, k1) \<noteq> (x2, k2) \<Longrightarrow> interior k1 \<inter> interior k2 = {}"
  6.1057    using assms unfolding tagged_partial_division_of_def by blast+
  6.1058 @@ -1509,7 +1579,7 @@
  6.1059  lemma tagged_division_of:
  6.1060    "s tagged_division_of i \<longleftrightarrow>
  6.1061      finite s \<and>
  6.1062 -    (\<forall>x k. (x, k) \<in> s \<longrightarrow> x \<in> k \<and> k \<subseteq> i \<and> (\<exists>a b. k = {a..b})) \<and>
  6.1063 +    (\<forall>x k. (x, k) \<in> s \<longrightarrow> x \<in> k \<and> k \<subseteq> i \<and> (\<exists>a b. k = cbox a b)) \<and>
  6.1064      (\<forall>x1 k1 x2 k2. (x1, k1) \<in> s \<and> (x2, k2) \<in> s \<and> (x1, k1) \<noteq> (x2, k2) \<longrightarrow>
  6.1065        interior k1 \<inter> interior k2 = {}) \<and>
  6.1066      (\<Union>{k. \<exists>x. (x,k) \<in> s} = i)"
  6.1067 @@ -1519,7 +1589,7 @@
  6.1068    assumes "finite s"
  6.1069      and "\<And>x k. (x,k) \<in> s \<Longrightarrow> x \<in> k"
  6.1070      and "\<And>x k. (x,k) \<in> s \<Longrightarrow> k \<subseteq> i"
  6.1071 -    and "\<And>x k. (x,k) \<in> s \<Longrightarrow> \<exists>a b. k = {a..b}"
  6.1072 +    and "\<And>x k. (x,k) \<in> s \<Longrightarrow> \<exists>a b. k = cbox a b"
  6.1073      and "\<And>x1 k1 x2 k2. (x1,k1) \<in> s \<Longrightarrow> (x2, k2) \<in> s \<Longrightarrow> (x1, k1) \<noteq> (x2, k2) \<Longrightarrow>
  6.1074        interior k1 \<inter> interior k2 = {}"
  6.1075      and "(\<Union>{k. \<exists>x. (x,k) \<in> s} = i)"
  6.1076 @@ -1544,7 +1614,7 @@
  6.1077    shows "finite s"
  6.1078      and "\<And>x k. (x,k) \<in> s \<Longrightarrow> x \<in> k"
  6.1079      and "\<And>x k. (x,k) \<in> s \<Longrightarrow> k \<subseteq> i"
  6.1080 -    and "\<And>x k. (x,k) \<in> s \<Longrightarrow> \<exists>a b. k = {a..b}"
  6.1081 +    and "\<And>x k. (x,k) \<in> s \<Longrightarrow> \<exists>a b. k = cbox a b"
  6.1082      and "\<And>x1 k1 x2 k2. (x1, k1) \<in> s \<Longrightarrow> (x2, k2) \<in> s \<Longrightarrow> (x1, k1) \<noteq> (x2, k2) \<Longrightarrow>
  6.1083        interior k1 \<inter> interior k2 = {}"
  6.1084      and "(\<Union>{k. \<exists>x. (x,k) \<in> s} = i)"
  6.1085 @@ -1561,7 +1631,7 @@
  6.1086    assume k: "k \<in> snd ` s"
  6.1087    then obtain xk where xk: "(xk, k) \<in> s"
  6.1088      by auto
  6.1089 -  then show "k \<subseteq> i" "k \<noteq> {}" "\<exists>a b. k = {a..b}"
  6.1090 +  then show "k \<subseteq> i" "k \<noteq> {}" "\<exists>a b. k = cbox a b"
  6.1091      using assm by fastforce+
  6.1092    fix k'
  6.1093    assume k': "k' \<in> snd ` s" "k \<noteq> k'"
  6.1094 @@ -1587,7 +1657,7 @@
  6.1095    assume k: "k \<in> snd ` s"
  6.1096    then obtain xk where xk: "(xk, k) \<in> s"
  6.1097      by auto
  6.1098 -  then show "k \<noteq> {}" "\<exists>a b. k = {a..b}" "k \<subseteq> \<Union>(snd ` s)"
  6.1099 +  then show "k \<noteq> {}" "\<exists>a b. k = cbox a b" "k \<subseteq> \<Union>(snd ` s)"
  6.1100      using assm by auto
  6.1101    fix k'
  6.1102    assume k': "k' \<in> snd ` s" "k \<noteq> k'"
  6.1103 @@ -1612,9 +1682,9 @@
  6.1104    by blast
  6.1105  
  6.1106  lemma setsum_over_tagged_division_lemma:
  6.1107 -  fixes d :: "'m::ordered_euclidean_space set \<Rightarrow> 'a::real_normed_vector"
  6.1108 +  fixes d :: "'m::euclidean_space set \<Rightarrow> 'a::real_normed_vector"
  6.1109    assumes "p tagged_division_of i"
  6.1110 -    and "\<And>u v. {u..v} \<noteq> {} \<Longrightarrow> content {u..v} = 0 \<Longrightarrow> d {u..v} = 0"
  6.1111 +    and "\<And>u v. cbox u v \<noteq> {} \<Longrightarrow> content (cbox u v) = 0 \<Longrightarrow> d (cbox u v) = 0"
  6.1112    shows "setsum (\<lambda>(x,k). d k) p = setsum d (snd ` p)"
  6.1113  proof -
  6.1114    note assm = tagged_division_ofD[OF assms(1)]
  6.1115 @@ -1628,7 +1698,7 @@
  6.1116        using assm by auto
  6.1117      fix x y
  6.1118      assume as: "x\<in>p" "y\<in>p" "x\<noteq>y" "snd x = snd y"
  6.1119 -    obtain a b where ab: "snd x = {a..b}"
  6.1120 +    obtain a b where ab: "snd x = cbox a b"
  6.1121        using assm(4)[of "fst x" "snd x"] as(1) by auto
  6.1122      have "(fst x, snd y) \<in> p" "(fst x, snd y) \<noteq> y"
  6.1123        unfolding as(4)[symmetric] using as(1-3) by auto
  6.1124 @@ -1638,9 +1708,9 @@
  6.1125        using as
  6.1126        apply auto
  6.1127        done
  6.1128 -    then have "content {a..b} = 0"
  6.1129 +    then have "content (cbox a b) = 0"
  6.1130        unfolding as(4)[symmetric] ab content_eq_0_interior by auto
  6.1131 -    then have "d {a..b} = 0"
  6.1132 +    then have "d (cbox a b) = 0"
  6.1133        apply -
  6.1134        apply (rule assms(2))
  6.1135        using assm(2)[of "fst x" "snd x"] as(1)
  6.1136 @@ -1664,9 +1734,13 @@
  6.1137  lemma tagged_division_of_trivial[simp]: "p tagged_division_of {} \<longleftrightarrow> p = {}"
  6.1138    unfolding tagged_division_of by auto
  6.1139  
  6.1140 -lemma tagged_division_of_self: "x \<in> {a..b} \<Longrightarrow> {(x,{a..b})} tagged_division_of {a..b}"
  6.1141 +lemma tagged_division_of_self: "x \<in> cbox a b \<Longrightarrow> {(x,cbox a b)} tagged_division_of (cbox a b)"
  6.1142    by (rule tagged_division_ofI) auto
  6.1143  
  6.1144 +lemma tagged_division_of_self_real: "x \<in> {a .. b::real} \<Longrightarrow> {(x,{a .. b})} tagged_division_of {a .. b}"
  6.1145 +  unfolding box_real[symmetric]
  6.1146 +  by (rule tagged_division_of_self)
  6.1147 +
  6.1148  lemma tagged_division_union:
  6.1149    assumes "p1 tagged_division_of s1"
  6.1150      and "p2 tagged_division_of s2"
  6.1151 @@ -1681,7 +1755,7 @@
  6.1152      using p1(6) p2(6) by blast
  6.1153    fix x k
  6.1154    assume xk: "(x, k) \<in> p1 \<union> p2"
  6.1155 -  show "x \<in> k" "\<exists>a b. k = {a..b}"
  6.1156 +  show "x \<in> k" "\<exists>a b. k = cbox a b"
  6.1157      using xk p1(2,4) p2(2,4) by auto
  6.1158    show "k \<subseteq> s1 \<union> s2"
  6.1159      using xk p1(3) p2(3) by blast
  6.1160 @@ -1727,7 +1801,7 @@
  6.1161    assume xk: "(x, k) \<in> \<Union>(pfn ` iset)"
  6.1162    then obtain i where i: "i \<in> iset" "(x, k) \<in> pfn i"
  6.1163      by auto
  6.1164 -  show "x \<in> k" "\<exists>a b. k = {a..b}" "k \<subseteq> \<Union>iset"
  6.1165 +  show "x \<in> k" "\<exists>a b. k = cbox a b" "k \<subseteq> \<Union>iset"
  6.1166      using assm(2-4)[OF i] using i(1) by auto
  6.1167    fix x' k'
  6.1168    assume xk': "(x', k') \<in> \<Union>(pfn ` iset)" "(x, k) \<noteq> (x', k')"
  6.1169 @@ -1806,48 +1880,56 @@
  6.1170          norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - y) < e))"
  6.1171  
  6.1172  definition has_integral ::
  6.1173 -    "('n::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'b \<Rightarrow> 'n set \<Rightarrow> bool"
  6.1174 +    "('n::euclidean_space \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'b \<Rightarrow> 'n set \<Rightarrow> bool"
  6.1175    (infixr "has'_integral" 46)
  6.1176    where "(f has_integral y) i \<longleftrightarrow>
  6.1177 -    (if \<exists>a b. i = {a..b}
  6.1178 +    (if \<exists>a b. i = cbox a b
  6.1179       then (f has_integral_compact_interval y) i
  6.1180 -     else (\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow>
  6.1181 -      (\<exists>z. ((\<lambda>x. if x \<in> i then f x else 0) has_integral_compact_interval z) {a..b} \<and>
  6.1182 +     else (\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> cbox a b \<longrightarrow>
  6.1183 +      (\<exists>z. ((\<lambda>x. if x \<in> i then f x else 0) has_integral_compact_interval z) (cbox a b) \<and>
  6.1184          norm (z - y) < e)))"
  6.1185  
  6.1186  lemma has_integral:
  6.1187 -  "(f has_integral y) {a..b} \<longleftrightarrow>
  6.1188 +  "(f has_integral y) (cbox a b) \<longleftrightarrow>
  6.1189      (\<forall>e>0. \<exists>d. gauge d \<and>
  6.1190 -      (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
  6.1191 +      (\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
  6.1192          norm (setsum (\<lambda>(x,k). content(k) *\<^sub>R f x) p - y) < e))"
  6.1193    unfolding has_integral_def has_integral_compact_interval_def
  6.1194    by auto
  6.1195  
  6.1196 +lemma has_integral_real:
  6.1197 +  "(f has_integral y) {a .. b::real} \<longleftrightarrow>
  6.1198 +    (\<forall>e>0. \<exists>d. gauge d \<and>
  6.1199 +      (\<forall>p. p tagged_division_of {a .. b} \<and> d fine p \<longrightarrow>
  6.1200 +        norm (setsum (\<lambda>(x,k). content(k) *\<^sub>R f x) p - y) < e))"
  6.1201 +  unfolding box_real[symmetric]
  6.1202 +  by (rule has_integral)
  6.1203 +
  6.1204  lemma has_integralD[dest]:
  6.1205 -  assumes "(f has_integral y) ({a..b})"
  6.1206 +  assumes "(f has_integral y) (cbox a b)"
  6.1207      and "e > 0"
  6.1208    obtains d where "gauge d"
  6.1209 -    and "\<And>p. p tagged_division_of {a..b} \<Longrightarrow> d fine p \<Longrightarrow>
  6.1210 +    and "\<And>p. p tagged_division_of (cbox a b) \<Longrightarrow> d fine p \<Longrightarrow>
  6.1211        norm (setsum (\<lambda>(x,k). content(k) *\<^sub>R f(x)) p - y) < e"
  6.1212    using assms unfolding has_integral by auto
  6.1213  
  6.1214  lemma has_integral_alt:
  6.1215    "(f has_integral y) i \<longleftrightarrow>
  6.1216 -    (if \<exists>a b. i = {a..b}
  6.1217 +    (if \<exists>a b. i = cbox a b
  6.1218       then (f has_integral y) i
  6.1219 -     else (\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow>
  6.1220 -      (\<exists>z. ((\<lambda>x. if x \<in> i then f(x) else 0) has_integral z) ({a..b}) \<and> norm (z - y) < e)))"
  6.1221 +     else (\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> cbox a b \<longrightarrow>
  6.1222 +      (\<exists>z. ((\<lambda>x. if x \<in> i then f(x) else 0) has_integral z) (cbox a b) \<and> norm (z - y) < e)))"
  6.1223    unfolding has_integral
  6.1224    unfolding has_integral_compact_interval_def has_integral_def
  6.1225    by auto
  6.1226  
  6.1227  lemma has_integral_altD:
  6.1228    assumes "(f has_integral y) i"
  6.1229 -    and "\<not> (\<exists>a b. i = {a..b})"
  6.1230 +    and "\<not> (\<exists>a b. i = cbox a b)"
  6.1231      and "e>0"
  6.1232    obtains B where "B > 0"
  6.1233 -    and "\<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow>
  6.1234 -      (\<exists>z. ((\<lambda>x. if x \<in> i then f(x) else 0) has_integral z) ({a..b}) \<and> norm(z - y) < e)"
  6.1235 +    and "\<forall>a b. ball 0 B \<subseteq> cbox a b \<longrightarrow>
  6.1236 +      (\<exists>z. ((\<lambda>x. if x \<in> i then f(x) else 0) has_integral z) (cbox a b) \<and> norm(z - y) < e)"
  6.1237    using assms
  6.1238    unfolding has_integral
  6.1239    unfolding has_integral_compact_interval_def has_integral_def
  6.1240 @@ -1868,8 +1950,8 @@
  6.1241    by auto
  6.1242  
  6.1243  lemma setsum_content_null:
  6.1244 -  assumes "content {a..b} = 0"
  6.1245 -    and "p tagged_division_of {a..b}"
  6.1246 +  assumes "content (cbox a b) = 0"
  6.1247 +    and "p tagged_division_of (cbox a b)"
  6.1248    shows "setsum (\<lambda>(x,k). content k *\<^sub>R f x) p = (0::'a::real_normed_vector)"
  6.1249  proof (rule setsum_0', rule)
  6.1250    fix y
  6.1251 @@ -1877,7 +1959,7 @@
  6.1252    obtain x k where xk: "y = (x, k)"
  6.1253      using surj_pair[of y] by blast
  6.1254    note assm = tagged_division_ofD(3-4)[OF assms(2) y[unfolded xk]]
  6.1255 -  from this(2) obtain c d where k: "k = {c..d}" by blast
  6.1256 +  from this(2) obtain c d where k: "k = cbox c d" by blast
  6.1257    have "(\<lambda>(x, k). content k *\<^sub>R f x) y = content k *\<^sub>R f x"
  6.1258      unfolding xk by auto
  6.1259    also have "\<dots> = 0"
  6.1260 @@ -1923,22 +2005,22 @@
  6.1261  subsection {* General bisection principle for intervals; might be useful elsewhere. *}
  6.1262  
  6.1263  lemma interval_bisection_step:
  6.1264 -  fixes type :: "'a::ordered_euclidean_space"
  6.1265 +  fixes type :: "'a::euclidean_space"
  6.1266    assumes "P {}"
  6.1267      and "\<forall>s t. P s \<and> P t \<and> interior(s) \<inter> interior(t) = {} \<longrightarrow> P (s \<union> t)"
  6.1268 -    and "\<not> P {a..b::'a}"
  6.1269 -  obtains c d where "\<not> P{c..d}"
  6.1270 +    and "\<not> P (cbox a (b::'a))"
  6.1271 +  obtains c d where "\<not> P (cbox c d)"
  6.1272      and "\<forall>i\<in>Basis. 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"
  6.1273  proof -
  6.1274 -  have "{a..b} \<noteq> {}"
  6.1275 +  have "cbox a b \<noteq> {}"
  6.1276      using assms(1,3) by metis
  6.1277    then have ab: "\<And>i. i\<in>Basis \<Longrightarrow> a \<bullet> i \<le> b \<bullet> i"
  6.1278 -    by (auto simp: eucl_le[where 'a='a])
  6.1279 +    by (force simp: mem_box)
  6.1280    {
  6.1281      fix f
  6.1282      have "finite f \<Longrightarrow>
  6.1283        \<forall>s\<in>f. P s \<Longrightarrow>
  6.1284 -      \<forall>s\<in>f. \<exists>a b. s = {a..b} \<Longrightarrow>
  6.1285 +      \<forall>s\<in>f. \<exists>a b. s = cbox a b \<Longrightarrow>
  6.1286        \<forall>s\<in>f.\<forall>t\<in>f. s \<noteq> t \<longrightarrow> interior s \<inter> interior t = {} \<Longrightarrow> P (\<Union>f)"
  6.1287      proof (induct f rule: finite_induct)
  6.1288        case empty
  6.1289 @@ -1959,11 +2041,11 @@
  6.1290          done
  6.1291      qed
  6.1292    } note * = this
  6.1293 -  let ?A = "{{c..d} | c d::'a. \<forall>i\<in>Basis. (c\<bullet>i = a\<bullet>i) \<and> (d\<bullet>i = (a\<bullet>i + b\<bullet>i) / 2) \<or>
  6.1294 +  let ?A = "{cbox c d | c d::'a. \<forall>i\<in>Basis. (c\<bullet>i = a\<bullet>i) \<and> (d\<bullet>i = (a\<bullet>i + b\<bullet>i) / 2) \<or>
  6.1295      (c\<bullet>i = (a\<bullet>i + b\<bullet>i) / 2) \<and> (d\<bullet>i = b\<bullet>i)}"
  6.1296    let ?PP = "\<lambda>c d. \<forall>i\<in>Basis. 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"
  6.1297    {
  6.1298 -    presume "\<forall>c d. ?PP c d \<longrightarrow> P {c..d} \<Longrightarrow> False"
  6.1299 +    presume "\<forall>c d. ?PP c d \<longrightarrow> P (cbox c d) \<Longrightarrow> False"
  6.1300      then show thesis
  6.1301        unfolding atomize_not not_all
  6.1302        apply -
  6.1303 @@ -1972,23 +2054,23 @@
  6.1304        apply auto
  6.1305        done
  6.1306    }
  6.1307 -  assume as: "\<forall>c d. ?PP c d \<longrightarrow> P {c..d}"
  6.1308 +  assume as: "\<forall>c d. ?PP c d \<longrightarrow> P (cbox c d)"
  6.1309    have "P (\<Union> ?A)"
  6.1310      apply (rule *)
  6.1311      apply (rule_tac[2-] ballI)
  6.1312      apply (rule_tac[4] ballI)
  6.1313      apply (rule_tac[4] impI)
  6.1314    proof -
  6.1315 -    let ?B = "(\<lambda>s.{(\<Sum>i\<in>Basis. (if i \<in> s then a\<bullet>i else (a\<bullet>i + b\<bullet>i) / 2) *\<^sub>R i)::'a ..
  6.1316 -      (\<Sum>i\<in>Basis. (if i \<in> s then (a\<bullet>i + b\<bullet>i) / 2 else b\<bullet>i) *\<^sub>R i)}) ` {s. s \<subseteq> Basis}"
  6.1317 +    let ?B = "(\<lambda>s. cbox (\<Sum>i\<in>Basis. (if i \<in> s then a\<bullet>i else (a\<bullet>i + b\<bullet>i) / 2) *\<^sub>R i::'a)
  6.1318 +      (\<Sum>i\<in>Basis. (if i \<in> s then (a\<bullet>i + b\<bullet>i) / 2 else b\<bullet>i) *\<^sub>R i)) ` {s. s \<subseteq> Basis}"
  6.1319      have "?A \<subseteq> ?B"
  6.1320      proof
  6.1321        case goal1
  6.1322 -      then obtain c d where x: "x = {c..d}"
  6.1323 +      then obtain c d where x: "x = cbox c d"
  6.1324          "\<And>i. i \<in> Basis \<Longrightarrow>
  6.1325            c \<bullet> i = a \<bullet> i \<and> d \<bullet> i = (a \<bullet> i + b \<bullet> i) / 2 \<or>
  6.1326            c \<bullet> i = (a \<bullet> i + b \<bullet> i) / 2 \<and> d \<bullet> i = b \<bullet> i" by blast
  6.1327 -      have *: "\<And>a b c d. a = c \<Longrightarrow> b = d \<Longrightarrow> {a..b} = {c..d}"
  6.1328 +      have *: "\<And>a b c d. a = c \<Longrightarrow> b = d \<Longrightarrow> cbox a b = cbox c d"
  6.1329          by auto
  6.1330        show "x \<in> ?B"
  6.1331          unfolding image_iff
  6.1332 @@ -2011,7 +2093,7 @@
  6.1333      fix s
  6.1334      assume "s \<in> ?A"
  6.1335      then obtain c d where s:
  6.1336 -      "s = {c..d}"
  6.1337 +      "s = cbox c d"
  6.1338        "\<And>i. i \<in> Basis \<Longrightarrow>
  6.1339           c \<bullet> i = a \<bullet> i \<and> d \<bullet> i = (a \<bullet> i + b \<bullet> i) / 2 \<or>
  6.1340           c \<bullet> i = (a \<bullet> i + b \<bullet> i) / 2 \<and> d \<bullet> i = b \<bullet> i"
  6.1341 @@ -2024,12 +2106,12 @@
  6.1342        then show ?case
  6.1343          using s(2)[of i] using ab[OF `i \<in> Basis`] by auto
  6.1344      qed
  6.1345 -    show "\<exists>a b. s = {a..b}"
  6.1346 +    show "\<exists>a b. s = cbox a b"
  6.1347        unfolding s by auto
  6.1348      fix t
  6.1349      assume "t \<in> ?A"
  6.1350      then obtain e f where t:
  6.1351 -      "t = {e..f}"
  6.1352 +      "t = cbox e f"
  6.1353        "\<And>i. i \<in> Basis \<Longrightarrow>
  6.1354          e \<bullet> i = a \<bullet> i \<and> f \<bullet> i = (a \<bullet> i + b \<bullet> i) / 2 \<or>
  6.1355          e \<bullet> i = (a \<bullet> i + b \<bullet> i) / 2 \<and> f \<bullet> i = b \<bullet> i"
  6.1356 @@ -2054,12 +2136,12 @@
  6.1357      have *: "\<And>s t. (\<And>a. a \<in> s \<Longrightarrow> a \<in> t \<Longrightarrow> False) \<Longrightarrow> s \<inter> t = {}"
  6.1358        by auto
  6.1359      show "interior s \<inter> interior t = {}"
  6.1360 -      unfolding s t interior_closed_interval
  6.1361 +      unfolding s t interior_cbox
  6.1362      proof (rule *)
  6.1363        fix x
  6.1364        assume "x \<in> box c d" "x \<in> box e f"
  6.1365        then have x: "c\<bullet>i < d\<bullet>i" "e\<bullet>i < f\<bullet>i" "c\<bullet>i < f\<bullet>i" "e\<bullet>i < d\<bullet>i"
  6.1366 -        unfolding mem_interval using i'
  6.1367 +        unfolding mem_box using i'
  6.1368          apply -
  6.1369          apply (erule_tac[!] x=i in ballE)+
  6.1370          apply auto
  6.1371 @@ -2080,35 +2162,35 @@
  6.1372        qed
  6.1373      qed
  6.1374    qed
  6.1375 -  also have "\<Union> ?A = {a..b}"
  6.1376 +  also have "\<Union> ?A = cbox a b"
  6.1377    proof (rule set_eqI,rule)
  6.1378      fix x
  6.1379      assume "x \<in> \<Union>?A"
  6.1380      then obtain c d where x:
  6.1381 -      "x \<in> {c..d}"
  6.1382 +      "x \<in> cbox c d"
  6.1383        "\<And>i. i \<in> Basis \<Longrightarrow>
  6.1384          c \<bullet> i = a \<bullet> i \<and> d \<bullet> i = (a \<bullet> i + b \<bullet> i) / 2 \<or>
  6.1385          c \<bullet> i = (a \<bullet> i + b \<bullet> i) / 2 \<and> d \<bullet> i = b \<bullet> i" by blast
  6.1386 -    show "x\<in>{a..b}"
  6.1387 -      unfolding mem_interval
  6.1388 +    show "x\<in>cbox a b"
  6.1389 +      unfolding mem_box
  6.1390      proof safe
  6.1391        fix i :: 'a
  6.1392        assume i: "i \<in> Basis"
  6.1393        then show "a \<bullet> i \<le> x \<bullet> i" "x \<bullet> i \<le> b \<bullet> i"
  6.1394 -        using x(2)[OF i] x(1)[unfolded mem_interval,THEN bspec, OF i] by auto
  6.1395 +        using x(2)[OF i] x(1)[unfolded mem_box,THEN bspec, OF i] by auto
  6.1396      qed
  6.1397    next
  6.1398      fix x
  6.1399 -    assume x: "x \<in> {a..b}"
  6.1400 +    assume x: "x \<in> cbox a b"
  6.1401      have "\<forall>i\<in>Basis.
  6.1402        \<exists>c d. (c = a\<bullet>i \<and> d = (a\<bullet>i + b\<bullet>i) / 2 \<or> c = (a\<bullet>i + b\<bullet>i) / 2 \<and> d = b\<bullet>i) \<and> c\<le>x\<bullet>i \<and> x\<bullet>i \<le> d"
  6.1403        (is "\<forall>i\<in>Basis. \<exists>c d. ?P i c d")
  6.1404 -      unfolding mem_interval
  6.1405 +      unfolding mem_box
  6.1406      proof
  6.1407        fix i :: 'a
  6.1408        assume i: "i \<in> Basis"
  6.1409        have "?P i (a\<bullet>i) ((a \<bullet> i + b \<bullet> i) / 2) \<or> ?P i ((a \<bullet> i + b \<bullet> i) / 2) (b\<bullet>i)"
  6.1410 -        using x[unfolded mem_interval,THEN bspec, OF i] by auto
  6.1411 +        using x[unfolded mem_box,THEN bspec, OF i] by auto
  6.1412        then show "\<exists>c d. ?P i c d"
  6.1413          by blast
  6.1414      qed
  6.1415 @@ -2116,8 +2198,8 @@
  6.1416        unfolding Union_iff Bex_def mem_Collect_eq choice_Basis_iff
  6.1417        apply -
  6.1418        apply (erule exE)+
  6.1419 -      apply (rule_tac x="{xa..xaa}" in exI)
  6.1420 -      unfolding mem_interval
  6.1421 +      apply (rule_tac x="cbox xa xaa" in exI)
  6.1422 +      unfolding mem_box
  6.1423        apply auto
  6.1424        done
  6.1425    qed
  6.1426 @@ -2126,25 +2208,25 @@
  6.1427  qed
  6.1428  
  6.1429  lemma interval_bisection:
  6.1430 -  fixes type :: "'a::ordered_euclidean_space"
  6.1431 +  fixes type :: "'a::euclidean_space"
  6.1432    assumes "P {}"
  6.1433      and "(\<forall>s t. P s \<and> P t \<and> interior(s) \<inter> interior(t) = {} \<longrightarrow> P(s \<union> t))"
  6.1434 -    and "\<not> P {a..b::'a}"
  6.1435 -  obtains x where "x \<in> {a..b}"
  6.1436 -    and "\<forall>e>0. \<exists>c d. x \<in> {c..d} \<and> {c..d} \<subseteq> ball x e \<and> {c..d} \<subseteq> {a..b} \<and> \<not> P {c..d}"
  6.1437 -proof -
  6.1438 -  have "\<forall>x. \<exists>y. \<not> P {fst x..snd x} \<longrightarrow> (\<not> P {fst y..snd y} \<and>
  6.1439 +    and "\<not> P (cbox a (b::'a))"
  6.1440 +  obtains x where "x \<in> cbox a b"
  6.1441 +    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)"
  6.1442 +proof -
  6.1443 +  have "\<forall>x. \<exists>y. \<not> P (cbox (fst x) (snd x)) \<longrightarrow> (\<not> P (cbox (fst y) (snd y)) \<and>
  6.1444      (\<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>
  6.1445         2 * (snd y\<bullet>i - fst y\<bullet>i) \<le> snd x\<bullet>i - fst x\<bullet>i))"
  6.1446    proof
  6.1447      case goal1
  6.1448      then show ?case
  6.1449      proof -
  6.1450 -      presume "\<not> P {fst x..snd x} \<Longrightarrow> ?thesis"
  6.1451 -      then show ?thesis by (cases "P {fst x..snd x}") auto
  6.1452 +      presume "\<not> P (cbox (fst x) (snd x)) \<Longrightarrow> ?thesis"
  6.1453 +      then show ?thesis by (cases "P (cbox (fst x) (snd x))") auto
  6.1454      next
  6.1455 -      assume as: "\<not> P {fst x..snd x}"
  6.1456 -      obtain c d where "\<not> P {c..d}"
  6.1457 +      assume as: "\<not> P (cbox (fst x) (snd x))"
  6.1458 +      obtain c d where "\<not> P (cbox c d)"
  6.1459          "\<forall>i\<in>Basis.
  6.1460             fst x \<bullet> i \<le> c \<bullet> i \<and>
  6.1461             c \<bullet> i \<le> d \<bullet> i \<and>
  6.1462 @@ -2160,8 +2242,8 @@
  6.1463    qed
  6.1464    then obtain f where f:
  6.1465      "\<forall>x.
  6.1466 -      \<not> P {fst x..snd x} \<longrightarrow>
  6.1467 -      \<not> P {fst (f x)..snd (f x)} \<and>
  6.1468 +      \<not> P (cbox (fst x) (snd x)) \<longrightarrow>
  6.1469 +      \<not> P (cbox (fst (f x)) (snd (f x))) \<and>
  6.1470          (\<forall>i\<in>Basis.
  6.1471              fst x \<bullet> i \<le> fst (f x) \<bullet> i \<and>
  6.1472              fst (f x) \<bullet> i \<le> snd (f x) \<bullet> i \<and>
  6.1473 @@ -2175,7 +2257,7 @@
  6.1474    def A \<equiv> "\<lambda>n. fst(AB n)"
  6.1475    def B \<equiv> "\<lambda>n. snd(AB n)"
  6.1476    note ab_def = A_def B_def AB_def
  6.1477 -  have "A 0 = a" "B 0 = b" "\<And>n. \<not> P {A(Suc n)..B(Suc n)} \<and>
  6.1478 +  have "A 0 = a" "B 0 = b" "\<And>n. \<not> P (cbox (A(Suc n)) (B(Suc n))) \<and>
  6.1479      (\<forall>i\<in>Basis. A(n)\<bullet>i \<le> A(Suc n)\<bullet>i \<and> A(Suc n)\<bullet>i \<le> B(Suc n)\<bullet>i \<and> B(Suc n)\<bullet>i \<le> B(n)\<bullet>i \<and>
  6.1480      2 * (B(Suc n)\<bullet>i - A(Suc n)\<bullet>i) \<le> B(n)\<bullet>i - A(n)\<bullet>i)" (is "\<And>n. ?P n")
  6.1481    proof -
  6.1482 @@ -2204,7 +2286,7 @@
  6.1483    qed
  6.1484    note AB = this(1-2) conjunctD2[OF this(3),rule_format]
  6.1485  
  6.1486 -  have interv: "\<And>e. 0 < e \<Longrightarrow> \<exists>n. \<forall>x\<in>{A n..B n}. \<forall>y\<in>{A n..B n}. dist x y < e"
  6.1487 +  have interv: "\<And>e. 0 < e \<Longrightarrow> \<exists>n. \<forall>x\<in>cbox (A n) (B n). \<forall>y\<in>cbox (A n) (B n). dist x y < e"
  6.1488    proof -
  6.1489      case goal1
  6.1490      obtain n where n: "(\<Sum>i\<in>Basis. b \<bullet> i - a \<bullet> i) / e < 2 ^ n"
  6.1491 @@ -2215,7 +2297,7 @@
  6.1492        apply rule
  6.1493      proof -
  6.1494        fix x y
  6.1495 -      assume xy: "x\<in>{A n..B n}" "y\<in>{A n..B n}"
  6.1496 +      assume xy: "x\<in>cbox (A n) (B n)" "y\<in>cbox (A n) (B n)"
  6.1497        have "dist x y \<le> setsum (\<lambda>i. abs((x - y)\<bullet>i)) Basis"
  6.1498          unfolding dist_norm by(rule norm_le_l1)
  6.1499        also have "\<dots> \<le> setsum (\<lambda>i. B n\<bullet>i - A n\<bullet>i) Basis"
  6.1500 @@ -2223,7 +2305,7 @@
  6.1501          fix i :: 'a
  6.1502          assume i: "i \<in> Basis"
  6.1503          show "\<bar>(x - y) \<bullet> i\<bar> \<le> B n \<bullet> i - A n \<bullet> i"
  6.1504 -          using xy[unfolded mem_interval,THEN bspec, OF i]
  6.1505 +          using xy[unfolded mem_box,THEN bspec, OF i]
  6.1506            by (auto simp: inner_diff_left)
  6.1507        qed
  6.1508        also have "\<dots> \<le> setsum (\<lambda>i. b\<bullet>i - a\<bullet>i) Basis / 2^n"
  6.1509 @@ -2251,27 +2333,27 @@
  6.1510    qed
  6.1511    {
  6.1512      fix n m :: nat
  6.1513 -    assume "m \<le> n" then have "{A n..B n} \<subseteq> {A m..B m}"
  6.1514 +    assume "m \<le> n" then have "cbox (A n) (B n) \<subseteq> cbox (A m) (B m)"
  6.1515      proof (induction rule: inc_induct)
  6.1516        case (step i)
  6.1517        show ?case
  6.1518 -        using AB(4) by (intro order_trans[OF step.IH] subset_interval_imp) auto
  6.1519 +        using AB(4) by (intro order_trans[OF step.IH] subset_box_imp) auto
  6.1520      qed simp
  6.1521    } note ABsubset = this
  6.1522 -  have "\<exists>a. \<forall>n. a\<in>{A n..B n}"
  6.1523 -    by (rule decreasing_closed_nest[rule_format,OF closed_interval _ ABsubset interv])
  6.1524 +  have "\<exists>a. \<forall>n. a\<in> cbox (A n) (B n)"
  6.1525 +    by (rule decreasing_closed_nest[rule_format,OF closed_cbox _ ABsubset interv])
  6.1526        (metis nat.exhaust AB(1-3) assms(1,3))
  6.1527 -  then obtain x0 where x0: "\<And>n. x0 \<in> {A n..B n}"
  6.1528 +  then obtain x0 where x0: "\<And>n. x0 \<in> cbox (A n) (B n)"
  6.1529      by blast
  6.1530    show thesis
  6.1531    proof (rule that[rule_format, of x0])
  6.1532 -    show "x0\<in>{a..b}"
  6.1533 +    show "x0\<in>cbox a b"
  6.1534        using x0[of 0] unfolding AB .
  6.1535      fix e :: real
  6.1536      assume "e > 0"
  6.1537      from interv[OF this] obtain n
  6.1538 -      where n: "\<forall>x\<in>{A n..B n}. \<forall>y\<in>{A n..B n}. dist x y < e" ..
  6.1539 -    show "\<exists>c d. x0 \<in> {c..d} \<and> {c..d} \<subseteq> ball x0 e \<and> {c..d} \<subseteq> {a..b} \<and> \<not> P {c..d}"
  6.1540 +      where n: "\<forall>x\<in>cbox (A n) (B n). \<forall>y\<in>cbox (A n) (B n). dist x y < e" ..
  6.1541 +    show "\<exists>c d. x0 \<in> cbox c d \<and> cbox c d \<subseteq> ball x0 e \<and> cbox c d \<subseteq> cbox a b \<and> \<not> P (cbox c d)"
  6.1542        apply (rule_tac x="A n" in exI)
  6.1543        apply (rule_tac x="B n" in exI)
  6.1544        apply rule
  6.1545 @@ -2280,14 +2362,14 @@
  6.1546        defer
  6.1547        apply rule
  6.1548      proof -
  6.1549 -      show "\<not> P {A n..B n}"
  6.1550 +      show "\<not> P (cbox (A n) (B n))"
  6.1551          apply (cases "0 < n")
  6.1552          using AB(3)[of "n - 1"] assms(3) AB(1-2)
  6.1553          apply auto
  6.1554          done
  6.1555 -      show "{A n..B n} \<subseteq> ball x0 e"
  6.1556 +      show "cbox (A n) (B n) \<subseteq> ball x0 e"
  6.1557          using n using x0[of n] by auto
  6.1558 -      show "{A n..B n} \<subseteq> {a..b}"
  6.1559 +      show "cbox (A n) (B n) \<subseteq> cbox a b"
  6.1560          unfolding AB(1-2)[symmetric] by (rule ABsubset) auto
  6.1561      qed
  6.1562    qed
  6.1563 @@ -2297,24 +2379,24 @@
  6.1564  subsection {* Cousin's lemma. *}
  6.1565  
  6.1566  lemma fine_division_exists:
  6.1567 -  fixes a b :: "'a::ordered_euclidean_space"
  6.1568 +  fixes a b :: "'a::euclidean_space"
  6.1569    assumes "gauge g"
  6.1570 -  obtains p where "p tagged_division_of {a..b}" "g fine p"
  6.1571 -proof -
  6.1572 -  presume "\<not> (\<exists>p. p tagged_division_of {a..b} \<and> g fine p) \<Longrightarrow> False"
  6.1573 -  then obtain p where "p tagged_division_of {a..b}" "g fine p"
  6.1574 +  obtains p where "p tagged_division_of (cbox a b)" "g fine p"
  6.1575 +proof -
  6.1576 +  presume "\<not> (\<exists>p. p tagged_division_of (cbox a b) \<and> g fine p) \<Longrightarrow> False"
  6.1577 +  then obtain p where "p tagged_division_of (cbox a b)" "g fine p"
  6.1578      by blast
  6.1579    then show thesis ..
  6.1580  next
  6.1581 -  assume as: "\<not> (\<exists>p. p tagged_division_of {a..b} \<and> g fine p)"
  6.1582 +  assume as: "\<not> (\<exists>p. p tagged_division_of (cbox a b) \<and> g fine p)"
  6.1583    obtain x where x:
  6.1584 -    "x \<in> {a..b}"
  6.1585 +    "x \<in> (cbox a b)"
  6.1586      "\<And>e. 0 < e \<Longrightarrow>
  6.1587        \<exists>c d.
  6.1588 -        x \<in> {c..d} \<and>
  6.1589 -        {c..d} \<subseteq> ball x e \<and>
  6.1590 -        {c..d} \<subseteq> {a..b} \<and>
  6.1591 -        \<not> (\<exists>p. p tagged_division_of {c..d} \<and> g fine p)"
  6.1592 +        x \<in> cbox c d \<and>
  6.1593 +        cbox c d \<subseteq> ball x e \<and>
  6.1594 +        cbox c d \<subseteq> (cbox a b) \<and>
  6.1595 +        \<not> (\<exists>p. p tagged_division_of cbox c d \<and> g fine p)"
  6.1596      apply (rule interval_bisection[of "\<lambda>s. \<exists>p. p tagged_division_of s \<and> g fine p",rule_format,OF _ _ as])
  6.1597      apply (rule_tac x="{}" in exI)
  6.1598      defer
  6.1599 @@ -2338,22 +2420,27 @@
  6.1600    obtain e where e: "e > 0" "ball x e \<subseteq> g x"
  6.1601      using gaugeD[OF assms, of x] unfolding open_contains_ball by auto
  6.1602    from x(2)[OF e(1)] obtain c d where c_d:
  6.1603 -    "x \<in> {c..d}"
  6.1604 -    "{c..d} \<subseteq> ball x e"
  6.1605 -    "{c..d} \<subseteq> {a..b}"
  6.1606 -    "\<not> (\<exists>p. p tagged_division_of {c..d} \<and> g fine p)"
  6.1607 +    "x \<in> cbox c d"
  6.1608 +    "cbox c d \<subseteq> ball x e"
  6.1609 +    "cbox c d \<subseteq> cbox a b"
  6.1610 +    "\<not> (\<exists>p. p tagged_division_of cbox c d \<and> g fine p)"
  6.1611      by blast
  6.1612 -  have "g fine {(x, {c..d})}"
  6.1613 +  have "g fine {(x, cbox c d)}"
  6.1614      unfolding fine_def using e using c_d(2) by auto
  6.1615    then show False
  6.1616      using tagged_division_of_self[OF c_d(1)] using c_d by auto
  6.1617  qed
  6.1618  
  6.1619 +lemma fine_division_exists_real:
  6.1620 +  fixes a b :: real
  6.1621 +  assumes "gauge g"
  6.1622 +  obtains p where "p tagged_division_of {a .. b}" "g fine p"
  6.1623 +  by (metis assms box_real(2) fine_division_exists)
  6.1624  
  6.1625  subsection {* Basic theorems about integrals. *}
  6.1626  
  6.1627  lemma has_integral_unique:
  6.1628 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
  6.1629 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::real_normed_vector"
  6.1630    assumes "(f has_integral k1) i"
  6.1631      and "(f has_integral k2) i"
  6.1632    shows "k1 = k2"
  6.1633 @@ -2363,23 +2450,23 @@
  6.1634    then have e: "?e > 0"
  6.1635      by auto
  6.1636    have lem: "\<And>f::'n \<Rightarrow> 'a.  \<And>a b k1 k2.
  6.1637 -    (f has_integral k1) ({a..b}) \<Longrightarrow> (f has_integral k2) ({a..b}) \<Longrightarrow> k1 \<noteq> k2 \<Longrightarrow> False"
  6.1638 +    (f has_integral k1) (cbox a b) \<Longrightarrow> (f has_integral k2) (cbox a b) \<Longrightarrow> k1 \<noteq> k2 \<Longrightarrow> False"
  6.1639    proof -
  6.1640      case goal1
  6.1641      let ?e = "norm (k1 - k2) / 2"
  6.1642      from goal1(3) have e: "?e > 0" by auto
  6.1643      obtain d1 where d1:
  6.1644          "gauge d1"
  6.1645 -        "\<And>p. p tagged_division_of {a..b} \<Longrightarrow>
  6.1646 +        "\<And>p. p tagged_division_of cbox a b \<Longrightarrow>
  6.1647            d1 fine p \<Longrightarrow> norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - k1) < norm (k1 - k2) / 2"
  6.1648        by (rule has_integralD[OF goal1(1) e]) blast
  6.1649      obtain d2 where d2:
  6.1650          "gauge d2"
  6.1651 -        "\<And>p. p tagged_division_of {a..b} \<Longrightarrow>
  6.1652 +        "\<And>p. p tagged_division_of cbox a b \<Longrightarrow>
  6.1653            d2 fine p \<Longrightarrow> norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - k2) < norm (k1 - k2) / 2"
  6.1654        by (rule has_integralD[OF goal1(2) e]) blast
  6.1655      obtain p where p:
  6.1656 -        "p tagged_division_of {a..b}"
  6.1657 +        "p tagged_division_of cbox a b"
  6.1658          "(\<lambda>x. d1 x \<inter> d2 x) fine p"
  6.1659        by (rule fine_division_exists[OF gauge_inter[OF d1(1) d2(1)]])
  6.1660      let ?c = "(\<Sum>(x, k)\<in>p. content k *\<^sub>R f x)"
  6.1661 @@ -2395,40 +2482,40 @@
  6.1662      finally show False by auto
  6.1663    qed
  6.1664    {
  6.1665 -    presume "\<not> (\<exists>a b. i = {a..b}) \<Longrightarrow> False"
  6.1666 +    presume "\<not> (\<exists>a b. i = cbox a b) \<Longrightarrow> False"
  6.1667      then show False
  6.1668        apply -
  6.1669 -      apply (cases "\<exists>a b. i = {a..b}")
  6.1670 +      apply (cases "\<exists>a b. i = cbox a b")
  6.1671        using assms
  6.1672        apply (auto simp add:has_integral intro:lem[OF _ _ as])
  6.1673        done
  6.1674    }
  6.1675 -  assume as: "\<not> (\<exists>a b. i = {a..b})"
  6.1676 +  assume as: "\<not> (\<exists>a b. i = cbox a b)"
  6.1677    obtain B1 where B1:
  6.1678        "0 < B1"
  6.1679 -      "\<And>a b. ball 0 B1 \<subseteq> {a..b} \<Longrightarrow>
  6.1680 -        \<exists>z. ((\<lambda>x. if x \<in> i then f x else 0) has_integral z) {a..b} \<and>
  6.1681 +      "\<And>a b. ball 0 B1 \<subseteq> cbox a b \<Longrightarrow>
  6.1682 +        \<exists>z. ((\<lambda>x. if x \<in> i then f x else 0) has_integral z) (cbox a b) \<and>
  6.1683            norm (z - k1) < norm (k1 - k2) / 2"
  6.1684      by (rule has_integral_altD[OF assms(1) as,OF e]) blast
  6.1685    obtain B2 where B2:
  6.1686        "0 < B2"
  6.1687 -      "\<And>a b. ball 0 B2 \<subseteq> {a..b} \<Longrightarrow>
  6.1688 -        \<exists>z. ((\<lambda>x. if x \<in> i then f x else 0) has_integral z) {a..b} \<and>
  6.1689 +      "\<And>a b. ball 0 B2 \<subseteq> cbox a b \<Longrightarrow>
  6.1690 +        \<exists>z. ((\<lambda>x. if x \<in> i then f x else 0) has_integral z) (cbox a b) \<and>
  6.1691            norm (z - k2) < norm (k1 - k2) / 2"
  6.1692      by (rule has_integral_altD[OF assms(2) as,OF e]) blast
  6.1693 -  have "\<exists>a b::'n. ball 0 B1 \<union> ball 0 B2 \<subseteq> {a..b}"
  6.1694 -    apply (rule bounded_subset_closed_interval)
  6.1695 +  have "\<exists>a b::'n. ball 0 B1 \<union> ball 0 B2 \<subseteq> cbox a b"
  6.1696 +    apply (rule bounded_subset_cbox)
  6.1697      using bounded_Un bounded_ball
  6.1698      apply auto
  6.1699      done
  6.1700 -  then obtain a b :: 'n where ab: "ball 0 B1 \<subseteq> {a..b}" "ball 0 B2 \<subseteq> {a..b}"
  6.1701 +  then obtain a b :: 'n where ab: "ball 0 B1 \<subseteq> cbox a b" "ball 0 B2 \<subseteq> cbox a b"
  6.1702      by blast
  6.1703    obtain w where w:
  6.1704 -    "((\<lambda>x. if x \<in> i then f x else 0) has_integral w) {a..b}"
  6.1705 +    "((\<lambda>x. if x \<in> i then f x else 0) has_integral w) (cbox a b)"
  6.1706      "norm (w - k1) < norm (k1 - k2) / 2"
  6.1707      using B1(2)[OF ab(1)] by blast
  6.1708    obtain z where z:
  6.1709 -    "((\<lambda>x. if x \<in> i then f x else 0) has_integral z) {a..b}"
  6.1710 +    "((\<lambda>x. if x \<in> i then f x else 0) has_integral z) (cbox a b)"
  6.1711      "norm (z - k2) < norm (k1 - k2) / 2"
  6.1712      using B2(2)[OF ab(2)] by blast
  6.1713    have "z = w"
  6.1714 @@ -2448,21 +2535,21 @@
  6.1715    by (rule some_equality) (auto intro: has_integral_unique)
  6.1716  
  6.1717  lemma has_integral_is_0:
  6.1718 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
  6.1719 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::real_normed_vector"
  6.1720    assumes "\<forall>x\<in>s. f x = 0"
  6.1721    shows "(f has_integral 0) s"
  6.1722  proof -
  6.1723    have lem: "\<And>a b. \<And>f::'n \<Rightarrow> 'a.
  6.1724 -    (\<forall>x\<in>{a..b}. f(x) = 0) \<Longrightarrow> (f has_integral 0) ({a..b})"
  6.1725 +    (\<forall>x\<in>cbox a b. f(x) = 0) \<Longrightarrow> (f has_integral 0) (cbox a b)"
  6.1726      unfolding has_integral
  6.1727      apply rule
  6.1728      apply rule
  6.1729    proof -
  6.1730      fix a b e
  6.1731      fix f :: "'n \<Rightarrow> 'a"
  6.1732 -    assume as: "\<forall>x\<in>{a..b}. f x = 0" "0 < (e::real)"
  6.1733 +    assume as: "\<forall>x\<in>cbox a b. f x = 0" "0 < (e::real)"
  6.1734      show "\<exists>d. gauge d \<and>
  6.1735 -      (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow> norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) < e)"
  6.1736 +      (\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow> norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) < e)"
  6.1737        apply (rule_tac x="\<lambda>x. ball x 1" in exI)
  6.1738        apply rule
  6.1739        apply (rule gaugeI)
  6.1740 @@ -2491,10 +2578,10 @@
  6.1741      qed auto
  6.1742    qed
  6.1743    {
  6.1744 -    presume "\<not> (\<exists>a b. s = {a..b}) \<Longrightarrow> ?thesis"
  6.1745 +    presume "\<not> (\<exists>a b. s = cbox a b) \<Longrightarrow> ?thesis"
  6.1746      then show ?thesis
  6.1747        apply -
  6.1748 -      apply (cases "\<exists>a b. s = {a..b}")
  6.1749 +      apply (cases "\<exists>a b. s = cbox a b")
  6.1750        using assms
  6.1751        apply (auto simp add:has_integral intro: lem)
  6.1752        done
  6.1753 @@ -2504,7 +2591,7 @@
  6.1754      using assms
  6.1755      apply auto
  6.1756      done
  6.1757 -  assume "\<not> (\<exists>a b. s = {a..b})"
  6.1758 +  assume "\<not> (\<exists>a b. s = cbox a b)"
  6.1759    then show ?thesis
  6.1760      apply (subst has_integral_alt)
  6.1761      unfolding if_not_P *
  6.1762 @@ -2520,7 +2607,7 @@
  6.1763      fix e :: real
  6.1764      fix a b
  6.1765      assume "e > 0"
  6.1766 -    then show "\<exists>z. ((\<lambda>x::'n. 0::'a) has_integral z) {a..b} \<and> norm (z - 0) < e"
  6.1767 +    then show "\<exists>z. ((\<lambda>x::'n. 0::'a) has_integral z) (cbox a b) \<and> norm (z - 0) < e"
  6.1768        apply (rule_tac x=0 in exI)
  6.1769        apply(rule,rule lem)
  6.1770        apply auto
  6.1771 @@ -2528,14 +2615,14 @@
  6.1772    qed auto
  6.1773  qed
  6.1774  
  6.1775 -lemma has_integral_0[simp]: "((\<lambda>x::'n::ordered_euclidean_space. 0) has_integral 0) s"
  6.1776 +lemma has_integral_0[simp]: "((\<lambda>x::'n::euclidean_space. 0) has_integral 0) s"
  6.1777    by (rule has_integral_is_0) auto
  6.1778  
  6.1779  lemma has_integral_0_eq[simp]: "((\<lambda>x. 0) has_integral i) s \<longleftrightarrow> i = 0"
  6.1780    using has_integral_unique[OF has_integral_0] by auto
  6.1781  
  6.1782  lemma has_integral_linear:
  6.1783 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
  6.1784 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::real_normed_vector"
  6.1785    assumes "(f has_integral y) s"
  6.1786      and "bounded_linear h"
  6.1787    shows "((h o f) has_integral ((h y))) s"
  6.1788 @@ -2545,7 +2632,7 @@
  6.1789    from pos_bounded obtain B where B: "0 < B" "\<And>x. norm (h x) \<le> norm x * B"
  6.1790      by blast
  6.1791    have lem: "\<And>(f :: 'n \<Rightarrow> 'a) y a b.
  6.1792 -    (f has_integral y) {a..b} \<Longrightarrow> ((h o f) has_integral h y) {a..b}"
  6.1793 +    (f has_integral y) (cbox a b) \<Longrightarrow> ((h o f) has_integral h y) (cbox a b)"
  6.1794      apply (subst has_integral)
  6.1795      apply rule
  6.1796      apply rule
  6.1797 @@ -2561,7 +2648,7 @@
  6.1798        done
  6.1799      obtain g where g:
  6.1800        "gauge g"
  6.1801 -      "\<And>p. p tagged_division_of {a..b} \<Longrightarrow> g fine p \<Longrightarrow>
  6.1802 +      "\<And>p. p tagged_division_of (cbox a b) \<Longrightarrow> g fine p \<Longrightarrow>
  6.1803          norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - y) < e / B"
  6.1804        by (rule has_integralD[OF goal1(1) *]) blast
  6.1805      show ?case
  6.1806 @@ -2573,7 +2660,7 @@
  6.1807        apply (erule conjE)
  6.1808      proof -
  6.1809        fix p
  6.1810 -      assume as: "p tagged_division_of {a..b}" "g fine p"
  6.1811 +      assume as: "p tagged_division_of (cbox a b)" "g fine p"
  6.1812        have *: "\<And>x k. h ((\<lambda>(x, k). content k *\<^sub>R f x) x) = (\<lambda>(x, k). h (content k *\<^sub>R f x)) x"
  6.1813          by auto
  6.1814        have "(\<Sum>(x, k)\<in>p. content k *\<^sub>R (h \<circ> f) x) = setsum (h \<circ> (\<lambda>(x, k). content k *\<^sub>R f x)) p"
  6.1815 @@ -2590,15 +2677,15 @@
  6.1816      qed
  6.1817    qed
  6.1818    {
  6.1819 -    presume "\<not> (\<exists>a b. s = {a..b}) \<Longrightarrow> ?thesis"
  6.1820 +    presume "\<not> (\<exists>a b. s = cbox a b) \<Longrightarrow> ?thesis"
  6.1821      then show ?thesis
  6.1822        apply -
  6.1823 -      apply (cases "\<exists>a b. s = {a..b}")
  6.1824 +      apply (cases "\<exists>a b. s = cbox a b")
  6.1825        using assms
  6.1826        apply (auto simp add:has_integral intro!:lem)
  6.1827        done
  6.1828    }
  6.1829 -  assume as: "\<not> (\<exists>a b. s = {a..b})"
  6.1830 +  assume as: "\<not> (\<exists>a b. s = cbox a b)"
  6.1831    then show ?thesis
  6.1832      apply (subst has_integral_alt)
  6.1833      unfolding if_not_P
  6.1834 @@ -2611,11 +2698,11 @@
  6.1835        by (rule divide_pos_pos,rule e,rule B(1))
  6.1836      obtain M where M:
  6.1837        "M > 0"
  6.1838 -      "\<And>a b. ball 0 M \<subseteq> {a..b} \<Longrightarrow>
  6.1839 -        \<exists>z. ((\<lambda>x. if x \<in> s then f x else 0) has_integral z) {a..b} \<and> norm (z - y) < e / B"
  6.1840 +      "\<And>a b. ball 0 M \<subseteq> cbox a b \<Longrightarrow>
  6.1841 +        \<exists>z. ((\<lambda>x. if x \<in> s then f x else 0) has_integral z) (cbox a b) \<and> norm (z - y) < e / B"
  6.1842        using has_integral_altD[OF assms(1) as *] by blast
  6.1843 -    show "\<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow>
  6.1844 -      (\<exists>z. ((\<lambda>x. if x \<in> s then (h \<circ> f) x else 0) has_integral z) {a..b} \<and> norm (z - h y) < e)"
  6.1845 +    show "\<exists>B>0. \<forall>a b. ball 0 B \<subseteq> cbox a b \<longrightarrow>
  6.1846 +      (\<exists>z. ((\<lambda>x. if x \<in> s then (h \<circ> f) x else 0) has_integral z) (cbox a b) \<and> norm (z - h y) < e)"
  6.1847        apply (rule_tac x=M in exI)
  6.1848        apply rule
  6.1849        apply (rule M(1))
  6.1850 @@ -2625,7 +2712,7 @@
  6.1851      proof -
  6.1852        case goal1
  6.1853        obtain z where z:
  6.1854 -        "((\<lambda>x. if x \<in> s then f x else 0) has_integral z) {a..b}"
  6.1855 +        "((\<lambda>x. if x \<in> s then f x else 0) has_integral z) (cbox a b)"
  6.1856          "norm (z - y) < e / B"
  6.1857          using M(2)[OF goal1(1)] by blast
  6.1858        have *: "(\<lambda>x. if x \<in> s then (h \<circ> f) x else 0) = h \<circ> (\<lambda>x. if x \<in> s then f x else 0)"
  6.1859 @@ -2673,15 +2760,15 @@
  6.1860    done
  6.1861  
  6.1862  lemma has_integral_add:
  6.1863 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
  6.1864 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::real_normed_vector"
  6.1865    assumes "(f has_integral k) s"
  6.1866      and "(g has_integral l) s"
  6.1867    shows "((\<lambda>x. f x + g x) has_integral (k + l)) s"
  6.1868  proof -
  6.1869    have lem:"\<And>(f:: 'n \<Rightarrow> 'a) g a b k l.
  6.1870 -    (f has_integral k) {a..b} \<Longrightarrow>
  6.1871 -    (g has_integral l) {a..b} \<Longrightarrow>
  6.1872 -    ((\<lambda>x. f x + g x) has_integral (k + l)) {a..b}"
  6.1873 +    (f has_integral k) (cbox a b) \<Longrightarrow>
  6.1874 +    (g has_integral l) (cbox a b) \<Longrightarrow>
  6.1875 +    ((\<lambda>x. f x + g x) has_integral (k + l)) (cbox a b)"
  6.1876    proof -
  6.1877      case goal1
  6.1878      show ?case
  6.1879 @@ -2695,15 +2782,15 @@
  6.1880          by auto
  6.1881        obtain d1 where d1:
  6.1882          "gauge d1"
  6.1883 -        "\<And>p. p tagged_division_of {a..b} \<Longrightarrow> d1 fine p \<Longrightarrow>
  6.1884 +        "\<And>p. p tagged_division_of (cbox a b) \<Longrightarrow> d1 fine p \<Longrightarrow>
  6.1885            norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - k) < e / 2"
  6.1886          using has_integralD[OF goal1(1) *] by blast
  6.1887        obtain d2 where d2:
  6.1888          "gauge d2"
  6.1889 -        "\<And>p. p tagged_division_of {a..b} \<Longrightarrow> d2 fine p \<Longrightarrow>
  6.1890 +        "\<And>p. p tagged_division_of (cbox a b) \<Longrightarrow> d2 fine p \<Longrightarrow>
  6.1891            norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R g x) - l) < e / 2"
  6.1892          using has_integralD[OF goal1(2) *] by blast
  6.1893 -      show "\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
  6.1894 +      show "\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
  6.1895          norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R (f x + g x)) - (k + l)) < e)"
  6.1896          apply (rule_tac x="\<lambda>x. (d1 x) \<inter> (d2 x)" in exI)
  6.1897          apply rule
  6.1898 @@ -2711,7 +2798,7 @@
  6.1899          apply (rule,rule,erule conjE)
  6.1900        proof -
  6.1901          fix p
  6.1902 -        assume as: "p tagged_division_of {a..b}" "(\<lambda>x. d1 x \<inter> d2 x) fine p"
  6.1903 +        assume as: "p tagged_division_of (cbox a b)" "(\<lambda>x. d1 x \<inter> d2 x) fine p"
  6.1904          have *: "(\<Sum>(x, k)\<in>p. content k *\<^sub>R (f x + g x)) =
  6.1905            (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>p. content k *\<^sub>R g x)"
  6.1906            unfolding scaleR_right_distrib setsum_addf[of "\<lambda>(x,k). content k *\<^sub>R f x" "\<lambda>(x,k). content k *\<^sub>R g x" p,symmetric]
  6.1907 @@ -2735,15 +2822,15 @@
  6.1908      qed
  6.1909    qed
  6.1910    {
  6.1911 -    presume "\<not> (\<exists>a b. s = {a..b}) \<Longrightarrow> ?thesis"
  6.1912 +    presume "\<not> (\<exists>a b. s = cbox a b) \<Longrightarrow> ?thesis"
  6.1913      then show ?thesis
  6.1914        apply -
  6.1915 -      apply (cases "\<exists>a b. s = {a..b}")
  6.1916 +      apply (cases "\<exists>a b. s = cbox a b")
  6.1917        using assms
  6.1918        apply (auto simp add:has_integral intro!:lem)
  6.1919        done
  6.1920    }
  6.1921 -  assume as: "\<not> (\<exists>a b. s = {a..b})"
  6.1922 +  assume as: "\<not> (\<exists>a b. s = cbox a b)"
  6.1923    then show ?thesis
  6.1924      apply (subst has_integral_alt)
  6.1925      unfolding if_not_P
  6.1926 @@ -2756,14 +2843,14 @@
  6.1927      from has_integral_altD[OF assms(1) as *]
  6.1928      obtain B1 where B1:
  6.1929          "0 < B1"
  6.1930 -        "\<And>a b. ball 0 B1 \<subseteq> {a..b} \<Longrightarrow>
  6.1931 -          \<exists>z. ((\<lambda>x. if x \<in> s then f x else 0) has_integral z) {a..b} \<and> norm (z - k) < e / 2"
  6.1932 +        "\<And>a b. ball 0 B1 \<subseteq> cbox a b \<Longrightarrow>
  6.1933 +          \<exists>z. ((\<lambda>x. if x \<in> s then f x else 0) has_integral z) (cbox a b) \<and> norm (z - k) < e / 2"
  6.1934        by blast
  6.1935      from has_integral_altD[OF assms(2) as *]
  6.1936      obtain B2 where B2:
  6.1937          "0 < B2"
  6.1938 -        "\<And>a b. ball 0 B2 \<subseteq> {a..b} \<Longrightarrow>
  6.1939 -          \<exists>z. ((\<lambda>x. if x \<in> s then g x else 0) has_integral z) {a..b} \<and> norm (z - l) < e / 2"
  6.1940 +        "\<And>a b. ball 0 B2 \<subseteq> (cbox a b) \<Longrightarrow>
  6.1941 +          \<exists>z. ((\<lambda>x. if x \<in> s then g x else 0) has_integral z) (cbox a b) \<and> norm (z - l) < e / 2"
  6.1942        by blast
  6.1943      show ?case
  6.1944        apply (rule_tac x="max B1 B2" in exI)
  6.1945 @@ -2775,21 +2862,21 @@
  6.1946        apply rule
  6.1947      proof -
  6.1948        fix a b
  6.1949 -      assume "ball 0 (max B1 B2) \<subseteq> {a..b::'n}"
  6.1950 -      then have *: "ball 0 B1 \<subseteq> {a..b::'n}" "ball 0 B2 \<subseteq> {a..b::'n}"
  6.1951 +      assume "ball 0 (max B1 B2) \<subseteq> cbox a (b::'n)"
  6.1952 +      then have *: "ball 0 B1 \<subseteq> cbox a (b::'n)" "ball 0 B2 \<subseteq> cbox a (b::'n)"
  6.1953          by auto
  6.1954        obtain w where w:
  6.1955 -        "((\<lambda>x. if x \<in> s then f x else 0) has_integral w) {a..b}"
  6.1956 +        "((\<lambda>x. if x \<in> s then f x else 0) has_integral w) (cbox a b)"
  6.1957          "norm (w - k) < e / 2"
  6.1958          using B1(2)[OF *(1)] by blast
  6.1959        obtain z where z:
  6.1960 -        "((\<lambda>x. if x \<in> s then g x else 0) has_integral z) {a..b}"
  6.1961 +        "((\<lambda>x. if x \<in> s then g x else 0) has_integral z) (cbox a b)"
  6.1962          "norm (z - l) < e / 2"
  6.1963          using B2(2)[OF *(2)] by blast
  6.1964        have *: "\<And>x. (if x \<in> s then f x + g x else 0) =
  6.1965          (if x \<in> s then f x else 0) + (if x \<in> s then g x else 0)"
  6.1966          by auto
  6.1967 -      show "\<exists>z. ((\<lambda>x. if x \<in> s then f x + g x else 0) has_integral z) {a..b} \<and> norm (z - (k + l)) < e"
  6.1968 +      show "\<exists>z. ((\<lambda>x. if x \<in> s then f x + g x else 0) has_integral z) (cbox a b) \<and> norm (z - (k + l)) < e"
  6.1969          apply (rule_tac x="w + z" in exI)
  6.1970          apply rule
  6.1971          apply (rule lem[OF w(1) z(1), unfolded *[symmetric]])
  6.1972 @@ -2808,7 +2895,7 @@
  6.1973    by auto
  6.1974  
  6.1975  lemma integral_0:
  6.1976 -  "integral s (\<lambda>x::'n::ordered_euclidean_space. 0::'m::real_normed_vector) = 0"
  6.1977 +  "integral s (\<lambda>x::'n::euclidean_space. 0::'m::real_normed_vector) = 0"
  6.1978    by (rule integral_unique has_integral_0)+
  6.1979  
  6.1980  lemma integral_add: "f integrable_on s \<Longrightarrow> g integrable_on s \<Longrightarrow>
  6.1981 @@ -2880,7 +2967,7 @@
  6.1982    done
  6.1983  
  6.1984  lemma integral_component_eq[simp]:
  6.1985 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
  6.1986 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  6.1987    assumes "f integrable_on s"
  6.1988    shows "integral s (\<lambda>x. f x \<bullet> k) = integral s f \<bullet> k"
  6.1989    unfolding integral_linear[OF assms(1) bounded_linear_component,unfolded o_def] ..
  6.1990 @@ -2938,8 +3025,8 @@
  6.1991    by auto
  6.1992  
  6.1993  lemma has_integral_null[dest]:
  6.1994 -  assumes "content({a..b}) = 0"
  6.1995 -  shows "(f has_integral 0) ({a..b})"
  6.1996 +  assumes "content(cbox a b) = 0"
  6.1997 +  shows "(f has_integral 0) (cbox a b)"
  6.1998    unfolding has_integral
  6.1999    apply rule
  6.2000    apply rule
  6.2001 @@ -2955,7 +3042,7 @@
  6.2002    then show "gauge (\<lambda>x. ball x 1)"
  6.2003      by auto
  6.2004    fix p
  6.2005 -  assume p: "p tagged_division_of {a..b}"
  6.2006 +  assume p: "p tagged_division_of (cbox a b)"
  6.2007    have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) = 0"
  6.2008      unfolding norm_eq_zero diff_0_right
  6.2009      using setsum_content_null[OF assms(1) p, of f] .
  6.2010 @@ -2963,7 +3050,12 @@
  6.2011      using e by auto
  6.2012  qed
  6.2013  
  6.2014 -lemma has_integral_null_eq[simp]: "content {a..b} = 0 \<Longrightarrow> (f has_integral i) {a..b} \<longleftrightarrow> i = 0"
  6.2015 +lemma has_integral_null_real[dest]:
  6.2016 +  assumes "content {a .. b::real} = 0"
  6.2017 +  shows "(f has_integral 0) {a .. b}"
  6.2018 +  by (metis assms box_real(2) has_integral_null)
  6.2019 +
  6.2020 +lemma has_integral_null_eq[simp]: "content (cbox a b) = 0 \<Longrightarrow> (f has_integral i) (cbox a b) \<longleftrightarrow> i = 0"
  6.2021    apply rule
  6.2022    apply (rule has_integral_unique)
  6.2023    apply assumption
  6.2024 @@ -2972,13 +3064,13 @@
  6.2025    apply auto
  6.2026    done
  6.2027  
  6.2028 -lemma integral_null[dest]: "content {a..b} = 0 \<Longrightarrow> integral {a..b} f = 0"
  6.2029 +lemma integral_null[dest]: "content (cbox a b) = 0 \<Longrightarrow> integral (cbox a b) f = 0"
  6.2030    apply (rule integral_unique)
  6.2031    apply (drule has_integral_null)
  6.2032    apply assumption
  6.2033    done
  6.2034  
  6.2035 -lemma integrable_on_null[dest]: "content {a..b} = 0 \<Longrightarrow> f integrable_on {a..b}"
  6.2036 +lemma integrable_on_null[dest]: "content (cbox a b) = 0 \<Longrightarrow> f integrable_on (cbox a b)"
  6.2037    unfolding integrable_on_def
  6.2038    apply (drule has_integral_null)
  6.2039    apply auto
  6.2040 @@ -3006,32 +3098,32 @@
  6.2041    by (rule integral_unique) (rule has_integral_empty)
  6.2042  
  6.2043  lemma has_integral_refl[intro]:
  6.2044 -  fixes a :: "'a::ordered_euclidean_space"
  6.2045 -  shows "(f has_integral 0) {a..a}"
  6.2046 +  fixes a :: "'a::euclidean_space"
  6.2047 +  shows "(f has_integral 0) (cbox a a)"
  6.2048      and "(f has_integral 0) {a}"
  6.2049  proof -
  6.2050 -  have *: "{a} = {a..a}"
  6.2051 +  have *: "{a} = cbox a a"
  6.2052      apply (rule set_eqI)
  6.2053 -    unfolding mem_interval singleton_iff euclidean_eq_iff[where 'a='a]
  6.2054 +    unfolding mem_box singleton_iff euclidean_eq_iff[where 'a='a]
  6.2055      apply safe
  6.2056      prefer 3
  6.2057      apply (erule_tac x=b in ballE)
  6.2058      apply (auto simp add: field_simps)
  6.2059      done
  6.2060 -  show "(f has_integral 0) {a..a}" "(f has_integral 0) {a}"
  6.2061 +  show "(f has_integral 0) (cbox a a)" "(f has_integral 0) {a}"
  6.2062      unfolding *
  6.2063      apply (rule_tac[!] has_integral_null)
  6.2064      unfolding content_eq_0_interior
  6.2065 -    unfolding interior_closed_interval
  6.2066 -    using interval_sing
  6.2067 -    apply auto
  6.2068 -    done
  6.2069 -qed
  6.2070 -
  6.2071 -lemma integrable_on_refl[intro]: "f integrable_on {a..a}"
  6.2072 +    unfolding interior_cbox
  6.2073 +    using box_sing
  6.2074 +    apply auto
  6.2075 +    done
  6.2076 +qed
  6.2077 +
  6.2078 +lemma integrable_on_refl[intro]: "f integrable_on cbox a a"
  6.2079    unfolding integrable_on_def by auto
  6.2080  
  6.2081 -lemma integral_refl: "integral {a..a} f = 0"
  6.2082 +lemma integral_refl: "integral (cbox a a) f = 0"
  6.2083    by (rule integral_unique) auto
  6.2084  
  6.2085  
  6.2086 @@ -3039,11 +3131,11 @@
  6.2087  
  6.2088  (* XXXXXXX *)
  6.2089  lemma integrable_cauchy:
  6.2090 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::{real_normed_vector,complete_space}"
  6.2091 -  shows "f integrable_on {a..b} \<longleftrightarrow>
  6.2092 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::{real_normed_vector,complete_space}"
  6.2093 +  shows "f integrable_on cbox a b \<longleftrightarrow>
  6.2094      (\<forall>e>0.\<exists>d. gauge d \<and>
  6.2095 -      (\<forall>p1 p2. p1 tagged_division_of {a..b} \<and> d fine p1 \<and>
  6.2096 -        p2 tagged_division_of {a..b} \<and> d fine p2 \<longrightarrow>
  6.2097 +      (\<forall>p1 p2. p1 tagged_division_of (cbox a b) \<and> d fine p1 \<and>
  6.2098 +        p2 tagged_division_of (cbox a b) \<and> d fine p2 \<longrightarrow>
  6.2099          norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p1 -
  6.2100          setsum (\<lambda>(x,k). content k *\<^sub>R f x) p2) < e))"
  6.2101    (is "?l = (\<forall>e>0. \<exists>d. ?P e d)")
  6.2102 @@ -3070,8 +3162,8 @@
  6.2103        apply (erule conjE)+
  6.2104      proof -
  6.2105        fix p1 p2
  6.2106 -      assume as: "p1 tagged_division_of {a..b}" "d fine p1"
  6.2107 -        "p2 tagged_division_of {a..b}" "d fine p2"
  6.2108 +      assume as: "p1 tagged_division_of (cbox a b)" "d fine p1"
  6.2109 +        "p2 tagged_division_of (cbox a b)" "d fine p2"
  6.2110        show "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)) < e"
  6.2111          apply (rule dist_triangle_half_l[where y=y,unfolded dist_norm])
  6.2112          using d(2)[OF conjI[OF as(1-2)]] d(2)[OF conjI[OF as(3-4)]] .
  6.2113 @@ -3087,7 +3179,7 @@
  6.2114      using d(1)
  6.2115      apply auto
  6.2116      done
  6.2117 -  then have "\<forall>n. \<exists>p. p tagged_division_of {a..b} \<and> (\<lambda>x. \<Inter>{d i x |i. i \<in> {0..n}}) fine p"
  6.2118 +  then have "\<forall>n. \<exists>p. p tagged_division_of (cbox a b) \<and> (\<lambda>x. \<Inter>{d i x |i. i \<in> {0..n}}) fine p"
  6.2119      apply -
  6.2120    proof
  6.2121      case goal1
  6.2122 @@ -3133,7 +3225,7 @@
  6.2123        by auto
  6.2124      guess N2 using y[OF *] .. note N2=this
  6.2125      show "\<exists>d. gauge d \<and>
  6.2126 -      (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
  6.2127 +      (\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
  6.2128          norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - y) < e)"
  6.2129        apply (rule_tac x="d (N1 + N2)" in exI)
  6.2130        apply rule
  6.2131 @@ -3142,7 +3234,7 @@
  6.2132        show "gauge (d (N1 + N2))"
  6.2133          using d by auto
  6.2134        fix q
  6.2135 -      assume as: "q tagged_division_of {a..b}" "d (N1 + N2) fine q"
  6.2136 +      assume as: "q tagged_division_of (cbox a b)" "d (N1 + N2) fine q"
  6.2137        have *: "inverse (real (N1 + N2 + 1)) < e / 2"
  6.2138          apply (rule less_trans)
  6.2139          using N1
  6.2140 @@ -3167,23 +3259,23 @@
  6.2141  subsection {* Additivity of integral on abutting intervals. *}
  6.2142  
  6.2143  lemma interval_split:
  6.2144 -  fixes a :: "'a::ordered_euclidean_space"
  6.2145 +  fixes a :: "'a::euclidean_space"
  6.2146    assumes "k \<in> Basis"
  6.2147    shows
  6.2148 -    "{a..b} \<inter> {x. x\<bullet>k \<le> c} = {a .. (\<Sum>i\<in>Basis. (if i = k then min (b\<bullet>k) c else b\<bullet>i) *\<^sub>R i)}"
  6.2149 -    "{a..b} \<inter> {x. x\<bullet>k \<ge> c} = {(\<Sum>i\<in>Basis. (if i = k then max (a\<bullet>k) c else a\<bullet>i) *\<^sub>R i) .. b}"
  6.2150 +    "cbox a b \<inter> {x. x\<bullet>k \<le> c} = cbox a (\<Sum>i\<in>Basis. (if i = k then min (b\<bullet>k) c else b\<bullet>i) *\<^sub>R i)"
  6.2151 +    "cbox a b \<inter> {x. x\<bullet>k \<ge> c} = cbox (\<Sum>i\<in>Basis. (if i = k then max (a\<bullet>k) c else a\<bullet>i) *\<^sub>R i) b"
  6.2152    apply (rule_tac[!] set_eqI)
  6.2153 -  unfolding Int_iff mem_interval mem_Collect_eq
  6.2154 +  unfolding Int_iff mem_box mem_Collect_eq
  6.2155    using assms
  6.2156    apply auto
  6.2157    done
  6.2158  
  6.2159  lemma content_split:
  6.2160 -  fixes a :: "'a::ordered_euclidean_space"
  6.2161 +  fixes a :: "'a::euclidean_space"
  6.2162    assumes "k \<in> Basis"
  6.2163 -  shows "content {a..b} = content({a..b} \<inter> {x. x\<bullet>k \<le> c}) + content({a..b} \<inter> {x. x\<bullet>k \<ge> c})"
  6.2164 +  shows "content (cbox a b) = content(cbox a b \<inter> {x. x\<bullet>k \<le> c}) + content(cbox a b \<inter> {x. x\<bullet>k \<ge> c})"
  6.2165  proof cases
  6.2166 -  note simps = interval_split[OF assms] content_closed_interval_cases eucl_le[where 'a='a]
  6.2167 +  note simps = interval_split[OF assms] content_cbox_cases
  6.2168    have *: "Basis = insert k (Basis - {k})" "\<And>x. finite (Basis-{x})" "\<And>x. x\<notin>Basis-{x}"
  6.2169      using assms by auto
  6.2170    have *: "\<And>X Y Z. (\<Prod>i\<in>Basis. Z i (if i = k then X else Y i)) = Z k X * (\<Prod>i\<in>Basis-{k}. Z i (Y i))"
  6.2171 @@ -3194,7 +3286,7 @@
  6.2172      unfolding setprod_insert[OF *(2-)]
  6.2173      apply auto
  6.2174      done
  6.2175 -  assume as: "a \<le> b"
  6.2176 +  assume as: "\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i"
  6.2177    moreover
  6.2178    have "\<And>x. min (b \<bullet> k) c = max (a \<bullet> k) c \<Longrightarrow>
  6.2179      x * (b\<bullet>k - a\<bullet>k) = x * (max (a \<bullet> k) c - a \<bullet> k) + x * (b \<bullet> k - max (a \<bullet> k) c)"
  6.2180 @@ -3207,7 +3299,7 @@
  6.2181      by (auto intro!: setprod_cong)
  6.2182    have "\<not> a \<bullet> k \<le> c \<Longrightarrow> \<not> c \<le> b \<bullet> k \<Longrightarrow> False"
  6.2183      unfolding not_le
  6.2184 -    using as[unfolded eucl_le[where 'a='a],rule_format,of k] assms
  6.2185 +    using as[unfolded ,rule_format,of k] assms
  6.2186      by auto
  6.2187    ultimately show ?thesis
  6.2188      using assms
  6.2189 @@ -3216,15 +3308,15 @@
  6.2190      unfolding *(2)
  6.2191      by auto
  6.2192  next
  6.2193 -  assume "\<not> a \<le> b"
  6.2194 -  then have "{a .. b} = {}"
  6.2195 -    unfolding interval_eq_empty by (auto simp: eucl_le[where 'a='a] not_le)
  6.2196 +  assume "\<not> (\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i)"
  6.2197 +  then have "cbox a b = {}"
  6.2198 +    unfolding box_eq_empty by (auto simp: not_le)
  6.2199    then show ?thesis
  6.2200      by (auto simp: not_le)
  6.2201  qed
  6.2202  
  6.2203  lemma division_split_left_inj:
  6.2204 -  fixes type :: "'a::ordered_euclidean_space"
  6.2205 +  fixes type :: "'a::euclidean_space"
  6.2206    assumes "d division_of i"
  6.2207      and "k1 \<in> d"
  6.2208      and "k2 \<in> d"
  6.2209 @@ -3234,8 +3326,8 @@
  6.2210    shows "content(k1 \<inter> {x. x\<bullet>k \<le> c}) = 0"
  6.2211  proof -
  6.2212    note d=division_ofD[OF assms(1)]
  6.2213 -  have *: "\<And>(a::'a) b c. content ({a..b} \<inter> {x. x\<bullet>k \<le> c}) = 0 \<longleftrightarrow>
  6.2214 -    interior({a..b} \<inter> {x. x\<bullet>k \<le> c}) = {}"
  6.2215 +  have *: "\<And>(a::'a) b c. content (cbox a b \<inter> {x. x\<bullet>k \<le> c}) = 0 \<longleftrightarrow>
  6.2216 +    interior(cbox a b \<inter> {x. x\<bullet>k \<le> c}) = {}"
  6.2217      unfolding  interval_split[OF k] content_eq_0_interior by auto
  6.2218    guess u1 v1 using d(4)[OF assms(2)] by (elim exE) note uv1=this
  6.2219    guess u2 v2 using d(4)[OF assms(3)] by (elim exE) note uv2=this
  6.2220 @@ -3252,7 +3344,7 @@
  6.2221  qed
  6.2222  
  6.2223  lemma division_split_right_inj:
  6.2224 -  fixes type :: "'a::ordered_euclidean_space"
  6.2225 +  fixes type :: "'a::euclidean_space"
  6.2226    assumes "d division_of i"
  6.2227      and "k1 \<in> d"
  6.2228      and "k2 \<in> d"
  6.2229 @@ -3262,8 +3354,8 @@
  6.2230    shows "content (k1 \<inter> {x. x\<bullet>k \<ge> c}) = 0"
  6.2231  proof -
  6.2232    note d=division_ofD[OF assms(1)]
  6.2233 -  have *: "\<And>a b::'a. \<And>c. content({a..b} \<inter> {x. x\<bullet>k \<ge> c}) = 0 \<longleftrightarrow>
  6.2234 -    interior({a..b} \<inter> {x. x\<bullet>k \<ge> c}) = {}"
  6.2235 +  have *: "\<And>a b::'a. \<And>c. content(cbox a b \<inter> {x. x\<bullet>k \<ge> c}) = 0 \<longleftrightarrow>
  6.2236 +    interior(cbox a b \<inter> {x. x\<bullet>k \<ge> c}) = {}"
  6.2237      unfolding interval_split[OF k] content_eq_0_interior by auto
  6.2238    guess u1 v1 using d(4)[OF assms(2)] by (elim exE) note uv1=this
  6.2239    guess u2 v2 using d(4)[OF assms(3)] by (elim exE) note uv2=this
  6.2240 @@ -3280,7 +3372,7 @@
  6.2241  qed
  6.2242  
  6.2243  lemma tagged_division_split_left_inj:
  6.2244 -  fixes x1 :: "'a::ordered_euclidean_space"
  6.2245 +  fixes x1 :: "'a::euclidean_space"
  6.2246    assumes "d tagged_division_of i"
  6.2247      and "(x1, k1) \<in> d"
  6.2248      and "(x2, k2) \<in> d"
  6.2249 @@ -3303,7 +3395,7 @@
  6.2250  qed
  6.2251  
  6.2252  lemma tagged_division_split_right_inj:
  6.2253 -  fixes x1 :: "'a::ordered_euclidean_space"
  6.2254 +  fixes x1 :: "'a::euclidean_space"
  6.2255    assumes "d tagged_division_of i"
  6.2256      and "(x1, k1) \<in> d"
  6.2257      and "(x2, k2) \<in> d"
  6.2258 @@ -3326,12 +3418,12 @@
  6.2259  qed
  6.2260  
  6.2261  lemma division_split:
  6.2262 -  fixes a :: "'a::ordered_euclidean_space"
  6.2263 -  assumes "p division_of {a..b}"
  6.2264 +  fixes a :: "'a::euclidean_space"
  6.2265 +  assumes "p division_of (cbox a b)"
  6.2266      and k: "k\<in>Basis"
  6.2267 -  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({a..b} \<inter> {x. x\<bullet>k \<le> c})"
  6.2268 +  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})"
  6.2269        (is "?p1 division_of ?I1")
  6.2270 -    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 ({a..b} \<inter> {x. x\<bullet>k \<ge> c})"
  6.2271 +    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})"
  6.2272        (is "?p2 division_of ?I2")
  6.2273  proof (rule_tac[!] division_ofI)
  6.2274    note p = division_ofD[OF assms(1)]
  6.2275 @@ -3344,7 +3436,7 @@
  6.2276      assume "k \<in> ?p1"
  6.2277      then guess l unfolding mem_Collect_eq by (elim exE conjE) note l=this
  6.2278      guess u v using p(4)[OF l(2)] by (elim exE) note uv=this
  6.2279 -    show "k \<subseteq> ?I1" "k \<noteq> {}" "\<exists>a b. k = {a..b}"
  6.2280 +    show "k \<subseteq> ?I1" "k \<noteq> {}" "\<exists>a b. k = cbox a b"
  6.2281        unfolding l
  6.2282        using p(2-3)[OF l(2)] l(3)
  6.2283        unfolding uv
  6.2284 @@ -3365,7 +3457,7 @@
  6.2285      assume "k \<in> ?p2"
  6.2286      then guess l unfolding mem_Collect_eq by (elim exE conjE) note l=this
  6.2287      guess u v using p(4)[OF l(2)] by (elim exE) note uv=this
  6.2288 -    show "k \<subseteq> ?I2" "k \<noteq> {}" "\<exists>a b. k = {a..b}"
  6.2289 +    show "k \<subseteq> ?I2" "k \<noteq> {}" "\<exists>a b. k = cbox a b"
  6.2290        unfolding l
  6.2291        using p(2-3)[OF l(2)] l(3)
  6.2292        unfolding uv
  6.2293 @@ -3384,11 +3476,11 @@
  6.2294  qed
  6.2295  
  6.2296  lemma has_integral_split:
  6.2297 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
  6.2298 -  assumes "(f has_integral i) ({a..b} \<inter> {x. x\<bullet>k \<le> c})"
  6.2299 -    and "(f has_integral j) ({a..b} \<inter> {x. x\<bullet>k \<ge> c})"
  6.2300 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
  6.2301 +  assumes "(f has_integral i) (cbox a b \<inter> {x. x\<bullet>k \<le> c})"
  6.2302 +    and "(f has_integral j) (cbox a b \<inter> {x. x\<bullet>k \<ge> c})"
  6.2303      and k: "k \<in> Basis"
  6.2304 -  shows "(f has_integral (i + j)) ({a..b})"
  6.2305 +  shows "(f has_integral (i + j)) (cbox a b)"
  6.2306  proof (unfold has_integral, rule, rule)
  6.2307    case goal1
  6.2308    then have e: "e/2 > 0"
  6.2309 @@ -3409,7 +3501,7 @@
  6.2310      show "gauge ?d"
  6.2311        using d1(1) d2(1) unfolding gauge_def by auto
  6.2312      fix p
  6.2313 -    assume "p tagged_division_of {a..b}" "?d fine p"
  6.2314 +    assume "p tagged_division_of (cbox a b)" "?d fine p"
  6.2315      note p = this tagged_division_ofD[OF this(1)]
  6.2316      have lem0:
  6.2317        "\<And>x kk. (x, kk) \<in> p \<Longrightarrow> kk \<inter> {x. x\<bullet>k \<le> c} \<noteq> {} \<Longrightarrow> x\<bullet>k \<le> c"
  6.2318 @@ -3499,7 +3591,7 @@
  6.2319        prefer 6
  6.2320        apply (rule fineI)
  6.2321      proof -
  6.2322 -      show "\<Union>{k. \<exists>x. (x, k) \<in> ?M1} = {a..b} \<inter> {x. x\<bullet>k \<le> c}"
  6.2323 +      show "\<Union>{k. \<exists>x. (x, k) \<in> ?M1} = cbox a b \<inter> {x. x\<bullet>k \<le> c}"
  6.2324          unfolding p(8)[symmetric] by auto
  6.2325        fix x l
  6.2326        assume xl: "(x, l) \<in> ?M1"
  6.2327 @@ -3510,11 +3602,11 @@
  6.2328          done
  6.2329        then show "l \<subseteq> d1 x"
  6.2330          unfolding xl' by auto
  6.2331 -      show "x \<in> l" "l \<subseteq> {a..b} \<inter> {x. x \<bullet> k \<le> c}"
  6.2332 +      show "x \<in> l" "l \<subseteq> cbox a b \<inter> {x. x \<bullet> k \<le> c}"
  6.2333          unfolding xl'
  6.2334          using p(4-6)[OF xl'(3)] using xl'(4)
  6.2335          using lem0(1)[OF xl'(3-4)] by auto
  6.2336 -      show "\<exists>a b. l = {a..b}"
  6.2337 +      show "\<exists>a b. l = cbox a b"
  6.2338          unfolding xl'
  6.2339          using p(6)[OF xl'(3)]
  6.2340          by (fastforce simp add: interval_split[OF k,where c=c])
  6.2341 @@ -3544,7 +3636,7 @@
  6.2342        prefer 6
  6.2343        apply (rule fineI)
  6.2344      proof -
  6.2345 -      show "\<Union>{k. \<exists>x. (x, k) \<in> ?M2} = {a..b} \<inter> {x. x\<bullet>k \<ge> c}"
  6.2346 +      show "\<Union>{k. \<exists>x. (x, k) \<in> ?M2} = cbox a b \<inter> {x. x\<bullet>k \<ge> c}"
  6.2347          unfolding p(8)[symmetric] by auto
  6.2348        fix x l
  6.2349        assume xl: "(x, l) \<in> ?M2"
  6.2350 @@ -3555,13 +3647,13 @@
  6.2351          done
  6.2352        then show "l \<subseteq> d2 x"
  6.2353          unfolding xl' by auto
  6.2354 -      show "x \<in> l" "l \<subseteq> {a..b} \<inter> {x. x \<bullet> k \<ge> c}"
  6.2355 +      show "x \<in> l" "l \<subseteq> cbox a b \<inter> {x. x \<bullet> k \<ge> c}"
  6.2356          unfolding xl'
  6.2357          using p(4-6)[OF xl'(3)]
  6.2358          using xl'(4)
  6.2359          using lem0(2)[OF xl'(3-4)]
  6.2360          by auto
  6.2361 -      show "\<exists>a b. l = {a..b}"
  6.2362 +      show "\<exists>a b. l = cbox a b"
  6.2363          unfolding xl'
  6.2364          using p(6)[OF xl'(3)]
  6.2365          by (fastforce simp add: interval_split[OF k, where c=c])
  6.2366 @@ -3654,31 +3746,41 @@
  6.2367  subsection {* A sort of converse, integrability on subintervals. *}
  6.2368  
  6.2369  lemma tagged_division_union_interval:
  6.2370 -  fixes a :: "'a::ordered_euclidean_space"
  6.2371 -  assumes "p1 tagged_division_of ({a..b} \<inter> {x. x\<bullet>k \<le> (c::real)})"
  6.2372 -    and "p2 tagged_division_of ({a..b} \<inter> {x. x\<bullet>k \<ge> c})"
  6.2373 +  fixes a :: "'a::euclidean_space"
  6.2374 +  assumes "p1 tagged_division_of (cbox a b \<inter> {x. x\<bullet>k \<le> (c::real)})"
  6.2375 +    and "p2 tagged_division_of (cbox a b \<inter> {x. x\<bullet>k \<ge> c})"
  6.2376      and k: "k \<in> Basis"
  6.2377 -  shows "(p1 \<union> p2) tagged_division_of ({a..b})"
  6.2378 -proof -
  6.2379 -  have *: "{a..b} = ({a..b} \<inter> {x. x\<bullet>k \<le> c}) \<union> ({a..b} \<inter> {x. x\<bullet>k \<ge> c})"
  6.2380 +  shows "(p1 \<union> p2) tagged_division_of (cbox a b)"
  6.2381 +proof -
  6.2382 +  have *: "cbox a b = (cbox a b \<inter> {x. x\<bullet>k \<le> c}) \<union> (cbox a b \<inter> {x. x\<bullet>k \<ge> c})"
  6.2383      by auto
  6.2384    show ?thesis
  6.2385      apply (subst *)
  6.2386      apply (rule tagged_division_union[OF assms(1-2)])
  6.2387 -    unfolding interval_split[OF k] interior_closed_interval
  6.2388 +    unfolding interval_split[OF k] interior_cbox
  6.2389      using k
  6.2390 -    apply (auto simp add: interval elim!: ballE[where x=k])
  6.2391 -    done
  6.2392 -qed
  6.2393 +    apply (auto simp add: box elim!: ballE[where x=k])
  6.2394 +    done
  6.2395 +qed
  6.2396 +
  6.2397 +lemma tagged_division_union_interval_real:
  6.2398 +  fixes a :: real
  6.2399 +  assumes "p1 tagged_division_of ({a .. b} \<inter> {x. x\<bullet>k \<le> (c::real)})"
  6.2400 +    and "p2 tagged_division_of ({a .. b} \<inter> {x. x\<bullet>k \<ge> c})"
  6.2401 +    and k: "k \<in> Basis"
  6.2402 +  shows "(p1 \<union> p2) tagged_division_of {a .. b}"
  6.2403 +  using assms
  6.2404 +  unfolding box_real[symmetric]
  6.2405 +  by (rule tagged_division_union_interval)
  6.2406  
  6.2407  lemma has_integral_separate_sides:
  6.2408 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
  6.2409 -  assumes "(f has_integral i) ({a..b})"
  6.2410 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
  6.2411 +  assumes "(f has_integral i) (cbox a b)"
  6.2412      and "e > 0"
  6.2413      and k: "k \<in> Basis"
  6.2414    obtains d where "gauge d"
  6.2415 -    "\<forall>p1 p2. p1 tagged_division_of ({a..b} \<inter> {x. x\<bullet>k \<le> c}) \<and> d fine p1 \<and>
  6.2416 -        p2 tagged_division_of ({a..b} \<inter> {x. x\<bullet>k \<ge> c}) \<and> d fine p2 \<longrightarrow>
  6.2417 +    "\<forall>p1 p2. p1 tagged_division_of (cbox a b \<inter> {x. x\<bullet>k \<le> c}) \<and> d fine p1 \<and>
  6.2418 +        p2 tagged_division_of (cbox a b \<inter> {x. x\<bullet>k \<ge> c}) \<and> d fine p2 \<longrightarrow>
  6.2419          norm ((setsum (\<lambda>(x,k). content k *\<^sub>R f x) p1 + setsum (\<lambda>(x,k). content k *\<^sub>R f x) p2) - i) < e"
  6.2420  proof -
  6.2421    guess d using has_integralD[OF assms(1-2)] . note d=this
  6.2422 @@ -3691,9 +3793,9 @@
  6.2423      apply (elim conjE)
  6.2424    proof -
  6.2425      fix p1 p2
  6.2426 -    assume "p1 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<le> c}" "d fine p1"
  6.2427 +    assume "p1 tagged_division_of (cbox a b) \<inter> {x. x \<bullet> k \<le> c}" "d fine p1"
  6.2428      note p1=tagged_division_ofD[OF this(1)] this
  6.2429 -    assume "p2 tagged_division_of {a..b} \<inter> {x. c \<le> x \<bullet> k}" "d fine p2"
  6.2430 +    assume "p2 tagged_division_of (cbox a b) \<inter> {x. c \<le> x \<bullet> k}" "d fine p2"
  6.2431      note p2=tagged_division_ofD[OF this(1)] this
  6.2432      note tagged_division_union_interval[OF p1(7) p2(7)] note p12 = tagged_division_ofD[OF this] this
  6.2433      have "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x) - i) =
  6.2434 @@ -3755,11 +3857,11 @@
  6.2435  qed
  6.2436  
  6.2437  lemma integrable_split[intro]:
  6.2438 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::{real_normed_vector,complete_space}"
  6.2439 -  assumes "f integrable_on {a..b}"
  6.2440 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::{real_normed_vector,complete_space}"
  6.2441 +  assumes "f integrable_on cbox a b"
  6.2442      and k: "k \<in> Basis"
  6.2443 -  shows "f integrable_on ({a..b} \<inter> {x. x\<bullet>k \<le> c})" (is ?t1)
  6.2444 -    and "f integrable_on ({a..b} \<inter> {x. x\<bullet>k \<ge> c})" (is ?t2)
  6.2445 +  shows "f integrable_on (cbox a b \<inter> {x. x\<bullet>k \<le> c})" (is ?t1)
  6.2446 +    and "f integrable_on (cbox a b \<inter> {x. x\<bullet>k \<ge> c})" (is ?t2)
  6.2447  proof -
  6.2448    guess y using assms(1) unfolding integrable_on_def .. note y=this
  6.2449    def b' \<equiv> "\<Sum>i\<in>Basis. (if i = k then min (b\<bullet>k) c else b\<bullet>i)*\<^sub>R i::'a"
  6.2450 @@ -3773,8 +3875,8 @@
  6.2451      then have "e/2>0"
  6.2452        by auto
  6.2453      from has_integral_separate_sides[OF y this k,of c] guess d . note d=this[rule_format]
  6.2454 -    let ?P = "\<lambda>A. \<exists>d. gauge d \<and> (\<forall>p1 p2. p1 tagged_division_of {a..b} \<inter> A \<and> d fine p1 \<and>
  6.2455 -      p2 tagged_division_of {a..b} \<inter> A \<and> d fine p2 \<longrightarrow>
  6.2456 +    let ?P = "\<lambda>A. \<exists>d. gauge d \<and> (\<forall>p1 p2. p1 tagged_division_of (cbox a b) \<inter> A \<and> d fine p1 \<and>
  6.2457 +      p2 tagged_division_of (cbox a b) \<inter> A \<and> d fine p2 \<longrightarrow>
  6.2458        norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)) < e)"
  6.2459      show "?P {x. x \<bullet> k \<le> c}"
  6.2460        apply (rule_tac x=d in exI)
  6.2461 @@ -3785,8 +3887,8 @@
  6.2462        apply rule
  6.2463      proof -
  6.2464        fix p1 p2
  6.2465 -      assume as: "p1 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<le> c} \<and> d fine p1 \<and>
  6.2466 -        p2 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<le> c} \<and> d fine p2"
  6.2467 +      assume as: "p1 tagged_division_of (cbox a b) \<inter> {x. x \<bullet> k \<le> c} \<and> d fine p1 \<and>
  6.2468 +        p2 tagged_division_of (cbox a b) \<inter> {x. x \<bullet> k \<le> c} \<and> d fine p2"
  6.2469        show "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)) < e"
  6.2470        proof -
  6.2471          guess p using fine_division_exists[OF d(1), of a' b] . note p=this
  6.2472 @@ -3806,8 +3908,8 @@
  6.2473        apply rule
  6.2474      proof -
  6.2475        fix p1 p2
  6.2476 -      assume as: "p1 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<ge> c} \<and> d fine p1 \<and>
  6.2477 -        p2 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<ge> c} \<and> d fine p2"
  6.2478 +      assume as: "p1 tagged_division_of (cbox a b) \<inter> {x. x \<bullet> k \<ge> c} \<and> d fine p1 \<and>
  6.2479 +        p2 tagged_division_of (cbox a b) \<inter> {x. x \<bullet> k \<ge> c} \<and> d fine p2"
  6.2480        show "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)) < e"
  6.2481        proof -
  6.2482          guess p using fine_division_exists[OF d(1), of a b'] . note p=this
  6.2483 @@ -3828,23 +3930,23 @@
  6.2484  
  6.2485  definition "neutral opp = (SOME x. \<forall>y. opp x y = y \<and> opp y x = y)"
  6.2486  
  6.2487 -definition operative :: "('a \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> (('b::ordered_euclidean_space) set \<Rightarrow> 'a) \<Rightarrow> bool"
  6.2488 +definition operative :: "('a \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> (('b::euclidean_space) set \<Rightarrow> 'a) \<Rightarrow> bool"
  6.2489    where "operative opp f \<longleftrightarrow>
  6.2490 -    (\<forall>a b. content {a..b} = 0 \<longrightarrow> f {a..b} = neutral opp) \<and>
  6.2491 -    (\<forall>a b c. \<forall>k\<in>Basis. f {a..b} = opp (f({a..b} \<inter> {x. x\<bullet>k \<le> c})) (f ({a..b} \<inter> {x. x\<bullet>k \<ge> c})))"
  6.2492 +    (\<forall>a b. content (cbox a b) = 0 \<longrightarrow> f (cbox a b) = neutral opp) \<and>
  6.2493 +    (\<forall>a b c. \<forall>k\<in>Basis. f (cbox a b) = opp (f(cbox a b \<inter> {x. x\<bullet>k \<le> c})) (f (cbox a b \<inter> {x. x\<bullet>k \<ge> c})))"
  6.2494  
  6.2495  lemma operativeD[dest]:
  6.2496 -  fixes type :: "'a::ordered_euclidean_space"
  6.2497 +  fixes type :: "'a::euclidean_space"
  6.2498    assumes "operative opp f"
  6.2499 -  shows "\<And>a b::'a. content {a..b} = 0 \<Longrightarrow> f {a..b} = neutral opp"
  6.2500 -    and "\<And>a b c k. k \<in> Basis \<Longrightarrow> f {a..b} =
  6.2501 -      opp (f ({a..b} \<inter> {x. x\<bullet>k \<le> c})) (f ({a..b} \<inter> {x. x\<bullet>k \<ge> c}))"
  6.2502 +  shows "\<And>a b::'a. content (cbox a b) = 0 \<Longrightarrow> f (cbox a b) = neutral opp"
  6.2503 +    and "\<And>a b c k. k \<in> Basis \<Longrightarrow> f (cbox a b) =
  6.2504 +      opp (f (cbox a b \<inter> {x. x\<bullet>k \<le> c})) (f (cbox a b \<inter> {x. x\<bullet>k \<ge> c}))"
  6.2505    using assms unfolding operative_def by auto
  6.2506  
  6.2507 -lemma operative_trivial: "operative opp f \<Longrightarrow> content {a..b} = 0 \<Longrightarrow> f {a..b} = neutral opp"
  6.2508 +lemma operative_trivial: "operative opp f \<Longrightarrow> content (cbox a b) = 0 \<Longrightarrow> f (cbox a b) = neutral opp"
  6.2509    unfolding operative_def by auto
  6.2510  
  6.2511 -lemma property_empty_interval: "\<forall>a b. content {a..b} = 0 \<longrightarrow> P {a..b} \<Longrightarrow> P {}"
  6.2512 +lemma property_empty_interval: "\<forall>a b. content (cbox a b) = 0 \<longrightarrow> P (cbox a b) \<Longrightarrow> P {}"
  6.2513    using content_empty unfolding empty_as_interval by auto
  6.2514  
  6.2515  lemma operative_empty: "operative opp f \<Longrightarrow> f {} = neutral opp"
  6.2516 @@ -4042,7 +4144,7 @@
  6.2517    by (auto simp add: algebra_simps)
  6.2518  
  6.2519  lemma operative_integral:
  6.2520 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
  6.2521 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::banach"
  6.2522    shows "operative (lifted(op +)) (\<lambda>i. if f integrable_on i then Some(integral i f) else None)"
  6.2523    unfolding operative_def
  6.2524    unfolding neutral_lifted[OF monoidal_monoid] neutral_add
  6.2525 @@ -4056,10 +4158,10 @@
  6.2526    fix a b c
  6.2527    fix k :: 'a
  6.2528    assume k: "k \<in> Basis"
  6.2529 -  show "(if f integrable_on {a..b} then Some (integral {a..b} f) else None) =
  6.2530 -    lifted op + (if f integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c} then Some (integral ({a..b} \<inter> {x. x \<bullet> k \<le> c}) f) else None)
  6.2531 -    (if f integrable_on {a..b} \<inter> {x. c \<le> x \<bullet> k} then Some (integral ({a..b} \<inter> {x. c \<le> x \<bullet> k}) f) else None)"
  6.2532 -  proof (cases "f integrable_on {a..b}")
  6.2533 +  show "(if f integrable_on cbox a b then Some (integral (cbox a b) f) else None) =
  6.2534 +    lifted op + (if f integrable_on cbox a b \<inter> {x. x \<bullet> k \<le> c} then Some (integral (cbox a b \<inter> {x. x \<bullet> k \<le> c}) f) else None)
  6.2535 +    (if f integrable_on cbox a b \<inter> {x. c \<le> x \<bullet> k} then Some (integral (cbox a b \<inter> {x. c \<le> x \<bullet> k}) f) else None)"
  6.2536 +  proof (cases "f integrable_on cbox a b")
  6.2537      case True
  6.2538      show ?thesis
  6.2539        unfolding if_P[OF True]
  6.2540 @@ -4076,13 +4178,13 @@
  6.2541        done
  6.2542    next
  6.2543      case False
  6.2544 -    have "\<not> (f integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c}) \<or> \<not> ( f integrable_on {a..b} \<inter> {x. c \<le> x \<bullet> k})"
  6.2545 +    have "\<not> (f integrable_on cbox a b \<inter> {x. x \<bullet> k \<le> c}) \<or> \<not> ( f integrable_on cbox a b \<inter> {x. c \<le> x \<bullet> k})"
  6.2546      proof (rule ccontr)
  6.2547        assume "\<not> ?thesis"
  6.2548 -      then have "f integrable_on {a..b}"
  6.2549 +      then have "f integrable_on cbox a b"
  6.2550          apply -
  6.2551          unfolding integrable_on_def
  6.2552 -        apply (rule_tac x="integral ({a..b} \<inter> {x. x \<bullet> k \<le> c}) f + integral ({a..b} \<inter> {x. x \<bullet> k \<ge> c}) f" in exI)
  6.2553 +        apply (rule_tac x="integral (cbox a b \<inter> {x. x \<bullet> k \<le> c}) f + integral (cbox a b \<inter> {x. x \<bullet> k \<ge> c}) f" in exI)
  6.2554          apply (rule has_integral_split[OF _ _ k])
  6.2555          apply (rule_tac[!] integrable_integral)
  6.2556          apply auto
  6.2557 @@ -4095,8 +4197,8 @@
  6.2558    qed
  6.2559  next
  6.2560    fix a b :: 'a
  6.2561 -  assume as: "content {a..b} = 0"
  6.2562 -  then show "(if f integrable_on {a..b} then Some (integral {a..b} f) else None) = Some 0"
  6.2563 +  assume as: "content (cbox a b) = 0"
  6.2564 +  then show "(if f integrable_on cbox a b then Some (integral (cbox a b) f) else None) = Some 0"
  6.2565      unfolding if_P[OF integrable_on_null[OF as]]
  6.2566      using has_integral_null_eq[OF as]
  6.2567      by auto
  6.2568 @@ -4105,18 +4207,18 @@
  6.2569  
  6.2570  subsection {* Points of division of a partition. *}
  6.2571  
  6.2572 -definition "division_points (k::('a::ordered_euclidean_space) set) d =
  6.2573 -  {(j,x). j \<in> Basis \<and> (Inf k)\<bullet>j < x \<and> x < (Sup k)\<bullet>j \<and>
  6.2574 -    (\<exists>i\<in>d. (Inf i)\<bullet>j = x \<or> (Sup i)\<bullet>j = x)}"
  6.2575 +definition "division_points (k::('a::euclidean_space) set) d =
  6.2576 +   {(j,x). j \<in> Basis \<and> (interval_lowerbound k)\<bullet>j < x \<and> x < (interval_upperbound k)\<bullet>j \<and>
  6.2577 +     (\<exists>i\<in>d. (interval_lowerbound i)\<bullet>j = x \<or> (interval_upperbound i)\<bullet>j = x)}"
  6.2578  
  6.2579  lemma division_points_finite:
  6.2580 -  fixes i :: "'a::ordered_euclidean_space set"
  6.2581 +  fixes i :: "'a::euclidean_space set"
  6.2582    assumes "d division_of i"
  6.2583    shows "finite (division_points i d)"
  6.2584  proof -
  6.2585    note assm = division_ofD[OF assms]
  6.2586 -  let ?M = "\<lambda>j. {(j,x)|x. (Inf i)\<bullet>j < x \<and> x < (Sup i)\<bullet>j \<and>
  6.2587 -    (\<exists>i\<in>d. (Inf i)\<bullet>j = x \<or> (Sup i)\<bullet>j = x)}"
  6.2588 +  let ?M = "\<lambda>j. {(j,x)|x. (interval_lowerbound i)\<bullet>j < x \<and> x < (interval_upperbound i)\<bullet>j \<and>
  6.2589 +    (\<exists>i\<in>d. (interval_lowerbound i)\<bullet>j = x \<or> (interval_upperbound i)\<bullet>j = x)}"
  6.2590    have *: "division_points i d = \<Union>(?M ` Basis)"
  6.2591      unfolding division_points_def by auto
  6.2592    show ?thesis
  6.2593 @@ -4124,14 +4226,14 @@
  6.2594  qed
  6.2595  
  6.2596  lemma division_points_subset:
  6.2597 -  fixes a :: "'a::ordered_euclidean_space"
  6.2598 -  assumes "d division_of {a..b}"
  6.2599 +  fixes a :: "'a::euclidean_space"
  6.2600 +  assumes "d division_of (cbox a b)"
  6.2601      and "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"  "a\<bullet>k < c" "c < b\<bullet>k"
  6.2602      and k: "k \<in> Basis"
  6.2603 -  shows "division_points ({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>
  6.2604 -      division_points ({a..b}) d" (is ?t1)
  6.2605 -    and "division_points ({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} = {})} \<subseteq>
  6.2606 -      division_points ({a..b}) d" (is ?t2)
  6.2607 +  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>
  6.2608 +      division_points (cbox a b) d" (is ?t1)
  6.2609 +    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} = {})} \<subseteq>
  6.2610 +      division_points (cbox a b) d" (is ?t2)
  6.2611  proof -
  6.2612    note assm = division_ofD[OF assms(1)]
  6.2613    have *: "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i"
  6.2614 @@ -4153,15 +4255,15 @@
  6.2615      fix i l x
  6.2616      assume as:
  6.2617        "a \<bullet> fst x < snd x" "snd x < (if fst x = k then c else b \<bullet> fst x)"
  6.2618 -      "Inf i \<bullet> fst x = snd x \<or> Sup i \<bullet> fst x = snd x"
  6.2619 +      "interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
  6.2620        "i = l \<inter> {x. x \<bullet> k \<le> c}" "l \<in> d" "l \<inter> {x. x \<bullet> k \<le> c} \<noteq> {}"
  6.2621        and fstx: "fst x \<in> Basis"
  6.2622      from assm(4)[OF this(5)] guess u v apply-by(erule exE)+ note l=this
  6.2623      have *: "\<forall>i\<in>Basis. u \<bullet> i \<le> (\<Sum>i\<in>Basis. (if i = k then min (v \<bullet> k) c else v \<bullet> i) *\<^sub>R i) \<bullet> i"
  6.2624 -      using as(6) unfolding l interval_split[OF k] interval_ne_empty as .
  6.2625 +      using as(6) unfolding l interval_split[OF k] box_ne_empty as .
  6.2626      have **: "\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i"
  6.2627 -      using l using as(6) unfolding interval_ne_empty[symmetric] by auto
  6.2628 -    show "\<exists>i\<in>d. Inf i \<bullet> fst x = snd x \<or> Sup i \<bullet> fst x = snd x"
  6.2629 +      using l using as(6) unfolding box_ne_empty[symmetric] by auto
  6.2630 +    show "\<exists>i\<in>d. interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
  6.2631        apply (rule bexI[OF _ `l \<in> d`])
  6.2632        using as(1-3,5) fstx
  6.2633        unfolding l interval_bounds[OF **] interval_bounds[OF *] interval_split[OF k] as
  6.2634 @@ -4184,15 +4286,15 @@
  6.2635      fix i l x
  6.2636      assume as:
  6.2637        "(if fst x = k then c else a \<bullet> fst x) < snd x" "snd x < b \<bullet> fst x"
  6.2638 -      "Inf i \<bullet> fst x = snd x \<or> Sup i \<bullet> fst x = snd x"
  6.2639 +      "interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
  6.2640        "i = l \<inter> {x. c \<le> x \<bullet> k}" "l \<in> d" "l \<inter> {x. c \<le> x \<bullet> k} \<noteq> {}"
  6.2641        and fstx: "fst x \<in> Basis"
  6.2642      from assm(4)[OF this(5)] guess u v by (elim exE) note l=this
  6.2643      have *: "\<forall>i\<in>Basis. (\<Sum>i\<in>Basis. (if i = k then max (u \<bullet> k) c else u \<bullet> i) *\<^sub>R i) \<bullet> i \<le> v \<bullet> i"
  6.2644 -      using as(6) unfolding l interval_split[OF k] interval_ne_empty as .
  6.2645 +      using as(6) unfolding l interval_split[OF k] box_ne_empty as .
  6.2646      have **: "\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i"
  6.2647 -      using l using as(6) unfolding interval_ne_empty[symmetric] by auto
  6.2648 -    show "\<exists>i\<in>d. Inf i \<bullet> fst x = snd x \<or> Sup i \<bullet> fst x = snd x"
  6.2649 +      using l using as(6) unfolding box_ne_empty[symmetric] by auto
  6.2650 +    show "\<exists>i\<in>d. interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
  6.2651        apply (rule bexI[OF _ `l \<in> d`])
  6.2652        using as(1-3,5) fstx
  6.2653        unfolding l interval_bounds[OF **] interval_bounds[OF *] interval_split[OF k] as
  6.2654 @@ -4204,32 +4306,32 @@
  6.2655  qed
  6.2656  
  6.2657  lemma division_points_psubset:
  6.2658 -  fixes a :: "'a::ordered_euclidean_space"
  6.2659 -  assumes "d division_of {a..b}"
  6.2660 +  fixes a :: "'a::euclidean_space"
  6.2661 +  assumes "d division_of (cbox a b)"
  6.2662      and "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"  "a\<bullet>k < c" "c < b\<bullet>k"
  6.2663      and "l \<in> d"
  6.2664 -    and "Inf l\<bullet>k = c \<or> Sup l\<bullet>k = c"
  6.2665 +     and "interval_lowerbound l\<bullet>k = c \<or> interval_upperbound l\<bullet>k = c"
  6.2666      and k: "k \<in> Basis"
  6.2667 -  shows "division_points ({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>
  6.2668 -      division_points ({a..b}) d" (is "?D1 \<subset> ?D")
  6.2669 -    and "division_points ({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>
  6.2670 -      division_points ({a..b}) d" (is "?D2 \<subset> ?D")
  6.2671 +  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>
  6.2672 +      division_points (cbox a b) d" (is "?D1 \<subset> ?D")
  6.2673 +    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>
  6.2674 +      division_points (cbox a b) d" (is "?D2 \<subset> ?D")
  6.2675  proof -
  6.2676    have ab: "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i"
  6.2677      using assms(2) by (auto intro!:less_imp_le)
  6.2678    guess u v using division_ofD(4)[OF assms(1,5)] by (elim exE) note l=this
  6.2679    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"
  6.2680 -    using division_ofD(2,2,3)[OF assms(1,5)] unfolding l interval_ne_empty
  6.2681 +    using division_ofD(2,2,3)[OF assms(1,5)] unfolding l box_ne_empty
  6.2682      unfolding subset_eq
  6.2683      apply -
  6.2684      defer
  6.2685      apply (erule_tac x=u in ballE)
  6.2686      apply (erule_tac x=v in ballE)
  6.2687 -    unfolding mem_interval
  6.2688 -    apply auto
  6.2689 -    done
  6.2690 -  have *: "Sup ({a..b} \<inter> {x. x \<bullet> k \<le> Sup l \<bullet> k}) \<bullet> k = Sup l \<bullet> k"
  6.2691 -    "Sup ({a..b} \<inter> {x. x \<bullet> k \<le> Inf l \<bullet> k}) \<bullet> k = Inf l \<bullet> k"
  6.2692 +    unfolding mem_box
  6.2693 +    apply auto
  6.2694 +    done
  6.2695 +  have *: "interval_upperbound (cbox a b \<inter> {x. x \<bullet> k \<le> interval_upperbound l \<bullet> k}) \<bullet> k = interval_upperbound l \<bullet> k"
  6.2696 +    "interval_upperbound (cbox a b \<inter> {x. x \<bullet> k \<le> interval_lowerbound l \<bullet> k}) \<bullet> k = interval_lowerbound l \<bullet> k"
  6.2697      unfolding interval_split[OF k]
  6.2698      apply (subst interval_bounds)
  6.2699      prefer 3
  6.2700 @@ -4242,9 +4344,9 @@
  6.2701      using assms(2-)
  6.2702      apply -
  6.2703      apply (erule disjE)
  6.2704 -    apply (rule_tac x="(k,(Inf l)\<bullet>k)" in exI)
  6.2705 +    apply (rule_tac x="(k,(interval_lowerbound l)\<bullet>k)" in exI)
  6.2706      defer
  6.2707 -    apply (rule_tac x="(k,(Sup l)\<bullet>k)" in exI)
  6.2708 +    apply (rule_tac x="(k,(interval_upperbound l)\<bullet>k)" in exI)
  6.2709      unfolding division_points_def
  6.2710      unfolding interval_bounds[OF ab]
  6.2711      apply (auto simp add:*)
  6.2712 @@ -4257,8 +4359,8 @@
  6.2713      apply auto
  6.2714      done
  6.2715  
  6.2716 -  have *: "Inf ({a..b} \<inter> {x. x \<bullet> k \<ge> Inf l \<bullet> k}) \<bullet> k = Inf l \<bullet> k"
  6.2717 -    "Inf ({a..b} \<inter> {x. x \<bullet> k \<ge> Sup l \<bullet> k}) \<bullet> k = Sup l \<bullet> k"
  6.2718 +  have *: "interval_lowerbound (cbox a b \<inter> {x. x \<bullet> k \<ge> interval_lowerbound l \<bullet> k}) \<bullet> k = interval_lowerbound l \<bullet> k"
  6.2719 +    "interval_lowerbound (cbox a b \<inter> {x. x \<bullet> k \<ge> interval_upperbound l \<bullet> k}) \<bullet> k = interval_upperbound l \<bullet> k"
  6.2720      unfolding interval_split[OF k]
  6.2721      apply (subst interval_bounds)
  6.2722      prefer 3
  6.2723 @@ -4271,9 +4373,9 @@
  6.2724      using assms(2-)
  6.2725      apply -
  6.2726      apply (erule disjE)
  6.2727 -    apply (rule_tac x="(k,(Inf l)\<bullet>k)" in exI)
  6.2728 +    apply (rule_tac x="(k,(interval_lowerbound l)\<bullet>k)" in exI)
  6.2729      defer
  6.2730 -    apply (rule_tac x="(k,(Sup l)\<bullet>k)" in exI)
  6.2731 +    apply (rule_tac x="(k,(interval_upperbound l)\<bullet>k)" in exI)
  6.2732      unfolding division_points_def
  6.2733      unfolding interval_bounds[OF ab]
  6.2734      apply (auto simp add:*)
  6.2735 @@ -4459,25 +4561,25 @@
  6.2736    using assms by auto
  6.2737  
  6.2738  lemma operative_division:
  6.2739 -  fixes f :: "'a::ordered_euclidean_space set \<Rightarrow> 'b"
  6.2740 +  fixes f :: "'a::euclidean_space set \<Rightarrow> 'b"
  6.2741    assumes "monoidal opp"
  6.2742      and "operative opp f"
  6.2743 -    and "d division_of {a..b}"
  6.2744 -  shows "iterate opp d f = f {a..b}"
  6.2745 -proof -
  6.2746 -  def C \<equiv> "card (division_points {a..b} d)"
  6.2747 +    and "d division_of (cbox a b)"
  6.2748 +  shows "iterate opp d f = f (cbox a b)"
  6.2749 +proof -
  6.2750 +  def C \<equiv> "card (division_points (cbox a b) d)"
  6.2751    then show ?thesis
  6.2752      using assms
  6.2753    proof (induct C arbitrary: a b d rule: full_nat_induct)
  6.2754      case goal1
  6.2755 -    { presume *: "content {a..b} \<noteq> 0 \<Longrightarrow> ?case"
  6.2756 +    { presume *: "content (cbox a b) \<noteq> 0 \<Longrightarrow> ?case"
  6.2757        then show ?case
  6.2758          apply -
  6.2759          apply cases
  6.2760          defer
  6.2761          apply assumption
  6.2762        proof -
  6.2763 -        assume as: "content {a..b} = 0"
  6.2764 +        assume as: "content (cbox a b) = 0"
  6.2765          show ?case
  6.2766            unfolding operativeD(1)[OF assms(2) as]
  6.2767            apply(rule iterate_eq_neutral[OF goal1(2)])
  6.2768 @@ -4495,13 +4597,13 @@
  6.2769          qed
  6.2770        qed
  6.2771      }
  6.2772 -    assume "content {a..b} \<noteq> 0" note ab = this[unfolded content_lt_nz[symmetric] content_pos_lt_eq]
  6.2773 +    assume "content (cbox a b) \<noteq> 0" note ab = this[unfolded content_lt_nz[symmetric] content_pos_lt_eq]
  6.2774      then have ab': "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i"
  6.2775        by (auto intro!: less_imp_le)
  6.2776      show ?case
  6.2777 -    proof (cases "division_points {a..b} d = {}")
  6.2778 +    proof (cases "division_points (cbox a b) d = {}")
  6.2779        case True
  6.2780 -      have d': "\<forall>i\<in>d. \<exists>u v. i = {u..v} \<and>
  6.2781 +      have d': "\<forall>i\<in>d. \<exists>u v. i = cbox u v \<and>
  6.2782          (\<forall>j\<in>Basis. u\<bullet>j = a\<bullet>j \<and> v\<bullet>j = a\<bullet>j \<or> u\<bullet>j = b\<bullet>j \<and> v\<bullet>j = b\<bullet>j \<or> u\<bullet>j = a\<bullet>j \<and> v\<bullet>j = b\<bullet>j)"
  6.2783          unfolding forall_in_division[OF goal1(4)]
  6.2784          apply rule
  6.2785 @@ -4515,14 +4617,14 @@
  6.2786          fix u v
  6.2787          fix j :: 'a
  6.2788          assume j: "j \<in> Basis"
  6.2789 -        assume as: "{u..v} \<in> d"
  6.2790 +        assume as: "cbox u v \<in> d"
  6.2791          note division_ofD(3)[OF goal1(4) this]
  6.2792          then have uv: "\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i" "u\<bullet>j \<le> v\<bullet>j"
  6.2793 -          using j unfolding interval_ne_empty by auto
  6.2794 -        have *: "\<And>p r Q. \<not> j\<in>Basis \<or> p \<or> r \<or> (\<forall>x\<in>d. Q x) \<Longrightarrow> p \<or> r \<or> Q {u..v}"
  6.2795 +          using j unfolding box_ne_empty by auto
  6.2796 +        have *: "\<And>p r Q. \<not> j\<in>Basis \<or> p \<or> r \<or> (\<forall>x\<in>d. Q x) \<Longrightarrow> p \<or> r \<or> Q (cbox u v)"
  6.2797            using as j by auto
  6.2798 -        have "(j, u\<bullet>j) \<notin> division_points {a..b} d"
  6.2799 -          "(j, v\<bullet>j) \<notin> division_points {a..b} d" using True by auto
  6.2800 +        have "(j, u\<bullet>j) \<notin> division_points (cbox a b) d"
  6.2801 +          "(j, v\<bullet>j) \<notin> division_points (cbox a b) d" using True by auto
  6.2802          note this[unfolded de_Morgan_conj division_points_def mem_Collect_eq split_conv interval_bounds[OF ab'] bex_simps]
  6.2803          note *[OF this(1)] *[OF this(2)] note this[unfolded interval_bounds[OF uv(1)]]
  6.2804          moreover
  6.2805 @@ -4531,39 +4633,39 @@
  6.2806            unfolding subset_eq
  6.2807            apply -
  6.2808            apply (erule_tac x=u in ballE,erule_tac[3] x=v in ballE)
  6.2809 -          unfolding interval_ne_empty mem_interval
  6.2810 +          unfolding box_ne_empty mem_box
  6.2811            using j
  6.2812            apply auto
  6.2813            done
  6.2814          ultimately show "u\<bullet>j = a\<bullet>j \<and> v\<bullet>j = a\<bullet>j \<or> u\<bullet>j = b\<bullet>j \<and> v\<bullet>j = b\<bullet>j \<or> u\<bullet>j = a\<bullet>j \<and> v\<bullet>j = b\<bullet>j"
  6.2815            unfolding not_less de_Morgan_disj using ab[rule_format,of j] uv(2) j by auto
  6.2816        qed
  6.2817 -      have "(1/2) *\<^sub>R (a+b) \<in> {a..b}"
  6.2818 -        unfolding mem_interval using ab by(auto intro!: less_imp_le simp: inner_simps)
  6.2819 +      have "(1/2) *\<^sub>R (a+b) \<in> cbox a b"
  6.2820 +        unfolding mem_box using ab by(auto intro!: less_imp_le simp: inner_simps)
  6.2821        note this[unfolded division_ofD(6)[OF goal1(4),symmetric] Union_iff]
  6.2822        then guess i .. note i=this
  6.2823        guess u v using d'[rule_format,OF i(1)] by (elim exE conjE) note uv=this
  6.2824 -      have "{a..b} \<in> d"
  6.2825 +      have "cbox a b \<in> d"
  6.2826        proof -
  6.2827 -        { presume "i = {a..b}" then show ?thesis using i by auto }
  6.2828 -        { presume "u = a" "v = b" then show "i = {a..b}" using uv by auto }
  6.2829 +        { presume "i = cbox a b" then show ?thesis using i by auto }
  6.2830 +        { presume "u = a" "v = b" then show "i = cbox a b" using uv by auto }
  6.2831          show "u = a" "v = b"
  6.2832            unfolding euclidean_eq_iff[where 'a='a]
  6.2833          proof safe
  6.2834            fix j :: 'a
  6.2835            assume j: "j \<in> Basis"
  6.2836 -          note i(2)[unfolded uv mem_interval,rule_format,of j]
  6.2837 +          note i(2)[unfolded uv mem_box,rule_format,of j]
  6.2838            then show "u \<bullet> j = a \<bullet> j" and "v \<bullet> j = b \<bullet> j"
  6.2839              using uv(2)[rule_format,of j] j by (auto simp: inner_simps)
  6.2840          qed
  6.2841        qed
  6.2842 -      then have *: "d = insert {a..b} (d - {{a..b}})"
  6.2843 +      then have *: "d = insert (cbox a b) (d - {cbox a b})"
  6.2844          by auto
  6.2845 -      have "iterate opp (d - {{a..b}}) f = neutral opp"
  6.2846 +      have "iterate opp (d - {cbox a b}) f = neutral opp"
  6.2847          apply (rule iterate_eq_neutral[OF goal1(2)])
  6.2848        proof
  6.2849          fix x
  6.2850 -        assume x: "x \<in> d - {{a..b}}"
  6.2851 +        assume x: "x \<in> d - {cbox a b}"
  6.2852          then have "x\<in>d"
  6.2853            by auto note d'[rule_format,OF this]
  6.2854          then guess u v by (elim exE conjE) note uv=this
  6.2855 @@ -4573,7 +4675,7 @@
  6.2856            unfolding euclidean_eq_iff[where 'a='a] by auto
  6.2857          then have "u\<bullet>j = v\<bullet>j"
  6.2858            using uv(2)[rule_format,OF j] by auto
  6.2859 -        then have "content {u..v} = 0"
  6.2860 +        then have "content (cbox u v) = 0"
  6.2861            unfolding content_eq_0
  6.2862            apply (rule_tac x=j in bexI)
  6.2863            using j
  6.2864 @@ -4582,7 +4684,7 @@
  6.2865          then show "f x = neutral opp"
  6.2866            unfolding uv(1) by (rule operativeD(1)[OF goal1(3)])
  6.2867        qed
  6.2868 -      then show "iterate opp d f = f {a..b}"
  6.2869 +      then show "iterate opp d f = f (cbox a b)"
  6.2870          apply -
  6.2871          apply (subst *)
  6.2872          apply (subst iterate_insert[OF goal1(2)])
  6.2873 @@ -4591,7 +4693,7 @@
  6.2874          done
  6.2875      next
  6.2876        case False
  6.2877 -      then have "\<exists>x. x \<in> division_points {a..b} d"
  6.2878 +      then have "\<exists>x. x \<in> division_points (cbox a b) d"
  6.2879          by auto
  6.2880        then guess k c
  6.2881          unfolding split_paired_Ex
  6.2882 @@ -4606,8 +4708,8 @@
  6.2883        def ca \<equiv> "(\<Sum>i\<in>Basis. (if i = k then c else a\<bullet>i) *\<^sub>R i)::'a"
  6.2884        note division_points_psubset[OF goal1(4) ab kc(1-2) j]
  6.2885        note psubset_card_mono[OF _ this(1)] psubset_card_mono[OF _ this(2)]
  6.2886 -      then have *: "(iterate opp d1 f) = f ({a..b} \<inter> {x. x\<bullet>k \<le> c})"
  6.2887 -        "(iterate opp d2 f) = f ({a..b} \<inter> {x. x\<bullet>k \<ge> c})"
  6.2888 +      then have *: "(iterate opp d1 f) = f (cbox a b \<inter> {x. x\<bullet>k \<le> c})"
  6.2889 +        "(iterate opp d2 f) = f (cbox a b \<inter> {x. x\<bullet>k \<ge> c})"
  6.2890          unfolding interval_split[OF kc(4)]
  6.2891          apply (rule_tac[!] goal1(1)[rule_format])
  6.2892          using division_split[OF goal1(4), where k=k and c=c]
  6.2893 @@ -4618,7 +4720,7 @@
  6.2894          using kc(4)
  6.2895          apply auto
  6.2896          done
  6.2897 -      have "f {a..b} = opp (iterate opp d1 f) (iterate opp d2 f)" (is "_ = ?prev")
  6.2898 +      have "f (cbox a b) = opp (iterate opp d1 f) (iterate opp d2 f)" (is "_ = ?prev")
  6.2899          unfolding *
  6.2900          apply (rule operativeD(2))
  6.2901          using goal1(3)
  6.2902 @@ -4728,8 +4830,8 @@
  6.2903  lemma operative_tagged_division:
  6.2904    assumes "monoidal opp"
  6.2905      and "operative opp f"
  6.2906 -    and "d tagged_division_of {a..b}"
  6.2907 -  shows "iterate opp d (\<lambda>(x,l). f l) = f {a..b}"
  6.2908 +    and "d tagged_division_of (cbox a b)"
  6.2909 +  shows "iterate opp d (\<lambda>(x,l). f l) = f (cbox a b)"
  6.2910  proof -
  6.2911    have *: "(\<lambda>(x,l). f l) = f \<circ> snd"
  6.2912      unfolding o_def by rule auto note assm = tagged_division_ofD[OF assms(3)]
  6.2913 @@ -4752,7 +4854,7 @@
  6.2914        apply auto
  6.2915        done
  6.2916    qed
  6.2917 -  also have "\<dots> = f {a..b}"
  6.2918 +  also have "\<dots> = f (cbox a b)"
  6.2919      using operative_division[OF assms(1-2) division_of_tagged_division[OF assms(3)]] .
  6.2920    finally show ?thesis .
  6.2921  qed
  6.2922 @@ -4775,8 +4877,8 @@
  6.2923  qed
  6.2924  
  6.2925  lemma additive_content_division:
  6.2926 -  assumes "d division_of {a..b}"
  6.2927 -  shows "setsum content d = content {a..b}"
  6.2928 +  assumes "d division_of (cbox a b)"
  6.2929 +  shows "setsum content d = content (cbox a b)"
  6.2930    unfolding operative_division[OF monoidal_monoid operative_content assms,symmetric]
  6.2931    apply (subst setsum_iterate)
  6.2932    using assms
  6.2933 @@ -4784,8 +4886,8 @@
  6.2934    done
  6.2935  
  6.2936  lemma additive_content_tagged_division:
  6.2937 -  assumes "d tagged_division_of {a..b}"
  6.2938 -  shows "setsum (\<lambda>(x,l). content l) d = content {a..b}"
  6.2939 +  assumes "d tagged_division_of (cbox a b)"
  6.2940 +  shows "setsum (\<lambda>(x,l). content l) d = content (cbox a b)"
  6.2941    unfolding operative_tagged_division[OF monoidal_monoid operative_content assms,symmetric]
  6.2942    apply (subst setsum_iterate)
  6.2943    using assms
  6.2944 @@ -4796,8 +4898,8 @@
  6.2945  subsection {* Finally, the integral of a constant *}
  6.2946  
  6.2947  lemma has_integral_const[intro]:
  6.2948 -  fixes a b :: "'a::ordered_euclidean_space"
  6.2949 -  shows "((\<lambda>x. c) has_integral (content {a..b} *\<^sub>R c)) {a..b}"
  6.2950 +  fixes a b :: "'a::euclidean_space"
  6.2951 +  shows "((\<lambda>x. c) has_integral (content (cbox a b) *\<^sub>R c)) (cbox a b)"
  6.2952    unfolding has_integral
  6.2953    apply rule
  6.2954    apply rule
  6.2955 @@ -4815,18 +4917,28 @@
  6.2956    apply auto
  6.2957    done
  6.2958  
  6.2959 +lemma has_integral_const_real[intro]:
  6.2960 +  fixes a b :: real
  6.2961 +  shows "((\<lambda>x. c) has_integral (content {a .. b} *\<^sub>R c)) {a .. b}"
  6.2962 +  by (metis box_real(2) has_integral_const)
  6.2963 +
  6.2964  lemma integral_const[simp]:
  6.2965 -  fixes a b :: "'a::ordered_euclidean_space"
  6.2966 +  fixes a b :: "'a::euclidean_space"
  6.2967 +  shows "integral (cbox a b) (\<lambda>x. c) = content (cbox a b) *\<^sub>R c"
  6.2968 +  by (rule integral_unique) (rule has_integral_const)
  6.2969 +
  6.2970 +lemma integral_const_real[simp]:
  6.2971 +  fixes a b :: real
  6.2972    shows "integral {a .. b} (\<lambda>x. c) = content {a .. b} *\<^sub>R c"
  6.2973 -  by (rule integral_unique) (rule has_integral_const)
  6.2974 +  by (metis box_real(2) integral_const)
  6.2975  
  6.2976  
  6.2977  subsection {* Bounds on the norm of Riemann sums and the integral itself. *}
  6.2978  
  6.2979  lemma dsum_bound:
  6.2980 -  assumes "p division_of {a..b}"
  6.2981 +  assumes "p division_of (cbox a b)"
  6.2982      and "norm c \<le> e"
  6.2983 -  shows "norm (setsum (\<lambda>l. content l *\<^sub>R c) p) \<le> e * content({a..b})"
  6.2984 +  shows "norm (setsum (\<lambda>l. content l *\<^sub>R c) p) \<le> e * content(cbox a b)"
  6.2985    apply (rule order_trans)
  6.2986    apply (rule norm_setsum)
  6.2987    unfolding norm_scaleR setsum_left_distrib[symmetric]
  6.2988 @@ -4850,10 +4962,10 @@
  6.2989  qed (insert assms, auto)
  6.2990  
  6.2991  lemma rsum_bound:
  6.2992 -  assumes "p tagged_division_of {a..b}"
  6.2993 -    and "\<forall>x\<in>{a..b}. norm (f x) \<le> e"
  6.2994 -  shows "norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p) \<le> e * content {a..b}"
  6.2995 -proof (cases "{a..b} = {}")
  6.2996 +  assumes "p tagged_division_of (cbox a b)"
  6.2997 +    and "\<forall>x\<in>cbox a b. norm (f x) \<le> e"
  6.2998 +  shows "norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p) \<le> e * content (cbox a b)"
  6.2999 +proof (cases "cbox a b = {}")
  6.3000    case True
  6.3001    show ?thesis
  6.3002      using assms(1) unfolding True tagged_division_of_trivial by auto
  6.3003 @@ -4875,7 +4987,7 @@
  6.3004      apply (subst o_def)
  6.3005      apply (rule abs_of_nonneg)
  6.3006    proof -
  6.3007 -    show "setsum (content \<circ> snd) p \<le> content {a..b}"
  6.3008 +    show "setsum (content \<circ> snd) p \<le> content (cbox a b)"
  6.3009        apply (rule eq_refl)
  6.3010        unfolding additive_content_tagged_division[OF assms(1),symmetric] split_def
  6.3011        apply auto
  6.3012 @@ -4901,10 +5013,10 @@
  6.3013  qed
  6.3014  
  6.3015  lemma rsum_diff_bound:
  6.3016 -  assumes "p tagged_division_of {a..b}"
  6.3017 -    and "\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e"
  6.3018 +  assumes "p tagged_division_of (cbox a b)"
  6.3019 +    and "\<forall>x\<in>cbox a b. norm (f x - g x) \<le> e"
  6.3020    shows "norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - setsum (\<lambda>(x,k). content k *\<^sub>R g x) p) \<le>
  6.3021 -    e * content {a..b}"
  6.3022 +    e * content (cbox a b)"
  6.3023    apply (rule order_trans[OF _ rsum_bound[OF assms]])
  6.3024    apply (rule eq_refl)
  6.3025    apply (rule arg_cong[where f=norm])
  6.3026 @@ -4915,19 +5027,19 @@
  6.3027    done
  6.3028  
  6.3029  lemma has_integral_bound:
  6.3030 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
  6.3031 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
  6.3032    assumes "0 \<le> B"
  6.3033 -    and "(f has_integral i) {a..b}"
  6.3034 -    and "\<forall>x\<in>{a..b}. norm (f x) \<le> B"
  6.3035 -  shows "norm i \<le> B * content {a..b}"
  6.3036 -proof -
  6.3037 -  let ?P = "content {a..b} > 0"
  6.3038 +    and "(f has_integral i) (cbox a b)"
  6.3039 +    and "\<forall>x\<in>cbox a b. norm (f x) \<le> B"
  6.3040 +  shows "norm i \<le> B * content (cbox a b)"
  6.3041 +proof -
  6.3042 +  let ?P = "content (cbox a b) > 0"
  6.3043    {
  6.3044      presume "?P \<Longrightarrow> ?thesis"
  6.3045      then show ?thesis
  6.3046      proof (cases ?P)
  6.3047        case False
  6.3048 -      then have *: "content {a..b} = 0"
  6.3049 +      then have *: "content (cbox a b) = 0"
  6.3050          using content_lt_nz by auto
  6.3051        then have **: "i = 0"
  6.3052          using assms(2)
  6.3053 @@ -4941,7 +5053,7 @@
  6.3054    assume ab: ?P
  6.3055    { presume "\<not> ?thesis \<Longrightarrow> False" then show ?thesis by auto }
  6.3056    assume "\<not> ?thesis"
  6.3057 -  then have *: "norm i - B * content {a..b} > 0"
  6.3058 +  then have *: "norm i - B * content (cbox a b) > 0"
  6.3059      by auto
  6.3060    from assms(2)[unfolded has_integral,rule_format,OF *]
  6.3061    guess d by (elim exE conjE) note d=this[rule_format]
  6.3062 @@ -4959,13 +5071,21 @@
  6.3063      using d(2)[OF conjI[OF p]] *[OF rsum_bound[OF p(1) assms(3)]] by auto
  6.3064  qed
  6.3065  
  6.3066 +lemma has_integral_bound_real:
  6.3067 +  fixes f :: "real \<Rightarrow> 'b::real_normed_vector"
  6.3068 +  assumes "0 \<le> B"
  6.3069 +    and "(f has_integral i) {a .. b}"
  6.3070 +    and "\<forall>x\<in>{a .. b}. norm (f x) \<le> B"
  6.3071 +  shows "norm i \<le> B * content {a .. b}"
  6.3072 +  by (metis assms(1) assms(2) assms(3) box_real(2) has_integral_bound)
  6.3073 +
  6.3074  
  6.3075  subsection {* Similar theorems about relationship among components. *}
  6.3076  
  6.3077  lemma rsum_component_le:
  6.3078 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3079 -  assumes "p tagged_division_of {a..b}"
  6.3080 -    and "\<forall>x\<in>{a..b}. (f x)\<bullet>i \<le> (g x)\<bullet>i"
  6.3081 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3082 +  assumes "p tagged_division_of (cbox a b)"
  6.3083 +    and "\<forall>x\<in>cbox a b. (f x)\<bullet>i \<le> (g x)\<bullet>i"
  6.3084    shows "(setsum (\<lambda>(x,k). content k *\<^sub>R f x) p)\<bullet>i \<le> (setsum (\<lambda>(x,k). content k *\<^sub>R g x) p)\<bullet>i"
  6.3085    unfolding inner_setsum_left
  6.3086    apply (rule setsum_mono)
  6.3087 @@ -4987,14 +5107,14 @@
  6.3088  qed
  6.3089  
  6.3090  lemma has_integral_component_le:
  6.3091 -  fixes f g :: "'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3092 +  fixes f g :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3093    assumes k: "k \<in> Basis"
  6.3094    assumes "(f has_integral i) s" "(g has_integral j) s"
  6.3095      and "\<forall>x\<in>s. (f x)\<bullet>k \<le> (g x)\<bullet>k"
  6.3096    shows "i\<bullet>k \<le> j\<bullet>k"
  6.3097  proof -
  6.3098 -  have lem: "\<And>a b i j::'b. \<And>g f::'a \<Rightarrow> 'b. (f has_integral i) {a..b} \<Longrightarrow>
  6.3099 -    (g has_integral j) ({a..b}) \<Longrightarrow> \<forall>x\<in>{a..b}. (f x)\<bullet>k \<le> (g x)\<bullet>k \<Longrightarrow> i\<bullet>k \<le> j\<bullet>k"
  6.3100 +  have lem: "\<And>a b i j::'b. \<And>g f::'a \<Rightarrow> 'b. (f has_integral i) (cbox a b) \<Longrightarrow>
  6.3101 +    (g has_integral j) (cbox a b) \<Longrightarrow> \<forall>x\<in>cbox a b. (f x)\<bullet>k \<le> (g x)\<bullet>k \<Longrightarrow> i\<bullet>k \<le> j\<bullet>k"
  6.3102    proof (rule ccontr)
  6.3103      case goal1
  6.3104      then have *: "0 < (i\<bullet>k - j\<bullet>k) / 3"
  6.3105 @@ -5010,7 +5130,7 @@
  6.3106        using rsum_component_le[OF p(1) goal1(3)]
  6.3107        by (simp add: abs_real_def split: split_if_asm)
  6.3108    qed
  6.3109 -  let ?P = "\<exists>a b. s = {a..b}"
  6.3110 +  let ?P = "\<exists>a b. s = cbox a b"
  6.3111    {
  6.3112      presume "\<not> ?P \<Longrightarrow> ?thesis"
  6.3113      then show ?thesis
  6.3114 @@ -5033,7 +5153,7 @@
  6.3115    from this[OF assms(2)] this[OF assms(3)] guess B1 B2 . note B=this[rule_format]
  6.3116    have "bounded (ball 0 B1 \<union> ball (0::'a) B2)"
  6.3117      unfolding bounded_Un by(rule conjI bounded_ball)+
  6.3118 -  from bounded_subset_closed_interval[OF this] guess a b by (elim exE)
  6.3119 +  from bounded_subset_cbox[OF this] guess a b by (elim exE)
  6.3120    note ab = conjunctD2[OF this[unfolded Un_subset_iff]]
  6.3121    guess w1 using B(2)[OF ab(1)] .. note w1=conjunctD2[OF this]
  6.3122    guess w2 using B(4)[OF ab(2)] .. note w2=conjunctD2[OF this]
  6.3123 @@ -5052,7 +5172,7 @@
  6.3124  qed
  6.3125  
  6.3126  lemma integral_component_le:
  6.3127 -  fixes g f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3128 +  fixes g f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3129    assumes "k \<in> Basis"
  6.3130      and "f integrable_on s" "g integrable_on s"
  6.3131      and "\<forall>x\<in>s. (f x)\<bullet>k \<le> (g x)\<bullet>k"
  6.3132 @@ -5063,7 +5183,7 @@
  6.3133    done
  6.3134  
  6.3135  lemma has_integral_component_nonneg:
  6.3136 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3137 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3138    assumes "k \<in> Basis"
  6.3139      and "(f has_integral i) s"
  6.3140      and "\<forall>x\<in>s. 0 \<le> (f x)\<bullet>k"
  6.3141 @@ -5073,7 +5193,7 @@
  6.3142    by auto
  6.3143  
  6.3144  lemma integral_component_nonneg:
  6.3145 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3146 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3147    assumes "k \<in> Basis"
  6.3148      and "f integrable_on s" "\<forall>x\<in>s. 0 \<le> (f x)\<bullet>k"
  6.3149    shows "0 \<le> (integral s f)\<bullet>k"
  6.3150 @@ -5083,7 +5203,7 @@
  6.3151    done
  6.3152  
  6.3153  lemma has_integral_component_neg:
  6.3154 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::ordered_euclidean_space"
  6.3155 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3156    assumes "k \<in> Basis"
  6.3157      and "(f has_integral i) s"
  6.3158      and "\<forall>x\<in>s. (f x)\<bullet>k \<le> 0"
  6.3159 @@ -5092,29 +5212,29 @@
  6.3160    by auto
  6.3161  
  6.3162  lemma has_integral_component_lbound:
  6.3163 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::ordered_euclidean_space"
  6.3164 -  assumes "(f has_integral i) {a..b}"
  6.3165 -    and "\<forall>x\<in>{a..b}. B \<le> f(x)\<bullet>k"
  6.3166 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3167 +  assumes "(f has_integral i) (cbox a b)"
  6.3168 +    and "\<forall>x\<in>cbox a b. B \<le> f(x)\<bullet>k"
  6.3169      and "k \<in> Basis"
  6.3170 -  shows "B * content {a..b} \<le> i\<bullet>k"
  6.3171 +  shows "B * content (cbox a b) \<le> i\<bullet>k"
  6.3172    using has_integral_component_le[OF assms(3) has_integral_const assms(1),of "(\<Sum>i\<in>Basis. B *\<^sub>R i)::'b"] assms(2-)
  6.3173    by (auto simp add: field_simps)
  6.3174  
  6.3175  lemma has_integral_component_ubound:
  6.3176 -  fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
  6.3177 -  assumes "(f has_integral i) {a..b}"
  6.3178 -    and "\<forall>x\<in>{a..b}. f x\<bullet>k \<le> B"
  6.3179 +  fixes f::"'a::euclidean_space => 'b::euclidean_space"
  6.3180 +  assumes "(f has_integral i) (cbox a b)"
  6.3181 +    and "\<forall>x\<in>cbox a b. f x\<bullet>k \<le> B"
  6.3182      and "k \<in> Basis"
  6.3183 -  shows "i\<bullet>k \<le> B * content {a..b}"
  6.3184 +  shows "i\<bullet>k \<le> B * content (cbox a b)"
  6.3185    using has_integral_component_le[OF assms(3,1) has_integral_const, of "\<Sum>i\<in>Basis. B *\<^sub>R i"] assms(2-)
  6.3186    by (auto simp add: field_simps)
  6.3187  
  6.3188  lemma integral_component_lbound:
  6.3189 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::ordered_euclidean_space"
  6.3190 -  assumes "f integrable_on {a..b}"
  6.3191 -    and "\<forall>x\<in>{a..b}. B \<le> f(x)\<bullet>k"
  6.3192 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3193 +  assumes "f integrable_on cbox a b"
  6.3194 +    and "\<forall>x\<in>cbox a b. B \<le> f(x)\<bullet>k"
  6.3195      and "k \<in> Basis"
  6.3196 -  shows "B * content {a..b} \<le> (integral({a..b}) f)\<bullet>k"
  6.3197 +  shows "B * content (cbox a b) \<le> (integral(cbox a b) f)\<bullet>k"
  6.3198    apply (rule has_integral_component_lbound)
  6.3199    using assms
  6.3200    unfolding has_integral_integral
  6.3201 @@ -5122,11 +5242,11 @@
  6.3202    done
  6.3203  
  6.3204  lemma integral_component_ubound:
  6.3205 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::ordered_euclidean_space"
  6.3206 -  assumes "f integrable_on {a..b}"
  6.3207 -    and "\<forall>x\<in>{a..b}. f x\<bullet>k \<le> B"
  6.3208 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  6.3209 +  assumes "f integrable_on cbox a b"
  6.3210 +    and "\<forall>x\<in>cbox a b. f x\<bullet>k \<le> B"
  6.3211      and "k \<in> Basis"
  6.3212 -  shows "(integral {a..b} f)\<bullet>k \<le> B * content {a..b}"
  6.3213 +  shows "(integral (cbox a b) f)\<bullet>k \<le> B * content (cbox a b)"
  6.3214    apply (rule has_integral_component_ubound)
  6.3215    using assms
  6.3216    unfolding has_integral_integral
  6.3217 @@ -5137,12 +5257,12 @@
  6.3218  subsection {* Uniform limit of integrable functions is integrable. *}
  6.3219  
  6.3220  lemma integrable_uniform_limit:
  6.3221 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
  6.3222 -  assumes "\<forall>e>0. \<exists>g. (\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b}"
  6.3223 -  shows "f integrable_on {a..b}"
  6.3224 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::banach"
  6.3225 +  assumes "\<forall>e>0. \<exists>g. (\<forall>x\<in>cbox a b. norm (f x - g x) \<le> e) \<and> g integrable_on cbox a b"
  6.3226 +  shows "f integrable_on cbox a b"
  6.3227  proof -
  6.3228    {
  6.3229 -    presume *: "content {a..b} > 0 \<Longrightarrow> ?thesis"
  6.3230 +    presume *: "content (cbox a b) > 0 \<Longrightarrow> ?thesis"
  6.3231      show ?thesis
  6.3232        apply cases
  6.3233        apply (rule *)
  6.3234 @@ -5152,7 +5272,7 @@
  6.3235        apply auto
  6.3236        done
  6.3237    }
  6.3238 -  assume as: "content {a..b} > 0"
  6.3239 +  assume as: "content (cbox a b) > 0"
  6.3240    have *: "\<And>P. \<forall>e>(0::real). P e \<Longrightarrow> \<forall>n::nat. P (inverse (real n + 1))"
  6.3241      by auto
  6.3242    from choice[OF *[OF assms]] guess g .. note g=conjunctD2[OF this[rule_format],rule_format]
  6.3243 @@ -5163,7 +5283,7 @@
  6.3244    proof (rule, rule)
  6.3245      fix e :: real
  6.3246      assume "e>0"
  6.3247 -    then have "e / 4 / content {a..b} > 0"
  6.3248 +    then have "e / 4 / content (cbox a b) > 0"
  6.3249        using as by (auto simp add: field_simps)
  6.3250      then guess M
  6.3251        apply -
  6.3252 @@ -5205,12 +5325,12 @@
  6.3253          apply (rule order_trans)
  6.3254          apply (rule rsum_diff_bound[OF p(1), where e="2 / real M"])
  6.3255        proof
  6.3256 -        show "2 / real M * content {a..b} \<le> e / 2"
  6.3257 +        show "2 / real M * content (cbox a b) \<le> e / 2"
  6.3258            unfolding divide_inverse
  6.3259            using M as
  6.3260            by (auto simp add: field_simps)
  6.3261          fix x
  6.3262 -        assume x: "x \<in> {a..b}"
  6.3263 +        assume x: "x \<in> cbox a b"
  6.3264          have "norm (f x - g n x) + norm (f x - g m x) \<le> inverse (real n + 1) + inverse (real m + 1)"
  6.3265            using g(1)[OF x, of n] g(1)[OF x, of m] by auto
  6.3266          also have "\<dots> \<le> inverse (real M) + inverse (real M)"
  6.3267 @@ -5237,7 +5357,7 @@
  6.3268      case goal1
  6.3269      then have *: "e/3 > 0" by auto
  6.3270      from LIMSEQ_D [OF s this] guess N1 .. note N1=this
  6.3271 -    from goal1 as have "e / 3 / content {a..b} > 0"
  6.3272 +    from goal1 as have "e / 3 / content (cbox a b) > 0"
  6.3273        by (auto simp add: field_simps)
  6.3274      from real_arch_invD[OF this] guess N2 by (elim exE conjE) note N2=this
  6.3275      from i[of "N1 + N2",unfolded has_integral,rule_format,OF *] guess g' .. note g'=conjunctD2[OF this,rule_format]
  6.3276 @@ -5261,7 +5381,7 @@
  6.3277        apply (rule g')
  6.3278      proof (rule, rule)
  6.3279        fix p
  6.3280 -      assume p: "p tagged_division_of {a..b} \<and> g' fine p"
  6.3281 +      assume p: "p tagged_division_of (cbox a b) \<and> g' fine p"
  6.3282        note * = g'(2)[OF this]
  6.3283        show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - s) < e"
  6.3284          apply -
  6.3285 @@ -5272,15 +5392,15 @@
  6.3286          apply (rule g)
  6.3287          apply assumption
  6.3288        proof -
  6.3289 -        have "content {a..b} < e / 3 * (real N2)"
  6.3290 +        have "content (cbox a b) < e / 3 * (real N2)"
  6.3291            using N2 unfolding inverse_eq_divide using as by (auto simp add: field_simps)
  6.3292 -        then have "content {a..b} < e / 3 * (real (N1 + N2) + 1)"
  6.3293 +        then have "content (cbox a b) < e / 3 * (real (N1 + N2) + 1)"
  6.3294            apply -
  6.3295            apply (rule less_le_trans,assumption)
  6.3296            using `e>0`
  6.3297            apply auto
  6.3298            done
  6.3299 -        then show "inverse (real (N1 + N2) + 1) * content {a..b} \<le> e / 3"
  6.3300 +        then show "inverse (real (N1 + N2) + 1) * content (cbox a b) \<le> e / 3"
  6.3301            unfolding inverse_eq_divide
  6.3302            by (auto simp add: field_simps)
  6.3303          show "norm (i (N1 + N2) - s) < e / 3"
  6.3304 @@ -5293,8 +5413,8 @@
  6.3305  
  6.3306  subsection {* Negligible sets. *}
  6.3307  
  6.3308 -definition "negligible (s:: 'a::ordered_euclidean_space set) \<longleftrightarrow>
  6.3309 -  (\<forall>a b. ((indicator s :: 'a\<Rightarrow>real) has_integral 0) {a..b})"
  6.3310 +definition "negligible (s:: 'a::euclidean_space set) \<longleftrightarrow>
  6.3311 +  (\<forall>a b. ((indicator s :: 'a\<Rightarrow>real) has_integral 0) (cbox a b))"
  6.3312  
  6.3313  
  6.3314  subsection {* Negligibility of hyperplane. *}
  6.3315 @@ -5316,11 +5436,11 @@
  6.3316    done
  6.3317  
  6.3318  lemma interval_doublesplit:
  6.3319 -  fixes a :: "'a::ordered_euclidean_space"
  6.3320 +  fixes a :: "'a::euclidean_space"
  6.3321    assumes "k \<in> Basis"
  6.3322 -  shows "{a..b} \<inter> {x . abs(x\<bullet>k - c) \<le> (e::real)} =
  6.3323 -    {(\<Sum>i\<in>Basis. (if i = k then max (a\<bullet>k) (c - e) else a\<bullet>i) *\<^sub>R i) ..
  6.3324 -     (\<Sum>i\<in>Basis. (if i = k then min (b\<bullet>k) (c + e) else b\<bullet>i) *\<^sub>R i)}"
  6.3325 +  shows "cbox a b \<inter> {x . abs(x\<bullet>k - c) \<le> (e::real)} =
  6.3326 +    cbox (\<Sum>i\<in>Basis. (if i = k then max (a\<bullet>k) (c - e) else a\<bullet>i) *\<^sub>R i)
  6.3327 +     (\<Sum>i\<in>Basis. (if i = k then min (b\<bullet>k) (c + e) else b\<bullet>i) *\<^sub>R i)"
  6.3328  proof -
  6.3329    have *: "\<And>x c e::real. abs(x - c) \<le> e \<longleftrightarrow> x \<ge> c - e \<and> x \<le> c + e"
  6.3330      by auto
  6.3331 @@ -5331,10 +5451,10 @@
  6.3332  qed
  6.3333  
  6.3334  lemma division_doublesplit:
  6.3335 -  fixes a :: "'a::ordered_euclidean_space"
  6.3336 -  assumes "p division_of {a..b}"
  6.3337 +  fixes a :: "'a::euclidean_space"
  6.3338 +  assumes "p division_of (cbox a b)"
  6.3339      and k: "k \<in> Basis"
  6.3340 -  shows "{l \<inter> {x. abs(x\<bullet>k - c) \<le> e} |l. l \<in> p \<and> l \<inter> {x. abs(x\<bullet>k - c) \<le> e} \<noteq> {}} division_of ({a..b} \<inter> {x. abs(x\<bullet>k - c) \<le> e})"
  6.3341 +  shows "{l \<inter> {x. abs(x\<bullet>k - c) \<le> e} |l. l \<in> p \<and> l \<inter> {x. abs(x\<bullet>k - c) \<le> e} \<noteq> {}} division_of (cbox a b \<inter> {x. abs(x\<bullet>k - c) \<le> e})"
  6.3342  proof -
  6.3343    have *: "\<And>x c. abs (x - c) \<le> e \<longleftrightarrow> x \<ge> c - e \<and> x \<le> c + e"
  6.3344      by auto
  6.3345 @@ -5366,11 +5486,11 @@
  6.3346  qed
  6.3347  
  6.3348  lemma content_doublesplit:
  6.3349 -  fixes a :: "'a::ordered_euclidean_space"
  6.3350 +  fixes a :: "'a::euclidean_space"
  6.3351    assumes "0 < e"
  6.3352      and k: "k \<in> Basis"
  6.3353 -  obtains d where "0 < d" and "content ({a..b} \<inter> {x. abs(x\<bullet>k - c) \<le> d}) < e"
  6.3354 -proof (cases "content {a..b} = 0")
  6.3355 +  obtains d where "0 < d" and "content (cbox a b \<inter> {x. abs(x\<bullet>k - c) \<le> d}) < e"
  6.3356 +proof (cases "content (cbox a b) = 0")
  6.3357    case True
  6.3358    show ?thesis
  6.3359      apply (rule that[of 1])
  6.3360 @@ -5402,9 +5522,9 @@
  6.3361    proof (rule that[of d])
  6.3362      have *: "Basis = insert k (Basis - {k})"
  6.3363        using k by auto
  6.3364 -    have **: "{a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {} \<Longrightarrow>
  6.3365 -      (\<Prod>i\<in>Basis - {k}. Sup ({a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<bullet> i -
  6.3366 -        Inf ({a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<bullet> i) =
  6.3367 +    have **: "cbox a b \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {} \<Longrightarrow>
  6.3368 +      (\<Prod>i\<in>Basis - {k}. interval_upperbound (cbox a b \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<bullet> i -
  6.3369 +        interval_lowerbound (cbox a b \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<bullet> i) =
  6.3370        (\<Prod>i\<in>Basis - {k}. b\<bullet>i - a\<bullet>i)"
  6.3371        apply (rule setprod_cong)
  6.3372        apply (rule refl)
  6.3373 @@ -5412,10 +5532,10 @@
  6.3374        apply (subst interval_bounds)
  6.3375        defer
  6.3376        apply (subst interval_bounds)
  6.3377 -      unfolding interval_eq_empty not_ex not_less
  6.3378 -      apply auto
  6.3379 -      done
  6.3380 -    show "content ({a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) < e"
  6.3381 +      unfolding box_eq_empty not_ex not_less
  6.3382 +      apply auto
  6.3383 +      done
  6.3384 +    show "content (cbox a b \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) < e"
  6.3385        apply cases
  6.3386        unfolding content_def
  6.3387        apply (subst if_P)
  6.3388 @@ -5425,7 +5545,7 @@
  6.3389        apply (subst *)
  6.3390        apply (subst setprod_insert)
  6.3391        unfolding **
  6.3392 -      unfolding interval_doublesplit[OF k] interval_eq_empty not_ex not_less
  6.3393 +      unfolding interval_doublesplit[OF k] box_eq_empty not_ex not_less
  6.3394        prefer 3
  6.3395        apply (subst interval_bounds)
  6.3396        defer
  6.3397 @@ -5445,7 +5565,7 @@
  6.3398  qed
  6.3399  
  6.3400  lemma negligible_standard_hyperplane[intro]:
  6.3401 -  fixes k :: "'a::ordered_euclidean_space"
  6.3402 +  fixes k :: "'a::euclidean_space"
  6.3403    assumes k: "k \<in> Basis"
  6.3404    shows "negligible {x. x\<bullet>k = c}"
  6.3405    unfolding negligible_def has_integral
  6.3406 @@ -5461,7 +5581,7 @@
  6.3407      apply (rule d)
  6.3408    proof (rule, rule)
  6.3409      fix p
  6.3410 -    assume p: "p tagged_division_of {a..b} \<and> (\<lambda>x. ball x d) fine p"
  6.3411 +    assume p: "p tagged_division_of (cbox a b) \<and> (\<lambda>x. ball x d) fine p"
  6.3412      have *: "(\<Sum>(x, ka)\<in>p. content ka *\<^sub>R ?i x) =
  6.3413        (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. abs(x\<bullet>k - c) \<le> d}) *\<^sub>R ?i x)"
  6.3414        apply (rule setsum_cong2)
  6.3415 @@ -5526,7 +5646,7 @@
  6.3416          apply (subst setsum_over_tagged_division_lemma[OF p[THEN conjunct1]])
  6.3417        proof -
  6.3418          case goal1
  6.3419 -        have "content ({u..v} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<le> content {u..v}"
  6.3420 +        have "content (cbox u v \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<le> content (cbox u v)"
  6.3421            unfolding interval_doublesplit[OF k]
  6.3422            apply (rule content_subset)
  6.3423            unfolding interval_doublesplit[symmetric,OF k]
  6.3424 @@ -5565,15 +5685,15 @@
  6.3425          proof (rule,rule,rule,rule,rule,rule,rule,erule conjE)
  6.3426            fix m n u v
  6.3427            assume as:
  6.3428 -            "{m..n} \<in> snd ` p" "{u..v} \<in> snd ` p"
  6.3429 -            "{m..n} \<noteq> {u..v}"
  6.3430 -            "{m..n} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} = {u..v} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}"
  6.3431 -          have "({m..n} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<inter> ({u..v} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<subseteq> {m..n} \<inter> {u..v}"
  6.3432 +            "cbox m n \<in> snd ` p" "cbox u v \<in> snd ` p"
  6.3433 +            "cbox m n \<noteq> cbox u v"
  6.3434 +            "cbox m n \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} = cbox u v \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}"
  6.3435 +          have "(cbox m n \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<inter> (cbox u v \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<subseteq> cbox m n \<inter> cbox u v"
  6.3436              by blast
  6.3437 -          note interior_mono[OF this, unfolded division_ofD(5)[OF p'' as(1-3)] interior_inter[of "{m..n}"]]
  6.3438 -          then have "interior ({m..n} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) = {}"
  6.3439 +          note interior_mono[OF this, unfolded division_ofD(5)[OF p'' as(1-3)] interior_inter[of "cbox m n"]]
  6.3440 +          then have "interior (cbox m n \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) = {}"
  6.3441              unfolding as Int_absorb by auto
  6.3442 -          then show "content ({m..n} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) = 0"
  6.3443 +          then show "content (cbox m n \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) = 0"
  6.3444              unfolding interval_doublesplit[OF k] content_eq_0_interior[symmetric] .
  6.3445          qed
  6.3446        qed
  6.3447 @@ -5586,18 +5706,18 @@
  6.3448  subsection {* A technical lemma about "refinement" of division. *}
  6.3449  
  6.3450  lemma tagged_division_finer:
  6.3451 -  fixes p :: "('a::ordered_euclidean_space \<times> ('a::ordered_euclidean_space set)) set"
  6.3452 -  assumes "p tagged_division_of {a..b}"
  6.3453 +  fixes p :: "('a::euclidean_space \<times> ('a::euclidean_space set)) set"
  6.3454 +  assumes "p tagged_division_of (cbox a b)"
  6.3455      and "gauge d"
  6.3456 -  obtains q where "q tagged_division_of {a..b}"
  6.3457 +  obtains q where "q tagged_division_of (cbox a b)"
  6.3458      and "d fine q"
  6.3459      and "\<forall>(x,k) \<in> p. k \<subseteq> d(x) \<longrightarrow> (x,k) \<in> q"
  6.3460  proof -
  6.3461 -  let ?P = "\<lambda>p. p tagged_partial_division_of {a..b} \<longrightarrow> gauge d \<longrightarrow>
  6.3462 +  let ?P = "\<lambda>p. p tagged_partial_division_of (cbox a b) \<longrightarrow> gauge d \<longrightarrow>
  6.3463      (\<exists>q. q tagged_division_of (\<Union>{k. \<exists>x. (x,k) \<in> p}) \<and> d fine q \<and>
  6.3464        (\<forall>(x,k) \<in> p. k \<subseteq> d(x) \<longrightarrow> (x,k) \<in> q))"
  6.3465    {
  6.3466 -    have *: "finite p" "p tagged_partial_division_of {a..b}"
  6.3467 +    have *: "finite p" "p tagged_partial_division_of (cbox a b)"
  6.3468        using assms(1)
  6.3469        unfolding tagged_division_of_def
  6.3470        by auto
  6.3471 @@ -5610,7 +5730,7 @@
  6.3472        apply auto
  6.3473        done
  6.3474    }
  6.3475 -  fix p :: "('a::ordered_euclidean_space \<times> ('a::ordered_euclidean_space set)) set"
  6.3476 +  fix p :: "('a::euclidean_space \<times> ('a::euclidean_space set)) set"
  6.3477    assume as: "finite p"
  6.3478    show "?P p"
  6.3479      apply rule
  6.3480 @@ -5641,7 +5761,7 @@
  6.3481        using p
  6.3482        apply auto
  6.3483        done
  6.3484 -    then have int: "interior {u..v} \<inter> interior (\<Union>{k. \<exists>x. (x, k) \<in> p}) = {}"
  6.3485 +    then have int: "interior (cbox u v) \<inter> interior (\<Union>{k. \<exists>x. (x, k) \<in> p}) = {}"
  6.3486        apply (rule inter_interior_unions_intervals)
  6.3487        apply (rule open_interior)
  6.3488        apply (rule_tac[!] ballI)
  6.3489 @@ -5659,10 +5779,10 @@
  6.3490        apply auto
  6.3491        done
  6.3492      show ?case
  6.3493 -    proof (cases "{u..v} \<subseteq> d x")
  6.3494 +    proof (cases "cbox u v \<subseteq> d x")
  6.3495        case True
  6.3496        then show ?thesis
  6.3497 -        apply (rule_tac x="{(x,{u..v})} \<union> q1" in exI)
  6.3498 +        apply (rule_tac x="{(x,cbox u v)} \<union> q1" in exI)
  6.3499          apply rule
  6.3500          unfolding * uv
  6.3501          apply (rule tagged_division_union)
  6.3502 @@ -5767,13 +5887,13 @@
  6.3503  qed auto
  6.3504  
  6.3505  lemma has_integral_negligible:
  6.3506 -  fixes f :: "'b::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
  6.3507 +  fixes f :: "'b::euclidean_space \<Rightarrow> 'a::real_normed_vector"
  6.3508    assumes "negligible s"
  6.3509      and "\<forall>x\<in>(t - s). f x = 0"
  6.3510    shows "(f has_integral 0) t"
  6.3511  proof -
  6.3512 -  presume P: "\<And>f::'b::ordered_euclidean_space \<Rightarrow> 'a.
  6.3513 -    \<And>a b. \<forall>x. x \<notin> s \<longrightarrow> f x = 0 \<Longrightarrow> (f has_integral 0) {a..b}"
  6.3514 +  presume P: "\<And>f::'b::euclidean_space \<Rightarrow> 'a.
  6.3515 +    \<And>a b. \<forall>x. x \<notin> s \<longrightarrow> f x = 0 \<Longrightarrow> (f has_integral 0) (cbox a b)"
  6.3516    let ?f = "(\<lambda>x. if x \<in> t then f x else 0)"
  6.3517    show ?thesis
  6.3518      apply (rule_tac f="?f" in has_integral_eq)
  6.3519 @@ -5785,7 +5905,7 @@
  6.3520      apply (subst if_P, assumption)
  6.3521      unfolding if_not_P
  6.3522    proof -
  6.3523 -    assume "\<exists>a b. t = {a..b}"
  6.3524 +    assume "\<exists>a b. t = cbox a b"
  6.3525      then guess a b apply - by (erule exE)+ note t = this
  6.3526      show "(?f has_integral 0) t"
  6.3527        unfolding t
  6.3528 @@ -5795,8 +5915,8 @@
  6.3529        apply auto
  6.3530        done
  6.3531    next
  6.3532 -    show "\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow>
  6.3533 -      (\<exists>z. ((\<lambda>x. if x \<in> t then ?f x else 0) has_integral z) {a..b} \<and> norm (z - 0) < e)"
  6.3534 +    show "\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> cbox a b \<longrightarrow>
  6.3535 +      (\<exists>z. ((\<lambda>x. if x \<in> t then ?f x else 0) has_integral z) (cbox a b) \<and> norm (z - 0) < e)"
  6.3536        apply safe
  6.3537        apply (rule_tac x=1 in exI)
  6.3538        apply rule
  6.3539 @@ -5813,7 +5933,7 @@
  6.3540    fix f :: "'b \<Rightarrow> 'a"
  6.3541    fix a b :: 'b
  6.3542    assume assm: "\<forall>x. x \<notin> s \<longrightarrow> f x = 0"
  6.3543 -  show "(f has_integral 0) {a..b}"
  6.3544 +  show "(f has_integral 0) (cbox a b)"
  6.3545      unfolding has_integral
  6.3546    proof safe
  6.3547      case goal1
  6.3548 @@ -5833,7 +5953,7 @@
  6.3549        show "gauge (\<lambda>x. d (nat \<lfloor>norm (f x)\<rfloor>) x)"
  6.3550          using d(1) unfolding gauge_def by auto
  6.3551        fix p
  6.3552 -      assume as: "p tagged_division_of {a..b}" "(\<lambda>x. d (nat \<lfloor>norm (f x)\<rfloor>) x) fine p"
  6.3553 +      assume as: "p tagged_division_of (cbox a b)" "(\<lambda>x. d (nat \<lfloor>norm (f x)\<rfloor>) x) fine p"
  6.3554        let ?goal = "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) < e"
  6.3555        {
  6.3556          presume "p \<noteq> {} \<Longrightarrow> ?goal"
  6.3557 @@ -5850,7 +5970,7 @@
  6.3558          using as as'
  6.3559          apply auto
  6.3560          done
  6.3561 -      have "\<forall>i. \<exists>q. q tagged_division_of {a..b} \<and> (d i) fine q \<and> (\<forall>(x, k)\<in>p. k \<subseteq> (d i) x \<longrightarrow> (x, k) \<in> q)"
  6.3562 +      have "\<forall>i. \<exists>q. q tagged_division_of (cbox a b) \<and> (d i) fine q \<and> (\<forall>(x, k)\<in>p. k \<subseteq> (d i) x \<longrightarrow> (x, k) \<in> q)"
  6.3563          apply rule
  6.3564          apply (rule tagged_division_finer[OF as(1) d(1)])
  6.3565          apply auto
  6.3566 @@ -5977,7 +6097,7 @@
  6.3567  qed
  6.3568  
  6.3569  lemma has_integral_spike:
  6.3570 -  fixes f :: "'b::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
  6.3571 +  fixes f :: "'b::euclidean_space \<Rightarrow> 'a::real_normed_vector"
  6.3572    assumes "negligible s"
  6.3573      and "(\<forall>x\<in>(t - s). g x = f x)"
  6.3574      and "(f has_integral y) t"
  6.3575 @@ -5987,14 +6107,14 @@
  6.3576      fix a b :: 'b
  6.3577      fix f g :: "'b \<Rightarrow> 'a"
  6.3578      fix y :: 'a
  6.3579 -    assume as: "\<forall>x \<in> {a..b} - s. g x = f x" "(f has_integral y) {a..b}"
  6.3580 -    have "((\<lambda>x. f x + (g x - f x)) has_integral (y + 0)) {a..b}"
  6.3581 +    assume as: "\<forall>x \<in> cbox a b - s. g x = f x" "(f has_integral y) (cbox a b)"
  6.3582 +    have "((\<lambda>x. f x + (g x - f x)) has_integral (y + 0)) (cbox a b)"
  6.3583        apply (rule has_integral_add[OF as(2)])
  6.3584        apply (rule has_integral_negligible[OF assms(1)])
  6.3585        using as
  6.3586        apply auto
  6.3587        done
  6.3588 -    then have "(g has_integral y) {a..b}"
  6.3589 +    then have "(g has_integral y) (cbox a b)"
  6.3590        by auto
  6.3591    } note * = this
  6.3592    show ?thesis
  6.3593 @@ -6105,7 +6225,7 @@
  6.3594  lemma negligible_union_eq[simp]: "negligible (s \<union> t) \<longleftrightarrow> negligible s \<and> negligible t"
  6.3595    using negligible_union by auto
  6.3596  
  6.3597 -lemma negligible_sing[intro]: "negligible {a::'a::ordered_euclidean_space}"
  6.3598 +lemma negligible_sing[intro]: "negligible {a::'a::euclidean_space}"
  6.3599    using negligible_standard_hyperplane[OF SOME_Basis, of "a \<bullet> (SOME i. i \<in> Basis)"] by auto
  6.3600  
  6.3601  lemma negligible_insert[simp]: "negligible (insert a s) \<longleftrightarrow> negligible s"
  6.3602 @@ -6129,7 +6249,7 @@
  6.3603    using assms by induct auto
  6.3604  
  6.3605  lemma negligible:
  6.3606 -  "negligible s \<longleftrightarrow> (\<forall>t::('a::ordered_euclidean_space) set. ((indicator s::'a\<Rightarrow>real) has_integral 0) t)"
  6.3607 +  "negligible s \<longleftrightarrow> (\<forall>t::('a::euclidean_space) set. ((indicator s::'a\<Rightarrow>real) has_integral 0) t)"
  6.3608    apply safe
  6.3609    defer
  6.3610    apply (subst negligible_def)
  6.3611 @@ -6195,11 +6315,11 @@
  6.3612  
  6.3613  subsection {* In particular, the boundary of an interval is negligible. *}
  6.3614  
  6.3615 -lemma negligible_frontier_interval: "negligible({a::'a::ordered_euclidean_space..b} - box a b)"
  6.3616 +lemma negligible_frontier_interval: "negligible(cbox (a::'a::euclidean_space) b - box a b)"
  6.3617  proof -
  6.3618    let ?A = "\<Union>((\<lambda>k. {x. x\<bullet>k = a\<bullet>k} \<union> {x::'a. x\<bullet>k = b\<bullet>k}) ` Basis)"
  6.3619 -  have "{a..b} - box a b \<subseteq> ?A"
  6.3620 -    apply rule unfolding Diff_iff mem_interval
  6.3621 +  have "cbox a b - box a b \<subseteq> ?A"
  6.3622 +    apply rule unfolding Diff_iff mem_box
  6.3623      apply simp
  6.3624      apply(erule conjE bexE)+
  6.3625      apply(rule_tac x=i in bexI)
  6.3626 @@ -6215,8 +6335,8 @@
  6.3627  
  6.3628  lemma has_integral_spike_interior:
  6.3629    assumes "\<forall>x\<in>box a b. g x = f x"
  6.3630 -    and "(f has_integral y) ({a..b})"
  6.3631 -  shows "(g has_integral y) {a..b}"
  6.3632 +    and "(f has_integral y) (cbox a b)"
  6.3633 +  shows "(g has_integral y) (cbox a b)"
  6.3634    apply (rule has_integral_spike[OF negligible_frontier_interval _ assms(2)])
  6.3635    using assms(1)
  6.3636    apply auto
  6.3637 @@ -6224,7 +6344,7 @@
  6.3638  
  6.3639  lemma has_integral_spike_interior_eq:
  6.3640    assumes "\<forall>x\<in>box a b. g x = f x"
  6.3641 -  shows "(f has_integral y) {a..b} \<longleftrightarrow> (g has_integral y) {a..b}"
  6.3642 +  shows "(f has_integral y) (cbox a b) \<longleftrightarrow> (g has_integral y) (cbox a b)"
  6.3643    apply rule
  6.3644    apply (rule_tac[!] has_integral_spike_interior)
  6.3645    using assms
  6.3646 @@ -6233,8 +6353,8 @@
  6.3647  
  6.3648  lemma integrable_spike_interior:
  6.3649    assumes "\<forall>x\<in>box a b. g x = f x"
  6.3650 -    and "f integrable_on {a..b}"
  6.3651 -  shows "g integrable_on {a..b}"
  6.3652 +    and "f integrable_on cbox a b"
  6.3653 +  shows "g integrable_on cbox a b"
  6.3654    using assms
  6.3655    unfolding integrable_on_def
  6.3656    using has_integral_spike_interior[OF assms(1)]
  6.3657 @@ -6260,21 +6380,21 @@
  6.3658  
  6.3659  lemma operative_division_and:
  6.3660    assumes "operative op \<and> P"
  6.3661 -    and "d division_of {a..b}"
  6.3662 -  shows "(\<forall>i\<in>d. P i) \<longleftrightarrow> P {a..b}"
  6.3663 +    and "d division_of (cbox a b)"
  6.3664 +  shows "(\<forall>i\<in>d. P i) \<longleftrightarrow> P (cbox a b)"
  6.3665    using operative_division[OF monoidal_and assms] division_of_finite[OF assms(2)]
  6.3666    by auto
  6.3667  
  6.3668  lemma operative_approximable:
  6.3669 -  fixes f::"'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.3670 +  fixes f::"'b::euclidean_space \<Rightarrow> 'a::banach"
  6.3671    assumes "0 \<le> e"
  6.3672    shows "operative op \<and> (\<lambda>i. \<exists>g. (\<forall>x\<in>i. norm (f x - g (x::'b)) \<le> e) \<and> g integrable_on i)"
  6.3673    unfolding operative_def neutral_and
  6.3674  proof safe
  6.3675    fix a b :: 'b
  6.3676    {
  6.3677 -    assume "content {a..b} = 0"
  6.3678 -    then show "\<exists>g. (\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b}"
  6.3679 +    assume "content (cbox a b) = 0"
  6.3680 +    then show "\<exists>g. (\<forall>x\<in>cbox a b. norm (f x - g x) \<le> e) \<and> g integrable_on cbox a b"
  6.3681        apply (rule_tac x=f in exI)
  6.3682        using assms
  6.3683        apply (auto intro!:integrable_on_null)
  6.3684 @@ -6283,21 +6403,21 @@
  6.3685    {
  6.3686      fix c g
  6.3687      fix k :: 'b
  6.3688 -    assume as: "\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e" "g integrable_on {a..b}"
  6.3689 +    assume as: "\<forall>x\<in>cbox a b. norm (f x - g x) \<le> e" "g integrable_on cbox a b"
  6.3690      assume k: "k \<in> Basis"
  6.3691 -    show "\<exists>g. (\<forall>x\<in>{a..b} \<inter> {x. x \<bullet> k \<le> c}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c}"
  6.3692 -      "\<exists>g. (\<forall>x\<in>{a..b} \<inter> {x. c \<le> x \<bullet> k}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b} \<inter> {x. c \<le> x \<bullet> k}"
  6.3693 +    show "\<exists>g. (\<forall>x\<in>cbox a b \<inter> {x. x \<bullet> k \<le> c}. norm (f x - g x) \<le> e) \<and> g integrable_on cbox a b \<inter> {x. x \<bullet> k \<le> c}"
  6.3694 +      "\<exists>g. (\<forall>x\<in>cbox a b \<inter> {x. c \<le> x \<bullet> k}. norm (f x - g x) \<le> e) \<and> g integrable_on cbox a b \<inter> {x. c \<le> x \<bullet> k}"
  6.3695        apply (rule_tac[!] x=g in exI)
  6.3696        using as(1) integrable_split[OF as(2) k]
  6.3697        apply auto
  6.3698        done
  6.3699    }
  6.3700    fix c k g1 g2
  6.3701 -  assume as: "\<forall>x\<in>{a..b} \<inter> {x. x \<bullet> k \<le> c}. norm (f x - g1 x) \<le> e" "g1 integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c}"
  6.3702 -    "\<forall>x\<in>{a..b} \<inter> {x. c \<le> x \<bullet> k}. norm (f x - g2 x) \<le> e" "g2 integrable_on {a..b} \<inter> {x. c \<le> x \<bullet> k}"
  6.3703 +  assume as: "\<forall>x\<in>cbox a b \<inter> {x. x \<bullet> k \<le> c}. norm (f x - g1 x) \<le> e" "g1 integrable_on cbox a b \<inter> {x. x \<bullet> k \<le> c}"
  6.3704 +    "\<forall>x\<in>cbox a b \<inter> {x. c \<le> x \<bullet> k}. norm (f x - g2 x) \<le> e" "g2 integrable_on cbox a b \<inter> {x. c \<le> x \<bullet> k}"
  6.3705    assume k: "k \<in> Basis"
  6.3706    let ?g = "\<lambda>x. if x\<bullet>k = c then f x else if x\<bullet>k \<le> c then g1 x else g2 x"
  6.3707 -  show "\<exists>g. (\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b}"
  6.3708 +  show "\<exists>g. (\<forall>x\<in>cbox a b. norm (f x - g x) \<le> e) \<and> g integrable_on cbox a b"
  6.3709      apply (rule_tac x="?g" in exI)
  6.3710    proof safe
  6.3711      case goal1
  6.3712 @@ -6310,13 +6430,13 @@
  6.3713        done
  6.3714    next
  6.3715      case goal2
  6.3716 -    presume "?g integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c}"
  6.3717 -      and "?g integrable_on {a..b} \<inter> {x. x \<bullet> k \<ge> c}"
  6.3718 +    presume "?g integrable_on cbox a b \<inter> {x. x \<bullet> k \<le> c}"
  6.3719 +      and "?g integrable_on cbox a b \<inter> {x. x \<bullet> k \<ge> c}"
  6.3720      then guess h1 h2 unfolding integrable_on_def by auto
  6.3721      from has_integral_split[OF this k] show ?case
  6.3722        unfolding integrable_on_def by auto
  6.3723    next
  6.3724 -    show "?g integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c}" "?g integrable_on {a..b} \<inter> {x. x \<bullet> k \<ge> c}"
  6.3725 +    show "?g integrable_on cbox a b \<inter> {x. x \<bullet> k \<le> c}" "?g integrable_on cbox a b \<inter> {x. x \<bullet> k \<ge> c}"
  6.3726        apply(rule_tac[!] integrable_spike[OF negligible_standard_hyperplane[of k c]])
  6.3727        using k as(2,4)
  6.3728        apply auto
  6.3729 @@ -6325,11 +6445,11 @@
  6.3730  qed
  6.3731  
  6.3732  lemma approximable_on_division:
  6.3733 -  fixes f :: "'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.3734 +  fixes f :: "'b::euclidean_space \<Rightarrow> 'a::banach"
  6.3735    assumes "0 \<le> e"
  6.3736 -    and "d division_of {a..b}"
  6.3737 +    and "d division_of (cbox a b)"
  6.3738      and "\<forall>i\<in>d. \<exists>g. (\<forall>x\<in>i. norm (f x - g x) \<le> e) \<and> g integrable_on i"
  6.3739 -  obtains g where "\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e" "g integrable_on {a..b}"
  6.3740 +  obtains g where "\<forall>x\<in>cbox a b. norm (f x - g x) \<le> e" "g integrable_on cbox a b"
  6.3741  proof -
  6.3742    note * = operative_division[OF monoidal_and operative_approximable[OF assms(1)] assms(2)]
  6.3743    note this[unfolded iterate_and[OF division_of_finite[OF assms(2)]]]
  6.3744 @@ -6342,13 +6462,13 @@
  6.3745  qed
  6.3746  
  6.3747  lemma integrable_continuous:
  6.3748 -  fixes f :: "'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.3749 -  assumes "continuous_on {a..b} f"
  6.3750 -  shows "f integrable_on {a..b}"
  6.3751 +  fixes f :: "'b::euclidean_space \<Rightarrow> 'a::banach"
  6.3752 +  assumes "continuous_on (cbox a b) f"
  6.3753 +  shows "f integrable_on cbox a b"
  6.3754  proof (rule integrable_uniform_limit, safe)
  6.3755    fix e :: real
  6.3756    assume e: "e > 0"
  6.3757 -  from compact_uniformly_continuous[OF assms compact_interval,unfolded uniformly_continuous_on_def,rule_format,OF e] guess d ..
  6.3758 +  from compact_uniformly_continuous[OF assms compact_cbox,unfolded uniformly_continuous_on_def,rule_format,OF e] guess d ..
  6.3759    note d=conjunctD2[OF this,rule_format]
  6.3760    from fine_division_exists[OF gauge_ball[OF d(1)], of a b] guess p . note p=this
  6.3761    note p' = tagged_division_ofD[OF p(1)]
  6.3762 @@ -6376,10 +6496,16 @@
  6.3763    from e have "e \<ge> 0"
  6.3764      by auto
  6.3765    from approximable_on_division[OF this division_of_tagged_division[OF p(1)] *] guess g .
  6.3766 -  then show "\<exists>g. (\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b}"
  6.3767 +  then show "\<exists>g. (\<forall>x\<in>cbox a b. norm (f x - g x) \<le> e) \<and> g integrable_on cbox a b"
  6.3768      by auto
  6.3769  qed
  6.3770  
  6.3771 +lemma integrable_continuous_real:
  6.3772 +  fixes f :: "real \<Rightarrow> 'a::banach"
  6.3773 +  assumes "continuous_on {a .. b} f"
  6.3774 +  shows "f integrable_on {a .. b}"
  6.3775 +  by (metis assms box_real(2) integrable_continuous)
  6.3776 +
  6.3777  
  6.3778  subsection {* Specialization of additivity to one dimension. *}
  6.3779  
  6.3780 @@ -6388,26 +6514,36 @@
  6.3781    and real_inner_1_right: "inner x 1 = x"
  6.3782    by simp_all
  6.3783  
  6.3784 +lemma content_real_eq_0: "content {a .. b::real} = 0 \<longleftrightarrow> a \<ge> b"
  6.3785 +  by (metis atLeastatMost_empty_iff2 content_empty content_real diff_self eq_iff le_cases le_iff_diff_le_0)
  6.3786 +
  6.3787 +lemma interval_real_split:
  6.3788 +  "{a .. b::real} \<inter> {x. x \<le> c} = {a .. min b c}"
  6.3789 +  "{a .. b} \<inter> {x. c \<le> x} = {max a c .. b}"
  6.3790 +  apply (metis Int_atLeastAtMostL1 atMost_def)
  6.3791 +  apply (metis Int_atLeastAtMostL2 atLeast_def)
  6.3792 +  done
  6.3793 +
  6.3794  lemma operative_1_lt:
  6.3795    assumes "monoidal opp"
  6.3796 -  shows "operative opp f \<longleftrightarrow> ((\<forall>a b. b \<le> a \<longrightarrow> f {a..b::real} = neutral opp) \<and>
  6.3797 -    (\<forall>a b c. a < c \<and> c < b \<longrightarrow> opp (f {a..c}) (f {c..b}) = f {a..b}))"
  6.3798 -  apply (simp add: operative_def content_eq_0)
  6.3799 +  shows "operative opp f \<longleftrightarrow> ((\<forall>a b. b \<le> a \<longrightarrow> f {a .. b::real} = neutral opp) \<and>
  6.3800 +    (\<forall>a b c. a < c \<and> c < b \<longrightarrow> opp (f {a .. c}) (f {c .. b}) = f {a .. b}))"
  6.3801 +  apply (simp add: operative_def content_real_eq_0)
  6.3802  proof safe
  6.3803    fix a b c :: real
  6.3804    assume as:
  6.3805 -    "\<forall>a b c. f {a..b} = opp (f ({a..b} \<inter> {x. x \<le> c})) (f ({a..b} \<inter> {x. c \<le> x}))"
  6.3806 +    "\<forall>a b c. f {a..b} = opp (f ({a..b} \<inter> {x. x \<le> c})) (f ({a..b} \<inter> Collect (op \<le> c)))"
  6.3807      "a < c"
  6.3808      "c < b"
  6.3809 -    from this(2-) have "{a..b} \<inter> {x. x \<le> c} = {a..c}" "{a..b} \<inter> {x. x \<ge> c} = {c..b}"
  6.3810 -      by auto
  6.3811 +    from this(2-) have "cbox a b \<inter> {x. x \<le> c} = cbox a c" "cbox a b \<inter> {x. x \<ge> c} = cbox c b"
  6.3812 +      by (auto simp: mem_box)
  6.3813      then show "opp (f {a..c}) (f {c..b}) = f {a..b}"
  6.3814        unfolding as(1)[rule_format,of a b "c"] by auto
  6.3815  next
  6.3816    fix a b c :: real
  6.3817    assume as: "\<forall>a b. b \<le> a \<longrightarrow> f {a..b} = neutral opp"
  6.3818      "\<forall>a b c. a < c \<and> c < b \<longrightarrow> opp (f {a..c}) (f {c..b}) = f {a..b}"
  6.3819 -  show "f {a..b} = opp (f ({a..b} \<inter> {x. x \<le> c})) (f ({a..b} \<inter> {x. c \<le> x}))"
  6.3820 +  show " f {a..b} = opp (f ({a..b} \<inter> {x. x \<le> c})) (f ({a..b} \<inter> Collect (op \<le> c)))"
  6.3821    proof (cases "c \<in> {a..b}")
  6.3822      case False
  6.3823      then have "c < a \<or> c > b" by auto
  6.3824 @@ -6424,7 +6560,7 @@
  6.3825          done
  6.3826      next
  6.3827        assume "b < c"
  6.3828 -      then have *: "{a..b} \<inter> {x. x \<le> c} = {a..b}" "{a..b} \<inter> {x. c \<le> x} = {1..0}"
  6.3829 +      then have *: "{a..b} \<inter> {x. x \<le> c} = {a..b}" "{a..b} \<inter> {x. c \<le> x} = {1 .. 0}"
  6.3830          by auto
  6.3831        show ?thesis
  6.3832          unfolding *
  6.3833 @@ -6442,7 +6578,7 @@
  6.3834      have ***: "\<And>P Q. (\<Sum>i\<in>Basis. (if i = 1 then P i else Q i) *\<^sub>R i) = (P 1::real)"
  6.3835        by simp
  6.3836      show ?thesis
  6.3837 -      unfolding interval_split[OF **, unfolded real_inner_1_right] unfolding *** *
  6.3838 +      unfolding interval_real_split unfolding *
  6.3839      proof (cases "c = a \<or> c = b")
  6.3840        case False
  6.3841        then show "f {a..b} = opp (f {a..c}) (f {c..b})"
  6.3842 @@ -6456,7 +6592,7 @@
  6.3843        then show "f {a..b} = opp (f {a..c}) (f {c..b})"
  6.3844        proof
  6.3845          assume *: "c = a"
  6.3846 -        then have "f {a..c} = neutral opp"
  6.3847 +        then have "f {a .. c} = neutral opp"
  6.3848            apply -
  6.3849            apply (rule as(1)[rule_format])
  6.3850            apply auto
  6.3851 @@ -6465,7 +6601,7 @@
  6.3852            using assms unfolding * by auto
  6.3853        next
  6.3854          assume *: "c = b"
  6.3855 -        then have "f {c..b} = neutral opp"
  6.3856 +        then have "f {c .. b} = neutral opp"
  6.3857            apply -
  6.3858            apply (rule as(1)[rule_format])
  6.3859            apply auto
  6.3860 @@ -6479,8 +6615,8 @@
  6.3861  
  6.3862  lemma operative_1_le:
  6.3863    assumes "monoidal opp"
  6.3864 -  shows "operative opp f \<longleftrightarrow> ((\<forall>a b. b \<le> a \<longrightarrow> f {a..b::real} = neutral opp) \<and>
  6.3865 -    (\<forall>a b c. a \<le> c \<and> c \<le> b \<longrightarrow> opp (f {a..c}) (f {c..b}) = f {a..b}))"
  6.3866 +  shows "operative opp f \<longleftrightarrow> ((\<forall>a b. b \<le> a \<longrightarrow> f {a .. b::real} = neutral opp) \<and>
  6.3867 +    (\<forall>a b c. a \<le> c \<and> c \<le> b \<longrightarrow> opp (f {a .. c}) (f {c .. b}) = f {a .. b}))"
  6.3868    unfolding operative_1_lt[OF assms]
  6.3869  proof safe
  6.3870    fix a b c :: real
  6.3871 @@ -6495,7 +6631,7 @@
  6.3872      done
  6.3873  next
  6.3874    fix a b c :: real
  6.3875 -  assume "\<forall>a b. b \<le> a \<longrightarrow> f {a..b} = neutral opp"
  6.3876 +  assume "\<forall>a b. b \<le> a \<longrightarrow> f {a .. b} = neutral opp"
  6.3877      and "\<forall>a b c. a < c \<and> c < b \<longrightarrow> opp (f {a..c}) (f {c..b}) = f {a..b}"
  6.3878      and "a \<le> c"
  6.3879      and "c \<le> b"
  6.3880 @@ -6514,7 +6650,7 @@
  6.3881      then show ?thesis
  6.3882      proof
  6.3883        assume *: "c = a"
  6.3884 -      then have "f {a..c} = neutral opp"
  6.3885 +      then have "f {a .. c} = neutral opp"
  6.3886          apply -
  6.3887          apply (rule as(1)[rule_format])
  6.3888          apply auto
  6.3889 @@ -6523,7 +6659,7 @@
  6.3890          using assms unfolding * by auto
  6.3891      next
  6.3892        assume *: "c = b"
  6.3893 -      then have "f {c..b} = neutral opp"
  6.3894 +      then have "f {c .. b} = neutral opp"
  6.3895          apply -
  6.3896          apply (rule as(1)[rule_format])
  6.3897          apply auto
  6.3898 @@ -6543,13 +6679,15 @@
  6.3899      and "p tagged_division_of {a..b}"
  6.3900    shows "setsum (\<lambda>(x,k). f(Sup k) - f(Inf k)) p = f b - f a"
  6.3901  proof -
  6.3902 -  let ?f = "(\<lambda>k::(real) set. if k = {} then 0 else f(Sup k) - f(Inf k))"
  6.3903 +  let ?f = "(\<lambda>k::(real) set. if k = {} then 0 else f(interval_upperbound k) - f(interval_lowerbound k))"
  6.3904    have ***: "\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i"
  6.3905      using assms by auto
  6.3906    have *: "operative op + ?f"
  6.3907 -    unfolding operative_1_lt[OF monoidal_monoid] interval_eq_empty by auto
  6.3908 -  have **: "{a..b} \<noteq> {}"
  6.3909 -    using assms(1) by auto note operative_tagged_division[OF monoidal_monoid * assms(2)]
  6.3910 +    unfolding operative_1_lt[OF monoidal_monoid] box_eq_empty
  6.3911 +    by auto
  6.3912 +  have **: "cbox a b \<noteq> {}"
  6.3913 +    using assms(1) by auto
  6.3914 +  note operative_tagged_division[OF monoidal_monoid * assms(2)[simplified box_real[symmetric]]]
  6.3915    note * = this[unfolded if_not_P[OF **] interval_bounds[OF ***],symmetric]
  6.3916    show ?thesis
  6.3917      unfolding *
  6.3918 @@ -6566,10 +6704,10 @@
  6.3919  subsection {* A useful lemma allowing us to factor out the content size. *}
  6.3920  
  6.3921  lemma has_integral_factor_content:
  6.3922 -  "(f has_integral i) {a..b} \<longleftrightarrow>
  6.3923 -    (\<forall>e>0. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
  6.3924 -      norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - i) \<le> e * content {a..b}))"
  6.3925 -proof (cases "content {a..b} = 0")
  6.3926 +  "(f has_integral i) (cbox a b) \<longleftrightarrow>
  6.3927 +    (\<forall>e>0. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
  6.3928 +      norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - i) \<le> e * content (cbox a b)))"
  6.3929 +proof (cases "content (cbox a b) = 0")
  6.3930    case True
  6.3931    show ?thesis
  6.3932      unfolding has_integral_null_eq[OF True]
  6.3933 @@ -6590,7 +6728,7 @@
  6.3934    case False
  6.3935    note F = this[unfolded content_lt_nz[symmetric]]
  6.3936    let ?P = "\<lambda>e opp. \<exists>d. gauge d \<and>
  6.3937 -    (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow> opp (norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - i)) e)"
  6.3938 +    (\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow> opp (norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - i)) e)"
  6.3939    show ?thesis
  6.3940      apply (subst has_integral)
  6.3941    proof safe
  6.3942 @@ -6598,8 +6736,8 @@
  6.3943      assume e: "e > 0"
  6.3944      {
  6.3945        assume "\<forall>e>0. ?P e op <"
  6.3946 -      then show "?P (e * content {a..b}) op \<le>"
  6.3947 -        apply (erule_tac x="e * content {a..b}" in allE)
  6.3948 +      then show "?P (e * content (cbox a b)) op \<le>"
  6.3949 +        apply (erule_tac x="e * content (cbox a b)" in allE)
  6.3950          apply (erule impE)
  6.3951          defer
  6.3952          apply (erule exE,rule_tac x=d in exI)
  6.3953 @@ -6608,9 +6746,9 @@
  6.3954          done
  6.3955      }
  6.3956      {
  6.3957 -      assume "\<forall>e>0. ?P (e * content {a..b}) op \<le>"
  6.3958 +      assume "\<forall>e>0. ?P (e * content (cbox a b)) op \<le>"
  6.3959        then show "?P e op <"
  6.3960 -        apply (erule_tac x="e / 2 / content {a..b}" in allE)
  6.3961 +        apply (erule_tac x="e / 2 / content (cbox a b)" in allE)
  6.3962          apply (erule impE)
  6.3963          defer
  6.3964          apply (erule exE,rule_tac x=d in exI)
  6.3965 @@ -6621,6 +6759,13 @@
  6.3966    qed
  6.3967  qed
  6.3968  
  6.3969 +lemma has_integral_factor_content_real:
  6.3970 +  "(f has_integral i) {a .. b::real} \<longleftrightarrow>
  6.3971 +    (\<forall>e>0. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a .. b}  \<and> d fine p \<longrightarrow>
  6.3972 +      norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - i) \<le> e * content {a .. b} ))"
  6.3973 +  unfolding box_real[symmetric]
  6.3974 +  by (rule has_integral_factor_content)
  6.3975 +
  6.3976  
  6.3977  subsection {* Fundamental theorem of calculus. *}
  6.3978  
  6.3979 @@ -6629,28 +6774,25 @@
  6.3980    assumes "a \<le> b"
  6.3981    shows "Sup {a..b} = b"
  6.3982      and "Inf {a..b} = a"
  6.3983 -  apply (rule_tac[!] interval_bounds)
  6.3984 -  using assms
  6.3985 -  apply auto
  6.3986 -  done
  6.3987 +  using assms by auto
  6.3988  
  6.3989  lemma fundamental_theorem_of_calculus:
  6.3990    fixes f :: "real \<Rightarrow> 'a::banach"
  6.3991    assumes "a \<le> b"
  6.3992 -    and "\<forall>x\<in>{a..b}. (f has_vector_derivative f' x) (at x within {a..b})"
  6.3993 -  shows "(f' has_integral (f b - f a)) {a..b}"
  6.3994 -  unfolding has_integral_factor_content
  6.3995 +    and "\<forall>x\<in>{a .. b}. (f has_vector_derivative f' x) (at x within {a .. b})"
  6.3996 +  shows "(f' has_integral (f b - f a)) {a .. b}"
  6.3997 +  unfolding has_integral_factor_content box_real[symmetric]
  6.3998  proof safe
  6.3999    fix e :: real
  6.4000    assume e: "e > 0"
  6.4001    note assm = assms(2)[unfolded has_vector_derivative_def has_derivative_within_alt]
  6.4002 -  have *: "\<And>P Q. \<forall>x\<in>{a..b}. P x \<and> (\<forall>e>0. \<exists>d>0. Q x e d) \<Longrightarrow> \<forall>x. \<exists>(d::real)>0. x\<in>{a..b} \<longrightarrow> Q x e d"
  6.4003 +  have *: "\<And>P Q. \<forall>x\<in>{a .. b}. P x \<and> (\<forall>e>0. \<exists>d>0. Q x e d) \<Longrightarrow> \<forall>x. \<exists>(d::real)>0. x\<in>{a .. b} \<longrightarrow> Q x e d"
  6.4004      using e by blast
  6.4005    note this[OF assm,unfolded gauge_existence_lemma]
  6.4006    from choice[OF this,unfolded Ball_def[symmetric]] guess d ..
  6.4007    note d=conjunctD2[OF this[rule_format],rule_format]
  6.4008 -  show "\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
  6.4009 -    norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f' x) - (f b - f a)) \<le> e * content {a..b})"
  6.4010 +  show "\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
  6.4011 +    norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f' x) - (f b - f a)) \<le> e * content (cbox a b))"
  6.4012      apply (rule_tac x="\<lambda>x. ball x (d x)" in exI)
  6.4013      apply safe
  6.4014      apply (rule gauge_ball_dependent)
  6.4015 @@ -6658,10 +6800,10 @@
  6.4016      apply (rule d(1))
  6.4017    proof -
  6.4018      fix p
  6.4019 -    assume as: "p tagged_division_of {a..b}" "(\<lambda>x. ball x (d x)) fine p"
  6.4020 -    show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f' x) - (f b - f a)) \<le> e * content {a..b}"
  6.4021 -      unfolding content_real[OF assms(1)] additive_tagged_division_1[OF assms(1) as(1),of f,symmetric]
  6.4022 -      unfolding additive_tagged_division_1[OF assms(1) as(1),of "\<lambda>x. x",symmetric]
  6.4023 +    assume as: "p tagged_division_of cbox a b" "(\<lambda>x. ball x (d x)) fine p"
  6.4024 +    show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f' x) - (f b - f a)) \<le> e * content (cbox a b)"
  6.4025 +      unfolding content_real[OF assms(1), simplified box_real[symmetric]] additive_tagged_division_1[OF assms(1) as(1)[simplified box_real],of f,symmetric]
  6.4026 +      unfolding additive_tagged_division_1[OF assms(1) as(1)[simplified box_real],of "\<lambda>x. x",symmetric]
  6.4027        unfolding setsum_right_distrib
  6.4028        defer
  6.4029        unfolding setsum_subtractf[symmetric]
  6.4030 @@ -6699,7 +6841,9 @@
  6.4031          by (auto simp add: dist_real_def field_simps)
  6.4032        finally show "norm (content k *\<^sub>R f' x - (f (Sup k) - f (Inf k))) \<le>
  6.4033          e * (Sup k - Inf k)"
  6.4034 -        unfolding k interval_bounds_real[OF *] content_real[OF *] .
  6.4035 +        unfolding box_real k interval_bounds_real[OF *] content_real[OF *]
  6.4036 +          interval_upperbound_real interval_lowerbound_real
  6.4037 +          .
  6.4038      qed
  6.4039    qed
  6.4040  qed
  6.4041 @@ -6723,19 +6867,19 @@
  6.4042  subsection {* Only need trivial subintervals if the interval itself is trivial. *}
  6.4043  
  6.4044  lemma division_of_nontrivial:
  6.4045 -  fixes s :: "'a::ordered_euclidean_space set set"
  6.4046 -  assumes "s division_of {a..b}"
  6.4047 -    and "content {a..b} \<noteq> 0"
  6.4048 -  shows "{k. k \<in> s \<and> content k \<noteq> 0} division_of {a..b}"
  6.4049 +  fixes s :: "'a::euclidean_space set set"
  6.4050 +  assumes "s division_of (cbox a b)"
  6.4051 +    and "content (cbox a b) \<noteq> 0"
  6.4052 +  shows "{k. k \<in> s \<and> content k \<noteq> 0} division_of (cbox a b)"
  6.4053    using assms(1)
  6.4054    apply -
  6.4055  proof (induct "card s" arbitrary: s rule: nat_less_induct)
  6.4056    fix s::"'a set set"
  6.4057 -  assume assm: "s division_of {a..b}"
  6.4058 +  assume assm: "s division_of (cbox a b)"
  6.4059      "\<forall>m<card s. \<forall>x. m = card x \<longrightarrow>
  6.4060 -      x division_of {a..b} \<longrightarrow> {k \<in> x. content k \<noteq> 0} division_of {a..b}"
  6.4061 +      x division_of (cbox a b) \<longrightarrow> {k \<in> x. content k \<noteq> 0} division_of (cbox a b)"
  6.4062    note s = division_ofD[OF assm(1)]
  6.4063 -  let ?thesis = "{k \<in> s. content k \<noteq> 0} division_of {a..b}"
  6.4064 +  let ?thesis = "{k \<in> s. content k \<noteq> 0} division_of (cbox a b)"
  6.4065    {
  6.4066      presume *: "{k \<in> s. content k \<noteq> 0} \<noteq> s \<Longrightarrow> ?thesis"
  6.4067      show ?thesis
  6.4068 @@ -6763,8 +6907,6 @@
  6.4069      defer
  6.4070      apply rule
  6.4071      apply (drule DiffD1,drule s(4))
  6.4072 -    apply safe
  6.4073 -    apply (rule closed_interval)
  6.4074      using assm(1)
  6.4075      apply auto
  6.4076      done
  6.4077 @@ -6778,23 +6920,23 @@
  6.4078      assume as: "x \<in> k" "e > 0"
  6.4079      from k(2)[unfolded k content_eq_0] guess i ..
  6.4080      then have i:"c\<bullet>i = d\<bullet>i" "i\<in>Basis"
  6.4081 -      using s(3)[OF k(1),unfolded k] unfolding interval_ne_empty by auto
  6.4082 +      using s(3)[OF k(1),unfolded k] unfolding box_ne_empty by auto
  6.4083      then have xi: "x\<bullet>i = d\<bullet>i"
  6.4084 -      using as unfolding k mem_interval by (metis antisym)
  6.4085 +      using as unfolding k mem_box by (metis antisym)
  6.4086      def y \<equiv> "\<Sum>j\<in>Basis. (if j = i then if c\<bullet>i \<le> (a\<bullet>i + b\<bullet>i) / 2 then c\<bullet>i +
  6.4087        min e (b\<bullet>i - c\<bullet>i) / 2 else c\<bullet>i - min e (c\<bullet>i - a\<bullet>i) / 2 else x\<bullet>j) *\<^sub>R j"
  6.4088      show "\<exists>x'\<in>\<Union>(s - {k}). x' \<noteq> x \<and> dist x' x < e"
  6.4089        apply (rule_tac x=y in bexI)
  6.4090      proof
  6.4091 -      have "d \<in> {c..d}"
  6.4092 +      have "d \<in> cbox c d"
  6.4093          using s(3)[OF k(1)]
  6.4094 -        unfolding k interval_eq_empty mem_interval
  6.4095 +        unfolding k box_eq_empty mem_box
  6.4096          by (fastforce simp add: not_less)
  6.4097 -      then have "d \<in> {a..b}"
  6.4098 +      then have "d \<in> cbox a b"
  6.4099          using s(2)[OF k(1)]
  6.4100          unfolding k
  6.4101          by auto
  6.4102 -      note di = this[unfolded mem_interval,THEN bspec[where x=i]]
  6.4103 +      note di = this[unfolded mem_box,THEN bspec[where x=i]]
  6.4104        then have xyi: "y\<bullet>i \<noteq> x\<bullet>i"
  6.4105          unfolding y_def i xi
  6.4106          using as(2) assms(2)[unfolded content_eq_0] i(2)
  6.4107 @@ -6818,7 +6960,7 @@
  6.4108        then show "dist y x < e"
  6.4109          unfolding dist_norm by auto
  6.4110        have "y \<notin> k"
  6.4111 -        unfolding k mem_interval
  6.4112 +        unfolding k mem_box
  6.4113          apply rule
  6.4114          apply (erule_tac x=i in ballE)
  6.4115          using xyi k i xi
  6.4116 @@ -6827,15 +6969,15 @@
  6.4117        moreover
  6.4118        have "y \<in> \<Union>s"
  6.4119          using set_rev_mp[OF as(1) s(2)[OF k(1)]] as(2) di i
  6.4120 -        unfolding s mem_interval y_def
  6.4121 +        unfolding s mem_box y_def
  6.4122          by (auto simp: field_simps elim!: ballE[of _ _ i])
  6.4123        ultimately
  6.4124        show "y \<in> \<Union>(s - {k})" by auto
  6.4125      qed
  6.4126    qed
  6.4127 -  then have "\<Union>(s - {k}) = {a..b}"
  6.4128 +  then have "\<Union>(s - {k}) = cbox a b"
  6.4129      unfolding s(6)[symmetric] by auto
  6.4130 -  then have  "{ka \<in> s - {k}. content ka \<noteq> 0} division_of {a..b}"
  6.4131 +  then have  "{ka \<in> s - {k}. content ka \<noteq> 0} division_of (cbox a b)"
  6.4132      apply -
  6.4133      apply (rule assm(2)[rule_format,OF card refl])
  6.4134      apply (rule division_ofI)
  6.4135 @@ -6854,7 +6996,7 @@
  6.4136  subsection {* Integrability on subintervals. *}
  6.4137  
  6.4138  lemma operative_integrable:
  6.4139 -  fixes f :: "'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.4140 +  fixes f :: "'b::euclidean_space \<Rightarrow> 'a::banach"
  6.4141    shows "operative op \<and> (\<lambda>i. f integrable_on i)"
  6.4142    unfolding operative_def neutral_and
  6.4143    apply safe
  6.4144 @@ -6866,17 +7008,24 @@
  6.4145    by (auto intro!: has_integral_split)
  6.4146  
  6.4147  lemma integrable_subinterval:
  6.4148 -  fixes f :: "'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.4149 -  assumes "f integrable_on {a..b}"
  6.4150 -    and "{c..d} \<subseteq> {a..b}"
  6.4151 -  shows "f integrable_on {c..d}"
  6.4152 -  apply (cases "{c..d} = {}")
  6.4153 +  fixes f :: "'b::euclidean_space \<Rightarrow> 'a::banach"
  6.4154 +  assumes "f integrable_on cbox a b"
  6.4155 +    and "cbox c d \<subseteq> cbox a b"
  6.4156 +  shows "f integrable_on cbox c d"
  6.4157 +  apply (cases "cbox c d = {}")
  6.4158    defer
  6.4159    apply (rule partial_division_extend_1[OF assms(2)],assumption)
  6.4160    using operative_division_and[OF operative_integrable,symmetric,of _ _ _ f] assms(1)
  6.4161    apply auto
  6.4162    done
  6.4163  
  6.4164 +lemma integrable_subinterval_real:
  6.4165 +  fixes f :: "real \<Rightarrow> 'a::banach"
  6.4166 +  assumes "f integrable_on {a .. b}"
  6.4167 +    and "{c .. d} \<subseteq> {a .. b}"
  6.4168 +  shows "f integrable_on {c .. d}"
  6.4169 +  by (metis assms(1) assms(2) box_real(2) integrable_subinterval)
  6.4170 +
  6.4171  
  6.4172  subsection {* Combining adjacent intervals in 1 dimension. *}
  6.4173  
  6.4174 @@ -6884,14 +7033,14 @@
  6.4175    fixes a b c :: real
  6.4176    assumes "a \<le> c"
  6.4177      and "c \<le> b"
  6.4178 -    and "(f has_integral i) {a..c}"
  6.4179 -    and "(f has_integral (j::'a::banach)) {c..b}"
  6.4180 -  shows "(f has_integral (i + j)) {a..b}"
  6.4181 +    and "(f has_integral i) {a .. c}"
  6.4182 +    and "(f has_integral (j::'a::banach)) {c .. b}"
  6.4183 +  shows "(f has_integral (i + j)) {a .. b}"
  6.4184  proof -
  6.4185    note operative_integral[of f, unfolded operative_1_le[OF monoidal_lifted[OF monoidal_monoid]]]
  6.4186    note conjunctD2[OF this,rule_format]
  6.4187    note * = this(2)[OF conjI[OF assms(1-2)],unfolded if_P[OF assms(3)]]
  6.4188 -  then have "f integrable_on {a..b}"
  6.4189 +  then have "f integrable_on cbox a b"
  6.4190      apply -
  6.4191      apply (rule ccontr)
  6.4192      apply (subst(asm) if_P)
  6.4193 @@ -6918,22 +7067,20 @@
  6.4194    fixes f :: "real \<Rightarrow> 'a::banach"
  6.4195    assumes "a \<le> c"
  6.4196      and "c \<le> b"
  6.4197 -    and "f integrable_on {a..b}"
  6.4198 -  shows "integral {a..c} f + integral {c..b} f = integral {a..b} f"
  6.4199 +    and "f integrable_on {a .. b}"
  6.4200 +  shows "integral {a .. c} f + integral {c .. b} f = integral {a .. b} f"
  6.4201    apply (rule integral_unique[symmetric])
  6.4202    apply (rule has_integral_combine[OF assms(1-2)])
  6.4203 -  apply (rule_tac[!] integrable_integral integrable_subinterval[OF assms(3)])+
  6.4204 -  using assms(1-2)
  6.4205 -  apply auto
  6.4206 -  done
  6.4207 +  apply (metis assms(2) assms(3) atLeastatMost_subset_iff box_real(2) content_pos_le content_real_eq_0 integrable_integral integrable_subinterval le_add_same_cancel2 monoid_add_class.add.left_neutral)
  6.4208 +  by (metis assms(1) assms(3) atLeastatMost_subset_iff box_real(2) content_pos_le content_real_eq_0 integrable_integral integrable_subinterval le_add_same_cancel1 monoid_add_class.add.right_neutral)
  6.4209  
  6.4210  lemma integrable_combine:
  6.4211    fixes f :: "real \<Rightarrow> 'a::banach"
  6.4212    assumes "a \<le> c"
  6.4213      and "c \<le> b"
  6.4214 -    and "f integrable_on {a..c}"
  6.4215 -    and "f integrable_on {c..b}"
  6.4216 -  shows "f integrable_on {a..b}"
  6.4217 +    and "f integrable_on {a .. c}"
  6.4218 +    and "f integrable_on {c .. b}"
  6.4219 +  shows "f integrable_on {a .. b}"
  6.4220    using assms
  6.4221    unfolding integrable_on_def
  6.4222    by (fastforce intro!:has_integral_combine)
  6.4223 @@ -6942,13 +7089,13 @@
  6.4224  subsection {* Reduce integrability to "local" integrability. *}
  6.4225  
  6.4226  lemma integrable_on_little_subintervals:
  6.4227 -  fixes f :: "'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.4228 -  assumes "\<forall>x\<in>{a..b}. \<exists>d>0. \<forall>u v. x \<in> {u..v} \<and> {u..v} \<subseteq> ball x d \<and> {u..v} \<subseteq> {a..b} \<longrightarrow>
  6.4229 -    f integrable_on {u..v}"
  6.4230 -  shows "f integrable_on {a..b}"
  6.4231 -proof -
  6.4232 -  have "\<forall>x. \<exists>d. x\<in>{a..b} \<longrightarrow> d>0 \<and> (\<forall>u v. x \<in> {u..v} \<and> {u..v} \<subseteq> ball x d \<and> {u..v} \<subseteq> {a..b} \<longrightarrow>
  6.4233 -    f integrable_on {u..v})"
  6.4234 +  fixes f :: "'b::euclidean_space \<Rightarrow> 'a::banach"
  6.4235 +  assumes "\<forall>x\<in>cbox a b. \<exists>d>0. \<forall>u v. x \<in> cbox u v \<and> cbox u v \<subseteq> ball x d \<and> cbox u v \<subseteq> cbox a b \<longrightarrow>
  6.4236 +    f integrable_on cbox u v"
  6.4237 +  shows "f integrable_on cbox a b"
  6.4238 +proof -
  6.4239 +  have "\<forall>x. \<exists>d. x\<in>cbox a b \<longrightarrow> d>0 \<and> (\<forall>u v. x \<in> cbox u v \<and> cbox u v \<subseteq> ball x d \<and> cbox u v \<subseteq> cbox a b \<longrightarrow>
  6.4240 +    f integrable_on cbox u v)"
  6.4241      using assms by auto
  6.4242    note this[unfolded gauge_existence_lemma]
  6.4243    from choice[OF this] guess d .. note d=this[rule_format]
  6.4244 @@ -6978,35 +7125,41 @@
  6.4245  
  6.4246  subsection {* Second FCT or existence of antiderivative. *}
  6.4247  
  6.4248 -lemma integrable_const[intro]: "(\<lambda>x. c) integrable_on {a..b}"
  6.4249 +lemma integrable_const[intro]: "(\<lambda>x. c) integrable_on cbox a b"
  6.4250    unfolding integrable_on_def
  6.4251    apply rule
  6.4252    apply (rule has_integral_const)
  6.4253    done
  6.4254  
  6.4255 +lemma integrable_const_ivl[intro]:
  6.4256 +  fixes a::"'a::ordered_euclidean_space"
  6.4257 +  shows "(\<lambda>x. c) integrable_on {a .. b}"
  6.4258 +  unfolding cbox_interval[symmetric]
  6.4259 +  by (rule integrable_const)
  6.4260 +
  6.4261  lemma integral_has_vector_derivative:
  6.4262    fixes f :: "real \<Rightarrow> 'a::banach"
  6.4263 -  assumes "continuous_on {a..b} f"
  6.4264 -    and "x \<in> {a..b}"
  6.4265 -  shows "((\<lambda>u. integral {a..u} f) has_vector_derivative f(x)) (at x within {a..b})"
  6.4266 +  assumes "continuous_on {a .. b} f"
  6.4267 +    and "x \<in> {a .. b}"
  6.4268 +  shows "((\<lambda>u. integral {a .. u} f) has_vector_derivative f(x)) (at x within {a .. b})"
  6.4269    unfolding has_vector_derivative_def has_derivative_within_alt
  6.4270    apply safe
  6.4271    apply (rule bounded_linear_scaleR_left)
  6.4272  proof -
  6.4273    fix e :: real
  6.4274    assume e: "e > 0"
  6.4275 -  note compact_uniformly_continuous[OF assms(1) compact_interval,unfolded uniformly_continuous_on_def]
  6.4276 +  note compact_uniformly_continuous[OF assms(1) compact_Icc,unfolded uniformly_continuous_on_def]
  6.4277    from this[rule_format,OF e] guess d by (elim conjE exE) note d=this[rule_format]
  6.4278 -  let ?I = "\<lambda>a b. integral {a..b} f"
  6.4279 -  show "\<exists>d>0. \<forall>y\<in>{a..b}. norm (y - x) < d \<longrightarrow>
  6.4280 +  let ?I = "\<lambda>a b. integral {a .. b} f"
  6.4281 +  show "\<exists>d>0. \<forall>y\<in>{a .. b}. norm (y - x) < d \<longrightarrow>
  6.4282      norm (?I a y - ?I a x - (y - x) *\<^sub>R f x) \<le> e * norm (y - x)"
  6.4283    proof (rule, rule, rule d, safe)
  6.4284      case goal1
  6.4285      show ?case
  6.4286      proof (cases "y < x")
  6.4287        case False
  6.4288 -      have "f integrable_on {a..y}"
  6.4289 -        apply (rule integrable_subinterval,rule integrable_continuous)
  6.4290 +      have "f integrable_on {a .. y}"
  6.4291 +        apply (rule integrable_subinterval_real,rule integrable_continuous_real)
  6.4292          apply (rule assms)
  6.4293          unfolding not_less
  6.4294          using assms(2) goal1
  6.4295 @@ -7021,34 +7174,28 @@
  6.4296          using assms(2) goal1
  6.4297          apply auto
  6.4298          done
  6.4299 -      have **: "norm (y - x) = content {x..y}"
  6.4300 -        apply (subst content_real)
  6.4301 -        using False
  6.4302 -        unfolding not_less
  6.4303 -        apply auto
  6.4304 -        done
  6.4305 +      have **: "norm (y - x) = content {x .. y}"
  6.4306 +        using False by (auto simp: content_real)
  6.4307        show ?thesis
  6.4308          unfolding **
  6.4309 -        apply (rule has_integral_bound[where f="(\<lambda>u. f u - f x)"])
  6.4310 +        apply (rule has_integral_bound_real[where f="(\<lambda>u. f u - f x)"])
  6.4311          unfolding *
  6.4312 -        unfolding o_def
  6.4313          defer
  6.4314          apply (rule has_integral_sub)
  6.4315          apply (rule integrable_integral)
  6.4316 -        apply (rule integrable_subinterval)
  6.4317 -        apply (rule integrable_continuous)
  6.4318 +        apply (rule integrable_subinterval_real)
  6.4319 +        apply (rule integrable_continuous_real)
  6.4320          apply (rule assms)+
  6.4321        proof -
  6.4322 -        show "{x..y} \<subseteq> {a..b}"
  6.4323 +        show "{x .. y} \<subseteq> {a .. b}"
  6.4324            using goal1 assms(2) by auto
  6.4325          have *: "y - x = norm (y - x)"
  6.4326            using False by auto
  6.4327 -        show "((\<lambda>xa. f x) has_integral (y - x) *\<^sub>R f x) {x.. y}"
  6.4328 +        show "((\<lambda>xa. f x) has_integral (y - x) *\<^sub>R f x) {x .. y}"
  6.4329            apply (subst *)
  6.4330            unfolding **
  6.4331 -          apply auto
  6.4332 -          done
  6.4333 -        show "\<forall>xa\<in>{x..y}. norm (f xa - f x) \<le> e"
  6.4334 +          by auto
  6.4335 +        show "\<forall>xa\<in>{x .. y}. norm (f xa - f x) \<le> e"
  6.4336            apply safe
  6.4337            apply (rule less_imp_le)
  6.4338            apply (rule d(2)[unfolded dist_norm])
  6.4339 @@ -7059,8 +7206,9 @@
  6.4340        qed (insert e, auto)
  6.4341      next
  6.4342        case True
  6.4343 -      have "f integrable_on {a..x}"
  6.4344 +      have "f integrable_on cbox a x"
  6.4345          apply (rule integrable_subinterval,rule integrable_continuous)
  6.4346 +        unfolding box_real
  6.4347          apply (rule assms)+
  6.4348          unfolding not_less
  6.4349          using assms(2) goal1
  6.4350 @@ -7073,7 +7221,7 @@
  6.4351          using True using assms(2) goal1
  6.4352          apply auto
  6.4353          done
  6.4354 -      have **: "norm (y - x) = content {y..x}"
  6.4355 +      have **: "norm (y - x) = content {y .. x}"
  6.4356          apply (subst content_real)
  6.4357          using True
  6.4358          unfolding not_less
  6.4359 @@ -7084,7 +7232,7 @@
  6.4360        show ?thesis
  6.4361          apply (subst ***)
  6.4362          unfolding norm_minus_cancel **
  6.4363 -        apply (rule has_integral_bound[where f="(\<lambda>u. f u - f x)"])
  6.4364 +        apply (rule has_integral_bound_real[where f="(\<lambda>u. f u - f x)"])
  6.4365          unfolding *
  6.4366          unfolding o_def
  6.4367          defer
  6.4368 @@ -7092,19 +7240,19 @@
  6.4369          apply (subst minus_minus[symmetric])
  6.4370          unfolding minus_minus
  6.4371          apply (rule integrable_integral)
  6.4372 -        apply (rule integrable_subinterval,rule integrable_continuous)
  6.4373 +        apply (rule integrable_subinterval_real,rule integrable_continuous_real)
  6.4374          apply (rule assms)+
  6.4375        proof -
  6.4376 -        show "{y..x} \<subseteq> {a..b}"
  6.4377 +        show "{y .. x} \<subseteq> {a .. b}"
  6.4378            using goal1 assms(2) by auto
  6.4379          have *: "x - y = norm (y - x)"
  6.4380            using True by auto
  6.4381 -        show "((\<lambda>xa. f x) has_integral (x - y) *\<^sub>R f x) {y..x}"
  6.4382 +        show "((\<lambda>xa. f x) has_integral (x - y) *\<^sub>R f x) {y .. x}"
  6.4383            apply (subst *)
  6.4384            unfolding **
  6.4385            apply auto
  6.4386            done
  6.4387 -        show "\<forall>xa\<in>{y..x}. norm (f xa - f x) \<le> e"
  6.4388 +        show "\<forall>xa\<in>{y .. x}. norm (f xa - f x) \<le> e"
  6.4389            apply safe
  6.4390            apply (rule less_imp_le)
  6.4391            apply (rule d(2)[unfolded dist_norm])
  6.4392 @@ -7119,8 +7267,8 @@
  6.4393  
  6.4394  lemma antiderivative_continuous:
  6.4395    fixes q b :: real
  6.4396 -  assumes "continuous_on {a..b} f"
  6.4397 -  obtains g where "\<forall>x\<in> {a..b}. (g has_vector_derivative (f x::_::banach)) (at x within {a..b})"
  6.4398 +  assumes "continuous_on {a .. b} f"
  6.4399 +  obtains g where "\<forall>x\<in>{a .. b}. (g has_vector_derivative (f x::_::banach)) (at x within {a .. b})"
  6.4400    apply (rule that)
  6.4401    apply rule
  6.4402    using integral_has_vector_derivative[OF assms]
  6.4403 @@ -7132,15 +7280,15 @@
  6.4404  
  6.4405  lemma antiderivative_integral_continuous:
  6.4406    fixes f :: "real \<Rightarrow> 'a::banach"
  6.4407 -  assumes "continuous_on {a..b} f"
  6.4408 -  obtains g where "\<forall>u\<in>{a..b}. \<forall>v \<in> {a..b}. u \<le> v \<longrightarrow> (f has_integral (g v - g u)) {u..v}"
  6.4409 +  assumes "continuous_on {a .. b} f"
  6.4410 +  obtains g where "\<forall>u\<in>{a .. b}. \<forall>v \<in> {a .. b}. u \<le> v \<longrightarrow> (f has_integral (g v - g u)) {u .. v}"
  6.4411  proof -
  6.4412    from antiderivative_continuous[OF assms] guess g . note g=this
  6.4413    show ?thesis
  6.4414      apply (rule that[of g])
  6.4415    proof safe
  6.4416      case goal1
  6.4417 -    have "\<forall>x\<in>{u..v}. (g has_vector_derivative f x) (at x within {u..v})"
  6.4418 +    have "\<forall>x\<in>cbox u v. (g has_vector_derivative f x) (at x within cbox u v)"
  6.4419        apply rule
  6.4420        apply (rule has_vector_derivative_within_subset)
  6.4421        apply (rule g[rule_format])
  6.4422 @@ -7160,14 +7308,14 @@
  6.4423      and "\<forall>x. h(g x) = x"
  6.4424      and "\<forall>x. g(h x) = x"
  6.4425      and "\<forall>x. continuous (at x) g"
  6.4426 -    and "\<forall>u v. \<exists>w z. g ` {u..v} = {w..z}"
  6.4427 -    and "\<forall>u v. \<exists>w z. h ` {u..v} = {w..z}"
  6.4428 -    and "\<forall>u v. content(g ` {u..v}) = r * content {u..v}"
  6.4429 -    and "(f has_integral i) {a..b}"
  6.4430 -  shows "((\<lambda>x. f(g x)) has_integral (1 / r) *\<^sub>R i) (h ` {a..b})"
  6.4431 +    and "\<forall>u v. \<exists>w z. g ` cbox u v = cbox w z"
  6.4432 +    and "\<forall>u v. \<exists>w z. h ` cbox u v = cbox w z"
  6.4433 +    and "\<forall>u v. content(g ` cbox u v) = r * content (cbox u v)"
  6.4434 +    and "(f has_integral i) (cbox a b)"
  6.4435 +  shows "((\<lambda>x. f(g x)) has_integral (1 / r) *\<^sub>R i) (h ` cbox a b)"
  6.4436  proof -
  6.4437    {
  6.4438 -    presume *: "{a..b} \<noteq> {} \<Longrightarrow> ?thesis"
  6.4439 +    presume *: "cbox a b \<noteq> {} \<Longrightarrow> ?thesis"
  6.4440      show ?thesis
  6.4441        apply cases
  6.4442        defer
  6.4443 @@ -7178,7 +7326,7 @@
  6.4444        then show ?thesis
  6.4445          unfolding goal1 assms(8)[unfolded goal1 has_integral_empty_eq] by auto qed
  6.4446    }
  6.4447 -  assume "{a..b} \<noteq> {}"
  6.4448 +  assume "cbox a b \<noteq> {}"
  6.4449    from assms(6)[rule_format,of a b] guess w z by (elim exE) note wz=this
  6.4450    have inj: "inj g" "inj h"
  6.4451      unfolding inj_on_def
  6.4452 @@ -7210,7 +7358,7 @@
  6.4453      def d' \<equiv> "\<lambda>x. {y. g y \<in> d (g x)}"
  6.4454      have d': "\<And>x. d' x = {y. g y \<in> (d (g x))}"
  6.4455        unfolding d'_def ..
  6.4456 -    show "\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of h ` {a..b} \<and> d fine p \<longrightarrow> norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f (g x)) - (1 / r) *\<^sub>R i) < e)"
  6.4457 +    show "\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of h ` cbox a b \<and> d fine p \<longrightarrow> norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f (g x)) - (1 / r) *\<^sub>R i) < e)"
  6.4458      proof (rule_tac x=d' in exI, safe)
  6.4459        show "gauge d'"
  6.4460          using d(1)
  6.4461 @@ -7218,9 +7366,9 @@
  6.4462          using continuous_open_preimage_univ[OF assms(4)]
  6.4463          by auto
  6.4464        fix p
  6.4465 -      assume as: "p tagged_division_of h ` {a..b}" "d' fine p"
  6.4466 +      assume as: "p tagged_division_of h ` cbox a b" "d' fine p"
  6.4467        note p = tagged_division_ofD[OF as(1)]
  6.4468 -      have "(\<lambda>(x, k). (g x, g ` k)) ` p tagged_division_of {a..b} \<and> d fine (\<lambda>(x, k). (g x, g ` k)) ` p"
  6.4469 +      have "(\<lambda>(x, k). (g x, g ` k)) ` p tagged_division_of (cbox a b) \<and> d fine (\<lambda>(x, k). (g x, g ` k)) ` p"
  6.4470          unfolding tagged_division_of
  6.4471        proof safe
  6.4472          show "finite ((\<lambda>(x, k). (g x, g ` k)) ` p)"
  6.4473 @@ -7231,12 +7379,12 @@
  6.4474          assume xk[intro]: "(x, k) \<in> p"
  6.4475          show "g x \<in> g ` k"
  6.4476            using p(2)[OF xk] by auto
  6.4477 -        show "\<exists>u v. g ` k = {u..v}"
  6.4478 +        show "\<exists>u v. g ` k = cbox u v"
  6.4479            using p(4)[OF xk] using assms(5-6) by auto
  6.4480          {
  6.4481            fix y
  6.4482            assume "y \<in> k"
  6.4483 -          then show "g y \<in> {a..b}" "g y \<in> {a..b}"
  6.4484 +          then show "g y \<in> cbox a b" "g y \<in> cbox a b"
  6.4485              using p(3)[OF xk,unfolded subset_eq,rule_format,of "h (g y)"]
  6.4486              using assms(2)[rule_format,of y]
  6.4487              unfolding inj_image_mem_iff[OF inj(2)]
  6.4488 @@ -7278,7 +7426,7 @@
  6.4489          }
  6.4490        next
  6.4491          fix x
  6.4492 -        assume "x \<in> {a..b}"
  6.4493 +        assume "x \<in> cbox a b"
  6.4494          then have "h x \<in>  \<Union>{k. \<exists>x. (x, k) \<in> p}"
  6.4495            using p(6) by auto
  6.4496          then guess X unfolding Union_iff .. note X=this
  6.4497 @@ -7327,8 +7475,8 @@
  6.4498  subsection {* Special case of a basic affine transformation. *}
  6.4499  
  6.4500  lemma interval_image_affinity_interval:
  6.4501 -  "\<exists>u v. (\<lambda>x. m *\<^sub>R (x::'a::ordered_euclidean_space) + c) ` {a..b} = {u..v}"
  6.4502 -  unfolding image_affinity_interval
  6.4503 +  "\<exists>u v. (\<lambda>x. m *\<^sub>R (x::'a::euclidean_space) + c) ` cbox a b = cbox u v"
  6.4504 +  unfolding image_affinity_cbox
  6.4505    by auto
  6.4506  
  6.4507  lemma setprod_cong2:
  6.4508 @@ -7339,12 +7487,12 @@
  6.4509    apply auto
  6.4510    done
  6.4511  
  6.4512 -lemma content_image_affinity_interval:
  6.4513 -  "content((\<lambda>x::'a::ordered_euclidean_space. m *\<^sub>R x + c) ` {a..b}) =
  6.4514 -    abs m ^ DIM('a) * content {a..b}" (is "?l = ?r")
  6.4515 +lemma content_image_affinity_cbox:
  6.4516 +  "content((\<lambda>x::'a::euclidean_space. m *\<^sub>R x + c) ` cbox a b) =
  6.4517 +    abs m ^ DIM('a) * content (cbox a b)" (is "?l = ?r")
  6.4518  proof -
  6.4519    {
  6.4520 -    presume *: "{a..b} \<noteq> {} \<Longrightarrow> ?thesis"
  6.4521 +    presume *: "cbox a b \<noteq> {} \<Longrightarrow> ?thesis"
  6.4522      show ?thesis
  6.4523        apply cases
  6.4524        apply (rule *)
  6.4525 @@ -7354,12 +7502,12 @@
  6.4526        apply auto
  6.4527        done
  6.4528    }
  6.4529 -  assume as: "{a..b} \<noteq> {}"
  6.4530 +  assume as: "cbox a b \<noteq> {}"
  6.4531    show ?thesis
  6.4532    proof (cases "m \<ge> 0")
  6.4533      case True
  6.4534 -    with as have "{m *\<^sub>R a + c..m *\<^sub>R b + c} \<noteq> {}"
  6.4535 -      unfolding interval_ne_empty
  6.4536 +    with as have "cbox (m *\<^sub>R a + c) (m *\<^sub>R b + c) \<noteq> {}"
  6.4537 +      unfolding box_ne_empty
  6.4538        apply (intro ballI)
  6.4539        apply (erule_tac x=i in ballE)
  6.4540        apply (auto simp: inner_simps intro!: mult_left_mono)
  6.4541 @@ -7367,12 +7515,12 @@
  6.4542      moreover from True have *: "\<And>i. (m *\<^sub>R b + c) \<bullet> i - (m *\<^sub>R a + c) \<bullet> i = m *\<^sub>R (b - a) \<bullet> i"
  6.4543        by (simp add: inner_simps field_simps)
  6.4544      ultimately show ?thesis
  6.4545 -      by (simp add: image_affinity_interval True content_closed_interval'
  6.4546 +      by (simp add: image_affinity_cbox True content_cbox'
  6.4547          setprod_timesf setprod_constant inner_diff_left)
  6.4548    next
  6.4549      case False
  6.4550 -    with as have "{m *\<^sub>R b + c..m *\<^sub>R a + c} \<noteq> {}"
  6.4551 -      unfolding interval_ne_empty
  6.4552 +    with as have "cbox (m *\<^sub>R b + c) (m *\<^sub>R a + c) \<noteq> {}"
  6.4553 +      unfolding box_ne_empty
  6.4554        apply (intro ballI)
  6.4555        apply (erule_tac x=i in ballE)
  6.4556        apply (auto simp: inner_simps intro!: mult_left_mono)
  6.4557 @@ -7380,16 +7528,16 @@
  6.4558      moreover from False have *: "\<And>i. (m *\<^sub>R a + c) \<bullet> i - (m *\<^sub>R b + c) \<bullet> i = (-m) *\<^sub>R (b - a) \<bullet> i"
  6.4559        by (simp add: inner_simps field_simps)
  6.4560      ultimately show ?thesis using False
  6.4561 -      by (simp add: image_affinity_interval content_closed_interval'
  6.4562 +      by (simp add: image_affinity_cbox content_cbox'
  6.4563          setprod_timesf[symmetric] setprod_constant[symmetric] inner_diff_left)
  6.4564    qed
  6.4565  qed
  6.4566  
  6.4567  lemma has_integral_affinity:
  6.4568 -  fixes a :: "'a::ordered_euclidean_space"
  6.4569 -  assumes "(f has_integral i) {a..b}"
  6.4570 +  fixes a :: "'a::euclidean_space"
  6.4571 +  assumes "(f has_integral i) (cbox a b)"
  6.4572      and "m \<noteq> 0"
  6.4573 -  shows "((\<lambda>x. f(m *\<^sub>R x + c)) has_integral ((1 / (abs(m) ^ DIM('a))) *\<^sub>R i)) ((\<lambda>x. (1 / m) *\<^sub>R x + -((1 / m) *\<^sub>R c)) ` {a..b})"
  6.4574 +  shows "((\<lambda>x. f(m *\<^sub>R x + c)) has_integral ((1 / (abs(m) ^ DIM('a))) *\<^sub>R i)) ((\<lambda>x. (1 / m) *\<^sub>R x + -((1 / m) *\<^sub>R c)) ` cbox a b)"
  6.4575    apply (rule has_integral_twiddle)
  6.4576    apply safe
  6.4577    apply (rule zero_less_power)
  6.4578 @@ -7402,15 +7550,15 @@
  6.4579    apply (simp add: field_simps)
  6.4580    apply (rule continuous_intros)+
  6.4581    apply (rule interval_image_affinity_interval)+
  6.4582 -  apply (rule content_image_affinity_interval)
  6.4583 +  apply (rule content_image_affinity_cbox)
  6.4584    using assms
  6.4585    apply auto
  6.4586    done
  6.4587  
  6.4588  lemma integrable_affinity:
  6.4589 -  assumes "f integrable_on {a..b}"
  6.4590 +  assumes "f integrable_on cbox a b"
  6.4591      and "m \<noteq> 0"
  6.4592 -  shows "(\<lambda>x. f(m *\<^sub>R x + c)) integrable_on ((\<lambda>x. (1 / m) *\<^sub>R x + -((1/m) *\<^sub>R c)) ` {a..b})"
  6.4593 +  shows "(\<lambda>x. f(m *\<^sub>R x + c)) integrable_on ((\<lambda>x. (1 / m) *\<^sub>R x + -((1/m) *\<^sub>R c)) ` cbox a b)"
  6.4594    using assms
  6.4595    unfolding integrable_on_def
  6.4596    apply safe
  6.4597 @@ -7422,20 +7570,20 @@
  6.4598  subsection {* Special case of stretching coordinate axes separately. *}
  6.4599  
  6.4600  lemma image_stretch_interval:
  6.4601 -  "(\<lambda>x. \<Sum>k\<in>Basis. (m k * (x\<bullet>k)) *\<^sub>R k) ` {a..b::'a::ordered_euclidean_space} =
  6.4602 -  (if {a..b} = {} then {} else
  6.4603 -    {(\<Sum>k\<in>Basis. (min (m k * (a\<bullet>k)) (m k * (b\<bullet>k))) *\<^sub>R k)::'a ..
  6.4604 -     (\<Sum>k\<in>Basis. (max (m k * (a\<bullet>k)) (m k * (b\<bullet>k))) *\<^sub>R k)})"
  6.4605 +  "(\<lambda>x. \<Sum>k\<in>Basis. (m k * (x\<bullet>k)) *\<^sub>R k) ` cbox a (b::'a::euclidean_space) =
  6.4606 +  (if (cbox a b) = {} then {} else
  6.4607 +    cbox (\<Sum>k\<in>Basis. (min (m k * (a\<bullet>k)) (m k * (b\<bullet>k))) *\<^sub>R k::'a)
  6.4608 +     (\<Sum>k\<in>Basis. (max (m k * (a\<bullet>k)) (m k * (b\<bullet>k))) *\<^sub>R k))"
  6.4609  proof cases
  6.4610 -  assume *: "{a..b} \<noteq> {}"
  6.4611 +  assume *: "cbox a b \<noteq> {}"
  6.4612    show ?thesis
  6.4613 -    unfolding interval_ne_empty if_not_P[OF *]
  6.4614 -    apply (simp add: interval image_Collect set_eq_iff euclidean_eq_iff[where 'a='a] ball_conj_distrib[symmetric])
  6.4615 +    unfolding box_ne_empty if_not_P[OF *]
  6.4616 +    apply (simp add: cbox_def image_Collect set_eq_iff euclidean_eq_iff[where 'a='a] ball_conj_distrib[symmetric])
  6.4617      apply (subst choice_Basis_iff[symmetric])
  6.4618    proof (intro allI ball_cong refl)
  6.4619      fix x i :: 'a assume "i \<in> Basis"
  6.4620      with * have a_le_b: "a \<bullet> i \<le> b \<bullet> i"
  6.4621 -      unfolding interval_ne_empty by auto
  6.4622 +      unfolding box_ne_empty by auto
  6.4623      show "(\<exists>xa. x \<bullet> i = m i * xa \<and> a \<bullet> i \<le> xa \<and> xa \<le> b \<bullet> i) \<longleftrightarrow>
  6.4624          min (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) \<le> x \<bullet> i \<and> x \<bullet> i \<le> max (m i * (a \<bullet> i)) (m i * (b \<bullet> i))"
  6.4625      proof (cases "m i = 0")
  6.4626 @@ -7456,19 +7604,19 @@
  6.4627  qed simp
  6.4628  
  6.4629  lemma interval_image_stretch_interval:
  6.4630 -  "\<exists>u v. (\<lambda>x. \<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k) ` {a..b::'a::ordered_euclidean_space} = {u..v::'a}"
  6.4631 +  "\<exists>u v. (\<lambda>x. \<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k) ` cbox a (b::'a::euclidean_space) = cbox u (v::'a::euclidean_space)"
  6.4632    unfolding image_stretch_interval by auto
  6.4633  
  6.4634  lemma content_image_stretch_interval:
  6.4635 -  "content ((\<lambda>x::'a::ordered_euclidean_space. (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)::'a) ` {a..b}) =
  6.4636 -    abs (setprod m Basis) * content {a..b}"
  6.4637 -proof (cases "{a..b} = {}")
  6.4638 +  "content ((\<lambda>x::'a::euclidean_space. (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)::'a) ` cbox a b) =
  6.4639 +    abs (setprod m Basis) * content (cbox a b)"
  6.4640 +proof (cases "cbox a b = {}")
  6.4641    case True
  6.4642    then show ?thesis
  6.4643      unfolding content_def image_is_empty image_stretch_interval if_P[OF True] by auto
  6.4644  next
  6.4645    case False
  6.4646 -  then have "(\<lambda>x. (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)) ` {a..b} \<noteq> {}"
  6.4647 +  then have "(\<lambda>x. (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)) ` cbox a b \<noteq> {}"
  6.4648      by auto
  6.4649    then show ?thesis
  6.4650      using False
  6.4651 @@ -7489,18 +7637,18 @@
  6.4652        apply -
  6.4653        apply (erule disjE)+
  6.4654        unfolding min_def max_def
  6.4655 -      using False[unfolded interval_ne_empty,rule_format,of i] i
  6.4656 +      using False[unfolded box_ne_empty,rule_format,of i] i
  6.4657        apply (auto simp add:field_simps not_le mult_le_cancel_left_neg mult_le_cancel_left_pos)
  6.4658        done
  6.4659    qed
  6.4660  qed
  6.4661  
  6.4662  lemma has_integral_stretch:
  6.4663 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
  6.4664 -  assumes "(f has_integral i) {a..b}"
  6.4665 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
  6.4666 +  assumes "(f has_integral i) (cbox a b)"
  6.4667      and "\<forall>k\<in>Basis. m k \<noteq> 0"
  6.4668    shows "((\<lambda>x. f (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)) has_integral
  6.4669 -    ((1/(abs(setprod m Basis))) *\<^sub>R i)) ((\<lambda>x. (\<Sum>k\<in>Basis. (1 / m k * (x\<bullet>k))*\<^sub>R k)) ` {a..b})"
  6.4670 +    ((1/(abs(setprod m Basis))) *\<^sub>R i)) ((\<lambda>x. (\<Sum>k\<in>Basis. (1 / m k * (x\<bullet>k))*\<^sub>R k)) ` cbox a b)"
  6.4671    apply (rule has_integral_twiddle[where f=f])
  6.4672    unfolding zero_less_abs_iff content_image_stretch_interval
  6.4673    unfolding image_stretch_interval empty_as_interval euclidean_eq_iff[where 'a='a]
  6.4674 @@ -7516,11 +7664,11 @@
  6.4675  qed auto
  6.4676  
  6.4677  lemma integrable_stretch:
  6.4678 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
  6.4679 -  assumes "f integrable_on {a..b}"
  6.4680 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
  6.4681 +  assumes "f integrable_on cbox a b"
  6.4682      and "\<forall>k\<in>Basis. m k \<noteq> 0"
  6.4683    shows "(\<lambda>x::'a. f (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)) integrable_on
  6.4684 -    ((\<lambda>x. \<Sum>k\<in>Basis. (1 / m k * (x\<bullet>k))*\<^sub>R k) ` {a..b})"
  6.4685 +    ((\<lambda>x. \<Sum>k\<in>Basis. (1 / m k * (x\<bullet>k))*\<^sub>R k) ` cbox a b)"
  6.4686    using assms
  6.4687    unfolding integrable_on_def
  6.4688    apply -
  6.4689 @@ -7534,35 +7682,50 @@
  6.4690  subsection {* even more special cases. *}
  6.4691  
  6.4692  lemma uminus_interval_vector[simp]:
  6.4693 -  fixes a b :: "'a::ordered_euclidean_space"
  6.4694 -  shows "uminus ` {a..b} = {-b..-a}"
  6.4695 +  fixes a b :: "'a::euclidean_space"
  6.4696 +  shows "uminus ` cbox a b = cbox (-b) (-a)"
  6.4697    apply (rule set_eqI)
  6.4698    apply rule
  6.4699    defer
  6.4700    unfolding image_iff
  6.4701    apply (rule_tac x="-x" in bexI)
  6.4702 -  apply (auto simp add:minus_le_iff le_minus_iff eucl_le[where 'a='a])
  6.4703 +  apply (auto simp add:minus_le_iff le_minus_iff mem_box)
  6.4704    done
  6.4705  
  6.4706  lemma has_integral_reflect_lemma[intro]:
  6.4707 -  assumes "(f has_integral i) {a..b}"
  6.4708 -  shows "((\<lambda>x. f(-x)) has_integral i) {-b..-a}"
  6.4709 +  assumes "(f has_integral i) (cbox a b)"
  6.4710 +  shows "((\<lambda>x. f(-x)) has_integral i) (cbox (-b) (-a))"
  6.4711    using has_integral_affinity[OF assms, of "-1" 0]
  6.4712    by auto
  6.4713  
  6.4714 +lemma has_integral_reflect_lemma_real[intro]:
  6.4715 +  assumes "(f has_integral i) {a .. b::real}"
  6.4716 +  shows "((\<lambda>x. f(-x)) has_integral i) {-b .. -a}"
  6.4717 +  using assms
  6.4718 +  unfolding box_real[symmetric]
  6.4719 +  by (rule has_integral_reflect_lemma)
  6.4720 +
  6.4721  lemma has_integral_reflect[simp]:
  6.4722 -  "((\<lambda>x. f (-x)) has_integral i) {-b..-a} \<longleftrightarrow> (f has_integral i) {a..b}"
  6.4723 +  "((\<lambda>x. f (-x)) has_integral i) (cbox (-b) (-a)) \<longleftrightarrow> (f has_integral i) (cbox a b)"
  6.4724    apply rule
  6.4725    apply (drule_tac[!] has_integral_reflect_lemma)
  6.4726    apply auto
  6.4727    done
  6.4728  
  6.4729 -lemma integrable_reflect[simp]: "(\<lambda>x. f(-x)) integrable_on {-b..-a} \<longleftrightarrow> f integrable_on {a..b}"
  6.4730 +lemma integrable_reflect[simp]: "(\<lambda>x. f(-x)) integrable_on cbox (-b) (-a) \<longleftrightarrow> f integrable_on cbox a b"
  6.4731    unfolding integrable_on_def by auto
  6.4732  
  6.4733 -lemma integral_reflect[simp]: "integral {-b..-a} (\<lambda>x. f (-x)) = integral {a..b} f"
  6.4734 +lemma integrable_reflect_real[simp]: "(\<lambda>x. f(-x)) integrable_on {-b .. -a} \<longleftrightarrow> f integrable_on {a .. b::real}"
  6.4735 +  unfolding box_real[symmetric]
  6.4736 +  by (rule integrable_reflect)
  6.4737 +
  6.4738 +lemma integral_reflect[simp]: "integral (cbox (-b) (-a)) (\<lambda>x. f (-x)) = integral (cbox a b) f"
  6.4739    unfolding integral_def by auto
  6.4740  
  6.4741 +lemma integral_reflect_real[simp]: "integral {-b .. -a} (\<lambda>x. f (-x)) = integral {a .. b::real} f"
  6.4742 +  unfolding box_real[symmetric]
  6.4743 +  by (rule integral_reflect)
  6.4744 +
  6.4745  
  6.4746  subsection {* Stronger form of FCT; quite a tedious proof. *}
  6.4747  
  6.4748 @@ -7590,9 +7753,9 @@
  6.4749  lemma fundamental_theorem_of_calculus_interior:
  6.4750    fixes f :: "real \<Rightarrow> 'a::real_normed_vector"
  6.4751    assumes "a \<le> b"
  6.4752 -    and "continuous_on {a..b} f"
  6.4753 -    and "\<forall>x\<in>box a b. (f has_vector_derivative f'(x)) (at x)"
  6.4754 -  shows "(f' has_integral (f b - f a)) {a..b}"
  6.4755 +    and "continuous_on {a .. b} f"
  6.4756 +    and "\<forall>x\<in>{a <..< b}. (f has_vector_derivative f'(x)) (at x)"
  6.4757 +  shows "(f' has_integral (f b - f a)) {a .. b}"
  6.4758  proof -
  6.4759    {
  6.4760      presume *: "a < b \<Longrightarrow> ?thesis"
  6.4761 @@ -7604,20 +7767,19 @@
  6.4762        case False
  6.4763        then have "a = b"
  6.4764          using assms(1) by auto
  6.4765 -      then have *: "{a .. b} = {b}" "f b - f a = 0"
  6.4766 +      then have *: "cbox a b = {b}" "f b - f a = 0"
  6.4767          by (auto simp add:  order_antisym)
  6.4768        show ?thesis
  6.4769          unfolding *(2)
  6.4770 -        apply (rule has_integral_null)
  6.4771          unfolding content_eq_0
  6.4772          using * `a = b`
  6.4773          by (auto simp: ex_in_conv)
  6.4774      qed
  6.4775    }
  6.4776    assume ab: "a < b"
  6.4777 -  let ?P = "\<lambda>e. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
  6.4778 -    norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f' x) - (f b - f a)) \<le> e * content {a..b})"
  6.4779 -  { presume "\<And>e. e > 0 \<Longrightarrow> ?P e" then show ?thesis unfolding has_integral_factor_content by auto }
  6.4780 +  let ?P = "\<lambda>e. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a .. b} \<and> d fine p \<longrightarrow>
  6.4781 +    norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f' x) - (f b - f a)) \<le> e * content {a .. b})"
  6.4782 +  { presume "\<And>e. e > 0 \<Longrightarrow> ?P e" then show ?thesis unfolding has_integral_factor_content_real by auto }
  6.4783    fix e :: real
  6.4784    assume e: "e > 0"
  6.4785    note assms(3)[unfolded has_vector_derivative_def has_derivative_at_alt ball_conj_distrib]
  6.4786 @@ -7636,17 +7798,17 @@
  6.4787    from choice[OF this] guess d ..
  6.4788    note conjunctD2[OF this[rule_format]]
  6.4789    note d = this[rule_format]
  6.4790 -  have "bounded (f ` {a..b})"
  6.4791 +  have "bounded (f ` cbox a b)"
  6.4792      apply (rule compact_imp_bounded compact_continuous_image)+
  6.4793 -    using compact_interval assms
  6.4794 +    using compact_cbox assms
  6.4795      apply auto
  6.4796      done
  6.4797    from this[unfolded bounded_pos] guess B .. note B = this[rule_format]
  6.4798  
  6.4799 -  have "\<exists>da. 0 < da \<and> (\<forall>c. a \<le> c \<and> {a..c} \<subseteq> {a..b} \<and> {a..c} \<subseteq> ball a da \<longrightarrow>
  6.4800 -    norm (content {a..c} *\<^sub>R f' a - (f c - f a)) \<le> (e * (b - a)) / 4)"
  6.4801 +  have "\<exists>da. 0 < da \<and> (\<forall>c. a \<le> c \<and> {a .. c} \<subseteq> {a .. b} \<and> {a .. c} \<subseteq> ball a da \<longrightarrow>
  6.4802 +    norm (content {a .. c} *\<^sub>R f' a - (f c - f a)) \<le> (e * (b - a)) / 4)"
  6.4803    proof -
  6.4804 -    have "a \<in> {a..b}"
  6.4805 +    have "a \<in> {a .. b}"
  6.4806        using ab by auto
  6.4807      note assms(2)[unfolded continuous_on_eq_continuous_within,rule_format,OF this]
  6.4808      note * = this[unfolded continuous_within Lim_within,rule_format]
  6.4809 @@ -7678,8 +7840,8 @@
  6.4810        apply (rule l k)+
  6.4811      proof -
  6.4812        fix c
  6.4813 -      assume as: "a \<le> c" "{a..c} \<subseteq> {a..b}" "{a..c} \<subseteq> ball a (min k l)"
  6.4814 -      note as' = this[unfolded subset_eq Ball_def mem_ball dist_real_def mem_interval]
  6.4815 +      assume as: "a \<le> c" "{a .. c} \<subseteq> {a .. b}" "{a .. c} \<subseteq> ball a (min k l)"
  6.4816 +      note as' = this[unfolded subset_eq Ball_def mem_ball dist_real_def mem_box]
  6.4817        have "norm ((c - a) *\<^sub>R f' a - (f c - f a)) \<le> norm ((c - a) *\<^sub>R f' a) + norm (f c - f a)"
  6.4818          by (rule norm_triangle_ineq4)
  6.4819        also have "\<dots> \<le> e * (b - a) / 8 + e * (b - a) / 8"
  6.4820 @@ -7705,16 +7867,16 @@
  6.4821            apply (auto simp add: field_simps)
  6.4822            done
  6.4823        qed
  6.4824 -      finally show "norm (content {a..c} *\<^sub>R f' a - (f c - f a)) \<le> e * (b - a) / 4"
  6.4825 +      finally show "norm (content {a .. c} *\<^sub>R f' a - (f c - f a)) \<le> e * (b - a) / 4"
  6.4826          unfolding content_real[OF as(1)] by auto
  6.4827      qed
  6.4828    qed
  6.4829    then guess da .. note da=conjunctD2[OF this,rule_format]
  6.4830  
  6.4831 -  have "\<exists>db>0. \<forall>c\<le>b. {c..b} \<subseteq> {a..b} \<and> {c..b} \<subseteq> ball b db \<longrightarrow>
  6.4832 -    norm (content {c..b} *\<^sub>R f' b - (f b - f c)) \<le> (e * (b - a)) / 4"
  6.4833 +  have "\<exists>db>0. \<forall>c\<le>b. {c .. b} \<subseteq> {a .. b} \<and> {c .. b} \<subseteq> ball b db \<longrightarrow>
  6.4834 +    norm (content {c .. b} *\<^sub>R f' b - (f b - f c)) \<le> (e * (b - a)) / 4"
  6.4835    proof -
  6.4836 -    have "b \<in> {a..b}"
  6.4837 +    have "b \<in> {a .. b}"
  6.4838        using ab by auto
  6.4839      note assms(2)[unfolded continuous_on_eq_continuous_within,rule_format,OF this]
  6.4840      note * = this[unfolded continuous_within Lim_within,rule_format] have "(e * (b - a)) / 8 > 0"
  6.4841 @@ -7746,7 +7908,7 @@
  6.4842      proof -
  6.4843        fix c
  6.4844        assume as: "c \<le> b" "{c..b} \<subseteq> {a..b}" "{c..b} \<subseteq> ball b (min k l)"
  6.4845 -      note as' = this[unfolded subset_eq Ball_def mem_ball dist_real_def mem_interval]
  6.4846 +      note as' = this[unfolded subset_eq Ball_def mem_ball dist_real_def mem_box]
  6.4847        have "norm ((b - c) *\<^sub>R f' b - (f b - f c)) \<le> norm ((b - c) *\<^sub>R f' b) + norm (f b - f c)"
  6.4848          by (rule norm_triangle_ineq4)
  6.4849        also have "\<dots> \<le> e * (b - a) / 8 + e * (b - a) / 8"
  6.4850 @@ -7773,7 +7935,7 @@
  6.4851            apply (auto simp add: field_simps)
  6.4852            done
  6.4853        qed
  6.4854 -      finally show "norm (content {c..b} *\<^sub>R f' b - (f b - f c)) \<le> e * (b - a) / 4"
  6.4855 +      finally show "norm (content {c .. b} *\<^sub>R f' b - (f b - f c)) \<le> e * (b - a) / 4"
  6.4856          unfolding content_real[OF as(1)] by auto
  6.4857      qed
  6.4858    qed
  6.4859 @@ -7821,13 +7983,13 @@
  6.4860            "e * (Sup k -  Inf k) / 2 <
  6.4861              norm (content k *\<^sub>R f' x - (f (Sup k) - f (Inf k)))"
  6.4862          from p(4)[OF this(1)] guess u v by (elim exE) note k=this
  6.4863 -        then have "u \<le> v" and uv: "{u, v} \<subseteq> {u..v}"
  6.4864 +        then have "u \<le> v" and uv: "{u, v} \<subseteq> cbox u v"
  6.4865            using p(2)[OF as(1)] by auto
  6.4866 -        note result = as(2)[unfolded k interval_bounds_real[OF this(1)] content_real[OF this(1)]]
  6.4867 +        note result = as(2)[unfolded k box_real interval_bounds_real[OF this(1)] content_real[OF this(1)]]
  6.4868  
  6.4869          assume as': "x \<noteq> a" "x \<noteq> b"
  6.4870          then have "x \<in> box a b"
  6.4871 -          using p(2-3)[OF as(1)] by (auto simp: interval)
  6.4872 +          using p(2-3)[OF as(1)] by (auto simp: mem_box)
  6.4873          note  * = d(2)[OF this]
  6.4874          have "norm ((v - u) *\<^sub>R f' (x) - (f (v) - f (u))) =
  6.4875            norm ((f (u) - f (x) - (u - x) *\<^sub>R f' (x)) - (f (v) - f (x) - (v - x) *\<^sub>R f' (x)))"
  6.4876 @@ -7871,6 +8033,7 @@
  6.4877          defer
  6.4878          unfolding setsum_Un_disjoint[OF pA(2-),symmetric] pA(1)[symmetric]
  6.4879          unfolding setsum_right_distrib[symmetric]
  6.4880 +        thm additive_tagged_division_1
  6.4881          apply (subst additive_tagged_division_1[OF _ as(1)])
  6.4882          apply (rule assms)
  6.4883        proof -
  6.4884 @@ -7878,7 +8041,7 @@
  6.4885          assume "(x, k) \<in> p \<inter> {t. fst t \<in> {a, b}}"
  6.4886          note xk=IntD1[OF this]
  6.4887          from p(4)[OF this] guess u v by (elim exE) note uv=this
  6.4888 -        with p(2)[OF xk] have "{u..v} \<noteq> {}"
  6.4889 +        with p(2)[OF xk] have "cbox u v \<noteq> {}"
  6.4890            by auto
  6.4891          then show "0 \<le> e * ((Sup k) - (Inf k))"
  6.4892            unfolding uv using e by (auto simp add: field_simps)
  6.4893 @@ -7902,7 +8065,7 @@
  6.4894              using p(2)[OF xk(1)] by auto
  6.4895            then have *: "u = v"
  6.4896              using xk
  6.4897 -            unfolding uv content_eq_0 interval_eq_empty
  6.4898 +            unfolding uv content_eq_0 box_eq_empty
  6.4899              by auto
  6.4900            then show "content k *\<^sub>R (f' (x)) - (f ((Sup k)) - f ((Inf k))) = 0"
  6.4901              using xk unfolding uv by auto
  6.4902 @@ -7931,7 +8094,7 @@
  6.4903              apply (rule_tac[1-2] **)
  6.4904            proof -
  6.4905              let ?B = "\<lambda>x. {t \<in> p. fst t = x \<and> content (snd t) \<noteq> 0}"
  6.4906 -            have pa: "\<And>k. (a, k) \<in> p \<Longrightarrow> \<exists>v. k = {a .. v} \<and> a \<le> v"
  6.4907 +            have pa: "\<And>k. (a, k) \<in> p \<Longrightarrow> \<exists>v. k = cbox a v \<and> a \<le> v"
  6.4908              proof -
  6.4909                case goal1
  6.4910                guess u v using p(4)[OF goal1] by (elim exE) note uv=this
  6.4911 @@ -7939,7 +8102,7 @@
  6.4912                  using p(2)[OF goal1] unfolding uv by auto
  6.4913                have u: "u = a"
  6.4914                proof (rule ccontr)
  6.4915 -                have "u \<in> {u..v}"
  6.4916 +                have "u \<in> cbox u v"
  6.4917                    using p(2-3)[OF goal1(1)] unfolding uv by auto
  6.4918                  have "u \<ge> a"
  6.4919                    using p(2-3)[OF goal1(1)] unfolding uv subset_eq by auto
  6.4920 @@ -7955,7 +8118,7 @@
  6.4921                  apply auto
  6.4922                  done
  6.4923              qed
  6.4924 -            have pb: "\<And>k. (b, k) \<in> p \<Longrightarrow> \<exists>v. k = {v .. b} \<and> b \<ge> v"
  6.4925 +            have pb: "\<And>k. (b, k) \<in> p \<Longrightarrow> \<exists>v. k = cbox v b \<and> b \<ge> v"
  6.4926              proof -
  6.4927                case goal1
  6.4928                guess u v using p(4)[OF goal1] by (elim exE) note uv=this
  6.4929 @@ -7963,7 +8126,7 @@
  6.4930                  using p(2)[OF goal1] unfolding uv by auto
  6.4931                have u: "v =  b"
  6.4932                proof (rule ccontr)
  6.4933 -                have "u \<in> {u..v}"
  6.4934 +                have "u \<in> cbox u v"
  6.4935                    using p(2-3)[OF goal1(1)] unfolding uv by auto
  6.4936                  have "v \<le> b"
  6.4937                    using p(2-3)[OF goal1(1)] unfolding uv subset_eq by auto
  6.4938 @@ -7989,14 +8152,14 @@
  6.4939                guess v using pa[OF k(1)] .. note v = conjunctD2[OF this]
  6.4940                guess v' using pa[OF k(2)] .. note v' = conjunctD2[OF this] let ?v = "min v v'"
  6.4941                have "box a ?v \<subseteq> k \<inter> k'"
  6.4942 -                unfolding v v' by (auto simp add: interval)
  6.4943 +                unfolding v v' by (auto simp add: mem_box)
  6.4944                note interior_mono[OF this,unfolded interior_inter]
  6.4945                moreover have "(a + ?v)/2 \<in> box a ?v"
  6.4946                  using k(3-)
  6.4947                  unfolding v v' content_eq_0 not_le
  6.4948 -                by (auto simp add: interval)
  6.4949 +                by (auto simp add: mem_box)
  6.4950                ultimately have "(a + ?v)/2 \<in> interior k \<inter> interior k'"
  6.4951 -                unfolding interior_open[OF open_interval] by auto
  6.4952 +                unfolding interior_open[OF open_box] by auto
  6.4953                then have *: "k = k'"
  6.4954                  apply -
  6.4955                  apply (rule ccontr)
  6.4956 @@ -8020,12 +8183,12 @@
  6.4957                guess v' using pb[OF k(2)] .. note v' = conjunctD2[OF this]
  6.4958                let ?v = "max v v'"
  6.4959                have "box ?v b \<subseteq> k \<inter> k'"
  6.4960 -                unfolding v v' by (auto simp: interval)
  6.4961 +                unfolding v v' by (auto simp: mem_box)
  6.4962                  note interior_mono[OF this,unfolded interior_inter]
  6.4963                moreover have " ((b + ?v)/2) \<in> box ?v b"
  6.4964 -                using k(3-) unfolding v v' content_eq_0 not_le by (auto simp: interval)
  6.4965 +                using k(3-) unfolding v v' content_eq_0 not_le by (auto simp: mem_box)
  6.4966                ultimately have " ((b + ?v)/2) \<in> interior k \<inter> interior k'"
  6.4967 -                unfolding interior_open[OF open_interval] by auto
  6.4968 +                unfolding interior_open[OF open_box] by auto
  6.4969                then have *: "k = k'"
  6.4970                  apply -
  6.4971                  apply (rule ccontr)
  6.4972 @@ -8061,7 +8224,7 @@
  6.4973                  apply (auto simp add:subset_eq dist_real_def v)
  6.4974                  done
  6.4975                ultimately show ?case
  6.4976 -                unfolding v interval_bounds_real[OF v(2)]
  6.4977 +                unfolding v interval_bounds_real[OF v(2)] box_real
  6.4978                  apply -
  6.4979                  apply(rule da(2)[of "v"])
  6.4980                  using goal1 fineD[OF as(2) goal1(1)]
  6.4981 @@ -8093,7 +8256,7 @@
  6.4982                  done
  6.4983                ultimately show ?case
  6.4984                  unfolding v
  6.4985 -                unfolding interval_bounds_real[OF v(2)]
  6.4986 +                unfolding interval_bounds_real[OF v(2)] box_real
  6.4987                  apply -
  6.4988                  apply(rule db(2)[of "v"])
  6.4989                  using goal1 fineD[OF as(2) goal1(1)]
  6.4990 @@ -8115,9 +8278,9 @@
  6.4991    fixes f :: "real \<Rightarrow> 'a::banach"
  6.4992    assumes "finite s"
  6.4993      and "a \<le> b"
  6.4994 -    and "continuous_on {a..b} f"
  6.4995 -    and "\<forall>x\<in>box a b - s. (f has_vector_derivative f'(x)) (at x)"
  6.4996 -  shows "(f' has_integral (f b - f a)) {a..b}"
  6.4997 +    and "continuous_on {a .. b} f"
  6.4998 +    and "\<forall>x\<in>{a <..< b} - s. (f has_vector_derivative f'(x)) (at x)"
  6.4999 +  shows "(f' has_integral (f b - f a)) {a .. b}"
  6.5000    using assms
  6.5001  proof (induct "card s" arbitrary: s a b)
  6.5002    case 0
  6.5003 @@ -8154,7 +8317,7 @@
  6.5004        by auto
  6.5005      case True
  6.5006      then have "a \<le> c" "c \<le> b"
  6.5007 -      by (auto simp: interval)
  6.5008 +      by (auto simp: mem_box)
  6.5009      then show ?thesis
  6.5010        apply (subst *)
  6.5011        apply (rule has_integral_combine)
  6.5012 @@ -8163,18 +8326,18 @@
  6.5013        using Suc(3)
  6.5014        unfolding cs
  6.5015      proof -
  6.5016 -      show "continuous_on {a..c} f" "continuous_on {c..b} f"
  6.5017 +      show "continuous_on {a .. c} f" "continuous_on {c .. b} f"
  6.5018          apply (rule_tac[!] continuous_on_subset[OF Suc(5)])
  6.5019          using True
  6.5020 -        apply (auto simp: interval)
  6.5021 -        done
  6.5022 -      let ?P = "\<lambda>i j. \<forall>x\<in>box i j - s'. (f has_vector_derivative f' x) (at x)"
  6.5023 +        apply (auto simp: mem_box)
  6.5024 +        done
  6.5025 +      let ?P = "\<lambda>i j. \<forall>x\<in>{i <..< j} - s'. (f has_vector_derivative f' x) (at x)"
  6.5026        show "?P a c" "?P c b"
  6.5027          apply safe
  6.5028          apply (rule_tac[!] Suc(6)[rule_format])
  6.5029          using True
  6.5030          unfolding cs
  6.5031 -        apply (auto simp: interval)
  6.5032 +        apply (auto simp: mem_box)
  6.5033          done
  6.5034      qed auto
  6.5035    qed
  6.5036 @@ -8184,22 +8347,22 @@
  6.5037    fixes f :: "real \<Rightarrow> 'a::banach"
  6.5038    assumes "finite s"
  6.5039      and "a \<le> b"
  6.5040 -    and "continuous_on {a..b} f"
  6.5041 -    and "\<forall>x\<in>{a..b} - s. (f has_vector_derivative f'(x)) (at x)"
  6.5042 -  shows "(f' has_integral (f(b) - f(a))) {a..b}"
  6.5043 +    and "continuous_on {a .. b} f"
  6.5044 +    and "\<forall>x\<in>{a .. b} - s. (f has_vector_derivative f'(x)) (at x)"
  6.5045 +  shows "(f' has_integral (f b - f a)) {a .. b}"
  6.5046    apply (rule fundamental_theorem_of_calculus_interior_strong[OF assms(1-3), of f'])
  6.5047    using assms(4)
  6.5048 -  apply (auto simp: interval)
  6.5049 +  apply (auto simp: mem_box)
  6.5050    done
  6.5051  
  6.5052  lemma indefinite_integral_continuous_left:
  6.5053    fixes f:: "real \<Rightarrow> 'a::banach"
  6.5054 -  assumes "f integrable_on {a..b}"
  6.5055 +  assumes "f integrable_on {a .. b}"
  6.5056      and "a < c"
  6.5057      and "c \<le> b"
  6.5058      and "e > 0"
  6.5059    obtains d where "d > 0"
  6.5060 -    and "\<forall>t. c - d < t \<and> t \<le> c \<longrightarrow> norm (integral {a..c} f - integral {a..t} f) < e"
  6.5061 +    and "\<forall>t. c - d < t \<and> t \<le> c \<longrightarrow> norm (integral {a .. c} f - integral {a .. t} f) < e"
  6.5062  proof -
  6.5063    have "\<exists>w>0. \<forall>t. c - w < t \<and> t < c \<longrightarrow> norm (f c) * norm(c - t) < e / 3"
  6.5064    proof (cases "f c = 0")
  6.5065 @@ -8244,12 +8407,12 @@
  6.5066  
  6.5067    have *: "e / 3 > 0"
  6.5068      using assms by auto
  6.5069 -  have "f integrable_on {a..c}"
  6.5070 -    apply (rule integrable_subinterval[OF assms(1)])
  6.5071 +  have "f integrable_on {a .. c}"
  6.5072 +    apply (rule integrable_subinterval_real[OF assms(1)])
  6.5073      using assms(2-3)
  6.5074      apply auto
  6.5075      done
  6.5076 -  from integrable_integral[OF this,unfolded has_integral,rule_format,OF *] guess d1 ..
  6.5077 +  from integrable_integral[OF this,unfolded has_integral_real,rule_format,OF *] guess d1 ..
  6.5078    note d1 = conjunctD2[OF this,rule_format]
  6.5079    def d \<equiv> "\<lambda>x. ball x w \<inter> d1 x"
  6.5080    have "gauge d"
  6.5081 @@ -8268,7 +8431,7 @@
  6.5082        using k(1) using assms(2) by auto
  6.5083      fix t
  6.5084      assume as: "c - ?d < t" "t \<le> c"
  6.5085 -    let ?thesis = "norm (integral {a..c} f - integral {a..t} f) < e"
  6.5086 +    let ?thesis = "norm (integral ({a .. c}) f - integral ({a .. t}) f) < e"
  6.5087      {
  6.5088        presume *: "t < c \<Longrightarrow> ?thesis"
  6.5089        show ?thesis
  6.5090 @@ -8282,17 +8445,17 @@
  6.5091      }
  6.5092      assume "t < c"
  6.5093  
  6.5094 -    have "f integrable_on {a..t}"
  6.5095 -      apply (rule integrable_subinterval[OF assms(1)])
  6.5096 +    have "f integrable_on {a .. t}"
  6.5097 +      apply (rule integrable_subinterval_real[OF assms(1)])
  6.5098        using assms(2-3) as(2)
  6.5099        apply auto
  6.5100        done
  6.5101 -    from integrable_integral[OF this,unfolded has_integral,rule_format,OF *] guess d2 ..
  6.5102 +    from integrable_integral[OF this,unfolded has_integral_real,rule_format,OF *] guess d2 ..
  6.5103      note d2 = conjunctD2[OF this,rule_format]
  6.5104      def d3 \<equiv> "\<lambda>x. if x \<le> t then d1 x \<inter> d2 x else d1 x"
  6.5105      have "gauge d3"
  6.5106        using d2(1) d1(1) unfolding d3_def gauge_def by auto
  6.5107 -    from fine_division_exists[OF this, of a t] guess p . note p=this
  6.5108 +    from fine_division_exists_real[OF this, of a t] guess p . note p=this
  6.5109      note p'=tagged_division_ofD[OF this(1)]
  6.5110      have pt: "\<forall>(x,k)\<in>p. x \<le> t"
  6.5111      proof safe
  6.5112 @@ -8308,14 +8471,14 @@
  6.5113        done
  6.5114      note d2_fin = d2(2)[OF conjI[OF p(1) this]]
  6.5115  
  6.5116 -    have *: "{a..c} \<inter> {x. x \<bullet> 1 \<le> t} = {a..t}" "{a..c} \<inter> {x. x \<bullet> 1 \<ge> t} = {t..c}"
  6.5117 +    have *: "{a .. c} \<inter> {x. x \<bullet> 1 \<le> t} = {a .. t}" "{a .. c} \<inter> {x. x \<bullet> 1 \<ge> t} = {t .. c}"
  6.5118        using assms(2-3) as by (auto simp add: field_simps)
  6.5119 -    have "p \<union> {(c, {t..c})} tagged_division_of {a..c} \<and> d1 fine p \<union> {(c, {t..c})}"
  6.5120 +    have "p \<union> {(c, {t .. c})} tagged_division_of {a .. c} \<and> d1 fine p \<union> {(c, {t .. c})}"
  6.5121        apply rule
  6.5122 -      apply (rule tagged_division_union_interval[of _ _ _ 1 "t"])
  6.5123 +      apply (rule tagged_division_union_interval_real[of _ _ _ 1 "t"])
  6.5124        unfolding *
  6.5125        apply (rule p)
  6.5126 -      apply (rule tagged_division_of_self)
  6.5127 +      apply (rule tagged_division_of_self_real)
  6.5128        unfolding fine_def
  6.5129        apply safe
  6.5130      proof -
  6.5131 @@ -8340,25 +8503,25 @@
  6.5132          by auto
  6.5133      qed (insert as(2), auto) note d1_fin = d1(2)[OF this]
  6.5134  
  6.5135 -    have *: "integral{a..c} f - integral {a..t} f = -(((c - t) *\<^sub>R f c + (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x)) -
  6.5136 -      integral {a..c} f) + ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - integral {a..t} f) + (c - t) *\<^sub>R f c"
  6.5137 +    have *: "integral {a .. c} f - integral {a .. t} f = -(((c - t) *\<^sub>R f c + (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x)) -
  6.5138 +      integral {a .. c} f) + ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - integral {a .. t} f) + (c - t) *\<^sub>R f c"
  6.5139        "e = (e/3 + e/3) + e/3"
  6.5140        by auto
  6.5141 -    have **: "(\<Sum>(x, k)\<in>p \<union> {(c, {t..c})}. content k *\<^sub>R f x) =
  6.5142 +    have **: "(\<Sum>(x, k)\<in>p \<union> {(c, {t .. c})}. content k *\<^sub>R f x) =
  6.5143        (c - t) *\<^sub>R f c + (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x)"
  6.5144      proof -
  6.5145        have **: "\<And>x F. F \<union> {x} = insert x F"
  6.5146          by auto
  6.5147 -      have "(c, {t..c}) \<notin> p"
  6.5148 +      have "(c, cbox t c) \<notin> p"
  6.5149        proof safe
  6.5150          case goal1
  6.5151 -        from p'(2-3)[OF this] have "c \<in> {a..t}"
  6.5152 +        from p'(2-3)[OF this] have "c \<in> cbox a t"
  6.5153            by auto
  6.5154          then show False using `t < c`
  6.5155            by auto
  6.5156        qed
  6.5157        then show ?thesis
  6.5158 -        unfolding **
  6.5159 +        unfolding ** box_real
  6.5160          apply -
  6.5161          apply (subst setsum_insert)
  6.5162          apply (rule p')
  6.5163 @@ -8401,14 +8564,14 @@
  6.5164  
  6.5165  lemma indefinite_integral_continuous_right:
  6.5166    fixes f :: "real \<Rightarrow> 'a::banach"
  6.5167 -  assumes "f integrable_on {a..b}"
  6.5168 +  assumes "f integrable_on {a .. b}"
  6.5169      and "a \<le> c"
  6.5170      and "c < b"
  6.5171      and "e > 0"
  6.5172    obtains d where "0 < d"
  6.5173 -    and "\<forall>t. c \<le> t \<and> t < c + d \<longrightarrow> norm (integral {a..c} f - integral {a..t} f) < e"
  6.5174 -proof -
  6.5175 -  have *: "(\<lambda>x. f (- x)) integrable_on {- b..- a}" "- b < - c" "- c \<le> - a"
  6.5176 +    and "\<forall>t. c \<le> t \<and> t < c + d \<longrightarrow> norm (integral {a .. c} f - integral {a .. t} f) < e"
  6.5177 +proof -
  6.5178 +  have *: "(\<lambda>x. f (- x)) integrable_on {-b .. -a}" "- b < - c" "- c \<le> - a"
  6.5179      using assms by auto
  6.5180    from indefinite_integral_continuous_left[OF * `e>0`] guess d . note d = this
  6.5181    let ?d = "min d (b - c)"
  6.5182 @@ -8420,8 +8583,8 @@
  6.5183        using d(1) assms(3) by auto
  6.5184      fix t :: real
  6.5185      assume as: "c \<le> t" "t < c + ?d"
  6.5186 -    have *: "integral {a..c} f = integral {a..b} f - integral {c..b} f"
  6.5187 -      "integral {a..t} f = integral {a..b} f - integral {t..b} f"
  6.5188 +    have *: "integral {a .. c} f = integral {a .. b} f - integral {c .. b} f"
  6.5189 +      "integral {a .. t} f = integral {a .. b} f - integral {t .. b} f"
  6.5190        unfolding algebra_simps
  6.5191        apply (rule_tac[!] integral_combine)
  6.5192        using assms as
  6.5193 @@ -8429,7 +8592,7 @@
  6.5194        done
  6.5195      have "(- c) - d < (- t) \<and> - t \<le> - c"
  6.5196        using as by auto note d(2)[rule_format,OF this]
  6.5197 -    then show "norm (integral {a..c} f - integral {a..t} f) < e"
  6.5198 +    then show "norm (integral {a .. c} f - integral {a .. t} f) < e"
  6.5199        unfolding *
  6.5200        unfolding integral_reflect
  6.5201        apply (subst norm_minus_commute)
  6.5202 @@ -8440,12 +8603,12 @@
  6.5203  
  6.5204  lemma indefinite_integral_continuous:
  6.5205    fixes f :: "real \<Rightarrow> 'a::banach"
  6.5206 -  assumes "f integrable_on {a..b}"
  6.5207 -  shows "continuous_on {a..b} (\<lambda>x. integral {a..x} f)"
  6.5208 +  assumes "f integrable_on {a .. b}"
  6.5209 +  shows "continuous_on {a .. b} (\<lambda>x. integral {a .. x} f)"
  6.5210  proof (unfold continuous_on_iff, safe)
  6.5211    fix x e :: real
  6.5212 -  assume as: "x \<in> {a..b}" "e > 0"
  6.5213 -  let ?thesis = "\<exists>d>0. \<forall>x'\<in>{a..b}. dist x' x < d \<longrightarrow> dist (integral {a..x'} f) (integral {a..x} f) < e"
  6.5214 +  assume as: "x \<in> {a .. b}" "e > 0"
  6.5215 +  let ?thesis = "\<exists>d>0. \<forall>x'\<in>{a .. b}. dist x' x < d \<longrightarrow> dist (integral {a .. x'} f) (integral {a .. x} f) < e"
  6.5216    {
  6.5217      presume *: "a < b \<Longrightarrow> ?thesis"
  6.5218      show ?thesis
  6.5219 @@ -8454,12 +8617,11 @@
  6.5220        apply assumption
  6.5221      proof -
  6.5222        case goal1
  6.5223 -      then have "{a..b} = {x}"
  6.5224 +      then have "cbox a b = {x}"
  6.5225          using as(1)
  6.5226          apply -
  6.5227          apply (rule set_eqI)
  6.5228 -        unfolding atLeastAtMost_iff
  6.5229 -        apply (auto simp only: field_simps not_less)
  6.5230 +        apply auto
  6.5231          done
  6.5232        then show ?case using `e > 0` by auto
  6.5233      qed
  6.5234 @@ -8509,8 +8671,8 @@
  6.5235        show "0 < min d1 d2"
  6.5236          using d1 d2 by auto
  6.5237        fix y
  6.5238 -      assume "y \<in> {a..b}" and "dist y x < min d1 d2"
  6.5239 -      then show "dist (integral {a..y} f) (integral {a..x} f) < e"
  6.5240 +      assume "y \<in> {a .. b}" and "dist y x < min d1 d2"
  6.5241 +      then show "dist (integral {a .. y} f) (integral {a .. x} f) < e"
  6.5242          apply (subst dist_commute)
  6.5243          apply (cases "y < x")
  6.5244          unfolding dist_norm
  6.5245 @@ -8530,16 +8692,16 @@
  6.5246  lemma has_derivative_zero_unique_strong_interval:
  6.5247    fixes f :: "real \<Rightarrow> 'a::banach"
  6.5248    assumes "finite k"
  6.5249 -    and "continuous_on {a..b} f"
  6.5250 +    and "continuous_on {a .. b} f"
  6.5251      and "f a = y"
  6.5252 -    and "\<forall>x\<in>({a..b} - k). (f has_derivative (\<lambda>h. 0)) (at x within {a..b})" "x \<in> {a..b}"
  6.5253 +    and "\<forall>x\<in>({a .. b} - k). (f has_derivative (\<lambda>h. 0)) (at x within {a .. b})" "x \<in> {a .. b}"
  6.5254    shows "f x = y"
  6.5255  proof -
  6.5256    have ab: "a \<le> b"
  6.5257      using assms by auto
  6.5258    have *: "a \<le> x"
  6.5259      using assms(5) by auto
  6.5260 -  have "((\<lambda>x. 0\<Colon>'a) has_integral f x - f a) {a..x}"
  6.5261 +  have "((\<lambda>x. 0\<Colon>'a) has_integral f x - f a) {a .. x}"
  6.5262      apply (rule fundamental_theorem_of_calculus_interior_strong[OF assms(1) *])
  6.5263      apply (rule continuous_on_subset[OF assms(2)])
  6.5264      defer
  6.5265 @@ -8547,10 +8709,10 @@
  6.5266      unfolding has_vector_derivative_def
  6.5267      apply (subst has_derivative_within_open[symmetric])
  6.5268      apply assumption
  6.5269 -    apply (rule open_interval)
  6.5270 -    apply (rule has_derivative_within_subset[where s="{a..b}"])
  6.5271 +    apply (rule open_greaterThanLessThan)
  6.5272 +    apply (rule has_derivative_within_subset[where s="{a .. b}"])
  6.5273      using assms(4) assms(5)
  6.5274 -    apply (auto simp: interval)
  6.5275 +    apply (auto simp: mem_box)
  6.5276      done
  6.5277    note this[unfolded *]
  6.5278    note has_integral_unique[OF has_integral_0 this]
  6.5279 @@ -8562,7 +8724,7 @@
  6.5280  subsection {* Generalize a bit to any convex set. *}
  6.5281  
  6.5282  lemma has_derivative_zero_unique_strong_convex:
  6.5283 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
  6.5284 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::banach"
  6.5285    assumes "convex s"
  6.5286      and "finite k"
  6.5287      and "continuous_on s f"
  6.5288 @@ -8584,7 +8746,7 @@
  6.5289    }
  6.5290    assume "x \<noteq> c"
  6.5291    note conv = assms(1)[unfolded convex_alt,rule_format]
  6.5292 -  have as1: "continuous_on {0..1} (f \<circ> (\<lambda>t. (1 - t) *\<^sub>R c + t *\<^sub>R x))"
  6.5293 +  have as1: "continuous_on {0 ..1} (f \<circ> (\<lambda>t. (1 - t) *\<^sub>R c + t *\<^sub>R x))"
  6.5294      apply (rule continuous_on_intros)+
  6.5295      apply (rule continuous_on_subset[OF assms(3)])
  6.5296      apply safe
  6.5297 @@ -8623,14 +8785,14 @@
  6.5298      apply rule
  6.5299    proof -
  6.5300      fix t
  6.5301 -    assume as: "t \<in> {0..1} - {t. (1 - t) *\<^sub>R c + t *\<^sub>R x \<in> k}"
  6.5302 +    assume as: "t \<in> {0 .. 1} - {t. (1 - t) *\<^sub>R c + t *\<^sub>R x \<in> k}"
  6.5303      have *: "c - t *\<^sub>R c + t *\<^sub>R x \<in> s - k"
  6.5304        apply safe
  6.5305        apply (rule conv[unfolded scaleR_simps])
  6.5306        using `x \<in> s` `c \<in> s` as
  6.5307        by (auto simp add: algebra_simps)
  6.5308      have "(f \<circ> (\<lambda>t. (1 - t) *\<^sub>R c + t *\<^sub>R x) has_derivative (\<lambda>x. 0) \<circ> (\<lambda>z. (0 - z *\<^sub>R c) + z *\<^sub>R x))
  6.5309 -      (at t within {0..1})"
  6.5310 +      (at t within {0 .. 1})"
  6.5311        apply (rule diff_chain_within)
  6.5312        apply (rule has_derivative_add)
  6.5313        unfolding scaleR_simps
  6.5314 @@ -8643,7 +8805,7 @@
  6.5315        using `x \<in> s` `c \<in> s`
  6.5316        apply auto
  6.5317        done
  6.5318 -    then show "((\<lambda>xa. f ((1 - xa) *\<^sub>R c + xa *\<^sub>R x)) has_derivative (\<lambda>h. 0)) (at t within {0..1})"
  6.5319 +    then show "((\<lambda>xa. f ((1 - xa) *\<^sub>R c + xa *\<^sub>R x)) has_derivative (\<lambda>h. 0)) (at t within {0 .. 1})"
  6.5320        unfolding o_def .
  6.5321    qed auto
  6.5322    then show ?thesis
  6.5323 @@ -8655,7 +8817,7 @@
  6.5324   generalize to locally convex set with limpt-free set of exceptions. *}
  6.5325  
  6.5326  lemma has_derivative_zero_unique_strong_connected:
  6.5327 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
  6.5328 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::banach"
  6.5329    assumes "connected s"
  6.5330      and "open s"
  6.5331      and "finite k"
  6.5332 @@ -8711,14 +8873,14 @@
  6.5333  subsection {* Integrating characteristic function of an interval *}
  6.5334  
  6.5335  lemma has_integral_restrict_open_subinterval:
  6.5336 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
  6.5337 -  assumes "(f has_integral i) {c..d}"
  6.5338 -    and "{c..d} \<subseteq> {a..b}"
  6.5339 -  shows "((\<lambda>x. if x \<in> box c d then f x else 0) has_integral i) {a..b}"
  6.5340 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::banach"
  6.5341 +  assumes "(f has_integral i) (cbox c d)"
  6.5342 +    and "cbox c d \<subseteq> cbox a b"
  6.5343 +  shows "((\<lambda>x. if x \<in> box c d then f x else 0) has_integral i) (cbox a b)"
  6.5344  proof -
  6.5345    def g \<equiv> "\<lambda>x. if x \<in>box c d then f x else 0"
  6.5346    {
  6.5347 -    presume *: "{c..d} \<noteq> {} \<Longrightarrow> ?thesis"
  6.5348 +    presume *: "cbox c d \<noteq> {} \<Longrightarrow> ?thesis"
  6.5349      show ?thesis
  6.5350        apply cases
  6.5351        apply (rule *)
  6.5352 @@ -8726,7 +8888,7 @@
  6.5353      proof -
  6.5354        case goal1
  6.5355        then have *: "box c d = {}"
  6.5356 -        by (metis bot.extremum_uniqueI interval_open_subset_closed)
  6.5357 +        by (metis bot.extremum_uniqueI box_subset_cbox)
  6.5358        show ?thesis
  6.5359          using assms(1)
  6.5360          unfolding *
  6.5361 @@ -8734,14 +8896,14 @@
  6.5362          by auto
  6.5363      qed
  6.5364    }
  6.5365 -  assume "{c..d} \<noteq> {}"
  6.5366 +  assume "cbox c d \<noteq> {}"
  6.5367    from partial_division_extend_1[OF assms(2) this] guess p . note p=this
  6.5368    note mon = monoidal_lifted[OF monoidal_monoid]
  6.5369    note operat = operative_division[OF this operative_integral p(1), symmetric]
  6.5370 -  let ?P = "(if g integrable_on {a..b} then Some (integral {a..b} g) else None) = Some i"
  6.5371 +  let ?P = "(if g integrable_on cbox a b then Some (integral (cbox a b) g) else None) = Some i"
  6.5372    {
  6.5373      presume "?P"
  6.5374 -    then have "g integrable_on {a..b} \<and> integral {a..b} g = i"
  6.5375 +    then have "g integrable_on cbox a b \<and> integral (cbox a b) g = i"
  6.5376        apply -
  6.5377        apply cases
  6.5378        apply (subst(asm) if_P)
  6.5379 @@ -8756,7 +8918,7 @@
  6.5380  
  6.5381    note iterate_eq_neutral[OF mon,unfolded neutral_lifted[OF monoidal_monoid]]
  6.5382    note * = this[unfolded neutral_add]
  6.5383 -  have iterate:"iterate (lifted op +) (p - {{c..d}})
  6.5384 +  have iterate:"iterate (lifted op +) (p - {cbox c d})
  6.5385      (\<lambda>i. if g integrable_on i then Some (integral i g) else None) = Some 0"
  6.5386    proof (rule *, rule)
  6.5387      case goal1
  6.5388 @@ -8764,22 +8926,22 @@
  6.5389        by auto
  6.5390      note div = division_ofD(2-5)[OF p(1) this]
  6.5391      from div(3) guess u v by (elim exE) note uv=this
  6.5392 -    have "interior x \<inter> interior {c..d} = {}"
  6.5393 +    have "interior x \<inter> interior (cbox c d) = {}"
  6.5394        using div(4)[OF p(2)] goal1 by auto
  6.5395      then have "(g has_integral 0) x"
  6.5396        unfolding uv
  6.5397        apply -
  6.5398        apply (rule has_integral_spike_interior[where f="\<lambda>x. 0"])
  6.5399 -      unfolding g_def interior_closed_interval
  6.5400 +      unfolding g_def interior_cbox
  6.5401        apply auto
  6.5402        done
  6.5403      then show ?case
  6.5404        by auto
  6.5405    qed
  6.5406  
  6.5407 -  have *: "p = insert {c..d} (p - {{c..d}})"
  6.5408 +  have *: "p = insert (cbox c d) (p - {cbox c d})"
  6.5409      using p by auto
  6.5410 -  have **: "g integrable_on {c..d}"
  6.5411 +  have **: "g integrable_on cbox c d"
  6.5412      apply (rule integrable_spike_interior[where f=f])
  6.5413      unfolding g_def
  6.5414      defer
  6.5415 @@ -8788,7 +8950,7 @@
  6.5416      apply auto
  6.5417      done
  6.5418    moreover
  6.5419 -  have "integral {c..d} g = i"
  6.5420 +  have "integral (cbox c d) g = i"
  6.5421      apply (rule has_integral_unique[OF _ assms(1)])
  6.5422      apply (rule has_integral_spike_interior[where f=g])
  6.5423      defer
  6.5424 @@ -8811,28 +8973,28 @@
  6.5425  qed
  6.5426  
  6.5427  lemma has_integral_restrict_closed_subinterval:
  6.5428 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
  6.5429 -  assumes "(f has_integral i) {c..d}"
  6.5430 -    and "{c..d} \<subseteq> {a..b}"
  6.5431 -  shows "((\<lambda>x. if x \<in> {c..d} then f x else 0) has_integral i) {a..b}"
  6.5432 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::banach"
  6.5433 +  assumes "(f has_integral i) (cbox c d)"
  6.5434 +    and "cbox c d \<subseteq> cbox a b"
  6.5435 +  shows "((\<lambda>x. if x \<in> cbox c d then f x else 0) has_integral i) (cbox a b)"
  6.5436  proof -
  6.5437    note has_integral_restrict_open_subinterval[OF assms]
  6.5438    note * = has_integral_spike[OF negligible_frontier_interval _ this]
  6.5439    show ?thesis
  6.5440      apply (rule *[of c d])
  6.5441 -    using interval_open_subset_closed[of c d]
  6.5442 +    using box_subset_cbox[of c d]
  6.5443      apply auto
  6.5444      done
  6.5445  qed
  6.5446  
  6.5447  lemma has_integral_restrict_closed_subintervals_eq:
  6.5448 -  fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
  6.5449 -  assumes "{c..d} \<subseteq> {a..b}"
  6.5450 -  shows "((\<lambda>x. if x \<in> {c..d} then f x else 0) has_integral i) {a..b} \<longleftrightarrow> (f has_integral i) {c..d}"
  6.5451 +  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::banach"
  6.5452 +  assumes "cbox c d \<subseteq> cbox a b"
  6.5453 +  shows "((\<lambda>x. if x \<in> cbox c d then f x else 0) has_integral i) (cbox a b) \<longleftrightarrow> (f has_integral i) (cbox c d)"
  6.5454    (is "?l = ?r")
  6.5455 -proof (cases "{c..d} = {}")
  6.5456 +proof (cases "cbox c d = {}")
  6.5457    case False
  6.5458 -  let ?g = "\<lambda>x. if x \<in> {c..d} then f x else 0"
  6.5459 +  let ?g = "\<lambda>x. if x \<in> cbox c d then f x else 0"
  6.5460    show ?thesis
  6.5461      apply rule
  6.5462      defer
  6.5463 @@ -8840,17 +9002,17 @@
  6.5464      apply assumption
  6.5465    proof -
  6.5466      assume ?l
  6.5467 -    then have "?g integrable_on {c..d}"
  6.5468 +    then have "?g integrable_on cbox c d"
  6.5469        apply -
  6.5470        apply (rule integrable_subinterval[OF _ assms])
  6.5471        apply auto
  6.5472        done
  6.5473 -    then have *: "f integrable_on {c..d}"
  6.5474 +    then have *: "f integrable_on cbox c d"
  6.5475        apply -
  6.5476        apply (rule integrable_eq)
  6.5477        apply auto
  6.5478        done
  6.5479 -    then have "i = integral {c..d} f"
  6.5480 +    then have "i = integral (cbox c d) f"
  6.5481        apply -
  6.5482        apply (rule has_integral_unique)
  6.5483        apply (rule `?l`)
  6.5484 @@ -8866,14 +9028,14 @@
  6.5485  text {* Hence we can apply the limit process uniformly to all integrals. *}
  6.5486  
  6.5487  lemma has_integral':
  6.5488 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5489 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5490    shows "(f has_integral i) s \<longleftrightarrow>
  6.5491 -    (\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow>
  6.5492 -      (\<exists>z. ((\<lambda>x. if x \<in> s then f(x) else 0) has_integral z) {a..b} \<and> norm(z - i) < e))"
  6.5493 +    (\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> cbox a b \<longrightarrow>
  6.5494 +      (\<exists>z. ((\<lambda>x. if x \<in> s then f(x) else 0) has_integral z) (cbox a b) \<and> norm(z - i) < e))"
  6.5495    (is "?l \<longleftrightarrow> (\<forall>e>0. ?r e)")
  6.5496  proof -
  6.5497    {
  6.5498 -    presume *: "\<exists>a b. s = {a..b} \<Longrightarrow> ?thesis"
  6.5499 +    presume *: "\<exists>a b. s = cbox a b \<Longrightarrow> ?thesis"
  6.5500      show ?thesis
  6.5501        apply cases
  6.5502        apply (rule *)
  6.5503 @@ -8882,7 +9044,7 @@
  6.5504        apply auto
  6.5505        done
  6.5506    }
  6.5507 -  assume "\<exists>a b. s = {a..b}"
  6.5508 +  assume "\<exists>a b. s = cbox a b"
  6.5509    then guess a b by (elim exE) note s=this
  6.5510    from bounded_interval[of a b, THEN conjunct1, unfolded bounded_pos] guess B ..
  6.5511    note B = conjunctD2[OF this,rule_format] show ?thesis
  6.5512 @@ -8897,8 +9059,8 @@
  6.5513        apply (rule_tac x=i in exI)
  6.5514      proof
  6.5515        fix c d :: 'n
  6.5516 -      assume as: "ball 0 (B+1) \<subseteq> {c..d}"
  6.5517 -      then show "((\<lambda>x. if x \<in> s then f x else 0) has_integral i) {c..d}"
  6.5518 +      assume as: "ball 0 (B+1) \<subseteq> cbox c d"
  6.5519 +      then show "((\<lambda>x. if x \<in> s then f x else 0) has_integral i) (cbox c d)"
  6.5520          unfolding s
  6.5521          apply -
  6.5522          apply (rule has_integral_restrict_closed_subinterval)
  6.5523 @@ -8915,10 +9077,10 @@
  6.5524      from this[rule_format,OF zero_less_one] guess C .. note C=conjunctD2[OF this,rule_format]
  6.5525      def c \<equiv> "(\<Sum>i\<in>Basis. (- max B C) *\<^sub>R i)::'n"
  6.5526      def d \<equiv> "(\<Sum>i\<in>Basis. max B C *\<^sub>R i)::'n"
  6.5527 -    have c_d: "{a..b} \<subseteq> {c..d}"
  6.5528 +    have c_d: "cbox a b \<subseteq> cbox c d"
  6.5529        apply safe
  6.5530        apply (drule B(2))
  6.5531 -      unfolding mem_interval
  6.5532 +      unfolding mem_box
  6.5533      proof
  6.5534        case goal1
  6.5535        then show ?case
  6.5536 @@ -8926,9 +9088,9 @@
  6.5537          unfolding c_def d_def
  6.5538          by (auto simp add: field_simps setsum_negf)
  6.5539      qed
  6.5540 -    have "ball 0 C \<subseteq> {c..d}"
  6.5541 +    have "ball 0 C \<subseteq> cbox c d"
  6.5542        apply safe
  6.5543 -      unfolding mem_interval mem_ball dist_norm
  6.5544 +      unfolding mem_box mem_ball dist_norm
  6.5545      proof
  6.5546        case goal1
  6.5547        then show ?case
  6.5548 @@ -8936,7 +9098,7 @@
  6.5549          unfolding c_def d_def
  6.5550          by (auto simp: setsum_negf)
  6.5551      qed
  6.5552 -    from C(2)[OF this] have "\<exists>y. (f has_integral y) {a..b}"
  6.5553 +    from C(2)[OF this] have "\<exists>y. (f has_integral y) (cbox a b)"
  6.5554        unfolding has_integral_restrict_closed_subintervals_eq[OF c_d,symmetric]
  6.5555        unfolding s
  6.5556        by auto
  6.5557 @@ -8950,10 +9112,10 @@
  6.5558        from as[rule_format,OF this] guess C ..  note C=conjunctD2[OF this,rule_format]
  6.5559        def c \<equiv> "(\<Sum>i\<in>Basis. (- max B C) *\<^sub>R i)::'n"
  6.5560        def d \<equiv> "(\<Sum>i\<in>Basis. max B C *\<^sub>R i)::'n"
  6.5561 -      have c_d: "{a..b} \<subseteq> {c..d}"
  6.5562 +      have c_d: "cbox a b \<subseteq> cbox c d"
  6.5563          apply safe
  6.5564          apply (drule B(2))
  6.5565 -        unfolding mem_interval
  6.5566 +        unfolding mem_box
  6.5567        proof
  6.5568          case goal1
  6.5569          then show ?case
  6.5570 @@ -8961,9 +9123,9 @@
  6.5571            unfolding c_def d_def
  6.5572            by (auto simp add: field_simps setsum_negf)
  6.5573        qed
  6.5574 -      have "ball 0 C \<subseteq> {c..d}"
  6.5575 +      have "ball 0 C \<subseteq> cbox c d"
  6.5576          apply safe
  6.5577 -        unfolding mem_interval mem_ball dist_norm
  6.5578 +        unfolding mem_box mem_ball dist_norm
  6.5579        proof
  6.5580          case goal1
  6.5581          then show ?case
  6.5582 @@ -8990,7 +9152,7 @@
  6.5583  qed
  6.5584  
  6.5585  lemma has_integral_le:
  6.5586 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> real"
  6.5587 +  fixes f :: "'n::euclidean_space \<Rightarrow> real"
  6.5588    assumes "(f has_integral i) s"
  6.5589      and "(g has_integral j) s"
  6.5590      and "\<forall>x\<in>s. f x \<le> g x"
  6.5591 @@ -9000,7 +9162,7 @@
  6.5592    by auto
  6.5593  
  6.5594  lemma integral_le:
  6.5595 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> real"
  6.5596 +  fixes f :: "'n::euclidean_space \<Rightarrow> real"
  6.5597    assumes "f integrable_on s"
  6.5598      and "g integrable_on s"
  6.5599      and "\<forall>x\<in>s. f x \<le> g x"
  6.5600 @@ -9008,7 +9170,7 @@
  6.5601    by (rule has_integral_le[OF assms(1,2)[unfolded has_integral_integral] assms(3)])
  6.5602  
  6.5603  lemma has_integral_nonneg:
  6.5604 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> real"
  6.5605 +  fixes f :: "'n::euclidean_space \<Rightarrow> real"
  6.5606    assumes "(f has_integral i) s"
  6.5607      and "\<forall>x\<in>s. 0 \<le> f x"
  6.5608    shows "0 \<le> i"
  6.5609 @@ -9018,7 +9180,7 @@
  6.5610    by auto
  6.5611  
  6.5612  lemma integral_nonneg:
  6.5613 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> real"
  6.5614 +  fixes f :: "'n::euclidean_space \<Rightarrow> real"
  6.5615    assumes "f integrable_on s"
  6.5616      and "\<forall>x\<in>s. 0 \<le> f x"
  6.5617    shows "0 \<le> integral s f"
  6.5618 @@ -9042,12 +9204,12 @@
  6.5619  qed
  6.5620  
  6.5621  lemma has_integral_restrict_univ:
  6.5622 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5623 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5624    shows "((\<lambda>x. if x \<in> s then f x else 0) has_integral i) UNIV \<longleftrightarrow> (f has_integral i) s"
  6.5625    by auto
  6.5626  
  6.5627  lemma has_integral_on_superset:
  6.5628 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5629 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5630    assumes "\<forall>x. x \<notin> s \<longrightarrow> f x = 0"
  6.5631      and "s \<subseteq> t"
  6.5632      and "(f has_integral i) s"
  6.5633 @@ -9067,7 +9229,7 @@
  6.5634  qed
  6.5635  
  6.5636  lemma integrable_on_superset:
  6.5637 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5638 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5639    assumes "\<forall>x. x \<notin> s \<longrightarrow> f x = 0"
  6.5640      and "s \<subseteq> t"
  6.5641      and "f integrable_on s"
  6.5642 @@ -9077,7 +9239,7 @@
  6.5643    by (auto intro:has_integral_on_superset)
  6.5644  
  6.5645  lemma integral_restrict_univ[intro]:
  6.5646 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5647 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5648    shows "f integrable_on s \<Longrightarrow> integral UNIV (\<lambda>x. if x \<in> s then f x else 0) = integral s f"
  6.5649    apply (rule integral_unique)
  6.5650    unfolding has_integral_restrict_univ
  6.5651 @@ -9085,12 +9247,12 @@
  6.5652    done
  6.5653  
  6.5654  lemma integrable_restrict_univ:
  6.5655 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5656 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5657    shows "(\<lambda>x. if x \<in> s then f x else 0) integrable_on UNIV \<longleftrightarrow> f integrable_on s"
  6.5658    unfolding integrable_on_def
  6.5659    by auto
  6.5660  
  6.5661 -lemma negligible_on_intervals: "negligible s \<longleftrightarrow> (\<forall>a b. negligible(s \<inter> {a..b}))" (is "?l \<longleftrightarrow> ?r")
  6.5662 +lemma negligible_on_intervals: "negligible s \<longleftrightarrow> (\<forall>a b. negligible(s \<inter> cbox a b))" (is "?l \<longleftrightarrow> ?r")
  6.5663  proof
  6.5664    assume ?r
  6.5665    show ?l
  6.5666 @@ -9106,7 +9268,7 @@
  6.5667  qed auto
  6.5668  
  6.5669  lemma has_integral_spike_set_eq:
  6.5670 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5671 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5672    assumes "negligible ((s - t) \<union> (t - s))"
  6.5673    shows "(f has_integral y) s \<longleftrightarrow> (f has_integral y) t"
  6.5674    unfolding has_integral_restrict_univ[symmetric,of f]
  6.5675 @@ -9114,7 +9276,7 @@
  6.5676    by (auto split: split_if_asm)
  6.5677  
  6.5678  lemma has_integral_spike_set[dest]:
  6.5679 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5680 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5681    assumes "negligible ((s - t) \<union> (t - s))"
  6.5682      and "(f has_integral y) s"
  6.5683    shows "(f has_integral y) t"
  6.5684 @@ -9122,7 +9284,7 @@
  6.5685    by auto
  6.5686  
  6.5687  lemma integrable_spike_set[dest]:
  6.5688 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5689 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5690    assumes "negligible ((s - t) \<union> (t - s))"
  6.5691      and "f integrable_on s"
  6.5692    shows "f integrable_on t"
  6.5693 @@ -9131,7 +9293,7 @@
  6.5694    unfolding has_integral_spike_set_eq[OF assms(1)] .
  6.5695  
  6.5696  lemma integrable_spike_set_eq:
  6.5697 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5698 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5699    assumes "negligible ((s - t) \<union> (t - s))"
  6.5700    shows "f integrable_on s \<longleftrightarrow> f integrable_on t"
  6.5701    apply rule
  6.5702 @@ -9176,7 +9338,7 @@
  6.5703  subsection {* More lemmas that are useful later *}
  6.5704  
  6.5705  lemma has_integral_subset_component_le:
  6.5706 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
  6.5707 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  6.5708    assumes k: "k \<in> Basis"
  6.5709      and as: "s \<subseteq> t" "(f has_integral i) s" "(f has_integral j) t" "\<forall>x\<in>t. 0 \<le> f(x)\<bullet>k"
  6.5710    shows "i\<bullet>k \<le> j\<bullet>k"
  6.5711 @@ -9191,7 +9353,7 @@
  6.5712  qed
  6.5713  
  6.5714  lemma has_integral_subset_le:
  6.5715 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> real"
  6.5716 +  fixes f :: "'n::euclidean_space \<Rightarrow> real"
  6.5717    assumes "s \<subseteq> t"
  6.5718      and "(f has_integral i) s"
  6.5719      and "(f has_integral j) t"
  6.5720 @@ -9202,7 +9364,7 @@
  6.5721    by auto
  6.5722  
  6.5723  lemma integral_subset_component_le:
  6.5724 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
  6.5725 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  6.5726    assumes "k \<in> Basis"
  6.5727      and "s \<subseteq> t"
  6.5728      and "f integrable_on s"
  6.5729 @@ -9215,7 +9377,7 @@
  6.5730    done
  6.5731  
  6.5732  lemma integral_subset_le:
  6.5733 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> real"
  6.5734 +  fixes f :: "'n::euclidean_space \<Rightarrow> real"
  6.5735    assumes "s \<subseteq> t"
  6.5736      and "f integrable_on s"
  6.5737      and "f integrable_on t"
  6.5738 @@ -9227,10 +9389,10 @@
  6.5739    done
  6.5740  
  6.5741  lemma has_integral_alt':
  6.5742 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5743 -  shows "(f has_integral i) s \<longleftrightarrow> (\<forall>a b. (\<lambda>x. if x \<in> s then f x else 0) integrable_on {a..b}) \<and>
  6.5744 -    (\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow>
  6.5745 -      norm (integral {a..b} (\<lambda>x. if x \<in> s then f x else 0) - i) < e)"
  6.5746 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5747 +  shows "(f has_integral i) s \<longleftrightarrow> (\<forall>a b. (\<lambda>x. if x \<in> s then f x else 0) integrable_on cbox a b) \<and>
  6.5748 +    (\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> cbox a b \<longrightarrow>
  6.5749 +      norm (integral (cbox a b) (\<lambda>x. if x \<in> s then f x else 0) - i) < e)"
  6.5750    (is "?l = ?r")
  6.5751  proof
  6.5752    assume ?r
  6.5753 @@ -9245,7 +9407,7 @@
  6.5754        apply rule
  6.5755        apply (rule B)
  6.5756        apply safe
  6.5757 -      apply (rule_tac x="integral {a..b} (\<lambda>x. if x \<in> s then f x else 0)" in exI)
  6.5758 +      apply (rule_tac x="integral (cbox a b) (\<lambda>x. if x \<in> s then f x else 0)" in exI)
  6.5759        apply (drule B(2)[rule_format])
  6.5760        using integrable_integral[OF `?r`[THEN conjunct1,rule_format]]
  6.5761        apply auto
  6.5762 @@ -9260,22 +9422,22 @@
  6.5763      from as[OF zero_less_one] guess B .. note B=conjunctD2[OF this,rule_format]
  6.5764      let ?a = "\<Sum>i\<in>Basis. min (a\<bullet>i) (-B) *\<^sub>R i::'n"
  6.5765      let ?b = "\<Sum>i\<in>Basis. max (b\<bullet>i) B *\<^sub>R i::'n"
  6.5766 -    show "?f integrable_on {a..b}"
  6.5767 +    show "?f integrable_on cbox a b"
  6.5768      proof (rule integrable_subinterval[of _ ?a ?b])
  6.5769 -      have "ball 0 B \<subseteq> {?a..?b}"
  6.5770 +      have "ball 0 B \<subseteq> cbox ?a ?b"
  6.5771          apply safe
  6.5772 -        unfolding mem_ball mem_interval dist_norm
  6.5773 +        unfolding mem_ball mem_box dist_norm
  6.5774        proof
  6.5775          case goal1
  6.5776          then show ?case using Basis_le_norm[of i x]
  6.5777            by (auto simp add:field_simps)
  6.5778        qed
  6.5779        from B(2)[OF this] guess z .. note conjunct1[OF this]
  6.5780 -      then show "?f integrable_on {?a..?b}"
  6.5781 +      then show "?f integrable_on cbox ?a ?b"
  6.5782          unfolding integrable_on_def by auto
  6.5783 -      show "{a..b} \<subseteq> {?a..?b}"
  6.5784 +      show "cbox a b \<subseteq> cbox ?a ?b"
  6.5785          apply safe
  6.5786 -        unfolding mem_interval
  6.5787 +        unfolding mem_box
  6.5788          apply rule
  6.5789          apply (erule_tac x=i in ballE)
  6.5790          apply auto
  6.5791 @@ -9285,8 +9447,8 @@
  6.5792      fix e :: real
  6.5793      assume "e > 0"
  6.5794      from as[OF this] guess B .. note B=conjunctD2[OF this,rule_format]
  6.5795 -    show "\<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow>
  6.5796 -      norm (integral {a..b} (\<lambda>x. if x \<in> s then f x else 0) - i) < e"
  6.5797 +    show "\<exists>B>0. \<forall>a b. ball 0 B \<subseteq> cbox a b \<longrightarrow>
  6.5798 +      norm (integral (cbox a b) (\<lambda>x. if x \<in> s then f x else 0) - i) < e"
  6.5799        apply rule
  6.5800        apply rule
  6.5801        apply (rule B)
  6.5802 @@ -9304,12 +9466,12 @@
  6.5803  subsection {* Continuity of the integral (for a 1-dimensional interval). *}
  6.5804  
  6.5805  lemma integrable_alt:
  6.5806 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5807 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5808    shows "f integrable_on s \<longleftrightarrow>
  6.5809 -    (\<forall>a b. (\<lambda>x. if x \<in> s then f x else 0) integrable_on {a..b}) \<and>
  6.5810 -    (\<forall>e>0. \<exists>B>0. \<forall>a b c d. ball 0 B \<subseteq> {a..b} \<and> ball 0 B \<subseteq> {c..d} \<longrightarrow>
  6.5811 -    norm (integral {a..b} (\<lambda>x. if x \<in> s then f x else 0) -
  6.5812 -      integral {c..d}  (\<lambda>x. if x \<in> s then f x else 0)) < e)"
  6.5813 +    (\<forall>a b. (\<lambda>x. if x \<in> s then f x else 0) integrable_on cbox a b) \<and>
  6.5814 +    (\<forall>e>0. \<exists>B>0. \<forall>a b c d. ball 0 B \<subseteq> cbox a b \<and> ball 0 B \<subseteq> cbox c d \<longrightarrow>
  6.5815 +    norm (integral (cbox a b) (\<lambda>x. if x \<in> s then f x else 0) -
  6.5816 +      integral (cbox c d)  (\<lambda>x. if x \<in> s then f x else 0)) < e)"
  6.5817    (is "?l = ?r")
  6.5818  proof
  6.5819    assume ?l
  6.5820 @@ -9340,7 +9502,7 @@
  6.5821  next
  6.5822    assume ?r
  6.5823    note as = conjunctD2[OF this,rule_format]
  6.5824 -  let ?cube = "\<lambda>n. {(\<Sum>i\<in>Basis. - real n *\<^sub>R i)::'n .. (\<Sum>i\<in>Basis. real n *\<^sub>R i)} :: 'n set"
  6.5825 +  let ?cube = "\<lambda>n. cbox (\<Sum>i\<in>Basis. - real n *\<^sub>R i::'n) (\<Sum>i\<in>Basis. real n *\<^sub>R i)"
  6.5826    have "Cauchy (\<lambda>n. integral (?cube n) (\<lambda>x. if x \<in> s then f x else 0))"
  6.5827    proof (unfold Cauchy_def, safe)
  6.5828      case goal1
  6.5829 @@ -9351,7 +9513,7 @@
  6.5830        assume n: "n \<ge> N"
  6.5831        have "ball 0 B \<subseteq> ?cube n"
  6.5832          apply safe
  6.5833 -        unfolding mem_ball mem_interval dist_norm
  6.5834 +        unfolding mem_ball mem_box dist_norm
  6.5835        proof
  6.5836          case goal1
  6.5837          then show ?case
  6.5838 @@ -9388,9 +9550,9 @@
  6.5839        show "0 < ?B"
  6.5840          using B(1) by auto
  6.5841        fix a b :: 'n
  6.5842 -      assume ab: "ball 0 ?B \<subseteq> {a..b}"
  6.5843 +      assume ab: "ball 0 ?B \<subseteq> cbox a b"
  6.5844        from real_arch_simple[of ?B] guess n .. note n=this
  6.5845 -      show "norm (integral {a..b} (\<lambda>x. if x \<in> s then f x else 0) - i) < e"
  6.5846 +      show "norm (integral (cbox a b) (\<lambda>x. if x \<in> s then f x else 0) - i) < e"
  6.5847          apply (rule norm_triangle_half_l)
  6.5848          apply (rule B(2))
  6.5849          defer
  6.5850 @@ -9403,11 +9565,11 @@
  6.5851          assume x: "x \<in> ball 0 B"
  6.5852          then have "x \<in> ball 0 ?B"
  6.5853            by auto
  6.5854 -        then show "x \<in> {a..b}"
  6.5855 +        then show "x \<in> cbox a b"
  6.5856            using ab by blast
  6.5857          show "x \<in> ?cube n"
  6.5858            using x
  6.5859 -          unfolding mem_interval mem_ball dist_norm
  6.5860 +          unfolding mem_box mem_ball dist_norm
  6.5861            apply -
  6.5862          proof
  6.5863            case goal1
  6.5864 @@ -9422,18 +9584,18 @@
  6.5865  qed
  6.5866  
  6.5867  lemma integrable_altD:
  6.5868 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5869 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5870    assumes "f integrable_on s"
  6.5871 -  shows "\<And>a b. (\<lambda>x. if x \<in> s then f x else 0) integrable_on {a..b}"
  6.5872 -    and "\<And>e. e > 0 \<Longrightarrow> \<exists>B>0. \<forall>a b c d. ball 0 B \<subseteq> {a..b} \<and> ball 0 B \<subseteq> {c..d} \<longrightarrow>
  6.5873 -      norm (integral {a..b} (\<lambda>x. if x \<in> s then f x else 0) - integral {c..d}  (\<lambda>x. if x \<in> s then f x else 0)) < e"
  6.5874 +  shows "\<And>a b. (\<lambda>x. if x \<in> s then f x else 0) integrable_on cbox a b"
  6.5875 +    and "\<And>e. e > 0 \<Longrightarrow> \<exists>B>0. \<forall>a b c d. ball 0 B \<subseteq> cbox a b \<and> ball 0 B \<subseteq> cbox c d \<longrightarrow>
  6.5876 +      norm (integral (cbox a b) (\<lambda>x. if x \<in> s then f x else 0) - integral (cbox c d)  (\<lambda>x. if x \<in> s then f x else 0)) < e"
  6.5877    using assms[unfolded integrable_alt[of f]] by auto
  6.5878  
  6.5879 -lemma integrable_on_subinterval:
  6.5880 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5881 +lemma integrable_on_subcbox:
  6.5882 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.5883    assumes "f integrable_on s"
  6.5884 -    and "{a..b} \<subseteq> s"
  6.5885 -  shows "f integrable_on {a..b}"
  6.5886 +    and "cbox a b \<subseteq> s"
  6.5887 +  shows "f integrable_on cbox a b"
  6.5888    apply (rule integrable_eq)
  6.5889    defer
  6.5890    apply (rule integrable_altD(1)[OF assms(1)])
  6.5891 @@ -9441,14 +9603,22 @@
  6.5892    apply auto
  6.5893    done
  6.5894  
  6.5895 +lemma integrable_on_subinterval:
  6.5896 +  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.5897 +  assumes "f integrable_on s"
  6.5898 +    and "{a .. b} \<subseteq> s"
  6.5899 +  shows "f integrable_on {a .. b}"
  6.5900 +  using integrable_on_subcbox[of f s a b] assms
  6.5901 +  by (simp add: cbox_interval)
  6.5902 +
  6.5903  
  6.5904  subsection {* A straddling criterion for integrability *}
  6.5905  
  6.5906  lemma integrable_straddle_interval:
  6.5907 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> real"
  6.5908 -  assumes "\<forall>e>0. \<exists>g  h i j. (g has_integral i) {a..b} \<and> (h has_integral j) {a..b} \<and>
  6.5909 -    norm (i - j) < e \<and> (\<forall>x\<in>{a..b}. (g x) \<le> f x \<and> f x \<le> h x)"
  6.5910 -  shows "f integrable_on {a..b}"
  6.5911 +  fixes f :: "'n::euclidean_space \<Rightarrow> real"
  6.5912 +  assumes "\<forall>e>0. \<exists>g  h i j. (g has_integral i) (cbox a b) \<and> (h has_integral j) (cbox a b) \<and>
  6.5913 +    norm (i - j) < e \<and> (\<forall>x\<in>cbox a b. (g x) \<le> f x \<and> f x \<le> h x)"
  6.5914 +  shows "f integrable_on cbox a b"
  6.5915  proof (subst integrable_cauchy, safe)
  6.5916    case goal1
  6.5917    then have e: "e/3 > 0"
  6.5918 @@ -9522,12 +9692,12 @@
  6.5919  qed
  6.5920  
  6.5921  lemma integrable_straddle:
  6.5922 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> real"
  6.5923 +  fixes f :: "'n::euclidean_space \<Rightarrow> real"
  6.5924    assumes "\<forall>e>0. \<exists>g h i j. (g has_integral i) s \<and> (h has_integral j) s \<and>
  6.5925      norm (i - j) < e \<and> (\<forall>x\<in>s. g x \<le> f x \<and> f x \<le> h x)"
  6.5926    shows "f integrable_on s"
  6.5927  proof -
  6.5928 -  have "\<And>a b. (\<lambda>x. if x \<in> s then f x else 0) integrable_on {a..b}"
  6.5929 +  have "\<And>a b. (\<lambda>x. if x \<in> s then f x else 0) integrable_on cbox a b"
  6.5930    proof (rule integrable_straddle_interval, safe)
  6.5931      case goal1
  6.5932      then have *: "e/4 > 0"
  6.5933 @@ -9543,9 +9713,9 @@
  6.5934      from this(2) guess B2 .. note B2 = conjunctD2[OF this,rule_format]
  6.5935      def c \<equiv> "\<Sum>i\<in>Basis. min (a\<bullet>i) (- (max B1 B2)) *\<^sub>R i::'n"
  6.5936      def d \<equiv> "\<Sum>i\<in>Basis. max (b\<bullet>i) (max B1 B2) *\<^sub>R i::'n"
  6.5937 -    have *: "ball 0 B1 \<subseteq> {c..d}" "ball 0 B2 \<subseteq> {c..d}"
  6.5938 +    have *: "ball 0 B1 \<subseteq> cbox c d" "ball 0 B2 \<subseteq> cbox c d"
  6.5939        apply safe
  6.5940 -      unfolding mem_ball mem_interval dist_norm
  6.5941 +      unfolding mem_ball mem_box dist_norm
  6.5942        apply (rule_tac[!] ballI)
  6.5943      proof -
  6.5944        case goal1
  6.5945 @@ -9564,8 +9734,8 @@
  6.5946      show ?case
  6.5947        apply (rule_tac x="\<lambda>x. if x \<in> s then g x else 0" in exI)
  6.5948        apply (rule_tac x="\<lambda>x. if x \<in> s then h x else 0" in exI)
  6.5949 -      apply (rule_tac x="integral {a..b} (\<lambda>x. if x \<in> s then g x else 0)" in exI)
  6.5950 -      apply (rule_tac x="integral {a..b} (\<lambda>x. if x \<in> s then h x else 0)" in exI)
  6.5951 +      apply (rule_tac x="integral (cbox a b) (\<lambda>x. if x \<in> s then g x else 0)" in exI)
  6.5952 +      apply (rule_tac x="integral (cbox a b) (\<lambda>x. if x \<in> s then h x else 0)" in exI)
  6.5953        apply safe
  6.5954        apply (rule_tac[1-2] integrable_integral,rule g)
  6.5955        apply (rule h)
  6.5956 @@ -9575,10 +9745,10 @@
  6.5957          (if x \<in> s then f x - g x else (0::real))"
  6.5958          by auto
  6.5959        note ** = abs_of_nonneg[OF integral_nonneg[OF integrable_sub, OF h g]]
  6.5960 -      show "norm (integral {a..b} (\<lambda>x. if x \<in> s then h x else 0) -
  6.5961 -          integral {a..b} (\<lambda>x. if x \<in> s then g x else 0)) \<le>
  6.5962 -        norm (integral {c..d} (\<lambda>x. if x \<in> s then h x else 0) -
  6.5963 -          integral {c..d} (\<lambda>x. if x \<in> s then g x else 0))"
  6.5964 +      show "norm (integral (cbox a b) (\<lambda>x. if x \<in> s then h x else 0) -
  6.5965 +          integral (cbox a b) (\<lambda>x. if x \<in> s then g x else 0)) \<le>
  6.5966 +        norm (integral (cbox c d) (\<lambda>x. if x \<in> s then h x else 0) -
  6.5967 +          integral (cbox c d) (\<lambda>x. if x \<in> s then g x else 0))"
  6.5968          unfolding integral_sub[OF h g,symmetric] real_norm_def
  6.5969          apply (subst **)
  6.5970          defer
  6.5971 @@ -9589,9 +9759,9 @@
  6.5972          apply (rule integrable_integral integrable_sub h g)+
  6.5973        proof safe
  6.5974          fix x
  6.5975 -        assume "x \<in> {a..b}"
  6.5976 -        then show "x \<in> {c..d}"
  6.5977 -          unfolding mem_interval c_def d_def
  6.5978 +        assume "x \<in> cbox a b"
  6.5979 +        then show "x \<in> cbox c d"
  6.5980 +          unfolding mem_box c_def d_def
  6.5981            apply -
  6.5982            apply rule
  6.5983            apply (erule_tac x=i in ballE)
  6.5984 @@ -9626,7 +9796,7 @@
  6.5985        apply (rule B1)
  6.5986      proof -
  6.5987        fix a b c d :: 'n
  6.5988 -      assume as: "ball 0 (max B1 B2) \<subseteq> {a..b}" "ball 0 (max B1 B2) \<subseteq> {c..d}"
  6.5989 +      assume as: "ball 0 (max B1 B2) \<subseteq> cbox a b" "ball 0 (max B1 B2) \<subseteq> cbox c d"
  6.5990        have **: "ball 0 B1 \<subseteq> ball (0::'n) (max B1 B2)" "ball 0 B2 \<subseteq> ball (0::'n) (max B1 B2)"
  6.5991          by auto
  6.5992        have *: "\<And>ga gc ha hc fa fc::real.
  6.5993 @@ -9634,7 +9804,7 @@
  6.5994          abs (hc - j) < e / 3 \<and> abs (i - j) < e / 3 \<and> ga \<le> fa \<and> fa \<le> ha \<and> gc \<le> fc \<and> fc \<le> hc \<Longrightarrow>
  6.5995          abs (fa - fc) < e"
  6.5996          by (simp add: abs_real_def split: split_if_asm)
  6.5997 -      show "norm (integral {a..b} (\<lambda>x. if x \<in> s then f x else 0) - integral {c..d}
  6.5998 +      show "norm (integral (cbox a b) (\<lambda>x. if x \<in> s then f x else 0) - integral (cbox c d)
  6.5999          (\<lambda>x. if x \<in> s then f x else 0)) < e"
  6.6000          unfolding real_norm_def
  6.6001          apply (rule *)
  6.6002 @@ -9669,7 +9839,7 @@
  6.6003  subsection {* Adding integrals over several sets *}
  6.6004  
  6.6005  lemma has_integral_union:
  6.6006 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.6007 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.6008    assumes "(f has_integral i) s"
  6.6009      and "(f has_integral j) t"
  6.6010      and "negligible (s \<inter> t)"
  6.6011 @@ -9686,7 +9856,7 @@
  6.6012  qed
  6.6013  
  6.6014  lemma has_integral_unions:
  6.6015 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.6016 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.6017    assumes "finite t"
  6.6018      and "\<forall>s\<in>t. (f has_integral (i s)) s"
  6.6019      and "\<forall>s\<in>t. \<forall>s'\<in>t. s \<noteq> s' \<longrightarrow> negligible (s \<inter> s')"
  6.6020 @@ -9733,7 +9903,7 @@
  6.6021  text {* In particular adding integrals over a division, maybe not of an interval. *}
  6.6022  
  6.6023  lemma has_integral_combine_division:
  6.6024 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.6025 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.6026    assumes "d division_of s"
  6.6027      and "\<forall>k\<in>d. (f has_integral (i k)) k"
  6.6028    shows "(f has_integral (setsum i d)) s"
  6.6029 @@ -9750,9 +9920,9 @@
  6.6030      case goal1
  6.6031      from d(4)[OF this(1)] d(4)[OF this(2)] guess a c b d by (elim exE) note obt=this
  6.6032      from d(5)[OF goal1] show ?case
  6.6033 -      unfolding obt interior_closed_interval
  6.6034 +      unfolding obt interior_cbox
  6.6035        apply -
  6.6036 -      apply (rule negligible_subset[of "({a..b}-box a b) \<union> ({c..d}-box c d)"])
  6.6037 +      apply (rule negligible_subset[of "(cbox a b-box a b) \<union> (cbox c d-box c d)"])
  6.6038        apply (rule negligible_union negligible_frontier_interval)+
  6.6039        apply auto
  6.6040        done
  6.6041 @@ -9760,7 +9930,7 @@
  6.6042  qed
  6.6043  
  6.6044  lemma integral_combine_division_bottomup:
  6.6045 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.6046 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.6047    assumes "d division_of s"
  6.6048      and "\<forall>k\<in>d. f integrable_on k"
  6.6049    shows "integral s f = setsum (\<lambda>i. integral i f) d"
  6.6050 @@ -9772,7 +9942,7 @@
  6.6051    done
  6.6052  
  6.6053  lemma has_integral_combine_division_topdown:
  6.6054 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.6055 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.6056    assumes "f integrable_on s"
  6.6057      and "d division_of k"
  6.6058      and "k \<subseteq> s"
  6.6059 @@ -9785,7 +9955,7 @@
  6.6060    from division_ofD(2,4)[OF assms(2) this]
  6.6061    show ?case
  6.6062      apply safe
  6.6063 -    apply (rule integrable_on_subinterval)
  6.6064 +    apply (rule integrable_on_subcbox)
  6.6065      apply (rule assms)
  6.6066      using assms(3)
  6.6067      apply auto
  6.6068 @@ -9793,7 +9963,7 @@
  6.6069  qed
  6.6070  
  6.6071  lemma integral_combine_division_topdown:
  6.6072 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.6073 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.6074    assumes "f integrable_on s"
  6.6075      and "d division_of s"
  6.6076    shows "integral s f = setsum (\<lambda>i. integral i f) d"
  6.6077 @@ -9804,7 +9974,7 @@
  6.6078    done
  6.6079  
  6.6080  lemma integrable_combine_division:
  6.6081 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.6082 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.6083    assumes "d division_of s"
  6.6084      and "\<forall>i\<in>d. f integrable_on i"
  6.6085    shows "f integrable_on s"
  6.6086 @@ -9813,7 +9983,7 @@
  6.6087    by (metis has_integral_combine_division[OF assms(1)])
  6.6088  
  6.6089  lemma integrable_on_subdivision:
  6.6090 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.6091 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.6092    assumes "d division_of i"
  6.6093      and "f integrable_on s"
  6.6094      and "i \<subseteq> s"
  6.6095 @@ -9824,7 +9994,7 @@
  6.6096    note division_ofD(2,4)[OF assms(1) this]
  6.6097    then show ?case
  6.6098      apply safe
  6.6099 -    apply (rule integrable_on_subinterval[OF assms(2)])
  6.6100 +    apply (rule integrable_on_subcbox[OF assms(2)])
  6.6101      using assms(3)
  6.6102      apply auto
  6.6103      done
  6.6104 @@ -9834,7 +10004,7 @@
  6.6105  subsection {* Also tagged divisions *}
  6.6106  
  6.6107  lemma has_integral_combine_tagged_division:
  6.6108 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.6109 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.6110    assumes "p tagged_division_of s"
  6.6111      and "\<forall>(x,k) \<in> p. (f has_integral (i k)) k"
  6.6112    shows "(f has_integral (setsum (\<lambda>(x,k). i k) p)) s"
  6.6113 @@ -9864,10 +10034,10 @@
  6.6114  qed
  6.6115  
  6.6116  lemma integral_combine_tagged_division_bottomup:
  6.6117 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.6118 -  assumes "p tagged_division_of {a..b}"
  6.6119 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.6120 +  assumes "p tagged_division_of (cbox a b)"
  6.6121      and "\<forall>(x,k)\<in>p. f integrable_on k"
  6.6122 -  shows "integral {a..b} f = setsum (\<lambda>(x,k). integral k f) p"
  6.6123 +  shows "integral (cbox a b) f = setsum (\<lambda>(x,k). integral k f) p"
  6.6124    apply (rule integral_unique)
  6.6125    apply (rule has_integral_combine_tagged_division[OF assms(1)])
  6.6126    using assms(2)
  6.6127 @@ -9875,10 +10045,10 @@
  6.6128    done
  6.6129  
  6.6130  lemma has_integral_combine_tagged_division_topdown:
  6.6131 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.6132 -  assumes "f integrable_on {a..b}"
  6.6133 -    and "p tagged_division_of {a..b}"
  6.6134 -  shows "(f has_integral (setsum (\<lambda>(x,k). integral k f) p)) {a..b}"
  6.6135 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.6136 +  assumes "f integrable_on cbox a b"
  6.6137 +    and "p tagged_division_of (cbox a b)"
  6.6138 +  shows "(f has_integral (setsum (\<lambda>(x,k). integral k f) p)) (cbox a b)"
  6.6139    apply (rule has_integral_combine_tagged_division[OF assms(2)])
  6.6140  proof safe
  6.6141    case goal1
  6.6142 @@ -9888,10 +10058,10 @@
  6.6143  qed
  6.6144  
  6.6145  lemma integral_combine_tagged_division_topdown:
  6.6146 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.6147 -  assumes "f integrable_on {a..b}"
  6.6148 -    and "p tagged_division_of {a..b}"
  6.6149 -  shows "integral {a..b} f = setsum (\<lambda>(x,k). integral k f) p"
  6.6150 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.6151 +  assumes "f integrable_on cbox a b"
  6.6152 +    and "p tagged_division_of (cbox a b)"
  6.6153 +  shows "integral (cbox a b) f = setsum (\<lambda>(x,k). integral k f) p"
  6.6154    apply (rule integral_unique)
  6.6155    apply (rule has_integral_combine_tagged_division_topdown)
  6.6156    using assms
  6.6157 @@ -9902,13 +10072,13 @@
  6.6158  subsection {* Henstock's lemma *}
  6.6159  
  6.6160  lemma henstock_lemma_part1:
  6.6161 -  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
  6.6162 -  assumes "f integrable_on {a..b}"
  6.6163 +  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  6.6164 +  assumes "f integrable_on cbox a b"
  6.6165      and "e > 0"
  6.6166      and "gauge d"
  6.6167 -    and "(\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
  6.6168 -      norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - integral({a..b}) f) < e)"
  6.6169 -    and p: "p tagged_partial_division_of {a..b}" "d fine p"
  6.6170 +    and "(\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
  6.6171 +      norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - integral(cbox a b) f) < e)"
  6.6172 +    and p: "p tagged_partial_division_of (cbox a b)" "d fine p"
  6.6173    shows "norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x - integral k f) p) \<le> e"
  6.6174    (is "?x \<le> e")
  6.6175  proof -
  6.6176 @@ -9916,7 +10086,7 @@
  6.6177    fix k :: real
  6.6178    assume k: "k > 0"
  6.6179    note p' = tagged_partial_division_ofD[OF p(1)]
  6.6180 -  have "\<Union>(snd ` p) \<subseteq> {a..b}"
  6.6181 +  have "\<Union>(snd ` p) \<subseteq> cbox a b"
  6.6182      using p'(3) by fastforce
  6.6183    note partial_division_of_tagged_division[OF p(1)] this
  6.6184    from partial_division_extend_interval[OF this] guess q . note q=this and q' = division_ofD[OF this(2)]
  6.6185 @@ -9938,7 +10108,7 @@
  6.6186        apply (rule k)
  6.6187        apply auto
  6.6188        done
  6.6189 -    have "f integrable_on {u..v}"
  6.6190 +    have "f integrable_on cbox u v"
  6.6191        apply (rule integrable_subinterval[OF assms(1)])
  6.6192        using q'(2)[OF i]
  6.6193        unfolding uv
  6.6194 @@ -9958,7 +10128,7 @@
  6.6195    from bchoice[OF this] guess qq .. note qq=this[rule_format]
  6.6196  
  6.6197    let ?p = "p \<union> \<Union>(qq ` r)"
  6.6198 -  have "norm ((\<Sum>(x, k)\<in>?p. content k *\<^sub>R f x) - integral {a..b} f) < e"
  6.6199 +  have "norm ((\<Sum>(x, k)\<in>?p. content k *\<^sub>R f x) - integral (cbox a b) f) < e"
  6.6200      apply (rule assms(4)[rule_format])
  6.6201    proof
  6.6202      show "d fine ?p"
  6.6203 @@ -10009,16 +10179,16 @@
  6.6204          apply auto
  6.6205          done
  6.6206      qed
  6.6207 -    moreover have "\<Union>(snd ` p) \<union> \<Union>r = {a..b}" and "{qq i |i. i \<in> r} = qq ` r"
  6.6208 +    moreover have "\<Union>(snd ` p) \<union> \<Union>r = cbox a b" and "{qq i |i. i \<in> r} = qq ` r"
  6.6209        unfolding Union_Un_distrib[symmetric] r_def
  6.6210        using q
  6.6211        by auto
  6.6212 -    ultimately show "?p tagged_division_of {a..b}"
  6.6213 +    ultimately show "?p tagged_division_of (cbox a b)"
  6.6214        by fastforce
  6.6215    qed
  6.6216  
  6.6217    then have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>\<Union>(qq ` r). content k *\<^sub>R f x) -
  6.6218 -    integral {a..b} f) < e"
  6.6219 +    integral (cbox a b) f) < e"
  6.6220      apply (subst setsum_Un_zero[symmetric])
  6.6221      apply (rule p')
  6.6222      prefer 3
  6.6223 @@ -10045,7 +10215,7 @@
  6.6224    qed auto
  6.6225  
  6.6226    then have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + setsum (setsum (\<lambda>(x, k). content k *\<^sub>R f x))
  6.6227 -    (qq ` r) - integral {a..b} f) < e"
  6.6228 +    (qq ` r) - integral (cbox a b) f) < e"
  6.6229      apply (subst (asm) setsum_UNION_zero)
  6.6230      prefer 4
  6.6231      apply assumption
  6.6232 @@ -10080,7 +10250,7 @@
  6.6233    qed (insert qq, auto)
  6.6234  
  6.6235    then have **: "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + setsum (setsum (\<lambda>(x, k). content k *\<^sub>R f x) \<circ> qq) r -
  6.6236 -    integral {a..b} f) < e"
  6.6237 +    integral (cbox a b) f) < e"
  6.6238      apply (subst (asm) setsum_reindex_nonzero)
  6.6239      apply fact
  6.6240      apply (rule setsum_0')
  6.6241 @@ -10157,13 +10327,13 @@
  6.6242  qed
  6.6243  
  6.6244  lemma henstock_lemma_part2:
  6.6245 -  fixes f :: "'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space"
  6.6246 -  assumes "f integrable_on {a..b}"
  6.6247 +  fixes f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space"
  6.6248 +  assumes "f integrable_on cbox a b"
  6.6249      and "e > 0"
  6.6250      and "gauge d"
  6.6251 -    and "\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
  6.6252 -      norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - integral {a..b} f) < e"
  6.6253 -    and "p tagged_partial_division_of {a..b}"
  6.6254 +    and "\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
  6.6255 +      norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - integral (cbox a b) f) < e"
  6.6256 +    and "p tagged_partial_division_of (cbox a b)"
  6.6257      and "d fine p"
  6.6258    shows "setsum (\<lambda>(x,k). norm (content k *\<^sub>R f x - integral k f)) p \<le> 2 * real (DIM('n)) * e"
  6.6259    unfolding split_def
  6.6260 @@ -10184,11 +10354,11 @@
  6.6261    done
  6.6262  
  6.6263  lemma henstock_lemma:
  6.6264 -  fixes f :: "'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space"
  6.6265 -  assumes "f integrable_on {a..b}"
  6.6266 +  fixes f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space"
  6.6267 +  assumes "f integrable_on cbox a b"
  6.6268      and "e > 0"
  6.6269    obtains d where "gauge d"
  6.6270 -    and "\<forall>p. p tagged_partial_division_of {a..b} \<and> d fine p \<longrightarrow>
  6.6271 +    and "\<forall>p. p tagged_partial_division_of (cbox a b) \<and> d fine p \<longrightarrow>
  6.6272        setsum (\<lambda>(x,k). norm(content k *\<^sub>R f x - integral k f)) p < e"
  6.6273  proof -
  6.6274    have *: "e / (2 * (real DIM('n) + 1)) > 0"
  6.6275 @@ -10299,13 +10469,13 @@
  6.6276  subsection {* Monotone convergence (bounded interval first) *}
  6.6277  
  6.6278  lemma monotone_convergence_interval:
  6.6279 -  fixes f :: "nat \<Rightarrow> 'n::ordered_euclidean_space \<Rightarrow> real"
  6.6280 -  assumes "\<forall>k. (f k) integrable_on {a..b}"
  6.6281 -    and "\<forall>k. \<forall>x\<in>{a..b}.(f k x) \<le> f (Suc k) x"
  6.6282 -    and "\<forall>x\<in>{a..b}. ((\<lambda>k. f k x) ---> g x) sequentially"
  6.6283 -    and "bounded {integral {a..b} (f k) | k . k \<in> UNIV}"
  6.6284 -  shows "g integrable_on {a..b} \<and> ((\<lambda>k. integral ({a..b}) (f k)) ---> integral ({a..b}) g) sequentially"
  6.6285 -proof (cases "content {a..b} = 0")
  6.6286 +  fixes f :: "nat \<Rightarrow> 'n::euclidean_space \<Rightarrow> real"
  6.6287 +  assumes "\<forall>k. (f k) integrable_on cbox a b"
  6.6288 +    and "\<forall>k. \<forall>x\<in>cbox a b.(f k x) \<le> f (Suc k) x"
  6.6289 +    and "\<forall>x\<in>cbox a b. ((\<lambda>k. f k x) ---> g x) sequentially"
  6.6290 +    and "bounded {integral (cbox a b) (f k) | k . k \<in> UNIV}"
  6.6291 +  shows "g integrable_on cbox a b \<and> ((\<lambda>k. integral (cbox a b) (f k)) ---> integral (cbox a b) g) sequentially"
  6.6292 +proof (cases "content (cbox a b) = 0")
  6.6293    case True
  6.6294    show ?thesis
  6.6295      using integrable_on_null[OF True]
  6.6296 @@ -10314,7 +10484,7 @@
  6.6297      by auto
  6.6298  next
  6.6299    case False
  6.6300 -  have fg: "\<forall>x\<in>{a..b}. \<forall> k. (f k x) \<bullet> 1 \<le> (g x) \<bullet> 1"
  6.6301 +  have fg: "\<forall>x\<in>cbox a b. \<forall> k. (f k x) \<bullet> 1 \<le> (g x) \<bullet> 1"
  6.6302    proof safe
  6.6303      case goal1
  6.6304      note assms(3)[rule_format,OF this]
  6.6305 @@ -10329,7 +10499,7 @@
  6.6306        apply auto
  6.6307        done
  6.6308    qed
  6.6309 -  have "\<exists>i. ((\<lambda>k. integral ({a..b}) (f k)) ---> i) sequentially"
  6.6310 +  have "\<exists>i. ((\<lambda>k. integral (cbox a b) (f k)) ---> i) sequentially"
  6.6311      apply (rule bounded_increasing_convergent)
  6.6312      defer
  6.6313      apply rule
  6.6314 @@ -10340,7 +10510,7 @@
  6.6315      apply auto
  6.6316      done
  6.6317    then guess i .. note i=this
  6.6318 -  have i': "\<And>k. (integral({a..b}) (f k)) \<le> i\<bullet>1"
  6.6319 +  have i': "\<And>k. (integral(cbox a b) (f k)) \<le> i\<bullet>1"
  6.6320      apply (rule Lim_component_ge)
  6.6321      apply (rule i)
  6.6322      apply (rule trivial_limit_sequentially)
  6.6323 @@ -10355,13 +10525,13 @@
  6.6324      apply auto
  6.6325      done
  6.6326  
  6.6327 -  have "(g has_integral i) {a..b}"
  6.6328 +  have "(g has_integral i) (cbox a b)"
  6.6329      unfolding has_integral
  6.6330    proof safe
  6.6331      case goal1
  6.6332      note e=this
  6.6333 -    then have "\<forall>k. (\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
  6.6334 -      norm ((\<Sum>(x, ka)\<in>p. content ka *\<^sub>R f k x) - integral {a..b} (f k)) < e / 2 ^ (k + 2)))"
  6.6335 +    then have "\<forall>k. (\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
  6.6336 +      norm ((\<Sum>(x, ka)\<in>p. content ka *\<^sub>R f k x) - integral (cbox a b) (f k)) < e / 2 ^ (k + 2)))"
  6.6337        apply -
  6.6338        apply rule
  6.6339        apply (rule assms(1)[unfolded has_integral_integral has_integral,rule_format])
  6.6340 @@ -10370,7 +10540,7 @@
  6.6341        done
  6.6342      from choice[OF this] guess c .. note c=conjunctD2[OF this[rule_format],rule_format]
  6.6343  
  6.6344 -    have "\<exists>r. \<forall>k\<ge>r. 0 \<le> i\<bullet>1 - (integral {a..b} (f k)) \<and> i\<bullet>1 - (integral {a..b} (f k)) < e / 4"
  6.6345 +    have "\<exists>r. \<forall>k\<ge>r. 0 \<le> i\<bullet>1 - (integral (cbox a b) (f k)) \<and> i\<bullet>1 - (integral (cbox a b) (f k)) < e / 4"
  6.6346      proof -
  6.6347        case goal1
  6.6348        have "e/4 > 0"
  6.6349 @@ -10388,11 +10558,11 @@
  6.6350      qed
  6.6351      then guess r .. note r=conjunctD2[OF this[rule_format]]
  6.6352  
  6.6353 -    have "\<forall>x\<in>{a..b}. \<exists>n\<ge>r. \<forall>k\<ge>n. 0 \<le> (g x)\<bullet>1 - (f k x)\<bullet>1 \<and>
  6.6354 -      (g x)\<bullet>1 - (f k x)\<bullet>1 < e / (4 * content({a..b}))"
  6.6355 +    have "\<forall>x\<in>cbox a b. \<exists>n\<ge>r. \<forall>k\<ge>n. 0 \<le> (g x)\<bullet>1 - (f k x)\<bullet>1 \<and>
  6.6356 +      (g x)\<bullet>1 - (f k x)\<bullet>1 < e / (4 * content(cbox a b))"
  6.6357      proof
  6.6358        case goal1
  6.6359 -      have "e / (4 * content {a..b}) > 0"
  6.6360 +      have "e / (4 * content (cbox a b)) > 0"
  6.6361          apply (rule divide_pos_pos)
  6.6362          apply fact
  6.6363          using False content_pos_le[of a b]
  6.6364 @@ -10419,7 +10589,7 @@
  6.6365          using c(1) unfolding gauge_def d_def by auto
  6.6366      next
  6.6367        fix p
  6.6368 -      assume p: "p tagged_division_of {a..b}" "d fine p"
  6.6369 +      assume p: "p tagged_division_of (cbox a b)" "d fine p"
  6.6370        note p'=tagged_division_ofD[OF p(1)]
  6.6371        have "\<exists>a. \<forall>x\<in>p. m (fst x) \<le> a"
  6.6372          by (metis finite_imageI finite_nat_set_iff_bounded_le p'(1) rev_image_eqI)
  6.6373 @@ -10440,7 +10610,7 @@
  6.6374        proof safe
  6.6375          case goal1
  6.6376          show ?case
  6.6377 -          apply (rule order_trans[of _ "\<Sum>(x, k)\<in>p. content k * (e / (4 * content {a..b}))"])
  6.6378 +          apply (rule order_trans[of _ "\<Sum>(x, k)\<in>p. content k * (e / (4 * content (cbox a b)))"])
  6.6379            unfolding setsum_subtractf[symmetric]
  6.6380            apply (rule order_trans)
  6.6381            apply (rule norm_setsum)
  6.6382 @@ -10451,10 +10621,10 @@
  6.6383          proof -
  6.6384            fix x k
  6.6385            assume xk: "(x, k) \<in> p"
  6.6386 -          then have x: "x \<in> {a..b}"
  6.6387 +          then have x: "x \<in> cbox a b"
  6.6388              using p'(2-3)[OF xk] by auto
  6.6389            from p'(4)[OF xk] guess u v by (elim exE) note uv=this
  6.6390 -          show "norm (content k *\<^sub>R (g x - f (m x) x)) \<le> content k * (e / (4 * content {a..b}))"
  6.6391 +          show "norm (content k *\<^sub>R (g x - f (m x) x)) \<le> content k * (e / (4 * content (cbox a b)))"
  6.6392              unfolding norm_scaleR uv
  6.6393              unfolding abs_of_nonneg[OF content_pos_le]
  6.6394              apply (rule mult_left_mono)
  6.6395 @@ -10536,9 +10706,9 @@
  6.6396            unfolding split_paired_all split_conv
  6.6397            apply (rule_tac[1-2] integral_le[OF ])
  6.6398          proof safe
  6.6399 -          show "0 \<le> i\<bullet>1 - (integral {a..b} (f r))\<bullet>1"
  6.6400 +          show "0 \<le> i\<bullet>1 - (integral (cbox a b) (f r))\<bullet>1"
  6.6401              using r(1) by auto
  6.6402 -          show "i\<bullet>1 - (integral {a..b} (f r))\<bullet>1 < e /