author wenzelm Wed Sep 04 13:13:14 2013 +0200 (2013-09-04 ago) changeset 53399 43b3b3fa6967 parent 53398 f8b150e8778b child 53400 673eb869e6ee
tuned proofs;
```     1.1 --- a/src/HOL/Multivariate_Analysis/Integration.thy	Wed Sep 04 12:20:00 2013 +0200
1.2 +++ b/src/HOL/Multivariate_Analysis/Integration.thy	Wed Sep 04 13:13:14 2013 +0200
1.3 @@ -1,6 +1,8 @@
1.4 +(*  Author:     John Harrison
1.5 +    Author:     Robert Himmelmann, TU Muenchen (Translation from HOL light)
1.6 +*)
1.7 +
1.8  header {* Kurzweil-Henstock Gauge Integration in many dimensions. *}
1.9 -(*  Author:                     John Harrison
1.10 -    Translation from HOL light: Robert Himmelmann, TU Muenchen *)
1.11
1.12  theory Integration
1.13  imports
1.14 @@ -11,62 +13,76 @@
1.15  lemma cSup_abs_le: (* TODO: is this really needed? *)
1.16    fixes S :: "real set"
1.17    shows "S \<noteq> {} \<Longrightarrow> (\<forall>x\<in>S. \<bar>x\<bar> \<le> a) \<Longrightarrow> \<bar>Sup S\<bar> \<le> a"
1.18 -by (auto simp add: abs_le_interval_iff intro: cSup_least) (metis cSup_upper2)
1.19 +  by (auto simp add: abs_le_interval_iff intro: cSup_least) (metis cSup_upper2)
1.20
1.21  lemma cInf_abs_ge: (* TODO: is this really needed? *)
1.22    fixes S :: "real set"
1.23    shows "S \<noteq> {} \<Longrightarrow> (\<forall>x\<in>S. \<bar>x\<bar> \<le> a) \<Longrightarrow> \<bar>Inf S\<bar> \<le> a"
1.24 -by (simp add: Inf_real_def) (rule cSup_abs_le, auto)
1.25 +  by (simp add: Inf_real_def) (rule cSup_abs_le, auto)
1.26
1.27  lemma cSup_asclose: (* TODO: is this really needed? *)
1.28    fixes S :: "real set"
1.29 -  assumes S:"S \<noteq> {}" and b: "\<forall>x\<in>S. \<bar>x - l\<bar> \<le> e" shows "\<bar>Sup S - l\<bar> \<le> e"
1.30 -proof-
1.31 -  have th: "\<And>(x::real) l e. \<bar>x - l\<bar> \<le> e \<longleftrightarrow> l - e \<le> x \<and> x \<le> l + e" by arith
1.32 -  thus ?thesis using S b cSup_bounds[of S "l - e" "l+e"] unfolding th
1.33 -    by  (auto simp add: setge_def setle_def)
1.34 +  assumes S: "S \<noteq> {}"
1.35 +    and b: "\<forall>x\<in>S. \<bar>x - l\<bar> \<le> e"
1.36 +  shows "\<bar>Sup S - l\<bar> \<le> e"
1.37 +proof -
1.38 +  have th: "\<And>(x::real) l e. \<bar>x - l\<bar> \<le> e \<longleftrightarrow> l - e \<le> x \<and> x \<le> l + e"
1.39 +    by arith
1.40 +  then show ?thesis
1.41 +    using S b cSup_bounds[of S "l - e" "l+e"]
1.42 +    unfolding th
1.43 +    by (auto simp add: setge_def setle_def)
1.44  qed
1.45
1.46  lemma cInf_asclose: (* TODO: is this really needed? *)
1.47    fixes S :: "real set"
1.48 -  assumes S:"S \<noteq> {}" and b: "\<forall>x\<in>S. \<bar>x - l\<bar> \<le> e" shows "\<bar>Inf S - l\<bar> \<le> e"
1.49 +  assumes S: "S \<noteq> {}"
1.50 +    and b: "\<forall>x\<in>S. \<bar>x - l\<bar> \<le> e"
1.51 +  shows "\<bar>Inf S - l\<bar> \<le> e"
1.52  proof -
1.53    have "\<bar>- Sup (uminus ` S) - l\<bar> =  \<bar>Sup (uminus ` S) - (-l)\<bar>"
1.54      by auto
1.55 -  also have "... \<le> e"
1.56 -    apply (rule cSup_asclose)
1.57 +  also have "\<dots> \<le> e"
1.58 +    apply (rule cSup_asclose)
1.59      apply (auto simp add: S)
1.61      done
1.62    finally have "\<bar>- Sup (uminus ` S) - l\<bar> \<le> e" .
1.63 -  thus ?thesis
1.64 +  then show ?thesis
1.66  qed
1.67
1.68 -lemma cSup_finite_ge_iff:
1.69 -  fixes S :: "real set" shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<le> Sup S \<longleftrightarrow> (\<exists>x\<in>S. a \<le> x)"
1.70 +lemma cSup_finite_ge_iff:
1.71 +  fixes S :: "real set"
1.72 +  shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<le> Sup S \<longleftrightarrow> (\<exists>x\<in>S. a \<le> x)"
1.73    by (metis cSup_eq_Max Max_ge_iff)
1.74
1.75 -lemma cSup_finite_le_iff:
1.76 -  fixes S :: "real set" shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<ge> Sup S \<longleftrightarrow> (\<forall>x\<in>S. a \<ge> x)"
1.77 +lemma cSup_finite_le_iff:
1.78 +  fixes S :: "real set"
1.79 +  shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<ge> Sup S \<longleftrightarrow> (\<forall>x\<in>S. a \<ge> x)"
1.80    by (metis cSup_eq_Max Max_le_iff)
1.81
1.82 -lemma cInf_finite_ge_iff:
1.83 -  fixes S :: "real set" shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<le> Inf S \<longleftrightarrow> (\<forall>x\<in>S. a \<le> x)"
1.84 +lemma cInf_finite_ge_iff:
1.85 +  fixes S :: "real set"
1.86 +  shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<le> Inf S \<longleftrightarrow> (\<forall>x\<in>S. a \<le> x)"
1.87    by (metis cInf_eq_Min Min_ge_iff)
1.88
1.89 -lemma cInf_finite_le_iff:
1.90 -  fixes S :: "real set" shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<ge> Inf S \<longleftrightarrow> (\<exists>x\<in>S. a \<ge> x)"
1.91 +lemma cInf_finite_le_iff:
1.92 +  fixes S :: "real set"
1.93 +  shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<ge> Inf S \<longleftrightarrow> (\<exists>x\<in>S. a \<ge> x)"
1.94    by (metis cInf_eq_Min Min_le_iff)
1.95
1.96  lemma Inf: (* rename *)
1.97    fixes S :: "real set"
1.98 -  shows "S \<noteq> {} ==> (\<exists>b. b <=* S) ==> isGlb UNIV S (Inf S)"
1.99 -by (auto simp add: isLb_def setle_def setge_def isGlb_def greatestP_def intro: cInf_lower cInf_greatest)
1.100 -
1.101 +  shows "S \<noteq> {} \<Longrightarrow> (\<exists>b. b <=* S) \<Longrightarrow> isGlb UNIV S (Inf S)"
1.102 +  by (auto simp add: isLb_def setle_def setge_def isGlb_def greatestP_def
1.103 +    intro: cInf_lower cInf_greatest)
1.104 +
1.105  lemma real_le_inf_subset:
1.106 -  assumes "t \<noteq> {}" "t \<subseteq> s" "\<exists>b. b <=* s"
1.107 -  shows "Inf s <= Inf (t::real set)"
1.108 +  assumes "t \<noteq> {}"
1.109 +    and "t \<subseteq> s"
1.110 +    and "\<exists>b. b <=* s"
1.111 +  shows "Inf s \<le> Inf (t::real set)"
1.112    apply (rule isGlb_le_isLb)
1.113    apply (rule Inf[OF assms(1)])
1.114    apply (insert assms)
1.115 @@ -76,8 +92,11 @@
1.116    done
1.117
1.118  lemma real_ge_sup_subset:
1.119 -  assumes "t \<noteq> {}" "t \<subseteq> s" "\<exists>b. s *<= b"
1.120 -  shows "Sup s >= Sup (t::real set)"
1.121 +  fixes t :: "real set"
1.122 +  assumes "t \<noteq> {}"
1.123 +    and "t \<subseteq> s"
1.124 +    and "\<exists>b. s *<= b"
1.125 +  shows "Sup s \<ge> Sup t"
1.126    apply (rule isLub_le_isUb)
1.127    apply (rule isLub_cSup[OF assms(1)])
1.128    apply (insert assms)
1.129 @@ -104,9 +123,10 @@
1.130  lemma conjunctD4: assumes "a \<and> b \<and> c \<and> d" shows a b c d using assms by auto
1.131  lemma conjunctD5: assumes "a \<and> b \<and> c \<and> d \<and> e" shows a b c d e using assms by auto
1.132
1.133 -declare norm_triangle_ineq4[intro]
1.134 -
1.135 -lemma simple_image: "{f x |x . x \<in> s} = f ` s" by blast
1.136 +declare norm_triangle_ineq4[intro]
1.137 +
1.138 +lemma simple_image: "{f x |x . x \<in> s} = f ` s"
1.139 +  by blast
1.140
1.141  lemma linear_simps:
1.142    assumes "bounded_linear f"
1.143 @@ -123,24 +143,30 @@
1.144
1.145  lemma bounded_linearI:
1.146    assumes "\<And>x y. f (x + y) = f x + f y"
1.147 -    and "\<And>r x. f (r *\<^sub>R x) = r *\<^sub>R f x" "\<And>x. norm (f x) \<le> norm x * K"
1.148 +    and "\<And>r x. f (r *\<^sub>R x) = r *\<^sub>R f x"
1.149 +    and "\<And>x. norm (f x) \<le> norm x * K"
1.150    shows "bounded_linear f"
1.151 -  unfolding bounded_linear_def additive_def bounded_linear_axioms_def using assms by auto
1.152 +  unfolding bounded_linear_def additive_def bounded_linear_axioms_def
1.153 +  using assms by auto
1.154
1.155  lemma bounded_linear_component [intro]: "bounded_linear (\<lambda>x::'a::euclidean_space. x \<bullet> k)"
1.156    by (rule bounded_linear_inner_left)
1.157
1.158  lemma transitive_stepwise_lt_eq:
1.159    assumes "(\<And>x y z::nat. R x y \<Longrightarrow> R y z \<Longrightarrow> R x z)"
1.160 -  shows "((\<forall>m. \<forall>n>m. R m n) \<longleftrightarrow> (\<forall>n. R n (Suc n)))" (is "?l = ?r")
1.161 +  shows "((\<forall>m. \<forall>n>m. R m n) \<longleftrightarrow> (\<forall>n. R n (Suc n)))"
1.162 +  (is "?l = ?r")
1.163  proof (safe)
1.164    assume ?r
1.165    fix n m :: nat
1.166    assume "m < n"
1.167    then show "R m n"
1.168    proof (induct n arbitrary: m)
1.169 +    case 0
1.170 +    then show ?case by auto
1.171 +  next
1.172      case (Suc n)
1.173 -    show ?case
1.174 +    show ?case
1.175      proof (cases "m < n")
1.176        case True
1.177        show ?thesis
1.178 @@ -153,7 +179,7 @@
1.179        then have "m = n" using Suc(2) by auto
1.180        then show ?thesis using `?r` by auto
1.181      qed
1.182 -  qed auto
1.183 +  qed
1.184  qed auto
1.185
1.186  lemma transitive_stepwise_gt:
1.187 @@ -172,7 +198,8 @@
1.188
1.189  lemma transitive_stepwise_le_eq:
1.190    assumes "\<And>x. R x x" "\<And>x y z. R x y \<Longrightarrow> R y z \<Longrightarrow> R x z"
1.191 -  shows "(\<forall>m. \<forall>n\<ge>m. R m n) \<longleftrightarrow> (\<forall>n. R n (Suc n))" (is "?l = ?r")
1.192 +  shows "(\<forall>m. \<forall>n\<ge>m. R m n) \<longleftrightarrow> (\<forall>n. R n (Suc n))"
1.193 +  (is "?l = ?r")
1.194  proof safe
1.195    assume ?r
1.196    fix m n :: nat
1.197 @@ -215,14 +242,17 @@
1.198
1.199  subsection {* Some useful lemmas about intervals. *}
1.200
1.201 -abbreviation One where "One \<equiv> ((\<Sum>Basis)::_::euclidean_space)"
1.202 +abbreviation One where "One \<equiv> (\<Sum>Basis)::'a::euclidean_space"
1.203
1.204  lemma empty_as_interval: "{} = {One..(0::'a::ordered_euclidean_space)}"
1.205    by (auto simp: set_eq_iff eucl_le[where 'a='a] intro!: bexI[OF _ SOME_Basis])
1.206
1.207 -lemma interior_subset_union_intervals:
1.208 -  assumes "i = {a..b::'a::ordered_euclidean_space}" "j = {c..d}"
1.209 -    "interior j \<noteq> {}" "i \<subseteq> j \<union> s" "interior(i) \<inter> interior(j) = {}"
1.210 +lemma interior_subset_union_intervals:
1.211 +  assumes "i = {a..b::'a::ordered_euclidean_space}"
1.212 +    and "j = {c..d}"
1.213 +    and "interior j \<noteq> {}"
1.214 +    and "i \<subseteq> j \<union> s"
1.215 +    and "interior i \<inter> interior j = {}"
1.216    shows "interior i \<subseteq> interior s"
1.217  proof -
1.218    have "{a<..<b} \<inter> {c..d} = {}"
1.219 @@ -247,9 +277,12 @@
1.220
1.221  lemma inter_interior_unions_intervals:
1.222    fixes f::"('a::ordered_euclidean_space) set set"
1.223 -  assumes "finite f" "open s" "\<forall>t\<in>f. \<exists>a b. t = {a..b}" "\<forall>t\<in>f. s \<inter> (interior t) = {}"
1.224 -  shows "s \<inter> interior(\<Union>f) = {}"
1.225 -proof (rule ccontr, unfold ex_in_conv[THEN sym])
1.226 +  assumes "finite f"
1.227 +    and "open s"
1.228 +    and "\<forall>t\<in>f. \<exists>a b. t = {a..b}"
1.229 +    and "\<forall>t\<in>f. s \<inter> (interior t) = {}"
1.230 +  shows "s \<inter> interior (\<Union>f) = {}"
1.231 +proof (rule ccontr, unfold ex_in_conv[symmetric])
1.232    case goal1
1.233    have lem1: "\<And>x e s U. ball x e \<subseteq> s \<inter> interior U \<longleftrightarrow> ball x e \<subseteq> s \<inter> U"
1.234      apply rule
1.235 @@ -266,36 +299,44 @@
1.236      case goal1
1.237      then show ?case
1.238      proof (induct rule: finite_induct)
1.239 -      case empty from this(2) guess x ..
1.240 -      hence False unfolding Union_empty interior_empty by auto
1.241 -      thus ?case by auto
1.242 +      case empty
1.243 +      from this(2) guess x ..
1.244 +      then have False
1.245 +        unfolding Union_empty interior_empty by auto
1.246 +      then show ?case by auto
1.247      next
1.248 -      case (insert i f) guess x using insert(5) .. note x = this
1.249 -      then guess e unfolding open_contains_ball_eq[OF open_Int[OF assms(2) open_interior],rule_format] .. note e=this
1.250 -      guess a using insert(4)[rule_format,OF insertI1] ..
1.251 +      case (insert i f)
1.252 +      guess x using insert(5) .. note x = this
1.253 +      then guess e
1.254 +        unfolding open_contains_ball_eq[OF open_Int[OF assms(2) open_interior],rule_format] .. note e=this
1.255 +      guess a
1.256 +        using insert(4)[rule_format,OF insertI1] ..
1.257        then guess b .. note ab = this
1.258        show ?case
1.259        proof (cases "x\<in>i")
1.260          case False
1.261 -        hence "x \<in> UNIV - {a..b}" unfolding ab by auto
1.262 -        then guess d unfolding open_contains_ball_eq[OF open_Diff[OF open_UNIV closed_interval],rule_format] ..
1.263 -        hence "0 < d" "ball x (min d e) \<subseteq> UNIV - i" unfolding ab ball_min_Int by auto
1.264 -        hence "ball x (min d e) \<subseteq> s \<inter> interior (\<Union>f)"
1.265 +        then have "x \<in> UNIV - {a..b}"
1.266 +          unfolding ab by auto
1.267 +        then guess d
1.268 +          unfolding open_contains_ball_eq[OF open_Diff[OF open_UNIV closed_interval],rule_format] ..
1.269 +        then have "0 < d" "ball x (min d e) \<subseteq> UNIV - i"
1.270 +          unfolding ab ball_min_Int by auto
1.271 +        then have "ball x (min d e) \<subseteq> s \<inter> interior (\<Union>f)"
1.272            using e unfolding lem1 unfolding  ball_min_Int by auto
1.273 -        hence "x \<in> s \<inter> interior (\<Union>f)" using `d>0` e by auto
1.274 -        hence "\<exists>t\<in>f. \<exists>x e. 0 < e \<and> ball x e \<subseteq> s \<inter> t"
1.275 +        then have "x \<in> s \<inter> interior (\<Union>f)" using `d>0` e by auto
1.276 +        then have "\<exists>t\<in>f. \<exists>x e. 0 < e \<and> ball x e \<subseteq> s \<inter> t"
1.277            apply -
1.278            apply (rule insert(3))
1.279            using insert(4)
1.280            apply auto
1.281            done
1.282 -        thus ?thesis by auto
1.283 +        then show ?thesis by auto
1.284        next
1.285          case True show ?thesis
1.286          proof (cases "x\<in>{a<..<b}")
1.287            case True
1.288            then guess d unfolding open_contains_ball_eq[OF open_interval,rule_format] ..
1.289 -          thus ?thesis
1.290 +          then show ?thesis
1.291              apply (rule_tac x=i in bexI, rule_tac x=x in exI, rule_tac x="min d e" in exI)
1.292              unfolding ab
1.293              using interval_open_subset_closed[of a b] and e
1.294 @@ -303,38 +344,40 @@
1.295              done
1.296          next
1.297            case False
1.298 -          then obtain k where "x\<bullet>k \<le> a\<bullet>k \<or> x\<bullet>k \<ge> b\<bullet>k" and k:"k\<in>Basis"
1.299 +          then obtain k where "x\<bullet>k \<le> a\<bullet>k \<or> x\<bullet>k \<ge> b\<bullet>k" and k: "k \<in> Basis"
1.300              unfolding mem_interval by (auto simp add: not_less)
1.301 -          hence "x\<bullet>k = a\<bullet>k \<or> x\<bullet>k = b\<bullet>k"
1.302 +          then have "x\<bullet>k = a\<bullet>k \<or> x\<bullet>k = b\<bullet>k"
1.303              using True unfolding ab and mem_interval
1.304                apply (erule_tac x = k in ballE)
1.305                apply auto
1.306                done
1.307 -          hence "\<exists>x. ball x (e/2) \<subseteq> s \<inter> (\<Union>f)"
1.308 -          proof (erule_tac disjE)
1.309 +          then have "\<exists>x. ball x (e/2) \<subseteq> s \<inter> (\<Union>f)"
1.310 +          proof (rule disjE)
1.311              let ?z = "x - (e/2) *\<^sub>R k"
1.312              assume as: "x\<bullet>k = a\<bullet>k"
1.313              have "ball ?z (e / 2) \<inter> i = {}"
1.314                apply (rule ccontr)
1.315 -              unfolding ex_in_conv[THEN sym]
1.316 -            proof (erule exE)
1.317 +              unfolding ex_in_conv[symmetric]
1.318 +              apply (erule exE)
1.319 +            proof -
1.320                fix y
1.321                assume "y \<in> ball ?z (e / 2) \<inter> i"
1.322 -              hence "dist ?z y < e/2" and yi:"y\<in>i" by auto
1.323 -              hence "\<bar>(?z - y) \<bullet> k\<bar> < e/2"
1.324 +              then have "dist ?z y < e/2" and yi:"y\<in>i" by auto
1.325 +              then have "\<bar>(?z - y) \<bullet> k\<bar> < e/2"
1.326                  using Basis_le_norm[OF k, of "?z - y"] unfolding dist_norm by auto
1.327 -              hence "y\<bullet>k < a\<bullet>k"
1.328 -                using e[THEN conjunct1] k by (auto simp add: field_simps as inner_Basis inner_simps)
1.329 -              hence "y \<notin> i"
1.330 +              then have "y\<bullet>k < a\<bullet>k"
1.331 +                using e[THEN conjunct1] k
1.332 +                by (auto simp add: field_simps as inner_Basis inner_simps)
1.333 +              then have "y \<notin> i"
1.334                  unfolding ab mem_interval by (auto intro!: bexI[OF _ k])
1.335 -              thus False using yi by auto
1.336 +              then show False using yi by auto
1.337              qed
1.338              moreover
1.339              have "ball ?z (e/2) \<subseteq> s \<inter> (\<Union>insert i f)"
1.340 -              apply(rule order_trans[OF _ e[THEN conjunct2, unfolded lem1]])
1.341 +              apply (rule order_trans[OF _ e[THEN conjunct2, unfolded lem1]])
1.342              proof
1.343                fix y
1.344 -              assume as: "y\<in> ball ?z (e/2)"
1.345 +              assume as: "y \<in> ball ?z (e/2)"
1.346                have "norm (x - y) \<le> \<bar>e\<bar> / 2 + norm (x - y - (e / 2) *\<^sub>R k)"
1.347                  apply -
1.348                  apply (rule order_trans,rule norm_triangle_sub[of "x - y" "(e/2) *\<^sub>R k"])
1.349 @@ -348,7 +391,7 @@
1.350                  using e
1.351                  apply (auto simp add: field_simps)
1.352                  done
1.353 -              finally show "y\<in>ball x e"
1.354 +              finally show "y \<in> ball x e"
1.355                  unfolding mem_ball dist_norm using e by (auto simp add:field_simps)
1.356              qed
1.357              ultimately show ?thesis
1.358 @@ -361,18 +404,20 @@
1.359              assume as: "x\<bullet>k = b\<bullet>k"
1.360              have "ball ?z (e / 2) \<inter> i = {}"
1.361                apply (rule ccontr)
1.362 -              unfolding ex_in_conv[THEN sym]
1.363 -            proof(erule exE)
1.364 +              unfolding ex_in_conv[symmetric]
1.365 +            proof (erule exE)
1.366                fix y
1.367                assume "y \<in> ball ?z (e / 2) \<inter> i"
1.368 -              hence "dist ?z y < e/2" and yi:"y\<in>i" by auto
1.369 -              hence "\<bar>(?z - y) \<bullet> k\<bar> < e/2"
1.370 -                using Basis_le_norm[OF k, of "?z - y"] unfolding dist_norm by auto
1.371 -              hence "y\<bullet>k > b\<bullet>k"
1.372 -                using e[THEN conjunct1] k by(auto simp add:field_simps inner_simps inner_Basis as)
1.373 -              hence "y \<notin> i"
1.374 +              then have "dist ?z y < e/2" and yi: "y\<in>i" by auto
1.375 +              then have "\<bar>(?z - y) \<bullet> k\<bar> < e/2"
1.376 +                using Basis_le_norm[OF k, of "?z - y"]
1.377 +                unfolding dist_norm by auto
1.378 +              then have "y\<bullet>k > b\<bullet>k"
1.379 +                using e[THEN conjunct1] k
1.380 +                by (auto simp add:field_simps inner_simps inner_Basis as)
1.381 +              then have "y \<notin> i"
1.382                  unfolding ab mem_interval by (auto intro!: bexI[OF _ k])
1.383 -              thus False using yi by auto
1.384 +              then show False using yi by auto
1.385              qed
1.386              moreover
1.387              have "ball ?z (e/2) \<subseteq> s \<inter> (\<Union>insert i f)"
1.388 @@ -382,7 +427,7 @@
1.389                assume as: "y\<in> ball ?z (e/2)"
1.390                have "norm (x - y) \<le> \<bar>e\<bar> / 2 + norm (x - y + (e / 2) *\<^sub>R k)"
1.391                  apply -
1.392 -                apply(rule order_trans,rule norm_triangle_sub[of "x - y" "- (e/2) *\<^sub>R k"])
1.393 +                apply (rule order_trans,rule norm_triangle_sub[of "x - y" "- (e/2) *\<^sub>R k"])
1.394                  unfolding norm_scaleR
1.395                  apply (auto simp: k)
1.396                  done
1.397 @@ -391,23 +436,24 @@
1.398                  using as unfolding mem_ball dist_norm
1.399                  using e apply (auto simp add: field_simps)
1.400                  done
1.401 -              finally show "y\<in>ball x e"
1.402 -                unfolding mem_ball dist_norm using e by(auto simp add:field_simps)
1.403 +              finally show "y \<in> ball x e"
1.404 +                unfolding mem_ball dist_norm using e by (auto simp add:field_simps)
1.405              qed
1.406              ultimately show ?thesis
1.407                apply (rule_tac x="?z" in exI)
1.408                unfolding Union_insert
1.409                apply auto
1.410                done
1.411 -          qed
1.412 +          qed
1.413            then guess x ..
1.414 -          hence "x \<in> s \<inter> interior (\<Union>f)"
1.415 -            unfolding lem1[where U="\<Union>f",THEN sym]
1.416 +          then have "x \<in> s \<inter> interior (\<Union>f)"
1.417 +            unfolding lem1[where U="\<Union>f",symmetric]
1.418              using centre_in_ball e[THEN conjunct1] by auto
1.419 -          thus ?thesis
1.420 +          then show ?thesis
1.421              apply -
1.422              apply (rule lem2, rule insert(3))
1.423 -            using insert(4) apply auto
1.424 +            using insert(4)
1.425 +            apply auto
1.426              done
1.427          qed
1.428        qed
1.429 @@ -417,53 +463,57 @@
1.430    guess t using *[OF assms(1,3) goal1] ..
1.431    from this(2) guess x ..
1.432    then guess e ..
1.433 -  hence "x \<in> s" "x\<in>interior t"
1.434 +  then have "x \<in> s" "x\<in>interior t"
1.435      defer
1.436 -    using open_subset_interior[OF open_ball, of x e t] apply auto
1.437 +    using open_subset_interior[OF open_ball, of x e t]
1.438 +    apply auto
1.439      done
1.440 -  thus False using `t\<in>f` assms(4) by auto
1.441 +  then show False
1.442 +    using `t \<in> f` assms(4) by auto
1.443  qed
1.444
1.445
1.446  subsection {* Bounds on intervals where they exist. *}
1.447
1.448 -definition interval_upperbound :: "('a::ordered_euclidean_space) set \<Rightarrow> 'a" where
1.449 -  "interval_upperbound s = (\<Sum>i\<in>Basis. Sup {a. \<exists>x\<in>s. x\<bullet>i = a} *\<^sub>R i)"
1.450 -
1.451 -definition interval_lowerbound :: "('a::ordered_euclidean_space) set \<Rightarrow> 'a" where
1.452 -  "interval_lowerbound s = (\<Sum>i\<in>Basis. Inf {a. \<exists>x\<in>s. x\<bullet>i = a} *\<^sub>R i)"
1.453 +definition interval_upperbound :: "('a::ordered_euclidean_space) set \<Rightarrow> 'a"
1.454 +  where "interval_upperbound s = (\<Sum>i\<in>Basis. Sup {a. \<exists>x\<in>s. x\<bullet>i = a} *\<^sub>R i)"
1.455 +
1.456 +definition interval_lowerbound :: "('a::ordered_euclidean_space) set \<Rightarrow> 'a"
1.457 +  where "interval_lowerbound s = (\<Sum>i\<in>Basis. Inf {a. \<exists>x\<in>s. x\<bullet>i = a} *\<^sub>R i)"
1.458
1.459  lemma interval_upperbound[simp]:
1.460    "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow>
1.461      interval_upperbound {a..b} = (b::'a::ordered_euclidean_space)"
1.462    unfolding interval_upperbound_def euclidean_representation_setsum
1.463    by (auto simp del: ex_simps simp add: Bex_def ex_simps[symmetric] eucl_le[where 'a='a] setle_def
1.464 -           intro!: cSup_unique)
1.465 +      intro!: cSup_unique)
1.466
1.467  lemma interval_lowerbound[simp]:
1.468    "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow>
1.469      interval_lowerbound {a..b} = (a::'a::ordered_euclidean_space)"
1.470    unfolding interval_lowerbound_def euclidean_representation_setsum
1.471    by (auto simp del: ex_simps simp add: Bex_def ex_simps[symmetric] eucl_le[where 'a='a] setge_def
1.472 -           intro!: cInf_unique)
1.473 +      intro!: cInf_unique)
1.474
1.475  lemmas interval_bounds = interval_upperbound interval_lowerbound
1.476
1.477  lemma interval_bounds'[simp]:
1.478 -  assumes "{a..b}\<noteq>{}"
1.479 -  shows "interval_upperbound {a..b} = b" "interval_lowerbound {a..b} = a"
1.480 +  assumes "{a..b} \<noteq> {}"
1.481 +  shows "interval_upperbound {a..b} = b"
1.482 +    and "interval_lowerbound {a..b} = a"
1.483    using assms unfolding interval_ne_empty by auto
1.484
1.485 +
1.486  subsection {* Content (length, area, volume...) of an interval. *}
1.487
1.488  definition "content (s::('a::ordered_euclidean_space) set) =
1.489    (if s = {} then 0 else (\<Prod>i\<in>Basis. (interval_upperbound s)\<bullet>i - (interval_lowerbound s)\<bullet>i))"
1.490
1.491 -lemma interval_not_empty:"\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow> {a..b::'a::ordered_euclidean_space} \<noteq> {}"
1.492 +lemma interval_not_empty: "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow> {a..b::'a::ordered_euclidean_space} \<noteq> {}"
1.493    unfolding interval_eq_empty unfolding not_ex not_less by auto
1.494
1.495  lemma content_closed_interval:
1.496 -  fixes a::"'a::ordered_euclidean_space"
1.497 +  fixes a :: "'a::ordered_euclidean_space"
1.498    assumes "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i"
1.499    shows "content {a..b} = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
1.500    using interval_not_empty[OF assms]
1.501 @@ -471,8 +521,8 @@
1.502    by auto
1.503
1.504  lemma content_closed_interval':
1.505 -  fixes a::"'a::ordered_euclidean_space"
1.506 -  assumes "{a..b}\<noteq>{}"
1.507 +  fixes a :: "'a::ordered_euclidean_space"
1.508 +  assumes "{a..b} \<noteq> {}"
1.509    shows "content {a..b} = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
1.510    apply (rule content_closed_interval)
1.511    using assms
1.512 @@ -481,11 +531,12 @@
1.513    done
1.514
1.515  lemma content_real:
1.516 -  assumes "a\<le>b"
1.517 -  shows "content {a..b} = b-a"
1.518 +  assumes "a \<le> b"
1.519 +  shows "content {a..b} = b - a"
1.520  proof -
1.521    have *: "{..<Suc 0} = {0}" by auto
1.522 -  show ?thesis unfolding content_def using assms by (auto simp: *)
1.523 +  show ?thesis
1.524 +    unfolding content_def using assms by (auto simp: *)
1.525  qed
1.526
1.527  lemma content_singleton[simp]: "content {a} = 0"
1.528 @@ -499,7 +550,8 @@
1.529  proof -
1.530    have *: "\<forall>i\<in>Basis. (0::'a)\<bullet>i \<le> (One::'a)\<bullet>i" by auto
1.531    have "0 \<in> {0..One::'a}" unfolding mem_interval by auto
1.532 -  thus ?thesis unfolding content_def interval_bounds[OF *] using setprod_1 by auto
1.533 +  then show ?thesis
1.534 +    unfolding content_def interval_bounds[OF *] using setprod_1 by auto
1.535  qed
1.536
1.537  lemma content_pos_le[intro]:
1.538 @@ -507,7 +559,8 @@
1.539    shows "0 \<le> content {a..b}"
1.540  proof (cases "{a..b} = {}")
1.541    case False
1.542 -  hence *: "\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i" unfolding interval_ne_empty .
1.543 +  then have *: "\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i"
1.544 +    unfolding interval_ne_empty .
1.545    have "(\<Prod>i\<in>Basis. interval_upperbound {a..b} \<bullet> i - interval_lowerbound {a..b} \<bullet> i) \<ge> 0"
1.546      apply (rule setprod_nonneg)
1.547      unfolding interval_bounds[OF *]
1.548 @@ -515,11 +568,14 @@
1.549      apply (erule_tac x=x in ballE)
1.550      apply auto
1.551      done
1.552 -  thus ?thesis unfolding content_def by (auto simp del:interval_bounds')
1.553 -qed (unfold content_def, auto)
1.554 +  then show ?thesis unfolding content_def by (auto simp del:interval_bounds')
1.555 +next
1.556 +  case True
1.557 +  then show ?thesis unfolding content_def by auto
1.558 +qed
1.559
1.560  lemma content_pos_lt:
1.561 -  fixes a::"'a::ordered_euclidean_space"
1.562 +  fixes a :: "'a::ordered_euclidean_space"
1.563    assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
1.564    shows "0 < content {a..b}"
1.565  proof -
1.566 @@ -528,8 +584,9 @@
1.567      apply auto
1.568      done
1.569    show ?thesis unfolding content_closed_interval[OF help_lemma1[OF assms]]
1.570 -    apply(rule setprod_pos)
1.571 -    using assms apply (erule_tac x=x in ballE)
1.572 +    apply (rule setprod_pos)
1.573 +    using assms
1.574 +    apply (erule_tac x=x in ballE)
1.575      apply auto
1.576      done
1.577  qed
1.578 @@ -537,7 +594,7 @@
1.579  lemma content_eq_0: "content{a..b::'a::ordered_euclidean_space} = 0 \<longleftrightarrow> (\<exists>i\<in>Basis. b\<bullet>i \<le> a\<bullet>i)"
1.580  proof (cases "{a..b} = {}")
1.581    case True
1.582 -  thus ?thesis
1.583 +  then show ?thesis
1.584      unfolding content_def if_P[OF True]
1.585      unfolding interval_eq_empty
1.586      apply -
1.587 @@ -555,7 +612,8 @@
1.588      by (auto intro!: bexI)
1.589  qed
1.590
1.591 -lemma cond_cases:"(P \<Longrightarrow> Q x) \<Longrightarrow> (\<not> P \<Longrightarrow> Q y) \<Longrightarrow> Q (if P then x else y)" by auto
1.592 +lemma cond_cases:"(P \<Longrightarrow> Q x) \<Longrightarrow> (\<not> P \<Longrightarrow> Q y) \<Longrightarrow> Q (if P then x else y)"
1.593 +  by auto
1.594
1.595  lemma content_closed_interval_cases:
1.596    "content {a..b::'a::ordered_euclidean_space} =
1.597 @@ -565,31 +623,37 @@
1.598  lemma content_eq_0_interior: "content {a..b} = 0 \<longleftrightarrow> interior({a..b}) = {}"
1.599    unfolding content_eq_0 interior_closed_interval interval_eq_empty by auto
1.600
1.601 -lemma content_pos_lt_eq: "0 < content {a..b::'a::ordered_euclidean_space} \<longleftrightarrow> (\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i)"
1.602 +lemma content_pos_lt_eq:
1.603 +  "0 < content {a..b::'a::ordered_euclidean_space} \<longleftrightarrow> (\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i)"
1.604    apply rule
1.605    defer
1.606    apply (rule content_pos_lt, assumption)
1.607  proof -
1.608    assume "0 < content {a..b}"
1.609 -  hence "content {a..b} \<noteq> 0" by auto
1.610 -  thus "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
1.611 +  then have "content {a..b} \<noteq> 0" by auto
1.612 +  then show "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
1.613      unfolding content_eq_0 not_ex not_le by fastforce
1.614  qed
1.615
1.616 -lemma content_empty [simp]: "content {} = 0" unfolding content_def by auto
1.617 +lemma content_empty [simp]: "content {} = 0"
1.618 +  unfolding content_def by auto
1.619
1.620  lemma content_subset:
1.621    assumes "{a..b} \<subseteq> {c..d}"
1.622    shows "content {a..b::'a::ordered_euclidean_space} \<le> content {c..d}"
1.623  proof (cases "{a..b} = {}")
1.624    case True
1.625 -  thus ?thesis using content_pos_le[of c d] by auto
1.626 +  then show ?thesis
1.627 +    using content_pos_le[of c d] by auto
1.628  next
1.629    case False
1.630 -  hence ab_ne:"\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i" unfolding interval_ne_empty by auto
1.631 -  hence ab_ab:"a\<in>{a..b}" "b\<in>{a..b}" unfolding mem_interval by auto
1.632 +  then have ab_ne: "\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i"
1.633 +    unfolding interval_ne_empty by auto
1.634 +  then have ab_ab: "a\<in>{a..b}" "b\<in>{a..b}"
1.635 +    unfolding mem_interval by auto
1.636    have "{c..d} \<noteq> {}" using assms False by auto
1.637 -  hence cd_ne:"\<forall>i\<in>Basis. c \<bullet> i \<le> d \<bullet> i" using assms unfolding interval_ne_empty by auto
1.638 +  then have cd_ne: "\<forall>i\<in>Basis. c \<bullet> i \<le> d \<bullet> i"
1.639 +    using assms unfolding interval_ne_empty by auto
1.640    show ?thesis
1.641      unfolding content_def
1.642      unfolding interval_bounds[OF ab_ne] interval_bounds[OF cd_ne]
1.643 @@ -597,8 +661,9 @@
1.644      apply (rule setprod_mono, rule)
1.645    proof
1.646      fix i :: 'a
1.647 -    assume i: "i\<in>Basis"
1.648 -    show "0 \<le> b \<bullet> i - a \<bullet> i" using ab_ne[THEN bspec, OF i] i by auto
1.649 +    assume i: "i \<in> Basis"
1.650 +    show "0 \<le> b \<bullet> i - a \<bullet> i"
1.651 +      using ab_ne[THEN bspec, OF i] i by auto
1.652      show "b \<bullet> i - a \<bullet> i \<le> d \<bullet> i - c \<bullet> i"
1.653        using assms[unfolded subset_eq mem_interval,rule_format,OF ab_ab(2),of i]
1.654        using assms[unfolded subset_eq mem_interval,rule_format,OF ab_ab(1),of i]
1.655 @@ -612,47 +677,57 @@
1.656
1.657  subsection {* The notion of a gauge --- simply an open set containing the point. *}
1.658
1.659 -definition gauge where "gauge d \<longleftrightarrow> (\<forall>x. x\<in>(d x) \<and> open(d x))"
1.660 -
1.661 -lemma gaugeI: assumes "\<And>x. x\<in>g x" "\<And>x. open (g x)" shows "gauge g"
1.662 +definition "gauge d \<longleftrightarrow> (\<forall>x. x\<in>(d x) \<and> open (d x))"
1.663 +
1.664 +lemma gaugeI:
1.665 +  assumes "\<And>x. x \<in> g x"
1.666 +    and "\<And>x. open (g x)"
1.667 +  shows "gauge g"
1.668    using assms unfolding gauge_def by auto
1.669
1.670 -lemma gaugeD[dest]: assumes "gauge d" shows "x\<in>d x" "open (d x)"
1.671 +lemma gaugeD[dest]:
1.672 +  assumes "gauge d"
1.673 +  shows "x \<in> d x"
1.674 +    and "open (d x)"
1.675    using assms unfolding gauge_def by auto
1.676
1.677  lemma gauge_ball_dependent: "\<forall>x. 0 < e x \<Longrightarrow> gauge (\<lambda>x. ball x (e x))"
1.678 -  unfolding gauge_def by auto
1.679 -
1.680 -lemma gauge_ball[intro]: "0 < e \<Longrightarrow> gauge (\<lambda>x. ball x e)" unfolding gauge_def by auto
1.681 +  unfolding gauge_def by auto
1.682 +
1.683 +lemma gauge_ball[intro]: "0 < e \<Longrightarrow> gauge (\<lambda>x. ball x e)"
1.684 +  unfolding gauge_def by auto
1.685
1.686  lemma gauge_trivial[intro]: "gauge (\<lambda>x. ball x 1)"
1.687    by (rule gauge_ball) auto
1.688
1.689  lemma gauge_inter[intro]: "gauge d1 \<Longrightarrow> gauge d2 \<Longrightarrow> gauge (\<lambda>x. (d1 x) \<inter> (d2 x))"
1.690 -  unfolding gauge_def by auto
1.691 +  unfolding gauge_def by auto
1.692
1.693  lemma gauge_inters:
1.694 -  assumes "finite s" "\<forall>d\<in>s. gauge (f d)"
1.695 +  assumes "finite s"
1.696 +    and "\<forall>d\<in>s. gauge (f d)"
1.697    shows "gauge(\<lambda>x. \<Inter> {f d x | d. d \<in> s})"
1.698  proof -
1.699 -  have *:"\<And>x. {f d x |d. d \<in> s} = (\<lambda>d. f d x) ` s" by auto
1.700 +  have *: "\<And>x. {f d x |d. d \<in> s} = (\<lambda>d. f d x) ` s"
1.701 +    by auto
1.702    show ?thesis
1.703 -    unfolding gauge_def unfolding *
1.704 +    unfolding gauge_def unfolding *
1.705      using assms unfolding Ball_def Inter_iff mem_Collect_eq gauge_def by auto
1.706  qed
1.707
1.708 -lemma gauge_existence_lemma: "(\<forall>x. \<exists>d::real. p x \<longrightarrow> 0 < d \<and> q d x) \<longleftrightarrow> (\<forall>x. \<exists>d>0. p x \<longrightarrow> q d x)"
1.709 -  by(meson zero_less_one)
1.710 +lemma gauge_existence_lemma:
1.711 +  "(\<forall>x. \<exists>d::real. p x \<longrightarrow> 0 < d \<and> q d x) \<longleftrightarrow> (\<forall>x. \<exists>d>0. p x \<longrightarrow> q d x)"
1.712 +  by (metis zero_less_one)
1.713
1.714
1.715  subsection {* Divisions. *}
1.716
1.717  definition division_of (infixl "division'_of" 40) where
1.718 -  "s division_of i \<equiv>
1.719 -        finite s \<and>
1.720 -        (\<forall>k\<in>s. k \<subseteq> i \<and> k \<noteq> {} \<and> (\<exists>a b. k = {a..b})) \<and>
1.721 -        (\<forall>k1\<in>s. \<forall>k2\<in>s. k1 \<noteq> k2 \<longrightarrow> interior(k1) \<inter> interior(k2) = {}) \<and>
1.722 -        (\<Union>s = i)"
1.723 +  "s division_of i \<longleftrightarrow>
1.724 +    finite s \<and>
1.725 +    (\<forall>k\<in>s. k \<subseteq> i \<and> k \<noteq> {} \<and> (\<exists>a b. k = {a..b})) \<and>
1.726 +    (\<forall>k1\<in>s. \<forall>k2\<in>s. k1 \<noteq> k2 \<longrightarrow> interior(k1) \<inter> interior(k2) = {}) \<and>
1.727 +    (\<Union>s = i)"
1.728
1.729  lemma division_ofD[dest]:
1.730    assumes "s division_of i"
1.731 @@ -661,9 +736,13 @@
1.732    using assms unfolding division_of_def by auto
1.733
1.734  lemma division_ofI:
1.735 -  assumes "finite s" "\<And>k. k\<in>s \<Longrightarrow> k \<subseteq> i" "\<And>k. k\<in>s \<Longrightarrow>  k \<noteq> {}" "\<And>k. k\<in>s \<Longrightarrow> (\<exists>a b. k = {a..b})"
1.736 -    "\<And>k1 k2. \<lbrakk>k1\<in>s; k2\<in>s; k1 \<noteq> k2\<rbrakk> \<Longrightarrow> interior(k1) \<inter> interior(k2) = {}" "\<Union>s = i"
1.737 -  shows "s division_of i" using assms unfolding division_of_def by auto
1.738 +  assumes "finite s" "\<And>k. k\<in>s \<Longrightarrow> k \<subseteq> i"
1.739 +    and "\<And>k. k\<in>s \<Longrightarrow> k \<noteq> {}"
1.740 +    and "\<And>k. k\<in>s \<Longrightarrow> (\<exists>a b. k = {a..b})"
1.741 +    and "\<And>k1 k2. \<lbrakk>k1\<in>s; k2\<in>s; k1 \<noteq> k2\<rbrakk> \<Longrightarrow> interior(k1) \<inter> interior(k2) = {}"
1.742 +    and "\<Union>s = i"
1.743 +  shows "s division_of i"
1.744 +  using assms unfolding division_of_def by auto
1.745
1.746  lemma division_of_finite: "s division_of i \<Longrightarrow> finite s"
1.747    unfolding division_of_def by auto
1.748 @@ -671,26 +750,34 @@
1.749  lemma division_of_self[intro]: "{a..b} \<noteq> {} \<Longrightarrow> {{a..b}} division_of {a..b}"
1.750    unfolding division_of_def by auto
1.751
1.752 -lemma division_of_trivial[simp]: "s division_of {} \<longleftrightarrow> s = {}" unfolding division_of_def by auto
1.753 +lemma division_of_trivial[simp]: "s division_of {} \<longleftrightarrow> s = {}"
1.754 +  unfolding division_of_def by auto
1.755
1.756  lemma division_of_sing[simp]:
1.757 -  "s division_of {a..a::'a::ordered_euclidean_space} \<longleftrightarrow> s = {{a..a}}" (is "?l = ?r")
1.758 +  "s division_of {a..a::'a::ordered_euclidean_space} \<longleftrightarrow> s = {{a..a}}"
1.759 +  (is "?l = ?r")
1.760  proof
1.761    assume ?r
1.762 -  moreover {
1.763 +  moreover
1.764 +  {
1.765      assume "s = {{a}}"
1.766 -    moreover fix k assume "k\<in>s"
1.767 +    moreover fix k assume "k\<in>s"
1.768      ultimately have"\<exists>x y. k = {x..y}"
1.769        apply (rule_tac x=a in exI)+
1.770        unfolding interval_sing
1.771        apply auto
1.772        done
1.773    }
1.774 -  ultimately show ?l unfolding division_of_def interval_sing by auto
1.775 +  ultimately show ?l
1.776 +    unfolding division_of_def interval_sing by auto
1.777  next
1.778    assume ?l
1.779    note as=conjunctD4[OF this[unfolded division_of_def interval_sing]]
1.780 -  { fix x assume x:"x\<in>s" have "x={a}" using as(2)[rule_format,OF x] by auto }
1.781 +  {
1.782 +    fix x
1.783 +    assume x: "x \<in> s" have "x = {a}"
1.784 +      using as(2)[rule_format,OF x] by auto
1.785 +  }
1.786    moreover have "s \<noteq> {}" using as(4) by auto
1.787    ultimately show ?r unfolding interval_sing by auto
1.788  qed
1.789 @@ -708,7 +795,10 @@
1.790   "d division_of i \<Longrightarrow> ((\<forall>x\<in>d. P x) \<longleftrightarrow> (\<forall>a b. {a..b} \<in> d \<longrightarrow> P {a..b}))"
1.791    unfolding division_of_def by fastforce
1.792
1.793 -lemma division_of_subset: assumes "p division_of (\<Union>p)" "q \<subseteq> p" shows "q division_of (\<Union>q)"
1.794 +lemma division_of_subset:
1.795 +  assumes "p division_of (\<Union>p)"
1.796 +    and "q \<subseteq> p"
1.797 +  shows "q division_of (\<Union>q)"
1.798    apply (rule division_ofI)
1.799  proof -
1.800    note as=division_ofD[OF assms(1)]
1.801 @@ -716,16 +806,20 @@
1.802      apply (rule finite_subset)
1.803      using as(1) assms(2) apply auto
1.804      done
1.805 -  { fix k
1.806 +  {
1.807 +    fix k
1.808      assume "k \<in> q"
1.809 -    hence kp:"k\<in>p" using assms(2) by auto
1.810 -    show "k\<subseteq>\<Union>q" using `k \<in> q` by auto
1.811 +    then have kp: "k \<in> p" using assms(2) by auto
1.812 +    show "k \<subseteq> \<Union>q" using `k \<in> q` by auto
1.813      show "\<exists>a b. k = {a..b}" using as(4)[OF kp]
1.814 -      by auto show "k \<noteq> {}" using as(3)[OF kp] by auto }
1.815 +      by auto show "k \<noteq> {}" using as(3)[OF kp] by auto
1.816 +  }
1.817    fix k1 k2
1.818    assume "k1 \<in> q" "k2 \<in> q" "k1 \<noteq> k2"
1.819 -  hence *: "k1\<in>p" "k2\<in>p" "k1\<noteq>k2" using assms(2) by auto
1.820 -  show "interior k1 \<inter> interior k2 = {}" using as(5)[OF *] by auto
1.821 +  then have *: "k1 \<in> p" "k2 \<in> p" "k1 \<noteq> k2"
1.822 +    using assms(2) by auto
1.823 +  show "interior k1 \<inter> interior k2 = {}"
1.824 +    using as(5)[OF *] by auto
1.825  qed auto
1.826
1.827  lemma division_of_union_self[intro]: "p division_of s \<Longrightarrow> p division_of (\<Union>p)"
1.828 @@ -740,7 +834,7 @@
1.829    apply (drule content_subset) unfolding assms(1)
1.830  proof -
1.831    case goal1
1.832 -  thus ?case using content_pos_le[of a b] by auto
1.833 +  then show ?case using content_pos_le[of a b] by auto
1.834  qed
1.835
1.836  lemma division_inter:
1.837 @@ -750,22 +844,28 @@
1.838  proof -
1.839    let ?A = "{s. s \<in>  (\<lambda>(k1,k2). k1 \<inter> k2) ` (p1 \<times> p2) \<and> s \<noteq> {}}"
1.840    have *:"?A' = ?A" by auto
1.841 -  show ?thesis unfolding *
1.842 +  show ?thesis
1.843 +    unfolding *
1.844    proof (rule division_ofI)
1.845 -    have "?A \<subseteq> (\<lambda>(x, y). x \<inter> y) ` (p1 \<times> p2)" by auto
1.846 -    moreover have "finite (p1 \<times> p2)" using assms unfolding division_of_def by auto
1.847 +    have "?A \<subseteq> (\<lambda>(x, y). x \<inter> y) ` (p1 \<times> p2)"
1.848 +      by auto
1.849 +    moreover have "finite (p1 \<times> p2)"
1.850 +      using assms unfolding division_of_def by auto
1.851      ultimately show "finite ?A" by auto
1.852 -    have *:"\<And>s. \<Union>{x\<in>s. x \<noteq> {}} = \<Union>s" by auto
1.853 +    have *: "\<And>s. \<Union>{x\<in>s. x \<noteq> {}} = \<Union>s"
1.854 +      by auto
1.855      show "\<Union>?A = s1 \<inter> s2"
1.856        apply (rule set_eqI)
1.857        unfolding * and Union_image_eq UN_iff
1.858        using division_ofD(6)[OF assms(1)] and division_ofD(6)[OF assms(2)]
1.859        apply auto
1.860        done
1.861 -    { fix k
1.862 -      assume "k\<in>?A"
1.863 -      then obtain k1 k2 where k: "k = k1 \<inter> k2" "k1\<in>p1" "k2\<in>p2" "k\<noteq>{}" by auto
1.864 -      thus "k \<noteq> {}" by auto
1.865 +    {
1.866 +      fix k
1.867 +      assume "k \<in> ?A"
1.868 +      then obtain k1 k2 where k: "k = k1 \<inter> k2" "k1\<in>p1" "k2\<in>p2" "k\<noteq>{}"
1.869 +        by auto
1.870 +      then show "k \<noteq> {}" by auto
1.871        show "k \<subseteq> s1 \<inter> s2"
1.872          using division_ofD(2)[OF assms(1) k(2)] and division_ofD(2)[OF assms(2) k(3)]
1.873          unfolding k by auto
1.874 @@ -781,8 +881,9 @@
1.875      assume "k2\<in>?A"
1.876      then obtain x2 y2 where k2:"k2 = x2 \<inter> y2" "x2\<in>p1" "y2\<in>p2" "k2\<noteq>{}" by auto
1.877      assume "k1 \<noteq> k2"
1.878 -    hence th:"x1\<noteq>x2 \<or> y1\<noteq>y2" unfolding k1 k2 by auto
1.879 -    have *:"(interior x1 \<inter> interior x2 = {} \<or> interior y1 \<inter> interior y2 = {}) \<Longrightarrow>
1.880 +    then have th: "x1 \<noteq> x2 \<or> y1 \<noteq> y2"
1.881 +      unfolding k1 k2 by auto
1.882 +    have *: "(interior x1 \<inter> interior x2 = {} \<or> interior y1 \<inter> interior y2 = {}) \<Longrightarrow>
1.883        interior(x1 \<inter> y1) \<subseteq> interior(x1) \<Longrightarrow> interior(x1 \<inter> y1) \<subseteq> interior(y1) \<Longrightarrow>
1.884        interior(x2 \<inter> y2) \<subseteq> interior(x2) \<Longrightarrow> interior(x2 \<inter> y2) \<subseteq> interior(y2)
1.885        \<Longrightarrow> interior(x1 \<inter> y1) \<inter> interior(x2 \<inter> y2) = {}" by auto
1.886 @@ -793,7 +894,8 @@
1.887        apply (rule_tac[1-4] interior_mono)
1.888        using division_ofD(5)[OF assms(1) k1(2) k2(2)]
1.889        using division_ofD(5)[OF assms(2) k1(3) k2(3)]
1.890 -      using th apply auto done
1.891 +      using th apply auto
1.892 +      done
1.893    qed
1.894  qed
1.895
1.896 @@ -802,11 +904,14 @@
1.897    shows "{ {a..b} \<inter> k |k. k \<in> d \<and> {a..b} \<inter> k \<noteq> {} } division_of {a..b}"
1.898  proof (cases "{a..b} = {}")
1.899    case True
1.900 -  show ?thesis unfolding True and division_of_trivial by auto
1.901 +  show ?thesis
1.902 +    unfolding True and division_of_trivial by auto
1.903  next
1.904    case False
1.905    have *: "{a..b} \<inter> i = {a..b}" using assms(2) by auto
1.906 -  show ?thesis using division_inter[OF division_of_self[OF False] assms(1)] unfolding * by auto
1.907 +  show ?thesis
1.908 +    using division_inter[OF division_of_self[OF False] assms(1)]
1.909 +    unfolding * by auto
1.910  qed
1.911
1.912  lemma elementary_inter:
1.913 @@ -825,7 +930,8 @@
1.914    show ?case
1.915    proof (cases "f = {}")
1.916      case True
1.917 -    thus ?thesis unfolding True using insert by auto
1.918 +    then show ?thesis
1.919 +      unfolding True using insert by auto
1.920    next
1.921      case False
1.922      guess p using insert(3)[OF False insert(5)[unfolded ball_simps,THEN conjunct2]] ..
1.923 @@ -864,7 +970,8 @@
1.924          using interior_mono[OF d1(2)[OF as(2)]] interior_mono[OF d2(2)[OF as(1)]]
1.925          using assms(3) by blast
1.926      }
1.927 -    ultimately show ?g using d1(5)[OF _ _ as(3)] and d2(5)[OF _ _ as(3)] by auto
1.928 +    ultimately show ?g
1.929 +      using d1(5)[OF _ _ as(3)] and d2(5)[OF _ _ as(3)] by auto
1.930    }
1.931    fix k
1.932    assume k: "k \<in> p1 \<union> p2"
1.933 @@ -884,8 +991,7 @@
1.934    show "{c .. d} \<in> p"
1.935      unfolding p_def
1.936      by (auto simp add: interval_eq_empty eucl_le[where 'a='a]
1.937 -             intro!: image_eqI[where x="\<lambda>(i::'a)\<in>Basis. (c, d)"])
1.938 -
1.939 +        intro!: image_eqI[where x="\<lambda>(i::'a)\<in>Basis. (c, d)"])
1.940    {
1.941      fix i :: 'a
1.942      assume "i \<in> Basis"
1.943 @@ -896,7 +1002,8 @@
1.944
1.945    show "p division_of {a..b}"
1.946    proof (rule division_ofI)
1.947 -    show "finite p" unfolding p_def by (auto intro!: finite_PiE)
1.948 +    show "finite p"
1.949 +      unfolding p_def by (auto intro!: finite_PiE)
1.950      {
1.951        fix k
1.952        assume "k \<in> p"
1.953 @@ -943,7 +1050,7 @@
1.954        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)}"
1.955        proof
1.956          fix i :: 'a assume "i \<in> Basis"
1.957 -        with x ord[of i]
1.958 +        with x ord[of i]
1.959          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>
1.960              (d \<bullet> i \<le> x \<bullet> i \<and> x \<bullet> i \<le> b \<bullet> i)"
1.961            by (auto simp: eucl_le[where 'a='a])
1.962 @@ -968,7 +1075,7 @@
1.963  proof (cases "p = {}")
1.964    case True
1.965    guess q apply (rule elementary_interval[of a b]) .
1.966 -  thus ?thesis
1.967 +  then show ?thesis
1.968      apply -
1.969      apply (rule that[of q])
1.970      unfolding True
1.971 @@ -985,7 +1092,7 @@
1.972      have *: "{c..d} \<subseteq> {a..b}" "{c..d} \<noteq> {}"
1.973        using p(2,3)[OF goal1, unfolded "cd"] using assms(2) by auto
1.974      guess q apply(rule partial_division_extend_1[OF *]) .
1.975 -    thus ?case unfolding "cd" by auto
1.976 +    then show ?case unfolding "cd" by auto
1.977    qed
1.978    guess q using bchoice[OF *] .. note q = conjunctD2[OF this[rule_format]]
1.979    have "\<And>x. x\<in>p \<Longrightarrow> \<exists>d. d division_of \<Union>(q x - {x})"
1.980 @@ -1001,7 +1108,7 @@
1.981        done
1.982      show "q x - {x} \<subseteq> q x" by auto
1.983    qed
1.984 -  hence "\<exists>d. d division_of \<Inter> ((\<lambda>i. \<Union>(q i - {i})) ` p)"
1.985 +  then have "\<exists>d. d division_of \<Inter> ((\<lambda>i. \<Union>(q i - {i})) ` p)"
1.986      apply -
1.987      apply (rule elementary_inters)
1.988      apply (rule finite_imageI[OF p(1)])
1.989 @@ -1051,10 +1158,12 @@
1.990    qed auto
1.991  qed
1.992
1.993 -lemma elementary_bounded[dest]: "p division_of s \<Longrightarrow> bounded (s::('a::ordered_euclidean_space) set)"
1.994 -  unfolding division_of_def by(metis bounded_Union bounded_interval)
1.995 -
1.996 -lemma elementary_subset_interval: "p division_of s \<Longrightarrow> \<exists>a b. s \<subseteq> {a..b::'a::ordered_euclidean_space}"
1.997 +lemma elementary_bounded[dest]:
1.998 +  "p division_of s \<Longrightarrow> bounded (s::('a::ordered_euclidean_space) set)"
1.999 +  unfolding division_of_def by(metis bounded_Union bounded_interval)
1.1000 +
1.1001 +lemma elementary_subset_interval:
1.1002 +  "p division_of s \<Longrightarrow> \<exists>a b. s \<subseteq> {a..b::'a::ordered_euclidean_space}"
1.1003    by (meson elementary_bounded bounded_subset_closed_interval)
1.1004
1.1005  lemma division_union_intervals_exists:
1.1006 @@ -1091,7 +1200,7 @@
1.1007      guess p apply (rule partial_division_extend_1[OF * False[unfolded uv]]) .
1.1008      note p=this division_ofD[OF this(1)]
1.1009      have *: "{a..b} \<union> {c..d} = {a..b} \<union> \<Union>(p - {{u..v}})" "\<And>x s. insert x s = {x} \<union> s"
1.1010 -      using p(8) unfolding uv[THEN sym] by auto
1.1011 +      using p(8) unfolding uv[symmetric] by auto
1.1012      show ?thesis
1.1013        apply (rule that[of "p - {{u..v}}"])
1.1014        unfolding *(1)
1.1015 @@ -1101,10 +1210,10 @@
1.1016        apply (rule division_of_subset[of p])
1.1017        apply (rule division_of_union_self[OF p(1)])
1.1018        defer
1.1019 -      unfolding interior_inter[THEN sym]
1.1020 +      unfolding interior_inter[symmetric]
1.1021      proof -
1.1022        have *: "\<And>cd p uv ab. p \<subseteq> cd \<Longrightarrow> ab \<inter> cd = uv \<Longrightarrow> ab \<inter> p = uv \<inter> p" by auto
1.1023 -      have "interior ({a..b} \<inter> \<Union>(p - {{u..v}})) = interior({u..v} \<inter> \<Union>(p - {{u..v}}))"
1.1024 +      have "interior ({a..b} \<inter> \<Union>(p - {{u..v}})) = interior({u..v} \<inter> \<Union>(p - {{u..v}}))"
1.1025          apply (rule arg_cong[of _ _ interior])
1.1026          apply (rule *[OF _ uv])
1.1027          using p(8)
1.1028 @@ -1121,116 +1230,296 @@
1.1029    qed
1.1030  qed
1.1031
1.1032 -lemma division_of_unions: assumes "finite f"  "\<And>p. p\<in>f \<Longrightarrow> p division_of (\<Union>p)"
1.1033 -  "\<And>k1 k2. \<lbrakk>k1 \<in> \<Union>f; k2 \<in> \<Union>f; k1 \<noteq> k2\<rbrakk> \<Longrightarrow> interior k1 \<inter> interior k2 = {}"
1.1034 -  shows "\<Union>f division_of \<Union>\<Union>f" apply(rule division_ofI) prefer 5 apply(rule assms(3)|assumption)+
1.1035 -  apply(rule finite_Union assms(1))+ prefer 3 apply(erule UnionE) apply(rule_tac s=X in division_ofD(3)[OF assms(2)])
1.1036 -  using division_ofD[OF assms(2)] by auto
1.1037 -
1.1038 -lemma elementary_union_interval: assumes "p division_of \<Union>p"
1.1039 -  obtains q where "q division_of ({a..b::'a::ordered_euclidean_space} \<union> \<Union>p)" proof-
1.1040 -  note assm=division_ofD[OF assms]
1.1041 -  have lem1:"\<And>f s. \<Union>\<Union> (f ` s) = \<Union>((\<lambda>x.\<Union>(f x)) ` s)" by auto
1.1042 -  have lem2:"\<And>f s. f \<noteq> {} \<Longrightarrow> \<Union>{s \<union> t |t. t \<in> f} = s \<union> \<Union>f" by auto
1.1043 -{ presume "p={} \<Longrightarrow> thesis" "{a..b} = {} \<Longrightarrow> thesis" "{a..b} \<noteq> {} \<Longrightarrow> interior {a..b} = {} \<Longrightarrow> thesis"
1.1044 -    "p\<noteq>{} \<Longrightarrow> interior {a..b}\<noteq>{} \<Longrightarrow> {a..b} \<noteq> {} \<Longrightarrow> thesis"
1.1045 -  thus thesis by auto
1.1046 -next assume as:"p={}" guess p apply(rule elementary_interval[of a b]) .
1.1047 -  thus thesis apply(rule_tac that[of p]) unfolding as by auto
1.1048 -next assume as:"{a..b}={}" show thesis apply(rule that) unfolding as using assms by auto
1.1049 -next assume as:"interior {a..b} = {}" "{a..b} \<noteq> {}"
1.1050 -  show thesis apply(rule that[of "insert {a..b} p"],rule division_ofI)
1.1051 -    unfolding finite_insert apply(rule assm(1)) unfolding Union_insert
1.1052 -    using assm(2-4) as apply- by(fastforce dest: assm(5))+
1.1053 -next assume as:"p \<noteq> {}" "interior {a..b} \<noteq> {}" "{a..b}\<noteq>{}"
1.1054 -  have "\<forall>k\<in>p. \<exists>q. (insert {a..b} q) division_of ({a..b} \<union> k)" proof case goal1
1.1055 -    from assm(4)[OF this] guess c .. then guess d ..
1.1056 -    thus ?case apply-apply(rule division_union_intervals_exists[OF as(3),of c d]) by auto
1.1057 -  qed from bchoice[OF this] guess q .. note q=division_ofD[OF this[rule_format]]
1.1058 -  let ?D = "\<Union>{insert {a..b} (q k) | k. k \<in> p}"
1.1059 -  show thesis apply(rule that[of "?D"]) proof(rule division_ofI)
1.1060 -    have *:"{insert {a..b} (q k) |k. k \<in> p} = (\<lambda>k. insert {a..b} (q k)) ` p" by auto
1.1061 -    show "finite ?D" apply(rule finite_Union) unfolding * apply(rule finite_imageI) using assm(1) q(1) by auto
1.1062 -    show "\<Union>?D = {a..b} \<union> \<Union>p" unfolding * lem1 unfolding lem2[OF as(1), of "{a..b}",THEN sym]
1.1063 -      using q(6) by auto
1.1064 -    fix k assume k:"k\<in>?D" thus " k \<subseteq> {a..b} \<union> \<Union>p" using q(2) by auto
1.1065 -    show "k \<noteq> {}" using q(3) k by auto show "\<exists>a b. k = {a..b}" using q(4) k by auto
1.1066 -    fix k' assume k':"k'\<in>?D" "k\<noteq>k'"
1.1067 -    obtain x  where x: "k \<in>insert {a..b} (q x)"  "x\<in>p"  using k  by auto
1.1068 -    obtain x' where x':"k'\<in>insert {a..b} (q x')" "x'\<in>p" using k' by auto
1.1069 -    show "interior k \<inter> interior k' = {}" proof(cases "x=x'")
1.1070 -      case True show ?thesis apply(rule q(5)) using x x' k' unfolding True by auto
1.1071 -    next case False
1.1072 -      { presume "k = {a..b} \<Longrightarrow> ?thesis" "k' = {a..b} \<Longrightarrow> ?thesis"
1.1073 -        "k \<noteq> {a..b} \<Longrightarrow> k' \<noteq> {a..b} \<Longrightarrow> ?thesis"
1.1074 -        thus ?thesis by auto }
1.1075 -      { assume as':"k  = {a..b}" show ?thesis apply(rule q(5)) using x' k'(2) unfolding as' by auto }
1.1076 -      { assume as':"k' = {a..b}" show ?thesis apply(rule q(5)) using x  k'(2) unfolding as' by auto }
1.1077 -      assume as':"k \<noteq> {a..b}" "k' \<noteq> {a..b}"
1.1078 -      guess c using q(4)[OF x(2,1)] .. then guess d .. note c_d=this
1.1079 -      have "interior k  \<inter> interior {a..b} = {}" apply(rule q(5)) using x  k'(2) using as' by auto
1.1080 -      hence "interior k \<subseteq> interior x" apply-
1.1081 -        apply(rule interior_subset_union_intervals[OF c_d _ as(2) q(2)[OF x(2,1)]]) by auto moreover
1.1082 -      guess c using q(4)[OF x'(2,1)] .. then guess d .. note c_d=this
1.1083 -      have "interior k' \<inter> interior {a..b} = {}" apply(rule q(5)) using x' k'(2) using as' by auto
1.1084 -      hence "interior k' \<subseteq> interior x'" apply-
1.1085 -        apply(rule interior_subset_union_intervals[OF c_d _ as(2) q(2)[OF x'(2,1)]]) by auto
1.1086 -      ultimately show ?thesis using assm(5)[OF x(2) x'(2) False] by auto
1.1087 -    qed qed } qed
1.1088 +lemma division_of_unions:
1.1089 +  assumes "finite f"
1.1090 +    and "\<And>p. p\<in>f \<Longrightarrow> p division_of (\<Union>p)"
1.1091 +    and "\<And>k1 k2. k1 \<in> \<Union>f \<Longrightarrow> k2 \<in> \<Union>f \<Longrightarrow> k1 \<noteq> k2 \<Longrightarrow> interior k1 \<inter> interior k2 = {}"
1.1092 +  shows "\<Union>f division_of \<Union>\<Union>f"
1.1093 +  apply (rule division_ofI)
1.1094 +  prefer 5
1.1095 +  apply (rule assms(3)|assumption)+
1.1096 +  apply (rule finite_Union assms(1))+
1.1097 +  prefer 3
1.1098 +  apply (erule UnionE)
1.1099 +  apply (rule_tac s=X in division_ofD(3)[OF assms(2)])
1.1100 +  using division_ofD[OF assms(2)]
1.1101 +  apply auto
1.1102 +  done
1.1103 +
1.1104 +lemma elementary_union_interval:
1.1105 +  assumes "p division_of \<Union>p"
1.1106 +  obtains q where "q division_of ({a..b::'a::ordered_euclidean_space} \<union> \<Union>p)"
1.1107 +proof -
1.1108 +  note assm = division_ofD[OF assms]
1.1109 +  have lem1: "\<And>f s. \<Union>\<Union> (f ` s) = \<Union>((\<lambda>x.\<Union>(f x)) ` s)"
1.1110 +    by auto
1.1111 +  have lem2: "\<And>f s. f \<noteq> {} \<Longrightarrow> \<Union>{s \<union> t |t. t \<in> f} = s \<union> \<Union>f"
1.1112 +    by auto
1.1113 +  {
1.1114 +    presume "p = {} \<Longrightarrow> thesis"
1.1115 +      "{a..b} = {} \<Longrightarrow> thesis"
1.1116 +      "{a..b} \<noteq> {} \<Longrightarrow> interior {a..b} = {} \<Longrightarrow> thesis"
1.1117 +      "p \<noteq> {} \<Longrightarrow> interior {a..b}\<noteq>{} \<Longrightarrow> {a..b} \<noteq> {} \<Longrightarrow> thesis"
1.1118 +    then show thesis by auto
1.1119 +  next
1.1120 +    assume as: "p = {}"
1.1121 +    guess p by (rule elementary_interval[of a b])
1.1122 +    then show thesis
1.1123 +      apply (rule_tac that[of p])
1.1124 +      unfolding as
1.1125 +      apply auto
1.1126 +      done
1.1127 +  next
1.1128 +    assume as: "{a..b} = {}"
1.1129 +    show thesis
1.1130 +      apply (rule that)
1.1131 +      unfolding as
1.1132 +      using assms
1.1133 +      apply auto
1.1134 +      done
1.1135 +  next
1.1136 +    assume as: "interior {a..b} = {}" "{a..b} \<noteq> {}"
1.1137 +    show thesis
1.1138 +      apply (rule that[of "insert {a..b} p"],rule division_ofI)
1.1139 +      unfolding finite_insert
1.1140 +      apply (rule assm(1)) unfolding Union_insert
1.1141 +      using assm(2-4) as
1.1142 +      apply -
1.1143 +      apply (fastforce dest: assm(5))+
1.1144 +      done
1.1145 +  next
1.1146 +    assume as: "p \<noteq> {}" "interior {a..b} \<noteq> {}" "{a..b} \<noteq> {}"
1.1147 +    have "\<forall>k\<in>p. \<exists>q. (insert {a..b} q) division_of ({a..b} \<union> k)"
1.1148 +    proof
1.1149 +      case goal1
1.1150 +      from assm(4)[OF this] guess c .. then guess d ..
1.1151 +      then show ?case
1.1152 +        apply -
1.1153 +        apply (rule division_union_intervals_exists[OF as(3),of c d])
1.1154 +        apply auto
1.1155 +        done
1.1156 +    qed
1.1157 +    from bchoice[OF this] guess q .. note q=division_ofD[OF this[rule_format]]
1.1158 +    let ?D = "\<Union>{insert {a..b} (q k) | k. k \<in> p}"
1.1159 +    show thesis
1.1160 +      apply (rule that[of "?D"])
1.1161 +    proof (rule division_ofI)
1.1162 +      have *: "{insert {a..b} (q k) |k. k \<in> p} = (\<lambda>k. insert {a..b} (q k)) ` p"
1.1163 +        by auto
1.1164 +      show "finite ?D"
1.1165 +        apply (rule finite_Union)
1.1166 +        unfolding *
1.1167 +        apply (rule finite_imageI)
1.1168 +        using assm(1) q(1)
1.1169 +        apply auto
1.1170 +        done
1.1171 +      show "\<Union>?D = {a..b} \<union> \<Union>p"
1.1172 +        unfolding * lem1
1.1173 +        unfolding lem2[OF as(1), of "{a..b}",symmetric]
1.1174 +        using q(6)
1.1175 +        by auto
1.1176 +      fix k
1.1177 +      assume k: "k\<in>?D"
1.1178 +      then show "k \<subseteq> {a..b} \<union> \<Union>p" using q(2) by auto
1.1179 +      show "k \<noteq> {}"
1.1180 +        using q(3) k by auto show "\<exists>a b. k = {a..b}" using q(4) k by auto
1.1181 +      fix k'
1.1182 +      assume k': "k'\<in>?D" "k\<noteq>k'"
1.1183 +      obtain x  where x: "k \<in>insert {a..b} (q x)"  "x\<in>p"
1.1184 +        using k  by auto
1.1185 +      obtain x' where x': "k'\<in>insert {a..b} (q x')" "x'\<in>p"
1.1186 +        using k' by auto
1.1187 +      show "interior k \<inter> interior k' = {}"
1.1188 +      proof (cases "x = x'")
1.1189 +        case True
1.1190 +        show ?thesis
1.1191 +          apply(rule q(5))
1.1192 +          using x x' k'
1.1193 +          unfolding True
1.1194 +          apply auto
1.1195 +          done
1.1196 +      next
1.1197 +        case False
1.1198 +        {
1.1199 +          presume "k = {a..b} \<Longrightarrow> ?thesis"
1.1200 +            and "k' = {a..b} \<Longrightarrow> ?thesis"
1.1201 +            and "k \<noteq> {a..b} \<Longrightarrow> k' \<noteq> {a..b} \<Longrightarrow> ?thesis"
1.1202 +          then show ?thesis by auto
1.1203 +        next
1.1204 +          assume as': "k  = {a..b}"
1.1205 +          show ?thesis
1.1206 +            apply (rule q(5)) using x' k'(2) unfolding as' by auto
1.1207 +        next
1.1208 +          assume as': "k' = {a..b}"
1.1209 +          show ?thesis
1.1210 +            apply (rule q(5))
1.1211 +            using x  k'(2)
1.1212 +            unfolding as'
1.1213 +            apply auto
1.1214 +            done
1.1215 +        }
1.1216 +        assume as': "k \<noteq> {a..b}" "k' \<noteq> {a..b}"
1.1217 +        guess c using q(4)[OF x(2,1)] ..
1.1218 +        then guess d .. note c_d=this
1.1219 +        have "interior k  \<inter> interior {a..b} = {}"
1.1220 +          apply(rule q(5))
1.1221 +          using x  k'(2)
1.1222 +          using as'
1.1223 +          apply auto
1.1224 +          done
1.1225 +        then have "interior k \<subseteq> interior x"
1.1226 +          apply -
1.1227 +          apply (rule interior_subset_union_intervals[OF c_d _ as(2) q(2)[OF x(2,1)]])
1.1228 +          apply auto
1.1229 +          done
1.1230 +        moreover
1.1231 +        guess c using q(4)[OF x'(2,1)] .. then guess d .. note c_d=this
1.1232 +        have "interior k' \<inter> interior {a..b} = {}"
1.1233 +          apply (rule q(5))
1.1234 +          using x' k'(2)
1.1235 +          using as'
1.1236 +          apply auto
1.1237 +          done
1.1238 +        then have "interior k' \<subseteq> interior x'"
1.1239 +          apply -
1.1240 +          apply (rule interior_subset_union_intervals[OF c_d _ as(2) q(2)[OF x'(2,1)]])
1.1241 +          apply auto
1.1242 +          done
1.1243 +        ultimately show ?thesis
1.1244 +          using assm(5)[OF x(2) x'(2) False] by auto
1.1245 +      qed
1.1246 +    qed
1.1247 +  }
1.1248 +qed
1.1249
1.1250  lemma elementary_unions_intervals:
1.1251 -  assumes "finite f" "\<And>s. s \<in> f \<Longrightarrow> \<exists>a b. s = {a..b::'a::ordered_euclidean_space}"
1.1252 -  obtains p where "p division_of (\<Union>f)" proof-
1.1253 -  have "\<exists>p. p division_of (\<Union>f)" proof(induct_tac f rule:finite_subset_induct)
1.1254 +  assumes fin: "finite f"
1.1255 +    and "\<And>s. s \<in> f \<Longrightarrow> \<exists>a b. s = {a..b::'a::ordered_euclidean_space}"
1.1256 +  obtains p where "p division_of (\<Union>f)"
1.1257 +proof -
1.1258 +  have "\<exists>p. p division_of (\<Union>f)"
1.1259 +  proof (induct_tac f rule:finite_subset_induct)
1.1260      show "\<exists>p. p division_of \<Union>{}" using elementary_empty by auto
1.1261 -    fix x F assume as:"finite F" "x \<notin> F" "\<exists>p. p division_of \<Union>F" "x\<in>f"
1.1262 +  next
1.1263 +    fix x F
1.1264 +    assume as: "finite F" "x \<notin> F" "\<exists>p. p division_of \<Union>F" "x\<in>f"
1.1265      from this(3) guess p .. note p=this
1.1266      from assms(2)[OF as(4)] guess a .. then guess b .. note ab=this
1.1267 -    have *:"\<Union>F = \<Union>p" using division_ofD[OF p] by auto
1.1268 -    show "\<exists>p. p division_of \<Union>insert x F" using elementary_union_interval[OF p[unfolded *], of a b]
1.1269 +    have *: "\<Union>F = \<Union>p"
1.1270 +      using division_ofD[OF p] by auto
1.1271 +    show "\<exists>p. p division_of \<Union>insert x F"
1.1272 +      using elementary_union_interval[OF p[unfolded *], of a b]
1.1273        unfolding Union_insert ab * by auto
1.1274 -  qed(insert assms,auto) thus ?thesis apply-apply(erule exE,rule that) by auto qed
1.1275 -
1.1276 -lemma elementary_union: assumes "ps division_of s" "pt division_of (t::('a::ordered_euclidean_space) set)"
1.1277 +  qed(insert assms, auto)
1.1278 +  then show ?thesis
1.1279 +    apply -
1.1280 +    apply (erule exE)
1.1281 +    apply (rule that)
1.1282 +    apply auto
1.1283 +    done
1.1284 +qed
1.1285 +
1.1286 +lemma elementary_union:
1.1287 +  assumes "ps division_of s"
1.1288 +    and "pt division_of (t::('a::ordered_euclidean_space) set)"
1.1289    obtains p where "p division_of (s \<union> t)"
1.1290 -proof- have "s \<union> t = \<Union>ps \<union> \<Union>pt" using assms unfolding division_of_def by auto
1.1291 -  hence *:"\<Union>(ps \<union> pt) = s \<union> t" by auto
1.1292 -  show ?thesis apply-apply(rule elementary_unions_intervals[of "ps\<union>pt"])
1.1293 -    unfolding * prefer 3 apply(rule_tac p=p in that)
1.1294 -    using assms[unfolded division_of_def] by auto qed
1.1295 -
1.1296 -lemma partial_division_extend: fixes t::"('a::ordered_euclidean_space) set"
1.1297 -  assumes "p division_of s" "q division_of t" "s \<subseteq> t"
1.1298 -  obtains r where "p \<subseteq> r" "r division_of t" proof-
1.1299 +proof -
1.1300 +  have "s \<union> t = \<Union>ps \<union> \<Union>pt"
1.1301 +    using assms unfolding division_of_def by auto
1.1302 +  then have *: "\<Union>(ps \<union> pt) = s \<union> t" by auto
1.1303 +  show ?thesis
1.1304 +    apply -
1.1305 +    apply (rule elementary_unions_intervals[of "ps\<union>pt"])
1.1306 +    unfolding *
1.1307 +    prefer 3
1.1308 +    apply (rule_tac p=p in that)
1.1309 +    using assms[unfolded division_of_def]
1.1310 +    apply auto
1.1311 +    done
1.1312 +qed
1.1313 +
1.1314 +lemma partial_division_extend:
1.1315 +  fixes t :: "'a::ordered_euclidean_space set"
1.1316 +  assumes "p division_of s"
1.1317 +    and "q division_of t"
1.1318 +    and "s \<subseteq> t"
1.1319 +  obtains r where "p \<subseteq> r" and "r division_of t"
1.1320 +proof -
1.1321    note divp = division_ofD[OF assms(1)] and divq = division_ofD[OF assms(2)]
1.1322 -  obtain a b where ab:"t\<subseteq>{a..b}" using elementary_subset_interval[OF assms(2)] by auto
1.1323 -  guess r1 apply(rule partial_division_extend_interval) apply(rule assms(1)[unfolded divp(6)[THEN sym]])
1.1324 -    apply(rule subset_trans) by(rule ab assms[unfolded divp(6)[THEN sym]])+  note r1 = this division_ofD[OF this(2)]
1.1325 -  guess p' apply(rule elementary_unions_intervals[of "r1 - p"]) using r1(3,6) by auto
1.1326 -  then obtain r2 where r2:"r2 division_of (\<Union>(r1 - p)) \<inter> (\<Union>q)"
1.1327 -    apply- apply(drule elementary_inter[OF _ assms(2)[unfolded divq(6)[THEN sym]]]) by auto
1.1328 -  { fix x assume x:"x\<in>t" "x\<notin>s"
1.1329 -    hence "x\<in>\<Union>r1" unfolding r1 using ab by auto
1.1330 -    then guess r unfolding Union_iff .. note r=this moreover
1.1331 -    have "r \<notin> p" proof assume "r\<in>p" hence "x\<in>s" using divp(2) r by auto
1.1332 -      thus False using x by auto qed
1.1333 -    ultimately have "x\<in>\<Union>(r1 - p)" by auto }
1.1334 -  hence *:"t = \<Union>p \<union> (\<Union>(r1 - p) \<inter> \<Union>q)" unfolding divp divq using assms(3) by auto
1.1335 -  show ?thesis apply(rule that[of "p \<union> r2"]) unfolding * defer apply(rule division_disjoint_union)
1.1336 -    unfolding divp(6) apply(rule assms r2)+
1.1337 -  proof- have "interior s \<inter> interior (\<Union>(r1-p)) = {}"
1.1338 -    proof(rule inter_interior_unions_intervals)
1.1339 -      show "finite (r1 - p)" "open (interior s)" "\<forall>t\<in>r1-p. \<exists>a b. t = {a..b}" using r1 by auto
1.1340 -      have *:"\<And>s. (\<And>x. x \<in> s \<Longrightarrow> False) \<Longrightarrow> s = {}" by auto
1.1341 -      show "\<forall>t\<in>r1-p. interior s \<inter> interior t = {}" proof(rule)
1.1342 -        fix m x assume as:"m\<in>r1-p"
1.1343 -        have "interior m \<inter> interior (\<Union>p) = {}" proof(rule inter_interior_unions_intervals)
1.1344 -          show "finite p" "open (interior m)" "\<forall>t\<in>p. \<exists>a b. t = {a..b}" using divp by auto
1.1345 -          show "\<forall>t\<in>p. interior m \<inter> interior t = {}" apply(rule, rule r1(7)) using as using r1 by auto
1.1346 -        qed thus "interior s \<inter> interior m = {}" unfolding divp by auto
1.1347 -      qed qed
1.1348 -    thus "interior s \<inter> interior (\<Union>(r1-p) \<inter> (\<Union>q)) = {}" using interior_subset by auto
1.1349 -  qed auto qed
1.1350 +  obtain a b where ab: "t \<subseteq> {a..b}"
1.1351 +    using elementary_subset_interval[OF assms(2)] by auto
1.1352 +  guess r1
1.1353 +    apply (rule partial_division_extend_interval)
1.1354 +    apply (rule assms(1)[unfolded divp(6)[symmetric]])
1.1355 +    apply (rule subset_trans)
1.1356 +    apply (rule ab assms[unfolded divp(6)[symmetric]])+
1.1357 +    done
1.1358 +  note r1 = this division_ofD[OF this(2)]
1.1359 +  guess p'
1.1360 +    apply (rule elementary_unions_intervals[of "r1 - p"])
1.1361 +    using r1(3,6)
1.1362 +    apply auto
1.1363 +    done
1.1364 +  then obtain r2 where r2: "r2 division_of (\<Union>(r1 - p)) \<inter> (\<Union>q)"
1.1365 +    apply -
1.1366 +    apply (drule elementary_inter[OF _ assms(2)[unfolded divq(6)[symmetric]]])
1.1367 +    apply auto
1.1368 +    done
1.1369 +  {
1.1370 +    fix x
1.1371 +    assume x: "x \<in> t" "x \<notin> s"
1.1372 +    then have "x\<in>\<Union>r1"
1.1373 +      unfolding r1 using ab by auto
1.1374 +    then guess r unfolding Union_iff .. note r=this
1.1375 +    moreover
1.1376 +    have "r \<notin> p"
1.1377 +    proof
1.1378 +      assume "r \<in> p"
1.1379 +      then have "x \<in> s" using divp(2) r by auto
1.1380 +      then show False using x by auto
1.1381 +    qed
1.1382 +    ultimately have "x\<in>\<Union>(r1 - p)" by auto
1.1383 +  }
1.1384 +  then have *: "t = \<Union>p \<union> (\<Union>(r1 - p) \<inter> \<Union>q)"
1.1385 +    unfolding divp divq using assms(3) by auto
1.1386 +  show ?thesis
1.1387 +    apply (rule that[of "p \<union> r2"])
1.1388 +    unfolding *
1.1389 +    defer
1.1390 +    apply (rule division_disjoint_union)
1.1391 +    unfolding divp(6)
1.1392 +    apply(rule assms r2)+
1.1393 +  proof -
1.1394 +    have "interior s \<inter> interior (\<Union>(r1-p)) = {}"
1.1395 +    proof (rule inter_interior_unions_intervals)
1.1396 +      show "finite (r1 - p)" and "open (interior s)" "\<forall>t\<in>r1-p. \<exists>a b. t = {a..b}"
1.1397 +        using r1 by auto
1.1398 +      have *: "\<And>s. (\<And>x. x \<in> s \<Longrightarrow> False) \<Longrightarrow> s = {}"
1.1399 +        by auto
1.1400 +      show "\<forall>t\<in>r1-p. interior s \<inter> interior t = {}"
1.1401 +      proof
1.1402 +        fix m x
1.1403 +        assume as: "m \<in> r1 - p"
1.1404 +        have "interior m \<inter> interior (\<Union>p) = {}"
1.1405 +        proof (rule inter_interior_unions_intervals)
1.1406 +          show "finite p" and "open (interior m)" and "\<forall>t\<in>p. \<exists>a b. t = {a..b}"
1.1407 +            using divp by auto
1.1408 +          show "\<forall>t\<in>p. interior m \<inter> interior t = {}"
1.1409 +            apply (rule, rule r1(7))
1.1410 +            using as
1.1411 +            using r1
1.1412 +            apply auto
1.1413 +            done
1.1414 +        qed
1.1415 +        then show "interior s \<inter> interior m = {}"
1.1416 +          unfolding divp by auto
1.1417 +      qed
1.1418 +    qed
1.1419 +    then show "interior s \<inter> interior (\<Union>(r1-p) \<inter> (\<Union>q)) = {}"
1.1420 +      using interior_subset by auto
1.1421 +  qed auto
1.1422 +qed
1.1423 +
1.1424
1.1425  subsection {* Tagged (partial) divisions. *}
1.1426
1.1427 @@ -1245,7 +1534,7 @@
1.1428    shows "finite s" "\<And>x k. (x,k) \<in> s \<Longrightarrow> x \<in> k" "\<And>x k. (x,k) \<in> s \<Longrightarrow> k \<subseteq> i"
1.1429    "\<And>x k. (x,k) \<in> s \<Longrightarrow> \<exists>a b. k = {a..b}"
1.1430    "\<And>x1 k1 x2 k2. (x1,k1) \<in> s \<Longrightarrow> (x2,k2) \<in> s \<Longrightarrow> (x1,k1) \<noteq> (x2,k2) \<Longrightarrow> interior(k1) \<inter> interior(k2) = {}"
1.1431 -  using assms unfolding tagged_partial_division_of_def  apply- by blast+
1.1432 +  using assms unfolding tagged_partial_division_of_def  apply- by blast+
1.1433
1.1434  definition tagged_division_of (infixr "tagged'_division'_of" 40) where
1.1435    "(s tagged_division_of i) \<equiv>
1.1436 @@ -1309,12 +1598,12 @@
1.1437    have *:"(\<lambda>(x,k). d k) = d \<circ> snd" unfolding o_def apply(rule ext) by auto
1.1438    show ?thesis unfolding * apply(subst eq_commute) proof(rule setsum_reindex_nonzero)
1.1439      show "finite p" using assm by auto
1.1440 -    fix x y assume as:"x\<in>p" "y\<in>p" "x\<noteq>y" "snd x = snd y"
1.1441 +    fix x y assume as:"x\<in>p" "y\<in>p" "x\<noteq>y" "snd x = snd y"
1.1442      obtain a b where ab:"snd x = {a..b}" using assm(4)[of "fst x" "snd x"] as(1) by auto
1.1443 -    have "(fst x, snd y) \<in> p" "(fst x, snd y) \<noteq> y" unfolding as(4)[THEN sym] using as(1-3) by auto
1.1444 -    hence "interior (snd x) \<inter> interior (snd y) = {}" apply-apply(rule assm(5)[of "fst x" _ "fst y"]) using as by auto
1.1445 -    hence "content {a..b} = 0" unfolding as(4)[THEN sym] ab content_eq_0_interior by auto
1.1446 -    hence "d {a..b} = 0" apply-apply(rule assms(2)) using assm(2)[of "fst x" "snd x"] as(1) unfolding ab[THEN sym] by auto
1.1447 +    have "(fst x, snd y) \<in> p" "(fst x, snd y) \<noteq> y" unfolding as(4)[symmetric] using as(1-3) by auto
1.1448 +    hence "interior (snd x) \<inter> interior (snd y) = {}" apply-apply(rule assm(5)[of "fst x" _ "fst y"]) using as by auto
1.1449 +    hence "content {a..b} = 0" unfolding as(4)[symmetric] ab content_eq_0_interior by auto
1.1450 +    hence "d {a..b} = 0" apply-apply(rule assms(2)) using assm(2)[of "fst x" "snd x"] as(1) unfolding ab[symmetric] by auto
1.1451      thus "d (snd x) = 0" unfolding ab by auto qed qed
1.1452
1.1453  lemma tag_in_interval: "p tagged_division_of i \<Longrightarrow> (x,k) \<in> p \<Longrightarrow> x \<in> i" by auto
1.1454 @@ -1346,7 +1635,7 @@
1.1455    have *:"\<And>a b. a\<subseteq> s1 \<Longrightarrow> b\<subseteq> s2 \<Longrightarrow> interior a \<inter> interior b = {}" using assms(3) interior_mono by blast
1.1456    show "interior k \<inter> interior k' = {}" apply(cases "(x,k)\<in>p1", case_tac[!] "(x',k')\<in>p1")
1.1457      apply(rule p1(5)) prefer 4 apply(rule *) prefer 6 apply(subst Int_commute,rule *) prefer 8 apply(rule p2(5))
1.1458 -    using p1(3) p2(3) using xk xk' by auto qed
1.1459 +    using p1(3) p2(3) using xk xk' by auto qed
1.1460
1.1461  lemma tagged_division_unions:
1.1462    assumes "finite iset" "\<forall>i\<in>iset. (pfn(i) tagged_division_of i)"
1.1463 @@ -1355,9 +1644,9 @@
1.1464  proof(rule tagged_division_ofI)
1.1465    note assm = tagged_division_ofD[OF assms(2)[rule_format]]
1.1466    show "finite (\<Union>(pfn ` iset))" apply(rule finite_Union) using assms by auto
1.1467 -  have "\<Union>{k. \<exists>x. (x, k) \<in> \<Union>(pfn ` iset)} = \<Union>((\<lambda>i. \<Union>{k. \<exists>x. (x, k) \<in> pfn i}) ` iset)" by blast
1.1468 +  have "\<Union>{k. \<exists>x. (x, k) \<in> \<Union>(pfn ` iset)} = \<Union>((\<lambda>i. \<Union>{k. \<exists>x. (x, k) \<in> pfn i}) ` iset)" by blast
1.1469    also have "\<dots> = \<Union>iset" using assm(6) by auto
1.1470 -  finally show "\<Union>{k. \<exists>x. (x, k) \<in> \<Union>(pfn ` iset)} = \<Union>iset" .
1.1471 +  finally show "\<Union>{k. \<exists>x. (x, k) \<in> \<Union>(pfn ` iset)} = \<Union>iset" .
1.1472    fix x k assume xk:"(x,k)\<in>\<Union>(pfn ` iset)" then obtain i where i:"i \<in> iset" "(x, k) \<in> pfn i" by auto
1.1473    show "x\<in>k" "\<exists>a b. k = {a..b}" "k \<subseteq> \<Union>iset" using assm(2-4)[OF i] using i(1) by auto
1.1474    fix x' k' assume xk':"(x',k')\<in>\<Union>(pfn ` iset)" "(x, k) \<noteq> (x', k')" then obtain i' where i':"i' \<in> iset" "(x', k') \<in> pfn i'" by auto
1.1475 @@ -1411,7 +1700,7 @@
1.1476            (\<forall>p. p tagged_division_of i \<and> d fine p
1.1477                          \<longrightarrow> norm(setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - y) < e))"
1.1478
1.1479 -definition has_integral (infixr "has'_integral" 46) where
1.1480 +definition has_integral (infixr "has'_integral" 46) where
1.1481  "((f::('n::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector)) has_integral y) i \<equiv>
1.1482          if (\<exists>a b. i = {a..b}) then (f has_integral_compact_interval y) i
1.1483          else (\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b}
1.1484 @@ -1479,8 +1768,8 @@
1.1485    "\<forall>i1\<in>iset. \<forall>i2\<in>iset. ~(i1 = i2) \<longrightarrow> (interior(i1) \<inter> interior(i2) = {})" "(\<Union>iset = i)"
1.1486     obtains p where "p tagged_division_of i" "d fine p"
1.1487  proof- guess pfn using bchoice[OF assms(2)] .. note pfn = conjunctD2[OF this[rule_format]]
1.1488 -  show thesis apply(rule_tac p="\<Union>(pfn ` iset)" in that) unfolding assms(4)[THEN sym]
1.1489 -    apply(rule tagged_division_unions[OF assms(1) _ assms(3)]) defer
1.1490 +  show thesis apply(rule_tac p="\<Union>(pfn ` iset)" in that) unfolding assms(4)[symmetric]
1.1491 +    apply(rule tagged_division_unions[OF assms(1) _ assms(3)]) defer
1.1492      apply(rule fine_unions) using pfn by auto
1.1493  qed
1.1494
1.1495 @@ -1512,7 +1801,7 @@
1.1496    { presume "\<forall>c d. ?PP c d \<longrightarrow> P {c..d} \<Longrightarrow> False"
1.1497      thus thesis unfolding atomize_not not_all apply-apply(erule exE)+ apply(rule_tac c=x and d=xa in that) by auto }
1.1498    assume as:"\<forall>c d. ?PP c d \<longrightarrow> P {c..d}"
1.1499 -  have "P (\<Union> ?A)" proof(rule *, rule_tac[2-] ballI, rule_tac[4] ballI, rule_tac[4] impI)
1.1500 +  have "P (\<Union> ?A)" proof(rule *, rule_tac[2-] ballI, rule_tac[4] ballI, rule_tac[4] impI)
1.1501      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 ..
1.1502        (\<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}"
1.1503      have "?A \<subseteq> ?B" proof case goal1
1.1504 @@ -1534,7 +1823,7 @@
1.1505      thus "finite ?A" apply(rule finite_subset) by auto
1.1506      fix s assume "s\<in>?A" then guess c unfolding mem_Collect_eq .. then guess d apply- by(erule exE,(erule conjE)+)
1.1507      note c_d=this[rule_format]
1.1508 -    show "P s" unfolding c_d apply(rule as[rule_format]) proof- case goal1 thus ?case
1.1509 +    show "P s" unfolding c_d apply(rule as[rule_format]) proof- case goal1 thus ?case
1.1510          using c_d(2)[of i] using ab[OF `i \<in> Basis`] by auto qed
1.1511      show "\<exists>a b. s = {a..b}" unfolding c_d by auto
1.1512      fix t assume "t\<in>?A" then guess e unfolding mem_Collect_eq .. then guess f apply- by(erule exE,(erule conjE)+)
1.1513 @@ -1585,12 +1874,12 @@
1.1514                             2 * (snd y\<bullet>i - fst y\<bullet>i) \<le> snd x\<bullet>i - fst x\<bullet>i))" proof case goal1 thus ?case proof-
1.1515        presume "\<not> P {fst x..snd x} \<Longrightarrow> ?thesis"
1.1516        thus ?thesis apply(cases "P {fst x..snd x}") by auto
1.1517 -    next assume as:"\<not> P {fst x..snd x}" from interval_bisection_step[of P, OF assms(1-2) as] guess c d .
1.1518 +    next assume as:"\<not> P {fst x..snd x}" from interval_bisection_step[of P, OF assms(1-2) as] guess c d .
1.1519        thus ?thesis apply- apply(rule_tac x="(c,d)" in exI) by auto
1.1520      qed qed then guess f apply-apply(drule choice) by(erule exE) note f=this
1.1521    def AB \<equiv> "\<lambda>n. (f ^^ n) (a,b)" def A \<equiv> "\<lambda>n. fst(AB n)" and B \<equiv> "\<lambda>n. snd(AB n)" note ab_def = this AB_def
1.1522    have "A 0 = a" "B 0 = b" "\<And>n. \<not> P {A(Suc n)..B(Suc n)} \<and>
1.1523 -    (\<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>
1.1524 +    (\<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>
1.1525      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")
1.1526    proof- show "A 0 = a" "B 0 = b" unfolding ab_def by auto
1.1527      case goal3 note S = ab_def funpow.simps o_def id_apply show ?case
1.1528 @@ -1620,7 +1909,7 @@
1.1529      proof(induct rule: inc_induct)
1.1530        case (step i) show ?case
1.1531          using AB(4) by (intro order_trans[OF step(2)] subset_interval_imp) auto
1.1532 -    qed simp } note ABsubset = this
1.1533 +    qed simp } note ABsubset = this
1.1534    have "\<exists>a. \<forall>n. a\<in>{A n..B n}" apply(rule decreasing_closed_nest[rule_format,OF closed_interval _ ABsubset interv])
1.1535    proof- fix n show "{A n..B n} \<noteq> {}" apply(cases "0<n") using AB(3)[of "n - 1"] assms(1,3) AB(1-2) by auto qed auto
1.1536    then guess x0 .. note x0=this[rule_format]
1.1537 @@ -1628,15 +1917,15 @@
1.1538      show "x0\<in>{a..b}" using x0[of 0] unfolding AB .
1.1539      fix e assume "0 < (e::real)" from interv[OF this] guess n .. note n=this
1.1540      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}"
1.1541 -      apply(rule_tac x="A n" in exI,rule_tac x="B n" in exI) apply(rule,rule x0) apply rule defer
1.1542 +      apply(rule_tac x="A n" in exI,rule_tac x="B n" in exI) apply(rule,rule x0) apply rule defer
1.1543      proof show "\<not> P {A n..B n}" apply(cases "0<n") using AB(3)[of "n - 1"] assms(3) AB(1-2) by auto
1.1544        show "{A n..B n} \<subseteq> ball x0 e" using n using x0[of n] by auto
1.1545        show "{A n..B n} \<subseteq> {a..b}" unfolding AB(1-2)[symmetric] apply(rule ABsubset) by auto
1.1546 -    qed qed qed
1.1547 +    qed qed qed
1.1548
1.1549  subsection {* Cousin's lemma. *}
1.1550
1.1551 -lemma fine_division_exists: assumes "gauge g"
1.1552 +lemma fine_division_exists: assumes "gauge g"
1.1553    obtains p where "p tagged_division_of {a..b::'a::ordered_euclidean_space}" "g fine p"
1.1554  proof- presume "\<not> (\<exists>p. p tagged_division_of {a..b} \<and> g fine p) \<Longrightarrow> False"
1.1555    then guess p unfolding atomize_not not_not .. thus thesis apply-apply(rule that[of p]) by auto
1.1556 @@ -1682,15 +1971,15 @@
1.1557    guess z using B2(2)[OF ab(2)] .. note z=conjunctD2[OF this]
1.1558    have "z = w" using lem[OF w(1) z(1)] by auto
1.1559    hence "norm (k1 - k2) \<le> norm (z - k2) + norm (w - k1)"
1.1560 -    using norm_triangle_ineq4[of "k1 - w" "k2 - z"] by(auto simp add: norm_minus_commute)
1.1561 +    using norm_triangle_ineq4[of "k1 - w" "k2 - z"] by(auto simp add: norm_minus_commute)
1.1562    also have "\<dots> < norm (k1 - k2) / 2 + norm (k1 - k2) / 2" apply(rule add_strict_mono) by(rule_tac[!] z(2) w(2))
1.1563    finally show False by auto qed
1.1564
1.1565  lemma integral_unique[intro]:
1.1566    "(f has_integral y) k \<Longrightarrow> integral k f = y"
1.1567 -  unfolding integral_def apply(rule some_equality) by(auto intro: has_integral_unique)
1.1568 -
1.1569 -lemma has_integral_is_0: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
1.1570 +  unfolding integral_def apply(rule some_equality) by(auto intro: has_integral_unique)
1.1571 +
1.1572 +lemma has_integral_is_0: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
1.1573    assumes "\<forall>x\<in>s. f x = 0" shows "(f has_integral 0) s"
1.1574  proof- have lem:"\<And>a b. \<And>f::'n \<Rightarrow> 'a.
1.1575      (\<forall>x\<in>{a..b}. f(x) = 0) \<Longrightarrow> (f has_integral 0) ({a..b})" unfolding has_integral
1.1576 @@ -1715,7 +2004,7 @@
1.1577    qed auto qed
1.1578
1.1579  lemma has_integral_0[simp]: "((\<lambda>x::'n::ordered_euclidean_space. 0) has_integral 0) s"
1.1580 -  apply(rule has_integral_is_0) by auto
1.1581 +  apply(rule has_integral_is_0) by auto
1.1582
1.1583  lemma has_integral_0_eq[simp]: "((\<lambda>x. 0) has_integral i) s \<longleftrightarrow> i = 0"
1.1584    using has_integral_unique[OF has_integral_0] by auto
1.1585 @@ -1730,13 +2019,13 @@
1.1586      have *:"e / B > 0" apply(rule divide_pos_pos) using goal1(2) B by auto
1.1587      guess g using has_integralD[OF goal1(1) *] . note g=this
1.1588      show ?case apply(rule_tac x=g in exI) apply(rule,rule g(1))
1.1589 -    proof(rule,rule,erule conjE) fix p assume as:"p tagged_division_of {a..b}" "g fine p"
1.1590 +    proof(rule,rule,erule conjE) fix p assume as:"p tagged_division_of {a..b}" "g fine p"
1.1591        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" by auto
1.1592        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"
1.1593 -        unfolding o_def unfolding scaleR[THEN sym] * by simp
1.1594 +        unfolding o_def unfolding scaleR[symmetric] * by simp
1.1595        also have "\<dots> = h (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x)" using setsum[of "\<lambda>(x,k). content k *\<^sub>R f x" p] using as by auto
1.1596        finally have *:"(\<Sum>(x, k)\<in>p. content k *\<^sub>R (h \<circ> f) x) = h (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x)" .
1.1597 -      show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R (h \<circ> f) x) - h y) < e" unfolding * diff[THEN sym]
1.1598 +      show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R (h \<circ> f) x) - h y) < e" unfolding * diff[symmetric]
1.1599          apply(rule le_less_trans[OF B(2)]) using g(2)[OF as] B(1) by(auto simp add:field_simps)
1.1600      qed qed { presume "\<not> (\<exists>a b. s = {a..b}) \<Longrightarrow> ?thesis"
1.1601      thus ?thesis apply-apply(cases "\<exists>a b. s = {a..b}") using assms by(auto simp add:has_integral intro!:lem) }
1.1602 @@ -1749,13 +2038,13 @@
1.1603      proof(rule,rule,rule) case goal1 guess z using M(2)[OF goal1(1)] .. note z=conjunctD2[OF this]
1.1604        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)"
1.1605          unfolding o_def apply(rule ext) using zero by auto
1.1606 -      show ?case apply(rule_tac x="h z" in exI,rule) unfolding * apply(rule lem[OF z(1)]) unfolding diff[THEN sym]
1.1607 +      show ?case apply(rule_tac x="h z" in exI,rule) unfolding * apply(rule lem[OF z(1)]) unfolding diff[symmetric]
1.1608          apply(rule le_less_trans[OF B(2)]) using B(1) z(2) by(auto simp add:field_simps)
1.1609      qed qed qed
1.1610
1.1611  lemma has_integral_cmul:
1.1612    shows "(f has_integral k) s \<Longrightarrow> ((\<lambda>x. c *\<^sub>R f x) has_integral (c *\<^sub>R k)) s"
1.1613 -  unfolding o_def[THEN sym] apply(rule has_integral_linear,assumption)
1.1614 +  unfolding o_def[symmetric] apply(rule has_integral_linear,assumption)
1.1615    by(rule bounded_linear_scaleR_right)
1.1616
1.1617  lemma has_integral_cmult_real:
1.1618 @@ -1772,7 +2061,7 @@
1.1619    shows "(f has_integral k) s \<Longrightarrow> ((\<lambda>x. -(f x)) has_integral (-k)) s"
1.1620    apply(drule_tac c="-1" in has_integral_cmul) by auto
1.1621
1.1622 -lemma has_integral_add: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
1.1623 +lemma has_integral_add: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
1.1624    assumes "(f has_integral k) s" "(g has_integral l) s"
1.1625    shows "((\<lambda>x. f x + g x) has_integral (k + l)) s"
1.1626  proof- have lem:"\<And>f g::'n \<Rightarrow> 'a. \<And>a b k l.
1.1627 @@ -1785,7 +2074,7 @@
1.1628          apply(rule_tac x="\<lambda>x. (d1 x) \<inter> (d2 x)" in exI) apply(rule,rule gauge_inter[OF d1(1) d2(1)])
1.1629        proof(rule,rule,erule conjE) fix p assume as:"p tagged_division_of {a..b}" "(\<lambda>x. d1 x \<inter> d2 x) fine p"
1.1630          have *:"(\<Sum>(x, k)\<in>p. content k *\<^sub>R (f x + g x)) = (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>p. content k *\<^sub>R g x)"
1.1631 -          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,THEN sym]
1.1632 +          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]
1.1633            by(rule setsum_cong2,auto)
1.1634          have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R (f x + g x)) - (k + l)) = norm (((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - k) + ((\<Sum>(x, k)\<in>p. content k *\<^sub>R g x) - l))"
1.1635            unfolding * by(auto simp add:algebra_simps) also let ?res = "\<dots>"
1.1636 @@ -1806,7 +2095,7 @@
1.1637        guess z using B2(2)[OF *(2)] .. note z=conjunctD2[OF this]
1.1638        have *:"\<And>x. (if x \<in> s then f x + g x else 0) = (if x \<in> s then f x else 0) + (if x \<in> s then g x else 0)" by auto
1.1639        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"
1.1640 -        apply(rule_tac x="w + z" in exI) apply(rule,rule lem[OF w(1) z(1), unfolded *[THEN sym]])
1.1641 +        apply(rule_tac x="w + z" in exI) apply(rule,rule lem[OF w(1) z(1), unfolded *[symmetric]])
1.1642          using norm_triangle_ineq[of "w - k" "z - l"] w(2) z(2) by(auto simp add:field_simps)
1.1643      qed qed qed
1.1644
1.1645 @@ -1869,8 +2158,8 @@
1.1646
1.1647  lemma integral_linear:
1.1648    shows "f integrable_on s \<Longrightarrow> bounded_linear h \<Longrightarrow> integral s (h o f) = h(integral s f)"
1.1649 -  apply(rule has_integral_unique) defer unfolding has_integral_integral
1.1650 -  apply(drule has_integral_linear,assumption,assumption) unfolding has_integral_integral[THEN sym]
1.1651 +  apply(rule has_integral_unique) defer unfolding has_integral_integral
1.1652 +  apply(drule has_integral_linear,assumption,assumption) unfolding has_integral_integral[symmetric]
1.1653    apply(rule integrable_linear) by assumption+
1.1654
1.1655  lemma integral_component_eq[simp]: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
1.1656 @@ -1914,12 +2203,12 @@
1.1657  proof(rule,rule,erule conjE) fix e::real assume e:"e>0" thus "gauge (\<lambda>x. ball x 1)" by auto
1.1658    fix p assume p:"p tagged_division_of {a..b}" (*"(\<lambda>x. ball x 1) fine p"*)
1.1659    have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) = 0" unfolding norm_eq_zero diff_0_right
1.1660 -    using setsum_content_null[OF assms(1) p, of f] .
1.1661 +    using setsum_content_null[OF assms(1) p, of f] .
1.1662    thus "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) < e" using e by auto qed
1.1663
1.1664  lemma has_integral_null_eq[simp]:
1.1665    shows "content({a..b}) = 0 \<Longrightarrow> ((f has_integral i) ({a..b}) \<longleftrightarrow> i = 0)"
1.1666 -  apply rule apply(rule has_integral_unique,assumption)
1.1667 +  apply rule apply(rule has_integral_unique,assumption)
1.1668    apply(drule has_integral_null,assumption)
1.1669    apply(drule has_integral_null) by auto
1.1670
1.1671 @@ -1930,7 +2219,7 @@
1.1672    unfolding integrable_on_def apply(drule has_integral_null) by auto
1.1673
1.1674  lemma has_integral_empty[intro]: shows "(f has_integral 0) {}"
1.1675 -  unfolding empty_as_interval apply(rule has_integral_null)
1.1676 +  unfolding empty_as_interval apply(rule has_integral_null)
1.1677    using content_empty unfolding empty_as_interval .
1.1678
1.1679  lemma has_integral_empty_eq[simp]: shows "(f has_integral i) {} \<longleftrightarrow> i = 0"
1.1680 @@ -1956,7 +2245,7 @@
1.1681  subsection {* Cauchy-type criterion for integrability. *}
1.1682
1.1683  (* XXXXXXX *)
1.1684 -lemma integrable_cauchy: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::{real_normed_vector,complete_space}"
1.1685 +lemma integrable_cauchy: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::{real_normed_vector,complete_space}"
1.1686    shows "f integrable_on {a..b} \<longleftrightarrow>
1.1687    (\<forall>e>0.\<exists>d. gauge d \<and> (\<forall>p1 p2. p1 tagged_division_of {a..b} \<and> d fine p1 \<and>
1.1688                              p2 tagged_division_of {a..b} \<and> d fine p2
1.1689 @@ -1985,15 +2274,15 @@
1.1690      proof(rule,rule,rule,rule) fix m n assume mn:"N \<le> m" "N \<le> n" have *:"N = (N - 1) + 1" using N by auto
1.1691        show "norm ((\<Sum>(x, k)\<in>p m. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p n. content k *\<^sub>R f x)) < e"
1.1692          apply(rule less_trans[OF _ N[THEN conjunct2,THEN conjunct2]]) apply(subst *) apply(rule d(2))
1.1693 -        using dp p(1) using mn by auto
1.1694 +        using dp p(1) using mn by auto
1.1695      qed qed
1.1696 -  then guess y unfolding convergent_eq_cauchy[THEN sym] .. note y=this[THEN LIMSEQ_D]
1.1697 +  then guess y unfolding convergent_eq_cauchy[symmetric] .. note y=this[THEN LIMSEQ_D]
1.1698    show ?l unfolding integrable_on_def has_integral apply(rule_tac x=y in exI)
1.1699    proof(rule,rule) fix e::real assume "e>0" hence *:"e/2 > 0" by auto
1.1700      then guess N1 unfolding real_arch_inv[of "e/2"] .. note N1=this hence N1':"N1 = N1 - 1 + 1" by auto
1.1701      guess N2 using y[OF *] .. note N2=this
1.1702      show "\<exists>d. gauge d \<and> (\<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) - y) < e)"
1.1703 -      apply(rule_tac x="d (N1 + N2)" in exI) apply rule defer
1.1704 +      apply(rule_tac x="d (N1 + N2)" in exI) apply rule defer
1.1705      proof(rule,rule,erule conjE) show "gauge (d (N1 + N2))" using d by auto
1.1706        fix q assume as:"q tagged_division_of {a..b}" "d (N1 + N2) fine q"
1.1707        have *:"inverse (real (N1 + N2 + 1)) < e / 2" apply(rule less_trans) using N1 by auto
1.1708 @@ -2019,12 +2308,12 @@
1.1709    have *:"Basis = insert k (Basis - {k})" "\<And>x. finite (Basis-{x})" "\<And>x. x\<notin>Basis-{x}"
1.1710      using assms by auto
1.1711    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))"
1.1712 -    "(\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i) = (\<Prod>i\<in>Basis-{k}. b\<bullet>i - a\<bullet>i) * (b\<bullet>k - a\<bullet>k)"
1.1713 +    "(\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i) = (\<Prod>i\<in>Basis-{k}. b\<bullet>i - a\<bullet>i) * (b\<bullet>k - a\<bullet>k)"
1.1714      apply(subst *(1)) defer apply(subst *(1)) unfolding setprod_insert[OF *(2-)] by auto
1.1715    assume as:"a\<le>b" moreover have "\<And>x. min (b \<bullet> k) c = max (a \<bullet> k) c
1.1716      \<Longrightarrow> 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)"
1.1718 -  moreover have **:"(\<Prod>i\<in>Basis. ((\<Sum>i\<in>Basis. (if i = k then min (b \<bullet> k) c else b \<bullet> i) *\<^sub>R i) \<bullet> i - a \<bullet> i)) =
1.1719 +  moreover have **:"(\<Prod>i\<in>Basis. ((\<Sum>i\<in>Basis. (if i = k then min (b \<bullet> k) c else b \<bullet> i) *\<^sub>R i) \<bullet> i - a \<bullet> i)) =
1.1720        (\<Prod>i\<in>Basis. (if i = k then min (b \<bullet> k) c else b \<bullet> i) - a \<bullet> i)"
1.1721      "(\<Prod>i\<in>Basis. b \<bullet> i - ((\<Sum>i\<in>Basis. (if i = k then max (a \<bullet> k) c else a \<bullet> i) *\<^sub>R i) \<bullet> i)) =
1.1722        (\<Prod>i\<in>Basis. b \<bullet> i - (if i = k then max (a \<bullet> k) c else a \<bullet> i))"
1.1723 @@ -2041,7 +2330,7 @@
1.1724  qed
1.1725
1.1726  lemma division_split_left_inj: fixes type::"'a::ordered_euclidean_space"
1.1727 -  assumes "d division_of i" "k1 \<in> d" "k2 \<in> d"  "k1 \<noteq> k2"
1.1728 +  assumes "d division_of i" "k1 \<in> d" "k2 \<in> d"  "k1 \<noteq> k2"
1.1729    "k1 \<inter> {x::'a. x\<bullet>k \<le> c} = k2 \<inter> {x. x\<bullet>k \<le> c}"and k:"k\<in>Basis"
1.1730    shows "content(k1 \<inter> {x. x\<bullet>k \<le> c}) = 0"
1.1731  proof- note d=division_ofD[OF assms(1)]
1.1732 @@ -2052,7 +2341,7 @@
1.1733    have **:"\<And>s t u. s \<inter> t = {} \<Longrightarrow> u \<subseteq> s \<Longrightarrow> u \<subseteq> t \<Longrightarrow> u = {}" by auto
1.1734    show ?thesis unfolding uv1 uv2 * apply(rule **[OF d(5)[OF assms(2-4)]])
1.1735      defer apply(subst assms(5)[unfolded uv1 uv2]) unfolding uv1 uv2 by auto qed
1.1736 -
1.1737 +
1.1738  lemma division_split_right_inj: fixes type::"'a::ordered_euclidean_space"
1.1739    assumes "d division_of i" "k1 \<in> d" "k2 \<in> d"  "k1 \<noteq> k2"
1.1740    "k1 \<inter> {x::'a. x\<bullet>k \<ge> c} = k2 \<inter> {x. x\<bullet>k \<ge> c}" and k:"k\<in>Basis"
1.1741 @@ -2067,7 +2356,7 @@
1.1742      defer apply(subst assms(5)[unfolded uv1 uv2]) unfolding uv1 uv2 by auto qed
1.1743
1.1744  lemma tagged_division_split_left_inj: fixes x1::"'a::ordered_euclidean_space"
1.1745 -  assumes "d tagged_division_of i" "(x1,k1) \<in> d" "(x2,k2) \<in> d" "k1 \<noteq> k2"  "k1 \<inter> {x. x\<bullet>k \<le> c} = k2 \<inter> {x. x\<bullet>k \<le> c}"
1.1746 +  assumes "d tagged_division_of i" "(x1,k1) \<in> d" "(x2,k2) \<in> d" "k1 \<noteq> k2"  "k1 \<inter> {x. x\<bullet>k \<le> c} = k2 \<inter> {x. x\<bullet>k \<le> c}"
1.1747    and k:"k\<in>Basis"
1.1748    shows "content(k1 \<inter> {x. x\<bullet>k \<le> c}) = 0"
1.1749  proof- have *:"\<And>a b c. (a,b) \<in> c \<Longrightarrow> b \<in> snd ` c" unfolding image_iff apply(rule_tac x="(a,b)" in bexI) by auto
1.1750 @@ -2075,7 +2364,7 @@
1.1751      apply(rule_tac[1-2] *) using assms(2-) by auto qed
1.1752
1.1753  lemma tagged_division_split_right_inj: fixes x1::"'a::ordered_euclidean_space"
1.1754 -  assumes "d tagged_division_of i" "(x1,k1) \<in> d" "(x2,k2) \<in> d" "k1 \<noteq> k2"  "k1 \<inter> {x. x\<bullet>k \<ge> c} = k2 \<inter> {x. x\<bullet>k \<ge> c}"
1.1755 +  assumes "d tagged_division_of i" "(x1,k1) \<in> d" "(x2,k2) \<in> d" "k1 \<noteq> k2"  "k1 \<inter> {x. x\<bullet>k \<ge> c} = k2 \<inter> {x. x\<bullet>k \<ge> c}"
1.1756    and k:"k\<in>Basis"
1.1757    shows "content(k1 \<inter> {x. x\<bullet>k \<ge> c}) = 0"
1.1758  proof- have *:"\<And>a b c. (a,b) \<in> c \<Longrightarrow> b \<in> snd ` c" unfolding image_iff apply(rule_tac x="(a,b)" in bexI) by auto
1.1759 @@ -2084,10 +2373,10 @@
1.1760
1.1761  lemma division_split: fixes a::"'a::ordered_euclidean_space"
1.1762    assumes "p division_of {a..b}" and k:"k\<in>Basis"
1.1763 -  shows "{l \<inter> {x. x\<bullet>k \<le> c} | l. l \<in> p \<and> ~(l \<inter> {x. x\<bullet>k \<le> c} = {})} division_of({a..b} \<inter> {x. x\<bullet>k \<le> c})" (is "?p1 division_of ?I1") and
1.1764 +  shows "{l \<inter> {x. x\<bullet>k \<le> c} | l. l \<in> p \<and> ~(l \<inter> {x. x\<bullet>k \<le> c} = {})} division_of({a..b} \<inter> {x. x\<bullet>k \<le> c})" (is "?p1 division_of ?I1") and
1.1765          "{l \<inter> {x. x\<bullet>k \<ge> c} | l. l \<in> p \<and> ~(l \<inter> {x. x\<bullet>k \<ge> c} = {})} division_of ({a..b} \<inter> {x. x\<bullet>k \<ge> c})" (is "?p2 division_of ?I2")
1.1766  proof(rule_tac[!] division_ofI) note p=division_ofD[OF assms(1)]
1.1767 -  show "finite ?p1" "finite ?p2" using p(1) by auto show "\<Union>?p1 = ?I1" "\<Union>?p2 = ?I2" unfolding p(6)[THEN sym] by auto
1.1768 +  show "finite ?p1" "finite ?p2" using p(1) by auto show "\<Union>?p1 = ?I1" "\<Union>?p2 = ?I2" unfolding p(6)[symmetric] by auto
1.1769    { fix k assume "k\<in>?p1" then guess l unfolding mem_Collect_eq apply-by(erule exE,(erule conjE)+) note l=this
1.1770      guess u v using p(4)[OF l(2)] apply-by(erule exE)+ note uv=this
1.1771      show "k\<subseteq>?I1" "k \<noteq> {}" "\<exists>a b. k = {a..b}" unfolding l
1.1772 @@ -2106,8 +2395,8 @@
1.1773    assumes "(f has_integral i) ({a..b} \<inter> {x. x\<bullet>k \<le> c})"  "(f has_integral j) ({a..b} \<inter> {x. x\<bullet>k \<ge> c})" and k:"k\<in>Basis"
1.1774    shows "(f has_integral (i + j)) ({a..b})"
1.1775  proof(unfold has_integral,rule,rule) case goal1 hence e:"e/2>0" by auto
1.1776 -  guess d1 using has_integralD[OF assms(1)[unfolded interval_split[OF k]] e] . note d1=this[unfolded interval_split[THEN sym,OF k]]
1.1777 -  guess d2 using has_integralD[OF assms(2)[unfolded interval_split[OF k]] e] . note d2=this[unfolded interval_split[THEN sym,OF k]]
1.1778 +  guess d1 using has_integralD[OF assms(1)[unfolded interval_split[OF k]] e] . note d1=this[unfolded interval_split[symmetric,OF k]]
1.1779 +  guess d2 using has_integralD[OF assms(2)[unfolded interval_split[OF k]] e] . note d2=this[unfolded interval_split[symmetric,OF k]]
1.1780    let ?d = "\<lambda>x. if x\<bullet>k = c then (d1 x \<inter> d2 x) else ball x (abs(x\<bullet>k - c)) \<inter> d1 x \<inter> d2 x"
1.1781    show ?case apply(rule_tac x="?d" in exI,rule) defer apply(rule,rule,(erule conjE)+)
1.1782    proof- show "gauge ?d" using d1(1) d2(1) unfolding gauge_def by auto
1.1783 @@ -2119,7 +2408,7 @@
1.1784        proof(rule ccontr) case goal1
1.1785          from this(2)[unfolded not_le] have "kk \<subseteq> ball x \<bar>x \<bullet> k - c\<bar>"
1.1786            using p(2)[unfolded fine_def,rule_format,OF as,unfolded split_conv] by auto
1.1787 -        hence "\<exists>y. y \<in> ball x \<bar>x \<bullet> k - c\<bar> \<inter> {x. x \<bullet> k \<le> c}" using goal1(1) by blast
1.1788 +        hence "\<exists>y. y \<in> ball x \<bar>x \<bullet> k - c\<bar> \<inter> {x. x \<bullet> k \<le> c}" using goal1(1) by blast
1.1789          then guess y .. hence "\<bar>x \<bullet> k - y \<bullet> k\<bar> < \<bar>x \<bullet> k - c\<bar>" "y\<bullet>k \<le> c" apply-apply(rule le_less_trans)
1.1790            using Basis_le_norm[OF k, of "x - y"] by (auto simp add: dist_norm inner_diff_left)
1.1791          thus False using goal1(2)[unfolded not_le] by(auto simp add:field_simps)
1.1792 @@ -2128,7 +2417,7 @@
1.1793        proof(rule ccontr) case goal1
1.1794          from this(2)[unfolded not_le] have "kk \<subseteq> ball x \<bar>x \<bullet> k - c\<bar>"
1.1795            using p(2)[unfolded fine_def,rule_format,OF as,unfolded split_conv] by auto
1.1796 -        hence "\<exists>y. y \<in> ball x \<bar>x \<bullet> k - c\<bar> \<inter> {x. x \<bullet> k \<ge> c}" using goal1(1) by blast
1.1797 +        hence "\<exists>y. y \<in> ball x \<bar>x \<bullet> k - c\<bar> \<inter> {x. x \<bullet> k \<ge> c}" using goal1(1) by blast
1.1798          then guess y .. hence "\<bar>x \<bullet> k - y \<bullet> k\<bar> < \<bar>x \<bullet> k - c\<bar>" "y\<bullet>k \<ge> c" apply-apply(rule le_less_trans)
1.1799            using Basis_le_norm[OF k, of "x - y"] by (auto simp add: dist_norm inner_diff_left)
1.1800          thus False using goal1(2)[unfolded not_le] by(auto simp add:field_simps)
1.1801 @@ -2153,7 +2442,7 @@
1.1802      let ?M1 = "{(x,kk \<inter> {x. x\<bullet>k \<le> c}) |x kk. (x,kk) \<in> p \<and> kk \<inter> {x. x\<bullet>k \<le> c} \<noteq> {}}"
1.1803      have "norm ((\<Sum>(x, k)\<in>?M1. content k *\<^sub>R f x) - i) < e/2" apply(rule d1(2),rule tagged_division_ofI)
1.1804        apply(rule lem2 p(3))+ prefer 6 apply(rule fineI)
1.1805 -    proof- show "\<Union>{k. \<exists>x. (x, k) \<in> ?M1} = {a..b} \<inter> {x. x\<bullet>k \<le> c}" unfolding p(8)[THEN sym] by auto
1.1806 +    proof- show "\<Union>{k. \<exists>x. (x, k) \<in> ?M1} = {a..b} \<inter> {x. x\<bullet>k \<le> c}" unfolding p(8)[symmetric] by auto
1.1807        fix x l assume xl:"(x,l)\<in>?M1"
1.1808        then guess x' l' unfolding mem_Collect_eq apply- unfolding Pair_eq apply((erule exE)+,(erule conjE)+) .  note xl'=this
1.1809        have "l' \<subseteq> d1 x'" apply(rule order_trans[OF fineD[OF p(2) xl'(3)]]) by auto
1.1810 @@ -2170,10 +2459,10 @@
1.1811          thus ?thesis using p(7)[OF xl'(3) yr'(3)] using as unfolding xl' yr' by auto
1.1812        qed qed moreover
1.1813
1.1814 -    let ?M2 = "{(x,kk \<inter> {x. x\<bullet>k \<ge> c}) |x kk. (x,kk) \<in> p \<and> kk \<inter> {x. x\<bullet>k \<ge> c} \<noteq> {}}"
1.1815 +    let ?M2 = "{(x,kk \<inter> {x. x\<bullet>k \<ge> c}) |x kk. (x,kk) \<in> p \<and> kk \<inter> {x. x\<bullet>k \<ge> c} \<noteq> {}}"
1.1816      have "norm ((\<Sum>(x, k)\<in>?M2. content k *\<^sub>R f x) - j) < e/2" apply(rule d2(2),rule tagged_division_ofI)
1.1817        apply(rule lem2 p(3))+ prefer 6 apply(rule fineI)
1.1818 -    proof- show "\<Union>{k. \<exists>x. (x, k) \<in> ?M2} = {a..b} \<inter> {x. x\<bullet>k \<ge> c}" unfolding p(8)[THEN sym] by auto
1.1819 +    proof- show "\<Union>{k. \<exists>x. (x, k) \<in> ?M2} = {a..b} \<inter> {x. x\<bullet>k \<ge> c}" unfolding p(8)[symmetric] by auto
1.1820        fix x l assume xl:"(x,l)\<in>?M2"
1.1821        then guess x' l' unfolding mem_Collect_eq apply- unfolding Pair_eq apply((erule exE)+,(erule conjE)+) .  note xl'=this
1.1822        have "l' \<subseteq> d2 x'" apply(rule order_trans[OF fineD[OF p(2) xl'(3)]]) by auto
1.1823 @@ -2198,15 +2487,15 @@
1.1824        also have "\<dots> = (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. x \<bullet> k \<le> c}) *\<^sub>R f x) +
1.1825          (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. c \<le> x \<bullet> k}) *\<^sub>R f x) - (i + j)"
1.1826          unfolding lem3[OF p(3)] apply(subst setsum_reindex_nonzero[OF p(3)]) defer apply(subst setsum_reindex_nonzero[OF p(3)])
1.1827 -        defer unfolding lem4[THEN sym] apply(rule refl) unfolding split_paired_all split_conv apply(rule_tac[!] *)
1.1828 +        defer unfolding lem4[symmetric] apply(rule refl) unfolding split_paired_all split_conv apply(rule_tac[!] *)
1.1829        proof- case goal1 thus ?case apply- apply(rule tagged_division_split_left_inj [OF p(1), of a b aa ba]) using k by auto
1.1830        next case   goal2 thus ?case apply- apply(rule tagged_division_split_right_inj[OF p(1), of a b aa ba]) using k by auto
1.1831 -      qed also note setsum_addf[THEN sym]
1.1832 +      qed also note setsum_addf[symmetric]
1.1833        also have *:"\<And>x. x\<in>p \<Longrightarrow> (\<lambda>(x, ka). content (ka \<inter> {x. x \<bullet> k \<le> c}) *\<^sub>R f x) x + (\<lambda>(x, ka). content (ka \<inter> {x. c \<le> x \<bullet> k}) *\<^sub>R f x) x
1.1834          = (\<lambda>(x,ka). content ka *\<^sub>R f x) x" unfolding split_paired_all split_conv
1.1835        proof- fix a b assume "(a,b) \<in> p" from p(6)[OF this] guess u v apply-by(erule exE)+ note uv=this
1.1836          thus "content (b \<inter> {x. x \<bullet> k \<le> c}) *\<^sub>R f a + content (b \<inter> {x. c \<le> x \<bullet> k}) *\<^sub>R f a = content b *\<^sub>R f a"
1.1837 -          unfolding scaleR_left_distrib[THEN sym] unfolding uv content_split[OF k,of u v c] by auto
1.1838 +          unfolding scaleR_left_distrib[symmetric] unfolding uv content_split[OF k,of u v c] by auto
1.1839        qed note setsum_cong2[OF this]
1.1840        finally have "(\<Sum>(x, k)\<in>{(x, kk \<inter> {x. x \<bullet> k \<le> c}) |x kk. (x, kk) \<in> p \<and> kk \<inter> {x. x \<bullet> k \<le> c} \<noteq> {}}. content k *\<^sub>R f x) - i +
1.1841          ((\<Sum>(x, k)\<in>{(x, kk \<inter> {x. c \<le> x \<bullet> k}) |x kk. (x, kk) \<in> p \<and> kk \<inter> {x. c \<le> x \<bullet> k} \<noteq> {}}. content k *\<^sub>R f x) - j) =
1.1842 @@ -2240,7 +2529,7 @@
1.1843      proof- fix a b assume ab:"(a,b) \<in> p1 \<inter> p2"
1.1844        have "(a,b) \<in> p1" using ab by auto from p1(4)[OF this] guess u v apply-by(erule exE)+ note uv =this
1.1845        have "b \<subseteq> {x. x\<bullet>k = c}" using ab p1(3)[of a b] p2(3)[of a b] by fastforce
1.1846 -      moreover have "interior {x::'a. x \<bullet> k = c} = {}"
1.1847 +      moreover have "interior {x::'a. x \<bullet> k = c} = {}"
1.1848        proof(rule ccontr) case goal1 then obtain x where x:"x\<in>interior {x::'a. x\<bullet>k = c}" by auto
1.1849          then guess e unfolding mem_interior .. note e=this
1.1850          have x:"x\<bullet>k = c" using x interior_subset by fastforce
1.1851 @@ -2248,7 +2537,7 @@
1.1852            = (if i = k then e/2 else 0)" using e k by (auto simp: inner_simps inner_not_same_Basis)
1.1853          have "(\<Sum>i\<in>Basis. \<bar>(x - (x + (e / 2 ) *\<^sub>R k)) \<bullet> i\<bar>) =
1.1854            (\<Sum>i\<in>Basis. (if i = k then e / 2 else 0))" apply(rule setsum_cong2) apply(subst *) by auto
1.1855 -        also have "... < e" apply(subst setsum_delta) using e by auto
1.1856 +        also have "... < e" apply(subst setsum_delta) using e by auto
1.1857          finally have "x + (e/2) *\<^sub>R k \<in> ball x e"
1.1858            unfolding mem_ball dist_norm by(rule le_less_trans[OF norm_le_l1])
1.1859          hence "x + (e/2) *\<^sub>R k \<in> {x. x\<bullet>k = c}" using e by auto
1.1860 @@ -2262,11 +2551,11 @@
1.1861  lemma integrable_split[intro]:
1.1862    fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::{real_normed_vector,complete_space}"
1.1863    assumes "f integrable_on {a..b}" and k:"k\<in>Basis"
1.1864 -  shows "f integrable_on ({a..b} \<inter> {x. x\<bullet>k \<le> c})" (is ?t1) and "f integrable_on ({a..b} \<inter> {x. x\<bullet>k \<ge> c})" (is ?t2)
1.1865 +  shows "f integrable_on ({a..b} \<inter> {x. x\<bullet>k \<le> c})" (is ?t1) and "f integrable_on ({a..b} \<inter> {x. x\<bullet>k \<ge> c})" (is ?t2)
1.1866  proof- guess y using assms(1) unfolding integrable_on_def .. note y=this
1.1867    def b' \<equiv> "\<Sum>i\<in>Basis. (if i = k then min (b\<bullet>k) c else b\<bullet>i)*\<^sub>R i::'a"
1.1868    def a' \<equiv> "\<Sum>i\<in>Basis. (if i = k then max (a\<bullet>k) c else a\<bullet>i)*\<^sub>R i::'a"
1.1869 -  show ?t1 ?t2 unfolding interval_split[OF k] integrable_cauchy unfolding interval_split[THEN sym,OF k]
1.1870 +  show ?t1 ?t2 unfolding interval_split[OF k] integrable_cauchy unfolding interval_split[symmetric,OF k]
1.1871    proof(rule_tac[!] allI impI)+ fix e::real assume "e>0" hence "e/2>0" by auto
1.1872      from has_integral_separate_sides[OF y this k,of c] guess d . note d=this[rule_format]
1.1873      let ?P = "\<lambda>A. \<exists>d. gauge d \<and> (\<forall>p1 p2. p1 tagged_division_of {a..b} \<inter> A \<and> d fine p1
1.1874 @@ -2280,7 +2569,7 @@
1.1875          show ?thesis using norm_triangle_half_l[OF d(2)[of p1 p] d(2)[of p2 p]]
1.1876            using as unfolding interval_split[OF k] b'_def[symmetric] a'_def[symmetric]
1.1877            using p using assms by(auto simp add:algebra_simps)
1.1878 -      qed qed
1.1879 +      qed qed
1.1880      show "?P {x. x \<bullet> k \<ge> c}" apply(rule_tac x=d in exI) apply(rule,rule d) apply(rule,rule,rule)
1.1881      proof- fix p1 p2 assume as:"p1 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<ge> c} \<and> d fine p1
1.1882          \<and> p2 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<ge> c} \<and> d fine p2"
1.1883 @@ -2295,7 +2584,7 @@
1.1884  definition "neutral opp = (SOME x. \<forall>y. opp x y = y \<and> opp y x = y)"
1.1885
1.1886  definition operative :: "('a \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> (('b::ordered_euclidean_space) set \<Rightarrow> 'a) \<Rightarrow> bool" where
1.1887 -  "operative opp f \<equiv>
1.1888 +  "operative opp f \<equiv>
1.1889      (\<forall>a b. content {a..b} = 0 \<longrightarrow> f {a..b} = neutral(opp)) \<and>
1.1890      (\<forall>a b c. \<forall>k\<in>Basis. f({a..b}) =
1.1891                     opp (f({a..b} \<inter> {x. x\<bullet>k \<le> c}))
1.1892 @@ -2311,7 +2600,7 @@
1.1893    unfolding operative_def by auto
1.1894
1.1895  lemma property_empty_interval:
1.1896 - "(\<forall>a b. content({a..b}) = 0 \<longrightarrow> P({a..b})) \<Longrightarrow> P {}"
1.1897 + "(\<forall>a b. content({a..b}) = 0 \<longrightarrow> P({a..b})) \<Longrightarrow> P {}"
1.1898    using content_empty unfolding empty_as_interval by auto
1.1899
1.1900  lemma operative_empty: "operative opp f \<Longrightarrow> f {} = neutral opp"
1.1901 @@ -2395,10 +2684,10 @@
1.1902    unfolding support_def by auto
1.1903
1.1904  lemma iterate_empty[simp]:"iterate opp {} f = neutral opp"
1.1905 -  unfolding iterate_def fold'_def by auto
1.1906 +  unfolding iterate_def fold'_def by auto
1.1907
1.1908  lemma iterate_insert[simp]: assumes "monoidal opp" "finite s"
1.1909 -  shows "iterate opp (insert x s) f = (if x \<in> s then iterate opp s f else opp (f x) (iterate opp s f))"
1.1910 +  shows "iterate opp (insert x s) f = (if x \<in> s then iterate opp s f else opp (f x) (iterate opp s f))"
1.1911  proof(cases "x\<in>s") case True hence *:"insert x s = s" by auto
1.1912    show ?thesis unfolding iterate_def if_P[OF True] * by auto
1.1913  next case False note x=this
1.1914 @@ -2408,7 +2697,7 @@
1.1915        unfolding True monoidal_simps[OF assms(1)] by auto
1.1916    next case False show ?thesis unfolding iterate_def fold'_def  if_not_P[OF x] support_clauses if_not_P[OF False]
1.1917        apply(subst comp_fun_commute.fold_insert[OF * finite_support, simplified comp_def])
1.1918 -      using `finite s` unfolding support_def using False x by auto qed qed
1.1919 +      using `finite s` unfolding support_def using False x by auto qed qed
1.1920
1.1921  lemma iterate_some:
1.1922    assumes "monoidal opp"  "finite s"
1.1923 @@ -2419,19 +2708,19 @@
1.1924  subsection {* Two key instances of additivity. *}
1.1925
1.1927 -  "neutral op + = (0::_::comm_monoid_add)" unfolding neutral_def
1.1928 +  "neutral op + = (0::_::comm_monoid_add)" unfolding neutral_def
1.1929    apply(rule some_equality) defer apply(erule_tac x=0 in allE) by auto
1.1930
1.1931 -lemma operative_content[intro]: "operative (op +) content"
1.1932 -  unfolding operative_def neutral_add apply safe
1.1933 -  unfolding content_split[THEN sym] ..
1.1934 +lemma operative_content[intro]: "operative (op +) content"
1.1935 +  unfolding operative_def neutral_add apply safe
1.1936 +  unfolding content_split[symmetric] ..
1.1937
1.1938  lemma neutral_monoid: "neutral ((op +)::('a::comm_monoid_add) \<Rightarrow> 'a \<Rightarrow> 'a) = 0"
1.1939    by (rule neutral_add) (* FIXME: duplicate *)
1.1940
1.1941  lemma monoidal_monoid[intro]:
1.1942    shows "monoidal ((op +)::('a::comm_monoid_add) \<Rightarrow> 'a \<Rightarrow> 'a)"
1.1943 -  unfolding monoidal_def neutral_monoid by(auto simp add: algebra_simps)
1.1944 +  unfolding monoidal_def neutral_monoid by(auto simp add: algebra_simps)
1.1945
1.1946  lemma operative_integral: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
1.1947    shows "operative (lifted(op +)) (\<lambda>i. if f integrable_on i then Some(integral i f) else None)"
1.1948 @@ -2442,25 +2731,25 @@
1.1949    show "(if f integrable_on {a..b} then Some (integral {a..b} f) else None) =
1.1950      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)
1.1951      (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)"
1.1952 -  proof(cases "f integrable_on {a..b}")
1.1953 +  proof(cases "f integrable_on {a..b}")
1.1954      case True show ?thesis unfolding if_P[OF True] using k apply-
1.1955        unfolding if_P[OF integrable_split(1)[OF True]] unfolding if_P[OF integrable_split(2)[OF True]]
1.1956 -      unfolding lifted.simps option.inject apply(rule integral_unique) apply(rule has_integral_split[OF _ _ k])
1.1957 +      unfolding lifted.simps option.inject apply(rule integral_unique) apply(rule has_integral_split[OF _ _ k])
1.1958        apply(rule_tac[!] integrable_integral integrable_split)+ using True k by auto
1.1959    next case False 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}))"
1.1960      proof(rule ccontr) case goal1 hence "f integrable_on {a..b}" apply- unfolding integrable_on_def
1.1961          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)
1.1962          apply(rule has_integral_split[OF _ _ k]) apply(rule_tac[!] integrable_integral) by auto
1.1963        thus False using False by auto
1.1964 -    qed thus ?thesis using False by auto
1.1965 -  qed next
1.1966 +    qed thus ?thesis using False by auto
1.1967 +  qed next
1.1968    fix a b assume as:"content {a..b::'a} = 0"
1.1969    thus "(if f integrable_on {a..b} then Some (integral {a..b} f) else None) = Some 0"
1.1970      unfolding if_P[OF integrable_on_null[OF as]] using has_integral_null_eq[OF as] by auto qed
1.1971
1.1972  subsection {* Points of division of a partition. *}
1.1973
1.1974 -definition "division_points (k::('a::ordered_euclidean_space) set) d =
1.1975 +definition "division_points (k::('a::ordered_euclidean_space) set) d =
1.1976      {(j,x). j\<in>Basis \<and> (interval_lowerbound k)\<bullet>j < x \<and> x < (interval_upperbound k)\<bullet>j \<and>
1.1977             (\<exists>i\<in>d. (interval_lowerbound i)\<bullet>j = x \<or> (interval_upperbound i)\<bullet>j = x)}"
1.1978
1.1979 @@ -2502,7 +2791,7 @@
1.1980      from assm(4)[OF this(5)] guess u v apply-by(erule exE)+ note l=this
1.1981      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"
1.1982        using as(6) unfolding l interval_split[OF k] interval_ne_empty as .
1.1983 -    have **:"\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i" using l using as(6) unfolding interval_ne_empty[THEN sym] by auto
1.1984 +    have **:"\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i" using l using as(6) unfolding interval_ne_empty[symmetric] by auto
1.1985      show "\<exists>i\<in>d. interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
1.1986        apply (rule bexI[OF _ `l \<in> d`])
1.1987        using as(1-3,5) fstx
1.1988 @@ -2520,12 +2809,12 @@
1.1989      apply(erule exE conjE)+
1.1990    proof
1.1991      fix i l x assume as:"(if fst x = k then c else a \<bullet> fst x) < snd x" "snd x < b \<bullet> fst x"
1.1992 -      "interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
1.1993 +      "interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
1.1994        "i = l \<inter> {x. c \<le> x \<bullet> k}" "l \<in> d" "l \<inter> {x. c \<le> x \<bullet> k} \<noteq> {}" and fstx:"fst x \<in> Basis"
1.1995      from assm(4)[OF this(5)] guess u v apply-by(erule exE)+ note l=this
1.1996      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"
1.1997        using as(6) unfolding l interval_split[OF k] interval_ne_empty as .
1.1998 -    have **:"\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i" using l using as(6) unfolding interval_ne_empty[THEN sym] by auto
1.1999 +    have **:"\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i" using l using as(6) unfolding interval_ne_empty[symmetric] by auto
1.2000      show "\<exists>i\<in>d. interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
1.2001        apply (rule bexI[OF _ `l \<in> d`])
1.2002        using as(1-3,5) fstx
1.2003 @@ -2540,9 +2829,9 @@
1.2004    assumes "d division_of {a..b}"  "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"  "a\<bullet>k < c" "c < b\<bullet>k"
1.2005    "l \<in> d" "interval_lowerbound l\<bullet>k = c \<or> interval_upperbound l\<bullet>k = c" and k:"k\<in>Basis"
1.2006    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> {}}
1.2007 -              \<subset> division_points ({a..b}) d" (is "?D1 \<subset> ?D")
1.2008 +              \<subset> division_points ({a..b}) d" (is "?D1 \<subset> ?D")
1.2009          "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> {}}
1.2010 -              \<subset> division_points ({a..b}) d" (is "?D2 \<subset> ?D")
1.2011 +              \<subset> division_points ({a..b}) d" (is "?D2 \<subset> ?D")
1.2012  proof- have ab:"\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i" using assms(2) by(auto intro!:less_imp_le)
1.2013    guess u v using division_ofD(4)[OF assms(1,5)] apply-by(erule exE)+ note l=this
1.2014    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"
1.2015 @@ -2555,7 +2844,7 @@
1.2016    have "\<exists>x. x \<in> ?D - ?D1" using assms(2-) apply-apply(erule disjE)
1.2017      apply(rule_tac x="(k,(interval_lowerbound l)\<bullet>k)" in exI) defer
1.2018      apply(rule_tac x="(k,(interval_upperbound l)\<bullet>k)" in exI)
1.2019 -    unfolding division_points_def unfolding interval_bounds[OF ab] by(auto simp add:*)
1.2020 +    unfolding division_points_def unfolding interval_bounds[OF ab] by(auto simp add:*)
1.2021    thus "?D1 \<subset> ?D" apply-apply(rule,rule division_points_subset[OF assms(1-4)]) using k by auto
1.2022
1.2023    have *:"interval_lowerbound ({a..b} \<inter> {x. x \<bullet> k \<ge> interval_lowerbound l \<bullet> k}) \<bullet> k = interval_lowerbound l \<bullet> k"
1.2024 @@ -2565,7 +2854,7 @@
1.2025    have "\<exists>x. x \<in> ?D - ?D2" using assms(2-) apply-apply(erule disjE)
1.2026      apply(rule_tac x="(k,(interval_lowerbound l)\<bullet>k)" in exI) defer
1.2027      apply(rule_tac x="(k,(interval_upperbound l)\<bullet>k)" in exI)
1.2028 -    unfolding division_points_def unfolding interval_bounds[OF ab] by(auto simp add:*)
1.2029 +    unfolding division_points_def unfolding interval_bounds[OF ab] by(auto simp add:*)
1.2030    thus "?D2 \<subset> ?D" apply-apply(rule,rule division_points_subset[OF assms(1-4) k]) by auto qed
1.2031
1.2032  subsection {* Preservation by divisions and tagged divisions. *}
1.2033 @@ -2578,7 +2867,7 @@
1.2034
1.2035  lemma iterate_expand_cases:
1.2036    "iterate opp s f = (if finite(support opp f s) then iterate opp (support opp f s) f else neutral opp)"
1.2037 -  apply(cases) apply(subst if_P,assumption) unfolding iterate_def support_support fold'_def by auto
1.2038 +  apply(cases) apply(subst if_P,assumption) unfolding iterate_def support_support fold'_def by auto
1.2039
1.2040  lemma iterate_image: assumes "monoidal opp"  "inj_on f s"
1.2041    shows "iterate opp (f ` s) g = iterate opp s (g \<circ> f)"
1.2042 @@ -2587,14 +2876,14 @@
1.2043    proof- case goal1 show ?case using goal1
1.2044      proof(induct s) case empty thus ?case using assms(1) by auto
1.2045      next case (insert x s) show ?case unfolding iterate_insert[OF assms(1) insert(1)]
1.2046 -        unfolding if_not_P[OF insert(2)] apply(subst insert(3)[THEN sym])
1.2047 +        unfolding if_not_P[OF insert(2)] apply(subst insert(3)[symmetric])
1.2048          unfolding image_insert defer apply(subst iterate_insert[OF assms(1)])
1.2049          apply(rule finite_imageI insert)+ apply(subst if_not_P)
1.2050          unfolding image_iff o_def using insert(2,4) by auto
1.2051      qed qed
1.2052 -  show ?thesis
1.2053 +  show ?thesis
1.2054      apply(cases "finite (support opp g (f ` s))")
1.2055 -    apply(subst (1) iterate_support[THEN sym],subst (2) iterate_support[THEN sym])
1.2056 +    apply(subst (1) iterate_support[symmetric],subst (2) iterate_support[symmetric])
1.2057      unfolding support_clauses apply(rule *)apply(rule finite_imageD,assumption) unfolding inj_on_def[symmetric]
1.2058      apply(rule subset_inj_on[OF assms(2) support_subset])+
1.2059      apply(subst iterate_expand_cases) unfolding support_clauses apply(simp only: if_False)
1.2060 @@ -2610,16 +2899,16 @@
1.2061    have **:"support opp (g \<circ> f) {x \<in> s. f x \<noteq> a} = support opp (g \<circ> f) s"
1.2062      unfolding support_def using assms(3) by auto
1.2063    show ?thesis unfolding *
1.2064 -    apply(subst iterate_support[THEN sym]) unfolding support_clauses
1.2065 +    apply(subst iterate_support[symmetric]) unfolding support_clauses
1.2066      apply(subst iterate_image[OF assms(1)]) defer
1.2067 -    apply(subst(2) iterate_support[THEN sym]) apply(subst **)
1.2068 +    apply(subst(2) iterate_support[symmetric]) apply(subst **)
1.2069      unfolding inj_on_def using assms(3,4) unfolding support_def by auto qed
1.2070
1.2071  lemma iterate_eq_neutral:
1.2072    assumes "monoidal opp"  "\<forall>x \<in> s. (f(x) = neutral opp)"
1.2073    shows "(iterate opp s f = neutral opp)"
1.2074  proof- have *:"support opp f s = {}" unfolding support_def using assms(2) by auto
1.2075 -  show ?thesis apply(subst iterate_support[THEN sym])
1.2076 +  show ?thesis apply(subst iterate_support[symmetric])
1.2077      unfolding * using assms(1) by auto qed
1.2078
1.2079  lemma iterate_op: assumes "monoidal opp" "finite s"
1.2080 @@ -2637,11 +2926,11 @@
1.2081      case False thus ?thesis apply(subst iterate_expand_cases,subst(2) iterate_expand_cases)
1.2082        unfolding * by auto
1.2083    next def su \<equiv> "support opp f s"
1.2084 -    case True note support_subset[of opp f s]
1.2085 -    thus ?thesis apply- apply(subst iterate_support[THEN sym],subst(2) iterate_support[THEN sym]) unfolding * using True
1.2086 +    case True note support_subset[of opp f s]
1.2087 +    thus ?thesis apply- apply(subst iterate_support[symmetric],subst(2) iterate_support[symmetric]) unfolding * using True
1.2088        unfolding su_def[symmetric]
1.2089      proof(induct su) case empty show ?case by auto
1.2090 -    next case (insert x s) show ?case unfolding iterate_insert[OF assms(1) insert(1)]
1.2091 +    next case (insert x s) show ?case unfolding iterate_insert[OF assms(1) insert(1)]
1.2092          unfolding if_not_P[OF insert(2)] apply(subst insert(3))
1.2093          defer apply(subst assms(2)[of x]) using insert by auto qed qed qed
1.2094
1.2095 @@ -2659,11 +2948,11 @@
1.2096          show ?case unfolding operativeD(1)[OF assms(2) as] apply(rule iterate_eq_neutral[OF goal1(2)])
1.2097          proof fix x assume x:"x\<in>d"
1.2098            then guess u v apply(drule_tac division_ofD(4)[OF goal1(4)]) by(erule exE)+
1.2099 -          thus "f x = neutral opp" using division_of_content_0[OF as goal1(4)]
1.2100 +          thus "f x = neutral opp" using division_of_content_0[OF as goal1(4)]
1.2101              using operativeD(1)[OF assms(2)] x by auto
1.2102          qed qed }
1.2103 -    assume "content {a..b} \<noteq> 0" note ab = this[unfolded content_lt_nz[THEN sym] content_pos_lt_eq]
1.2104 -    hence ab':"\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i" by (auto intro!: less_imp_le) show ?case
1.2105 +    assume "content {a..b} \<noteq> 0" note ab = this[unfolded content_lt_nz[symmetric] content_pos_lt_eq]
1.2106 +    hence ab':"\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i" by (auto intro!: less_imp_le) show ?case
1.2107      proof(cases "division_points {a..b} d = {}")
1.2108        case True have d':"\<forall>i\<in>d. \<exists>u v. i = {u..v} \<and>
1.2109          (\<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)"
1.2110 @@ -2677,7 +2966,7 @@
1.2111            "(j, v\<bullet>j) \<notin> division_points {a..b} d" using True by auto
1.2112          note this[unfolded de_Morgan_conj division_points_def mem_Collect_eq split_conv interval_bounds[OF ab'] bex_simps]
1.2113          note *[OF this(1)] *[OF this(2)] note this[unfolded interval_bounds[OF uv(1)]]
1.2114 -        moreover have "a\<bullet>j \<le> u\<bullet>j" "v\<bullet>j \<le> b\<bullet>j" using division_ofD(2,2,3)[OF goal1(4) as]
1.2115 +        moreover have "a\<bullet>j \<le> u\<bullet>j" "v\<bullet>j \<le> b\<bullet>j" using division_ofD(2,2,3)[OF goal1(4) as]
1.2116            unfolding subset_eq apply- apply(erule_tac x=u in ballE,erule_tac[3] x=v in ballE)
1.2117            unfolding interval_ne_empty mem_interval using j by auto
1.2118          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"
1.2119 @@ -2685,7 +2974,7 @@
1.2120        qed
1.2121        have "(1/2) *\<^sub>R (a+b) \<in> {a..b}"
1.2122          unfolding mem_interval using ab by(auto intro!: less_imp_le simp: inner_simps)
1.2123 -      note this[unfolded division_ofD(6)[OF goal1(4),THEN sym] Union_iff]
1.2124 +      note this[unfolded division_ofD(6)[OF goal1(4),symmetric] Union_iff]
1.2125        then guess i .. note i=this guess u v using d'[rule_format,OF i(1)] apply-by(erule exE conjE)+ note uv=this
1.2126        have "{a..b} \<in> d"
1.2127        proof- { presume "i = {a..b}" thus ?thesis using i by auto }
1.2128 @@ -2700,12 +2989,12 @@
1.2129        have "iterate opp (d - {{a..b}}) f = neutral opp" apply(rule iterate_eq_neutral[OF goal1(2)])
1.2130        proof fix x assume x:"x \<in> d - {{a..b}}" hence "x\<in>d" by auto note d'[rule_format,OF this]
1.2131          then guess u v apply-by(erule exE conjE)+ note uv=this
1.2132 -        have "u\<noteq>a \<or> v\<noteq>b" using x[unfolded uv] by auto
1.2133 +        have "u\<noteq>a \<or> v\<noteq>b" using x[unfolded uv] by auto
1.2134          then obtain j where "u\<bullet>j \<noteq> a\<bullet>j \<or> v\<bullet>j \<noteq> b\<bullet>j" and j:"j\<in>Basis" unfolding euclidean_eq_iff[where 'a='a] by auto
1.2135          hence "u\<bullet>j = v\<bullet>j" using uv(2)[rule_format,OF j] by auto
1.2136          hence "content {u..v} = 0"  unfolding content_eq_0 apply(rule_tac x=j in bexI) using j by auto
1.2137          thus "f x = neutral opp" unfolding uv(1) by(rule operativeD(1)[OF goal1(3)])
1.2138 -      qed thus "iterate opp d f = f {a..b}" apply-apply(subst *)
1.2139 +      qed thus "iterate opp d f = f {a..b}" apply-apply(subst *)
1.2140          apply(subst iterate_insert[OF goal1(2)]) using goal1(2,4) by auto
1.2141      next case False hence "\<exists>x. x\<in>division_points {a..b} d" by auto
1.2142        then guess k c unfolding split_paired_Ex apply- unfolding division_points_def mem_Collect_eq split_conv
1.2143 @@ -2723,32 +3012,32 @@
1.2144          unfolding interval_split[OF kc(4)] d1_def[symmetric] d2_def[symmetric] unfolding goal1(2) Suc_le_mono
1.2145          using goal1(2-3) using division_points_finite[OF goal1(4)] using kc(4) by auto
1.2146        have "f {a..b} = opp (iterate opp d1 f) (iterate opp d2 f)" (is "_ = ?prev")
1.2147 -        unfolding * apply(rule operativeD(2)) using goal1(3) using kc(4) by auto
1.2148 +        unfolding * apply(rule operativeD(2)) using goal1(3) using kc(4) by auto
1.2149        also have "iterate opp d1 f = iterate opp d (\<lambda>l. f(l \<inter> {x. x\<bullet>k \<le> c}))"
1.2150          unfolding d1_def apply(rule iterate_nonzero_image_lemma[unfolded o_def])
1.2151          unfolding empty_as_interval apply(rule goal1 division_of_finite operativeD[OF goal1(3)])+
1.2152 -        unfolding empty_as_interval[THEN sym] apply(rule content_empty)
1.2153 -      proof(rule,rule,rule,erule conjE) fix l y assume as:"l \<in> d" "y \<in> d" "l \<inter> {x. x \<bullet> k \<le> c} = y \<inter> {x. x \<bullet> k \<le> c}" "l \<noteq> y"
1.2154 +        unfolding empty_as_interval[symmetric] apply(rule content_empty)
1.2155 +      proof(rule,rule,rule,erule conjE) fix l y assume as:"l \<in> d" "y \<in> d" "l \<inter> {x. x \<bullet> k \<le> c} = y \<inter> {x. x \<bullet> k \<le> c}" "l \<noteq> y"
1.2156          from division_ofD(4)[OF goal1(4) this(1)] guess u v apply-by(erule exE)+ note l=this
1.2157 -        show "f (l \<inter> {x. x \<bullet> k \<le> c}) = neutral opp" unfolding l interval_split[OF kc(4)]
1.2158 -          apply(rule operativeD(1) goal1)+ unfolding interval_split[THEN sym,OF kc(4)] apply(rule division_split_left_inj)
1.2159 -          apply(rule goal1) unfolding l[THEN sym] apply(rule as(1),rule as(2)) by(rule kc(4) as)+
1.2160 +        show "f (l \<inter> {x. x \<bullet> k \<le> c}) = neutral opp" unfolding l interval_split[OF kc(4)]
1.2161 +          apply(rule operativeD(1) goal1)+ unfolding interval_split[symmetric,OF kc(4)] apply(rule division_split_left_inj)
1.2162 +          apply(rule goal1) unfolding l[symmetric] apply(rule as(1),rule as(2)) by(rule kc(4) as)+
1.2163        qed also have "iterate opp d2 f = iterate opp d (\<lambda>l. f(l \<inter> {x. x\<bullet>k \<ge> c}))"
1.2164          unfolding d2_def apply(rule iterate_nonzero_image_lemma[unfolded o_def])
1.2165          unfolding empty_as_interval apply(rule goal1 division_of_finite operativeD[OF goal1(3)])+
1.2166 -        unfolding empty_as_interval[THEN sym] apply(rule content_empty)
1.2167 -      proof(rule,rule,rule,erule conjE) fix l y assume as:"l \<in> d" "y \<in> d" "l \<inter> {x. c \<le> x \<bullet> k} = y \<inter> {x. c \<le> x \<bullet> k}" "l \<noteq> y"
1.2168 +        unfolding empty_as_interval[symmetric] apply(rule content_empty)
1.2169 +      proof(rule,rule,rule,erule conjE) fix l y assume as:"l \<in> d" "y \<in> d" "l \<inter> {x. c \<le> x \<bullet> k} = y \<inter> {x. c \<le> x \<bullet> k}" "l \<noteq> y"
1.2170          from division_ofD(4)[OF goal1(4) this(1)] guess u v apply-by(erule exE)+ note l=this
1.2171 -        show "f (l \<inter> {x. x \<bullet> k \<ge> c}) = neutral opp" unfolding l interval_split[OF kc(4)]
1.2172 -          apply(rule operativeD(1) goal1)+ unfolding interval_split[THEN sym,OF kc(4)] apply(rule division_split_right_inj)
1.2173 -          apply(rule goal1) unfolding l[THEN sym] apply(rule as(1),rule as(2)) by(rule as kc(4))+
1.2174 +        show "f (l \<inter> {x. x \<bullet> k \<ge> c}) = neutral opp" unfolding l interval_split[OF kc(4)]
1.2175 +          apply(rule operativeD(1) goal1)+ unfolding interval_split[symmetric,OF kc(4)] apply(rule division_split_right_inj)
1.2176 +          apply(rule goal1) unfolding l[symmetric] apply(rule as(1),rule as(2)) by(rule as kc(4))+
1.2177        qed also have *:"\<forall>x\<in>d. f x = opp (f (x \<inter> {x. x \<bullet> k \<le> c})) (f (x \<inter> {x. c \<le> x \<bullet> k}))"
1.2178 -        unfolding forall_in_division[OF goal1(4)] apply(rule,rule,rule,rule operativeD(2)) using goal1(3) kc by auto
1.2179 +        unfolding forall_in_division[OF goal1(4)] apply(rule,rule,rule,rule operativeD(2)) using goal1(3) kc by auto
1.2180        have "opp (iterate opp d (\<lambda>l. f (l \<inter> {x. x \<bullet> k \<le> c}))) (iterate opp d (\<lambda>l. f (l \<inter> {x. c \<le> x \<bullet> k})))
1.2181          = iterate opp d f" apply(subst(3) iterate_eq[OF _ *[rule_format]]) prefer 3
1.2182 -        apply(rule iterate_op[THEN sym]) using goal1 by auto
1.2183 +        apply(rule iterate_op[symmetric]) using goal1 by auto
1.2184        finally show ?thesis by auto
1.2185 -    qed qed qed
1.2186 +    qed qed qed
1.2187
1.2188  lemma iterate_image_nonzero: assumes "monoidal opp"
1.2189    "finite s" "\<forall>x\<in>s. \<forall>y\<in>s. ~(x = y) \<and> f x = f y \<longrightarrow> g(f x) = neutral opp"
1.2190 @@ -2763,20 +3052,20 @@
1.2191      apply(subst iterate_insert[OF assms(1) goal2(1)])
1.2192      unfolding if_not_P[OF goal2(3)] defer unfolding image_iff defer apply(erule bexE)
1.2193      apply(rule *) unfolding o_def apply(rule_tac y=x in goal2(7)[rule_format])
1.2194 -    using goal2 unfolding o_def by auto qed
1.2195 +    using goal2 unfolding o_def by auto qed
1.2196
1.2197  lemma operative_tagged_division: assumes "monoidal opp" "operative opp f" "d tagged_division_of {a..b}"
1.2198    shows "iterate(opp) d (\<lambda>(x,l). f l) = f {a..b}"
1.2199  proof- have *:"(\<lambda>(x,l). f l) = (f o snd)" unfolding o_def by(rule,auto) note assm = tagged_division_ofD[OF assms(3)]
1.2200    have "iterate(opp) d (\<lambda>(x,l). f l) = iterate opp (snd ` d) f" unfolding *
1.2201 -    apply(rule iterate_image_nonzero[THEN sym,OF assms(1)]) apply(rule tagged_division_of_finite assms)+
1.2202 +    apply(rule iterate_image_nonzero[symmetric,OF assms(1)]) apply(rule tagged_division_of_finite assms)+
1.2203      unfolding Ball_def split_paired_All snd_conv apply(rule,rule,rule,rule,rule,rule,rule,erule conjE)
1.2204    proof- fix a b aa ba assume as:"(a, b) \<in> d" "(aa, ba) \<in> d" "(a, b) \<noteq> (aa, ba)" "b = ba"
1.2205      guess u v using assm(4)[OF as(1)] apply-by(erule exE)+ note uv=this
1.2206      show "f b = neutral opp" unfolding uv apply(rule operativeD(1)[OF assms(2)])
1.2207        unfolding content_eq_0_interior using tagged_division_ofD(5)[OF assms(3) as(1-3)]
1.2208 -      unfolding as(4)[THEN sym] uv by auto
1.2209 -  qed also have "\<dots> = f {a..b}"
1.2210 +      unfolding as(4)[symmetric] uv by auto
1.2211 +  qed also have "\<dots> = f {a..b}"
1.2212      using operative_division[OF assms(1-2) division_of_tagged_division[OF assms(3)]] .
1.2213    finally show ?thesis . qed
1.2214
1.2215 @@ -2794,13 +3083,13 @@
1.2216
1.2217  lemma additive_content_division: assumes "d division_of {a..b}"
1.2218    shows "setsum content d = content({a..b})"
1.2219 -  unfolding operative_division[OF monoidal_monoid operative_content assms,THEN sym]
1.2220 +  unfolding operative_division[OF monoidal_monoid operative_content assms,symmetric]
1.2221    apply(subst setsum_iterate) using assms by auto
1.2222
1.2224    assumes "d tagged_division_of {a..b}"
1.2225    shows "setsum (\<lambda>(x,l). content l) d = content({a..b})"
1.2226 -  unfolding operative_tagged_division[OF monoidal_monoid operative_content assms,THEN sym]
1.2227 +  unfolding operative_tagged_division[OF monoidal_monoid operative_content assms,symmetric]
1.2228    apply(subst setsum_iterate) using assms by auto
1.2229
1.2230  subsection {* Finally, the integral of a constant *}
1.2231 @@ -2809,7 +3098,7 @@
1.2232    "((\<lambda>x. c) has_integral (content({a..b::'a::ordered_euclidean_space}) *\<^sub>R c)) ({a..b})"
1.2233    unfolding has_integral apply(rule,rule,rule_tac x="\<lambda>x. ball x 1" in exI)
1.2234    apply(rule,rule gauge_trivial)apply(rule,rule,erule conjE)
1.2235 -  unfolding split_def apply(subst scaleR_left.setsum[THEN sym, unfolded o_def])
1.2236 +  unfolding split_def apply(subst scaleR_left.setsum[symmetric, unfolded o_def])
1.2237    defer apply(subst additive_content_tagged_division[unfolded split_def]) apply assumption by auto
1.2238
1.2239  lemma integral_const[simp]:
1.2240 @@ -2821,7 +3110,7 @@
1.2241
1.2242  lemma dsum_bound: assumes "p division_of {a..b}" "norm(c) \<le> e"
1.2243    shows "norm(setsum (\<lambda>l. content l *\<^sub>R c) p) \<le> e * content({a..b})" (is "?l \<le> ?r")
1.2244 -  apply(rule order_trans,rule norm_setsum) unfolding norm_scaleR setsum_left_distrib[THEN sym]
1.2245 +  apply(rule order_trans,rule norm_setsum) unfolding norm_scaleR setsum_left_distrib[symmetric]
1.2246    apply(rule order_trans[OF mult_left_mono],rule assms,rule setsum_abs_ge_zero)
1.2247    apply(subst mult_commute) apply(rule mult_left_mono)
1.2248    apply(rule order_trans[of _ "setsum content p"]) apply(rule eq_refl,rule setsum_cong2)
1.2249 @@ -2838,11 +3127,11 @@
1.2250  next case False show ?thesis
1.2251      apply(rule order_trans,rule norm_setsum) unfolding split_def norm_scaleR
1.2252      apply(rule order_trans[OF setsum_mono]) apply(rule mult_left_mono[OF _ abs_ge_zero, of _ e]) defer
1.2253 -    unfolding setsum_left_distrib[THEN sym] apply(subst mult_commute) apply(rule mult_left_mono)
1.2254 +    unfolding setsum_left_distrib[symmetric] apply(subst mult_commute) apply(rule mult_left_mono)
1.2255      apply(rule order_trans[of _ "setsum (content \<circ> snd) p"]) apply(rule eq_refl,rule setsum_cong2)
1.2256      apply(subst o_def, rule abs_of_nonneg)
1.2257    proof- show "setsum (content \<circ> snd) p \<le> content {a..b}" apply(rule eq_refl)
1.2258 -      unfolding additive_content_tagged_division[OF assms(1),THEN sym] split_def by auto
1.2259 +      unfolding additive_content_tagged_division[OF assms(1),symmetric] split_def by auto
1.2260      guess w using nonempty_witness[OF False] .
1.2261      thus "e\<ge>0" apply-apply(rule order_trans) defer apply(rule assms(2)[rule_format],assumption) by auto
1.2262      fix xk assume *:"xk\<in>p" guess x k  using surj_pair[of xk] apply-by(erule exE)+ note xk = this *[unfolded this]
1.2263 @@ -2855,7 +3144,7 @@
1.2264    assumes "p tagged_division_of {a..b}"  "\<forall>x\<in>{a..b}. norm(f x - g x) \<le> e"
1.2265    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> e * content({a..b})"
1.2266    apply(rule order_trans[OF _ rsum_bound[OF assms]]) apply(rule eq_refl) apply(rule arg_cong[where f=norm])
1.2267 -  unfolding setsum_subtractf[THEN sym] apply(rule setsum_cong2) unfolding scaleR_diff_right by auto
1.2268 +  unfolding setsum_subtractf[symmetric] apply(rule setsum_cong2) unfolding scaleR_diff_right by auto
1.2269
1.2270  lemma has_integral_bound: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
1.2271    assumes "0 \<le> B" "(f has_integral i) ({a..b})" "\<forall>x\<in>{a..b}. norm(f x) \<le> B"
1.2272 @@ -2863,7 +3152,7 @@
1.2273  proof- let ?P = "content {a..b} > 0" { presume "?P \<Longrightarrow> ?thesis"
1.2274      thus ?thesis proof(cases ?P) case False
1.2275        hence *:"content {a..b} = 0" using content_lt_nz by auto
1.2276 -      hence **:"i = 0" using assms(2) apply(subst has_integral_null_eq[THEN sym]) by auto
1.2277 +      hence **:"i = 0" using assms(2) apply(subst has_integral_null_eq[symmetric]) by auto
1.2278        show ?thesis unfolding * ** using assms(1) by auto
1.2279      qed auto } assume ab:?P
1.2280    { presume "\<not> ?thesis \<Longrightarrow> False" thus ?thesis by auto }
1.2281 @@ -2893,7 +3182,7 @@
1.2282    assumes "(f has_integral i) s" "(g has_integral j) s"  "\<forall>x\<in>s. (f x)\<bullet>k \<le> (g x)\<bullet>k"
1.2283    shows "i\<bullet>k \<le> j\<bullet>k"
1.2284  proof -
1.2285 -  have lem:"\<And>a b i (j::'b). \<And>g f::'a \<Rightarrow> 'b. (f has_integral i) ({a..b}) \<Longrightarrow>
1.2286 +  have lem:"\<And>a b i (j::'b). \<And>g f::'a \<Rightarrow> 'b. (f has_integral i) ({a..b}) \<Longrightarrow>
1.2287      (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"
1.2288    proof (rule ccontr)
1.2289      case goal1
1.2290 @@ -2935,7 +3224,7 @@
1.2291    apply(rule has_integral_component_le) using integrable_integral assms by auto
1.2292
1.2293  lemma has_integral_component_nonneg: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
1.2294 -  assumes "k\<in>Basis" "(f has_integral i) s" "\<forall>x\<in>s. 0 \<le> (f x)\<bullet>k" shows "0 \<le> i\<bullet>k"
1.2295 +  assumes "k\<in>Basis" "(f has_integral i) s" "\<forall>x\<in>s. 0 \<le> (f x)\<bullet>k" shows "0 \<le> i\<bullet>k"
1.2296    using has_integral_component_le[OF assms(1) has_integral_0 assms(2)] using assms(3-) by auto
1.2297
1.2298  lemma integral_component_nonneg: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
1.2299 @@ -2943,7 +3232,7 @@
1.2300    apply(rule has_integral_component_nonneg) using assms by auto
1.2301
1.2302  lemma has_integral_component_neg: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::ordered_euclidean_space"
1.2303 -  assumes "k\<in>Basis" "(f has_integral i) s" "\<forall>x\<in>s. (f x)\<bullet>k \<le> 0"shows "i\<bullet>k \<le> 0"
1.2304 +  assumes "k\<in>Basis" "(f has_integral i) s" "\<forall>x\<in>s. (f x)\<bullet>k \<le> 0"shows "i\<bullet>k \<le> 0"
1.2305    using has_integral_component_le[OF assms(1,2) has_integral_0] assms(2-) by auto
1.2306
1.2307  lemma has_integral_component_lbound:
1.2308 @@ -2966,7 +3255,7 @@
1.2309    apply(rule has_integral_component_lbound) using assms unfolding has_integral_integral by auto
1.2310
1.2311  lemma integral_component_ubound: fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
1.2312 -  assumes "f integrable_on {a..b}" "\<forall>x\<in>{a..b}. f(x)\<bullet>k \<le> B" "k\<in>Basis"
1.2313 +  assumes "f integrable_on {a..b}" "\<forall>x\<in>{a..b}. f(x)\<bullet>k \<le> B" "k\<in>Basis"
1.2314    shows "(integral({a..b}) f)\<bullet>k \<le> B * content({a..b})"
1.2315    apply(rule has_integral_component_ubound) using assms unfolding has_integral_integral by auto
1.2316
1.2317 @@ -2982,7 +3271,7 @@
1.2318    have *:"\<And>P. \<forall>e>(0::real). P e \<Longrightarrow> \<forall>n::nat. P (inverse (real n+1))" by auto
1.2319    from choice[OF *[OF assms]] guess g .. note g=conjunctD2[OF this[rule_format],rule_format]
1.2320    from choice[OF allI[OF g(2)[unfolded integrable_on_def], of "\<lambda>x. x"]] guess i .. note i=this[rule_format]
1.2321 -
1.2322 +
1.2323    have "Cauchy i" unfolding Cauchy_def
1.2324    proof(rule,rule) fix e::real assume "e>0"
1.2325      hence "e / 4 / content {a..b} > 0" using as by(auto simp add:field_simps)
1.2326 @@ -3003,10 +3292,10 @@
1.2327          apply(rule gm(2)[OF conjI[OF p(1)]],rule_tac[2] gn(2)[OF conjI[OF p(1)]])
1.2328          using conjunctD2[OF p(2)[unfolded fine_inter]] apply- apply assumption+ apply(rule order_trans)
1.2329          apply(rule rsum_diff_bound[OF p(1), where e="2 / real M"])
1.2330 -      proof show "2 / real M * content {a..b} \<le> e / 2" unfolding divide_inverse
1.2331 +      proof show "2 / real M * content {a..b} \<le> e / 2" unfolding divide_inverse
1.2332            using M as by(auto simp add:field_simps)
1.2333          fix x assume x:"x \<in> {a..b}"
1.2334 -        have "norm (f x - g n x) + norm (f x - g m x) \<le> inverse (real n + 1) + inverse (real m + 1)"
1.2335 +        have "norm (f x - g n x) + norm (f x - g m x) \<le> inverse (real n + 1) + inverse (real m + 1)"
1.2336              using g(1)[OF x, of n] g(1)[OF x, of m] by auto
1.2337          also have "\<dots> \<le> inverse (real M) + inverse (real M)" apply(rule add_mono)
1.2338            apply(rule_tac[!] le_imp_inverse_le) using goal1 M by auto
1.2339 @@ -3015,10 +3304,10 @@
1.2340            using norm_triangle_le[of "g n x - f x" "f x - g m x" "2 / real M"]
1.2342        qed qed qed
1.2343 -  from this[unfolded convergent_eq_cauchy[THEN sym]] guess s .. note s=this
1.2344 +  from this[unfolded convergent_eq_cauchy[symmetric]] guess s .. note s=this
1.2345
1.2346    show ?thesis unfolding integrable_on_def apply(rule_tac x=s in exI) unfolding has_integral
1.2347 -  proof(rule,rule)
1.2348 +  proof(rule,rule)
1.2349      case goal1 hence *:"e/3 > 0" by auto
1.2350      from LIMSEQ_D [OF s this] guess N1 .. note N1=this
1.2351      from goal1 as have "e / 3 / content {a..b} > 0" by(auto simp add:field_simps)
1.2352 @@ -3038,7 +3327,7 @@
1.2353        proof- have "content {a..b} < e / 3 * (real N2)"
1.2354            using N2 unfolding inverse_eq_divide using as by(auto simp add:field_simps)
1.2355          hence "content {a..b} < e / 3 * (real (N1 + N2) + 1)"
1.2356 -          apply-apply(rule less_le_trans,assumption) using `e>0` by auto
1.2357 +          apply-apply(rule less_le_trans,assumption) using `e>0` by auto
1.2358          thus "inverse (real (N1 + N2) + 1) * content {a..b} \<le> e / 3"
1.2359            unfolding inverse_eq_divide by(auto simp add:field_simps)
1.2360          show "norm (i (N1 + N2) - s) < e / 3" by(rule N1[rule_format],auto)
1.2361 @@ -3050,17 +3339,17 @@
1.2362
1.2363  subsection {* Negligibility of hyperplane. *}
1.2364
1.2365 -lemma vsum_nonzero_image_lemma:
1.2366 +lemma vsum_nonzero_image_lemma:
1.2367    assumes "finite s" "g(a) = 0"
1.2368    "\<forall>x\<in>s. \<forall>y\<in>s. f x = f y \<and> x \<noteq> y \<longrightarrow> g(f x) = 0"
1.2369    shows "setsum g {f x |x. x \<in> s \<and> f x \<noteq> a} = setsum (g o f) s"
1.2370    unfolding setsum_iterate[OF assms(1)] apply(subst setsum_iterate) defer
1.2371    apply(rule iterate_nonzero_image_lemma) apply(rule assms monoidal_monoid)+
1.2372 -  unfolding assms using neutral_add unfolding neutral_add using assms by auto
1.2373 +  unfolding assms using neutral_add unfolding neutral_add using assms by auto
1.2374
1.2375  lemma interval_doublesplit:  fixes a::"'a::ordered_euclidean_space" assumes "k\<in>Basis"
1.2376 -  shows "{a..b} \<inter> {x . abs(x\<bullet>k - c) \<le> (e::real)} =
1.2377 -  {(\<Sum>i\<in>Basis. (if i = k then max (a\<bullet>k) (c - e) else a\<bullet>i) *\<^sub>R i) ..
1.2378 +  shows "{a..b} \<inter> {x . abs(x\<bullet>k - c) \<le> (e::real)} =
1.2379 +  {(\<Sum>i\<in>Basis. (if i = k then max (a\<bullet>k) (c - e) else a\<bullet>i) *\<^sub>R i) ..
1.2380     (\<Sum>i\<in>Basis. (if i = k then min (b\<bullet>k) (c + e) else b\<bullet>i) *\<^sub>R i)}"
1.2381  proof- have *:"\<And>x c e::real. abs(x - c) \<le> e \<longleftrightarrow> x \<ge> c - e \<and> x \<le> c + e" by auto
1.2382    have **:"\<And>s P Q. s \<inter> {x. P x \<and> Q x} = (s \<inter> {x. Q x}) \<inter> {x. P x}" by blast
1.2383 @@ -3071,7 +3360,7 @@
1.2384  proof- have *:"\<And>x c. abs(x - c) \<le> e \<longleftrightarrow> x \<ge> c - e \<and> x \<le> c + e" by auto
1.2385    have **:"\<And>p q p' q'. p division_of q \<Longrightarrow> p = p' \<Longrightarrow> q = q' \<Longrightarrow> p' division_of q'" by auto
1.2386    note division_split(1)[OF assms, where c="c+e",unfolded interval_split[OF k]]
1.2387 -  note division_split(2)[OF this, where c="c-e" and k=k,OF k]
1.2388 +  note division_split(2)[OF this, where c="c-e" and k=k,OF k]
1.2389    thus ?thesis apply(rule **) using k apply- unfolding interval_doublesplit unfolding * unfolding interval_split interval_doublesplit
1.2390      apply(rule set_eqI) unfolding mem_Collect_eq apply rule apply(erule conjE exE)+ apply(rule_tac x=la in exI) defer
1.2391      apply(erule conjE exE)+ apply(rule_tac x="l \<inter> {x. c + e \<ge> x \<bullet> k}" in exI) apply rule defer apply rule
1.2392 @@ -3082,17 +3371,17 @@
1.2393  proof(cases "content {a..b} = 0")
1.2394    case True show ?thesis apply(rule that[of 1]) defer unfolding interval_doublesplit[OF k]
1.2395      apply(rule le_less_trans[OF content_subset]) defer apply(subst True)
1.2396 -    unfolding interval_doublesplit[THEN sym,OF k] using assms by auto
1.2397 +    unfolding interval_doublesplit[symmetric,OF k] using assms by auto
1.2398  next case False def d \<equiv> "e / 3 / setprod (\<lambda>i. b\<bullet>i - a\<bullet>i) (Basis - {k})"
1.2399    note False[unfolded content_eq_0 not_ex not_le, rule_format]
1.2400    hence "\<And>x. x\<in>Basis \<Longrightarrow> b\<bullet>x > a\<bullet>x" by(auto simp add:not_le)
1.2401    hence prod0:"0 < setprod (\<lambda>i. b\<bullet>i - a\<bullet>i) (Basis - {k})" apply-apply(rule setprod_pos) by(auto simp add:field_simps)
1.2402    hence "d > 0" unfolding d_def using assms by(auto simp add:field_simps) thus ?thesis
1.2403    proof(rule that[of d]) have *:"Basis = insert k (Basis - {k})" using k by auto
1.2404 -    have **:"{a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {} \<Longrightarrow>
1.2405 +    have **:"{a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {} \<Longrightarrow>
1.2406        (\<Prod>i\<in>Basis - {k}. interval_upperbound ({a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<bullet> i
1.2407        - interval_lowerbound ({a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<bullet> i)
1.2408 -      = (\<Prod>i\<in>Basis - {k}. b\<bullet>i - a\<bullet>i)" apply(rule setprod_cong,rule refl)
1.2409 +      = (\<Prod>i\<in>Basis - {k}. b\<bullet>i - a\<bullet>i)" apply(rule setprod_cong,rule refl)
1.2410        unfolding interval_doublesplit[OF k] apply(subst interval_bounds) defer apply(subst interval_bounds)
1.2411        unfolding interval_eq_empty not_ex not_less by auto
1.2412      show "content ({a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) < e" apply(cases) unfolding content_def apply(subst if_P,assumption,rule assms)
1.2413 @@ -3109,10 +3398,10 @@
1.2414    qed
1.2415  qed
1.2416
1.2417 -lemma negligible_standard_hyperplane[intro]:
1.2418 +lemma negligible_standard_hyperplane[intro]:
1.2419    fixes k :: "'a::ordered_euclidean_space"
1.2420    assumes k: "k \<in> Basis"
1.2421 -  shows "negligible {x. x\<bullet>k = c}"
1.2422 +  shows "negligible {x. x\<bullet>k = c}"
1.2423    unfolding negligible_def has_integral apply(rule,rule,rule,rule)
1.2424  proof-
1.2425    case goal1 from content_doublesplit[OF this k,of a b c] guess d . note d=this
1.2426 @@ -3136,30 +3425,30 @@
1.2427        prefer 2 apply(subst(asm) eq_commute) apply assumption
1.2428        apply(subst interval_doublesplit[OF k]) apply(rule content_pos_le) apply(rule indicator_pos_le)
1.2429      proof- have "(\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) * ?i x) \<le> (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}))"
1.2430 -        apply(rule setsum_mono) unfolding split_paired_all split_conv
1.2431 +        apply(rule setsum_mono) unfolding split_paired_all split_conv
1.2432          apply(rule mult_right_le_one_le) apply(drule p'(4)) by(auto simp add:interval_doublesplit[OF k])
1.2433        also have "... < e" apply(subst setsum_over_tagged_division_lemma[OF p[THEN conjunct1]])
1.2434        proof- case goal1 have "content ({u..v} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<le> content {u..v}"
1.2435 -          unfolding interval_doublesplit[OF k] apply(rule content_subset) unfolding interval_doublesplit[THEN sym,OF k] by auto
1.2436 +          unfolding interval_doublesplit[OF k] apply(rule content_subset) unfolding interval_doublesplit[symmetric,OF k] by auto
1.2437          thus ?case unfolding goal1 unfolding interval_doublesplit[OF k]
1.2438            by (blast intro: antisym)
1.2439        next have *:"setsum content {l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} |l. l \<in> snd ` p \<and> l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {}} \<ge> 0"
1.2440 -          apply(rule setsum_nonneg,rule) unfolding mem_Collect_eq image_iff apply(erule exE bexE conjE)+ unfolding split_paired_all
1.2441 +          apply(rule setsum_nonneg,rule) unfolding mem_Collect_eq image_iff apply(erule exE bexE conjE)+ unfolding split_paired_all
1.2442          proof- fix x l a b assume as:"x = l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}" "(a, b) \<in> p" "l = snd (a, b)"
1.2443            guess u v using p'(4)[OF as(2)] apply-by(erule exE)+ note * = this
1.2444            show "content x \<ge> 0" unfolding as snd_conv * interval_doublesplit[OF k] by(rule content_pos_le)
1.2445          qed have **:"norm (1::real) \<le> 1" by auto note division_doublesplit[OF p'' k,unfolded interval_doublesplit[OF k]]
1.2446 -        note dsum_bound[OF this **,unfolded interval_doublesplit[THEN sym,OF k]]
1.2447 +        note dsum_bound[OF this **,unfolded interval_doublesplit[symmetric,OF k]]
1.2448          note this[unfolded real_scaleR_def real_norm_def mult_1_right mult_1, of c d] note le_less_trans[OF this d(2)]
1.2449          from this[unfolded abs_of_nonneg[OF *]] show "(\<Sum>ka\<in>snd ` p. content (ka \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d})) < e"
1.2450 -          apply(subst vsum_nonzero_image_lemma[of "snd ` p" content "{}", unfolded o_def,THEN sym])
1.2451 +          apply(subst vsum_nonzero_image_lemma[of "snd ` p" content "{}", unfolded o_def,symmetric])
1.2452            apply(rule finite_imageI p' content_empty)+ unfolding forall_in_division[OF p'']
1.2453          proof(rule,rule,rule,rule,rule,rule,rule,erule conjE) fix m n u v
1.2454            assume as:"{m..n} \<in> snd ` p" "{u..v} \<in> snd ` p" "{m..n} \<noteq> {u..v}"  "{m..n} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} = {u..v} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}"
1.2455            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}" by blast
1.2456            note interior_mono[OF this, unfolded division_ofD(5)[OF p'' as(1-3)] interior_inter[of "{m..n}"]]
1.2457            hence "interior ({m..n} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) = {}" unfolding as Int_absorb by auto
1.2458 -          thus "content ({m..n} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) = 0" unfolding interval_doublesplit[OF k] content_eq_0_interior[THEN sym] .
1.2459 +          thus "content ({m..n} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) = 0" unfolding interval_doublesplit[OF k] content_eq_0_interior[symmetric] .
1.2460          qed qed
1.2461        finally show "(\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) * ?i x) < e" .
1.2462      qed qed qed
1.2463 @@ -3177,7 +3466,7 @@
1.2464      presume "\<And>p. finite p \<Longrightarrow> ?P p" from this[rule_format,OF * assms(2)] guess q .. note q=this
1.2465      thus ?thesis apply-apply(rule that[of q]) unfolding tagged_division_ofD[OF assms(1)] by auto
1.2466    } fix p::"(('a::ordered_euclidean_space) \<times> (('a::ordered_euclidean_space) set)) set" assume as:"finite p"
1.2467 -  show "?P p" apply(rule,rule) using as proof(induct p)
1.2468 +  show "?P p" apply(rule,rule) using as proof(induct p)
1.2469      case empty show ?case apply(rule_tac x="{}" in exI) unfolding fine_def by auto
1.2470    next case (insert xk p) guess x k using surj_pair[of xk] apply- by(erule exE)+ note xk=this
1.2471      note tagged_partial_division_subset[OF insert(4) subset_insertI]
1.2472 @@ -3186,19 +3475,19 @@
1.2473      note p = tagged_partial_division_ofD[OF insert(4)]
1.2474      from p(4)[unfolded xk, OF insertI1] guess u v apply-by(erule exE)+ note uv=this
1.2475
1.2476 -    have "finite {k. \<exists>x. (x, k) \<in> p}"
1.2477 +    have "finite {k. \<exists>x. (x, k) \<in> p}"
1.2478        apply(rule finite_subset[of _ "snd ` p"],rule) unfolding subset_eq image_iff mem_Collect_eq
1.2479        apply(erule exE,rule_tac x="(xa,x)" in bexI) using p by auto
1.2480      hence int:"interior {u..v} \<inter> interior (\<Union>{k. \<exists>x. (x, k) \<in> p}) = {}"
1.2481        apply(rule inter_interior_unions_intervals) apply(rule open_interior) apply(rule_tac[!] ballI)
1.2482 -      unfolding mem_Collect_eq apply(erule_tac[!] exE) apply(drule p(4)[OF insertI2],assumption)
1.2483 +      unfolding mem_Collect_eq apply(erule_tac[!] exE) apply(drule p(4)[OF insertI2],assumption)
1.2484        apply(rule p(5))  unfolding uv xk apply(rule insertI1,rule insertI2) apply assumption
1.2485        using insert(2) unfolding uv xk by auto
1.2486
1.2487      show ?case proof(cases "{u..v} \<subseteq> d x")
1.2488        case True thus ?thesis apply(rule_tac x="{(x,{u..v})} \<union> q1" in exI) apply rule
1.2489          unfolding * uv apply(rule tagged_division_union,rule tagged_division_of_self)
1.2490 -        apply(rule p[unfolded xk uv] insertI1)+  apply(rule q1,rule int)
1.2491 +        apply(rule p[unfolded xk uv] insertI1)+  apply(rule q1,rule int)
1.2492          apply(rule,rule fine_union,subst fine_def) defer apply(rule q1)
1.2493          unfolding Ball_def split_paired_All split_conv apply(rule,rule,rule,rule)
1.2494          apply(erule insertE) defer apply(rule UnI2) apply(drule q1(3)[rule_format]) unfolding xk uv by auto
1.2495 @@ -3214,7 +3503,7 @@
1.2496
1.2497  lemma finite_product_dependent: assumes "finite s" "\<And>x. x\<in>s\<Longrightarrow> finite (t x)"
1.2498    shows "finite {(i, j) |i j. i \<in> s \<and> j \<in> t i}" using assms
1.2499 -proof(induct) case (insert x s)
1.2500 +proof(induct) case (insert x s)
1.2501    have *:"{(i, j) |i j. i \<in> insert x s \<and> j \<in> t i} = (\<lambda>y. (x,y)) ` (t x) \<union> {(i, j) |i j. i \<in> s \<and> j \<in> t i}" by auto
1.2502    show ?case unfolding * apply(rule finite_UnI) using insert by auto qed auto
1.2503
1.2504 @@ -3241,16 +3530,16 @@
1.2505        apply(safe,rule_tac x=1 in exI,rule) apply(rule zero_less_one,safe) apply(rule_tac x=0 in exI)
1.2506        apply(rule,rule P) using assms(2) by auto
1.2507    qed
1.2508 -next fix f::"'b \<Rightarrow> 'a" and a b::"'b" assume assm:"\<forall>x. x \<notin> s \<longrightarrow> f x = 0"
1.2509 +next fix f::"'b \<Rightarrow> 'a" and a b::"'b" assume assm:"\<forall>x. x \<notin> s \<longrightarrow> f x = 0"
1.2510    show "(f has_integral 0) {a..b}" unfolding has_integral
1.2511    proof(safe) case goal1
1.2512 -    hence "\<And>n. e / 2 / ((real n+1) * (2 ^ n)) > 0"
1.2513 +    hence "\<And>n. e / 2 / ((real n+1) * (2 ^ n)) > 0"
1.2514        apply-apply(rule divide_pos_pos) defer apply(rule mult_pos_pos) by(auto simp add:field_simps)
1.2515 -    note assms(1)[unfolded negligible_def has_integral,rule_format,OF this,of a b] note allI[OF this,of "\<lambda>x. x"]
1.2516 +    note assms(1)[unfolded negligible_def has_integral,rule_format,OF this,of a b] note allI[OF this,of "\<lambda>x. x"]
1.2517      from choice[OF this] guess d .. note d=conjunctD2[OF this[rule_format]]
1.2518 -    show ?case apply(rule_tac x="\<lambda>x. d (nat \<lfloor>norm (f x)\<rfloor>) x" in exI)
1.2519 +    show ?case apply(rule_tac x="\<lambda>x. d (nat \<lfloor>norm (f x)\<rfloor>) x" in exI)
1.2520      proof safe show "gauge (\<lambda>x. d (nat \<lfloor>norm (f x)\<rfloor>) x)" using d(1) unfolding gauge_def by auto
1.2521 -      fix p assume as:"p tagged_division_of {a..b}" "(\<lambda>x. d (nat \<lfloor>norm (f x)\<rfloor>) x) fine p"
1.2522 +      fix p assume as:"p tagged_division_of {a..b}" "(\<lambda>x. d (nat \<lfloor>norm (f x)\<rfloor>) x) fine p"
1.2523        let ?goal = "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) < e"
1.2524        { presume "p\<noteq>{} \<Longrightarrow> ?goal" thus ?goal apply(cases "p={}") using goal1 by auto  }
1.2525        assume as':"p \<noteq> {}" from real_arch_simple[of "Sup((\<lambda>(x,k). norm(f x)) ` p)"] guess N ..
1.2526 @@ -3258,7 +3547,7 @@
1.2527        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)"
1.2528          apply(rule,rule tagged_division_finer[OF as(1) d(1)]) by auto
1.2529        from choice[OF this] guess q .. note q=conjunctD3[OF this[rule_format]]
1.2530 -      have *:"\<And>i. (\<Sum>(x, k)\<in>q i. content k *\<^sub>R indicator s x) \<ge> (0::real)" apply(rule setsum_nonneg,safe)
1.2531 +      have *:"\<And>i. (\<Sum>(x, k)\<in>q i. content k *\<^sub>R indicator s x) \<ge> (0::real)" apply(rule setsum_nonneg,safe)
1.2532          unfolding real_scaleR_def apply(rule mult_nonneg_nonneg) apply(drule tagged_division_ofD(4)[OF q(1)]) by auto
1.2533        have **:"\<And>f g s t. finite s \<Longrightarrow> finite t \<Longrightarrow> (\<forall>(x,y) \<in> t. (0::real) \<le> g(x,y)) \<Longrightarrow> (\<forall>y\<in>s. \<exists>x. (x,y) \<in> t \<and> f(y) \<le> g(x,y)) \<Longrightarrow> setsum f s \<le> setsum g t"
1.2534        proof- case goal1 thus ?case apply-apply(rule setsum_le_included[of s t g snd f]) prefer 4
1.2535 @@ -3266,7 +3555,7 @@
1.2536        have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) \<le> setsum (\<lambda>i. (real i + 1) *
1.2537                       norm(setsum (\<lambda>(x,k). content k *\<^sub>R indicator s x :: real) (q i))) {0..N+1}"
1.2538          unfolding real_norm_def setsum_right_distrib abs_of_nonneg[OF *] diff_0_right
1.2539 -        apply(rule order_trans,rule norm_setsum) apply(subst sum_sum_product) prefer 3
1.2540 +        apply(rule order_trans,rule norm_setsum) apply(subst sum_sum_product) prefer 3
1.2541        proof(rule **,safe) show "finite {(i, j) |i j. i \<in> {0..N + 1} \<and> j \<in> q i}" apply(rule finite_product_dependent) using q by auto
1.2542          fix i a b assume as'':"(a,b) \<in> q i" show "0 \<le> (real i + 1) * (content b *\<^sub>R indicator s a)"
1.2543            unfolding real_scaleR_def apply(rule mult_nonneg_nonneg) defer apply(rule mult_nonneg_nonneg)
1.2544 @@ -3286,11 +3575,11 @@
1.2545          qed ultimately show "\<exists>y. (y, x, k) \<in> {(i, j) |i j. i \<in> {0..N + 1} \<and> j \<in> q i} \<and> norm (content k *\<^sub>R f x) \<le> (real y + 1) * (content k *\<^sub>R indicator s x)"
1.2546            apply(rule_tac x=n in exI,safe) apply(rule_tac x=n in exI,rule_tac x="(x,k)" in exI,safe) by auto
1.2547        qed(insert as, auto)
1.2548 -      also have "... \<le> setsum (\<lambda>i. e / 2 / 2 ^ i) {0..N+1}" apply(rule setsum_mono)
1.2549 -      proof- case goal1 thus ?case apply(subst mult_commute, subst pos_le_divide_eq[THEN sym])
1.2550 +      also have "... \<le> setsum (\<lambda>i. e / 2 / 2 ^ i) {0..N+1}" apply(rule setsum_mono)
1.2551 +      proof- case goal1 thus ?case apply(subst mult_commute, subst pos_le_divide_eq[symmetric])
1.2552            using d(2)[rule_format,of "q i" i] using q[rule_format] by(auto simp add:field_simps)
1.2553 -      qed also have "... < e * inverse 2 * 2" unfolding divide_inverse setsum_right_distrib[THEN sym]
1.2554 -        apply(rule mult_strict_left_mono) unfolding power_inverse atLeastLessThanSuc_atLeastAtMost[THEN sym]
1.2555 +      qed also have "... < e * inverse 2 * 2" unfolding divide_inverse setsum_right_distrib[symmetric]
1.2556 +        apply(rule mult_strict_left_mono) unfolding power_inverse atLeastLessThanSuc_atLeastAtMost[symmetric]
1.2557          apply(subst sumr_geometric) using goal1 by auto
1.2558        finally show "?goal" by auto qed qed qed
1.2559
1.2560 @@ -3323,7 +3612,7 @@
1.2561
1.2562  subsection {* Some other trivialities about negligible sets. *}
1.2563
1.2564 -lemma negligible_subset[intro]: assumes "negligible s" "t \<subseteq> s" shows "negligible t" unfolding negligible_def
1.2565 +lemma negligible_subset[intro]: assumes "negligible s" "t \<subseteq> s" shows "negligible t" unfolding negligible_def
1.2566  proof(safe) case goal1 show ?case using assms(1)[unfolded negligible_def,rule_format,of a b]
1.2567      apply-apply(rule has_integral_spike[OF assms(1)]) defer apply assumption
1.2568      using assms(2) unfolding indicator_def by auto qed
1.2569 @@ -3332,7 +3621,7 @@
1.2570
1.2571  lemma negligible_inter: assumes "negligible s \<or> negligible t" shows "negligible(s \<inter> t)" using assms by auto
1.2572
1.2573 -lemma negligible_union: assumes "negligible s" "negligible t" shows "negligible (s \<union> t)" unfolding negligible_def
1.2574 +lemma negligible_union: assumes "negligible s" "negligible t" shows "negligible (s \<union> t)" unfolding negligible_def
1.2575  proof safe case goal1 note assm = assms[unfolded negligible_def,rule_format,of a b]
1.2576    thus ?case apply(subst has_integral_spike_eq[OF assms(2)])
1.2577      defer apply assumption unfolding indicator_def by auto qed
1.2578 @@ -3340,8 +3629,8 @@
1.2579  lemma negligible_union_eq[simp]: "negligible (s \<union> t) \<longleftrightarrow> (negligible s \<and> negligible t)"
1.2580    using negligible_union by auto
1.2581
1.2582 -lemma negligible_sing[intro]: "negligible {a::_::ordered_euclidean_space}"
1.2583 -  using negligible_standard_hyperplane[OF SOME_Basis, of "a \<bullet> (SOME i. i \<in> Basis)"] by auto
1.2584 +lemma negligible_sing[intro]: "negligible {a::_::ordered_euclidean_space}"
1.2585 +  using negligible_standard_hyperplane[OF SOME_Basis, of "a \<bullet> (SOME i. i \<in> Basis)"] by auto
1.2586
1.2587  lemma negligible_insert[simp]: "negligible(insert a s) \<longleftrightarrow> negligible s"
1.2588    apply(subst insert_is_Un) unfolding negligible_union_eq by auto
1.2589 @@ -3352,7 +3641,7 @@
1.2590    using assms apply(induct s) by auto
1.2591
1.2592  lemma negligible_unions[intro]: assumes "finite s" "\<forall>t\<in>s. negligible t" shows "negligible(\<Union>s)"
1.2593 -  using assms by(induct,auto)
1.2594 +  using assms by(induct,auto)
1.2595
1.2596  lemma negligible:  "negligible s \<longleftrightarrow> (\<forall>t::('a::ordered_euclidean_space) set. ((indicator s::'a\<Rightarrow>real) has_integral 0) t)"
1.2597    apply safe defer apply(subst negligible_def)
1.2598 @@ -3377,7 +3666,7 @@
1.2599
1.2600  subsection {* Finite case of the spike theorem is quite commonly needed. *}
1.2601
1.2602 -lemma has_integral_spike_finite: assumes "finite s" "\<forall>x\<in>t-s. g x = f x"
1.2603 +lemma has_integral_spike_finite: assumes "finite s" "\<forall>x\<in>t-s. g x = f x"
1.2604    "(f has_integral y) t" shows "(g has_integral y) t"
1.2605    apply(rule has_integral_spike) using assms by auto
1.2606
1.2607 @@ -3438,7 +3727,7 @@
1.2608  proof safe
1.2609    fix a b::"'b"
1.2610    { assume "content {a..b} = 0"
1.2611 -    thus "\<exists>g. (\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b}"
1.2612 +    thus "\<exists>g. (\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b}"
1.2613        apply(rule_tac x=f in exI) using assms by(auto intro!:integrable_on_null) }
1.2614    { fix c g and k :: 'b
1.2615      assume as:"\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e" "g integrable_on {a..b}" and k:"k\<in>Basis"
1.2616 @@ -3452,7 +3741,7 @@
1.2617    show "\<exists>g. (\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b}" apply(rule_tac x="?g" in exI)
1.2618    proof safe case goal1 thus ?case apply- apply(cases "x\<bullet>k=c", case_tac "x\<bullet>k < c") using as assms by auto
1.2619    next case goal2 presume "?g integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c}" "?g integrable_on {a..b} \<inter> {x. x \<bullet> k \<ge> c}"
1.2620 -    then guess h1 h2 unfolding integrable_on_def by auto from has_integral_split[OF this k]
1.2621 +    then guess h1 h2 unfolding integrable_on_def by auto from has_integral_split[OF this k]
1.2622      show ?case unfolding integrable_on_def by auto
1.2623    next 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}"
1.2624        apply(rule_tac[!] integrable_spike[OF negligible_standard_hyperplane[of k c]]) using k as(2,4) by auto qed qed
1.2625 @@ -3472,7 +3761,7 @@
1.2626    from fine_division_exists[OF gauge_ball[OF d(1)], of a b] guess p . note p=this
1.2627    note p' = tagged_division_ofD[OF p(1)]
1.2628    have *:"\<forall>i\<in>snd ` p. \<exists>g. (\<forall>x\<in>i. norm (f x - g x) \<le> e) \<and> g integrable_on i"
1.2629 -  proof(safe,unfold snd_conv) fix x l assume as:"(x,l) \<in> p"
1.2630 +  proof(safe,unfold snd_conv) fix x l assume as:"(x,l) \<in> p"
1.2631      from p'(4)[OF this] guess a b apply-by(erule exE)+ note l=this
1.2632      show "\<exists>g. (\<forall>x\<in>l. norm (f x - g x) \<le> e) \<and> g integrable_on l" apply(rule_tac x="\<lambda>y. f x" in exI)
1.2633      proof safe show "(\<lambda>y. f x) integrable_on l" unfolding integrable_on_def l by(rule,rule has_integral_const)
1.2634 @@ -3480,11 +3769,11 @@
1.2635        note d(2)[OF _ _ this[unfolded mem_ball]]
1.2636        thus "norm (f y - f x) \<le> e" using y p'(2-3)[OF as] unfolding dist_norm l norm_minus_commute by fastforce qed qed
1.2637    from e have "0 \<le> e" by auto from approximable_on_division[OF this division_of_tagged_division[OF p(1)] *] guess g .
1.2638 -  thus "\<exists>g. (\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b}" by auto qed
1.2639 +  thus "\<exists>g. (\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b}" by auto qed
1.2640
1.2641  subsection {* Specialization of additivity to one dimension. *}
1.2642
1.2643 -lemma
1.2644 +lemma
1.2645    shows real_inner_1_left: "inner 1 x = x"
1.2646    and real_inner_1_right: "inner x 1 = x"
1.2647    by simp_all
1.2648 @@ -3510,9 +3799,9 @@
1.2649      qed
1.2650    next case True hence *:"min (b) c = c" "max a c = c" by auto
1.2651      have **: "(1::real) \<in> Basis" by simp
1.2652 -    have ***:"\<And>P Q. (\<Sum>i\<in>Basis. (if i = 1 then P i else Q i) *\<^sub>R i) = (P 1::real)"
1.2653 +    have ***:"\<And>P Q. (\<Sum>i\<in>Basis. (if i = 1 then P i else Q i) *\<^sub>R i) = (P 1::real)"
1.2654        by simp
1.2655 -    show ?thesis
1.2656 +    show ?thesis
1.2657        unfolding interval_split[OF **, unfolded real_inner_1_right] unfolding *** *
1.2658      proof(cases "c = a \<or> c = b")
1.2659        case False thus "f {a..b} = opp (f {a..c}) (f {c..b})"
1.2660 @@ -3540,7 +3829,7 @@
1.2661        proof(erule disjE) assume *:"c=a" hence "f {a..c} = neutral opp" apply-apply(rule as(1)[rule_format]) by auto
1.2662          thus ?thesis using assms unfolding * by auto
1.2663        next               assume *:"c=b" hence "f {c..b} = neutral opp" apply-apply(rule as(1)[rule_format]) by auto
1.2664 -        thus ?thesis using assms unfolding * by auto qed qed qed
1.2665 +        thus ?thesis using assms unfolding * by auto qed qed qed
1.2666
1.2667  subsection {* Special case of additivity we need for the FCT. *}
1.2668
1.2669 @@ -3554,8 +3843,8 @@
1.2670    have ***:"\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i" using assms by auto
1.2671    have *:"operative op + ?f" unfolding operative_1_lt[OF monoidal_monoid] interval_eq_empty by auto
1.2672    have **:"{a..b} \<noteq> {}" using assms(1) by auto note operative_tagged_division[OF monoidal_monoid * assms(2)]
1.2673 -  note * = this[unfolded if_not_P[OF **] interval_bounds[OF ***],THEN sym]
1.2674 -  show ?thesis unfolding * apply(subst setsum_iterate[THEN sym]) defer
1.2675 +  note * = this[unfolded if_not_P[OF **] interval_bounds[OF ***],symmetric]
1.2676 +  show ?thesis unfolding * apply(subst setsum_iterate[symmetric]) defer
1.2677      apply(rule setsum_cong2) unfolding split_paired_all split_conv using assms(2) by auto qed
1.2678
1.2679  subsection {* A useful lemma allowing us to factor out the content size. *}
1.2680 @@ -3565,10 +3854,10 @@
1.2681      \<longrightarrow> norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - i) \<le> e * content {a..b}))"
1.2682  proof(cases "content {a..b} = 0")
1.2683    case True show ?thesis unfolding has_integral_null_eq[OF True] apply safe
1.2684 -    apply(rule,rule,rule gauge_trivial,safe) unfolding setsum_content_null[OF True] True defer
1.2685 +    apply(rule,rule,rule gauge_trivial,safe) unfolding setsum_content_null[OF True] True defer
1.2686      apply(erule_tac x=1 in allE,safe) defer apply(rule fine_division_exists[of _ a b],assumption)
1.2687      apply(erule_tac x=p in allE) unfolding setsum_content_null[OF True] by auto
1.2688 -next case False note F = this[unfolded content_lt_nz[THEN sym]]
1.2689 +next case False note F = this[unfolded content_lt_nz[symmetric]]
1.2690    let ?P = "\<lambda>e opp. \<exists>d. gauge d \<and> (\<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)"
1.2691    show ?thesis apply(subst has_integral)
1.2692    proof safe fix e::real assume e:"e>0"
1.2693 @@ -3599,10 +3888,10 @@
1.2694      apply(rule_tac x="\<lambda>x. ball x (d x)" in exI,safe)
1.2695      apply(rule gauge_ball_dependent,rule,rule d(1))
1.2696    proof- fix p assume as:"p tagged_division_of {a..b}" "(\<lambda>x. ball x (d x)) fine p"
1.2697 -    show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f' x) - (f b - f a)) \<le> e * content {a..b}"
1.2698 -      unfolding content_real[OF assms(1)] additive_tagged_division_1[OF assms(1) as(1),of f,THEN sym]
1.2699 -      unfolding additive_tagged_division_1[OF assms(1) as(1),of "\<lambda>x. x",THEN sym]
1.2700 -      unfolding setsum_right_distrib defer unfolding setsum_subtractf[THEN sym]
1.2701 +    show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f' x) - (f b - f a)) \<le> e * content {a..b}"
1.2702 +      unfolding content_real[OF assms(1)] additive_tagged_division_1[OF assms(1) as(1),of f,symmetric]
1.2703 +      unfolding additive_tagged_division_1[OF assms(1) as(1),of "\<lambda>x. x",symmetric]
1.2704 +      unfolding setsum_right_distrib defer unfolding setsum_subtractf[symmetric]
1.2705      proof(rule setsum_norm_le,safe) fix x k assume "(x,k)\<in>p"
1.2706        note xk = tagged_division_ofD(2-4)[OF as(1) this] from this(3) guess u v apply-by(erule exE)+ note k=this
1.2707        have *:"u \<le> v" using xk unfolding k by auto
1.2708 @@ -3615,8 +3904,8 @@
1.2709        also have "... \<le> e * norm (u - x) + e * norm (v - x)"
1.2710          apply(rule add_mono) apply(rule d(2)[of "x" "u",unfolded o_def]) prefer 4
1.2711          apply(rule d(2)[of "x" "v",unfolded o_def])
1.2712 -        using ball[rule_format,of u] ball[rule_format,of v]
1.2713 -        using xk(1-2) unfolding k subset_eq by(auto simp add:dist_real_def)
1.2714 +        using ball[rule_format,of u] ball[rule_format,of v]
1.2715 +        using xk(1-2) unfolding k subset_eq by(auto simp add:dist_real_def)
1.2716        also have "... \<le> e * (interval_upperbound k - interval_lowerbound k)"
1.2717          unfolding k interval_bounds_real[OF *] using xk(1) unfolding k by(auto simp add:dist_real_def field_simps)
1.2718        finally show "norm (content k *\<^sub>R f' x - (f (interval_upperbound k) - f (interval_lowerbound k))) \<le>
1.2719 @@ -3638,7 +3927,7 @@
1.2720    shows "{k. k \<in> s \<and> content k \<noteq> 0} division_of {a..b}" using assms(1) apply-
1.2721  proof(induct "card s" arbitrary:s rule:nat_less_induct)
1.2722    fix s::"'a set set" assume assm:"s division_of {a..b}"
1.2723 -    "\<forall>m<card s. \<forall>x. m = card x \<longrightarrow> x division_of {a..b} \<longrightarrow> {k \<in> x. content k \<noteq> 0} division_of {a..b}"
1.2724 +    "\<forall>m<card s. \<forall>x. m = card x \<longrightarrow> x division_of {a..b} \<longrightarrow> {k \<in> x. content k \<noteq> 0} division_of {a..b}"
1.2725    note s = division_ofD[OF assm(1)] let ?thesis = "{k \<in> s. content k \<noteq> 0} division_of {a..b}"
1.2726    { presume *:"{k \<in> s. content k \<noteq> 0} \<noteq> s \<Longrightarrow> ?thesis"
1.2727      show ?thesis apply cases defer apply(rule *,assumption) using assm(1) by auto }
1.2728 @@ -3651,12 +3940,12 @@
1.2729      apply safe apply(rule closed_interval) using assm(1) by auto
1.2730    have "k \<subseteq> \<Union>(s - {k})" apply safe apply(rule *[unfolded closed_limpt,rule_format]) unfolding islimpt_approachable
1.2731    proof safe fix x and e::real assume as:"x\<in>k" "e>0"
1.2732 -    from k(2)[unfolded k content_eq_0] guess i ..
1.2733 +    from k(2)[unfolded k content_eq_0] guess i ..
1.2734      hence i:"c\<bullet>i = d\<bullet>i" "i\<in>Basis" using s(3)[OF k(1),unfolded k] unfolding interval_ne_empty by auto
1.2735      hence xi:"x\<bullet>i = d\<bullet>i" using as unfolding k mem_interval by (metis antisym)
1.2736      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 +
1.2737        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)::'a"
1.2738 -    show "\<exists>x'\<in>\<Union>(s - {k}). x' \<noteq> x \<and> dist x' x < e" apply(rule_tac x=y in bexI)
1.2739 +    show "\<exists>x'\<in>\<Union>(s - {k}). x' \<noteq> x \<and> dist x' x < e" apply(rule_tac x=y in bexI)
1.2740      proof have "d \<in> {c..d}" using s(3)[OF k(1)] unfolding k interval_eq_empty mem_interval by(fastforce simp add: not_less)
1.2741        hence "d \<in> {a..b}" using s(2)[OF k(1)] unfolding k by auto note di = this[unfolded mem_interval,THEN bspec[where x=i]]
1.2742        hence xyi:"y\<bullet>i \<noteq> x\<bullet>i"
1.2743 @@ -3677,7 +3966,7 @@
1.2744          using set_rev_mp[OF as(1) s(2)[OF k(1)]] as(2) di i unfolding s mem_interval y_def
1.2745          by (auto simp: field_simps elim!: ballE[of _ _ i])
1.2746        ultimately show "y \<in> \<Union>(s - {k})" by auto
1.2747 -    qed qed hence "\<Union>(s - {k}) = {a..b}" unfolding s(6)[THEN sym] by auto
1.2748 +    qed qed hence "\<Union>(s - {k}) = {a..b}" unfolding s(6)[symmetric] by auto
1.2749    hence  "{ka \<in> s - {k}. content ka \<noteq> 0} division_of {a..b}" apply-apply(rule assm(2)[rule_format,OF card refl])
1.2750      apply(rule division_ofI) defer apply(rule_tac[1-4] s) using assm(1) by auto
1.2751    moreover have "{ka \<in> s - {k}. content ka \<noteq> 0} = {k \<in> s. content k \<noteq> 0}" using k by auto ultimately show ?thesis by auto qed
1.2752 @@ -3690,10 +3979,10 @@
1.2753    unfolding has_integral_null_eq apply(rule,rule refl) apply(rule,assumption,assumption)+
1.2754    unfolding integrable_on_def by(auto intro!: has_integral_split)
1.2755
1.2756 -lemma integrable_subinterval: fixes f::"'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.2757 -  assumes "f integrable_on {a..b}" "{c..d} \<subseteq> {a..b}" shows "f integrable_on {c..d}"
1.2758 +lemma integrable_subinterval: fixes f::"'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.2759 +  assumes "f integrable_on {a..b}" "{c..d} \<subseteq> {a..b}" shows "f integrable_on {c..d}"
1.2760    apply(cases "{c..d} = {}") defer apply(rule partial_division_extend_1[OF assms(2)],assumption)
1.2761 -  using operative_division_and[OF operative_integrable,THEN sym,of _ _ _ f] assms(1) by auto
1.2762 +  using operative_division_and[OF operative_integrable,symmetric,of _ _ _ f] assms(1) by auto
1.2763
1.2764  subsection {* Combining adjacent intervals in 1 dimension. *}
1.2765
1.2766 @@ -3710,7 +3999,7 @@
1.2767  lemma integral_combine: fixes f::"real \<Rightarrow> 'a::banach"
1.2768    assumes "a \<le> c" "c \<le> b" "f integrable_on ({a..b})"
1.2769    shows "integral {a..c} f + integral {c..b} f = integral({a..b}) f"
1.2770 -  apply(rule integral_unique[THEN sym]) apply(rule has_integral_combine[OF assms(1-2)])
1.2771 +  apply(rule integral_unique[symmetric]) apply(rule has_integral_combine[OF assms(1-2)])
1.2772    apply(rule_tac[!] integrable_integral integrable_subinterval[OF assms(3)])+ using assms(1-2) by auto
1.2773
1.2774  lemma integrable_combine: fixes f::"real \<Rightarrow> 'a::banach"
1.2775 @@ -3725,7 +4014,7 @@
1.2776  proof- 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> f integrable_on {u..v})"
1.2777      using assms by auto note this[unfolded gauge_existence_lemma] from choice[OF this] guess d .. note d=this[rule_format]
1.2778    guess p apply(rule fine_division_exists[OF gauge_ball_dependent,of d a b]) using d by auto note p=this(1-2)
1.2779 -  note division_of_tagged_division[OF this(1)] note * = operative_division_and[OF operative_integrable,OF this,THEN sym,of f]
1.2780 +  note division_of_tagged_division[OF this(1)] note * = operative_division_and[OF operative_integrable,OF this,symmetric,of f]
1.2781    show ?thesis unfolding * apply safe unfolding snd_conv
1.2782    proof- fix x k assume "(x,k) \<in> p" note tagged_division_ofD(2-4)[OF p(1) this] fineD[OF p(2) this]
1.2783      thus "f integrable_on k" apply safe apply(rule d[THEN conjunct2,rule_format,of x]) by auto qed qed
1.2784 @@ -3765,10 +4054,10 @@
1.2785        hence *:"?I a x - ?I a y = ?I y x" unfolding algebra_simps apply(subst eq_commute) apply(rule integral_combine)
1.2786          using True using assms(2) goal1 by auto
1.2787        have **:"norm (y - x) = content {y..x}" apply(subst content_real) using True unfolding not_less by auto
1.2788 -      have ***:"\<And>fy fx c::'a. fx - fy - (y - x) *\<^sub>R c = -(fy - fx - (x - y) *\<^sub>R c)" unfolding scaleR_left.diff by auto
1.2789 +      have ***:"\<And>fy fx c::'a. fx - fy - (y - x) *\<^sub>R c = -(fy - fx - (x - y) *\<^sub>R c)" unfolding scaleR_left.diff by auto
1.2790        show ?thesis apply(subst ***) unfolding norm_minus_cancel **
1.2791          apply(rule has_integral_bound[where f="(\<lambda>u. f u - f x)"]) unfolding * unfolding o_def
1.2792 -        defer apply(rule has_integral_sub) apply(subst minus_minus[THEN sym]) unfolding minus_minus
1.2793 +        defer apply(rule has_integral_sub) apply(subst minus_minus[symmetric]) unfolding minus_minus
1.2794          apply(rule integrable_integral) apply(rule integrable_subinterval,rule integrable_continuous) apply(rule assms)+
1.2795        proof- show "{y..x} \<subseteq> {a..b}" using goal1 assms(2) by auto
1.2796          have *:"x - y = norm(y - x)" using True by auto
1.2797 @@ -3813,8 +4102,8 @@
1.2798      def d' \<equiv> "\<lambda>x. {y. g y \<in> d (g x)}" have d':"\<And>x. d' x = {y. g y \<in> (d (g x))}" unfolding d'_def ..
1.2799      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)"
1.2800      proof(rule_tac x=d' in exI,safe) show "gauge d'" using d(1) unfolding gauge_def d' using continuous_open_preimage_univ[OF assms(4)] by auto
1.2801 -      fix p assume as:"p tagged_division_of h ` {a..b}" "d' fine p" note p = tagged_division_ofD[OF as(1)]
1.2802 -      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" unfolding tagged_division_of
1.2803 +      fix p assume as:"p tagged_division_of h ` {a..b}" "d' fine p" note p = tagged_division_ofD[OF as(1)]
1.2804 +      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" unfolding tagged_division_of
1.2805        proof safe show "finite ((\<lambda>(x, k). (g x, g ` k)) ` p)" using as by auto
1.2806          show "d fine (\<lambda>(x, k). (g x, g ` k)) ` p" using as(2) unfolding fine_def d' by auto
1.2807          fix x k assume xk[intro]:"(x,k) \<in> p" show "g x \<in> g ` k" using p(2)[OF xk] by auto
1.2808 @@ -3852,12 +4141,12 @@
1.2809  lemma setprod_cong2: assumes "\<And>x. x \<in> A \<Longrightarrow> f x = g x" shows "setprod f A = setprod g A"
1.2810    apply(rule setprod_cong) using assms by auto
1.2811
1.2812 -lemma content_image_affinity_interval:
1.2813 +lemma content_image_affinity_interval:
1.2814   "content((\<lambda>x::'a::ordered_euclidean_space. m *\<^sub>R x + c) ` {a..b}) = (abs m) ^ DIM('a) * content {a..b}" (is "?l = ?r")
1.2815  proof- { presume *:"{a..b}\<noteq>{} \<Longrightarrow> ?thesis" show ?thesis apply(cases,rule *,assumption)
1.2816        unfolding not_not using content_empty by auto }
1.2817 -  assume as: "{a..b}\<noteq>{}"
1.2818 -  show ?thesis
1.2819 +  assume as: "{a..b}\<noteq>{}"
1.2820 +  show ?thesis
1.2821    proof (cases "m \<ge> 0")
1.2822      case True
1.2823      with as have "{m *\<^sub>R a + c..m *\<^sub>R b + c} \<noteq> {}"
1.2824 @@ -3903,10 +4192,10 @@
1.2825  lemma image_stretch_interval:
1.2826    "(\<lambda>x. \<Sum>k\<in>Basis. (m k * (x\<bullet>k)) *\<^sub>R k) ` {a..b::'a::ordered_euclidean_space} =
1.2827    (if {a..b} = {} then {} else
1.2828 -    {(\<Sum>k\<in>Basis. (min (m k * (a\<bullet>k)) (m k * (b\<bullet>k))) *\<^sub>R k)::'a ..
1.2829 +    {(\<Sum>k\<in>Basis. (min (m k * (a\<bullet>k)) (m k * (b\<bullet>k))) *\<^sub>R k)::'a ..
1.2830       (\<Sum>k\<in>Basis. (max (m k * (a\<bullet>k)) (m k * (b\<bullet>k))) *\<^sub>R k)})"
1.2831  proof cases
1.2832 -  assume *: "{a..b} \<noteq> {}"
1.2833 +  assume *: "{a..b} \<noteq> {}"
1.2834    show ?thesis
1.2835      unfolding interval_ne_empty if_not_P[OF *]
1.2836      apply (simp add: interval image_Collect set_eq_iff euclidean_eq_iff[where 'a='a] ball_conj_distrib[symmetric])
1.2837 @@ -3929,14 +4218,14 @@
1.2838            "max (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) = (if 0 < m i then m i * (b \<bullet> i) else m i * (a \<bullet> i))"
1.2839          using a_le_b by (auto simp: min_def max_def mult_le_cancel_left)
1.2840        with False show ?thesis using a_le_b
1.2841 -        unfolding * by (auto simp add: le_divide_eq divide_le_eq ac_simps)
1.2842 +        unfolding * by (auto simp add: le_divide_eq divide_le_eq ac_simps)
1.2843      qed
1.2844    qed
1.2845  qed simp
1.2846
1.2847 -lemma interval_image_stretch_interval:
1.2848 +lemma interval_image_stretch_interval:
1.2849      "\<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}"
1.2850 -  unfolding image_stretch_interval by auto
1.2851 +  unfolding image_stretch_interval by auto
1.2852
1.2853  lemma content_image_stretch_interval:
1.2854    "content((\<lambda>x::'a::ordered_euclidean_space. (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)::'a) ` {a..b}) = abs(setprod m Basis) * content({a..b})"
1.2855 @@ -3944,12 +4233,12 @@
1.2856      unfolding content_def image_is_empty image_stretch_interval if_P[OF True] by auto
1.2857  next case False hence "(\<lambda>x. (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)::'a) ` {a..b} \<noteq> {}" by auto
1.2858    thus ?thesis using False unfolding content_def image_stretch_interval apply- unfolding interval_bounds' if_not_P
1.2859 -    unfolding abs_setprod setprod_timesf[THEN sym] apply(rule setprod_cong2) unfolding lessThan_iff
1.2860 +    unfolding abs_setprod setprod_timesf[symmetric] apply(rule setprod_cong2) unfolding lessThan_iff
1.2861    proof (simp only: inner_setsum_left_Basis)
1.2862      fix i :: 'a assume i:"i\<in>Basis" have "(m i < 0 \<or> m i > 0) \<or> m i = 0" by auto
1.2863 -    thus "max (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) - min (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) =
1.2864 +    thus "max (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) - min (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) =
1.2865          \<bar>m i\<bar> * (b \<bullet> i - a \<bullet> i)"
1.2866 -      apply-apply(erule disjE)+ unfolding min_def max_def using False[unfolded interval_ne_empty,rule_format,of i] i
1.2867 +      apply-apply(erule disjE)+ unfolding min_def max_def using False[unfolded interval_ne_empty,rule_format,of i] i
1.2868        by(auto simp add:field_simps not_le mult_le_cancel_left_neg mult_le_cancel_left_pos) qed qed
1.2869
1.2870  lemma has_integral_stretch: fixes f::"'a::ordered_euclidean_space => 'b::real_normed_vector"
1.2871 @@ -3966,7 +4255,7 @@
1.2872  lemma integrable_stretch:  fixes f::"'a::ordered_euclidean_space => 'b::real_normed_vector"
1.2873    assumes "f integrable_on {a..b}" "\<forall>k\<in>Basis. ~(m k = 0)"
1.2874    shows "(\<lambda>x::'a. f (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)) integrable_on ((\<lambda>x. \<Sum>k\<in>Basis. (1 / m k * (x\<bullet>k))*\<^sub>R k) ` {a..b})"
1.2875 -  using assms unfolding integrable_on_def apply-apply(erule exE)
1.2876 +  using assms unfolding integrable_on_def apply-apply(erule exE)
1.2877    apply(drule has_integral_stretch,assumption) by auto
1.2878
1.2879  subsection {* even more special cases. *}
1.2880 @@ -4001,13 +4290,13 @@
1.2881    unfolding split_def by(rule refl)
1.2882
1.2883  lemma norm_triangle_le_sub: "norm x + norm y \<le> e \<Longrightarrow> norm (x - y) \<le> e"
1.2884 -  apply(subst(asm)(2) norm_minus_cancel[THEN sym])
1.2885 +  apply(subst(asm)(2) norm_minus_cancel[symmetric])
1.2886    apply(drule norm_triangle_le) by(auto simp add:algebra_simps)
1.2887
1.2888  lemma fundamental_theorem_of_calculus_interior: fixes f::"real => 'a::real_normed_vector"
1.2889    assumes"a \<le> b" "continuous_on {a..b} f" "\<forall>x\<in>{a<..<b}. (f has_vector_derivative f'(x)) (at x)"
1.2890    shows "(f' has_integral (f b - f a)) {a..b}"
1.2891 -proof- { presume *:"a < b \<Longrightarrow> ?thesis"
1.2892 +proof- { presume *:"a < b \<Longrightarrow> ?thesis"
1.2893      show ?thesis proof(cases,rule *,assumption)
1.2894        assume "\<not> a < b" hence "a = b" using assms(1) by auto
1.2895        hence *:"{a .. b} = {b}" "f b - f a = 0" by(auto simp add:  order_antisym)
1.2896 @@ -4034,15 +4323,15 @@
1.2897      from *[OF this] guess k .. note k = conjunctD2[OF this,rule_format]
1.2898      have "\<exists>l. 0 < l \<and> norm(l *\<^sub>R f' a) \<le> (e * (b - a)) / 8"
1.2899      proof(cases "f' a = 0") case True
1.2900 -      thus ?thesis apply(rule_tac x=1 in exI) using ab e by(auto intro!:mult_nonneg_nonneg)
1.2901 +      thus ?thesis apply(rule_tac x=1 in exI) using ab e by(auto intro!:mult_nonneg_nonneg)
1.2902      next case False thus ?thesis
1.2903 -        apply(rule_tac x="(e * (b - a)) / 8 / norm (f' a)" in exI) using ab e by(auto simp add:field_simps)
1.2904 +        apply(rule_tac x="(e * (b - a)) / 8 / norm (f' a)" in exI) using ab e by(auto simp add:field_simps)
1.2905      qed then guess l .. note l = conjunctD2[OF this]
1.2906      show ?thesis apply(rule_tac x="min k l" in exI) apply safe unfolding min_less_iff_conj apply(rule,(rule l k)+)
1.2907 -    proof- fix c assume as:"a \<le> c" "{a..c} \<subseteq> {a..b}" "{a..c} \<subseteq> ball a (min k l)"
1.2908 +    proof- fix c assume as:"a \<le> c" "{a..c} \<subseteq> {a..b}" "{a..c} \<subseteq> ball a (min k l)"
1.2909        note as' = this[unfolded subset_eq Ball_def mem_ball dist_real_def mem_interval]
1.2910        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)" by(rule norm_triangle_ineq4)
1.2911 -      also have "... \<le> e * (b - a) / 8 + e * (b - a) / 8"
1.2912 +      also have "... \<le> e * (b - a) / 8 + e * (b - a) / 8"
1.2913        proof(rule add_mono) case goal1 have "\<bar>c - a\<bar> \<le> \<bar>l\<bar>" using as' by auto
1.2914          thus ?case apply-apply(rule order_trans[OF _ l(2)]) unfolding norm_scaleR apply(rule mult_right_mono) by auto
1.2915        next case goal2 show ?case apply(rule less_imp_le) apply(cases "a = c") defer
1.2916 @@ -4060,16 +4349,16 @@
1.2917      from *[OF this] guess k .. note k = conjunctD2[OF this,rule_format]
1.2918      have "\<exists>l. 0 < l \<and> norm(l *\<^sub>R f' b) \<le> (e * (b - a)) / 8"
1.2919      proof(cases "f' b = 0") case True
1.2920 -      thus ?thesis apply(rule_tac x=1 in exI) using ab e by(auto intro!:mult_nonneg_nonneg)
1.2921 -    next case False thus ?thesis
1.2922 +      thus ?thesis apply(rule_tac x=1 in exI) using ab e by(auto intro!:mult_nonneg_nonneg)
1.2923 +    next case False thus ?thesis
1.2924          apply(rule_tac x="(e * (b - a)) / 8 / norm (f' b)" in exI)
1.2925          using ab e by(auto simp add:field_simps)
1.2926      qed then guess l .. note l = conjunctD2[OF this]
1.2927      show ?thesis apply(rule_tac x="min k l" in exI) apply safe unfolding min_less_iff_conj apply(rule,(rule l k)+)
1.2928 -    proof- fix c assume as:"c \<le> b" "{c..b} \<subseteq> {a..b}" "{c..b} \<subseteq> ball b (min k l)"
1.2929 +    proof- fix c assume as:"c \<le> b" "{c..b} \<subseteq> {a..b}" "{c..b} \<subseteq> ball b (min k l)"
1.2930        note as' = this[unfolded subset_eq Ball_def mem_ball dist_real_def mem_interval]
1.2931        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)" by(rule norm_triangle_ineq4)
1.2932 -      also have "... \<le> e * (b - a) / 8 + e * (b - a) / 8"
1.2933 +      also have "... \<le> e * (b - a) / 8 + e * (b - a) / 8"
1.2934        proof(rule add_mono) case goal1 have "\<bar>c - b\<bar> \<le> \<bar>l\<bar>" using as' by auto
1.2935          thus ?case apply-apply(rule order_trans[OF _ l(2)]) unfolding norm_scaleR apply(rule mult_right_mono) by auto
1.2936        next case goal2 show ?case apply(rule less_imp_le) apply(cases "b = c") defer apply(subst norm_minus_commute)
1.2937 @@ -4083,11 +4372,11 @@
1.2938    proof safe case goal1 show ?case apply(rule gauge_ball_dependent) using ab db(1) da(1) d(1) by auto
1.2939    next case goal2 note as=this let ?A = "{t. fst t \<in> {a, b}}" note p = tagged_division_ofD[OF goal2(1)]
1.2940      have pA:"p = (p \<inter> ?A) \<union> (p - ?A)" "finite (p \<inter> ?A)" "finite (p - ?A)" "(p \<inter> ?A) \<inter> (p - ?A) = {}"  using goal2 by auto
1.2941 -    note * = additive_tagged_division_1'[OF assms(1) goal2(1), THEN sym]
1.2942 +    note * = additive_tagged_division_1'[OF assms(1) goal2(1), symmetric]
1.2943      have **:"\<And>n1 s1 n2 s2::real. n2 \<le> s2 / 2 \<Longrightarrow> n1 - s1 \<le> s2 / 2 \<Longrightarrow> n1 + n2 \<le> s1 + s2" by arith
1.2944 -    show ?case unfolding content_real[OF assms(1)] and *[of "\<lambda>x. x"] *[of f] setsum_subtractf[THEN sym] split_minus
1.2945 +    show ?case unfolding content_real[OF assms(1)] and *[of "\<lambda>x. x"] *[of f] setsum_subtractf[symmetric] split_minus
1.2946        unfolding setsum_right_distrib apply(subst(2) pA,subst pA) unfolding setsum_Un_disjoint[OF pA(2-)]
1.2947 -    proof(rule norm_triangle_le,rule **)
1.2948 +    proof(rule norm_triangle_le,rule **)
1.2949        case goal1 show ?case apply(rule order_trans,rule setsum_norm_le) defer apply(subst setsum_divide_distrib)
1.2950        proof(rule order_refl,safe,unfold not_le o_def split_conv fst_conv,rule ccontr) fix x k assume as:"(x,k) \<in> p"
1.2951            "e * (interval_upperbound k -  interval_lowerbound k) / 2
1.2952 @@ -4099,8 +4388,8 @@
1.2953          assume as':"x \<noteq> a" "x \<noteq> b" hence "x \<in> {a<..<b}" using p(2-3)[OF as(1)] by auto
1.2954          note  * = d(2)[OF this]
1.2955          have "norm ((v - u) *\<^sub>R f' (x) - (f (v) - f (u))) =
1.2956 -          norm ((f (u) - f (x) - (u - x) *\<^sub>R f' (x)) - (f (v) - f (x) - (v - x) *\<^sub>R f' (x)))"
1.2957 -          apply(rule arg_cong[of _ _ norm]) unfolding scaleR_left.diff by auto
1.2958 +          norm ((f (u) - f (x) - (u - x) *\<^sub>R f' (x)) - (f (v) - f (x) - (v - x) *\<^sub>R f' (x)))"
1.2959 +          apply(rule arg_cong[of _ _ norm]) unfolding scaleR_left.diff by auto
1.2960          also have "... \<le> e / 2 * norm (u - x) + e / 2 * norm (v - x)" apply(rule norm_triangle_le_sub)
1.2961            apply(rule add_mono) apply(rule_tac[!] *) using fineD[OF goal2(2) as(1)] as' unfolding k subset_eq
1.2962            apply- apply(erule_tac x=u in ballE,erule_tac[3] x=v in ballE) using uv by(auto simp:dist_real_def)
1.2963 @@ -4110,7 +4399,7 @@
1.2964
1.2965      next have *:"\<And>x s1 s2::real. 0 \<le> s1 \<Longrightarrow> x \<le> (s1 + s2) / 2 \<Longrightarrow> x - s1 \<le> s2 / 2" by auto
1.2966        case goal2 show ?case apply(rule *) apply(rule setsum_nonneg) apply(rule,unfold split_paired_all split_conv)
1.2967 -        defer unfolding setsum_Un_disjoint[OF pA(2-),THEN sym] pA(1)[THEN sym] unfolding setsum_right_distrib[THEN sym]
1.2968 +        defer unfolding setsum_Un_disjoint[OF pA(2-),symmetric] pA(1)[symmetric] unfolding setsum_right_distrib[symmetric]
1.2969          apply(subst additive_tagged_division_1[OF _ as(1)]) apply(rule assms)
1.2970        proof- fix x k assume "(x,k) \<in> p \<inter> {t. fst t \<in> {a, b}}" note xk=IntD1[OF this]
1.2971          from p(4)[OF this] guess u v apply-by(erule exE)+ note uv=this
1.2972 @@ -4119,7 +4408,7 @@
1.2973            unfolding uv using e by(auto simp add:field_simps)
1.2974        next have *:"\<And>s f t e. setsum f s = setsum f t \<Longrightarrow> norm(setsum f t) \<le> e \<Longrightarrow> norm(setsum f s) \<le> e" by auto
1.2975          show "norm (\<Sum>(x, k)\<in>p \<inter> ?A. content k *\<^sub>R f' x -
1.2976 -          (f ((interval_upperbound k)) - f ((interval_lowerbound k)))) \<le> e * (b - a) / 2"
1.2977 +          (f ((interval_upperbound k)) - f ((interval_lowerbound k)))) \<le> e * (b - a) / 2"
1.2978            apply(rule *[where t="p \<inter> {t. fst t \<in> {a, b} \<and> content(snd t) \<noteq> 0}"])
1.2979            apply(rule setsum_mono_zero_right[OF pA(2)]) defer apply(rule) unfolding split_paired_all split_conv o_def
1.2980          proof- fix x k assume "(x,k) \<in> p \<inter> {t. fst t \<in> {a, b}} - p \<inter> {t. fst t \<in> {a, b} \<and> content (snd t) \<noteq> 0}"
1.2981 @@ -4127,7 +4416,7 @@
1.2982            have "k\<noteq>{}" using p(2)[OF xk(1)] by auto hence *:"u = v" using xk
1.2983              unfolding uv content_eq_0 interval_eq_empty by auto
1.2984            thus "content k *\<^sub>R (f' (x)) - (f ((interval_upperbound k)) - f ((interval_lowerbound k))) = 0" using xk unfolding uv by auto
1.2985 -        next have *:"p \<inter> {t. fst t \<in> {a, b} \<and> content(snd t) \<noteq> 0} =
1.2986 +        next have *:"p \<inter> {t. fst t \<in> {a, b} \<and> content(snd t) \<noteq> 0} =
1.2987              {t. t\<in>p \<and> fst t = a \<and> content(snd t) \<noteq> 0} \<union> {t. t\<in>p \<and> fst t = b \<and> content(snd t) \<noteq> 0}" by blast
1.2988            have **:"\<And>s f. \<And>e::real. (\<forall>x y. x \<in> s \<and> y \<in> s \<longrightarrow> x = y) \<Longrightarrow> (\<forall>x. x \<in> s \<longrightarrow> norm(f x) \<le> e)
1.2989              \<Longrightarrow> e>0 \<Longrightarrow> norm(setsum f s) \<le> e"
1.2990 @@ -4135,22 +4424,22 @@
1.2991              thus ?case using `x\<in>s` goal2(2) by auto
1.2992            qed auto
1.2993            case goal2 show ?case apply(subst *, subst setsum_Un_disjoint) prefer 4
1.2994 -            apply(rule order_trans[of _ "e * (b - a)/4 + e * (b - a)/4"])
1.2995 +            apply(rule order_trans[of _ "e * (b - a)/4 + e * (b - a)/4"])
1.2996              apply(rule norm_triangle_le,rule add_mono) apply(rule_tac[1-2] **)
1.2997            proof- let ?B = "\<lambda>x. {t \<in> p. fst t = x \<and> content (snd t) \<noteq> 0}"
1.2998 -            have pa:"\<And>k. (a, k) \<in> p \<Longrightarrow> \<exists>v. k = {a .. v} \<and> a \<le> v"
1.2999 +            have pa:"\<And>k. (a, k) \<in> p \<Longrightarrow> \<exists>v. k = {a .. v} \<and> a \<le> v"
1.3000              proof- case goal1 guess u v using p(4)[OF goal1] apply-by(erule exE)+ note uv=this
1.3001                have *:"u \<le> v" using p(2)[OF goal1] unfolding uv by auto
1.3002 -              have u:"u = a" proof(rule ccontr)  have "u \<in> {u..v}" using p(2-3)[OF goal1(1)] unfolding uv by auto
1.3003 +              have u:"u = a" proof(rule ccontr)  have "u \<in> {u..v}" using p(2-3)[OF goal1(1)] unfolding uv by auto
1.3004                  have "u \<ge> a" using p(2-3)[OF goal1(1)] unfolding uv subset_eq by auto moreover assume "u\<noteq>a" ultimately
1.3005                  have "u > a" by auto
1.3006                  thus False using p(2)[OF goal1(1)] unfolding uv by(auto simp add:)
1.3007                qed thus ?case apply(rule_tac x=v in exI) unfolding uv using * by auto
1.3008              qed
1.3009 -            have pb:"\<And>k. (b, k) \<in> p \<Longrightarrow> \<exists>v. k = {v .. b} \<and> b \<ge> v"
1.3010 +            have pb:"\<And>k. (b, k) \<in> p \<Longrightarrow> \<exists>v. k = {v .. b} \<and> b \<ge> v"
1.3011              proof- case goal1 guess u v using p(4)[OF goal1] apply-by(erule exE)+ note uv=this
1.3012                have *:"u \<le> v" using p(2)[OF goal1] unfolding uv by auto
1.3013 -              have u:"v =  b" proof(rule ccontr)  have "u \<in> {u..v}" using p(2-3)[OF goal1(1)] unfolding uv by auto
1.3014 +              have u:"v =  b" proof(rule ccontr)  have "u \<in> {u..v}" using p(2-3)[OF goal1(1)] unfolding uv by auto
1.3015                  have "v \<le>  b" using p(2-3)[OF goal1(1)] unfolding uv subset_eq by auto moreover assume "v\<noteq> b" ultimately
1.3016                  have "v <  b" by auto
1.3017                  thus False using p(2)[OF goal1(1)] unfolding uv by(auto simp add:)
1.3018 @@ -4168,7 +4457,7 @@
1.3019                ultimately have " ((a + ?v)/2) \<in> interior k \<inter> interior k'" unfolding interior_open[OF open_interval] by auto
1.3020                hence *:"k = k'" apply- apply(rule ccontr) using p(5)[OF k(1-2)] by auto
1.3021                { assume "x\<in>k" thus "x\<in>k'" unfolding * . } { assume "x\<in>k'" thus "x\<in>k" unfolding * . }
1.3022 -            qed
1.3023 +            qed
1.3024              show "\<forall>x y. x \<in> ?B b \<and> y \<in> ?B b \<longrightarrow> x = y" apply(rule,rule,rule,unfold split_paired_all)
1.3025                unfolding mem_Collect_eq fst_conv snd_conv apply safe
1.3026              proof- fix x k k' assume k:"( b, k) \<in> p" "( b, k') \<in> p" "content k \<noteq> 0" "content k' \<noteq> 0"
1.3027 @@ -4184,7 +4473,7 @@
1.3028              let ?a = a and ?b = b (* a is something else while proofing the next theorem. *)
1.3029              show "\<forall>x. x \<in> ?B a \<longrightarrow> norm ((\<lambda>(x, k). content k *\<^sub>R f' (x) - (f ((interval_upperbound k)) -
1.3030                f ((interval_lowerbound k)))) x) \<le> e * (b - a) / 4" apply(rule,rule) unfolding mem_Collect_eq
1.3031 -              unfolding split_paired_all fst_conv snd_conv
1.3032 +              unfolding split_paired_all fst_conv snd_conv
1.3033              proof safe case goal1 guess v using pa[OF goal1(1)] .. note v = conjunctD2[OF this]
1.3034                have " ?a\<in>{ ?a..v}" using v(2) by auto hence "v \<le> ?b" using p(3)[OF goal1(1)] unfolding subset_eq v by auto
1.3035                moreover have "{?a..v} \<subseteq> ball ?a da" using fineD[OF as(2) goal1(1)]
1.3036 @@ -4195,7 +4484,7 @@
1.3037              qed
1.3038              show "\<forall>x. x \<in> ?B b \<longrightarrow> norm ((\<lambda>(x, k). content k *\<^sub>R f' (x) -
1.3039                (f ((interval_upperbound k)) - f ((interval_lowerbound k)))) x) \<le> e * (b - a) / 4"
1.3040 -              apply(rule,rule) unfolding mem_Collect_eq unfolding split_paired_all fst_conv snd_conv
1.3041 +              apply(rule,rule) unfolding mem_Collect_eq unfolding split_paired_all fst_conv snd_conv
1.3042              proof safe case goal1 guess v using pb[OF goal1(1)] .. note v = conjunctD2[OF this]
1.3043                have " ?b\<in>{v.. ?b}" using v(2) by auto hence "v \<ge> ?a" using p(3)[OF goal1(1)]
1.3044                  unfolding subset_eq v by auto
1.3045 @@ -4213,7 +4502,7 @@
1.3046  lemma fundamental_theorem_of_calculus_interior_strong: fixes f::"real \<Rightarrow> 'a::banach"
1.3047    assumes"finite s" "a \<le> b" "continuous_on {a..b} f"
1.3048    "\<forall>x\<in>{a<..<b} - s. (f has_vector_derivative f'(x)) (at x)"
1.3049 -  shows "(f' has_integral (f b - f a)) {a..b}" using assms apply-
1.3050 +  shows "(f' has_integral (f b - f a)) {a..b}" using assms apply-
1.3051  proof(induct "card s" arbitrary:s a b)
1.3052    case 0 show ?case apply(rule fundamental_theorem_of_calculus_interior) using 0 by auto
1.3053  next case (Suc n) from this(2) guess c s' apply-apply(subst(asm) eq_commute) unfolding card_Suc_eq
1.3054 @@ -4249,10 +4538,10 @@
1.3055        hence "c - t < e / 3 / norm (f c)" by auto
1.3056        hence "norm (c - t) < e / 3 / norm (f c)" using as by auto
1.3057        thus "norm (f c) * norm (c - t) < e / 3" using False apply-
1.3058 -        apply(subst mult_commute) apply(subst pos_less_divide_eq[THEN sym]) by auto
1.3059 +        apply(subst mult_commute) apply(subst pos_less_divide_eq[symmetric]) by auto
1.3060      qed next case True show ?thesis apply(rule_tac x=1 in exI) unfolding True using `e>0` by auto
1.3061    qed then guess w .. note w = conjunctD2[OF this,rule_format]
1.3062 -
1.3063 +
1.3064    have *:"e / 3 > 0" using assms by auto
1.3065    have "f integrable_on {a..c}" apply(rule integrable_subinterval[OF assms(1)]) using assms(2-3) by auto
1.3066    from integrable_integral[OF this,unfolded has_integral,rule_format,OF *] guess d1 ..
1.3067 @@ -4281,7 +4570,7 @@
1.3068      have pt:"\<forall>(x,k)\<in>p. x \<le> t" proof safe case goal1 from p'(2,3)[OF this] show ?case by auto qed
1.3069      with p(2) have "d2 fine p" unfolding fine_def d3_def apply safe apply(erule_tac x="(a,b)" in ballE)+ by auto
1.3070      note d2_fin = d2(2)[OF conjI[OF p(1) this]]
1.3071 -
1.3072 +
1.3073      have *:"{a..c} \<inter> {x. x \<bullet> 1 \<le> t} = {a..t}" "{a..c} \<inter> {x. x \<bullet> 1 \<ge> t} = {t..c}"
1.3074        using assms(2-3) as by(auto simp add:field_simps)
1.3075      have "p \<union> {(c, {t..c})} tagged_division_of {a..c} \<and> d1 fine p \<union> {(c, {t..c})}" apply rule
1.3076 @@ -4290,30 +4579,30 @@
1.3077      proof safe fix x k y assume "(x,k)\<in>p" "y\<in>k" thus "y\<in>d1 x"
1.3078          using p(2) pt unfolding fine_def d3_def apply- apply(erule_tac x="(x,k)" in ballE)+ by auto
1.3079      next fix x assume "x\<in>{t..c}" hence "dist c x < k" unfolding dist_real_def
1.3080 -        using as(1) by(auto simp add:field_simps)
1.3081 +        using as(1) by(auto simp add:field_simps)
1.3082        thus "x \<in> d1 c" using k(2) unfolding d_def by auto
1.3083      qed(insert as(2), auto) note d1_fin = d1(2)[OF this]
1.3084
1.3085      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)) -
1.3086 -        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"
1.3087 +        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"
1.3088        "e = (e/3 + e/3) + e/3" by auto
1.3089      have **:"(\<Sum>(x, k)\<in>p \<union> {(c, {t..c})}. content k *\<^sub>R f x) = (c - t) *\<^sub>R f c + (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x)"
1.3090      proof- have **:"\<And>x F. F \<union> {x} = insert x F" by auto
1.3091        have "(c, {t..c}) \<notin> p" proof safe case goal1 from p'(2-3)[OF this]
1.3092          have "c \<in> {a..t}" by auto thus False using `t<c` by auto
1.3093        qed thus ?thesis unfolding ** apply- apply(subst setsum_insert) apply(rule p')
1.3094 -        unfolding split_conv defer apply(subst content_real) using as(2) by auto qed
1.3095 +        unfolding split_conv defer apply(subst content_real) using as(2) by auto qed
1.3096
1.3097      have ***:"c - w < t \<and> t < c"
1.3098      proof- have "c - k < t" using `k>0` as(1) by(auto simp add:field_simps)
1.3099 -      moreover have "k \<le> w" apply(rule ccontr) using k(2)
1.3100 +      moreover have "k \<le> w" apply(rule ccontr) using k(2)
1.3101          unfolding subset_eq apply(erule_tac x="c + ((k + w)/2)" in ballE)
1.3102          unfolding d_def using `k>0` `w>0` by(auto simp add:field_simps not_le not_less dist_real_def)
1.3103        ultimately show  ?thesis using `t<c` by(auto simp add:field_simps) qed
1.3104
1.3105      show ?thesis unfolding *(1) apply(subst *(2)) apply(rule norm_triangle_lt add_strict_mono)+
1.3106        unfolding norm_minus_cancel apply(rule d1_fin[unfolded **]) apply(rule d2_fin)
1.3107 -      using w(2)[OF ***] unfolding norm_scaleR by(auto simp add:field_simps) qed qed
1.3108 +      using w(2)[OF ***] unfolding norm_scaleR by(auto simp add:field_simps) qed qed
1.3109
1.3110  lemma indefinite_integral_continuous_right: fixes f::"real \<Rightarrow> 'a::banach"
1.3111    assumes "f integrable_on {a..b}" "a \<le> c" "c < b" "0 < e"
1.3112 @@ -4327,9 +4616,9 @@
1.3113        "integral{a..t} f = integral{a..b} f - integral{t..b} f" unfolding algebra_simps
1.3114        apply(rule_tac[!] integral_combine) using assms as by auto
1.3115      have "(- c) - d < (- t) \<and> - t \<le> - c" using as by auto note d(2)[rule_format,OF this]
1.3116 -    thus "norm (integral {a..c} f - integral {a..t} f) < e" unfolding *
1.3117 +    thus "norm (integral {a..c} f - integral {a..t} f) < e" unfolding *
1.3118        unfolding integral_reflect apply-apply(subst norm_minus_commute) by(auto simp add:algebra_simps) qed qed
1.3119 -
1.3120 +
1.3121  lemma indefinite_integral_continuous: fixes f::"real \<Rightarrow> 'a::banach"
1.3122    assumes "f integrable_on {a..b}" shows  "continuous_on {a..b} (\<lambda>x. integral {a..x} f)"
1.3123  proof(unfold continuous_on_iff, safe)  fix x e assume as:"x\<in>{a..b}" "0<(e::real)"
1.3124 @@ -4359,7 +4648,7 @@
1.3125        thus "dist (integral {a..y} f) (integral {a..x} f) < e" apply-apply(subst dist_commute)
1.3126          apply(cases "y < x") unfolding dist_norm apply(rule d1(2)[rule_format]) defer
1.3127          apply(rule d2(2)[rule_format]) unfolding not_less by(auto simp add:field_simps)
1.3128 -    qed qed qed
1.3129 +    qed qed qed
1.3130
1.3131  subsection {* This doesn't directly involve integration, but that gives an easy proof. *}
1.3132
1.3133 @@ -4372,7 +4661,7 @@
1.3134    have "((\<lambda>x. 0\<Colon>'a) has_integral f x - f a) {a..x}"
1.3135      apply(rule fundamental_theorem_of_calculus_interior_strong[OF assms(1) *])
1.3136      apply(rule continuous_on_subset[OF assms(2)]) defer
1.3137 -    apply safe unfolding has_vector_derivative_def apply(subst has_derivative_within_open[THEN sym])
1.3138 +    apply safe unfolding has_vector_derivative_def apply(subst has_derivative_within_open[symmetric])
1.3139      apply assumption apply(rule open_interval) apply(rule has_derivative_within_subset[where s="{a..b}"])
1.3140      using assms(4) assms(5) by auto note this[unfolded *]
1.3141    note has_integral_unique[OF has_integral_0 this]
1.3142 @@ -4385,16 +4674,16 @@
1.3143    "\<forall>x\<in>(s - k). (f has_derivative (\<lambda>h. 0)) (at x within s)" "x \<in> s"
1.3144    shows "f x = y"
1.3145  proof- { presume *:"x \<noteq> c \<Longrightarrow> ?thesis" show ?thesis apply(cases,rule *,assumption)
1.3146 -      unfolding assms(5)[THEN sym] by auto } assume "x\<noteq>c"
1.3147 +      unfolding assms(5)[symmetric] by auto } assume "x\<noteq>c"
1.3148    note conv = assms(1)[unfolded convex_alt,rule_format]
1.3149    have as1:"continuous_on {0..1} (f \<circ> (\<lambda>t. (1 - t) *\<^sub>R c + t *\<^sub>R x))"
1.3150      apply(rule continuous_on_intros)+ apply(rule continuous_on_subset[OF assms(3)])
1.3151      apply safe apply(rule conv) using assms(4,7) by auto
1.3152    have *:"\<And>t xa. (1 - t) *\<^sub>R c + t *\<^sub>R x = (1 - xa) *\<^sub>R c + xa *\<^sub>R x \<Longrightarrow> t = xa"
1.3153 -  proof- case goal1 hence "(t - xa) *\<^sub>R x = (t - xa) *\<^sub>R c"
1.3154 +  proof- case goal1 hence "(t - xa) *\<^sub>R x = (t - xa) *\<^sub>R c"
1.3155        unfolding scaleR_simps by(auto simp add:algebra_simps)
1.3156      thus ?case using `x\<noteq>c` by auto qed
1.3157 -  have as2:"finite {t. ((1 - t) *\<^sub>R c + t *\<^sub>R x) \<in> k}" using assms(2)
1.3158 +  have as2:"finite {t. ((1 - t) *\<^sub>R c + t *\<^sub>R x) \<in> k}" using assms(2)
1.3159      apply(rule finite_surj[where f="\<lambda>z. SOME t. (1-t) *\<^sub>R c + t *\<^sub>R x = z"])
1.3160      apply safe unfolding image_iff apply rule defer apply assumption
1.3161      apply(rule sym) apply(rule some_equality) defer apply(drule *) by auto
1.3162 @@ -4402,7 +4691,7 @@
1.3163      apply(rule has_derivative_zero_unique_strong_interval[OF as2 as1, of ])
1.3164      unfolding o_def using assms(5) defer apply-apply(rule)
1.3165    proof- fix t assume as:"t\<in>{0..1} - {t. (1 - t) *\<^sub>R c + t *\<^sub>R x \<in> k}"
1.3166 -    have *:"c - t *\<^sub>R c + t *\<^sub>R x \<in> s - k" apply safe apply(rule conv[unfolded scaleR_simps])
1.3167 +    have *:"c - t *\<^sub>R c + t *\<^sub>R x \<in> s - k" apply safe apply(rule conv[unfolded scaleR_simps])
1.3168        using `x\<in>s` `c\<in>s` as by(auto simp add: algebra_simps)
1.3169      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)) (at t within {0..1})"
1.3171 @@ -4414,7 +4703,7 @@
1.3172      thus "((\<lambda>xa. f ((1 - xa) *\<^sub>R c + xa *\<^sub>R x)) has_derivative (\<lambda>h. 0)) (at t within {0..1})" unfolding o_def .
1.3173    qed auto thus ?thesis by auto qed
1.3174
1.3175 -subsection {* Also to any open connected set with finite set of exceptions. Could
1.3176 +subsection {* Also to any open connected set with finite set of exceptions. Could
1.3177   generalize to locally convex set with limpt-free set of exceptions. *}
1.3178
1.3179  lemma has_derivative_zero_unique_strong_connected: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
1.3180 @@ -4425,7 +4714,7 @@
1.3181      apply(rule assms(1)[unfolded connected_clopen,rule_format]) apply rule defer
1.3182      apply(rule continuous_closed_in_preimage[OF assms(4) closed_singleton])
1.3183      apply(rule open_openin_trans[OF assms(2)]) unfolding open_contains_ball
1.3184 -  proof safe fix x assume "x\<in>s"
1.3185 +  proof safe fix x assume "x\<in>s"
1.3186      from assms(2)[unfolded open_contains_ball,rule_format,OF this] guess e .. note e=conjunctD2[OF this]
1.3187      show "\<exists>e>0. ball x e \<subseteq> {xa \<in> s. f xa \<in> {f x}}" apply(rule,rule,rule e)
1.3188      proof safe fix y assume y:"y \<in> ball x e" thus "y\<in>s" using e by auto
1.3189 @@ -4444,12 +4733,12 @@
1.3190  proof- def g \<equiv> "\<lambda>x. if x \<in>{c<..<d} then f x else 0"
1.3191    { presume *:"{c..d}\<noteq>{} \<Longrightarrow> ?thesis"
1.3192      show ?thesis apply(cases,rule *,assumption)
1.3193 -    proof- case goal1 hence *:"{c<..<d} = {}" using interval_open_subset_closed by auto
1.3194 +    proof- case goal1 hence *:"{c<..<d} = {}" using interval_open_subset_closed by auto
1.3195        show ?thesis using assms(1) unfolding * using goal1 by auto
1.3196      qed } assume "{c..d}\<noteq>{}"
1.3197    from partial_division_extend_1[OF assms(2) this] guess p . note p=this
1.3198 -  note mon = monoidal_lifted[OF monoidal_monoid]
1.3199 -  note operat = operative_division[OF this operative_integral p(1), THEN sym]
1.3200 +  note mon = monoidal_lifted[OF monoidal_monoid]
1.3201 +  note operat = operative_division[OF this operative_integral p(1), symmetric]
1.3202    let ?P = "(if g integrable_on {a..b} then Some (integral {a..b} g) else None) = Some i"
1.3203    { presume "?P" hence "g integrable_on {a..b} \<and> integral {a..b} g = i"
1.3204        apply- apply(cases,subst(asm) if_P,assumption) by auto
1.3205 @@ -4476,13 +4765,13 @@
1.3206      unfolding iterate defer apply(subst if_not_P) defer using p by auto qed
1.3207
1.3208  lemma has_integral_restrict_closed_subinterval: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
1.3209 -  assumes "(f has_integral i) ({c..d})" "{c..d} \<subseteq> {a..b}"
1.3210 +  assumes "(f has_integral i) ({c..d})" "{c..d} \<subseteq> {a..b}"
1.3211    shows "((\<lambda>x. if x \<in> {c..d} then f x else 0) has_integral i) {a..b}"
1.3212  proof- note has_integral_restrict_open_subinterval[OF assms]
1.3213    note * = has_integral_spike[OF negligible_frontier_interval _ this]
1.3214    show ?thesis apply(rule *[of c d]) using interval_open_subset_closed[of c d] by auto qed
1.3215
1.3216 -lemma has_integral_restrict_closed_subintervals_eq: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::banach" assumes "{c..d} \<subseteq> {a..b}"
1.3217 +lemma has_integral_restrict_closed_subintervals_eq: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::banach" assumes "{c..d} \<subseteq> {a..b}"
1.3218    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}" (is "?l = ?r")
1.3219  proof(cases "{c..d} = {}") case False let ?g = "\<lambda>x. if x \<in> {c..d} then f x else 0"
1.3220    show ?thesis apply rule defer apply(rule has_integral_restrict_closed_subinterval[OF _ assms])
1.3221 @@ -4512,38 +4801,38 @@
1.3222          apply safe apply(drule B(2)[rule_format]) unfolding subset_eq apply(erule_tac x=x in ballE)
1.3224      qed(insert B `e>0`, auto)
1.3225 -  next assume as:"\<forall>e>0. ?r e"
1.3226 +  next assume as:"\<forall>e>0. ?r e"
1.3227      from this[rule_format,OF zero_less_one] guess C .. note C=conjunctD2[OF this,rule_format]
1.3228 -    def c \<equiv> "(\<Sum>i\<in>Basis. (- max B C) *\<^sub>R i)::'n::ordered_euclidean_space"
1.3229 +    def c \<equiv> "(\<Sum>i\<in>Basis. (- max B C) *\<^sub>R i)::'n::ordered_euclidean_space"
1.3230      def d \<equiv> "(\<Sum>i\<in>Basis. max B C *\<^sub>R i)::'n::ordered_euclidean_space"
1.3231      have c_d:"{a..b} \<subseteq> {c..d}" apply safe apply(drule B(2)) unfolding mem_interval
1.3232      proof
1.3233        case goal1 thus ?case using Basis_le_norm[OF `i\<in>Basis`, of x] unfolding c_def d_def
1.3235      qed
1.3236 -    have "ball 0 C \<subseteq> {c..d}" apply safe unfolding mem_interval mem_ball dist_norm
1.3237 +    have "ball 0 C \<subseteq> {c..d}" apply safe unfolding mem_interval mem_ball dist_norm
1.3238      proof
1.3239        case goal1 thus ?case
1.3240          using Basis_le_norm[OF `i\<in>Basis`, of x] unfolding c_def d_def by (auto simp: setsum_negf)
1.3241      qed
1.3242      from C(2)[OF this] have "\<exists>y. (f has_integral y) {a..b}"
1.3243 -      unfolding has_integral_restrict_closed_subintervals_eq[OF c_d,THEN sym] unfolding s by auto
1.3244 +      unfolding has_integral_restrict_closed_subintervals_eq[OF c_d,symmetric] unfolding s by auto
1.3245      then guess y .. note y=this
1.3246
1.3247      have "y = i" proof(rule ccontr) assume "y\<noteq>i" hence "0 < norm (y - i)" by auto
1.3248        from as[rule_format,OF this] guess C ..  note C=conjunctD2[OF this,rule_format]
1.3249 -      def c \<equiv> "(\<Sum>i\<in>Basis. (- max B C) *\<^sub>R i)::'n::ordered_euclidean_space"
1.3250 +      def c \<equiv> "(\<Sum>i\<in>Basis. (- max B C) *\<^sub>R i)::'n::ordered_euclidean_space"
1.3251        def d \<equiv> "(\<Sum>i\<in>Basis. max B C *\<^sub>R i)::'n::ordered_euclidean_space"
1.3252        have c_d:"{a..b} \<subseteq> {c..d}" apply safe apply(drule B(2)) unfolding mem_interval
1.3253        proof case goal1 thus ?case using Basis_le_norm[of i x] unfolding c_def d_def
1.3254            by(auto simp add:field_simps setsum_negf) qed
1.3255 -      have "ball 0 C \<subseteq> {c..d}" apply safe unfolding mem_interval mem_ball dist_norm
1.3256 +      have "ball 0 C \<subseteq> {c..d}" apply safe unfolding mem_interval mem_ball dist_norm
1.3257        proof case goal1 thus ?case using Basis_le_norm[of i x] unfolding c_def d_def by (auto simp: setsum_negf) qed
1.3258        note C(2)[OF this] then guess z .. note z = conjunctD2[OF this, unfolded s]
1.3259        note this[unfolded has_integral_restrict_closed_subintervals_eq[OF c_d]]
1.3260        hence "z = y" "norm (z - i) < norm (y - i)" apply- apply(rule has_integral_unique[OF _ y(1)]) .
1.3261        thus False by auto qed
1.3262 -    thus ?l using y unfolding s by auto qed qed
1.3263 +    thus ?l using y unfolding s by auto qed qed
1.3264
1.3265  lemma has_integral_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
1.3266    assumes "(f has_integral i) s" "(g has_integral j) s"  "\<forall>x\<in>s. (f x) \<le> (g x)"
1.3267 @@ -4556,12 +4845,12 @@
1.3268    using has_integral_le[OF assms(1,2)[unfolded has_integral_integral] assms(3)] .
1.3269
1.3270  lemma has_integral_nonneg: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
1.3271 -  assumes "(f has_integral i) s" "\<forall>x\<in>s. 0 \<le> f x" shows "0 \<le> i"
1.3272 +  assumes "(f has_integral i) s" "\<forall>x\<in>s. 0 \<le> f x" shows "0 \<le> i"
1.3273    using has_integral_component_nonneg[of 1 f i s]
1.3274    unfolding o_def using assms by auto
1.3275
1.3276  lemma integral_nonneg: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
1.3277 -  assumes "f integrable_on s" "\<forall>x\<in>s. 0 \<le> f x" shows "0 \<le> integral s f"
1.3278 +  assumes "f integrable_on s" "\<forall>x\<in>s. 0 \<le> f x" shows "0 \<le> integral s f"
1.3279    using has_integral_nonneg[OF assms(1)[unfolded has_integral_integral] assms(2)] .
1.3280
1.3281  subsection {* Hence a general restriction property. *}
1.3282 @@ -4574,20 +4863,20 @@
1.3283  lemma has_integral_restrict_univ: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach" shows
1.3284    "((\<lambda>x. if x \<in> s then f x else 0) has_integral i) UNIV \<longleftrightarrow> (f has_integral i) s" by auto
1.3285
1.3286 -lemma has_integral_on_superset: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3287 +lemma has_integral_on_superset: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3288    assumes "\<forall>x. ~(x \<in> s) \<longrightarrow> f x = 0" "s \<subseteq> t" "(f has_integral i) s"
1.3289    shows "(f has_integral i) t"
1.3290  proof- have "(\<lambda>x. if x \<in> s then f x else 0) = (\<lambda>x. if x \<in> t then f x else 0)"
1.3291      apply(rule) using assms(1-2) by auto
1.3292 -  thus ?thesis apply- using assms(3) apply(subst has_integral_restrict_univ[THEN sym])
1.3293 -  apply- apply(subst(asm) has_integral_restrict_univ[THEN sym]) by auto qed
1.3294 -
1.3295 -lemma integrable_on_superset: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3296 +  thus ?thesis apply- using assms(3) apply(subst has_integral_restrict_univ[symmetric])
1.3297 +  apply- apply(subst(asm) has_integral_restrict_univ[symmetric]) by auto qed
1.3298 +
1.3299 +lemma integrable_on_superset: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3300    assumes "\<forall>x. ~(x \<in> s) \<longrightarrow> f x = 0" "s \<subseteq> t" "f integrable_on s"
1.3301    shows "f integrable_on t"
1.3302    using assms unfolding integrable_on_def by(auto intro:has_integral_on_superset)
1.3303
1.3304 -lemma integral_restrict_univ[intro]: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3305 +lemma integral_restrict_univ[intro]: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3306    shows "f integrable_on s \<Longrightarrow> integral UNIV (\<lambda>x. if x \<in> s then f x else 0) = integral s f"
1.3307    apply(rule integral_unique) unfolding has_integral_restrict_univ by auto
1.3308
1.3309 @@ -4600,9 +4889,9 @@
1.3310    proof safe case goal1 show ?case apply(rule has_integral_negligible[OF `?r`[rule_format,of a b]])
1.3311        unfolding indicator_def by auto qed qed auto
1.3312
1.3313 -lemma has_integral_spike_set_eq: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3314 +lemma has_integral_spike_set_eq: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3315    assumes "negligible((s - t) \<union> (t - s))" shows "((f has_integral y) s \<longleftrightarrow> (f has_integral y) t)"
1.3316 -  unfolding has_integral_restrict_univ[THEN sym,of f] apply(rule has_integral_spike_eq[OF assms]) by (auto split: split_if_asm)
1.3317 +  unfolding has_integral_restrict_univ[symmetric,of f] apply(rule has_integral_spike_eq[OF assms]) by (auto split: split_if_asm)
1.3318
1.3319  lemma has_integral_spike_set[dest]: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3320    assumes "negligible((s - t) \<union> (t - s))" "(f has_integral y) s"
1.3321 @@ -4611,7 +4900,7 @@
1.3322
1.3323  lemma integrable_spike_set[dest]: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3324    assumes "negligible((s - t) \<union> (t - s))" "f integrable_on s"
1.3325 -  shows "f integrable_on t" using assms(2) unfolding integrable_on_def
1.3326 +  shows "f integrable_on t" using assms(2) unfolding integrable_on_def
1.3327    unfolding has_integral_spike_set_eq[OF assms(1)] .
1.3328
1.3329  lemma integrable_spike_set_eq: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3330 @@ -4656,7 +4945,7 @@
1.3331  lemma has_integral_subset_component_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
1.3332    assumes k: "k\<in>Basis" 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"
1.3333    shows "i\<bullet>k \<le> j\<bullet>k"
1.3334 -proof- note has_integral_restrict_univ[THEN sym, of f]
1.3335 +proof- note has_integral_restrict_univ[symmetric, of f]
1.3336    note as(2-3)[unfolded this] note * = has_integral_component_le[OF k this]
1.3337    show ?thesis apply(rule *) using as(1,4) by auto qed
1.3338
1.3339 @@ -4701,12 +4990,12 @@
1.3340      show "\<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow>
1.3341                      norm (integral {a..b} (\<lambda>x. if x \<in> s then f x else 0) - i) < e"
1.3342      proof(rule,rule,rule B,safe) case goal1 from B(2)[OF this] guess z .. note z=conjunctD2[OF this]
1.3343 -      from integral_unique[OF this(1)] show ?case using z(2) by auto qed qed qed
1.3344 +      from integral_unique[OF this(1)] show ?case using z(2) by auto qed qed qed
1.3345
1.3346
1.3347  subsection {* Continuity of the integral (for a 1-dimensional interval). *}
1.3348
1.3349 -lemma integrable_alt: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach" shows
1.3350 +lemma integrable_alt: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach" shows
1.3351    "f integrable_on s \<longleftrightarrow>
1.3352            (\<forall>a b. (\<lambda>x. if x \<in> s then f x else 0) integrable_on {a..b}) \<and>
1.3353            (\<forall>e>0. \<exists>B>0. \<forall>a b c d. ball 0 B \<subseteq> {a..b} \<and> ball 0 B \<subseteq> {c..d}
1.3354 @@ -4718,7 +5007,7 @@
1.3355      show ?case apply(rule,rule,rule B)
1.3356      proof safe case goal1 show ?case apply(rule norm_triangle_half_l)
1.3357          using B(2)[OF goal1(1)] B(2)[OF goal1(2)] by auto qed qed
1.3358 -
1.3359 +
1.3360  next assume ?r note as = conjunctD2[OF this,rule_format]
1.3361    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"
1.3362    have "Cauchy (\<lambda>n. integral (?cube n) (\<lambda>x. if x \<in> s then f x else 0))"
1.3363 @@ -4730,7 +5019,7 @@
1.3364        proof case goal1 thus ?case using Basis_le_norm[of i x] `i\<in>Basis`
1.3365            using n N by(auto simp add:field_simps setsum_negf) qed }
1.3366      thus ?case apply-apply(rule_tac x=N in exI) apply safe unfolding dist_norm apply(rule B(2)) by auto
1.3367 -  qed from this[unfolded convergent_eq_cauchy[THEN sym]] guess i ..
1.3368 +  qed from this[unfolded convergent_eq_cauchy[symmetric]] guess i ..
1.3369    note i = this[THEN LIMSEQ_D]
1.3370
1.3371    show ?l unfolding integrable_on_def has_integral_alt'[of f] apply(rule_tac x=i in exI)
1.3372 @@ -4747,7 +5036,7 @@
1.3373          apply(rule N[of n])
1.3374        proof safe show "N \<le> n" using n by auto
1.3375          fix x::"'n::ordered_euclidean_space" assume x:"x \<in> ball 0 B" hence "x\<in> ball 0 ?B" by auto
1.3376 -        thus "x\<in>{a..b}" using ab by blast
1.3377 +        thus "x\<in>{a..b}" using ab by blast
1.3378          show "x\<in>?cube n" using x unfolding mem_interval mem_ball dist_norm apply-
1.3379          proof case goal1 thus ?case using Basis_le_norm[of i x] `i\<in>Basis`
1.3380              using n by(auto simp add:field_simps setsum_negf) qed qed qed qed qed
1.3381 @@ -4777,31 +5066,31 @@
1.3382    from obt(2)[unfolded has_integral[of h], rule_format, OF e] guess d2 .. note d2=conjunctD2[OF this,rule_format]
1.3383    show ?case apply(rule_tac x="\<lambda>x. d1 x \<inter> d2 x" in exI) apply(rule conjI gauge_inter d1 d2)+ unfolding fine_inter
1.3384    proof safe have **:"\<And>i j g1 g2 h1 h2 f1 f2. g1 - h2 \<le> f1 - f2 \<Longrightarrow> f1 - f2 \<le> h1 - g2 \<Longrightarrow>
1.3385 -      abs(i - j) < e / 3 \<Longrightarrow> abs(g2 - i) < e / 3 \<Longrightarrow>  abs(g1 - i) < e / 3 \<Longrightarrow>
1.3386 +      abs(i - j) < e / 3 \<Longrightarrow> abs(g2 - i) < e / 3 \<Longrightarrow>  abs(g1 - i) < e / 3 \<Longrightarrow>
1.3387        abs(h2 - j) < e / 3 \<Longrightarrow> abs(h1 - j) < e / 3 \<Longrightarrow> abs(f1 - f2) < e" using `e>0` by arith
1.3388      case goal1 note tagged_division_ofD(2-4) note * = this[OF goal1(1)] this[OF goal1(4)]
1.3389
1.3390      have "(\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p1. content k *\<^sub>R g x) \<ge> 0"
1.3391 -      "0 \<le> (\<Sum>(x, k)\<in>p2. content k *\<^sub>R h x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)"
1.3392 +      "0 \<le> (\<Sum>(x, k)\<in>p2. content k *\<^sub>R h x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)"
1.3393        "(\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R g x) \<ge> 0"
1.3394 -      "0 \<le> (\<Sum>(x, k)\<in>p1. content k *\<^sub>R h x) - (\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x)"
1.3395 -      unfolding setsum_subtractf[THEN sym] apply- apply(rule_tac[!] setsum_nonneg)
1.3396 -      apply safe unfolding real_scaleR_def right_diff_distrib[THEN sym]
1.3397 +      "0 \<le> (\<Sum>(x, k)\<in>p1. content k *\<^sub>R h x) - (\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x)"
1.3398 +      unfolding setsum_subtractf[symmetric] apply- apply(rule_tac[!] setsum_nonneg)
1.3399 +      apply safe unfolding real_scaleR_def right_diff_distrib[symmetric]
1.3400        apply(rule_tac[!] mult_nonneg_nonneg)
1.3401      proof- fix a b assume ab:"(a,b) \<in> p1"
1.3402        show "0 \<le> content b" using *(3)[OF ab] apply safe using content_pos_le . thus "0 \<le> content b" .
1.3403        show "0 \<le> f a - g a" "0 \<le> h a - f a" using *(1-2)[OF ab] using obt(4)[rule_format,of a] by auto
1.3404      next fix a b assume ab:"(a,b) \<in> p2"
1.3405        show "0 \<le> content b" using *(6)[OF ab] apply safe using content_pos_le . thus "0 \<le> content b" .
1.3406 -      show "0 \<le> f a - g a" "0 \<le> h a - f a" using *(4-5)[OF ab] using obt(4)[rule_format,of a] by auto qed
1.3407 +      show "0 \<le> f a - g a" "0 \<le> h a - f a" using *(4-5)[OF ab] using obt(4)[rule_format,of a] by auto qed
1.3408
1.3409      thus ?case apply- unfolding real_norm_def apply(rule **) defer defer
1.3410 -      unfolding real_norm_def[THEN sym] apply(rule obt(3))
1.3411 +      unfolding real_norm_def[symmetric] apply(rule obt(3))
1.3412        apply(rule d1(2)[OF conjI[OF goal1(4,5)]])
1.3413        apply(rule d1(2)[OF conjI[OF goal1(1,2)]])
1.3414        apply(rule d2(2)[OF conjI[OF goal1(4,6)]])
1.3415 -      apply(rule d2(2)[OF conjI[OF goal1(1,3)]]) by auto qed qed
1.3416 -
1.3417 +      apply(rule d2(2)[OF conjI[OF goal1(1,3)]]) by auto qed qed
1.3418 +
1.3419  lemma integrable_straddle: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
1.3420    assumes "\<forall>e>0. \<exists>g h i j. (g has_integral i) s \<and> (h has_integral j) s \<and>
1.3421    norm(i - j) < e \<and> (\<forall>x\<in>s. (g x) \<le>(f x) \<and>(f x) \<le>(h x))"
1.3422 @@ -4822,7 +5111,7 @@
1.3423        case goal2 thus ?case using Basis_le_norm[of i x] unfolding c_def d_def by auto qed
1.3424      have **:"\<And>ch cg ag ah::real. norm(ah - ag) \<le> norm(ch - cg) \<Longrightarrow> norm(cg - i) < e / 4 \<Longrightarrow>
1.3425        norm(ch - j) < e / 4 \<Longrightarrow> norm(ag - ah) < e"
1.3426 -      using obt(3) unfolding real_norm_def by arith
1.3427 +      using obt(3) unfolding real_norm_def by arith
1.3428      show ?case apply(rule_tac x="\<lambda>x. if x \<in> s then g x else 0" in exI)
1.3429                 apply(rule_tac x="\<lambda>x. if x \<in> s then h x else 0" in exI)
1.3430        apply(rule_tac x="integral {a..b} (\<lambda>x. if x \<in> s then g x else 0)" in exI)
1.3431 @@ -4836,7 +5125,7 @@
1.3432                     integral {a..b} (\<lambda>x. if x \<in> s then g x else 0))
1.3433             \<le> norm (integral {c..d} (\<lambda>x. if x \<in> s then h x else 0) -
1.3434                     integral {c..d} (\<lambda>x. if x \<in> s then g x else 0))"
1.3435 -        unfolding integral_sub[OF h g,THEN sym] real_norm_def apply(subst **) defer apply(subst **) defer
1.3436 +        unfolding integral_sub[OF h g,symmetric] real_norm_def apply(subst **) defer apply(subst **) defer
1.3437          apply(rule has_integral_subset_le) defer apply(rule integrable_integral integrable_sub h g)+
1.3438        proof safe fix x assume "x\<in>{a..b}" thus "x\<in>{c..d}" unfolding mem_interval c_def d_def
1.3439            apply - apply rule apply(erule_tac x=i in ballE) by auto
1.3440 @@ -4856,30 +5145,30 @@
1.3441          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> abs(fa - fc) < e"
1.3442          by (simp add: abs_real_def split: split_if_asm)
1.3443        show "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"
1.3444 -        unfolding real_norm_def apply(rule *, safe) unfolding real_norm_def[THEN sym]
1.3445 -        apply(rule B1(2),rule order_trans,rule **,rule as(1))
1.3446 -        apply(rule B1(2),rule order_trans,rule **,rule as(2))
1.3447 -        apply(rule B2(2),rule order_trans,rule **,rule as(1))
1.3448 -        apply(rule B2(2),rule order_trans,rule **,rule as(2))
1.3449 +        unfolding real_norm_def apply(rule *, safe) unfolding real_norm_def[symmetric]
1.3450 +        apply(rule B1(2),rule order_trans,rule **,rule as(1))
1.3451 +        apply(rule B1(2),rule order_trans,rule **,rule as(2))
1.3452 +        apply(rule B2(2),rule order_trans,rule **,rule as(1))
1.3453 +        apply(rule B2(2),rule order_trans,rule **,rule as(2))
1.3454          apply(rule obt) apply(rule_tac[!] integral_le) using obt
1.3455 -        by(auto intro!: h g interv) qed qed qed
1.3456 +        by(auto intro!: h g interv) qed qed qed
1.3457
1.3458  subsection {* Adding integrals over several sets. *}
1.3459
1.3460  lemma has_integral_union: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3461    assumes "(f has_integral i) s" "(f has_integral j) t" "negligible(s \<inter> t)"
1.3462    shows "(f has_integral (i + j)) (s \<union> t)"
1.3463 -proof- note * = has_integral_restrict_univ[THEN sym, of f]
1.3464 +proof- note * = has_integral_restrict_univ[symmetric, of f]
1.3465    show ?thesis unfolding * apply(rule has_integral_spike[OF assms(3)])
1.3466      defer apply(rule has_integral_add[OF assms(1-2)[unfolded *]]) by auto qed
1.3467
1.3468  lemma has_integral_unions: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3469    assumes "finite t" "\<forall>s\<in>t. (f has_integral (i s)) s"  "\<forall>s\<in>t. \<forall>s'\<in>t. ~(s = s') \<longrightarrow> negligible(s \<inter> s')"
1.3470    shows "(f has_integral (setsum i t)) (\<Union>t)"
1.3471 -proof- note * = has_integral_restrict_univ[THEN sym, of f]
1.3472 +proof- note * = has_integral_restrict_univ[symmetric, of f]
1.3473    have **:"negligible (\<Union>((\<lambda>(a,b). a \<inter> b) ` {(a,b). a \<in> t \<and> b \<in> {y. y \<in> t \<and> ~(a = y)}}))"
1.3474 -    apply(rule negligible_unions) apply(rule finite_imageI) apply(rule finite_subset[of _ "t \<times> t"]) defer
1.3475 -    apply(rule finite_cartesian_product[OF assms(1,1)]) using assms(3) by auto
1.3476 +    apply(rule negligible_unions) apply(rule finite_imageI) apply(rule finite_subset[of _ "t \<times> t"]) defer
1.3477 +    apply(rule finite_cartesian_product[OF assms(1,1)]) using assms(3) by auto
1.3478    note assms(2)[unfolded *] note has_integral_setsum[OF assms(1) this]
1.3479    thus ?thesis unfolding * apply-apply(rule has_integral_spike[OF **]) defer apply assumption
1.3480    proof safe case goal1 thus ?case
1.3481 @@ -4895,7 +5184,7 @@
1.3482    assumes "d division_of s" "\<forall>k\<in>d. (f has_integral (i k)) k"
1.3483    shows "(f has_integral (setsum i d)) s"
1.3484  proof- note d = division_ofD[OF assms(1)]
1.3485 -  show ?thesis unfolding d(6)[THEN sym] apply(rule has_integral_unions)
1.3486 +  show ?thesis unfolding d(6)[symmetric] apply(rule has_integral_unions)
1.3487      apply(rule d assms)+ apply(rule,rule,rule)
1.3488    proof- case goal1 from d(4)[OF this(1)] d(4)[OF this(2)]
1.3489      guess a c b d apply-by(erule exE)+ note obt=this
1.3490 @@ -4913,7 +5202,7 @@
1.3491    assumes "f integrable_on s" "d division_of k" "k \<subseteq> s"
1.3492    shows "(f has_integral (setsum (\<lambda>i. integral i f) d)) k"
1.3493    apply(rule has_integral_combine_division[OF assms(2)])
1.3494 -  apply safe unfolding has_integral_integral[THEN sym]
1.3495 +  apply safe unfolding has_integral_integral[symmetric]
1.3496  proof- case goal1 from division_ofD(2,4)[OF assms(2) this]
1.3497    show ?case apply safe apply(rule integrable_on_subinterval)
1.3498      apply(rule assms) using assms(3) by auto qed
1.3499 @@ -4944,7 +5233,7 @@
1.3500    shows "(f has_integral (setsum (\<lambda>(x,k). i k) p)) s"
1.3501  proof- have *:"(f has_integral (setsum (\<lambda>k. integral k f) (snd ` p))) s"
1.3502      apply(rule has_integral_combine_division) apply(rule division_of_tagged_division[OF assms(1)])
1.3503 -    using assms(2) unfolding has_integral_integral[THEN sym] by(safe,auto)
1.3504 +    using assms(2) unfolding has_integral_integral[symmetric] by(safe,auto)
1.3505    thus ?thesis apply- apply(rule subst[where P="\<lambda>i. (f has_integral i) s"]) defer apply assumption
1.3506      apply(rule trans[of _ "setsum (\<lambda>(x,k). integral k f) p"]) apply(subst eq_commute)
1.3507      apply(rule setsum_over_tagged_division_lemma[OF assms(1)]) apply(rule integral_null,assumption)
1.3508 @@ -4998,22 +5287,22 @@
1.3509
1.3510    let ?p = "p \<union> \<Union>(qq ` r)" have "norm ((\<Sum>(x, k)\<in>?p. content k *\<^sub>R f x) - integral {a..b} f) < e"
1.3511      apply(rule assms(4)[rule_format])
1.3512 -  proof show "d fine ?p" apply(rule fine_union,rule p) apply(rule fine_unions) using qq by auto
1.3513 +  proof show "d fine ?p" apply(rule fine_union,rule p) apply(rule fine_unions) using qq by auto
1.3514      note * = tagged_partial_division_of_union_self[OF p(1)]
1.3515      have "p \<union> \<Union>(qq ` r) tagged_division_of \<Union>(snd ` p) \<union> \<Union>r"
1.3516      proof(rule tagged_division_union[OF * tagged_division_unions])
1.3517        show "finite r" by fact case goal2 thus ?case using qq by auto
1.3518      next case goal3 thus ?case apply(rule,rule,rule) apply(rule q'(5)) unfolding r_def by auto
1.3519      next case goal4 thus ?case apply(rule inter_interior_unions_intervals) apply(fact,rule)
1.3520 -        apply(rule,rule q') defer apply(rule,subst Int_commute)
1.3521 +        apply(rule,rule q') defer apply(rule,subst Int_commute)
1.3522          apply(rule inter_interior_unions_intervals) apply(rule finite_imageI,rule p',rule) defer
1.3523          apply(rule,rule q') using q(1) p' unfolding r_def by auto qed
1.3524      moreover have "\<Union>(snd ` p) \<union> \<Union>r = {a..b}" "{qq i |i. i \<in> r} = qq ` r"
1.3525 -      unfolding Union_Un_distrib[THEN sym] r_def using q by auto
1.3526 +      unfolding Union_Un_distrib[symmetric] r_def using q by auto
1.3527      ultimately show "?p tagged_division_of {a..b}" by fastforce qed
1.3528
1.3529    hence "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) -
1.3530 -    integral {a..b} f) < e" apply(subst setsum_Un_zero[THEN sym]) apply(rule p') prefer 3
1.3531 +    integral {a..b} f) < e" apply(subst setsum_Un_zero[symmetric]) apply(rule p') prefer 3
1.3532      apply assumption apply rule apply(rule finite_imageI,rule r) apply safe apply(drule qq)
1.3533    proof- fix x l k assume as:"(x,l)\<in>p" "(x,l)\<in>qq k" "k\<in>r"
1.3534      note qq[OF this(3)] note tagged_division_ofD(3,4)[OF conjunct1[OF this] as(2)]
1.3535 @@ -5021,7 +5310,7 @@
1.3536      have "l\<in>snd ` p" unfolding image_iff apply(rule_tac x="(x,l)" in bexI) using as by auto
1.3537      hence "l\<in>q" "k\<in>q" "l\<noteq>k" using as(1,3) q(1) unfolding r_def by auto
1.3538      note q'(5)[OF this] hence "interior l = {}" using interior_mono[OF `l \<subseteq> k`] by blast
1.3539 -    thus "content l *\<^sub>R f x = 0" unfolding uv content_eq_0_interior[THEN sym] by auto qed auto
1.3540 +    thus "content l *\<^sub>R f x = 0" unfolding uv content_eq_0_interior[symmetric] by auto qed auto
1.3541
1.3542    hence "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + setsum (setsum (\<lambda>(x, k). content k *\<^sub>R f x))
1.3543      (qq ` r) - integral {a..b} f) < e" apply(subst(asm) setsum_UNION_zero)
1.3544 @@ -5032,23 +5321,23 @@
1.3545      from this(2)[OF as(4,1)] guess u v apply-by(erule exE)+ note uv=this
1.3546      have *:"interior (k \<inter> l) = {}" unfolding interior_inter apply(rule q')
1.3547        using as unfolding r_def by auto
1.3548 -    have "interior m = {}" unfolding subset_empty[THEN sym] unfolding *[THEN sym]
1.3549 +    have "interior m = {}" unfolding subset_empty[symmetric] unfolding *[symmetric]
1.3550        apply(rule interior_mono) using kl(1)[OF as(4,1)] kl(1)[OF as(5,2)] by auto
1.3551 -    thus "content m *\<^sub>R f x = 0" unfolding uv content_eq_0_interior[THEN sym] by auto
1.3552 +    thus "content m *\<^sub>R f x = 0" unfolding uv content_eq_0_interior[symmetric] by auto
1.3553    qed(insert qq, auto)
1.3554
1.3555    hence **:"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 -
1.3556      integral {a..b} f) < e" apply(subst(asm) setsum_reindex_nonzero) apply fact
1.3557      apply(rule setsum_0',rule) unfolding split_paired_all split_conv defer apply assumption
1.3558    proof- fix k l x m assume as:"k\<in>r" "l\<in>r" "k\<noteq>l" "qq k = qq l" "(x,m)\<in>qq k"
1.3559 -    note tagged_division_ofD(6)[OF qq[THEN conjunct1]] from this[OF as(1)] this[OF as(2)]
1.3560 +    note tagged_division_ofD(6)[OF qq[THEN conjunct1]] from this[OF as(1)] this[OF as(2)]
1.3561      show "content m *\<^sub>R f x = 0"  using as(3) unfolding as by auto qed
1.3562 -
1.3563 -  have *:"\<And>ir ip i cr cp. norm((cp + cr) - i) < e \<Longrightarrow> norm(cr - ir) < k \<Longrightarrow>
1.3564 -    ip + ir = i \<Longrightarrow> norm(cp - ip) \<le> e + k"
1.3565 -  proof- case goal1 thus ?case  using norm_triangle_le[of "cp + cr - i" "- (cr - ir)"]
1.3566 -      unfolding goal1(3)[THEN sym] norm_minus_cancel by(auto simp add:algebra_simps) qed
1.3567 -
1.3568 +
1.3569 +  have *:"\<And>ir ip i cr cp. norm((cp + cr) - i) < e \<Longrightarrow> norm(cr - ir) < k \<Longrightarrow>
1.3570 +    ip + ir = i \<Longrightarrow> norm(cp - ip) \<le> e + k"
1.3571 +  proof- case goal1 thus ?case  using norm_triangle_le[of "cp + cr - i" "- (cr - ir)"]
1.3572 +      unfolding goal1(3)[symmetric] norm_minus_cancel by(auto simp add:algebra_simps) qed
1.3573 +
1.3574    have "?x =  norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p. integral k f))"
1.3575      unfolding split_def setsum_subtractf ..
1.3576    also have "... \<le> e + k" apply(rule *[OF **, where ir="setsum (\<lambda>k. integral k f) r"])
1.3577 @@ -5059,15 +5348,15 @@
1.3578        from p'(4)[OF as(1)] guess u v apply-by(erule exE)+ note uv=this
1.3579        show "integral l f = 0" unfolding uv apply(rule integral_unique)
1.3580          apply(rule has_integral_null) unfolding content_eq_0_interior
1.3581 -        using p'(5)[OF as(1-3)] unfolding uv as(4)[THEN sym] by auto
1.3582 -    qed auto
1.3583 +        using p'(5)[OF as(1-3)] unfolding uv as(4)[symmetric] by auto
1.3584 +    qed auto
1.3585      show ?case unfolding integral_combine_division_topdown[OF assms(1) q(2)] * r_def
1.3586 -      apply(rule setsum_Un_disjoint'[THEN sym]) using q(1) q'(1) p'(1) by auto
1.3587 +      apply(rule setsum_Un_disjoint'[symmetric]) using q(1) q'(1) p'(1) by auto
1.3588    next  case goal1 have *:"k * real (card r) / (1 + real (card r)) < k" using k by(auto simp add:field_simps)
1.3589      show ?case apply(rule le_less_trans[of _ "setsum (\<lambda>x. k / (real (card r) + 1)) r"])
1.3590 -      unfolding setsum_subtractf[THEN sym] apply(rule setsum_norm_le)
1.3591 -      apply rule apply(drule qq) defer unfolding divide_inverse setsum_left_distrib[THEN sym]
1.3592 -      unfolding divide_inverse[THEN sym] using * by(auto simp add:field_simps real_eq_of_nat)
1.3593 +      unfolding setsum_subtractf[symmetric] apply(rule setsum_norm_le)
1.3594 +      apply rule apply(drule qq) defer unfolding divide_inverse setsum_left_distrib[symmetric]
1.3595 +      unfolding divide_inverse[symmetric] using * by(auto simp add:field_simps real_eq_of_nat)
1.3596    qed finally show "?x \<le> e + k" . qed
1.3597
1.3598  lemma henstock_lemma_part2: fixes f::"'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space"
1.3599 @@ -5075,12 +5364,12 @@
1.3600    "\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow> norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p -
1.3601            integral({a..b}) f) < e"    "p tagged_partial_division_of {a..b}" "d fine p"
1.3602    shows "setsum (\<lambda>(x,k). norm(content k *\<^sub>R f x - integral k f)) p \<le> 2 * real (DIM('n)) * e"
1.3603 -  unfolding split_def apply(rule setsum_norm_allsubsets_bound) defer
1.3604 +  unfolding split_def apply(rule setsum_norm_allsubsets_bound) defer
1.3605    apply(rule henstock_lemma_part1[unfolded split_def,OF assms(1-3)])
1.3606    apply safe apply(rule assms[rule_format,unfolded split_def]) defer
1.3607    apply(rule tagged_partial_division_subset,rule assms,assumption)
1.3608    apply(rule fine_subset,assumption,rule assms) using assms(5) by auto
1.3609 -
1.3610 +
1.3611  lemma henstock_lemma: fixes f::"'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space"
1.3612    assumes "f integrable_on {a..b}" "e>0"
1.3613    obtains d where "gauge d"
1.3614 @@ -5201,7 +5490,7 @@
1.3615          unfolding dist_real_def using fg[rule_format,OF goal1]
1.3616          by (auto simp add:field_simps) qed
1.3617      from bchoice[OF this] guess m .. note m=conjunctD2[OF this[rule_format],rule_format]
1.3618 -    def d \<equiv> "\<lambda>x. c (m x) x"
1.3619 +    def d \<equiv> "\<lambda>x. c (m x) x"
1.3620
1.3621      show ?case apply(rule_tac x=d in exI)
1.3622      proof safe show "gauge d" using c(1) unfolding gauge_def d_def by auto
1.3623 @@ -5211,7 +5500,7 @@
1.3624          by (metis finite_imageI finite_nat_set_iff_bounded_le p'(1) rev_image_eqI)
1.3625        then guess s .. note s=this
1.3626        have *:"\<forall>a b c d. norm(a - b) \<le> e / 4 \<and> norm(b - c) < e / 2 \<and>
1.3627 -            norm(c - d) < e / 4 \<longrightarrow> norm(a - d) < e"
1.3628 +            norm(c - d) < e / 4 \<longrightarrow> norm(a - d) < e"
1.3629        proof safe case goal1 thus ?case using norm_triangle_lt[of "a - b" "b - c" "3* e/4"]
1.3630            norm_triangle_lt[of "a - b + (b - c)" "c - d" e] unfolding norm_minus_cancel
1.3632 @@ -5219,17 +5508,17 @@
1.3633            b="\<Sum>(x, k)\<in>p. content k *\<^sub>R f (m x) x" and c="\<Sum>(x, k)\<in>p. integral k (f (m x))"])
1.3634        proof safe case goal1
1.3635           show ?case apply(rule order_trans[of _ "\<Sum>(x, k)\<in>p. content k * (e / (4 * content {a..b}))"])
1.3636 -           unfolding setsum_subtractf[THEN sym] apply(rule order_trans,rule norm_setsum)
1.3637 +           unfolding setsum_subtractf[symmetric] apply(rule order_trans,rule norm_setsum)
1.3638             apply(rule setsum_mono) unfolding split_paired_all split_conv
1.3639 -           unfolding split_def setsum_left_distrib[THEN sym] scaleR_diff_right[THEN sym]
1.3640 +           unfolding split_def setsum_left_distrib[symmetric] scaleR_diff_right[symmetric]
1.3641             unfolding additive_content_tagged_division[OF p(1), unfolded split_def]
1.3642           proof- fix x k assume xk:"(x,k) \<in> p" hence x:"x\<in>{a..b}" using p'(2-3)[OF xk] by auto
1.3643             from p'(4)[OF xk] guess u v apply-by(erule exE)+ note uv=this
1.3644             show " norm (content k *\<^sub>R (g x - f (m x) x)) \<le> content k * (e / (4 * content {a..b}))"
1.3645 -             unfolding norm_scaleR uv unfolding abs_of_nonneg[OF content_pos_le]
1.3646 +             unfolding norm_scaleR uv unfolding abs_of_nonneg[OF content_pos_le]
1.3647               apply(rule mult_left_mono) using m(2)[OF x,of "m x"] by auto
1.3648           qed(insert ab,auto)
1.3649 -
1.3650 +
1.3651         next case goal2 show ?case apply(rule le_less_trans[of _ "norm (\<Sum>j = 0..s.
1.3652             \<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.3653             apply(subst setsum_group) apply fact apply(rule finite_atLeastAtMost) defer
1.3654 @@ -5240,7 +5529,7 @@
1.3655               apply(rule setsum_norm_le)
1.3656             proof show "(\<Sum>i = 0..s. e / 2 ^ (i + 2)) < e / 2"
1.3658 -               unfolding setsum_right_distrib[THEN sym] setsum_left_distrib[THEN sym]
1.3659 +               unfolding setsum_right_distrib[symmetric] setsum_left_distrib[symmetric]
1.3660                 unfolding power_inverse sum_gp apply(rule mult_strict_left_mono[OF _ e])
1.3661                 unfolding power2_eq_square by auto
1.3662               fix t assume "t\<in>{0..s}"
1.3663 @@ -5259,22 +5548,22 @@
1.3664         next case goal3
1.3665           note comb = integral_combine_tagged_division_topdown[OF assms(1)[rule_format] p(1)]
1.3666           have *:"\<And>sr sx ss ks kr::real. kr = sr \<longrightarrow> ks = ss \<longrightarrow> ks \<le> i \<and> sr \<le> sx \<and> sx \<le> ss \<and> 0 \<le> i\<bullet>1 - kr\<bullet>1
1.3667 -           \<and> i\<bullet>1 - kr\<bullet>1 < e/4 \<longrightarrow> abs(sx - i) < e/4" by auto
1.3668 +           \<and> i\<bullet>1 - kr\<bullet>1 < e/4 \<longrightarrow> abs(sx - i) < e/4" by auto
1.3669           show ?case unfolding real_norm_def apply(rule *[rule_format],safe)
1.3670 -           apply(rule comb[of r],rule comb[of s]) apply(rule i'[unfolded real_inner_1_right])
1.3671 +           apply(rule comb[of r],rule comb[of s]) apply(rule i'[unfolded real_inner_1_right])
1.3672             apply(rule_tac[1-2] setsum_mono) unfolding split_paired_all split_conv
1.3673             apply(rule_tac[1-2] integral_le[OF ])
1.3674           proof safe show "0 \<le> i\<bullet>1 - (integral {a..b} (f r))\<bullet>1" using r(1) by auto
1.3675             show "i\<bullet>1 - (integral {a..b} (f r))\<bullet>1 < e / 4" using r(2) by auto
1.3676             fix x k assume xk:"(x,k)\<in>p" from p'(4)[OF this] guess u v apply-by(erule exE)+ note uv=this
1.3677 -           show "f r integrable_on k" "f s integrable_on k" "f (m x) integrable_on k" "f (m x) integrable_on k"
1.3678 +           show "f r integrable_on k" "f s integrable_on k" "f (m x) integrable_on k" "f (m x) integrable_on k"
1.3679               unfolding uv apply(rule_tac[!] integrable_on_subinterval[OF assms(1)[rule_format]])
1.3680 -             using p'(3)[OF xk] unfolding uv by auto
1.3681 +             using p'(3)[OF xk] unfolding uv by auto
1.3682             fix y assume "y\<in>k" hence "y\<in>{a..b}" using p'(3)[OF xk] by auto
1.3683             hence *:"\<And>m. \<forall>n\<ge>m. (f m y) \<le> (f n y)" apply-apply(rule transitive_stepwise_le) using assms(2) by auto
1.3684             show "(f r y) \<le> (f (m x) y)" "(f (m x) y) \<le> (f s y)"
1.3685               apply(rule_tac[!] *[rule_format]) using s[rule_format,OF xk] m(1)[of x] p'(2-3)[OF xk] by auto
1.3686 -         qed qed qed qed note * = this
1.3687 +         qed qed qed qed note * = this
1.3688
1.3689     have "integral {a..b} g = i" apply(rule integral_unique) using * .
1.3690     thus ?thesis using i * by auto qed
1.3691 @@ -5300,13 +5589,13 @@
1.3692        apply(rule i,rule trivial_limit_sequentially) unfolding eventually_sequentially
1.3693        apply(rule_tac x=k in exI,safe) apply(rule integral_component_le)
1.3694        apply simp
1.3695 -      apply(rule goal1(2)[rule_format])+ by auto
1.3696 +      apply(rule goal1(2)[rule_format])+ by auto
1.3697
1.3698      note int = assms(2)[unfolded integrable_alt[of _ s],THEN conjunct1,rule_format]
1.3699      have ifif:"\<And>k t. (\<lambda>x. if x \<in> t then if x \<in> s then f k x else 0 else 0) =
1.3700        (\<lambda>x. if x \<in> t\<inter>s then f k x else 0)" apply(rule ext) by auto
1.3701 -    have int':"\<And>k a b. f k integrable_on {a..b} \<inter> s" apply(subst integrable_restrict_univ[THEN sym])
1.3702 -      apply(subst ifif[THEN sym]) apply(subst integrable_restrict_univ) using int .
1.3703 +    have int':"\<And>k a b. f k integrable_on {a..b} \<inter> s" apply(subst integrable_restrict_univ[symmetric])
1.3704 +      apply(subst ifif[symmetric]) apply(subst integrable_restrict_univ) using int .
1.3705      have "\<And>a b. (\<lambda>x. if x \<in> s then g x else 0) integrable_on {a..b} \<and>
1.3706        ((\<lambda>k. integral {a..b} (\<lambda>x. if x \<in> s then f k x else 0)) --->
1.3707        integral {a..b} (\<lambda>x. if x \<in> s then g x else 0)) sequentially"
1.3708 @@ -5320,7 +5609,7 @@
1.3709          unfolding real_norm_def apply(subst abs_of_nonneg) apply(rule *[OF int])
1.3710          apply(safe,case_tac "x\<in>s") apply(drule assms(1)) prefer 3
1.3711          apply(subst abs_of_nonneg) apply(rule *[OF assms(2) goal1(1)[THEN spec]])
1.3712 -        apply(subst integral_restrict_univ[THEN sym,OF int])
1.3713 +        apply(subst integral_restrict_univ[symmetric,OF int])
1.3714          unfolding ifif unfolding integral_restrict_univ[OF int']
1.3715          apply(rule integral_subset_le[OF _ int' assms(2)]) using assms(1) by auto
1.3716        thus ?case using assms(5) unfolding bounded_iff apply safe
1.3717 @@ -5341,7 +5630,7 @@
1.3718            apply-defer apply(subst norm_minus_commute) by auto
1.3719          have *:"\<And>f1 f2 g. abs(f1 - i) < e / 2 \<longrightarrow> abs(f2 - g) < e / 2 \<longrightarrow> f1 \<le> f2 \<longrightarrow> f2 \<le> i
1.3720            \<longrightarrow> abs(g - i) < e" unfolding real_inner_1_right by arith
1.3721 -        show "norm (integral {a..b} (\<lambda>x. if x \<in> s then g x else 0) - i) < e"
1.3722 +        show "norm (integral {a..b} (\<lambda>x. if x \<in> s then g x else 0) - i) < e"
1.3723            unfolding real_norm_def apply(rule *[rule_format])
1.3724            apply(rule **[unfolded real_norm_def])
1.3725            apply(rule M[rule_format,of "M + N",unfolded real_norm_def]) apply(rule le_add1)
1.3726 @@ -5349,10 +5638,10 @@
1.3727            apply(rule order_trans[OF _ i'[rule_format,of "M + N",unfolded real_inner_1_right]])
1.3728          proof safe case goal2 have "\<And>m. x\<in>s \<Longrightarrow> \<forall>n\<ge>m. (f m x)\<bullet>1 \<le> (f n x)\<bullet>1"
1.3729              apply(rule transitive_stepwise_le) using assms(3) by auto thus ?case by auto
1.3730 -        next case goal1 show ?case apply(subst integral_restrict_univ[THEN sym,OF int])
1.3731 +        next case goal1 show ?case apply(subst integral_restrict_univ[symmetric,OF int])
1.3732              unfolding ifif integral_restrict_univ[OF int']
1.3733              apply(rule integral_subset_le[OF _ int']) using assms by auto
1.3734 -        qed qed qed
1.3735 +        qed qed qed
1.3736      thus ?case apply safe defer apply(drule integral_unique) using i by auto qed
1.3737
1.3738    have sub:"\<And>k. integral s (\<lambda>x. f k x - f 0 x) = integral s (f k) - integral s (f 0)"
1.3739 @@ -5364,7 +5653,7 @@
1.3740    proof- case goal1 thus ?case using *[of x 0 "Suc k"] by auto
1.3741    next case goal2 thus ?case apply(rule integrable_sub) using assms(1) by auto
1.3742    next case goal3 thus ?case using *[of x "Suc k" "Suc (Suc k)"] by auto
1.3743 -  next case goal4 thus ?case apply-apply(rule tendsto_diff)
1.3744 +  next case goal4 thus ?case apply-apply(rule tendsto_diff)
1.3745        using seq_offset[OF assms(3)[rule_format],of x 1] by auto
1.3746    next case goal5 thus ?case using assms(4) unfolding bounded_iff
1.3747        apply safe apply(rule_tac x="a + norm (integral s (\<lambda>x. f 0 x))" in exI)
1.3748 @@ -5390,7 +5679,7 @@
1.3749    note * = conjunctD2[OF this]
1.3750    show ?thesis apply rule using integrable_neg[OF *(1)] defer
1.3751      using tendsto_minus[OF *(2)] apply- unfolding integral_neg[OF assm(1)]
1.3752 -    unfolding integral_neg[OF *(1),THEN sym] by auto qed
1.3753 +    unfolding integral_neg[OF *(1),symmetric] by auto qed
1.3754
1.3755  subsection {* absolute integrability (this is the same as Lebesgue integrability). *}
1.3756
1.3757 @@ -5415,9 +5704,9 @@
1.3758  proof- have *:"\<And>x y. (\<forall>e::real. 0 < e \<longrightarrow> x < y + e) \<longrightarrow> x \<le> y" apply(safe,rule ccontr)
1.3759      apply(erule_tac x="x - y" in allE) by auto
1.3760    have "\<And>e sg dsa dia ig. norm(sg) \<le> dsa \<longrightarrow> abs(dsa - dia) < e / 2 \<longrightarrow> norm(sg - ig) < e / 2
1.3761 -    \<longrightarrow> norm(ig) < dia + e"
1.3762 +    \<longrightarrow> norm(ig) < dia + e"
1.3763    proof safe case goal1 show ?case apply(rule le_less_trans[OF norm_triangle_sub[of ig sg]])
1.3764 -      apply(subst real_sum_of_halves[of e,THEN sym]) unfolding add_assoc[symmetric]
1.3765 +      apply(subst real_sum_of_halves[of e,symmetric]) unfolding add_assoc[symmetric]
1.3766        apply(rule add_le_less_mono) defer apply(subst norm_minus_commute,rule goal1)
1.3767        apply(rule order_trans[OF goal1(1)]) using goal1(2) by arith
1.3768    qed note norm=this[rule_format]
1.3769 @@ -5440,7 +5729,7 @@
1.3770          apply(rule mult_left_mono) using goal1(3) as by auto
1.3771      qed(insert p[unfolded fine_inter],auto) qed
1.3772
1.3773 -  { presume "\<And>e. 0 < e \<Longrightarrow> norm (integral s f) < integral s g + e"
1.3774 +  { presume "\<And>e. 0 < e \<Longrightarrow> norm (integral s f) < integral s g + e"
1.3775      thus ?thesis apply-apply(rule *[rule_format]) by auto }
1.3776    fix e::real assume "e>0" hence e:"e/2 > 0" by auto
1.3777    note assms(1)[unfolded integrable_alt[of f]] note f=this[THEN conjunct1,rule_format]
1.3778 @@ -5505,7 +5794,7 @@
1.3779    apply(drule absolutely_integrable_norm) unfolding real_norm_def .
1.3780
1.3781  lemma absolutely_integrable_on_subinterval: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach" shows
1.3782 -  "f absolutely_integrable_on s \<Longrightarrow> {a..b} \<subseteq> s \<Longrightarrow> f absolutely_integrable_on {a..b}"
1.3783 +  "f absolutely_integrable_on s \<Longrightarrow> {a..b} \<subseteq> s \<Longrightarrow> f absolutely_integrable_on {a..b}"
1.3784    unfolding absolutely_integrable_on_def by(meson integrable_on_subinterval)
1.3785
1.3786  lemma absolutely_integrable_bounded_variation: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
1.3787 @@ -5520,14 +5809,14 @@
1.3788      apply(subst integral_combine_division_topdown[OF _ goal1(2)])
1.3789      using integrable_on_subdivision[OF goal1(2)] using assms by auto
1.3790    also have "... \<le> integral UNIV (\<lambda>x. norm (f x))"
1.3791 -    apply(rule integral_subset_le)
1.3792 +    apply(rule integral_subset_le)
1.3793      using integrable_on_subdivision[OF goal1(2)] using assms by auto
1.3794    finally show ?case . qed
1.3795
1.3796  lemma helplemma:
1.3797    assumes "setsum (\<lambda>x. norm(f x - g x)) s < e" "finite s"
1.3798    shows "abs(setsum (\<lambda>x. norm(f x)) s - setsum (\<lambda>x. norm(g x)) s) < e"
1.3799 -  unfolding setsum_subtractf[THEN sym] apply(rule le_less_trans[OF setsum_abs])
1.3800 +  unfolding setsum_subtractf[symmetric] apply(rule le_less_trans[OF setsum_abs])
1.3801    apply(rule le_less_trans[OF _ assms(1)]) apply(rule setsum_mono)
1.3802    using norm_triangle_ineq3 .
1.3803
1.3804 @@ -5542,7 +5831,7 @@
1.3805    show ?thesis apply(rule,rule assms) apply rule apply(subst has_integral[of _ i])
1.3806    proof safe case goal1 hence "i - e / 2 \<notin> Collect (isUb UNIV (setsum (\<lambda>k. norm (integral k f)) `
1.3807          {d. d division_of {a..b}}))" using isLub_ubs[OF i,rule_format]
1.3808 -      unfolding setge_def ubs_def by auto
1.3809 +      unfolding setge_def ubs_def by auto
1.3810      hence " \<exists>y. y division_of {a..b} \<and> i - e / 2 < (\<Sum>k\<in>y. norm (integral k f))"
1.3811        unfolding mem_Collect_eq isUb_def setle_def by(simp add:not_le) then guess d .. note d=conjunctD2[OF this]
1.3812      note d' = division_ofD[OF this(1)]
1.3813 @@ -5567,7 +5856,7 @@
1.3814        have gp':"g fine p'" using p(2) unfolding p'_def fine_def by auto
1.3815        have p'':"p' tagged_division_of {a..b}" apply(rule tagged_division_ofI)
1.3816        proof- show "finite p'" apply(rule finite_subset[of _ "(\<lambda>(k,(x,l)). (x,k \<inter> l))
1.3817 -          ` {(k,xl) | k xl. k \<in> d \<and> xl \<in> p}"]) unfolding p'_def
1.3818 +          ` {(k,xl) | k xl. k \<in> d \<and> xl \<in> p}"]) unfolding p'_def
1.3819            defer apply(rule finite_imageI,rule finite_product_dependent[OF d'(1) p'(1)])
1.3820            apply safe unfolding image_iff apply(rule_tac x="(i,x,l)" in bexI) by auto
1.3821          fix x k assume "(x,k)\<in>p'"
1.3822 @@ -5590,15 +5879,15 @@
1.3823          show "\<Union>{k. \<exists>x. (x, k) \<in> p'} = {a..b}" apply rule apply(rule Union_least)
1.3824            unfolding mem_Collect_eq apply(erule exE) apply(drule *[rule_format]) apply safe
1.3825          proof- fix y assume y:"y\<in>{a..b}"
1.3826 -          hence "\<exists>x l. (x, l) \<in> p \<and> y\<in>l" unfolding p'(6)[THEN sym] by auto
1.3827 +          hence "\<exists>x l. (x, l) \<in> p \<and> y\<in>l" unfolding p'(6)[symmetric] by auto
1.3828            then guess x l apply-by(erule exE)+ note xl=conjunctD2[OF this]
1.3829 -          hence "\<exists>k. k\<in>d \<and> y\<in>k" using y unfolding d'(6)[THEN sym] by auto
1.3830 +          hence "\<exists>k. k\<in>d \<and> y\<in>k" using y unfolding d'(6)[symmetric] by auto
1.3831            then guess i .. note i = conjunctD2[OF this]
1.3832            have "x\<in>i" using fineD[OF p(3) xl(1)] using k(2)[OF i(1), of x] using i(2) xl(2) by auto
1.3833            thus "y\<in>\<Union>{k. \<exists>x. (x, k) \<in> p'}" unfolding p'_def Union_iff apply(rule_tac x="i \<inter> l" in bexI)
1.3834              defer unfolding mem_Collect_eq apply(rule_tac x=x in exI)+ apply(rule_tac x="i\<inter>l" in exI)
1.3835 -            apply safe apply(rule_tac x=i in exI) apply(rule_tac x=l in exI) using i xl by auto
1.3836 -        qed qed
1.3837 +            apply safe apply(rule_tac x=i in exI) apply(rule_tac x=l in exI) using i xl by auto
1.3838 +        qed qed
1.3839
1.3840        hence "(\<Sum>(x, k)\<in>p'. norm (content k *\<^sub>R f x - integral k f)) < e / 2"
1.3841          apply-apply(rule g(2)[rule_format]) unfolding tagged_division_of_def apply safe using gp' .
1.3842 @@ -5625,7 +5914,7 @@
1.3843
1.3844        have *:"\<And>sni sni' sf sf'. abs(sf' - sni') < e / 2 \<longrightarrow> i - e / 2 < sni \<and> sni' \<le> i \<and>
1.3845          sni \<le> sni' \<and> sf' = sf \<longrightarrow> abs(sf - i) < e" by arith
1.3846 -      show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R norm (f x)) - i) < e"
1.3847 +      show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R norm (f x)) - i) < e"
1.3848          unfolding real_norm_def apply(rule *[rule_format,OF **],safe) apply(rule d(2))
1.3849        proof- case goal1 show ?case unfolding sum_p'
1.3850            apply(rule isLubD2[OF i]) using division_of_tagged_division[OF p''] by auto
1.3851 @@ -5635,7 +5924,7 @@
1.3852          proof(rule setsum_mono) case goal1 note k=this
1.3853            from d'(4)[OF this] guess u v apply-by(erule exE)+ note uv=this
1.3854            def d' \<equiv> "{{u..v} \<inter> l |l. l \<in> snd ` p \<and>  ~({u..v} \<inter> l = {})}" note uvab = d'(2)[OF k[unfolded uv]]
1.3855 -          have "d' division_of {u..v}" apply(subst d'_def) apply(rule division_inter_1)
1.3856 +          have "d' division_of {u..v}" apply(subst d'_def) apply(rule division_inter_1)
1.3857              apply(rule division_of_tagged_division[OF p(1)]) using uvab .
1.3858            hence "norm (integral k f) \<le> setsum (\<lambda>k. norm (integral k f)) d'"
1.3859              unfolding uv apply(subst integral_combine_division_topdown[of _ _ d'])
1.3860 @@ -5653,18 +5942,18 @@
1.3861                apply(rule Int_greatest) defer apply(subst goal1(4)) by auto
1.3862              hence *:"interior (k \<inter> l) = {}" using snd_p(5)[OF goal1(1-3)] by auto
1.3863              from d'(4)[OF k] snd_p(4)[OF goal1(1)] guess u1 v1 u2 v2 apply-by(erule exE)+ note uv=this
1.3864 -            show ?case using * unfolding uv inter_interval content_eq_0_interior[THEN sym] by auto
1.3865 +            show ?case using * unfolding uv inter_interval content_eq_0_interior[symmetric] by auto
1.3866            qed finally show ?case .
1.3867          qed also have "... = (\<Sum>(i,l)\<in>{(i, l) |i l. i \<in> d \<and> l \<in> snd ` p}. norm (integral (i\<inter>l) f))"
1.3868 -          apply(subst sum_sum_product[THEN sym],fact) using p'(1) by auto
1.3869 +          apply(subst sum_sum_product[symmetric],fact) using p'(1) by auto
1.3870          also have "... = (\<Sum>x\<in>{(i, l) |i l. i \<in> d \<and> l \<in> snd ` p}. norm (integral (split op \<inter> x) f))"
1.3871            unfolding split_def ..
1.3872          also have "... = (\<Sum>k\<in>{i \<inter> l |i l. i \<in> d \<and> l \<in> snd ` p}. norm (integral k f))"
1.3873 -          unfolding * apply(rule setsum_reindex_nonzero[THEN sym,unfolded o_def])
1.3874 +          unfolding * apply(rule setsum_reindex_nonzero[symmetric,unfolded o_def])
1.3875            apply(rule finite_product_dependent) apply(fact,rule finite_imageI,rule p')
1.3876            unfolding split_paired_all mem_Collect_eq split_conv o_def
1.3877          proof- note * = division_ofD(4,5)[OF division_of_tagged_division,OF p(1)]
1.3878 -          fix l1 l2 k1 k2 assume as:"(l1, k1) \<noteq> (l2, k2)"  "l1 \<inter> k1 = l2 \<inter> k2"
1.3879 +          fix l1 l2 k1 k2 assume as:"(l1, k1) \<noteq> (l2, k2)"  "l1 \<inter> k1 = l2 \<inter> k2"
1.3880              "\<exists>i l. (l1, k1) = (i, l) \<and> i \<in> d \<and> l \<in> snd ` p"
1.3881              "\<exists>i l. (l2, k2) = (i, l) \<and> i \<in> d \<and> l \<in> snd ` p"
1.3882            hence "l1 \<in> d" "k1 \<in> snd ` p" by auto from d'(4)[OF this(1)] *(1)[OF this(2)]
1.3883 @@ -5676,7 +5965,7 @@
1.3884            moreover have "interior(l1 \<inter> k1) = interior(l2 \<inter> k2)" using as(2) by auto
1.3885            ultimately have "interior(l1 \<inter> k1) = {}" by auto
1.3886            thus "norm (integral (l1 \<inter> k1) f) = 0" unfolding uv inter_interval
1.3887 -            unfolding content_eq_0_interior[THEN sym] by auto
1.3888 +            unfolding content_eq_0_interior[symmetric] by auto
1.3889          qed also have "... = (\<Sum>(x, k)\<in>p'. norm (integral k f))" unfolding sum_p'
1.3890            apply(rule setsum_mono_zero_right) apply(subst *)
1.3891            apply(rule finite_imageI[OF finite_product_dependent]) apply fact
1.3892 @@ -5684,7 +5973,7 @@
1.3893          proof- case goal2 have "ia \<inter> b = {}" using goal2 unfolding p'alt image_iff Bex_def not_ex
1.3894              apply(erule_tac x="(a,ia\<inter>b)" in allE) by auto thus ?case by auto
1.3895          next case goal1 thus ?case unfolding p'_def apply safe
1.3896 -            apply(rule_tac x=i in exI,rule_tac x=l in exI) unfolding snd_conv image_iff
1.3897 +            apply(rule_tac x=i in exI,rule_tac x=l in exI) unfolding snd_conv image_iff
1.3898              apply safe apply(rule_tac x="(a,l)" in bexI) by auto
1.3899          qed finally show ?case .
1.3900
1.3901 @@ -5705,15 +5994,15 @@
1.3902              "x1 = x2" "l1 \<inter> k1 = l2 \<inter> k2" "\<not> ((x1 = x2 \<and> l1 = l2) \<and> k1 = k2)"
1.3903            from d'(4)[OF as(3)] p'(4)[OF as(1)] guess u1 v1 u2 v2 apply-by(erule exE)+ note uv=this
1.3904            from as have "l1 \<noteq> l2 \<or> k1 \<noteq> k2" by auto
1.3905 -          hence "(interior(k1) \<inter> interior(k2) = {} \<or> interior(l1) \<inter> interior(l2) = {})"
1.3906 +          hence "(interior(k1) \<inter> interior(k2) = {} \<or> interior(l1) \<inter> interior(l2) = {})"
1.3907              apply-apply(erule disjE) apply(rule disjI2) defer apply(rule disjI1)
1.3908              apply(rule d'(5)[OF as(3-4)],assumption) apply(rule p'(5)[OF as(1-2)]) by auto
1.3909            moreover have "interior(l1 \<inter> k1) = interior(l2 \<inter> k2)" unfolding  as ..
1.3910            ultimately have "interior (l1 \<inter> k1) = {}" by auto
1.3911            thus "\<bar>content (l1 \<inter> k1)\<bar> * norm (f x1) = 0" unfolding uv inter_interval
1.3912 -            unfolding content_eq_0_interior[THEN sym] by auto
1.3913 +            unfolding content_eq_0_interior[symmetric] by auto
1.3914          qed safe also have "... = (\<Sum>(x, k)\<in>p. content k *\<^sub>R norm (f x))" unfolding Sigma_alt
1.3915 -          apply(subst sum_sum_product[THEN sym]) apply(rule p', rule,rule d')
1.3916 +          apply(subst sum_sum_product[symmetric]) apply(rule p', rule,rule d')
1.3917            apply(rule setsum_cong2) unfolding split_paired_all split_conv
1.3918          proof- fix x l assume as:"(x,l)\<in>p"
1.3919            note xl = p'(2-4)[OF this] from this(3) guess u v apply-by(erule exE)+ note uv=this
1.3920 @@ -5721,7 +6010,7 @@
1.3921              apply(rule setsum_cong2) apply(drule d'(4),safe) apply(subst Int_commute)
1.3922              unfolding inter_interval uv apply(subst abs_of_nonneg) by auto
1.3923            also have "... = setsum content {k\<inter>{u..v}| k. k\<in>d}" unfolding simple_image
1.3924 -            apply(rule setsum_reindex_nonzero[unfolded o_def,THEN sym]) apply(rule d')
1.3925 +            apply(rule setsum_reindex_nonzero[unfolded o_def,symmetric]) apply(rule d')
1.3926            proof- case goal1 from d'(4)[OF this(1)] d'(4)[OF this(2)]
1.3927              guess u1 v1 u2 v2 apply- by(erule exE)+ note uv=this
1.3928              have "{} = interior ((k \<inter> y) \<inter> {u..v})" apply(subst interior_inter)
1.3929 @@ -5738,11 +6027,11 @@
1.3930                unfolding ab inter_interval content_eq_0_interior by auto
1.3931              thus ?case using goal1(1) using interior_subset[of "k \<inter> {u..v}"] by auto
1.3932            qed finally show "(\<Sum>i\<in>d. \<bar>content (l \<inter> i)\<bar> * norm (f x)) = content l *\<^sub>R norm (f x)"
1.3933 -            unfolding setsum_left_distrib[THEN sym] real_scaleR_def apply -
1.3934 +            unfolding setsum_left_distrib[symmetric] real_scaleR_def apply -
1.3936              using xl(2)[unfolded uv] unfolding uv by auto
1.3937 -        qed finally show ?case .
1.3938 -      qed qed qed qed
1.3939 +        qed finally show ?case .
1.3940 +      qed qed qed qed
1.3941
1.3942  lemma bounded_variation_absolutely_integrable:  fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
1.3943    assumes "f integrable_on UNIV" "\<forall>d. d division_of (\<Union>d) \<longrightarrow> setsum (\<lambda>k. norm(integral k f)) d \<le> B"
1.3944 @@ -5755,7 +6044,7 @@
1.3945    have f_int:"\<And>a b. f absolutely_integrable_on {a..b}"
1.3946      apply(rule bounded_variation_absolutely_integrable_interval[where B=B])
1.3947      apply(rule integrable_on_subinterval[OF assms(1)]) defer apply safe
1.3948 -    apply(rule assms(2)[rule_format]) by auto
1.3949 +    apply(rule assms(2)[rule_format]) by auto
1.3950    show "((\<lambda>x. norm (f x)) has_integral i) UNIV" apply(subst has_integral_alt',safe)
1.3951    proof- case goal1 show ?case using f_int[of a b] by auto
1.3952    next case goal2 have "\<exists>y\<in>setsum (\<lambda>k. norm (integral k f)) ` {d. d division_of \<Union>d}. \<not> y \<le> i - e"
1.3953 @@ -5775,11 +6064,11 @@
1.3954        proof- case goal1 have "(\<Sum>k\<in>d. norm (integral k f)) \<le> setsum (\<lambda>k. integral k (\<lambda>x. norm (f x))) d"
1.3955            apply(rule setsum_mono) apply(rule absolutely_integrable_le)
1.3956            apply(drule d'(4),safe) by(rule f_int)
1.3957 -        also have "... = integral (\<Union>d) (\<lambda>x. norm(f x))"
1.3958 -          apply(rule integral_combine_division_bottomup[THEN sym])
1.3959 +        also have "... = integral (\<Union>d) (\<lambda>x. norm(f x))"
1.3960 +          apply(rule integral_combine_division_bottomup[symmetric])
1.3961            apply(rule d) unfolding forall_in_division[OF d(1)] using f_int by auto
1.3962 -        also have "... \<le> integral {a..b} (\<lambda>x. if x \<in> UNIV then norm (f x) else 0)"
1.3963 -        proof- case goal1 have "\<Union>d \<subseteq> {a..b}" apply rule apply(drule K(2)[rule_format])
1.3964 +        also have "... \<le> integral {a..b} (\<lambda>x. if x \<in> UNIV then norm (f x) else 0)"
1.3965 +        proof- case goal1 have "\<Union>d \<subseteq> {a..b}" apply rule apply(drule K(2)[rule_format])
1.3966              apply(rule ab[unfolded subset_eq,rule_format]) by(auto simp add:dist_norm)
1.3967            thus ?case apply- apply(subst if_P,rule) apply(rule integral_subset_le) defer
1.3968              apply(rule integrable_on_subdivision[of _ _ _ "{a..b}"])
1.3969 @@ -5795,7 +6084,7 @@
1.3970          have *:"\<And>sf sf' si di. sf' = sf \<longrightarrow> si \<le> i \<longrightarrow> abs(sf - si) < e / 2
1.3971            \<longrightarrow> abs(sf' - di) < e / 2 \<longrightarrow> di < i + e" by arith
1.3972          show "integral {a..b} (\<lambda>x. if x \<in> UNIV then norm (f x) else 0) < i + e" apply(subst if_P,rule)
1.3973 -        proof(rule *[rule_format])
1.3974 +        proof(rule *[rule_format])
1.3975            show "\<bar>(\<Sum>(x,k)\<in>p. norm (content k *\<^sub>R f x)) - (\<Sum>(x,k)\<in>p. norm (integral k f))\<bar> < e / 2"
1.3976              unfolding split_def apply(rule helplemma) using d2(2)[rule_format,of p]
1.3977              using p(1,3) unfolding tagged_division_of_def split_def by auto
1.3978 @@ -5810,7 +6099,7 @@
1.3979              unfolding image_iff apply(rule_tac x="snd ` p" in bexI) unfolding mem_Collect_eq defer
1.3980              apply(rule partial_division_of_tagged_division[of _ "{a..b}"])
1.3981              using p(1) unfolding tagged_division_of_def by auto
1.3982 -        qed qed qed(insert K,auto) qed qed
1.3983 +        qed qed qed(insert K,auto) qed qed
1.3984
1.3985  lemma absolutely_integrable_restrict_univ:
1.3986   "(\<lambda>x. if x \<in> s then f x else (0::'a::banach)) absolutely_integrable_on UNIV \<longleftrightarrow> f absolutely_integrable_on s"
1.3987 @@ -5821,12 +6110,12 @@
1.3988    shows "(\<lambda>x. f(x) + g(x)) absolutely_integrable_on s"
1.3989  proof- let ?P = "\<And>f g::'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space. f absolutely_integrable_on UNIV \<Longrightarrow>
1.3990      g absolutely_integrable_on UNIV \<Longrightarrow> (\<lambda>x. f(x) + g(x)) absolutely_integrable_on UNIV"
1.3991 -  { presume as:"PROP ?P" note a = absolutely_integrable_restrict_univ[THEN sym]
1.3992 +  { presume as:"PROP ?P" note a = absolutely_integrable_restrict_univ[symmetric]
1.3993      have *:"\<And>x. (if x \<in> s then f x else 0) + (if x \<in> s then g x else 0)
1.3994        = (if x \<in> s then f x + g x else 0)" by auto
1.3995      show ?thesis apply(subst a) using as[OF assms[unfolded a[of f] a[of g]]] unfolding * . }
1.3996    fix f g::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space" assume assms:"f absolutely_integrable_on UNIV"
1.3997 -    "g absolutely_integrable_on UNIV"
1.3998 +    "g absolutely_integrable_on UNIV"
1.3999    note absolutely_integrable_bounded_variation
1.4000    from this[OF assms(1)] this[OF assms(2)] guess B1 B2 . note B=this[rule_format]
1.4001    show "(\<lambda>x. f(x) + g(x)) absolutely_integrable_on UNIV"
1.4002 @@ -5837,7 +6126,7 @@
1.4003        apply(rule_tac[!] integrable_on_subinterval[of _ UNIV]) using assms by auto
1.4004      hence "(\<Sum>k\<in>d. norm (integral k (\<lambda>x. f x + g x))) \<le>
1.4005        (\<Sum>k\<in>d. norm (integral k f)) + (\<Sum>k\<in>d. norm (integral k g))" apply-
1.4006 -      unfolding setsum_addf[THEN sym] apply(rule setsum_mono)
1.4007 +      unfolding setsum_addf[symmetric] apply(rule setsum_mono)
1.4008        apply(subst integral_add) prefer 3 apply(rule norm_triangle_ineq) by auto
1.4009      also have "... \<le> B1 + B2" using B(1)[OF goal1] B(2)[OF goal1] by auto
1.4010      finally show ?case .
1.4011 @@ -5852,18 +6141,18 @@
1.4012  lemma absolutely_integrable_linear: fixes f::"'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space" and h::"'n::ordered_euclidean_space \<Rightarrow> 'p::ordered_euclidean_space"
1.4013    assumes "f absolutely_integrable_on s" "bounded_linear h"
1.4014    shows "(h o f) absolutely_integrable_on s"
1.4015 -proof- { presume as:"\<And>f::'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space. \<And>h::'n::ordered_euclidean_space \<Rightarrow> 'p::ordered_euclidean_space.
1.4016 +proof- { presume as:"\<And>f::'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space. \<And>h::'n::ordered_euclidean_space \<Rightarrow> 'p::ordered_euclidean_space.
1.4017      f absolutely_integrable_on UNIV \<Longrightarrow> bounded_linear h \<Longrightarrow>
1.4018 -    (h o f) absolutely_integrable_on UNIV" note a = absolutely_integrable_restrict_univ[THEN sym]
1.4019 +    (h o f) absolutely_integrable_on UNIV" note a = absolutely_integrable_restrict_univ[symmetric]
1.4020      show ?thesis apply(subst a) using as[OF assms[unfolded a[of f] a[of g]]]
1.4021        unfolding o_def if_distrib linear_simps[OF assms(2)] . }
1.4022    fix f::"'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space" and h::"'n::ordered_euclidean_space \<Rightarrow> 'p::ordered_euclidean_space"
1.4023 -  assume assms:"f absolutely_integrable_on UNIV" "bounded_linear h"
1.4024 +  assume assms:"f absolutely_integrable_on UNIV" "bounded_linear h"
1.4025    from absolutely_integrable_bounded_variation[OF assms(1)] guess B . note B=this
1.4026    from bounded_linear.pos_bounded[OF assms(2)] guess b .. note b=conjunctD2[OF this]
1.4027    show "(h o f) absolutely_integrable_on UNIV"
1.4028      apply(rule bounded_variation_absolutely_integrable[of _ "B * b"])
1.4029 -    apply(rule integrable_linear[OF _ assms(2)])
1.4030 +    apply(rule integrable_linear[OF _ assms(2)])
1.4031    proof safe case goal2
1.4032      have "(\<Sum>k\<in>d. norm (integral k (h \<circ> f))) \<le> setsum (\<lambda>k. norm(integral k f)) d * b"
1.4033        unfolding setsum_left_distrib apply(rule setsum_mono)
1.4034 @@ -5953,14 +6242,14 @@
1.4035  proof
1.4036    assume ?l thus ?r apply-apply rule defer
1.4037      apply(drule absolutely_integrable_vector_abs) by auto
1.4038 -next
1.4039 +next
1.4040    assume ?r
1.4041    { presume lem:"\<And>f::'n \<Rightarrow> 'm. f integrable_on UNIV \<Longrightarrow>
1.4042        (\<lambda>x. (\<Sum>i\<in>Basis. \<bar>f x\<bullet>i\<bar> *\<^sub>R i)::'m) integrable_on UNIV \<Longrightarrow> f absolutely_integrable_on UNIV"
1.4043      have *:"\<And>x. (\<Sum>i\<in>Basis. \<bar>(if x \<in> s then f x else 0) \<bullet> i\<bar> *\<^sub>R i) =
1.4044          (if x\<in>s then (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i\<bar> *\<^sub>R i) else (0::'m))"
1.4045        unfolding euclidean_eq_iff[where 'a='m] by auto
1.4046 -    show ?l apply(subst absolutely_integrable_restrict_univ[THEN sym]) apply(rule lem)
1.4047 +    show ?l apply(subst absolutely_integrable_restrict_univ[symmetric]) apply(rule lem)
1.4048        unfolding integrable_restrict_univ * using `?r` by auto }
1.4049    fix f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
1.4050    assume assms:"f integrable_on UNIV" "(\<lambda>x. (\<Sum>i\<in>Basis. \<bar>f x\<bullet>i\<bar> *\<^sub>R i)::'m) integrable_on UNIV"
1.4051 @@ -5976,7 +6265,7 @@
1.4052        from d'(4)[OF this(1)] guess a b apply-by(erule exE)+ note ab=this
1.4053        show "\<bar>integral k f \<bullet> i\<bar> \<le> integral k (\<lambda>x. (\<Sum>i\<in>Basis. \<bar>f x\<bullet>i\<bar> *\<^sub>R i)::'m) \<bullet> i"
1.4054          apply (rule abs_leI)
1.4055 -        unfolding inner_minus_left[THEN sym] defer apply(subst integral_neg[THEN sym])
1.4056 +        unfolding inner_minus_left[symmetric] defer apply(subst integral_neg[symmetric])
1.4057          defer apply(rule_tac[1-2] integral_component_le[OF i]) apply(rule integrable_neg)
1.4058          using integrable_on_subinterval[OF assms(1),of a b]
1.4059            integrable_on_subinterval[OF assms(2),of a b] i unfolding ab by auto
1.4060 @@ -6009,7 +6298,7 @@
1.4061    shows "f absolutely_integrable_on s"
1.4062  proof- { presume *:"\<And>f::'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space. \<And> g. \<forall>x. norm(f x) \<le> g x \<Longrightarrow> f integrable_on UNIV
1.4063      \<Longrightarrow> g integrable_on UNIV \<Longrightarrow> f absolutely_integrable_on UNIV"
1.4064 -    show ?thesis apply(subst absolutely_integrable_restrict_univ[THEN sym])
1.4065 +    show ?thesis apply(subst absolutely_integrable_restrict_univ[symmetric])
1.4066        apply(rule *[of _ "\<lambda>x. if x\<in>s then g x else 0"])
1.4067        using assms unfolding integrable_restrict_univ by auto }
1.4068    fix g and f :: "'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
1.4069 @@ -6018,9 +6307,9 @@
1.4070      apply(rule bounded_variation_absolutely_integrable[OF assms(2),where B="integral UNIV g"])
1.4071    proof safe case goal1 note d=this and d'=division_ofD[OF this]
1.4072      have "(\<Sum>k\<in>d. norm (integral k f)) \<le> (\<Sum>k\<in>d. integral k g)"
1.4073 -      apply(rule setsum_mono) apply(rule integral_norm_bound_integral) apply(drule_tac[!] d'(4),safe)
1.4074 +      apply(rule setsum_mono) apply(rule integral_norm_bound_integral) apply(drule_tac[!] d'(4),safe)
1.4075        apply(rule_tac[1-2] integrable_on_subinterval) using assms by auto
1.4076 -    also have "... = integral (\<Union>d) g" apply(rule integral_combine_division_bottomup[THEN sym])
1.4077 +    also have "... = integral (\<Union>d) g" apply(rule integral_combine_division_bottomup[symmetric])
1.4078        apply(rule d,safe) apply(drule d'(4),safe)
1.4079        apply(rule integrable_on_subinterval[OF assms(3)]) by auto
1.4080      also have "... \<le> integral UNIV g" apply(rule integral_subset_le) defer
1.4081 @@ -6161,7 +6450,7 @@
1.4082        qed
1.4083        then guess y .. note y=this[unfolded not_le]
1.4084        from this(1)[unfolded mem_Collect_eq] guess N .. note N=conjunctD2[OF this]
1.4085 -
1.4086 +
1.4087        show ?case
1.4088          apply (rule_tac x=N in exI)
1.4089        proof safe
1.4090 @@ -6247,7 +6536,7 @@
1.4091          case goal1
1.4092          thus ?case using assms(3)[rule_format,OF x, of j] by auto
1.4093        qed auto
1.4094 -
1.4095 +
1.4096        have "\<exists>y\<in>?S. \<not> y \<le> i - r"
1.4097        proof (rule ccontr)
1.4098          case goal1
1.4099 @@ -6262,7 +6551,7 @@
1.4100        qed
1.4101        then guess y .. note y=this[unfolded not_le]
1.4102        from this(1)[unfolded mem_Collect_eq] guess N .. note N=conjunctD2[OF this]
1.4103 -
1.4104 +
1.4105        show ?case
1.4106          apply (rule_tac x=N in exI)
1.4107        proof safe
1.4108 @@ -6291,7 +6580,7 @@
1.4109    have "g integrable_on s \<and>
1.4110      ((\<lambda>k. integral s (\<lambda>x. Inf {f j x |j. k \<le> j})) ---> integral s g) sequentially"
1.4111      apply (rule monotone_convergence_increasing,safe)
1.4112 -    apply fact
1.4113 +    apply fact
1.4114    proof -
1.4115      show "bounded {integral s (\<lambda>x. Inf {f j x |j. k \<le> j}) |k. True}"
1.4116        unfolding bounded_iff apply(rule_tac x="integral s h" in exI)
1.4117 @@ -6418,7 +6707,7 @@
1.4118          show "integral s (\<lambda>x. Inf {f j x |j. n \<le> j}) \<le> integral s (f n)"
1.4119          proof (rule integral_le[OF dec1(1) assms(1)], safe)
1.4120            fix x
1.4121 -          assume x: "x \<in> s"
1.4122 +          assume x: "x \<in> s"
1.4123            have *: "\<And>x y::real. x \<ge> - y \<Longrightarrow> - x \<le> y" by auto
1.4124            show "Inf {f j x |j. n \<le> j} \<le> f n x"
1.4125              apply (rule cInf_lower[where z="- h x"])
```