src/HOL/Analysis/Henstock_Kurzweil_Integration.thy
changeset 66498 97fc319d6089
parent 66492 d7206afe2d28
parent 66497 18a6478a574c
child 66503 7685861f337d
     1.1 --- a/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy	Thu Aug 24 10:47:56 2017 +0200
     1.2 +++ b/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy	Thu Aug 24 12:45:46 2017 +0100
     1.3 @@ -253,26 +253,25 @@
     1.4  
     1.5  lemma has_integral:
     1.6    "(f has_integral y) (cbox a b) \<longleftrightarrow>
     1.7 -    (\<forall>e>0. \<exists>d. gauge d \<and>
     1.8 -      (\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
     1.9 -        norm (sum (\<lambda>(x,k). content(k) *\<^sub>R f x) p - y) < e))"
    1.10 +    (\<forall>e>0. \<exists>\<gamma>. gauge \<gamma> \<and>
    1.11 +      (\<forall>\<D>. \<D> tagged_division_of (cbox a b) \<and> \<gamma> fine \<D> \<longrightarrow>
    1.12 +        norm (sum (\<lambda>(x,k). content(k) *\<^sub>R f x) \<D> - y) < e))"
    1.13    by (auto simp: dist_norm eventually_division_filter has_integral_def tendsto_iff)
    1.14  
    1.15  lemma has_integral_real:
    1.16    "(f has_integral y) {a..b::real} \<longleftrightarrow>
    1.17 -    (\<forall>e>0. \<exists>d. gauge d \<and>
    1.18 -      (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
    1.19 -        norm (sum (\<lambda>(x,k). content(k) *\<^sub>R f x) p - y) < e))"
    1.20 -  unfolding box_real[symmetric]
    1.21 -  by (rule has_integral)
    1.22 +    (\<forall>e>0. \<exists>\<gamma>. gauge \<gamma> \<and>
    1.23 +      (\<forall>\<D>. \<D> tagged_division_of {a..b} \<and> \<gamma> fine \<D> \<longrightarrow>
    1.24 +        norm (sum (\<lambda>(x,k). content(k) *\<^sub>R f x) \<D> - y) < e))"
    1.25 +  unfolding box_real[symmetric] by (rule has_integral)
    1.26  
    1.27  lemma has_integralD[dest]:
    1.28    assumes "(f has_integral y) (cbox a b)"
    1.29      and "e > 0"
    1.30 -  obtains d
    1.31 -    where "gauge d"
    1.32 -      and "\<And>p. p tagged_division_of (cbox a b) \<Longrightarrow> d fine p \<Longrightarrow>
    1.33 -        norm ((\<Sum>(x,k)\<in>p. content k *\<^sub>R f x) - y) < e"
    1.34 +  obtains \<gamma>
    1.35 +    where "gauge \<gamma>"
    1.36 +      and "\<And>\<D>. \<D> tagged_division_of (cbox a b) \<Longrightarrow> \<gamma> fine \<D> \<Longrightarrow>
    1.37 +        norm ((\<Sum>(x,k)\<in>\<D>. content k *\<^sub>R f x) - y) < e"
    1.38    using assms unfolding has_integral by auto
    1.39  
    1.40  lemma has_integral_alt:
    1.41 @@ -914,28 +913,28 @@
    1.42  
    1.43  subsection \<open>Cauchy-type criterion for integrability.\<close>
    1.44  
    1.45 -lemma integrable_Cauchy:
    1.46 +proposition integrable_Cauchy:
    1.47    fixes f :: "'n::euclidean_space \<Rightarrow> 'a::{real_normed_vector,complete_space}"
    1.48    shows "f integrable_on cbox a b \<longleftrightarrow>
    1.49          (\<forall>e>0. \<exists>\<gamma>. gauge \<gamma> \<and>
    1.50 -          (\<forall>p1 p2. p1 tagged_division_of (cbox a b) \<and> \<gamma> fine p1 \<and>
    1.51 -            p2 tagged_division_of (cbox a b) \<and> \<gamma> fine p2 \<longrightarrow>
    1.52 -            norm ((\<Sum>(x,K)\<in>p1. content K *\<^sub>R f x) - (\<Sum>(x,K)\<in>p2. content K *\<^sub>R f x)) < e))"
    1.53 +          (\<forall>\<D>1 \<D>2. \<D>1 tagged_division_of (cbox a b) \<and> \<gamma> fine \<D>1 \<and>
    1.54 +            \<D>2 tagged_division_of (cbox a b) \<and> \<gamma> fine \<D>2 \<longrightarrow>
    1.55 +            norm ((\<Sum>(x,K)\<in>\<D>1. content K *\<^sub>R f x) - (\<Sum>(x,K)\<in>\<D>2. content K *\<^sub>R f x)) < e))"
    1.56    (is "?l = (\<forall>e>0. \<exists>\<gamma>. ?P e \<gamma>)")
    1.57  proof (intro iffI allI impI)
    1.58    assume ?l
    1.59    then obtain y
    1.60      where y: "\<And>e. e > 0 \<Longrightarrow>
    1.61          \<exists>\<gamma>. gauge \<gamma> \<and>
    1.62 -            (\<forall>p. p tagged_division_of cbox a b \<and> \<gamma> fine p \<longrightarrow>
    1.63 -                 norm ((\<Sum>(x,K) \<in> p. content K *\<^sub>R f x) - y) < e)"
    1.64 +            (\<forall>\<D>. \<D> tagged_division_of cbox a b \<and> \<gamma> fine \<D> \<longrightarrow>
    1.65 +                 norm ((\<Sum>(x,K) \<in> \<D>. content K *\<^sub>R f x) - y) < e)"
    1.66      by (auto simp: integrable_on_def has_integral)
    1.67    show "\<exists>\<gamma>. ?P e \<gamma>" if "e > 0" for e
    1.68    proof -
    1.69      have "e/2 > 0" using that by auto
    1.70      with y obtain \<gamma> where "gauge \<gamma>"
    1.71 -      and \<gamma>: "\<And>p. p tagged_division_of cbox a b \<and> \<gamma> fine p \<Longrightarrow>
    1.72 -                  norm ((\<Sum>(x,K)\<in>p. content K *\<^sub>R f x) - y) < e/2"
    1.73 +      and \<gamma>: "\<And>\<D>. \<D> tagged_division_of cbox a b \<and> \<gamma> fine \<D> \<Longrightarrow>
    1.74 +                  norm ((\<Sum>(x,K)\<in>\<D>. content K *\<^sub>R f x) - y) < e/2"
    1.75        by meson
    1.76      show ?thesis
    1.77      apply (rule_tac x=\<gamma> in exI, clarsimp simp: \<open>gauge \<gamma>\<close>)
    1.78 @@ -947,9 +946,9 @@
    1.79      by auto
    1.80    then obtain \<gamma> :: "nat \<Rightarrow> 'n \<Rightarrow> 'n set" where \<gamma>:
    1.81      "\<And>m. gauge (\<gamma> m)"
    1.82 -    "\<And>m p1 p2. \<lbrakk>p1 tagged_division_of cbox a b;
    1.83 -              \<gamma> m fine p1; p2 tagged_division_of cbox a b; \<gamma> m fine p2\<rbrakk>
    1.84 -              \<Longrightarrow> norm ((\<Sum>(x,K) \<in> p1. content K *\<^sub>R f x) - (\<Sum>(x,K) \<in> p2. content K *\<^sub>R f x))
    1.85 +    "\<And>m \<D>1 \<D>2. \<lbrakk>\<D>1 tagged_division_of cbox a b;
    1.86 +              \<gamma> m fine \<D>1; \<D>2 tagged_division_of cbox a b; \<gamma> m fine \<D>2\<rbrakk>
    1.87 +              \<Longrightarrow> norm ((\<Sum>(x,K) \<in> \<D>1. content K *\<^sub>R f x) - (\<Sum>(x,K) \<in> \<D>2. content K *\<^sub>R f x))
    1.88                    < 1 / (m + 1)"
    1.89      by metis
    1.90    have "\<And>n. gauge (\<lambda>x. \<Inter>{\<gamma> i x |i. i \<in> {0..n}})"
    1.91 @@ -993,8 +992,8 @@
    1.92      obtain N2::nat where N2: "\<And>n. n \<ge> N2 \<Longrightarrow> norm ((\<Sum>(x,K) \<in> p n. content K *\<^sub>R f x) - y) < e/2"
    1.93        using y[OF e2] by metis
    1.94      show "\<exists>\<gamma>. gauge \<gamma> \<and>
    1.95 -              (\<forall>p. p tagged_division_of (cbox a b) \<and> \<gamma> fine p \<longrightarrow>
    1.96 -                norm ((\<Sum>(x,K) \<in> p. content K *\<^sub>R f x) - y) < e)"
    1.97 +              (\<forall>\<D>. \<D> tagged_division_of (cbox a b) \<and> \<gamma> fine \<D> \<longrightarrow>
    1.98 +                norm ((\<Sum>(x,K) \<in> \<D>. content K *\<^sub>R f x) - y) < e)"
    1.99      proof (intro exI conjI allI impI)
   1.100        show "gauge (\<gamma> (N1+N2))"
   1.101          using \<gamma> by auto
   1.102 @@ -1059,15 +1058,15 @@
   1.103      by auto
   1.104      obtain \<gamma>1 where \<gamma>1: "gauge \<gamma>1"
   1.105        and \<gamma>1norm:
   1.106 -        "\<And>p. \<lbrakk>p tagged_division_of cbox a b \<inter> {x. x \<bullet> k \<le> c}; \<gamma>1 fine p\<rbrakk>
   1.107 -             \<Longrightarrow> norm ((\<Sum>(x,K) \<in> p. content K *\<^sub>R f x) - i) < e/2"
   1.108 +        "\<And>\<D>. \<lbrakk>\<D> tagged_division_of cbox a b \<inter> {x. x \<bullet> k \<le> c}; \<gamma>1 fine \<D>\<rbrakk>
   1.109 +             \<Longrightarrow> norm ((\<Sum>(x,K) \<in> \<D>. content K *\<^sub>R f x) - i) < e/2"
   1.110         apply (rule has_integralD[OF fi[unfolded interval_split[OF k]] e])
   1.111         apply (simp add: interval_split[symmetric] k)
   1.112        done
   1.113      obtain \<gamma>2 where \<gamma>2: "gauge \<gamma>2"
   1.114        and \<gamma>2norm:
   1.115 -        "\<And>p. \<lbrakk>p tagged_division_of cbox a b \<inter> {x. c \<le> x \<bullet> k}; \<gamma>2 fine p\<rbrakk>
   1.116 -             \<Longrightarrow> norm ((\<Sum>(x, k) \<in> p. content k *\<^sub>R f x) - j) < e/2"
   1.117 +        "\<And>\<D>. \<lbrakk>\<D> tagged_division_of cbox a b \<inter> {x. c \<le> x \<bullet> k}; \<gamma>2 fine \<D>\<rbrakk>
   1.118 +             \<Longrightarrow> norm ((\<Sum>(x, k) \<in> \<D>. content k *\<^sub>R f x) - j) < e/2"
   1.119         apply (rule has_integralD[OF fj[unfolded interval_split[OF k]] e])
   1.120         apply (simp add: interval_split[symmetric] k)
   1.121         done
   1.122 @@ -1075,8 +1074,8 @@
   1.123    have "gauge ?\<gamma>"
   1.124      using \<gamma>1 \<gamma>2 unfolding gauge_def by auto
   1.125    then show "\<exists>\<gamma>. gauge \<gamma> \<and>
   1.126 -                 (\<forall>p. p tagged_division_of cbox a b \<and> \<gamma> fine p \<longrightarrow>
   1.127 -                      norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - (i + j)) < e)"
   1.128 +                 (\<forall>\<D>. \<D> tagged_division_of cbox a b \<and> \<gamma> fine \<D> \<longrightarrow>
   1.129 +                      norm ((\<Sum>(x, k)\<in>\<D>. content k *\<^sub>R f x) - (i + j)) < e)"
   1.130    proof (rule_tac x="?\<gamma>" in exI, safe)
   1.131      fix p
   1.132      assume p: "p tagged_division_of (cbox a b)" and "?\<gamma> fine p"
   1.133 @@ -1285,7 +1284,7 @@
   1.134      note p1=tagged_division_ofD[OF this(1)] 
   1.135      assume tdiv2: "p2 tagged_division_of (cbox a b) \<inter> {x. c \<le> x \<bullet> k}" and "\<gamma> fine p2"
   1.136      note p2=tagged_division_ofD[OF this(1)] 
   1.137 -    note tagged_division_union_interval[OF tdiv1 tdiv2] 
   1.138 +    note tagged_division_Un_interval[OF tdiv1 tdiv2] 
   1.139      note p12 = tagged_division_ofD[OF this] this
   1.140      { fix a b
   1.141        assume ab: "(a, b) \<in> p1 \<inter> p2"
   1.142 @@ -4140,7 +4139,7 @@
   1.143        using as by (auto simp add: field_simps)
   1.144  
   1.145      have "p \<union> {(c, {t..c})} tagged_division_of {a..c}"
   1.146 -      apply (rule tagged_division_union_interval_real[of _ _ _ 1 "t"])
   1.147 +      apply (rule tagged_division_Un_interval_real[of _ _ _ 1 "t"])
   1.148        using  \<open>t \<le> c\<close> by (auto simp: * ptag tagged_division_of_self_real)
   1.149      moreover
   1.150      have "d1 fine p \<union> {(c, {t..c})}"
   1.151 @@ -4762,9 +4761,9 @@
   1.152  
   1.153  lemma has_integral_le:
   1.154    fixes f :: "'n::euclidean_space \<Rightarrow> real"
   1.155 -  assumes "(f has_integral i) s"
   1.156 -    and "(g has_integral j) s"
   1.157 -    and "\<forall>x\<in>s. f x \<le> g x"
   1.158 +  assumes "(f has_integral i) S"
   1.159 +    and "(g has_integral j) S"
   1.160 +    and "\<And>x. x \<in> S \<Longrightarrow> f x \<le> g x"
   1.161    shows "i \<le> j"
   1.162    using has_integral_component_le[OF _ assms(1-2), of 1]
   1.163    using assms(3)
   1.164 @@ -4772,27 +4771,27 @@
   1.165  
   1.166  lemma integral_le:
   1.167    fixes f :: "'n::euclidean_space \<Rightarrow> real"
   1.168 -  assumes "f integrable_on s"
   1.169 -    and "g integrable_on s"
   1.170 -    and "\<forall>x\<in>s. f x \<le> g x"
   1.171 -  shows "integral s f \<le> integral s g"
   1.172 +  assumes "f integrable_on S"
   1.173 +    and "g integrable_on S"
   1.174 +    and "\<And>x. x \<in> S \<Longrightarrow> f x \<le> g x"
   1.175 +  shows "integral S f \<le> integral S g"
   1.176    by (rule has_integral_le[OF assms(1,2)[unfolded has_integral_integral] assms(3)])
   1.177  
   1.178  lemma has_integral_nonneg:
   1.179    fixes f :: "'n::euclidean_space \<Rightarrow> real"
   1.180 -  assumes "(f has_integral i) s"
   1.181 -    and "\<forall>x\<in>s. 0 \<le> f x"
   1.182 +  assumes "(f has_integral i) S"
   1.183 +    and "\<And>x. x \<in> S \<Longrightarrow> 0 \<le> f x"
   1.184    shows "0 \<le> i"
   1.185 -  using has_integral_component_nonneg[of 1 f i s]
   1.186 +  using has_integral_component_nonneg[of 1 f i S]
   1.187    unfolding o_def
   1.188    using assms
   1.189    by auto
   1.190  
   1.191  lemma integral_nonneg:
   1.192    fixes f :: "'n::euclidean_space \<Rightarrow> real"
   1.193 -  assumes "f integrable_on s"
   1.194 -    and "\<forall>x\<in>s. 0 \<le> f x"
   1.195 -  shows "0 \<le> integral s f"
   1.196 +  assumes "f integrable_on S"
   1.197 +    and "\<And>x. x \<in> S \<Longrightarrow> 0 \<le> f x"
   1.198 +  shows "0 \<le> integral S f"
   1.199    by (rule has_integral_nonneg[OF assms(1)[unfolded has_integral_integral] assms(2)])
   1.200  
   1.201  
   1.202 @@ -5686,9 +5685,9 @@
   1.203  
   1.204  subsection \<open>Henstock's lemma\<close>
   1.205  
   1.206 -lemma henstock_lemma_part1:
   1.207 +lemma Henstock_lemma_part1:
   1.208    fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
   1.209 -  assumes "f integrable_on cbox a b"
   1.210 +  assumes intf: "f integrable_on cbox a b"
   1.211      and "e > 0"
   1.212      and "gauge d"
   1.213      and less_e: "\<And>p. \<lbrakk>p tagged_division_of (cbox a b); d fine p\<rbrakk> \<Longrightarrow>
   1.214 @@ -5711,59 +5710,52 @@
   1.215    have r: "finite r"
   1.216      using q' unfolding r_def by auto
   1.217  
   1.218 -  have "\<forall>i\<in>r. \<exists>p. p tagged_division_of i \<and> d fine p \<and>
   1.219 -    norm (sum (\<lambda>(x,j). content j *\<^sub>R f x) p - integral i f) < k / (real (card r) + 1)"
   1.220 -    apply safe
   1.221 -  proof goal_cases
   1.222 -    case (1 i)
   1.223 -    then have i: "i \<in> q"
   1.224 -      unfolding r_def by auto
   1.225 -    from q'(4)[OF this] guess u v by (elim exE) note uv=this
   1.226 +  have "\<exists>p. p tagged_division_of i \<and> d fine p \<and>
   1.227 +        norm (sum (\<lambda>(x,j). content j *\<^sub>R f x) p - integral i f) < k / (real (card r) + 1)"
   1.228 +    if "i\<in>r" for i
   1.229 +  proof -
   1.230      have *: "k / (real (card r) + 1) > 0" using k by simp
   1.231 -    have "f integrable_on cbox u v"
   1.232 -      apply (rule integrable_subinterval[OF assms(1)])
   1.233 -      using q'(2)[OF i]
   1.234 -      unfolding uv
   1.235 -      apply auto
   1.236 -      done
   1.237 +    have i: "i \<in> q"
   1.238 +      using that unfolding r_def by auto
   1.239 +    then obtain u v where uv: "i = cbox u v"
   1.240 +      using q'(4) by blast
   1.241 +    then have "cbox u v \<subseteq> cbox a b"
   1.242 +      using i q'(2) by auto  
   1.243 +    then have "f integrable_on cbox u v"
   1.244 +      by (rule integrable_subinterval[OF intf])
   1.245      note integrable_integral[OF this, unfolded has_integral[of f]]
   1.246      from this[rule_format,OF *] guess dd..note dd=conjunctD2[OF this,rule_format]
   1.247      note gauge_Int[OF \<open>gauge d\<close> dd(1)]
   1.248      from fine_division_exists[OF this,of u v] guess qq .
   1.249 -    then show ?case
   1.250 +    then show ?thesis
   1.251        apply (rule_tac x=qq in exI)
   1.252        using dd(2)[of qq]
   1.253        unfolding fine_Int uv
   1.254        apply auto
   1.255        done
   1.256    qed
   1.257 -  from bchoice[OF this] guess qq..note qq=this[rule_format]
   1.258 +  then obtain qq where qq: "\<And>i. i \<in> r \<Longrightarrow> qq i tagged_division_of i \<and>
   1.259 +      d fine qq i \<and>
   1.260 +      norm
   1.261 +       ((\<Sum>(x, j) \<in> qq i. content j *\<^sub>R f x) -
   1.262 +        integral i f)
   1.263 +      < k / (real (card r) + 1)"
   1.264 +    by metis
   1.265  
   1.266    let ?p = "p \<union> \<Union>(qq ` r)"
   1.267    have "norm ((\<Sum>(x, k)\<in>?p. content k *\<^sub>R f x) - integral (cbox a b) f) < e"
   1.268    proof (rule less_e)
   1.269      show "d fine ?p"
   1.270        by (metis (mono_tags, hide_lams) qq fine_Un fine_Union imageE p(2))
   1.271 -    note * = tagged_partial_division_of_union_self[OF p(1)]
   1.272 +    note * = tagged_partial_division_of_Union_self[OF p(1)]
   1.273      have "p \<union> \<Union>(qq ` r) tagged_division_of \<Union>(snd ` p) \<union> \<Union>r"
   1.274        using r
   1.275 -    proof (rule tagged_division_union[OF * tagged_division_unions], goal_cases)
   1.276 -      case 1
   1.277 -      then show ?case
   1.278 +    proof (rule tagged_division_Un[OF * tagged_division_Union])
   1.279 +      show "\<And>i. i \<in> r \<Longrightarrow> qq i tagged_division_of i"
   1.280          using qq by auto
   1.281 -    next
   1.282 -      case 2
   1.283 -      then show ?case
   1.284 -        apply rule
   1.285 -        apply rule
   1.286 -        apply rule
   1.287 -        apply(rule q'(5))
   1.288 -        unfolding r_def
   1.289 -        apply auto
   1.290 -        done
   1.291 -    next
   1.292 -      case 3
   1.293 -      then show ?case
   1.294 +      show "\<And>i1 i2. \<lbrakk>i1 \<in> r; i2 \<in> r; i1 \<noteq> i2\<rbrakk> \<Longrightarrow> interior i1 \<inter> interior i2 = {}"
   1.295 +        by (simp add: q'(5) r_def)
   1.296 +      show "interior (UNION p snd) \<inter> interior (\<Union>r) = {}"
   1.297        proof (rule Int_interior_Union_intervals [OF \<open>finite r\<close>])
   1.298          show "open (interior (UNION p snd))"
   1.299            by blast
   1.300 @@ -5780,9 +5772,7 @@
   1.301        qed
   1.302      qed
   1.303      moreover have "\<Union>(snd ` p) \<union> \<Union>r = cbox a b" and "{qq i |i. i \<in> r} = qq ` r"
   1.304 -      unfolding Union_Un_distrib[symmetric] r_def
   1.305 -      using q
   1.306 -      by auto
   1.307 +      using q  unfolding Union_Un_distrib[symmetric] r_def by auto
   1.308      ultimately show "?p tagged_division_of (cbox a b)"
   1.309        by fastforce
   1.310    qed
   1.311 @@ -5915,11 +5905,11 @@
   1.312    finally show "?x \<le> e + k" .
   1.313  qed
   1.314  
   1.315 -lemma henstock_lemma_part2:
   1.316 +lemma Henstock_lemma_part2:
   1.317    fixes f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space"
   1.318    assumes fed: "f integrable_on cbox a b" "e > 0" "gauge d"
   1.319 -    and less_e: "\<And>p. \<lbrakk>p tagged_division_of (cbox a b); d fine p\<rbrakk> \<Longrightarrow>
   1.320 -                     norm (sum (\<lambda>(x,k). content k *\<^sub>R f x) p - integral (cbox a b) f) < e"
   1.321 +    and less_e: "\<And>\<D>. \<lbrakk>\<D> tagged_division_of (cbox a b); d fine \<D>\<rbrakk> \<Longrightarrow>
   1.322 +                     norm (sum (\<lambda>(x,k). content k *\<^sub>R f x) \<D> - integral (cbox a b) f) < e"
   1.323      and tag: "p tagged_partial_division_of (cbox a b)"
   1.324      and "d fine p"
   1.325    shows "sum (\<lambda>(x,k). norm (content k *\<^sub>R f x - integral k f)) p \<le> 2 * real (DIM('n)) * e"
   1.326 @@ -5934,13 +5924,13 @@
   1.327      then have fine: "d fine Q"
   1.328        by (simp add: \<open>d fine p\<close> fine_subset)
   1.329      show "norm (\<Sum>x\<in>Q. content (snd x) *\<^sub>R f (fst x) - integral (snd x) f) \<le> e"
   1.330 -      apply (rule henstock_lemma_part1[OF fed less_e, unfolded split_def])
   1.331 +      apply (rule Henstock_lemma_part1[OF fed less_e, unfolded split_def])
   1.332        using Q tag tagged_partial_division_subset apply (force simp add: fine)+
   1.333        done
   1.334    qed
   1.335  qed
   1.336  
   1.337 -lemma henstock_lemma:
   1.338 +lemma Henstock_lemma:
   1.339    fixes f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space"
   1.340    assumes intf: "f integrable_on cbox a b"
   1.341      and "e > 0"
   1.342 @@ -5951,8 +5941,8 @@
   1.343    have *: "e/(2 * (real DIM('n) + 1)) > 0" using \<open>e > 0\<close> by simp
   1.344    with integrable_integral[OF intf, unfolded has_integral]
   1.345    obtain \<gamma> where "gauge \<gamma>"
   1.346 -    and \<gamma>: "\<And>p. \<lbrakk>p tagged_division_of cbox a b; \<gamma> fine p\<rbrakk> \<Longrightarrow>
   1.347 -         norm ((\<Sum>(x,K)\<in>p. content K *\<^sub>R f x) - integral (cbox a b) f)
   1.348 +    and \<gamma>: "\<And>\<D>. \<lbrakk>\<D> tagged_division_of cbox a b; \<gamma> fine \<D>\<rbrakk> \<Longrightarrow>
   1.349 +         norm ((\<Sum>(x,K)\<in>\<D>. content K *\<^sub>R f x) - integral (cbox a b) f)
   1.350           < e/(2 * (real DIM('n) + 1))"
   1.351      by metis
   1.352    show thesis
   1.353 @@ -5961,7 +5951,7 @@
   1.354      assume p: "p tagged_partial_division_of cbox a b" "\<gamma> fine p"
   1.355      have "(\<Sum>(x,K)\<in>p. norm (content K *\<^sub>R f x - integral K f)) 
   1.356            \<le> 2 * real DIM('n) * (e/(2 * (real DIM('n) + 1)))"
   1.357 -      using henstock_lemma_part2[OF intf * \<open>gauge \<gamma>\<close> \<gamma> p] by metis
   1.358 +      using Henstock_lemma_part2[OF intf * \<open>gauge \<gamma>\<close> \<gamma> p] by metis
   1.359      also have "... < e"
   1.360        using \<open>e > 0\<close> by (auto simp add: field_simps)
   1.361      finally
   1.362 @@ -5972,14 +5962,12 @@
   1.363  
   1.364  subsection \<open>Monotone convergence (bounded interval first)\<close>
   1.365  
   1.366 -(* TODO: is this lemma necessary? *)
   1.367  lemma bounded_increasing_convergent:
   1.368    fixes f :: "nat \<Rightarrow> real"
   1.369    shows "\<lbrakk>bounded (range f); \<And>n. f n \<le> f (Suc n)\<rbrakk> \<Longrightarrow> \<exists>l. f \<longlonglongrightarrow> l"
   1.370    using Bseq_mono_convergent[of f] incseq_Suc_iff[of f]
   1.371    by (auto simp: image_def Bseq_eq_bounded convergent_def incseq_def)
   1.372  
   1.373 -(*FIXME: why so much " \<bullet> 1"? *)
   1.374  lemma monotone_convergence_interval:
   1.375    fixes f :: "nat \<Rightarrow> 'n::euclidean_space \<Rightarrow> real"
   1.376    assumes intf: "\<And>k. (f k) integrable_on cbox a b"
   1.377 @@ -5988,57 +5976,53 @@
   1.378      and bou: "bounded (range (\<lambda>k. integral (cbox a b) (f k)))"
   1.379    shows "g integrable_on cbox a b \<and> ((\<lambda>k. integral (cbox a b) (f k)) \<longlongrightarrow> integral (cbox a b) g) sequentially"
   1.380  proof (cases "content (cbox a b) = 0")
   1.381 -  case True
   1.382 -  then show ?thesis
   1.383 +  case True then show ?thesis
   1.384      by auto
   1.385  next
   1.386    case False
   1.387 -  have fg1: "(f k x) \<bullet> 1 \<le> (g x) \<bullet> 1" if x: "x \<in> cbox a b" for x k
   1.388 +  have fg1: "(f k x) \<le> (g x)" if x: "x \<in> cbox a b" for x k
   1.389    proof -
   1.390 -    have "\<forall>\<^sub>F xa in sequentially. f k x \<bullet> 1 \<le> f xa x \<bullet> 1"
   1.391 -      unfolding eventually_sequentially
   1.392 -      apply (rule_tac x=k in exI)
   1.393 +    have "\<forall>\<^sub>F j in sequentially. f k x \<le> f j x"
   1.394 +      apply (rule eventually_sequentiallyI [of k])
   1.395        using le x apply (force intro: transitive_stepwise_le)
   1.396        done
   1.397 -    with Lim_component_ge [OF fg] x
   1.398 -    show "f k x \<bullet> 1 \<le> g x \<bullet> 1"
   1.399 -      using trivial_limit_sequentially by blast
   1.400 +    then show "f k x \<le> g x"
   1.401 +      using tendsto_lowerbound [OF fg] x trivial_limit_sequentially by blast
   1.402    qed
   1.403    have int_inc: "\<And>n. integral (cbox a b) (f n) \<le> integral (cbox a b) (f (Suc n))"
   1.404 -    by (metis integral_le assms(1-2))
   1.405 +    by (metis integral_le intf le)
   1.406    then obtain i where i: "(\<lambda>k. integral (cbox a b) (f k)) \<longlonglongrightarrow> i"
   1.407      using bounded_increasing_convergent bou by blast
   1.408 -  have "\<And>k. \<forall>\<^sub>F x in sequentially. integral (cbox a b) (f k) \<le> integral (cbox a b) (f x) \<bullet> 1"
   1.409 +  have "\<And>k. \<forall>\<^sub>F x in sequentially. integral (cbox a b) (f k) \<le> integral (cbox a b) (f x)"
   1.410      unfolding eventually_sequentially
   1.411      by (force intro: transitive_stepwise_le int_inc)
   1.412 -  then have i': "\<And>k. (integral(cbox a b) (f k)) \<le> i\<bullet>1"
   1.413 -    using Lim_component_ge [OF i] trivial_limit_sequentially by blast
   1.414 +  then have i': "\<And>k. (integral(cbox a b) (f k)) \<le> i"
   1.415 +    using tendsto_le [OF trivial_limit_sequentially i] by blast
   1.416    have "(g has_integral i) (cbox a b)"
   1.417      unfolding has_integral real_norm_def
   1.418    proof clarify
   1.419      fix e::real
   1.420      assume e: "e > 0"
   1.421 -    have "\<And>k. (\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
   1.422 -      abs ((\<Sum>(x, ka)\<in>p. content ka *\<^sub>R f k x) - integral (cbox a b) (f k)) < e/2 ^ (k + 2)))"
   1.423 +    have "\<And>k. (\<exists>\<gamma>. gauge \<gamma> \<and> (\<forall>\<D>. \<D> tagged_division_of (cbox a b) \<and> \<gamma> fine \<D> \<longrightarrow>
   1.424 +      abs ((\<Sum>(x,K)\<in>\<D>. content K *\<^sub>R f k x) - integral (cbox a b) (f k)) < e/2 ^ (k + 2)))"
   1.425        using intf e by (auto simp: has_integral_integral has_integral)
   1.426 -    then obtain c where c:
   1.427 -          "\<And>x. gauge (c x)"
   1.428 -          "\<And>x p. \<lbrakk>p tagged_division_of cbox a b; c x fine p\<rbrakk> \<Longrightarrow>
   1.429 -              abs ((\<Sum>(u, ka)\<in>p. content ka *\<^sub>R f x u) - integral (cbox a b) (f x))
   1.430 +    then obtain c where c: "\<And>x. gauge (c x)"
   1.431 +          "\<And>x \<D>. \<lbrakk>\<D> tagged_division_of cbox a b; c x fine \<D>\<rbrakk> \<Longrightarrow>
   1.432 +              abs ((\<Sum>(u,K)\<in>\<D>. content K *\<^sub>R f x u) - integral (cbox a b) (f x))
   1.433                < e/2 ^ (x + 2)"
   1.434        by metis
   1.435  
   1.436 -    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"
   1.437 +    have "\<exists>r. \<forall>k\<ge>r. 0 \<le> i - (integral (cbox a b) (f k)) \<and> i - (integral (cbox a b) (f k)) < e/4"
   1.438      proof -
   1.439        have "e/4 > 0"
   1.440          using e by auto
   1.441        show ?thesis
   1.442          using LIMSEQ_D [OF i \<open>e/4 > 0\<close>] i' by auto
   1.443      qed
   1.444 -    then obtain r where r: "\<And>k. r \<le> k \<Longrightarrow> 0 \<le> i \<bullet> 1 - integral (cbox a b) (f k)"
   1.445 -                       "\<And>k. r \<le> k \<Longrightarrow> i \<bullet> 1 - integral (cbox a b) (f k) < e/4" 
   1.446 +    then obtain r where r: "\<And>k. r \<le> k \<Longrightarrow> 0 \<le> i - integral (cbox a b) (f k)"
   1.447 +                       "\<And>k. r \<le> k \<Longrightarrow> i - integral (cbox a b) (f k) < e/4" 
   1.448        by metis
   1.449 -    have "\<exists>n\<ge>r. \<forall>k\<ge>n. 0 \<le> (g x)\<bullet>1 - (f k x)\<bullet>1 \<and> (g x)\<bullet>1 - (f k x)\<bullet>1 < e/(4 * content(cbox a b))"
   1.450 +    have "\<exists>n\<ge>r. \<forall>k\<ge>n. 0 \<le> (g x) - (f k x) \<and> (g x) - (f k x) < e/(4 * content(cbox a b))"
   1.451        if "x \<in> cbox a b" for x
   1.452      proof -
   1.453        have "e/(4 * content (cbox a b)) > 0"
   1.454 @@ -6048,8 +6032,8 @@
   1.455          by metis
   1.456        then show "\<exists>n\<ge>r.
   1.457              \<forall>k\<ge>n.
   1.458 -               0 \<le> g x \<bullet> 1 - f k x \<bullet> 1 \<and>
   1.459 -               g x \<bullet> 1 - f k x \<bullet> 1
   1.460 +               0 \<le> g x - f k x \<and>
   1.461 +               g x - f k x
   1.462                 < e/(4 * content (cbox a b))"
   1.463          apply (rule_tac x="N + r" in exI)
   1.464          using fg1[OF that] apply (auto simp add: field_simps)
   1.465 @@ -6057,127 +6041,119 @@
   1.466      qed
   1.467      then obtain m where r_le_m: "\<And>x. x \<in> cbox a b \<Longrightarrow> r \<le> m x"
   1.468         and m: "\<And>x k. \<lbrakk>x \<in> cbox a b; m x \<le> k\<rbrakk>
   1.469 -                     \<Longrightarrow> 0 \<le> g x \<bullet> 1 - f k x \<bullet> 1 \<and> g x \<bullet> 1 - f k x \<bullet> 1 < e/(4 * content (cbox a b))"
   1.470 +                     \<Longrightarrow> 0 \<le> g x - f k x \<and> g x - f k x < e/(4 * content (cbox a b))"
   1.471        by metis
   1.472      define d where "d x = c (m x) x" for x
   1.473      show "\<exists>\<gamma>. gauge \<gamma> \<and>
   1.474 -             (\<forall>p. p tagged_division_of cbox a b \<and>
   1.475 -                  \<gamma> fine p \<longrightarrow> abs ((\<Sum>(x,K)\<in>p. content K *\<^sub>R g x) - i) < e)"
   1.476 +             (\<forall>\<D>. \<D> tagged_division_of cbox a b \<and>
   1.477 +                  \<gamma> fine \<D> \<longrightarrow> abs ((\<Sum>(x,K)\<in>\<D>. content K *\<^sub>R g x) - i) < e)"
   1.478      proof (rule exI, safe)
   1.479        show "gauge d"
   1.480          using c(1) unfolding gauge_def d_def by auto
   1.481      next
   1.482 -      fix p
   1.483 -      assume p: "p tagged_division_of (cbox a b)" "d fine p"
   1.484 -      note p'=tagged_division_ofD[OF p(1)]
   1.485 -      obtain s where s: "\<And>x. x \<in> p \<Longrightarrow> m (fst x) \<le> s"
   1.486 +      fix \<D>
   1.487 +      assume ptag: "\<D> tagged_division_of (cbox a b)" and "d fine \<D>"
   1.488 +      note p'=tagged_division_ofD[OF ptag]
   1.489 +      obtain s where s: "\<And>x. x \<in> \<D> \<Longrightarrow> m (fst x) \<le> s"
   1.490          by (metis finite_imageI finite_nat_set_iff_bounded_le p'(1) rev_image_eqI)
   1.491        have *: "\<bar>a - d\<bar> < e" if "\<bar>a - b\<bar> \<le> e/4" "\<bar>b - c\<bar> < e/2" "\<bar>c - d\<bar> < e/4" for a b c d
   1.492          using that norm_triangle_lt[of "a - b" "b - c" "3* e/4"]
   1.493            norm_triangle_lt[of "a - b + (b - c)" "c - d" e]
   1.494          by (auto simp add: algebra_simps)
   1.495 -      show "abs ((\<Sum>(x, k)\<in>p. content k *\<^sub>R g x) - i) < e"
   1.496 +      show "\<bar>(\<Sum>(x, k)\<in>\<D>. content k *\<^sub>R g x) - i\<bar> < e"
   1.497        proof (rule *)
   1.498 -        show "\<bar>(\<Sum>(x, k)\<in>p. content k *\<^sub>R g x) - (\<Sum>(x, K)\<in>p. content K *\<^sub>R f (m x) x)\<bar>
   1.499 -              \<le> e/4"
   1.500 -          apply (rule order_trans[of _ "\<Sum>(x, k)\<in>p. content k * (e/(4 * content (cbox a b)))"])
   1.501 -          unfolding sum_subtractf[symmetric]
   1.502 -          apply (rule order_trans)
   1.503 -          apply (rule sum_abs)
   1.504 -          apply (rule sum_mono)
   1.505 -          unfolding split_paired_all split_conv
   1.506 -          unfolding split_def sum_distrib_right[symmetric] scaleR_diff_right[symmetric]
   1.507 -          unfolding additive_content_tagged_division[OF p(1), unfolded split_def]
   1.508 -        proof -
   1.509 +        have "\<bar>(\<Sum>(x,K)\<in>\<D>. content K *\<^sub>R g x) - (\<Sum>(x,K)\<in>\<D>. content K *\<^sub>R f (m x) x)\<bar> 
   1.510 +              \<le> (\<Sum>i\<in>\<D>. \<bar>(case i of (x, K) \<Rightarrow> content K *\<^sub>R g x) - (case i of (x, K) \<Rightarrow> content K *\<^sub>R f (m x) x)\<bar>)"
   1.511 +          by (metis (mono_tags) sum_subtractf sum_abs) 
   1.512 +        also have "... \<le> (\<Sum>(x, k)\<in>\<D>. content k * (e/(4 * content (cbox a b))))"
   1.513 +        proof (rule sum_mono, simp add: split_paired_all)
   1.514            fix x K
   1.515 -          assume xk: "(x, K) \<in> p"
   1.516 -          then have x: "x \<in> cbox a b"
   1.517 -            using p'(2-3)[OF xk] by auto
   1.518 -          with p'(4)[OF xk] obtain u v where "K = cbox u v" by metis
   1.519 -          then show "abs (content K *\<^sub>R (g x - f (m x) x)) \<le> content K * (e/(4 * content (cbox a b)))"
   1.520 -            unfolding abs_scaleR using m[OF x]
   1.521 -            by (metis real_inner_1_right real_scaleR_def abs_of_nonneg inner_real_def less_eq_real_def measure_nonneg mult_left_mono order_refl)
   1.522 -        qed (insert False, auto)
   1.523 +          assume xk: "(x,K) \<in> \<D>"
   1.524 +          with ptag have x: "x \<in> cbox a b"
   1.525 +            by blast
   1.526 +          then have "abs (content K * (g x - f (m x) x)) \<le> content K * (e/(4 * content (cbox a b)))"
   1.527 +            by (metis m[OF x] mult_nonneg_nonneg abs_of_nonneg less_eq_real_def measure_nonneg mult_left_mono order_refl)
   1.528 +          then show "\<bar>content K * g x - content K * f (m x) x\<bar> \<le> content K * e / (4 * content (cbox a b))"
   1.529 +            by (simp add: algebra_simps)
   1.530 +        qed
   1.531 +        also have "... = (e / (4 * content (cbox a b))) * (\<Sum>(x, k)\<in>\<D>. content k)"
   1.532 +          by (simp add: sum_distrib_left sum_divide_distrib split_def mult.commute)
   1.533 +        also have "... \<le> e/4"
   1.534 +          by (metis False additive_content_tagged_division [OF ptag] nonzero_mult_divide_mult_cancel_right order_refl times_divide_eq_left)
   1.535 +        finally show "\<bar>(\<Sum>(x,K)\<in>\<D>. content K *\<^sub>R g x) - (\<Sum>(x,K)\<in>\<D>. content K *\<^sub>R f (m x) x)\<bar> \<le> e/4" .
   1.536  
   1.537        next
   1.538 -        have "norm ((\<Sum>(x, K)\<in>p. content K *\<^sub>R f (m x) x) - (\<Sum>(x, k)\<in>p. integral k (f (m x))))
   1.539 -              \<le> norm
   1.540 -                  (\<Sum>j = 0..s.
   1.541 -                      \<Sum>(x, K)\<in>{xk \<in> p. m (fst xk) = j}.
   1.542 -                        content K *\<^sub>R f (m x) x - integral K (f (m x)))"
   1.543 +        have "norm ((\<Sum>(x,K)\<in>\<D>. content K *\<^sub>R f (m x) x) - (\<Sum>(x,K)\<in>\<D>. integral K (f (m x))))
   1.544 +              \<le> norm (\<Sum>j = 0..s. \<Sum>(x,K)\<in>{xk \<in> \<D>. m (fst xk) = j}. content K *\<^sub>R f (m x) x - integral K (f (m x)))"
   1.545            apply (subst sum_group)
   1.546            using s by (auto simp: sum_subtractf split_def p'(1))
   1.547          also have "\<dots> < e/2"
   1.548          proof -
   1.549 -          have "norm (\<Sum>j = 0..s. \<Sum>(x, k)\<in>{xk \<in> p. m (fst xk) = j}. content k *\<^sub>R f (m x) x - integral k (f (m x)))
   1.550 +          have "norm (\<Sum>j = 0..s. \<Sum>(x, k)\<in>{xk \<in> \<D>. m (fst xk) = j}. content k *\<^sub>R f (m x) x - integral k (f (m x)))
   1.551                  \<le> (\<Sum>i = 0..s. e/2 ^ (i + 2))"
   1.552            proof (rule sum_norm_le)
   1.553              fix t
   1.554              assume "t \<in> {0..s}"
   1.555 -            have "norm (\<Sum>(x,k)\<in>{xk \<in> p. m (fst xk) = t}. content k *\<^sub>R f (m x) x - integral k (f (m x))) =
   1.556 -                  norm (\<Sum>(x,k)\<in>{xk \<in> p. m (fst xk) = t}. content k *\<^sub>R f t x - integral k (f t))"
   1.557 +            have "norm (\<Sum>(x,k)\<in>{xk \<in> \<D>. m (fst xk) = t}. content k *\<^sub>R f (m x) x - integral k (f (m x))) =
   1.558 +                  norm (\<Sum>(x,k)\<in>{xk \<in> \<D>. m (fst xk) = t}. content k *\<^sub>R f t x - integral k (f t))"
   1.559                by (force intro!: sum.cong arg_cong[where f=norm])
   1.560              also have "... \<le> e/2 ^ (t + 2)"
   1.561 -            proof (rule henstock_lemma_part1 [OF intf])
   1.562 -              show "{xk \<in> p. m (fst xk) = t} tagged_partial_division_of cbox a b"
   1.563 -                apply (rule tagged_partial_division_subset[of p])
   1.564 -                using p by (auto simp: tagged_division_of_def)
   1.565 -              show "c t fine {xk \<in> p. m (fst xk) = t}"
   1.566 -                using p(2) by (auto simp: fine_def d_def)
   1.567 +            proof (rule Henstock_lemma_part1 [OF intf])
   1.568 +              show "{xk \<in> \<D>. m (fst xk) = t} tagged_partial_division_of cbox a b"
   1.569 +                apply (rule tagged_partial_division_subset[of \<D>])
   1.570 +                using ptag by (auto simp: tagged_division_of_def)
   1.571 +              show "c t fine {xk \<in> \<D>. m (fst xk) = t}"
   1.572 +                using \<open>d fine \<D>\<close> by (auto simp: fine_def d_def)
   1.573              qed (use c e in auto)
   1.574 -            finally show "norm (\<Sum>(x,K)\<in>{xk \<in> p. m (fst xk) = t}. content K *\<^sub>R f (m x) x -
   1.575 +            finally show "norm (\<Sum>(x,K)\<in>{xk \<in> \<D>. m (fst xk) = t}. content K *\<^sub>R f (m x) x -
   1.576                                  integral K (f (m x))) \<le> e/2 ^ (t + 2)" .
   1.577            qed
   1.578            also have "... = (e/2/2) * (\<Sum>i = 0..s. (1/2) ^ i)"
   1.579              by (simp add: sum_distrib_left field_simps)
   1.580            also have "\<dots> < e/2"
   1.581              by (simp add: sum_gp mult_strict_left_mono[OF _ e])
   1.582 -          finally show "norm (\<Sum>j = 0..s. \<Sum>(x, k)\<in>{xk \<in> p.
   1.583 +          finally show "norm (\<Sum>j = 0..s. \<Sum>(x, k)\<in>{xk \<in> \<D>.
   1.584              m (fst xk) = j}. content k *\<^sub>R f (m x) x - integral k (f (m x))) < e/2" .
   1.585          qed 
   1.586 -        finally show "\<bar>(\<Sum>(x,K)\<in>p. content K *\<^sub>R f (m x) x) - (\<Sum>(x,K)\<in>p. integral K (f (m x)))\<bar> < e/2"
   1.587 +        finally show "\<bar>(\<Sum>(x,K)\<in>\<D>. content K *\<^sub>R f (m x) x) - (\<Sum>(x,K)\<in>\<D>. integral K (f (m x)))\<bar> < e/2"
   1.588            by simp
   1.589        next
   1.590 -        note comb = integral_combine_tagged_division_topdown[OF assms(1)[rule_format] p(1)]
   1.591 -        have *: "\<And>sr sx ss ks kr. \<lbrakk>kr = sr; ks = ss;
   1.592 -          ks \<le> i; sr \<le> sx; sx \<le> ss; 0 \<le> i\<bullet>1 - kr\<bullet>1; i\<bullet>1 - kr\<bullet>1 < e/4\<rbrakk> \<Longrightarrow> \<bar>sx - i\<bar> < e/4"
   1.593 -          by auto
   1.594 -        show "\<bar>(\<Sum>(x, k)\<in>p. integral k (f (m x))) - i\<bar> < e/4"
   1.595 -          unfolding real_norm_def
   1.596 -          apply (rule *)
   1.597 -          apply (rule comb[of r])
   1.598 -          apply (rule comb[of s])
   1.599 -          apply (rule i'[unfolded real_inner_1_right])
   1.600 -          apply (rule_tac[1-2] sum_mono)
   1.601 -          unfolding split_paired_all split_conv
   1.602 -          apply (rule_tac[1-2] integral_le[OF ])
   1.603 -        proof safe
   1.604 -          show "0 \<le> i\<bullet>1 - (integral (cbox a b) (f r))\<bullet>1" "i\<bullet>1 - (integral (cbox a b) (f r))\<bullet>1 < e/4"
   1.605 -            using r by auto
   1.606 +        have comb: "integral (cbox a b) (f y) = (\<Sum>(x, k)\<in>\<D>. integral k (f y))" for y
   1.607 +          using integral_combine_tagged_division_topdown[OF intf ptag] by metis
   1.608 +        have f_le: "\<And>y m n. \<lbrakk>y \<in> cbox a b; n\<ge>m\<rbrakk> \<Longrightarrow> f m y \<le> f n y"
   1.609 +          using le by (auto intro: transitive_stepwise_le)        
   1.610 +        have "(\<Sum>(x, k)\<in>\<D>. integral k (f r)) \<le> (\<Sum>(x, K)\<in>\<D>. integral K (f (m x)))"
   1.611 +        proof (rule sum_mono, simp add: split_paired_all)
   1.612            fix x K
   1.613 -          assume xk: "(x, K) \<in> p"
   1.614 -          from p'(4)[OF this] guess u v by (elim exE) note uv=this
   1.615 -          show "f r integrable_on K"
   1.616 -            and "f s integrable_on K"
   1.617 -            and "f (m x) integrable_on K"
   1.618 -            and "f (m x) integrable_on K"
   1.619 -            unfolding uv
   1.620 -            apply (rule_tac[!] integrable_on_subcbox[OF assms(1)[rule_format]])
   1.621 -            using p'(3)[OF xk]
   1.622 -            unfolding uv
   1.623 -            apply auto
   1.624 -            done
   1.625 -          fix y
   1.626 -          assume "y \<in> K"
   1.627 -          then have "y \<in> cbox a b"
   1.628 -            using p'(3)[OF xk] by auto
   1.629 -          then have *: "\<And>m n. n\<ge>m \<Longrightarrow> f m y \<le> f n y"
   1.630 -            using assms(2) by (auto intro: transitive_stepwise_le)
   1.631 -          show "f r y \<le> f (m x) y" "f (m x) y \<le> f s y"
   1.632 -            using s[rule_format,OF xk] r_le_m[of x] p'(2-3)[OF xk]
   1.633 -            apply (auto intro!: *)
   1.634 -            done
   1.635 +          assume xK: "(x, K) \<in> \<D>"
   1.636 +          show "integral K (f r) \<le> integral K (f (m x))"
   1.637 +          proof (rule integral_le)
   1.638 +            show "f r integrable_on K"
   1.639 +              by (metis integrable_on_subcbox intf p'(3) p'(4) xK)
   1.640 +            show "f (m x) integrable_on K"
   1.641 +              by (metis elementary_interval integrable_on_subdivision intf p'(3) p'(4) xK)
   1.642 +            show "f r y \<le> f (m x) y" if "y \<in> K" for y
   1.643 +              using that r_le_m[of x] p'(2-3)[OF xK] f_le by auto
   1.644 +          qed
   1.645          qed
   1.646 +        moreover have "(\<Sum>(x, K)\<in>\<D>. integral K (f (m x))) \<le> (\<Sum>(x, k)\<in>\<D>. integral k (f s))"
   1.647 +        proof (rule sum_mono, simp add: split_paired_all)
   1.648 +          fix x K
   1.649 +          assume xK: "(x, K) \<in> \<D>"
   1.650 +          show "integral K (f (m x)) \<le> integral K (f s)"
   1.651 +          proof (rule integral_le)
   1.652 +            show "f (m x) integrable_on K"
   1.653 +              by (metis elementary_interval integrable_on_subdivision intf p'(3) p'(4) xK)
   1.654 +            show "f s integrable_on K"
   1.655 +              by (metis integrable_on_subcbox intf p'(3) p'(4) xK)
   1.656 +            show "f (m x) y \<le> f s y" if "y \<in> K" for y
   1.657 +              using that s xK f_le p'(3) by fastforce
   1.658 +          qed
   1.659 +        qed
   1.660 +        moreover have "0 \<le> i - integral (cbox a b) (f r)" "i - integral (cbox a b) (f r) < e / 4"
   1.661 +          using r by auto
   1.662 +        ultimately show "\<bar>(\<Sum>(x,K)\<in>\<D>. integral K (f (m x))) - i\<bar> < e/4"
   1.663 +          using comb i'[of s] by auto
   1.664        qed
   1.665      qed
   1.666    qed 
   1.667 @@ -6201,23 +6177,19 @@
   1.668      and bou: "bounded (range(\<lambda>k. integral S (f k)))"
   1.669      for f :: "nat \<Rightarrow> 'n::euclidean_space \<Rightarrow> real" and g S
   1.670    proof -
   1.671 -    have fg: "(f k x)\<bullet>1 \<le> (g x)\<bullet>1" if "x \<in> S" for x k
   1.672 -      apply (rule Lim_component_ge [OF lim [OF that] trivial_limit_sequentially])
   1.673 -      unfolding eventually_sequentially
   1.674 -      apply (rule_tac x=k in exI)
   1.675 -      using le  by (force intro: transitive_stepwise_le that) 
   1.676 -
   1.677 +    have fg: "(f k x) \<le> (g x)" if "x \<in> S" for x k
   1.678 +      apply (rule tendsto_lowerbound [OF lim [OF that]])
   1.679 +      apply (rule eventually_sequentiallyI [of k])
   1.680 +      using le  by (force intro: transitive_stepwise_le that)+
   1.681      obtain i where i: "(\<lambda>k. integral S (f k)) \<longlonglongrightarrow> i"
   1.682        using bounded_increasing_convergent [OF bou] le int_f integral_le by blast
   1.683 -    have i': "(integral S (f k))\<bullet>1 \<le> i\<bullet>1" for k
   1.684 +    have i': "(integral S (f k)) \<le> i" for k
   1.685      proof -
   1.686 -      have *: "\<And>k. \<forall>x\<in>S. \<forall>n\<ge>k. f k x \<le> f n x"
   1.687 +      have "\<And>k. \<forall>x\<in>S. \<forall>n\<ge>k. f k x \<le> f n x"
   1.688          using le  by (force intro: transitive_stepwise_le)
   1.689 -      show ?thesis
   1.690 -        apply (rule Lim_component_ge [OF i trivial_limit_sequentially])
   1.691 -        unfolding eventually_sequentially
   1.692 -        apply (rule_tac x=k in exI)
   1.693 -        using * by (simp add: int_f integral_le)
   1.694 +      then show ?thesis
   1.695 +        using tendsto_lowerbound [OF i eventually_sequentiallyI trivial_limit_sequentially]
   1.696 +        by (meson int_f integral_le)
   1.697      qed
   1.698  
   1.699      let ?f = "(\<lambda>k x. if x \<in> S then f k x else 0)"
   1.700 @@ -6277,7 +6249,7 @@
   1.701            show "integral (cbox a b) (?f N) \<le> integral (cbox a b) (?f (M + N))"
   1.702            proof (intro ballI integral_le[OF int int])
   1.703              fix x assume "x \<in> cbox a b"
   1.704 -            have "(f m x)\<bullet>1 \<le> (f n x)\<bullet>1" if "x \<in> S" "n \<ge> m" for m n
   1.705 +            have "(f m x) \<le> (f n x)" if "x \<in> S" "n \<ge> m" for m n
   1.706                apply (rule transitive_stepwise_le [OF \<open>n \<ge> m\<close> order_refl])
   1.707                using dual_order.trans apply blast
   1.708                by (simp add: le \<open>x \<in> S\<close>)
   1.709 @@ -6416,41 +6388,41 @@
   1.710        by auto
   1.711      with integrable_integral[OF f,unfolded has_integral[of f]]
   1.712      obtain \<gamma> where \<gamma>: "gauge \<gamma>"
   1.713 -              "\<And>p. p tagged_division_of cbox a b \<and> \<gamma> fine p 
   1.714 -           \<Longrightarrow> norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - integral (cbox a b) f) < e/2"
   1.715 +              "\<And>\<D>. \<D> tagged_division_of cbox a b \<and> \<gamma> fine \<D> 
   1.716 +           \<Longrightarrow> norm ((\<Sum>(x, k)\<in>\<D>. content k *\<^sub>R f x) - integral (cbox a b) f) < e/2"
   1.717        by meson 
   1.718      moreover
   1.719      from integrable_integral[OF g,unfolded has_integral[of g]] e
   1.720      obtain \<delta> where \<delta>: "gauge \<delta>"
   1.721 -              "\<And>p. p tagged_division_of cbox a b \<and> \<delta> fine p 
   1.722 -           \<Longrightarrow> norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R g x) - integral (cbox a b) g) < e/2"
   1.723 +              "\<And>\<D>. \<D> tagged_division_of cbox a b \<and> \<delta> fine \<D> 
   1.724 +           \<Longrightarrow> norm ((\<Sum>(x, k)\<in>\<D>. content k *\<^sub>R g x) - integral (cbox a b) g) < e/2"
   1.725        by meson
   1.726      ultimately have "gauge (\<lambda>x. \<gamma> x \<inter> \<delta> x)"
   1.727        using gauge_Int by blast
   1.728 -    with fine_division_exists obtain p 
   1.729 -      where p: "p tagged_division_of cbox a b" "(\<lambda>x. \<gamma> x \<inter> \<delta> x) fine p" 
   1.730 +    with fine_division_exists obtain \<D> 
   1.731 +      where p: "\<D> tagged_division_of cbox a b" "(\<lambda>x. \<gamma> x \<inter> \<delta> x) fine \<D>" 
   1.732        by metis
   1.733 -    have "\<gamma> fine p" "\<delta> fine p"
   1.734 +    have "\<gamma> fine \<D>" "\<delta> fine \<D>"
   1.735        using fine_Int p(2) by blast+
   1.736      show "norm (integral (cbox a b) f) < integral (cbox a b) g + e"
   1.737      proof (rule norm)
   1.738 -      have "norm (content K *\<^sub>R f x) \<le> content K *\<^sub>R g x" if  "(x, K) \<in> p" for x K
   1.739 +      have "norm (content K *\<^sub>R f x) \<le> content K *\<^sub>R g x" if  "(x, K) \<in> \<D>" for x K
   1.740        proof-
   1.741          have K: "x \<in> K" "K \<subseteq> cbox a b"
   1.742 -          using \<open>(x, K) \<in> p\<close> p(1) by blast+
   1.743 +          using \<open>(x, K) \<in> \<D>\<close> p(1) by blast+
   1.744          obtain u v where  "K = cbox u v"
   1.745 -          using \<open>(x, K) \<in> p\<close> p(1) by blast
   1.746 +          using \<open>(x, K) \<in> \<D>\<close> p(1) by blast
   1.747          moreover have "content K * norm (f x) \<le> content K * g x"
   1.748            by (metis K subsetD dual_order.antisym measure_nonneg mult_zero_left nle not_le real_mult_le_cancel_iff2)
   1.749          then show ?thesis
   1.750            by simp
   1.751        qed
   1.752 -      then show "norm (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) \<le> (\<Sum>(x, k)\<in>p. content k *\<^sub>R g x)"
   1.753 +      then show "norm (\<Sum>(x, k)\<in>\<D>. content k *\<^sub>R f x) \<le> (\<Sum>(x, k)\<in>\<D>. content k *\<^sub>R g x)"
   1.754          by (simp add: sum_norm_le split_def)
   1.755 -      show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - integral (cbox a b) f) < e/2"
   1.756 -        using \<open>\<gamma> fine p\<close> \<gamma> p(1) by simp
   1.757 -      show "\<bar>(\<Sum>(x, k)\<in>p. content k *\<^sub>R g x) - integral (cbox a b) g\<bar> < e/2"
   1.758 -        using \<open>\<delta> fine p\<close> \<delta> p(1) by simp
   1.759 +      show "norm ((\<Sum>(x, k)\<in>\<D>. content k *\<^sub>R f x) - integral (cbox a b) f) < e/2"
   1.760 +        using \<open>\<gamma> fine \<D>\<close> \<gamma> p(1) by simp
   1.761 +      show "\<bar>(\<Sum>(x, k)\<in>\<D>. content k *\<^sub>R g x) - integral (cbox a b) g\<bar> < e/2"
   1.762 +        using \<open>\<delta> fine \<D>\<close> \<delta> p(1) by simp
   1.763      qed
   1.764    qed
   1.765    show ?thesis
   1.766 @@ -7184,13 +7156,13 @@
   1.767                \<le> e * content (cbox (u, w) (v, z)) / content ?CBOX"
   1.768          using that by (simp add: e'_def)
   1.769      } note op_acbd = this
   1.770 -    { fix k::real and p and u::'a and v w and z::'b and t1 t2 l
   1.771 +    { fix k::real and \<D> and u::'a and v w and z::'b and t1 t2 l
   1.772        assume k: "0 < k"
   1.773           and nf: "\<And>x y u v.
   1.774                    \<lbrakk>x \<in> cbox a b; y \<in> cbox c d; u \<in> cbox a b; v\<in>cbox c d; norm (u-x, v-y) < k\<rbrakk>
   1.775                    \<Longrightarrow> norm (f(u,v) - f(x,y)) < e/(2 * (content ?CBOX))"
   1.776 -         and p_acbd: "p tagged_division_of cbox (a,c) (b,d)"
   1.777 -         and fine: "(\<lambda>x. ball x k) fine p"  "((t1,t2), l) \<in> p"
   1.778 +         and p_acbd: "\<D> tagged_division_of cbox (a,c) (b,d)"
   1.779 +         and fine: "(\<lambda>x. ball x k) fine \<D>"  "((t1,t2), l) \<in> \<D>"
   1.780           and uwvz_sub: "cbox (u,w) (v,z) \<subseteq> l" "cbox (u,w) (v,z) \<subseteq> cbox (a,c) (b,d)"
   1.781        have t: "t1 \<in> cbox a b" "t2 \<in> cbox c d"
   1.782          by (meson fine p_acbd cbox_Pair_iff tag_in_interval)+