author hoelzl Fri Dec 14 15:46:01 2012 +0100 (2012-12-14) changeset 50526 899c9c4e4a4c parent 50525 46be26e02456 child 50527 2f9b5b0e388d child 50534 75e02cd16533
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
```     1.1 --- a/NEWS	Fri Dec 14 14:46:01 2012 +0100
1.2 +++ b/NEWS	Fri Dec 14 15:46:01 2012 +0100
1.3 @@ -227,6 +227,36 @@
1.4  * HOL/Cardinals: Theories of ordinals and cardinals
1.5  (supersedes the AFP entry "Ordinals_and_Cardinals").
1.6
1.7 +* HOL/Multivariate_Analysis:
1.8 +  Replaced "basis :: 'a::euclidean_space => nat => real" and
1.9 +  "\<Chi>\<Chi> :: (nat => real) => 'a::euclidean_space" on euclidean spaces by
1.10 +  using the inner product "_ \<bullet> _" with vectors from the Basis set.
1.11 +  "\<Chi>\<Chi> i. f i" is replaced by "SUM i : Basis. f i *r i".
1.12 +
1.13 +  With this change the following constants are also chanegd or removed:
1.14 +
1.15 +    DIM('a) :: nat   ~>   card (Basis :: 'a set)   (is an abbreviation)
1.16 +    a \$\$ i    ~>    inner a i  (where i : Basis)
1.17 +    cart_base i     removed
1.18 +    \<pi>, \<pi>'   removed
1.19 +
1.20 +  Theorems about these constants where removed.
1.21 +
1.22 +  Renamed lemmas:
1.23 +
1.24 +    component_le_norm   ~>   Basis_le_norm
1.25 +    euclidean_eq   ~>   euclidean_eq_iff
1.26 +    differential_zero_maxmin_component   ~>   differential_zero_maxmin_cart
1.27 +    euclidean_simps   ~>   inner_simps
1.28 +    independent_basis   ~>   independent_Basis
1.29 +    span_basis   ~>   span_Basis
1.30 +    in_span_basis   ~>   in_span_Basis
1.31 +    norm_bound_component_le   ~>   norm_boound_Basis_le
1.32 +    norm_bound_component_lt   ~>   norm_boound_Basis_lt
1.33 +    component_le_infnorm   ~>   Basis_le_infnorm
1.34 +
1.35 +  INCOMPATIBILITY.
1.36 +
1.37  * HOL/Probability:
1.38    - Add simproc "measurable" to automatically prove measurability
1.39
```
```     2.1 --- a/src/HOL/Multivariate_Analysis/Brouwer_Fixpoint.thy	Fri Dec 14 14:46:01 2012 +0100
2.2 +++ b/src/HOL/Multivariate_Analysis/Brouwer_Fixpoint.thy	Fri Dec 14 15:46:01 2012 +0100
2.3 @@ -22,6 +22,18 @@
2.4    imports Convex_Euclidean_Space
2.5  begin
2.6
2.7 +(** move this **)
2.8 +lemma divide_nonneg_nonneg:assumes "a \<ge> 0" "b \<ge> 0" shows "0 \<le> a / (b::real)"
2.9 +  apply(cases "b=0") defer apply(rule divide_nonneg_pos) using assms by auto
2.10 +
2.11 +lemma continuous_setsum:
2.12 +  fixes f :: "'i \<Rightarrow> 'a::t2_space \<Rightarrow> 'b::real_normed_vector"
2.13 +  assumes f: "\<And>i. i \<in> I \<Longrightarrow> continuous F (f i)" shows "continuous F (\<lambda>x. \<Sum>i\<in>I. f i x)"
2.14 +proof cases
2.15 +  assume "finite I" from this f show ?thesis
2.16 +    by (induct I) (auto intro!: continuous_intros)
2.17 +qed (auto intro!: continuous_intros)
2.18 +
2.19  lemma brouwer_compactness_lemma:
2.20    assumes "compact s" "continuous_on s f" "\<not> (\<exists>x\<in>s. (f x = (0::_::euclidean_space)))"
2.21    obtains d where "0 < d" "\<forall>x\<in>s. d \<le> norm(f x)"
2.22 @@ -39,39 +51,39 @@
2.23  qed
2.24
2.25  lemma kuhn_labelling_lemma:
2.26 -  fixes type::"'a::euclidean_space"
2.27 -  assumes "(\<forall>x::'a. P x \<longrightarrow> P (f x))"
2.28 -    and "\<forall>x. P x \<longrightarrow> (\<forall>i<DIM('a). Q i \<longrightarrow> 0 \<le> x\$\$i \<and> x\$\$i \<le> 1)"
2.29 -  shows "\<exists>l. (\<forall>x.\<forall> i<DIM('a). l x i \<le> (1::nat)) \<and>
2.30 -             (\<forall>x.\<forall> i<DIM('a). P x \<and> Q i \<and> (x\$\$i = 0) \<longrightarrow> (l x i = 0)) \<and>
2.31 -             (\<forall>x.\<forall> i<DIM('a). P x \<and> Q i \<and> (x\$\$i = 1) \<longrightarrow> (l x i = 1)) \<and>
2.32 -             (\<forall>x.\<forall> i<DIM('a). P x \<and> Q i \<and> (l x i = 0) \<longrightarrow> x\$\$i \<le> f(x)\$\$i) \<and>
2.33 -             (\<forall>x.\<forall> i<DIM('a). P x \<and> Q i \<and> (l x i = 1) \<longrightarrow> f(x)\$\$i \<le> x\$\$i)"
2.34 +  fixes P Q :: "'a::euclidean_space \<Rightarrow> bool"
2.35 +  assumes "(\<forall>x. P x \<longrightarrow> P (f x))"
2.36 +    and "\<forall>x. P x \<longrightarrow> (\<forall>i\<in>Basis. Q i \<longrightarrow> 0 \<le> x\<bullet>i \<and> x\<bullet>i \<le> 1)"
2.37 +  shows "\<exists>l. (\<forall>x.\<forall>i\<in>Basis. l x i \<le> (1::nat)) \<and>
2.38 +             (\<forall>x.\<forall>i\<in>Basis. P x \<and> Q i \<and> (x\<bullet>i = 0) \<longrightarrow> (l x i = 0)) \<and>
2.39 +             (\<forall>x.\<forall>i\<in>Basis. P x \<and> Q i \<and> (x\<bullet>i = 1) \<longrightarrow> (l x i = 1)) \<and>
2.40 +             (\<forall>x.\<forall>i\<in>Basis. P x \<and> Q i \<and> (l x i = 0) \<longrightarrow> x\<bullet>i \<le> f(x)\<bullet>i) \<and>
2.41 +             (\<forall>x.\<forall>i\<in>Basis. P x \<and> Q i \<and> (l x i = 1) \<longrightarrow> f(x)\<bullet>i \<le> x\<bullet>i)"
2.42  proof -
2.43    have and_forall_thm:"\<And>P Q. (\<forall>x. P x) \<and> (\<forall>x. Q x) \<longleftrightarrow> (\<forall>x. P x \<and> Q x)"
2.44      by auto
2.45    have *: "\<forall>x y::real. 0 \<le> x \<and> x \<le> 1 \<and> 0 \<le> y \<and> y \<le> 1 \<longrightarrow> (x \<noteq> 1 \<and> x \<le> y \<or> x \<noteq> 0 \<and> y \<le> x)"
2.46      by auto
2.47    show ?thesis
2.48 -    unfolding and_forall_thm
2.49 +    unfolding and_forall_thm Ball_def
2.50      apply(subst choice_iff[THEN sym])+
2.51      apply rule
2.52      apply rule
2.53    proof -
2.54 -    case goal1
2.55 -    let ?R = "\<lambda>y. (P x \<and> Q xa \<and> x \$\$ xa = 0 \<longrightarrow> y = (0::nat)) \<and>
2.56 -        (P x \<and> Q xa \<and> x \$\$ xa = 1 \<longrightarrow> y = 1) \<and>
2.57 -        (P x \<and> Q xa \<and> y = 0 \<longrightarrow> x \$\$ xa \<le> f x \$\$ xa) \<and>
2.58 -        (P x \<and> Q xa \<and> y = 1 \<longrightarrow> f x \$\$ xa \<le> x \$\$ xa)"
2.59 +    case (goal1 x)
2.60 +    let ?R = "\<lambda>y. (P x \<and> Q xa \<and> x \<bullet> xa = 0 \<longrightarrow> y = (0::nat)) \<and>
2.61 +        (P x \<and> Q xa \<and> x \<bullet> xa = 1 \<longrightarrow> y = 1) \<and>
2.62 +        (P x \<and> Q xa \<and> y = 0 \<longrightarrow> x \<bullet> xa \<le> f x \<bullet> xa) \<and>
2.63 +        (P x \<and> Q xa \<and> y = 1 \<longrightarrow> f x \<bullet> xa \<le> x \<bullet> xa)"
2.64      {
2.65 -      assume "P x" "Q xa" "xa<DIM('a)"
2.66 -      then have "0 \<le> f x \$\$ xa \<and> f x \$\$ xa \<le> 1"
2.67 +      assume "P x" "Q xa" "xa\<in>Basis"
2.68 +      then have "0 \<le> f x \<bullet> xa \<and> f x \<bullet> xa \<le> 1"
2.69          using assms(2)[rule_format,of "f x" xa]
2.70          apply (drule_tac assms(1)[rule_format])
2.71          apply auto
2.72          done
2.73      }
2.74 -    then have "xa<DIM('a) \<Longrightarrow> ?R 0 \<or> ?R 1" by auto
2.75 +    then have "xa\<in>Basis \<Longrightarrow> ?R 0 \<or> ?R 1" by auto
2.76      then show ?case by auto
2.77    qed
2.78  qed
2.79 @@ -1363,50 +1375,56 @@
2.80          apply(drule_tac assms(1)[rule_format]) by auto }
2.81      hence "?R 0 \<or> ?R 1" by auto thus ?case by auto qed qed
2.82
2.83 -lemma brouwer_cube: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'a::ordered_euclidean_space"
2.84 -  assumes "continuous_on {0..\<chi>\<chi> i. 1} f" "f ` {0..\<chi>\<chi> i. 1} \<subseteq> {0..\<chi>\<chi> i. 1}"
2.85 -  shows "\<exists>x\<in>{0..\<chi>\<chi> i. 1}. f x = x" apply(rule ccontr) proof-
2.86 -  def n \<equiv> "DIM('a)" have n:"1 \<le> n" "0 < n" "n \<noteq> 0" unfolding n_def by(auto simp add:Suc_le_eq)
2.87 -  assume "\<not> (\<exists>x\<in>{0..\<chi>\<chi> i. 1}. f x = x)" hence *:"\<not> (\<exists>x\<in>{0..\<chi>\<chi> i. 1}. f x - x = 0)" by auto
2.88 +lemma brouwer_cube:
2.89 +  fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'a::ordered_euclidean_space"
2.90 +  assumes "continuous_on {0..(\<Sum>Basis)} f" "f ` {0..(\<Sum>Basis)} \<subseteq> {0..(\<Sum>Basis)}"
2.91 +  shows "\<exists>x\<in>{0..(\<Sum>Basis)}. f x = x"
2.92 +  proof (rule ccontr)
2.93 +  def n \<equiv> "DIM('a)" have n:"1 \<le> n" "0 < n" "n \<noteq> 0" unfolding n_def by(auto simp add: Suc_le_eq DIM_positive)
2.94 +  assume "\<not> (\<exists>x\<in>{0..\<Sum>Basis}. f x = x)" hence *:"\<not> (\<exists>x\<in>{0..\<Sum>Basis}. f x - x = 0)" by auto
2.95    guess d apply(rule brouwer_compactness_lemma[OF compact_interval _ *])
2.96      apply(rule continuous_on_intros assms)+ . note d=this[rule_format]
2.97 -  have *:"\<forall>x. x \<in> {0..\<chi>\<chi> i. 1} \<longrightarrow> f x \<in> {0..\<chi>\<chi> i. 1}"  "\<forall>x. x \<in> {0..(\<chi>\<chi> i. 1)::'a} \<longrightarrow>
2.98 -    (\<forall>i<DIM('a). True \<longrightarrow> 0 \<le> x \$\$ i \<and> x \$\$ i \<le> 1)"
2.99 +  have *:"\<forall>x. x \<in> {0..\<Sum>Basis} \<longrightarrow> f x \<in> {0..\<Sum>Basis}"  "\<forall>x. x \<in> {0..(\<Sum>Basis)::'a} \<longrightarrow>
2.100 +    (\<forall>i\<in>Basis. True \<longrightarrow> 0 \<le> x \<bullet> i \<and> x \<bullet> i \<le> 1)"
2.101      using assms(2)[unfolded image_subset_iff Ball_def] unfolding mem_interval by auto
2.102    guess label using kuhn_labelling_lemma[OF *] apply-apply(erule exE,(erule conjE)+) . note label = this[rule_format]
2.103 -  have lem1:"\<forall>x\<in>{0..\<chi>\<chi> i. 1}.\<forall>y\<in>{0..\<chi>\<chi> i. 1}.\<forall>i<DIM('a). label x i \<noteq> label y i
2.104 -            \<longrightarrow> abs(f x \$\$ i - x \$\$ i) \<le> norm(f y - f x) + norm(y - x)" proof safe
2.105 -    fix x y::'a assume xy:"x\<in>{0..\<chi>\<chi> i. 1}" "y\<in>{0..\<chi>\<chi> i. 1}" fix i assume i:"label x i \<noteq> label y i" "i<DIM('a)"
2.106 +  have lem1:"\<forall>x\<in>{0..\<Sum>Basis}.\<forall>y\<in>{0..\<Sum>Basis}.\<forall>i\<in>Basis. label x i \<noteq> label y i
2.107 +            \<longrightarrow> abs(f x \<bullet> i - x \<bullet> i) \<le> norm(f y - f x) + norm(y - x)" proof safe
2.108 +    fix x y::'a assume xy:"x\<in>{0..\<Sum>Basis}" "y\<in>{0..\<Sum>Basis}"
2.109 +    fix i assume i:"label x i \<noteq> label y i" "i\<in>Basis"
2.110      have *:"\<And>x y fx fy::real. (x \<le> fx \<and> fy \<le> y \<or> fx \<le> x \<and> y \<le> fy)
2.111               \<Longrightarrow> abs(fx - x) \<le> abs(fy - fx) + abs(y - x)" by auto
2.112 -    have "\<bar>(f x - x) \$\$ i\<bar> \<le> abs((f y - f x)\$\$i) + abs((y - x)\$\$i)" unfolding euclidean_simps
2.113 +    have "\<bar>(f x - x) \<bullet> i\<bar> \<le> abs((f y - f x)\<bullet>i) + abs((y - x)\<bullet>i)"
2.114 +      unfolding inner_simps
2.115        apply(rule *) apply(cases "label x i = 0") apply(rule disjI1,rule) prefer 3 proof(rule disjI2,rule)
2.116        assume lx:"label x i = 0" hence ly:"label y i = 1" using i label(1)[of i y] by auto
2.117 -      show "x \$\$ i \<le> f x \$\$ i" apply(rule label(4)[rule_format]) using xy lx i(2) by auto
2.118 -      show "f y \$\$ i \<le> y \$\$ i" apply(rule label(5)[rule_format]) using xy ly i(2) by auto next
2.119 +      show "x \<bullet> i \<le> f x \<bullet> i" apply(rule label(4)[rule_format]) using xy lx i(2) by auto
2.120 +      show "f y \<bullet> i \<le> y \<bullet> i" apply(rule label(5)[rule_format]) using xy ly i(2) by auto next
2.121        assume "label x i \<noteq> 0" hence l:"label x i = 1" "label y i = 0"
2.122          using i label(1)[of i x] label(1)[of i y] by auto
2.123 -      show "f x \$\$ i \<le> x \$\$ i" apply(rule label(5)[rule_format]) using xy l i(2) by auto
2.124 -      show "y \$\$ i \<le> f y \$\$ i" apply(rule label(4)[rule_format]) using xy l i(2) by auto qed
2.125 -    also have "\<dots> \<le> norm (f y - f x) + norm (y - x)" apply(rule add_mono) by(rule component_le_norm)+
2.126 -    finally show "\<bar>f x \$\$ i - x \$\$ i\<bar> \<le> norm (f y - f x) + norm (y - x)" unfolding euclidean_simps . qed
2.127 -  have "\<exists>e>0. \<forall>x\<in>{0..\<chi>\<chi> i. 1}. \<forall>y\<in>{0..\<chi>\<chi> i. 1}. \<forall>z\<in>{0..\<chi>\<chi> i. 1}. \<forall>i<DIM('a).
2.128 -    norm(x - z) < e \<and> norm(y - z) < e \<and> label x i \<noteq> label y i \<longrightarrow> abs((f(z) - z)\$\$i) < d / (real n)" proof-
2.129 -    have d':"d / real n / 8 > 0" apply(rule divide_pos_pos)+ using d(1) unfolding n_def by auto
2.130 -    have *:"uniformly_continuous_on {0..\<chi>\<chi> i. 1} f" by(rule compact_uniformly_continuous[OF assms(1) compact_interval])
2.131 +      show "f x \<bullet> i \<le> x \<bullet> i" apply(rule label(5)[rule_format]) using xy l i(2) by auto
2.132 +      show "y \<bullet> i \<le> f y \<bullet> i" apply(rule label(4)[rule_format]) using xy l i(2) by auto qed
2.133 +    also have "\<dots> \<le> norm (f y - f x) + norm (y - x)" apply(rule add_mono) by(rule Basis_le_norm[OF i(2)])+
2.134 +    finally show "\<bar>f x \<bullet> i - x \<bullet> i\<bar> \<le> norm (f y - f x) + norm (y - x)" unfolding inner_simps .
2.135 +  qed
2.136 +  have "\<exists>e>0. \<forall>x\<in>{0..\<Sum>Basis}. \<forall>y\<in>{0..\<Sum>Basis}. \<forall>z\<in>{0..\<Sum>Basis}. \<forall>i\<in>Basis.
2.137 +    norm(x - z) < e \<and> norm(y - z) < e \<and> label x i \<noteq> label y i \<longrightarrow> abs((f(z) - z)\<bullet>i) < d / (real n)" proof-
2.138 +    have d':"d / real n / 8 > 0" apply(rule divide_pos_pos)+ using d(1) unfolding n_def by (auto simp:  DIM_positive)
2.139 +    have *:"uniformly_continuous_on {0..\<Sum>Basis} f" by(rule compact_uniformly_continuous[OF assms(1) compact_interval])
2.140      guess e using *[unfolded uniformly_continuous_on_def,rule_format,OF d'] apply-apply(erule exE,(erule conjE)+) .
2.141      note e=this[rule_format,unfolded dist_norm]
2.142      show ?thesis apply(rule_tac x="min (e/2) (d/real n/8)" in exI)
2.143 -    proof safe show "0 < min (e / 2) (d / real n / 8)" using d' e by auto
2.144 -      fix x y z i assume as:"x \<in> {0..\<chi>\<chi> i. 1}" "y \<in> {0..\<chi>\<chi> i. 1}" "z \<in> {0..\<chi>\<chi> i. 1}"
2.145 +    proof safe
2.146 +      show "0 < min (e / 2) (d / real n / 8)" using d' e by auto
2.147 +      fix x y z i assume as:"x \<in> {0..\<Sum>Basis}" "y \<in> {0..\<Sum>Basis}" "z \<in> {0..\<Sum>Basis}"
2.148          "norm (x - z) < min (e / 2) (d / real n / 8)"
2.149 -        "norm (y - z) < min (e / 2) (d / real n / 8)" "label x i \<noteq> label y i" and i:"i<DIM('a)"
2.150 +        "norm (y - z) < min (e / 2) (d / real n / 8)" "label x i \<noteq> label y i" and i:"i\<in>Basis"
2.151        have *:"\<And>z fz x fx n1 n2 n3 n4 d4 d::real. abs(fx - x) \<le> n1 + n2 \<Longrightarrow> abs(fx - fz) \<le> n3 \<Longrightarrow> abs(x - z) \<le> n4 \<Longrightarrow>
2.152          n1 < d4 \<Longrightarrow> n2 < 2 * d4 \<Longrightarrow> n3 < d4 \<Longrightarrow> n4 < d4 \<Longrightarrow> (8 * d4 = d) \<Longrightarrow> abs(fz - z) < d" by auto
2.153 -      show "\<bar>(f z - z) \$\$ i\<bar> < d / real n" unfolding euclidean_simps proof(rule *)
2.154 -        show "\<bar>f x \$\$ i - x \$\$ i\<bar> \<le> norm (f y -f x) + norm (y - x)" apply(rule lem1[rule_format]) using as i  by auto
2.155 -        show "\<bar>f x \$\$ i - f z \$\$ i\<bar> \<le> norm (f x - f z)" "\<bar>x \$\$ i - z \$\$ i\<bar> \<le> norm (x - z)"
2.156 -          unfolding euclidean_component_diff[THEN sym] by(rule component_le_norm)+
2.157 +      show "\<bar>(f z - z) \<bullet> i\<bar> < d / real n" unfolding inner_simps proof(rule *)
2.158 +        show "\<bar>f x \<bullet> i - x \<bullet> i\<bar> \<le> norm (f y -f x) + norm (y - x)" apply(rule lem1[rule_format]) using as i  by auto
2.159 +        show "\<bar>f x \<bullet> i - f z \<bullet> i\<bar> \<le> norm (f x - f z)" "\<bar>x \<bullet> i - z \<bullet> i\<bar> \<le> norm (x - z)"
2.160 +          unfolding inner_diff_left[THEN sym] by(rule Basis_le_norm[OF i])+
2.161          have tria:"norm (y - x) \<le> norm (y - z) + norm (x - z)" using dist_triangle[of y x z,unfolded dist_norm]
2.162            unfolding norm_minus_commute by auto
2.163          also have "\<dots> < e / 2 + e / 2" apply(rule add_strict_mono) using as(4,5) by auto
2.164 @@ -1418,95 +1436,99 @@
2.165    guess p using real_arch_simple[of "1 + real n / e"] .. note p=this
2.166    have "1 + real n / e > 0" apply(rule add_pos_pos) defer apply(rule divide_pos_pos) using e(1) n by auto
2.167    hence "p > 0" using p by auto
2.168 -  def b \<equiv> "\<lambda>i. i - 1::nat" have b:"bij_betw b {1..n} {..<DIM('a)}"
2.169 -    unfolding bij_betw_def inj_on_def b_def n_def apply rule defer
2.170 -    apply safe defer unfolding image_iff apply(rule_tac x="Suc x" in bexI) by auto
2.171 +
2.172 +  obtain b :: "nat \<Rightarrow> 'a" where b: "bij_betw b {1..n} Basis"
2.173 +    by atomize_elim (auto simp: n_def intro!: finite_same_card_bij)
2.174    def b' \<equiv> "inv_into {1..n} b"
2.175 -  have b':"bij_betw b' {..<DIM('a)} {1..n}" using bij_betw_inv_into[OF b] unfolding b'_def n_def by auto
2.176 -  have bb'[simp]:"\<And>i. i<DIM('a) \<Longrightarrow> b (b' i) = i" unfolding b'_def apply(rule f_inv_into_f) using b
2.177 -    unfolding bij_betw_def by auto
2.178 -  have b'b[simp]:"\<And>i. i\<in>{1..n} \<Longrightarrow> b' (b i) = i" unfolding b'_def apply(rule inv_into_f_eq)
2.179 -    using b unfolding n_def bij_betw_def by auto
2.180 +  then have b': "bij_betw b' Basis {1..n}"
2.181 +    using bij_betw_inv_into[OF b] by auto
2.182 +  then have b'_Basis: "\<And>i. i \<in> Basis \<Longrightarrow> b' i \<in> {Suc 0 .. n}"
2.183 +    unfolding bij_betw_def by (auto simp: set_eq_iff)
2.184 +  have bb'[simp]:"\<And>i. i \<in> Basis \<Longrightarrow> b (b' i) = i"
2.185 +    unfolding b'_def using b by (auto simp: f_inv_into_f bij_betw_def)
2.186 +  have b'b[simp]:"\<And>i. i \<in> {1..n} \<Longrightarrow> b' (b i) = i"
2.187 +    unfolding b'_def using b by (auto simp: inv_into_f_eq bij_betw_def)
2.188    have *:"\<And>x::nat. x=0 \<or> x=1 \<longleftrightarrow> x\<le>1" by auto
2.189 -  have b'':"\<And>j. j\<in>{1..n} \<Longrightarrow> b j <DIM('a)" using b unfolding bij_betw_def by auto
2.190 +  have b'':"\<And>j. j\<in>{Suc 0..n} \<Longrightarrow> b j \<in>Basis" using b unfolding bij_betw_def by auto
2.191    have q1:"0 < p" "0 < n"  "\<forall>x. (\<forall>i\<in>{1..n}. x i \<le> p) \<longrightarrow>
2.192 -    (\<forall>i\<in>{1..n}. (label (\<chi>\<chi> i. real (x (b' i)) / real p) \<circ> b) i = 0 \<or> (label (\<chi>\<chi> i. real (x (b' i)) / real p) \<circ> b) i = 1)"
2.193 +    (\<forall>i\<in>{1..n}. (label (\<Sum>i\<in>Basis. (real (x (b' i)) / real p) *\<^sub>R i) \<circ> b) i = 0 \<or>
2.194 +                (label (\<Sum>i\<in>Basis. (real (x (b' i)) / real p) *\<^sub>R i) \<circ> b) i = 1)"
2.195      unfolding * using `p>0` `n>0` using label(1)[OF b'']  by auto
2.196 -  have q2:"\<forall>x. (\<forall>i\<in>{1..n}. x i \<le> p) \<longrightarrow> (\<forall>i\<in>{1..n}. x i = 0 \<longrightarrow> (label (\<chi>\<chi> i. real (x (b' i)) / real p) \<circ> b) i = 0)"
2.197 -    "\<forall>x. (\<forall>i\<in>{1..n}. x i \<le> p) \<longrightarrow> (\<forall>i\<in>{1..n}. x i = p \<longrightarrow> (label (\<chi>\<chi> i. real (x (b' i)) / real p) \<circ> b) i = 1)"
2.198 -    apply(rule,rule,rule,rule) defer proof(rule,rule,rule,rule) fix x i
2.199 -    assume as:"\<forall>i\<in>{1..n}. x i \<le> p" "i \<in> {1..n}"
2.200 -    { assume "x i = p \<or> x i = 0"
2.201 -      have "(\<chi>\<chi> i. real (x (b' i)) / real p) \<in> {0::'a..\<chi>\<chi> i. 1}" unfolding mem_interval
2.202 -        apply safe unfolding euclidean_lambda_beta euclidean_component_zero
2.203 -      proof (simp_all only: if_P) fix j assume j':"j<DIM('a)"
2.204 -        hence j:"b' j \<in> {1..n}" using b' unfolding n_def bij_betw_def by auto
2.205 -        show "0 \<le> real (x (b' j)) / real p"
2.206 -          apply(rule divide_nonneg_pos) using `p>0` using as(1)[rule_format,OF j] by auto
2.207 -        show "real (x (b' j)) / real p \<le> 1" unfolding divide_le_eq_1
2.208 -          using as(1)[rule_format,OF j] by auto qed } note cube=this
2.209 -    { assume "x i = p" thus "(label (\<chi>\<chi> i. real (x (b' i)) / real p) \<circ> b) i = 1" unfolding o_def
2.210 -        apply- apply(rule label(3)) apply(rule b'') using cube using as `p>0`
2.211 -      proof safe assume i:"i\<in>{1..n}"
2.212 -        show "((\<chi>\<chi> ia. real (x (b' ia)) / real (x i))::'a) \$\$ b i = 1"
2.213 -          unfolding euclidean_lambda_beta apply(subst if_P) apply(rule b''[OF i]) unfolding b'b[OF i]
2.214 -          unfolding  `x i = p` using q1(1) by auto
2.215 -      qed auto }
2.216 -    { assume "x i = 0" thus "(label (\<chi>\<chi> i. real (x (b' i)) / real p) \<circ> b) i = 0" unfolding o_def
2.217 -        apply-apply(rule label(2)[OF b'']) using cube using as `p>0`
2.218 -      proof safe assume i:"i\<in>{1..n}"
2.219 -        show "((\<chi>\<chi> ia. real (x (b' ia)) / real p)::'a) \$\$ b i = 0"
2.220 -          unfolding euclidean_lambda_beta apply (subst if_P) apply(rule b''[OF i]) unfolding b'b[OF i]
2.221 -          unfolding `x i = 0` using q1(1) by auto
2.222 -      qed auto }
2.223 +  have q2:"\<forall>x. (\<forall>i\<in>{1..n}. x i \<le> p) \<longrightarrow> (\<forall>i\<in>{1..n}. x i = 0 \<longrightarrow>
2.224 +      (label (\<Sum>i\<in>Basis. (real (x (b' i)) / real p) *\<^sub>R i) \<circ> b) i = 0)"
2.225 +    "\<forall>x. (\<forall>i\<in>{1..n}. x i \<le> p) \<longrightarrow> (\<forall>i\<in>{1..n}. x i = p \<longrightarrow>
2.226 +      (label (\<Sum>i\<in>Basis. (real (x (b' i)) / real p) *\<^sub>R i) \<circ> b) i = 1)"
2.227 +    apply(rule,rule,rule,rule)
2.228 +    defer
2.229 +  proof(rule,rule,rule,rule)
2.230 +    fix x i assume as:"\<forall>i\<in>{1..n}. x i \<le> p" "i \<in> {1..n}"
2.231 +    { assume "x i = p \<or> x i = 0"
2.232 +      have "(\<Sum>i\<in>Basis. (real (x (b' i)) / real p) *\<^sub>R i) \<in> {0::'a..\<Sum>Basis}"
2.233 +        unfolding mem_interval using as b'_Basis
2.234 +        by (auto simp add: inner_simps bij_betw_def zero_le_divide_iff divide_le_eq_1) }
2.235 +    note cube=this
2.236 +    { assume "x i = p" thus "(label (\<Sum>i\<in>Basis. (real (x (b' i)) / real p) *\<^sub>R i) \<circ> b) i = 1"
2.237 +        unfolding o_def using cube as `p>0`
2.238 +        by (intro label(3)) (auto simp add: b'') }
2.239 +    { assume "x i = 0" thus "(label (\<Sum>i\<in>Basis. (real (x (b' i)) / real p) *\<^sub>R i) \<circ> b) i = 0"
2.240 +        unfolding o_def using cube as `p>0`
2.241 +        by (intro label(2)) (auto simp add: b'') }
2.242    qed
2.243    guess q apply(rule kuhn_lemma[OF q1 q2]) . note q=this
2.244 -  def z \<equiv> "(\<chi>\<chi> i. real (q (b' i)) / real p)::'a"
2.245 -  have "\<exists>i<DIM('a). d / real n \<le> abs((f z - z)\$\$i)" proof(rule ccontr)
2.246 -    have "\<forall>i<DIM('a). q (b' i) \<in> {0..<p}" using q(1) b'[unfolded bij_betw_def] by auto
2.247 -    hence "\<forall>i<DIM('a). q (b' i) \<in> {0..p}" apply-apply(rule,erule_tac x=i in allE) by auto
2.248 -    hence "z\<in>{0..\<chi>\<chi> i.1}" unfolding z_def mem_interval apply safe unfolding euclidean_lambda_beta
2.249 -      unfolding euclidean_component_zero apply (simp_all only: if_P)
2.250 -      apply(rule divide_nonneg_pos) using `p>0` unfolding divide_le_eq_1 by auto
2.251 -    hence d_fz_z:"d \<le> norm (f z - z)" apply(drule_tac d) .
2.252 -    case goal1 hence as:"\<forall>i<DIM('a). \<bar>f z \$\$ i - z \$\$ i\<bar> < d / real n" using `n>0` by(auto simp add:not_le)
2.253 -    have "norm (f z - z) \<le> (\<Sum>i<DIM('a). \<bar>f z \$\$ i - z \$\$ i\<bar>)" unfolding euclidean_component_diff[THEN sym] by(rule norm_le_l1)
2.254 -    also have "\<dots> < (\<Sum>i<DIM('a). d / real n)" apply(rule setsum_strict_mono) using as by auto
2.255 -    also have "\<dots> = d" unfolding real_eq_of_nat n_def using n using DIM_positive[where 'a='a] by auto
2.256 +  def z \<equiv> "(\<Sum>i\<in>Basis. (real (q (b' i)) / real p) *\<^sub>R i)::'a"
2.257 +  have "\<exists>i\<in>Basis. d / real n \<le> abs((f z - z)\<bullet>i)"
2.258 +  proof(rule ccontr)
2.259 +    have "\<forall>i\<in>Basis. q (b' i) \<in> {0..p}"
2.260 +      using q(1) b' by (auto intro: less_imp_le simp: bij_betw_def)
2.261 +    hence "z\<in>{0..\<Sum>Basis}"
2.262 +      unfolding z_def mem_interval using b'_Basis
2.263 +      by (auto simp add: inner_simps bij_betw_def zero_le_divide_iff divide_le_eq_1)
2.264 +    hence d_fz_z:"d \<le> norm (f z - z)" by (rule d)
2.265 +    case goal1
2.266 +    hence as:"\<forall>i\<in>Basis. \<bar>f z \<bullet> i - z \<bullet> i\<bar> < d / real n"
2.267 +      using `n>0` by(auto simp add: not_le inner_simps)
2.268 +    have "norm (f z - z) \<le> (\<Sum>i\<in>Basis. \<bar>f z \<bullet> i - z \<bullet> i\<bar>)"
2.269 +      unfolding inner_diff_left[symmetric] by(rule norm_le_l1)
2.270 +    also have "\<dots> < (\<Sum>(i::'a)\<in>Basis. d / real n)" apply(rule setsum_strict_mono) using as by auto
2.271 +    also have "\<dots> = d" using DIM_positive[where 'a='a] by (auto simp: real_eq_of_nat n_def)
2.272      finally show False using d_fz_z by auto qed then guess i .. note i=this
2.273    have *:"b' i \<in> {1..n}" using i using b'[unfolded bij_betw_def] by auto
2.274    guess r using q(2)[rule_format,OF *] .. then guess s apply-apply(erule exE,(erule conjE)+) . note rs=this[rule_format]
2.275 -  have b'_im:"\<And>i. i<DIM('a) \<Longrightarrow>  b' i \<in> {1..n}" using b' unfolding bij_betw_def by auto
2.276 -  def r' \<equiv> "(\<chi>\<chi> i. real (r (b' i)) / real p)::'a"
2.277 -  have "\<And>i. i<DIM('a) \<Longrightarrow> r (b' i) \<le> p" apply(rule order_trans) apply(rule rs(1)[OF b'_im,THEN conjunct2])
2.278 +  have b'_im:"\<And>i. i\<in>Basis \<Longrightarrow>  b' i \<in> {1..n}" using b' unfolding bij_betw_def by auto
2.279 +  def r' \<equiv> "(\<Sum>i\<in>Basis. (real (r (b' i)) / real p) *\<^sub>R i)::'a"
2.280 +  have "\<And>i. i\<in>Basis \<Longrightarrow> r (b' i) \<le> p" apply(rule order_trans) apply(rule rs(1)[OF b'_im,THEN conjunct2])
2.281      using q(1)[rule_format,OF b'_im] by(auto simp add: Suc_le_eq)
2.282 -  hence "r' \<in> {0..\<chi>\<chi> i. 1}"  unfolding r'_def mem_interval apply safe unfolding euclidean_lambda_beta euclidean_component_zero
2.283 -    apply (simp only: if_P)
2.284 -    apply(rule divide_nonneg_pos) using rs(1)[OF b'_im] q(1)[rule_format,OF b'_im] `p>0` by auto
2.285 -  def s' \<equiv> "(\<chi>\<chi> i. real (s (b' i)) / real p)::'a"
2.286 -  have "\<And>i. i<DIM('a) \<Longrightarrow> s (b' i) \<le> p" apply(rule order_trans) apply(rule rs(2)[OF b'_im,THEN conjunct2])
2.287 +  hence "r' \<in> {0..\<Sum>Basis}"
2.288 +    unfolding r'_def mem_interval using b'_Basis
2.289 +    by (auto simp add: inner_simps bij_betw_def zero_le_divide_iff divide_le_eq_1)
2.290 +  def s' \<equiv> "(\<Sum>i\<in>Basis. (real (s (b' i)) / real p) *\<^sub>R i)::'a"
2.291 +  have "\<And>i. i\<in>Basis \<Longrightarrow> s (b' i) \<le> p" apply(rule order_trans) apply(rule rs(2)[OF b'_im,THEN conjunct2])
2.292      using q(1)[rule_format,OF b'_im] by(auto simp add: Suc_le_eq)
2.293 -  hence "s' \<in> {0..\<chi>\<chi> i.1}" unfolding s'_def mem_interval apply safe unfolding euclidean_lambda_beta euclidean_component_zero
2.294 -    apply (simp_all only: if_P) apply(rule divide_nonneg_pos) using rs(1)[OF b'_im] q(1)[rule_format,OF b'_im] `p>0` by auto
2.295 -  have "z\<in>{0..\<chi>\<chi> i.1}" unfolding z_def mem_interval apply safe unfolding euclidean_lambda_beta euclidean_component_zero
2.296 -    apply (simp_all only: if_P) apply(rule divide_nonneg_pos) using q(1)[rule_format,OF b'_im] `p>0` by(auto intro:less_imp_le)
2.297 +  hence "s' \<in> {0..\<Sum>Basis}"
2.298 +    unfolding s'_def mem_interval using b'_Basis
2.299 +    by (auto simp add: inner_simps bij_betw_def zero_le_divide_iff divide_le_eq_1)
2.300 +  have "z\<in>{0..\<Sum>Basis}"
2.301 +    unfolding z_def mem_interval using b'_Basis q(1)[rule_format,OF b'_im] `p>0`
2.302 +    by (auto simp add: inner_simps bij_betw_def zero_le_divide_iff divide_le_eq_1 less_imp_le)
2.303    have *:"\<And>x. 1 + real x = real (Suc x)" by auto
2.304 -  { have "(\<Sum>i<DIM('a). \<bar>real (r (b' i)) - real (q (b' i))\<bar>) \<le> (\<Sum>i<DIM('a). 1)"
2.305 +  { have "(\<Sum>i\<in>Basis. \<bar>real (r (b' i)) - real (q (b' i))\<bar>) \<le> (\<Sum>(i::'a)\<in>Basis. 1)"
2.306        apply(rule setsum_mono) using rs(1)[OF b'_im] by(auto simp add:* field_simps)
2.307 -    also have "\<dots> < e * real p" using p `e>0` `p>0` unfolding n_def real_of_nat_def
2.309 -    finally have "(\<Sum>i<DIM('a). \<bar>real (r (b' i)) - real (q (b' i))\<bar>) < e * real p" . } moreover
2.310 -  { have "(\<Sum>i<DIM('a). \<bar>real (s (b' i)) - real (q (b' i))\<bar>) \<le> (\<Sum>i<DIM('a). 1)"
2.311 +    also have "\<dots> < e * real p" using p `e>0` `p>0`
2.312 +      by(auto simp add: field_simps n_def real_of_nat_def)
2.313 +    finally have "(\<Sum>i\<in>Basis. \<bar>real (r (b' i)) - real (q (b' i))\<bar>) < e * real p" . } moreover
2.314 +  { have "(\<Sum>i\<in>Basis. \<bar>real (s (b' i)) - real (q (b' i))\<bar>) \<le> (\<Sum>(i::'a)\<in>Basis. 1)"
2.315        apply(rule setsum_mono) using rs(2)[OF b'_im] by(auto simp add:* field_simps)
2.316 -    also have "\<dots> < e * real p" using p `e>0` `p>0` unfolding n_def real_of_nat_def
2.318 -    finally have "(\<Sum>i<DIM('a). \<bar>real (s (b' i)) - real (q (b' i))\<bar>) < e * real p" . } ultimately
2.319 -  have "norm (r' - z) < e" "norm (s' - z) < e" unfolding r'_def s'_def z_def apply-
2.320 -    apply(rule_tac[!] le_less_trans[OF norm_le_l1]) using `p>0`
2.321 -    by(auto simp add:field_simps setsum_divide_distrib[THEN sym])
2.322 -  hence "\<bar>(f z - z) \$\$ i\<bar> < d / real n" apply-apply(rule e(2)[OF `r'\<in>{0..\<chi>\<chi> i.1}` `s'\<in>{0..\<chi>\<chi> i.1}` `z\<in>{0..\<chi>\<chi> i.1}`])
2.323 -    using rs(3) unfolding r'_def[symmetric] s'_def[symmetric] o_def bb' using i by auto
2.324 -  thus False using i by auto qed
2.325 +    also have "\<dots> < e * real p" using p `e>0` `p>0`
2.326 +      by(auto simp add: field_simps n_def real_of_nat_def)
2.327 +    finally have "(\<Sum>i\<in>Basis. \<bar>real (s (b' i)) - real (q (b' i))\<bar>) < e * real p" . } ultimately
2.328 +  have "norm (r' - z) < e" "norm (s' - z) < e" unfolding r'_def s'_def z_def using `p>0`
2.329 +    by (rule_tac[!] le_less_trans[OF norm_le_l1])
2.330 +       (auto simp add: field_simps setsum_divide_distrib[symmetric] inner_diff_left)
2.331 +  hence "\<bar>(f z - z) \<bullet> i\<bar> < d / real n"
2.332 +    using rs(3) i unfolding r'_def[symmetric] s'_def[symmetric] o_def bb'
2.333 +    by (intro e(2)[OF `r'\<in>{0..\<Sum>Basis}` `s'\<in>{0..\<Sum>Basis}` `z\<in>{0..\<Sum>Basis}`]) auto
2.334 +  thus False using i by auto
2.335 +qed
2.336
2.337  subsection {* Retractions. *}
2.338
2.339 @@ -1551,12 +1573,14 @@
2.340
2.341  subsection {*So the Brouwer theorem for any set with nonempty interior. *}
2.342
2.343 -lemma brouwer_weak: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'a::ordered_euclidean_space"
2.344 +lemma brouwer_weak:
2.345 +  fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'a::ordered_euclidean_space"
2.346    assumes "compact s" "convex s" "interior s \<noteq> {}" "continuous_on s f" "f ` s \<subseteq> s"
2.347    obtains x where "x \<in> s" "f x = x" proof-
2.348 -  have *:"interior {0::'a..\<chi>\<chi> i.1} \<noteq> {}" unfolding interior_closed_interval interval_eq_empty by auto
2.349 -  have *:"{0::'a..\<chi>\<chi> i.1} homeomorphic s" using homeomorphic_convex_compact[OF convex_interval(1) compact_interval * assms(2,1,3)] .
2.350 -  have "\<forall>f. continuous_on {0::'a..\<chi>\<chi> i.1} f \<and> f ` {0::'a..\<chi>\<chi> i.1} \<subseteq> {0::'a..\<chi>\<chi> i.1} \<longrightarrow> (\<exists>x\<in>{0::'a..\<chi>\<chi> i.1}. f x = x)"
2.351 +  have *:"interior {0::'a..\<Sum>Basis} \<noteq> {}" unfolding interior_closed_interval interval_eq_empty by auto
2.352 +  have *:"{0::'a..\<Sum>Basis} homeomorphic s" using homeomorphic_convex_compact[OF convex_interval(1) compact_interval * assms(2,1,3)] .
2.353 +  have "\<forall>f. continuous_on {0::'a..\<Sum>Basis} f \<and> f ` {0::'a..\<Sum>Basis} \<subseteq> {0::'a..\<Sum>Basis} \<longrightarrow>
2.354 +    (\<exists>x\<in>{0::'a..\<Sum>Basis}. f x = x)"
2.355      using brouwer_cube by auto
2.356    thus ?thesis unfolding homeomorphic_fixpoint_property[OF *] apply(erule_tac x=f in allE)
2.357      apply(erule impE) defer apply(erule bexE) apply(rule_tac x=y in that) using assms by auto qed
2.358 @@ -1609,49 +1633,45 @@
2.359
2.360  subsection {*Bijections between intervals. *}
2.361
2.362 -definition "interval_bij = (\<lambda> (a::'a,b::'a) (u::'a,v::'a) (x::'a::ordered_euclidean_space).
2.363 -    (\<chi>\<chi> i. u\$\$i + (x\$\$i - a\$\$i) / (b\$\$i - a\$\$i) * (v\$\$i - u\$\$i))::'a)"
2.364 +definition interval_bij :: "'a \<times> 'a \<Rightarrow> 'a \<times> 'a \<Rightarrow> 'a \<Rightarrow> 'a::ordered_euclidean_space" where
2.365 +  "interval_bij \<equiv> \<lambda>(a, b) (u, v) x. (\<Sum>i\<in>Basis. (u\<bullet>i + (x\<bullet>i - a\<bullet>i) / (b\<bullet>i - a\<bullet>i) * (v\<bullet>i - u\<bullet>i)) *\<^sub>R i)"
2.366
2.367  lemma interval_bij_affine:
2.368 - "interval_bij (a,b) (u,v) = (\<lambda>x. (\<chi>\<chi> i. (v\$\$i - u\$\$i) / (b\$\$i - a\$\$i) * x\$\$i) +
2.369 -            (\<chi>\<chi> i. u\$\$i - (v\$\$i - u\$\$i) / (b\$\$i - a\$\$i) * a\$\$i))"
2.370 -  apply rule apply(subst euclidean_eq,safe) unfolding euclidean_simps interval_bij_def euclidean_lambda_beta
2.372 +  "interval_bij (a,b) (u,v) = (\<lambda>x. (\<Sum>i\<in>Basis. ((v\<bullet>i - u\<bullet>i) / (b\<bullet>i - a\<bullet>i) * (x\<bullet>i)) *\<^sub>R i) +
2.373 +    (\<Sum>i\<in>Basis. (u\<bullet>i - (v\<bullet>i - u\<bullet>i) / (b\<bullet>i - a\<bullet>i) * (a\<bullet>i)) *\<^sub>R i))"
2.375 +                 field_simps inner_simps add_divide_distrib[symmetric] intro!: setsum_cong)
2.376
2.377  lemma continuous_interval_bij:
2.378    "continuous (at x) (interval_bij (a,b::'a::ordered_euclidean_space) (u,v::'a))"
2.379 -  unfolding interval_bij_affine apply(rule continuous_intros)
2.380 -    apply(rule linear_continuous_at) unfolding linear_conv_bounded_linear[THEN sym]
2.381 -    unfolding linear_def euclidean_eq[where 'a='a] apply safe unfolding euclidean_lambda_beta prefer 3
2.383 +  by (auto simp add: divide_inverse interval_bij_def intro!: continuous_setsum continuous_intros)
2.384
2.385  lemma continuous_on_interval_bij: "continuous_on s (interval_bij (a,b) (u,v))"
2.386    apply(rule continuous_at_imp_continuous_on) by(rule, rule continuous_interval_bij)
2.387
2.388 -(** move this **)
2.389 -lemma divide_nonneg_nonneg:assumes "a \<ge> 0" "b \<ge> 0" shows "0 \<le> a / (b::real)"
2.390 -  apply(cases "b=0") defer apply(rule divide_nonneg_pos) using assms by auto
2.391 -
2.392 -lemma in_interval_interval_bij: assumes "x \<in> {a..b}" "{u..v} \<noteq> {}"
2.393 -  shows "interval_bij (a,b) (u,v) x \<in> {u..v::'a::ordered_euclidean_space}"
2.394 -  unfolding interval_bij_def split_conv mem_interval apply safe unfolding euclidean_lambda_beta
2.395 -proof (simp_all only: if_P)
2.396 -  fix i assume i:"i<DIM('a)" have "{a..b} \<noteq> {}" using assms by auto
2.397 -  hence *:"a\$\$i \<le> b\$\$i" "u\$\$i \<le> v\$\$i" using assms(2) unfolding interval_eq_empty not_ex apply-
2.398 -    apply(erule_tac[!] x=i in allE)+ by auto
2.399 -  have x:"a\$\$i\<le>x\$\$i" "x\$\$i\<le>b\$\$i" using assms(1)[unfolded mem_interval] using i by auto
2.400 -  have "0 \<le> (x \$\$ i - a \$\$ i) / (b \$\$ i - a \$\$ i) * (v \$\$ i - u \$\$ i)"
2.401 -    apply(rule mult_nonneg_nonneg) apply(rule divide_nonneg_nonneg)
2.402 -    using * x by(auto simp add:field_simps)
2.403 -  thus "u \$\$ i \<le> u \$\$ i + (x \$\$ i - a \$\$ i) / (b \$\$ i - a \$\$ i) * (v \$\$ i - u \$\$ i)" using * by auto
2.404 -  have "((x \$\$ i - a \$\$ i) / (b \$\$ i - a \$\$ i)) * (v \$\$ i - u \$\$ i) \<le> 1 * (v \$\$ i - u \$\$ i)"
2.405 +lemma in_interval_interval_bij:
2.406 +  fixes a b u v x :: "'a::ordered_euclidean_space"
2.407 +  assumes "x \<in> {a..b}" "{u..v} \<noteq> {}" shows "interval_bij (a,b) (u,v) x \<in> {u..v}"
2.408 +  apply (simp only: interval_bij_def split_conv mem_interval inner_setsum_left_Basis cong: ball_cong)
2.409 +proof safe
2.410 +  fix i :: 'a assume i:"i\<in>Basis"
2.411 +  have "{a..b} \<noteq> {}" using assms by auto
2.412 +  with i have *: "a\<bullet>i \<le> b\<bullet>i" "u\<bullet>i \<le> v\<bullet>i"
2.413 +    using assms(2) by (auto simp add: interval_eq_empty not_less)
2.414 +  have x: "a\<bullet>i\<le>x\<bullet>i" "x\<bullet>i\<le>b\<bullet>i"
2.415 +    using assms(1)[unfolded mem_interval] using i by auto
2.416 +  have "0 \<le> (x \<bullet> i - a \<bullet> i) / (b \<bullet> i - a \<bullet> i) * (v \<bullet> i - u \<bullet> i)"
2.417 +    using * x by (auto intro!: mult_nonneg_nonneg divide_nonneg_nonneg)
2.418 +  thus "u \<bullet> i \<le> u \<bullet> i + (x \<bullet> i - a \<bullet> i) / (b \<bullet> i - a \<bullet> i) * (v \<bullet> i - u \<bullet> i)"
2.419 +    using * by auto
2.420 +  have "((x \<bullet> i - a \<bullet> i) / (b \<bullet> i - a \<bullet> i)) * (v \<bullet> i - u \<bullet> i) \<le> 1 * (v \<bullet> i - u \<bullet> i)"
2.421      apply(rule mult_right_mono) unfolding divide_le_eq_1 using * x by auto
2.422 -  thus "u \$\$ i + (x \$\$ i - a \$\$ i) / (b \$\$ i - a \$\$ i) * (v \$\$ i - u \$\$ i) \<le> v \$\$ i" using * by auto
2.423 +  thus "u \<bullet> i + (x \<bullet> i - a \<bullet> i) / (b \<bullet> i - a \<bullet> i) * (v \<bullet> i - u \<bullet> i) \<le> v \<bullet> i" using * by auto
2.424  qed
2.425
2.426 -lemma interval_bij_bij: fixes x::"'a::ordered_euclidean_space" assumes "\<forall>i. a\$\$i < b\$\$i \<and> u\$\$i < v\$\$i"
2.427 -  shows "interval_bij (a,b) (u,v) (interval_bij (u,v) (a,b) x) = x"
2.428 -  unfolding interval_bij_def split_conv euclidean_eq[where 'a='a]
2.429 -  apply(rule,insert assms,erule_tac x=i in allE) by auto
2.430 +lemma interval_bij_bij:
2.431 +  "\<forall>(i::'a::ordered_euclidean_space)\<in>Basis. a\<bullet>i < b\<bullet>i \<and> u\<bullet>i < v\<bullet>i \<Longrightarrow>
2.432 +    interval_bij (a,b) (u,v) (interval_bij (u,v) (a,b) x) = x"
2.433 +  by (auto simp: interval_bij_def euclidean_eq_iff[where 'a='a])
2.434
2.435  end
```
```     3.1 --- a/src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy	Fri Dec 14 14:46:01 2012 +0100
3.2 +++ b/src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy	Fri Dec 14 15:46:01 2012 +0100
3.3 @@ -328,283 +328,18 @@
3.4    fixes f:: "'a \<Rightarrow> real ^'n"
3.5    assumes fP: "finite P" and fPs: "\<And>Q. Q \<subseteq> P \<Longrightarrow> norm (setsum f Q) \<le> e"
3.6    shows "setsum (\<lambda>x. norm (f x)) P \<le> 2 * real CARD('n) *  e"
3.7 -proof -
3.8 -  let ?d = "real CARD('n)"
3.9 -  let ?nf = "\<lambda>x. norm (f x)"
3.10 -  let ?U = "UNIV :: 'n set"
3.11 -  have th0: "setsum (\<lambda>x. setsum (\<lambda>i. \<bar>f x \$ i\<bar>) ?U) P = setsum (\<lambda>i. setsum (\<lambda>x. \<bar>f x \$ i\<bar>) P) ?U"
3.12 -    by (rule setsum_commute)
3.13 -  have th1: "2 * ?d * e = of_nat (card ?U) * (2 * e)" by (simp add: real_of_nat_def)
3.14 -  have "setsum ?nf P \<le> setsum (\<lambda>x. setsum (\<lambda>i. \<bar>f x \$ i\<bar>) ?U) P"
3.15 -    apply (rule setsum_mono)
3.16 -    apply (rule norm_le_l1_cart)
3.17 -    done
3.18 -  also have "\<dots> \<le> 2 * ?d * e"
3.19 -    unfolding th0 th1
3.20 -  proof(rule setsum_bounded)
3.21 -    fix i assume i: "i \<in> ?U"
3.22 -    let ?Pp = "{x. x\<in> P \<and> f x \$ i \<ge> 0}"
3.23 -    let ?Pn = "{x. x \<in> P \<and> f x \$ i < 0}"
3.24 -    have thp: "P = ?Pp \<union> ?Pn" by auto
3.25 -    have thp0: "?Pp \<inter> ?Pn ={}" by auto
3.26 -    have PpP: "?Pp \<subseteq> P" and PnP: "?Pn \<subseteq> P" by blast+
3.27 -    have Ppe:"setsum (\<lambda>x. \<bar>f x \$ i\<bar>) ?Pp \<le> e"
3.28 -      using component_le_norm_cart[of "setsum (\<lambda>x. f x) ?Pp" i]  fPs[OF PpP]
3.29 -      by (auto intro: abs_le_D1)
3.30 -    have Pne: "setsum (\<lambda>x. \<bar>f x \$ i\<bar>) ?Pn \<le> e"
3.31 -      using component_le_norm_cart[of "setsum (\<lambda>x. - f x) ?Pn" i]  fPs[OF PnP]
3.32 -      by (auto simp add: setsum_negf intro: abs_le_D1)
3.33 -    have "setsum (\<lambda>x. \<bar>f x \$ i\<bar>) P = setsum (\<lambda>x. \<bar>f x \$ i\<bar>) ?Pp + setsum (\<lambda>x. \<bar>f x \$ i\<bar>) ?Pn"
3.34 -      apply (subst thp)
3.35 -      apply (rule setsum_Un_zero)
3.36 -      using fP thp0 apply auto
3.37 -      done
3.38 -    also have "\<dots> \<le> 2*e" using Pne Ppe by arith
3.39 -    finally show "setsum (\<lambda>x. \<bar>f x \$ i\<bar>) P \<le> 2*e" .
3.40 -  qed
3.41 -  finally show ?thesis .
3.42 -qed
3.43 -
3.44 -lemma if_distr: "(if P then f else g) \$ i = (if P then f \$ i else g \$ i)" by simp
3.45 -
3.46 -lemma split_dimensions'[consumes 1]:
3.47 -  assumes "k < DIM('a::euclidean_space^'b)"
3.48 -  obtains i j where "i < CARD('b::finite)"
3.49 -    and "j < DIM('a::euclidean_space)"
3.50 -    and "k = j + i * DIM('a::euclidean_space)"
3.51 -  using split_times_into_modulo[OF assms[simplified]] .
3.52 -
3.53 -lemma cart_euclidean_bound[intro]:
3.54 -  assumes j:"j < DIM('a::euclidean_space)"
3.55 -  shows "j + \<pi>' (i::'b::finite) * DIM('a) < CARD('b) * DIM('a::euclidean_space)"
3.56 -  using linear_less_than_times[OF pi'_range j, of i] .
3.57 -
3.58 -lemma (in euclidean_space) forall_CARD_DIM:
3.59 -  "(\<forall>i<CARD('b) * DIM('a). P i) \<longleftrightarrow> (\<forall>(i::'b::finite) j. j<DIM('a) \<longrightarrow> P (j + \<pi>' i * DIM('a)))"
3.60 -   (is "?l \<longleftrightarrow> ?r")
3.61 -proof (safe elim!: split_times_into_modulo)
3.62 -  fix i :: 'b and j
3.63 -  assume "j < DIM('a)"
3.64 -  note linear_less_than_times[OF pi'_range[of i] this]
3.65 -  moreover assume "?l"
3.66 -  ultimately show "P (j + \<pi>' i * DIM('a))" by auto
3.67 -next
3.68 -  fix i j
3.69 -  assume "i < CARD('b)" "j < DIM('a)" and "?r"
3.70 -  from `?r`[rule_format, OF `j < DIM('a)`, of "\<pi> i"] `i < CARD('b)`
3.71 -  show "P (j + i * DIM('a))" by simp
3.72 -qed
3.73 -
3.74 -lemma (in euclidean_space) exists_CARD_DIM:
3.75 -  "(\<exists>i<CARD('b) * DIM('a). P i) \<longleftrightarrow> (\<exists>i::'b::finite. \<exists>j<DIM('a). P (j + \<pi>' i * DIM('a)))"
3.76 -  using forall_CARD_DIM[where 'b='b, of "\<lambda>x. \<not> P x"] by blast
3.77 -
3.78 -lemma forall_CARD:
3.79 -  "(\<forall>i<CARD('b). P i) \<longleftrightarrow> (\<forall>i::'b::finite. P (\<pi>' i))"
3.80 -  using forall_CARD_DIM[where 'a=real, of P] by simp
3.81 -
3.82 -lemma exists_CARD:
3.83 -  "(\<exists>i<CARD('b). P i) \<longleftrightarrow> (\<exists>i::'b::finite. P (\<pi>' i))"
3.84 -  using exists_CARD_DIM[where 'a=real, of P] by simp
3.85 -
3.86 -lemmas cart_simps = forall_CARD_DIM exists_CARD_DIM forall_CARD exists_CARD
3.87 -
3.88 -lemma cart_euclidean_nth[simp]:
3.89 -  fixes x :: "('a::euclidean_space, 'b::finite) vec"
3.90 -  assumes j:"j < DIM('a)"
3.91 -  shows "x \$\$ (j + \<pi>' i * DIM('a)) = x \$ i \$\$ j"
3.92 -  unfolding euclidean_component_def inner_vec_def basis_eq_pi'[OF j] if_distrib cond_application_beta
3.93 -  by (simp add: setsum_cases)
3.94 -
3.95 -lemma real_euclidean_nth:
3.96 -  fixes x :: "real^'n"
3.97 -  shows "x \$\$ \<pi>' i = (x \$ i :: real)"
3.98 -  using cart_euclidean_nth[where 'a=real, of 0 x i] by simp
3.99 -
3.100 -lemmas nth_conv_component = real_euclidean_nth[symmetric]
3.101 -
3.102 -lemma mult_split_eq:
3.103 -  fixes A :: nat assumes "x < A" "y < A"
3.104 -  shows "x + i * A = y + j * A \<longleftrightarrow> x = y \<and> i = j"
3.105 -proof
3.106 -  assume *: "x + i * A = y + j * A"
3.107 -  { fix x y i j assume "i < j" "x < A" and *: "x + i * A = y + j * A"
3.108 -    hence "x + i * A < Suc i * A" using `x < A` by simp
3.109 -    also have "\<dots> \<le> j * A" using `i < j` unfolding mult_le_cancel2 by simp
3.110 -    also have "\<dots> \<le> y + j * A" by simp
3.111 -    finally have "i = j" using * by simp }
3.112 -  note eq = this
3.113 -
3.114 -  have "i = j"
3.115 -  proof (cases rule: linorder_cases)
3.116 -    assume "i < j"
3.117 -    from eq[OF this `x < A` *] show "i = j" by simp
3.118 -  next
3.119 -    assume "j < i"
3.120 -    from eq[OF this `y < A` *[symmetric]] show "i = j" by simp
3.121 -  qed simp
3.122 -  thus "x = y \<and> i = j" using * by simp
3.123 -qed simp
3.124 +  using setsum_norm_allsubsets_bound[OF assms]
3.125 +  by (simp add: DIM_cart Basis_real_def)
3.126
3.127  instance vec :: (ordered_euclidean_space, finite) ordered_euclidean_space
3.128  proof
3.129    fix x y::"'a^'b"
3.130 -  show "(x \<le> y) = (\<forall>i<DIM(('a, 'b) vec). x \$\$ i \<le> y \$\$ i)"
3.131 -    unfolding less_eq_vec_def apply(subst eucl_le) by (simp add: cart_simps)
3.132 -  show"(x < y) = (\<forall>i<DIM(('a, 'b) vec). x \$\$ i < y \$\$ i)"
3.133 -    unfolding less_vec_def apply(subst eucl_less) by (simp add: cart_simps)
3.134 -qed
3.135 -
3.136 -
3.137 -subsection{* Basis vectors in coordinate directions. *}
3.138 -
3.139 -definition "cart_basis k = (\<chi> i. if i = k then 1 else 0)"
3.140 -
3.141 -lemma basis_component [simp]: "cart_basis k \$ i = (if k=i then 1 else 0)"
3.142 -  unfolding cart_basis_def by simp
3.143 -
3.144 -lemma norm_basis[simp]:
3.145 -  shows "norm (cart_basis k :: real ^'n) = 1"
3.146 -  apply (simp add: cart_basis_def norm_eq_sqrt_inner) unfolding inner_vec_def
3.147 -  apply (vector delta_mult_idempotent)
3.148 -  using setsum_delta[of "UNIV :: 'n set" "k" "\<lambda>k. 1::real"] apply auto
3.149 -  done
3.150 -
3.151 -lemma norm_basis_1: "norm(cart_basis 1 :: real ^'n::{finite,one}) = 1"
3.152 -  by (rule norm_basis)
3.153 -
3.154 -lemma vector_choose_size: "0 <= c ==> \<exists>(x::real^'n). norm x = c"
3.155 -  by (rule exI[where x="c *\<^sub>R cart_basis arbitrary"]) simp
3.156 -
3.157 -lemma vector_choose_dist:
3.158 -  assumes e: "0 <= e"
3.159 -  shows "\<exists>(y::real^'n). dist x y = e"
3.160 -proof -
3.161 -  from vector_choose_size[OF e] obtain c:: "real ^'n" where "norm c = e"
3.162 -    by blast
3.163 -  then have "dist x (x - c) = e" by (simp add: dist_norm)
3.164 -  then show ?thesis by blast
3.165 +  show "(x \<le> y) = (\<forall>i\<in>Basis. x \<bullet> i \<le> y \<bullet> i)"
3.166 +    unfolding less_eq_vec_def apply(subst eucl_le) by (simp add: Basis_vec_def inner_axis)
3.167 +  show"(x < y) = (\<forall>i\<in>Basis. x \<bullet> i < y \<bullet> i)"
3.168 +    unfolding less_vec_def apply(subst eucl_less) by (simp add: Basis_vec_def inner_axis)
3.169  qed
3.170
3.171 -lemma basis_inj[intro]: "inj (cart_basis :: 'n \<Rightarrow> real ^'n)"
3.172 -  by (simp add: inj_on_def vec_eq_iff)
3.173 -
3.174 -lemma basis_expansion: "setsum (\<lambda>i. (x\$i) *s cart_basis i) UNIV = (x::('a::ring_1) ^'n)"
3.175 -  (is "?lhs = ?rhs" is "setsum ?f ?S = _")
3.176 -  by (auto simp add: vec_eq_iff
3.177 -      if_distrib setsum_delta[of "?S", where ?'b = "'a", simplified] cong del: if_weak_cong)
3.178 -
3.179 -lemma smult_conv_scaleR: "c *s x = scaleR c x"
3.180 -  unfolding vector_scalar_mult_def scaleR_vec_def by simp
3.181 -
3.182 -lemma basis_expansion': "setsum (\<lambda>i. (x\$i) *\<^sub>R cart_basis i) UNIV = x"
3.183 -  by (rule basis_expansion [where 'a=real, unfolded smult_conv_scaleR])
3.184 -
3.185 -lemma basis_expansion_unique:
3.186 -  "setsum (\<lambda>i. f i *s cart_basis i) UNIV = (x::('a::comm_ring_1) ^'n) \<longleftrightarrow> (\<forall>i. f i = x\$i)"
3.187 -  by (simp add: vec_eq_iff setsum_delta if_distrib cong del: if_weak_cong)
3.188 -
3.189 -lemma dot_basis: "cart_basis i \<bullet> x = x\$i" "x \<bullet> (cart_basis i) = (x\$i)"
3.190 -  by (auto simp add: inner_vec_def cart_basis_def cond_application_beta if_distrib setsum_delta
3.191 -           cong del: if_weak_cong)
3.192 -
3.193 -lemma inner_basis:
3.194 -  fixes x :: "'a::{real_inner, real_algebra_1} ^ 'n"
3.195 -  shows "inner (cart_basis i) x = inner 1 (x \$ i)"
3.196 -    and "inner x (cart_basis i) = inner (x \$ i) 1"
3.197 -  unfolding inner_vec_def cart_basis_def
3.198 -  by (auto simp add: cond_application_beta if_distrib setsum_delta cong del: if_weak_cong)
3.199 -
3.200 -lemma basis_eq_0: "cart_basis i = (0::'a::semiring_1^'n) \<longleftrightarrow> False"
3.201 -  by (auto simp add: vec_eq_iff)
3.202 -
3.203 -lemma basis_nonzero: "cart_basis k \<noteq> (0:: 'a::semiring_1 ^'n)"
3.204 -  by (simp add: basis_eq_0)
3.205 -
3.206 -text {* some lemmas to map between Eucl and Cart *}
3.207 -lemma basis_real_n[simp]:"(basis (\<pi>' i)::real^'a) = cart_basis i"
3.208 -  unfolding basis_vec_def using pi'_range[where 'n='a]
3.209 -  by (auto simp: vec_eq_iff axis_def)
3.210 -
3.211 -subsection {* Orthogonality on cartesian products *}
3.212 -
3.213 -lemma orthogonal_basis: "orthogonal (cart_basis i) x \<longleftrightarrow> x\$i = (0::real)"
3.214 -  by (auto simp add: orthogonal_def inner_vec_def cart_basis_def if_distrib
3.215 -                     cond_application_beta setsum_delta cong del: if_weak_cong)
3.216 -
3.217 -lemma orthogonal_basis_basis: "orthogonal (cart_basis i :: real^'n) (cart_basis j) \<longleftrightarrow> i \<noteq> j"
3.218 -  unfolding orthogonal_basis[of i] basis_component[of j] by simp
3.219 -
3.220 -subsection {* Linearity on cartesian products *}
3.221 -
3.222 -lemma linear_vmul_component:
3.223 -  assumes "linear f"
3.224 -  shows "linear (\<lambda>x. f x \$ k *\<^sub>R v)"
3.225 -  using assms by (auto simp add: linear_def algebra_simps)
3.226 -
3.227 -
3.228 -subsection {* Adjoints on cartesian products *}
3.229 -
3.230 -text {* TODO: The following lemmas about adjoints should hold for any
3.231 -Hilbert space (i.e. complete inner product space).
3.233 -*}
3.234 -
3.236 -  fixes f:: "real ^'n \<Rightarrow> real ^'m"
3.237 -  assumes lf: "linear f"
3.238 -  shows "\<forall>x y. f x \<bullet> y = x \<bullet> adjoint f y"
3.239 -proof -
3.240 -  let ?N = "UNIV :: 'n set"
3.241 -  let ?M = "UNIV :: 'm set"
3.242 -  have fN: "finite ?N" by simp
3.243 -  have fM: "finite ?M" by simp
3.244 -  { fix y:: "real ^ 'm"
3.245 -    let ?w = "(\<chi> i. (f (cart_basis i) \<bullet> y)) :: real ^ 'n"
3.246 -    { fix x
3.247 -      have "f x \<bullet> y = f (setsum (\<lambda>i. (x\$i) *\<^sub>R cart_basis i) ?N) \<bullet> y"
3.248 -        by (simp only: basis_expansion')
3.249 -      also have "\<dots> = (setsum (\<lambda>i. (x\$i) *\<^sub>R f (cart_basis i)) ?N) \<bullet> y"
3.250 -        unfolding linear_setsum[OF lf fN]
3.251 -        by (simp add: linear_cmul[OF lf])
3.252 -      finally have "f x \<bullet> y = x \<bullet> ?w"
3.253 -        by (simp add: inner_vec_def setsum_left_distrib
3.254 -            setsum_right_distrib setsum_commute[of _ ?M ?N] field_simps)
3.255 -    }
3.256 -  }
3.257 -  then show ?thesis
3.258 -    unfolding adjoint_def some_eq_ex[of "\<lambda>f'. \<forall>x y. f x \<bullet> y = x \<bullet> f' y"]
3.259 -    using choice_iff[of "\<lambda>a b. \<forall>x. f x \<bullet> a = x \<bullet> b "]
3.260 -    by metis
3.261 -qed
3.262 -
3.264 -  fixes f:: "real ^'n \<Rightarrow> real ^'m"
3.265 -  assumes lf: "linear f"
3.266 -  shows "x \<bullet> adjoint f y = f x \<bullet> y"
3.267 -  using adjoint_works_lemma[OF lf] by metis
3.268 -
3.270 -  fixes f:: "real ^'n \<Rightarrow> real ^'m"
3.271 -  assumes lf: "linear f"
3.272 -  shows "linear (adjoint f)"
3.273 -  unfolding linear_def vector_eq_ldot[where 'a="real^'n", symmetric] apply safe
3.274 -  unfolding inner_simps smult_conv_scaleR adjoint_works[OF lf] by auto
3.275 -
3.277 -  fixes f:: "real ^'n \<Rightarrow> real ^'m"
3.278 -  assumes lf: "linear f"
3.279 -  shows "x \<bullet> adjoint f y = f x \<bullet> y"
3.280 -    and "adjoint f y \<bullet> x = y \<bullet> f x"
3.282 -
3.284 -  fixes f:: "real ^'n \<Rightarrow> real ^'m"
3.285 -  assumes lf: "linear f"
3.288 -
3.289 -
3.290  subsection {* Matrix operations *}
3.291
3.292  text{* Matrix notation. NB: an MxN matrix is of type @{typ "'a^'n^'m"}, not @{typ "'a^'m^'n"} *}
3.293 @@ -680,10 +415,10 @@
3.294    apply auto
3.295    apply (subst vec_eq_iff)
3.296    apply clarify
3.297 -  apply (clarsimp simp add: matrix_vector_mult_def cart_basis_def if_distrib cond_application_beta vec_eq_iff cong del: if_weak_cong)
3.298 -  apply (erule_tac x="cart_basis ia" in allE)
3.299 +  apply (clarsimp simp add: matrix_vector_mult_def if_distrib cond_application_beta vec_eq_iff cong del: if_weak_cong)
3.300 +  apply (erule_tac x="axis ia 1" in allE)
3.301    apply (erule_tac x="i" in allE)
3.302 -  apply (auto simp add: cart_basis_def if_distrib cond_application_beta
3.303 +  apply (auto simp add: if_distrib cond_application_beta axis_def
3.304      setsum_delta[OF finite] cong del: if_weak_cong)
3.305    done
3.306
3.307 @@ -728,25 +463,27 @@
3.308    by (simp add: matrix_vector_mult_def vec_eq_iff column_def mult_commute)
3.309
3.310  lemma vector_componentwise:
3.311 -  "(x::'a::ring_1^'n) = (\<chi> j. setsum (\<lambda>i. (x\$i) * (cart_basis i :: 'a^'n)\$j) (UNIV :: 'n set))"
3.312 -  apply (subst basis_expansion[symmetric])
3.313 -  apply (vector vec_eq_iff setsum_component)
3.314 -  done
3.315 +  "(x::'a::ring_1^'n) = (\<chi> j. \<Sum>i\<in>UNIV. (x\$i) * (axis i 1 :: 'a^'n) \$ j)"
3.316 +  by (simp add: axis_def if_distrib setsum_cases vec_eq_iff)
3.317 +
3.318 +lemma basis_expansion: "setsum (\<lambda>i. (x\$i) *s axis i 1) UNIV = (x::('a::ring_1) ^'n)"
3.319 +  by (auto simp add: axis_def vec_eq_iff if_distrib setsum_cases cong del: if_weak_cong)
3.320
3.321  lemma linear_componentwise:
3.322    fixes f:: "real ^'m \<Rightarrow> real ^ _"
3.323    assumes lf: "linear f"
3.324 -  shows "(f x)\$j = setsum (\<lambda>i. (x\$i) * (f (cart_basis i)\$j)) (UNIV :: 'm set)" (is "?lhs = ?rhs")
3.325 +  shows "(f x)\$j = setsum (\<lambda>i. (x\$i) * (f (axis i 1)\$j)) (UNIV :: 'm set)" (is "?lhs = ?rhs")
3.326  proof -
3.327    let ?M = "(UNIV :: 'm set)"
3.328    let ?N = "(UNIV :: 'n set)"
3.329    have fM: "finite ?M" by simp
3.330 -  have "?rhs = (setsum (\<lambda>i.(x\$i) *\<^sub>R f (cart_basis i) ) ?M)\$j"
3.331 -    unfolding vector_smult_component[symmetric] smult_conv_scaleR
3.332 -    unfolding setsum_component[of "(\<lambda>i.(x\$i) *\<^sub>R f (cart_basis i :: real^'m))" ?M]
3.333 -    ..
3.334 +  have "?rhs = (setsum (\<lambda>i.(x\$i) *\<^sub>R f (axis i 1) ) ?M)\$j"
3.335 +    unfolding setsum_component by simp
3.336    then show ?thesis
3.337 -    unfolding linear_setsum_mul[OF lf fM, symmetric] basis_expansion' ..
3.338 +    unfolding linear_setsum_mul[OF lf fM, symmetric]
3.339 +    unfolding scalar_mult_eq_scaleR[symmetric]
3.340 +    unfolding basis_expansion
3.341 +    by simp
3.342  qed
3.343
3.344  text{* Inverse matrices  (not necessarily square) *}
3.345 @@ -761,7 +498,7 @@
3.346  text{* Correspondence between matrices and linear operators. *}
3.347
3.348  definition matrix :: "('a::{plus,times, one, zero}^'m \<Rightarrow> 'a ^ 'n) \<Rightarrow> 'a^'m^'n"
3.349 -  where "matrix f = (\<chi> i j. (f(cart_basis j))\$i)"
3.350 +  where "matrix f = (\<chi> i j. (f(axis j 1))\$i)"
3.351
3.352  lemma matrix_vector_mul_linear: "linear(\<lambda>x. A *v (x::real ^ _))"
3.353    by (simp add: linear_def matrix_vector_mult_def vec_eq_iff
3.354 @@ -831,103 +568,8 @@
3.355    ultimately show ?thesis by metis
3.356  qed
3.357
3.358 -
3.359 -subsection {* Standard bases are a spanning set, and obviously finite. *}
3.360 -
3.361 -lemma span_stdbasis:"span {cart_basis i :: real^'n | i. i \<in> (UNIV :: 'n set)} = UNIV"
3.362 -  apply (rule set_eqI)
3.363 -  apply auto
3.364 -  apply (subst basis_expansion'[symmetric])
3.365 -  apply (rule span_setsum)
3.366 -  apply simp
3.367 -  apply auto
3.368 -  apply (rule span_mul)
3.369 -  apply (rule span_superset)
3.370 -  apply auto
3.371 -  done
3.372 -
3.373 -lemma finite_stdbasis: "finite {cart_basis i ::real^'n |i. i\<in> (UNIV:: 'n set)}" (is "finite ?S")
3.374 -proof -
3.375 -  have "?S = cart_basis ` UNIV" by blast
3.376 -  then show ?thesis by auto
3.377 -qed
3.378 -
3.379 -lemma card_stdbasis: "card {cart_basis i ::real^'n |i. i\<in> (UNIV :: 'n set)} = CARD('n)" (is "card ?S = _")
3.380 -proof -
3.381 -  have "?S = cart_basis ` UNIV" by blast
3.382 -  then show ?thesis using card_image[OF basis_inj] by simp
3.383 -qed
3.384 -
3.385 -lemma independent_stdbasis_lemma:
3.386 -  assumes x: "(x::real ^ 'n) \<in> span (cart_basis ` S)"
3.387 -    and iS: "i \<notin> S"
3.388 -  shows "(x\$i) = 0"
3.389 -proof -
3.390 -  let ?U = "UNIV :: 'n set"
3.391 -  let ?B = "cart_basis ` S"
3.392 -  let ?P = "{(x::real^_). \<forall>i\<in> ?U. i \<notin> S \<longrightarrow> x\$i =0}"
3.393 -  { fix x::"real^_" assume xS: "x\<in> ?B"
3.394 -    from xS have "x \<in> ?P" by auto }
3.395 -  moreover
3.396 -  have "subspace ?P"
3.397 -    by (auto simp add: subspace_def)
3.398 -  ultimately show ?thesis
3.399 -    using x span_induct[of x ?B ?P] iS by blast
3.400 -qed
3.401 -
3.402 -lemma independent_stdbasis: "independent {cart_basis i ::real^'n |i. i\<in> (UNIV :: 'n set)}"
3.403 -proof -
3.404 -  let ?I = "UNIV :: 'n set"
3.405 -  let ?b = "cart_basis :: _ \<Rightarrow> real ^'n"
3.406 -  let ?B = "?b ` ?I"
3.407 -  have eq: "{?b i|i. i \<in> ?I} = ?B" by auto
3.408 -  { assume d: "dependent ?B"
3.409 -    then obtain k where k: "k \<in> ?I" "?b k \<in> span (?B - {?b k})"
3.410 -      unfolding dependent_def by auto
3.411 -    have eq1: "?B - {?b k} = ?B - ?b ` {k}"  by simp
3.412 -    have eq2: "?B - {?b k} = ?b ` (?I - {k})"
3.413 -      unfolding eq1
3.414 -      apply (rule inj_on_image_set_diff[symmetric])
3.415 -      apply (rule basis_inj) using k(1)
3.416 -      apply auto
3.417 -      done
3.418 -    from k(2) have th0: "?b k \<in> span (?b ` (?I - {k}))" unfolding eq2 .
3.419 -    from independent_stdbasis_lemma[OF th0, of k, simplified]
3.420 -    have False by simp }
3.421 -  then show ?thesis unfolding eq dependent_def ..
3.422 -qed
3.423 -
3.424  lemma vector_sub_project_orthogonal_cart: "(b::real^'n) \<bullet> (x - ((b \<bullet> x) / (b \<bullet> b)) *s b) = 0"
3.425 -  unfolding inner_simps smult_conv_scaleR by auto
3.426 -
3.427 -lemma linear_eq_stdbasis_cart:
3.428 -  assumes lf: "linear (f::real^'m \<Rightarrow> _)" and lg: "linear g"
3.429 -    and fg: "\<forall>i. f (cart_basis i) = g(cart_basis i)"
3.430 -  shows "f = g"
3.431 -proof -
3.432 -  let ?U = "UNIV :: 'm set"
3.433 -  let ?I = "{cart_basis i:: real^'m|i. i \<in> ?U}"
3.434 -  { fix x assume x: "x \<in> (UNIV :: (real^'m) set)"
3.435 -    from equalityD2[OF span_stdbasis]
3.436 -    have IU: " (UNIV :: (real^'m) set) \<subseteq> span ?I" by blast
3.437 -    from linear_eq[OF lf lg IU] fg x
3.438 -    have "f x = g x" unfolding Ball_def mem_Collect_eq by metis
3.439 -  }
3.440 -  then show ?thesis by auto
3.441 -qed
3.442 -
3.443 -lemma bilinear_eq_stdbasis_cart:
3.444 -  assumes bf: "bilinear (f:: real^'m \<Rightarrow> real^'n \<Rightarrow> _)"
3.445 -    and bg: "bilinear g"
3.446 -    and fg: "\<forall>i j. f (cart_basis i) (cart_basis j) = g (cart_basis i) (cart_basis j)"
3.447 -  shows "f = g"
3.448 -proof -
3.449 -  from fg have th: "\<forall>x \<in> {cart_basis i| i. i\<in> (UNIV :: 'm set)}.
3.450 -      \<forall>y\<in>  {cart_basis j |j. j \<in> (UNIV :: 'n set)}. f x y = g x y"
3.451 -    by blast
3.452 -  from bilinear_eq[OF bf bg equalityD2[OF span_stdbasis] equalityD2[OF span_stdbasis] th]
3.453 -  show ?thesis by blast
3.454 -qed
3.455 +  unfolding inner_simps scalar_mult_eq_scaleR by auto
3.456
3.457  lemma left_invertible_transpose:
3.458    "(\<exists>(B). B ** transpose (A) = mat (1::'a::comm_semiring_1)) \<longleftrightarrow> (\<exists>(B). A ** B = mat 1)"
3.459 @@ -1043,7 +685,7 @@
3.460          unfolding y[symmetric]
3.461          apply (rule span_setsum[OF fU])
3.462          apply clarify
3.463 -        unfolding smult_conv_scaleR
3.464 +        unfolding scalar_mult_eq_scaleR
3.465          apply (rule span_mul)
3.466          apply (rule span_superset)
3.467          unfolding columns_def
3.468 @@ -1056,7 +698,7 @@
3.469      let ?P = "\<lambda>(y::real ^'n). \<exists>(x::real^'m). setsum (\<lambda>i. (x\$i) *s column i A) ?U = y"
3.470      { fix y
3.471        have "?P y"
3.472 -      proof (rule span_induct_alt[of ?P "columns A", folded smult_conv_scaleR])
3.473 +      proof (rule span_induct_alt[of ?P "columns A", folded scalar_mult_eq_scaleR])
3.474          show "\<exists>x\<Colon>real ^ 'm. setsum (\<lambda>i. (x\$i) *s column i A) ?U = 0"
3.475            by (rule exI[where x=0], simp)
3.476        next
3.477 @@ -1159,25 +801,12 @@
3.478      dot_rowvector_columnvector matrix_transpose_mul matrix_mul_assoc ..
3.479
3.480
3.481 -lemma infnorm_cart:"infnorm (x::real^'n) = Sup {abs(x\$i) |i. i\<in> (UNIV :: 'n set)}"
3.482 -  unfolding infnorm_def apply(rule arg_cong[where f=Sup]) apply safe
3.483 -  apply(rule_tac x="\<pi> i" in exI) defer
3.484 -  apply(rule_tac x="\<pi>' i" in exI)
3.485 -  unfolding nth_conv_component
3.486 -  using pi'_range apply auto
3.487 -  done
3.488 -
3.489 -lemma infnorm_set_image_cart: "{abs(x\$i) |i. i\<in> (UNIV :: _ set)} =
3.490 -  (\<lambda>i. abs(x\$i)) ` (UNIV)" by blast
3.491 -
3.492 -lemma infnorm_set_lemma_cart:
3.493 -  "finite {abs((x::'a::abs ^'n)\$i) |i. i\<in> (UNIV :: 'n set)}"
3.494 -  "{abs(x\$i) |i. i\<in> (UNIV :: 'n::finite set)} \<noteq> {}"
3.495 -  unfolding infnorm_set_image_cart by auto
3.496 +lemma infnorm_cart:"infnorm (x::real^'n) = Sup {abs(x\$i) |i. i\<in>UNIV}"
3.497 +  by (simp add: infnorm_def inner_axis Basis_vec_def) (metis (lifting) inner_axis real_inner_1_right)
3.498
3.499  lemma component_le_infnorm_cart: "\<bar>x\$i\<bar> \<le> infnorm (x::real^'n)"
3.500 -  unfolding nth_conv_component
3.501 -  using component_le_infnorm[of x] .
3.502 +  using Basis_le_infnorm[of "axis i 1" x]
3.503 +  by (simp add: Basis_vec_def axis_eq_axis inner_axis)
3.504
3.505  lemma continuous_component: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. f x \$ i)"
3.506    unfolding continuous_def by (rule tendsto_vec_nth)
3.507 @@ -1371,7 +1000,7 @@
3.508      and "{c .. d} \<subseteq> {a<..<b} \<longleftrightarrow> (\<forall>i. c\$i \<le> d\$i) --> (\<forall>i. a\$i < c\$i \<and> d\$i < b\$i)" (is ?th2)
3.509      and "{c<..<d} \<subseteq> {a .. b} \<longleftrightarrow> (\<forall>i. c\$i < d\$i) --> (\<forall>i. a\$i \<le> c\$i \<and> d\$i \<le> b\$i)" (is ?th3)
3.510      and "{c<..<d} \<subseteq> {a<..<b} \<longleftrightarrow> (\<forall>i. c\$i < d\$i) --> (\<forall>i. a\$i \<le> c\$i \<and> d\$i \<le> b\$i)" (is ?th4)
3.511 -  using subset_interval[of c d a b] by (simp_all add: cart_simps real_euclidean_nth)
3.512 +  using subset_interval[of c d a b] by (simp_all add: Basis_vec_def inner_axis)
3.513
3.514  lemma disjoint_interval_cart:
3.515    fixes a::"real^'n"
3.516 @@ -1379,7 +1008,7 @@
3.517      and "{a .. b} \<inter> {c<..<d} = {} \<longleftrightarrow> (\<exists>i. (b\$i < a\$i \<or> d\$i \<le> c\$i \<or> b\$i \<le> c\$i \<or> d\$i \<le> a\$i))" (is ?th2)
3.518      and "{a<..<b} \<inter> {c .. d} = {} \<longleftrightarrow> (\<exists>i. (b\$i \<le> a\$i \<or> d\$i < c\$i \<or> b\$i \<le> c\$i \<or> d\$i \<le> a\$i))" (is ?th3)
3.519      and "{a<..<b} \<inter> {c<..<d} = {} \<longleftrightarrow> (\<exists>i. (b\$i \<le> a\$i \<or> d\$i \<le> c\$i \<or> b\$i \<le> c\$i \<or> d\$i \<le> a\$i))" (is ?th4)
3.520 -  using disjoint_interval[of a b c d] by (simp_all add: cart_simps real_euclidean_nth)
3.521 +  using disjoint_interval[of a b c d] by (simp_all add: Basis_vec_def inner_axis)
3.522
3.523  lemma inter_interval_cart:
3.524    fixes a :: "'a::linorder^'n"
3.525 @@ -1400,7 +1029,7 @@
3.526  lemma is_interval_cart:
3.527    "is_interval (s::(real^'n) set) \<longleftrightarrow>
3.528      (\<forall>a\<in>s. \<forall>b\<in>s. \<forall>x. (\<forall>i. ((a\$i \<le> x\$i \<and> x\$i \<le> b\$i) \<or> (b\$i \<le> x\$i \<and> x\$i \<le> a\$i))) \<longrightarrow> x \<in> s)"
3.529 -  by (simp add: is_interval_def Ball_def cart_simps real_euclidean_nth)
3.530 +  by (simp add: is_interval_def Ball_def Basis_vec_def inner_axis imp_ex)
3.531
3.532  lemma closed_halfspace_component_le_cart: "closed {x::real^'n. x\$i \<le> a}"
3.534 @@ -1416,27 +1045,15 @@
3.535
3.536  lemma Lim_component_le_cart:
3.537    fixes f :: "'a \<Rightarrow> real^'n"
3.538 -  assumes "(f ---> l) net" "\<not> (trivial_limit net)"  "eventually (\<lambda>x. f(x)\$i \<le> b) net"
3.539 +  assumes "(f ---> l) net" "\<not> (trivial_limit net)"  "eventually (\<lambda>x. f x \$i \<le> b) net"
3.540    shows "l\$i \<le> b"
3.541 -proof -
3.542 -  { fix x
3.543 -    have "x \<in> {x::real^'n. inner (cart_basis i) x \<le> b} \<longleftrightarrow> x\$i \<le> b"
3.544 -      unfolding inner_basis by auto }
3.545 -  then show ?thesis using Lim_in_closed_set[of "{x. inner (cart_basis i) x \<le> b}" f net l]
3.546 -    using closed_halfspace_le[of "(cart_basis i)::real^'n" b] and assms(1,2,3) by auto
3.547 -qed
3.548 +  by (rule tendsto_le[OF assms(2) tendsto_const tendsto_vec_nth, OF assms(1, 3)])
3.549
3.550  lemma Lim_component_ge_cart:
3.551    fixes f :: "'a \<Rightarrow> real^'n"
3.552    assumes "(f ---> l) net"  "\<not> (trivial_limit net)"  "eventually (\<lambda>x. b \<le> (f x)\$i) net"
3.553    shows "b \<le> l\$i"
3.554 -proof -
3.555 -  { fix x
3.556 -    have "x \<in> {x::real^'n. inner (cart_basis i) x \<ge> b} \<longleftrightarrow> x\$i \<ge> b"
3.557 -      unfolding inner_basis by auto }
3.558 -  then show ?thesis using Lim_in_closed_set[of "{x. inner (cart_basis i) x \<ge> b}" f net l]
3.559 -    using closed_halfspace_ge[of b "(cart_basis i)::real^'n"] and assms(1,2,3) by auto
3.560 -qed
3.561 +  by (rule tendsto_le[OF assms(2) tendsto_vec_nth tendsto_const, OF assms(1, 3)])
3.562
3.563  lemma Lim_component_eq_cart:
3.564    fixes f :: "'a \<Rightarrow> real^'n"
3.565 @@ -1449,8 +1066,8 @@
3.566  lemma connected_ivt_component_cart:
3.567    fixes x :: "real^'n"
3.568    shows "connected s \<Longrightarrow> x \<in> s \<Longrightarrow> y \<in> s \<Longrightarrow> x\$k \<le> a \<Longrightarrow> a \<le> y\$k \<Longrightarrow> (\<exists>z\<in>s.  z\$k = a)"
3.569 -  using connected_ivt_hyperplane[of s x y "(cart_basis k)::real^'n" a]
3.570 -  by (auto simp add: inner_basis)
3.571 +  using connected_ivt_hyperplane[of s x y "axis k 1" a]
3.572 +  by (auto simp add: inner_axis inner_commute)
3.573
3.574  lemma subspace_substandard_cart: "subspace {x::real^_. (\<forall>i. P i \<longrightarrow> x\$i = 0)}"
3.575    unfolding subspace_def by auto
3.576 @@ -1468,20 +1085,14 @@
3.577  lemma dim_substandard_cart: "dim {x::real^'n. \<forall>i. i \<notin> d \<longrightarrow> x\$i = 0} = card d"
3.578    (is "dim ?A = _")
3.579  proof -
3.580 -  have *: "{x. \<forall>i<DIM((real, 'n) vec). i \<notin> \<pi>' ` d \<longrightarrow> x \$\$ i = 0} =
3.581 -      {x::real^'n. \<forall>i. i \<notin> d \<longrightarrow> x\$i = 0}"
3.582 -    apply safe
3.583 -    apply (erule_tac x="\<pi>' i" in allE) defer
3.584 -    apply (erule_tac x="\<pi> i" in allE)
3.585 -    unfolding image_iff real_euclidean_nth[symmetric]
3.586 -    apply (auto simp: pi'_inj[THEN inj_eq])
3.587 -    done
3.588 -  have " \<pi>' ` d \<subseteq> {..<DIM((real, 'n) vec)}"
3.589 -    using pi'_range[where 'n='n] by auto
3.590 +  let ?a = "\<lambda>x. axis x 1 :: real^'n"
3.591 +  have *: "{x. \<forall>i\<in>Basis. i \<notin> ?a ` d \<longrightarrow> x \<bullet> i = 0} = ?A"
3.592 +    by (auto simp: image_iff Basis_vec_def axis_eq_axis inner_axis)
3.593 +  have "?a ` d \<subseteq> Basis"
3.594 +    by (auto simp: Basis_vec_def)
3.595    thus ?thesis
3.596 -    using dim_substandard[of "\<pi>' ` d", where 'a="real^'n"]
3.597 -    unfolding * using card_image[of "\<pi>'" d] using pi'_inj unfolding inj_on_def
3.598 -    by auto
3.599 +    using dim_substandard[of "?a ` d"] card_image[of ?a d]
3.600 +    by (auto simp: axis_eq_axis inj_on_def *)
3.601  qed
3.602
3.603  lemma affinity_inverses:
3.604 @@ -1513,32 +1124,24 @@
3.605    using vector_affinity_eq[where m=m and x=x and y=y and c=c]
3.606    by metis
3.607
3.608 -lemma const_vector_cart:"((\<chi> i. d)::real^'n) = (\<chi>\<chi> i. d)"
3.609 -  apply(subst euclidean_eq)
3.610 -proof safe
3.611 -  case goal1
3.612 -  hence *: "(basis i::real^'n) = cart_basis (\<pi> i)"
3.613 -    unfolding basis_real_n[symmetric] by auto
3.614 -  have "((\<chi> i. d)::real^'n) \$\$ i = d" unfolding euclidean_component_def *
3.615 -    unfolding dot_basis by auto
3.616 -  thus ?case using goal1 by auto
3.617 -qed
3.618 -
3.619 +lemma vector_cart:
3.620 +  fixes f :: "real^'n \<Rightarrow> real"
3.621 +  shows "(\<chi> i. f (axis i 1)) = (\<Sum>i\<in>Basis. f i *\<^sub>R i)"
3.622 +  unfolding euclidean_eq_iff[where 'a="real^'n"]
3.623 +  by simp (simp add: Basis_vec_def inner_axis)
3.624 +
3.625 +lemma const_vector_cart:"((\<chi> i. d)::real^'n) = (\<Sum>i\<in>Basis. d *\<^sub>R i)"
3.626 +  by (rule vector_cart)
3.627
3.628  subsection "Convex Euclidean Space"
3.629
3.630 -lemma Cart_1:"(1::real^'n) = (\<chi>\<chi> i. 1)"
3.631 -  apply(subst euclidean_eq)
3.632 -proof safe
3.633 -  case goal1
3.634 -  thus ?case
3.635 -    using nth_conv_component[THEN sym,where i1="\<pi> i" and x1="1::real^'n"] by auto
3.636 -qed
3.637 +lemma Cart_1:"(1::real^'n) = \<Sum>Basis"
3.638 +  using const_vector_cart[of 1] by (simp add: one_vec_def)
3.639
3.640  declare vector_add_ldistrib[simp] vector_ssub_ldistrib[simp] vector_smult_assoc[simp] vector_smult_rneg[simp]
3.642
3.643 -lemmas vector_component_simps = vector_minus_component vector_smult_component vector_add_component less_eq_vec_def vec_lambda_beta basis_component vector_uminus_component
3.644 +lemmas vector_component_simps = vector_minus_component vector_smult_component vector_add_component less_eq_vec_def vec_lambda_beta vector_uminus_component
3.645
3.646  lemma convex_box_cart:
3.647    assumes "\<And>i. convex {x. P i x}"
3.648 @@ -1551,95 +1154,20 @@
3.649  lemma unit_interval_convex_hull_cart:
3.650    "{0::real^'n .. 1} = convex hull {x. \<forall>i. (x\$i = 0) \<or> (x\$i = 1)}" (is "?int = convex hull ?points")
3.651    unfolding Cart_1 unit_interval_convex_hull[where 'a="real^'n"]
3.652 -  apply(rule arg_cong[where f="\<lambda>x. convex hull x"]) apply(rule set_eqI) unfolding mem_Collect_eq
3.653 -  apply safe apply(erule_tac x="\<pi>' i" in allE) unfolding nth_conv_component defer
3.654 -  apply(erule_tac x="\<pi> i" in allE)
3.655 -  apply auto
3.656 -  done
3.657 +  by (rule arg_cong[where f="\<lambda>x. convex hull x"]) (simp add: Basis_vec_def inner_axis)
3.658
3.659  lemma cube_convex_hull_cart:
3.660    assumes "0 < d"
3.661    obtains s::"(real^'n) set"
3.662      where "finite s" "{x - (\<chi> i. d) .. x + (\<chi> i. d)} = convex hull s"
3.663  proof -
3.664 -  obtain s where s: "finite s" "{x - (\<chi>\<chi> i. d)..x + (\<chi>\<chi> i. d)} = convex hull s"
3.665 -    by (rule cube_convex_hull [OF assms])
3.666 -  show thesis
3.667 -    apply(rule that[OF s(1)]) unfolding s(2)[symmetric] const_vector_cart ..
3.668 +  from cube_convex_hull [OF assms, of x] guess s .
3.669 +  with that[of s] show thesis by (simp add: const_vector_cart)
3.670  qed
3.671
3.672 -lemma std_simplex_cart:
3.673 -  "(insert (0::real^'n) { cart_basis i | i. i\<in>UNIV}) =
3.674 -    (insert 0 { basis i | i. i<DIM((real,'n) vec)})"
3.675 -  apply (rule arg_cong[where f="\<lambda>s. (insert 0 s)"])
3.676 -  unfolding basis_real_n[symmetric]
3.677 -  apply safe
3.678 -  apply (rule_tac x="\<pi>' i" in exI) defer
3.679 -  apply (rule_tac x="\<pi> i" in exI) using pi'_range[where 'n='n]
3.680 -  apply auto
3.681 -  done
3.682 -
3.683 -
3.684 -subsection "Brouwer Fixpoint"
3.685 -
3.686 -lemma kuhn_labelling_lemma_cart:
3.687 -  assumes "(\<forall>x::real^_. P x \<longrightarrow> P (f x))"  "\<forall>x. P x \<longrightarrow> (\<forall>i. Q i \<longrightarrow> 0 \<le> x\$i \<and> x\$i \<le> 1)"
3.688 -  shows "\<exists>l. (\<forall>x i. l x i \<le> (1::nat)) \<and>
3.689 -             (\<forall>x i. P x \<and> Q i \<and> (x\$i = 0) \<longrightarrow> (l x i = 0)) \<and>
3.690 -             (\<forall>x i. P x \<and> Q i \<and> (x\$i = 1) \<longrightarrow> (l x i = 1)) \<and>
3.691 -             (\<forall>x i. P x \<and> Q i \<and> (l x i = 0) \<longrightarrow> x\$i \<le> f(x)\$i) \<and>
3.692 -             (\<forall>x i. P x \<and> Q i \<and> (l x i = 1) \<longrightarrow> f(x)\$i \<le> x\$i)"
3.693 -proof -
3.694 -  have and_forall_thm:"\<And>P Q. (\<forall>x. P x) \<and> (\<forall>x. Q x) \<longleftrightarrow> (\<forall>x. P x \<and> Q x)"
3.695 -    by auto
3.696 -  have *: "\<forall>x y::real. 0 \<le> x \<and> x \<le> 1 \<and> 0 \<le> y \<and> y \<le> 1 \<longrightarrow> (x \<noteq> 1 \<and> x \<le> y \<or> x \<noteq> 0 \<and> y \<le> x)"
3.697 -    by auto
3.698 -  show ?thesis
3.699 -    unfolding and_forall_thm apply(subst choice_iff[symmetric])+
3.700 -  proof (rule, rule)
3.701 -    case goal1
3.702 -    let ?R = "\<lambda>y. (P x \<and> Q xa \<and> x \$ xa = 0 \<longrightarrow> y = (0::nat)) \<and>
3.703 -        (P x \<and> Q xa \<and> x \$ xa = 1 \<longrightarrow> y = 1) \<and>
3.704 -        (P x \<and> Q xa \<and> y = 0 \<longrightarrow> x \$ xa \<le> f x \$ xa) \<and>
3.705 -        (P x \<and> Q xa \<and> y = 1 \<longrightarrow> f x \$ xa \<le> x \$ xa)"
3.706 -    { assume "P x" "Q xa"
3.707 -      hence "0 \<le> f x \$ xa \<and> f x \$ xa \<le> 1"
3.708 -        using assms(2)[rule_format,of "f x" xa]
3.709 -        apply (drule_tac assms(1)[rule_format])
3.710 -        apply auto
3.711 -        done
3.712 -    }
3.713 -    hence "?R 0 \<or> ?R 1" by auto
3.714 -    thus ?case by auto
3.715 -  qed
3.716 -qed
3.717 -
3.718 -lemma interval_bij_cart:"interval_bij = (\<lambda> (a,b) (u,v) (x::real^'n).
3.719 -    (\<chi> i. u\$i + (x\$i - a\$i) / (b\$i - a\$i) * (v\$i - u\$i))::real^'n)"
3.720 -  unfolding interval_bij_def apply(rule ext)+ apply safe
3.721 -  unfolding vec_eq_iff vec_lambda_beta unfolding nth_conv_component
3.722 -  apply rule
3.723 -  apply (subst euclidean_lambda_beta)
3.724 -  using pi'_range apply auto
3.725 -  done
3.726 -
3.727 -lemma interval_bij_affine_cart:
3.728 - "interval_bij (a,b) (u,v) = (\<lambda>x. (\<chi> i. (v\$i - u\$i) / (b\$i - a\$i) * x\$i) +
3.729 -            (\<chi> i. u\$i - (v\$i - u\$i) / (b\$i - a\$i) * a\$i)::real^'n)"
3.730 -  apply rule
3.731 -  unfolding vec_eq_iff interval_bij_cart vector_component_simps
3.733 -  done
3.734 -
3.735
3.736  subsection "Derivative"
3.737
3.738 -lemma has_derivative_vmul_component_cart:
3.739 -  fixes c :: "real^'a \<Rightarrow> real^'b" and v :: "real^'c"
3.740 -  assumes "(c has_derivative c') net"
3.741 -  shows "((\<lambda>x. c(x)\$k *\<^sub>R v) has_derivative (\<lambda>x. (c' x)\$k *\<^sub>R v)) net"
3.742 -  unfolding nth_conv_component by (intro has_derivative_intros assms)
3.743 -
3.744  lemma differentiable_at_imp_differentiable_on:
3.745    "(\<forall>x\<in>(s::(real^'n) set). f differentiable at x) \<Longrightarrow> f differentiable_on s"
3.746    unfolding differentiable_on_def by(auto intro!: differentiable_at_withinI)
3.747 @@ -1662,56 +1190,14 @@
3.748  subsection {* Component of the differential must be zero if it exists at a local
3.749    maximum or minimum for that corresponding component. *}
3.750
3.751 -lemma differential_zero_maxmin_component:
3.752 +lemma differential_zero_maxmin_cart:
3.753    fixes f::"real^'a \<Rightarrow> real^'b"
3.754    assumes "0 < e" "((\<forall>y \<in> ball x e. (f y)\$k \<le> (f x)\$k) \<or> (\<forall>y\<in>ball x e. (f x)\$k \<le> (f y)\$k))"
3.755 -    "f differentiable (at x)" shows "jacobian f (at x) \$ k = 0"
3.756 -(* FIXME: reuse proof of generic differential_zero_maxmin_component*)
3.757 -proof (rule ccontr)
3.758 -  def D \<equiv> "jacobian f (at x)"
3.759 -  assume "jacobian f (at x) \$ k \<noteq> 0"
3.760 -  then obtain j where j:"D\$k\$j \<noteq> 0" unfolding vec_eq_iff D_def by auto
3.761 -  hence *: "abs (jacobian f (at x) \$ k \$ j) / 2 > 0"
3.762 -    unfolding D_def by auto
3.763 -  note as = assms(3)[unfolded jacobian_works has_derivative_at_alt]
3.764 -  guess e' using as[THEN conjunct2,rule_format,OF *] .. note e' = this
3.765 -  guess d using real_lbound_gt_zero[OF assms(1) e'[THEN conjunct1]] .. note d = this
3.766 -  { fix c
3.767 -    assume "abs c \<le> d"
3.768 -    hence *:"norm (x + c *\<^sub>R cart_basis j - x) < e'"
3.769 -      using norm_basis[of j] d by auto
3.770 -    have "\<bar>(f (x + c *\<^sub>R cart_basis j) - f x - D *v (c *\<^sub>R cart_basis j)) \$ k\<bar> \<le>
3.771 -        norm (f (x + c *\<^sub>R cart_basis j) - f x - D *v (c *\<^sub>R cart_basis j))"
3.772 -      by (rule component_le_norm_cart)
3.773 -    also have "\<dots> \<le> \<bar>D \$ k \$ j\<bar> / 2 * \<bar>c\<bar>"
3.774 -      using e'[THEN conjunct2,rule_format,OF *] and norm_basis[of j]
3.775 -      unfolding D_def[symmetric] by auto
3.776 -    finally
3.777 -    have "\<bar>(f (x + c *\<^sub>R cart_basis j) - f x - D *v (c *\<^sub>R cart_basis j)) \$ k\<bar> \<le>
3.778 -      \<bar>D \$ k \$ j\<bar> / 2 * \<bar>c\<bar>" by simp
3.779 -    hence "\<bar>f (x + c *\<^sub>R cart_basis j) \$ k - f x \$ k - c * D \$ k \$ j\<bar> \<le>
3.780 -      \<bar>D \$ k \$ j\<bar> / 2 * \<bar>c\<bar>"
3.781 -      unfolding vector_component_simps matrix_vector_mul_component
3.782 -      unfolding smult_conv_scaleR[symmetric]
3.783 -      unfolding inner_simps dot_basis smult_conv_scaleR by simp
3.784 -  } note * = this
3.785 -  have "x + d *\<^sub>R cart_basis j \<in> ball x e" "x - d *\<^sub>R cart_basis j \<in> ball x e"
3.786 -    unfolding mem_ball dist_norm using norm_basis[of j] d by auto
3.787 -  hence **: "((f (x - d *\<^sub>R cart_basis j))\$k \<le> (f x)\$k \<and> (f (x + d *\<^sub>R cart_basis j))\$k \<le> (f x)\$k) \<or>
3.788 -      ((f (x - d *\<^sub>R cart_basis j))\$k \<ge> (f x)\$k \<and> (f (x + d *\<^sub>R cart_basis j))\$k \<ge> (f x)\$k)"
3.789 -    using assms(2) by auto
3.790 -  have ***: "\<And>y y1 y2 d dx::real. (y1\<le>y\<and>y2\<le>y) \<or> (y\<le>y1\<and>y\<le>y2) \<Longrightarrow>
3.791 -    d < abs dx \<Longrightarrow> abs(y1 - y - - dx) \<le> d \<Longrightarrow> (abs (y2 - y - dx) \<le> d) \<Longrightarrow> False" by arith
3.792 -  show False
3.793 -    apply (rule ***[OF **, where dx="d * D \$ k \$ j" and d="\<bar>D \$ k \$ j\<bar> / 2 * \<bar>d\<bar>"])
3.794 -    using *[of "-d"] and *[of d] and d[THEN conjunct1] and j
3.795 -    unfolding mult_minus_left
3.796 -    unfolding abs_mult diff_minus_eq_add scaleR_minus_left
3.797 -    unfolding algebra_simps
3.798 -    apply (auto intro: mult_pos_pos)
3.799 -    done
3.800 -qed
3.801 -
3.802 +    "f differentiable (at x)"
3.803 +  shows "jacobian f (at x) \$ k = 0"
3.804 +  using differential_zero_maxmin_component[of "axis k 1" e x f] assms
3.805 +    vector_cart[of "\<lambda>j. frechet_derivative f (at x) j \$ k"]
3.806 +  by (simp add: Basis_vec_def axis_eq_axis inner_axis jacobian_def matrix_def)
3.807
3.808  subsection {* Lemmas for working on @{typ "real^1"} *}
3.809
3.810 @@ -1775,25 +1261,6 @@
3.811
3.812  end
3.813
3.814 -(* "lift" from 'a to 'a^1 and "drop" from 'a^1 to 'a -- FIXME: potential use of transfer *)
3.815 -
3.816 -abbreviation vec1:: "'a \<Rightarrow> 'a ^ 1" where "vec1 x \<equiv> vec x"
3.817 -
3.818 -abbreviation dest_vec1:: "'a ^1 \<Rightarrow> 'a" where "dest_vec1 x \<equiv> (x\$1)"
3.819 -
3.820 -lemma vec1_dest_vec1[simp]: "vec1(dest_vec1 x) = x"
3.821 -  by (simp add: vec_eq_iff)
3.822 -
3.823 -lemma forall_vec1: "(\<forall>x. P x) \<longleftrightarrow> (\<forall>x. P (vec1 x))"
3.824 -  by (metis vec1_dest_vec1(1))
3.825 -
3.826 -lemma exists_vec1: "(\<exists>x. P x) \<longleftrightarrow> (\<exists>x. P(vec1 x))"
3.827 -  by (metis vec1_dest_vec1(1))
3.828 -
3.829 -lemma dest_vec1_eq[simp]: "dest_vec1 x = dest_vec1 y \<longleftrightarrow> x = y"
3.830 -  by (metis vec1_dest_vec1(1))
3.831 -
3.832 -
3.833  subsection{* The collapse of the general concepts to dimension one. *}
3.834
3.835  lemma vector_one: "(x::'a ^1) = (\<chi> i. (x\$1))"
3.836 @@ -1863,438 +1330,10 @@
3.838    done
3.839
3.840 -lemma range_vec1[simp]:"range vec1 = UNIV"
3.841 -  apply (rule set_eqI,rule) unfolding image_iff defer
3.842 -  apply (rule_tac x="dest_vec1 x" in bexI)
3.843 -  apply auto
3.844 -  done
3.845 -
3.846 -lemma dest_vec1_lambda: "dest_vec1(\<chi> i. x i) = x 1"
3.847 -  by simp
3.848 -
3.849 -lemma dest_vec1_vec: "dest_vec1(vec x) = x"
3.850 -  by simp
3.851 -
3.852 -lemma dest_vec1_sum: assumes fS: "finite S"
3.853 -  shows "dest_vec1(setsum f S) = setsum (dest_vec1 o f) S"
3.854 -  apply (induct rule: finite_induct[OF fS])
3.855 -  apply simp
3.856 -  apply auto
3.857 -  done
3.858 -
3.859 -lemma norm_vec1 [simp]: "norm(vec1 x) = abs(x)"
3.860 -  by (simp add: vec_def norm_real)
3.861 -
3.862 -lemma dist_vec1: "dist(vec1 x) (vec1 y) = abs(x - y)"
3.863 -  by (simp only: dist_real vec_component)
3.864 -lemma abs_dest_vec1: "norm x = \<bar>dest_vec1 x\<bar>"
3.865 -  by (metis vec1_dest_vec1(1) norm_vec1)
3.866 -
3.867 -lemmas vec1_dest_vec1_simps =
3.868 -  forall_vec1 vec_add[symmetric] dist_vec1 vec_sub[symmetric] vec1_dest_vec1 norm_vec1 vector_smult_component
3.869 -  vec_inj[where 'b=1] vec_cmul[symmetric] smult_conv_scaleR[symmetric] o_def dist_real_def real_norm_def
3.870 -
3.871 -lemma bounded_linear_vec1: "bounded_linear (vec1::real\<Rightarrow>real^1)"
3.872 -  unfolding bounded_linear_def additive_def bounded_linear_axioms_def
3.873 -  unfolding smult_conv_scaleR[symmetric]
3.874 -  unfolding vec1_dest_vec1_simps
3.875 -  apply (rule conjI) defer
3.876 -  apply (rule conjI) defer
3.877 -  apply (rule_tac x=1 in exI)
3.878 -  apply auto
3.879 -  done
3.880 -
3.881 -lemma linear_vmul_dest_vec1:
3.882 -  fixes f:: "real^_ \<Rightarrow> real^1"
3.883 -  shows "linear f \<Longrightarrow> linear (\<lambda>x. dest_vec1(f x) *s v)"
3.884 -  unfolding smult_conv_scaleR
3.885 -  by (rule linear_vmul_component)
3.886 -
3.887 -lemma linear_from_scalars:
3.888 -  assumes lf: "linear (f::real^1 \<Rightarrow> real^_)"
3.889 -  shows "f = (\<lambda>x. dest_vec1 x *s column 1 (matrix f))"
3.890 -  unfolding smult_conv_scaleR
3.891 -  apply (rule ext)
3.892 -  apply (subst matrix_works[OF lf, symmetric])
3.893 -  apply (auto simp add: vec_eq_iff matrix_vector_mult_def column_def mult_commute)
3.894 -  done
3.895 -
3.896 -lemma linear_to_scalars:
3.897 -  assumes lf: "linear (f::real ^'n \<Rightarrow> real^1)"
3.898 -  shows "f = (\<lambda>x. vec1(row 1 (matrix f) \<bullet> x))"
3.899 -  apply (rule ext)
3.900 -  apply (subst matrix_works[OF lf, symmetric])
3.901 -  apply (simp add: vec_eq_iff matrix_vector_mult_def row_def inner_vec_def mult_commute)
3.902 -  done
3.903 -
3.904 -lemma dest_vec1_eq_0: "dest_vec1 x = 0 \<longleftrightarrow> x = 0"
3.905 -  by (simp add: dest_vec1_eq[symmetric])
3.906 -
3.907 -lemma setsum_scalars:
3.908 -  assumes fS: "finite S"
3.909 -  shows "setsum f S = vec1 (setsum (dest_vec1 o f) S)"
3.910 -  unfolding vec_setsum[OF fS] by simp
3.911 -
3.912 -lemma dest_vec1_wlog_le:
3.913 -  "(\<And>(x::'a::linorder ^ 1) y. P x y \<longleftrightarrow> P y x)
3.914 -    \<Longrightarrow> (\<And>x y. dest_vec1 x <= dest_vec1 y ==> P x y) \<Longrightarrow> P x y"
3.915 -  apply (cases "dest_vec1 x \<le> dest_vec1 y")
3.916 -  apply simp
3.917 -  apply (subgoal_tac "dest_vec1 y \<le> dest_vec1 x")
3.918 -  apply auto
3.919 -  done
3.920 -
3.921 -text{* Lifting and dropping *}
3.922 -
3.923 -lemma continuous_on_o_dest_vec1:
3.924 -  fixes f::"real \<Rightarrow> 'a::real_normed_vector"
3.925 -  assumes "continuous_on {a..b::real} f"
3.926 -  shows "continuous_on {vec1 a..vec1 b} (f o dest_vec1)"
3.927 -  using assms unfolding continuous_on_iff apply safe
3.928 -  apply (erule_tac x="x\$1" in ballE,erule_tac x=e in allE)
3.929 -  apply safe
3.930 -  apply (rule_tac x=d in exI)
3.931 -  apply safe
3.932 -  unfolding o_def dist_real_def dist_real
3.933 -  apply (erule_tac x="dest_vec1 x'" in ballE)
3.934 -  apply (auto simp add:less_eq_vec_def)
3.935 -  done
3.936 -
3.937 -lemma continuous_on_o_vec1:
3.938 -  fixes f::"real^1 \<Rightarrow> 'a::real_normed_vector"
3.939 -  assumes "continuous_on {a..b} f"
3.940 -  shows "continuous_on {dest_vec1 a..dest_vec1 b} (f o vec1)"
3.941 -  using assms unfolding continuous_on_iff
3.942 -  apply safe
3.943 -  apply (erule_tac x="vec x" in ballE,erule_tac x=e in allE)
3.944 -  apply safe
3.945 -  apply (rule_tac x=d in exI)
3.946 -  apply safe
3.947 -  unfolding o_def dist_real_def dist_real
3.948 -  apply (erule_tac x="vec1 x'" in ballE)
3.949 -  apply (auto simp add:less_eq_vec_def)
3.950 -  done
3.951 -
3.952 -lemma continuous_on_vec1:"continuous_on A (vec1::real\<Rightarrow>real^1)"
3.953 -  by (rule linear_continuous_on[OF bounded_linear_vec1])
3.954 -
3.955 -lemma mem_interval_1:
3.956 -  fixes x :: "real^1"
3.957 -  shows "(x \<in> {a .. b} \<longleftrightarrow> dest_vec1 a \<le> dest_vec1 x \<and> dest_vec1 x \<le> dest_vec1 b)"
3.958 -    and "(x \<in> {a<..<b} \<longleftrightarrow> dest_vec1 a < dest_vec1 x \<and> dest_vec1 x < dest_vec1 b)"
3.959 -  by (simp_all add: vec_eq_iff less_vec_def less_eq_vec_def)
3.960 -
3.961 -lemma vec1_interval:
3.962 -  fixes a::"real"
3.963 -  shows "vec1 ` {a .. b} = {vec1 a .. vec1 b}"
3.964 -    and "vec1 ` {a<..<b} = {vec1 a<..<vec1 b}"
3.965 -  apply (rule_tac[!] set_eqI)
3.966 -  unfolding image_iff less_vec_def
3.967 -  unfolding mem_interval_cart
3.968 -  unfolding forall_1 vec1_dest_vec1_simps
3.969 -  apply rule defer
3.970 -  apply (rule_tac x="dest_vec1 x" in bexI) prefer 3
3.971 -  apply rule defer
3.972 -  apply (rule_tac x="dest_vec1 x" in bexI)
3.973 -  apply auto
3.974 -  done
3.975 -
3.976 -(* Some special cases for intervals in R^1.                                  *)
3.977 -
3.978 -lemma interval_cases_1:
3.979 -  fixes x :: "real^1"
3.980 -  shows "x \<in> {a .. b} ==> x \<in> {a<..<b} \<or> (x = a) \<or> (x = b)"
3.981 -  unfolding vec_eq_iff less_vec_def less_eq_vec_def mem_interval_cart
3.982 -  by (auto simp del:dest_vec1_eq)
3.983 -
3.984 -lemma in_interval_1:
3.985 -  fixes x :: "real^1"
3.986 -  shows "(x \<in> {a .. b} \<longleftrightarrow> dest_vec1 a \<le> dest_vec1 x \<and> dest_vec1 x \<le> dest_vec1 b) \<and>
3.987 -    (x \<in> {a<..<b} \<longleftrightarrow> dest_vec1 a < dest_vec1 x \<and> dest_vec1 x < dest_vec1 b)"
3.988 -  unfolding vec_eq_iff less_vec_def less_eq_vec_def mem_interval_cart
3.989 -  by (auto simp del:dest_vec1_eq)
3.990 -
3.991 -lemma interval_eq_empty_1:
3.992 -  fixes a :: "real^1"
3.993 -  shows "{a .. b} = {} \<longleftrightarrow> dest_vec1 b < dest_vec1 a"
3.994 -    and "{a<..<b} = {} \<longleftrightarrow> dest_vec1 b \<le> dest_vec1 a"
3.995 -  unfolding interval_eq_empty_cart and ex_1 by auto
3.996 -
3.997 -lemma subset_interval_1:
3.998 -  fixes a :: "real^1"
3.999 -  shows "({a .. b} \<subseteq> {c .. d} \<longleftrightarrow>  dest_vec1 b < dest_vec1 a \<or>
3.1000 -    dest_vec1 c \<le> dest_vec1 a \<and> dest_vec1 a \<le> dest_vec1 b \<and> dest_vec1 b \<le> dest_vec1 d)"
3.1001 -   "({a .. b} \<subseteq> {c<..<d} \<longleftrightarrow>  dest_vec1 b < dest_vec1 a \<or>
3.1002 -    dest_vec1 c < dest_vec1 a \<and> dest_vec1 a \<le> dest_vec1 b \<and> dest_vec1 b < dest_vec1 d)"
3.1003 -   "({a<..<b} \<subseteq> {c .. d} \<longleftrightarrow>  dest_vec1 b \<le> dest_vec1 a \<or>
3.1004 -    dest_vec1 c \<le> dest_vec1 a \<and> dest_vec1 a < dest_vec1 b \<and> dest_vec1 b \<le> dest_vec1 d)"
3.1005 -   "({a<..<b} \<subseteq> {c<..<d} \<longleftrightarrow> dest_vec1 b \<le> dest_vec1 a \<or>
3.1006 -    dest_vec1 c \<le> dest_vec1 a \<and> dest_vec1 a < dest_vec1 b \<and> dest_vec1 b \<le> dest_vec1 d)"
3.1007 -  unfolding subset_interval_cart[of a b c d] unfolding forall_1 by auto
3.1008 -
3.1009 -lemma eq_interval_1:
3.1010 -  fixes a :: "real^1"
3.1011 -  shows "{a .. b} = {c .. d} \<longleftrightarrow>
3.1012 -          dest_vec1 b < dest_vec1 a \<and> dest_vec1 d < dest_vec1 c \<or>
3.1013 -          dest_vec1 a = dest_vec1 c \<and> dest_vec1 b = dest_vec1 d"
3.1014 -  unfolding set_eq_subset[of "{a .. b}" "{c .. d}"]
3.1015 -  unfolding subset_interval_1(1)[of a b c d]
3.1016 -  unfolding subset_interval_1(1)[of c d a b]
3.1017 -  by auto
3.1018 -
3.1019 -lemma disjoint_interval_1:
3.1020 -  fixes a :: "real^1"
3.1021 -  shows
3.1022 -    "{a .. b} \<inter> {c .. d} = {} \<longleftrightarrow>
3.1023 -      dest_vec1 b < dest_vec1 a \<or> dest_vec1 d < dest_vec1 c  \<or>  dest_vec1 b < dest_vec1 c \<or> dest_vec1 d < dest_vec1 a"
3.1024 -    "{a .. b} \<inter> {c<..<d} = {} \<longleftrightarrow>
3.1025 -      dest_vec1 b < dest_vec1 a \<or> dest_vec1 d \<le> dest_vec1 c  \<or>  dest_vec1 b \<le> dest_vec1 c \<or> dest_vec1 d \<le> dest_vec1 a"
3.1026 -    "{a<..<b} \<inter> {c .. d} = {} \<longleftrightarrow>
3.1027 -      dest_vec1 b \<le> dest_vec1 a \<or> dest_vec1 d < dest_vec1 c  \<or>  dest_vec1 b \<le> dest_vec1 c \<or> dest_vec1 d \<le> dest_vec1 a"
3.1028 -    "{a<..<b} \<inter> {c<..<d} = {} \<longleftrightarrow>
3.1029 -      dest_vec1 b \<le> dest_vec1 a \<or> dest_vec1 d \<le> dest_vec1 c  \<or>  dest_vec1 b \<le> dest_vec1 c \<or> dest_vec1 d \<le> dest_vec1 a"
3.1030 -  unfolding disjoint_interval_cart and ex_1 by auto
3.1031 -
3.1032 -lemma open_closed_interval_1:
3.1033 -  fixes a :: "real^1"
3.1034 -  shows "{a<..<b} = {a .. b} - {a, b}"
3.1035 -  unfolding set_eq_iff apply simp
3.1036 -  unfolding less_vec_def and less_eq_vec_def and forall_1 and dest_vec1_eq[symmetric]
3.1037 -  apply (auto simp del:dest_vec1_eq)
3.1038 -  done
3.1039 -
3.1040 -lemma closed_open_interval_1:
3.1041 -  "dest_vec1 (a::real^1) \<le> dest_vec1 b ==> {a .. b} = {a<..<b} \<union> {a,b}"
3.1042 -  unfolding set_eq_iff
3.1043 -  apply simp
3.1044 -  unfolding less_vec_def and less_eq_vec_def and forall_1 and dest_vec1_eq[symmetric]
3.1045 -  apply (auto simp del:dest_vec1_eq)
3.1046 -  done
3.1047 -
3.1048 -lemma Lim_drop_le:
3.1049 -  fixes f :: "'a \<Rightarrow> real^1"
3.1050 -  shows "(f ---> l) net \<Longrightarrow> \<not> trivial_limit net \<Longrightarrow>
3.1051 -    eventually (\<lambda>x. dest_vec1 (f x) \<le> b) net ==> dest_vec1 l \<le> b"
3.1052 -  using Lim_component_le_cart[of f l net 1 b] by auto
3.1053 -
3.1054 -lemma Lim_drop_ge:
3.1055 -  fixes f :: "'a \<Rightarrow> real^1"
3.1056 -  shows "(f ---> l) net \<Longrightarrow> \<not> trivial_limit net \<Longrightarrow>
3.1057 -    eventually (\<lambda>x. b \<le> dest_vec1 (f x)) net ==> b \<le> dest_vec1 l"
3.1058 -  using Lim_component_ge_cart[of f l net b 1] by auto
3.1059 -
3.1060 -
3.1061 -text{* Also more convenient formulations of monotone convergence.                *}
3.1062 -
3.1063 -lemma bounded_increasing_convergent:
3.1064 -  fixes s :: "nat \<Rightarrow> real^1"
3.1065 -  assumes "bounded {s n| n::nat. True}"  "\<forall>n. dest_vec1(s n) \<le> dest_vec1(s(Suc n))"
3.1066 -  shows "\<exists>l. (s ---> l) sequentially"
3.1067 -proof -
3.1068 -  obtain a where a:"\<forall>n. \<bar>dest_vec1 (s n)\<bar> \<le>  a"
3.1069 -    using assms(1)[unfolded bounded_iff abs_dest_vec1] by auto
3.1070 -  { fix m::nat
3.1071 -    have "\<And> n. n\<ge>m \<longrightarrow> dest_vec1 (s m) \<le> dest_vec1 (s n)"
3.1072 -      apply (induct_tac n)
3.1073 -      apply simp
3.1074 -      using assms(2) apply (erule_tac x="na" in allE)
3.1075 -      apply (auto simp add: not_less_eq_eq)
3.1076 -      done
3.1077 -  }
3.1078 -  hence "\<forall>m n. m \<le> n \<longrightarrow> dest_vec1 (s m) \<le> dest_vec1 (s n)"
3.1079 -    by auto
3.1080 -  then obtain l where "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<bar>dest_vec1 (s n) - l\<bar> < e"
3.1081 -    using convergent_bounded_monotone[OF a] unfolding monoseq_def by auto
3.1082 -  thus ?thesis unfolding LIMSEQ_def apply(rule_tac x="vec1 l" in exI)
3.1083 -    unfolding dist_norm unfolding abs_dest_vec1 by auto
3.1084 -qed
3.1085 -
3.1086 -lemma dest_vec1_simps[simp]:
3.1087 -  fixes a :: "real^1"
3.1088 -  shows "a\$1 = 0 \<longleftrightarrow> a = 0" (*"a \<le> 1 \<longleftrightarrow> dest_vec1 a \<le> 1" "0 \<le> a \<longleftrightarrow> 0 \<le> dest_vec1 a"*)
3.1089 -    "a \<le> b \<longleftrightarrow> dest_vec1 a \<le> dest_vec1 b" "dest_vec1 (1::real^1) = 1"
3.1090 -  by (auto simp add: less_eq_vec_def vec_eq_iff)
3.1091 -
3.1092 -lemma dest_vec1_inverval:
3.1093 -  "dest_vec1 ` {a .. b} = {dest_vec1 a .. dest_vec1 b}"
3.1094 -  "dest_vec1 ` {a<.. b} = {dest_vec1 a<.. dest_vec1 b}"
3.1095 -  "dest_vec1 ` {a ..<b} = {dest_vec1 a ..<dest_vec1 b}"
3.1096 -  "dest_vec1 ` {a<..<b} = {dest_vec1 a<..<dest_vec1 b}"
3.1097 -  apply(rule_tac [!] equalityI)
3.1098 -  unfolding subset_eq Ball_def Bex_def mem_interval_1 image_iff
3.1099 -  apply(rule_tac [!] allI)apply(rule_tac [!] impI)
3.1100 -  apply(rule_tac[2] x="vec1 x" in exI)apply(rule_tac[4] x="vec1 x" in exI)
3.1101 -  apply(rule_tac[6] x="vec1 x" in exI)apply(rule_tac[8] x="vec1 x" in exI)
3.1102 -  apply (auto simp add: less_vec_def less_eq_vec_def)
3.1103 -  done
3.1104 -
3.1105 -lemma dest_vec1_setsum:
3.1106 -  assumes "finite S"
3.1107 -  shows " dest_vec1 (setsum f S) = setsum (\<lambda>x. dest_vec1 (f x)) S"
3.1108 -  using dest_vec1_sum[OF assms] by auto
3.1109 -
3.1110 -lemma open_dest_vec1_vimage: "open S \<Longrightarrow> open (dest_vec1 -` S)"
3.1111 -  unfolding open_vec_def forall_1 by auto
3.1112 -
3.1113 -lemma tendsto_dest_vec1 [tendsto_intros]:
3.1114 -  "(f ---> l) net \<Longrightarrow> ((\<lambda>x. dest_vec1 (f x)) ---> dest_vec1 l) net"
3.1115 -  by (rule tendsto_vec_nth)
3.1116 -
3.1117 -lemma continuous_dest_vec1:
3.1118 -  "continuous net f \<Longrightarrow> continuous net (\<lambda>x. dest_vec1 (f x))"
3.1119 -  unfolding continuous_def by (rule tendsto_dest_vec1)
3.1120 -
3.1121 -lemma forall_dest_vec1: "(\<forall>x. P x) \<longleftrightarrow> (\<forall>x. P(dest_vec1 x))"
3.1122 -  apply safe defer
3.1123 -  apply (erule_tac x="vec1 x" in allE)
3.1124 -  apply auto
3.1125 -  done
3.1126 -
3.1127 -lemma forall_of_dest_vec1: "(\<forall>v. P (\<lambda>x. dest_vec1 (v x))) \<longleftrightarrow> (\<forall>x. P x)"
3.1128 -  apply rule
3.1129 -  apply rule
3.1130 -  apply (erule_tac x="vec1 \<circ> x" in allE)
3.1131 -  unfolding o_def vec1_dest_vec1
3.1132 -  apply auto
3.1133 -  done
3.1134 -
3.1135 -lemma forall_of_dest_vec1': "(\<forall>v. P (dest_vec1 v)) \<longleftrightarrow> (\<forall>x. P x)"
3.1136 -  apply rule
3.1137 -  apply rule
3.1138 -  apply (erule_tac x="(vec1 x)" in allE) defer
3.1139 -  apply rule
3.1140 -  apply (erule_tac x="dest_vec1 v" in allE)
3.1141 -  unfolding o_def vec1_dest_vec1
3.1142 -  apply auto
3.1143 -  done
3.1144 -
3.1145 -lemma dist_vec1_0[simp]: "dist(vec1 (x::real)) 0 = norm x"
3.1146 -  unfolding dist_norm by auto
3.1147 -
3.1148 -lemma bounded_linear_vec1_dest_vec1:
3.1149 -  fixes f :: "real \<Rightarrow> real"
3.1150 -  shows "linear (vec1 \<circ> f \<circ> dest_vec1) = bounded_linear f" (is "?l = ?r")
3.1151 -proof -
3.1152 -  { assume ?l
3.1153 -    then have "\<exists>K. \<forall>x. norm ((vec1 \<circ> f \<circ> dest_vec1) x) \<le> K * norm x" by (rule linear_bounded)
3.1154 -    then guess K ..
3.1155 -    hence "\<exists>K. \<forall>x. \<bar>f x\<bar> \<le> \<bar>x\<bar> * K"
3.1156 -      apply(rule_tac x=K in exI)
3.1157 -      unfolding vec1_dest_vec1_simps by (auto simp add:field_simps)
3.1158 -  }
3.1159 -  thus ?thesis
3.1160 -    unfolding linear_def bounded_linear_def additive_def bounded_linear_axioms_def o_def
3.1161 -    unfolding vec1_dest_vec1_simps by auto
3.1162 -qed
3.1163 -
3.1164 -lemma vec1_le[simp]: fixes a :: real shows "vec1 a \<le> vec1 b \<longleftrightarrow> a \<le> b"
3.1165 -  unfolding less_eq_vec_def by auto
3.1166 -lemma vec1_less[simp]: fixes a :: real shows "vec1 a < vec1 b \<longleftrightarrow> a < b"
3.1167 -  unfolding less_vec_def by auto
3.1168 -
3.1169 -
3.1170 -subsection {* Derivatives on real = Derivatives on @{typ "real^1"} *}
3.1171 -
3.1172 -lemma has_derivative_within_vec1_dest_vec1:
3.1173 -  fixes f :: "real \<Rightarrow> real"
3.1174 -  shows "((vec1 \<circ> f \<circ> dest_vec1) has_derivative (vec1 \<circ> f' \<circ> dest_vec1)) (at (vec1 x) within vec1 ` s)
3.1175 -    = (f has_derivative f') (at x within s)"
3.1176 -  unfolding has_derivative_within
3.1177 -  unfolding bounded_linear_vec1_dest_vec1[unfolded linear_conv_bounded_linear]
3.1178 -  unfolding o_def Lim_within Ball_def unfolding forall_vec1
3.1179 -  unfolding vec1_dest_vec1_simps dist_vec1_0 image_iff
3.1180 -  by auto
3.1181 -
3.1182 -lemma has_derivative_at_vec1_dest_vec1:
3.1183 -  fixes f :: "real \<Rightarrow> real"
3.1184 -  shows "((vec1 \<circ> f \<circ> dest_vec1) has_derivative (vec1 \<circ> f' \<circ> dest_vec1)) (at (vec1 x)) = (f has_derivative f') (at x)"
3.1185 -  using has_derivative_within_vec1_dest_vec1[where s=UNIV, unfolded range_vec1 within_UNIV]
3.1186 -  by auto
3.1187 -
3.1188 -lemma bounded_linear_vec1':
3.1189 -  fixes f :: "'a::real_normed_vector\<Rightarrow>real"
3.1190 -  shows "bounded_linear f = bounded_linear (vec1 \<circ> f)"
3.1191 -  unfolding bounded_linear_def additive_def bounded_linear_axioms_def o_def
3.1192 -  unfolding vec1_dest_vec1_simps by auto
3.1193 -
3.1194 -lemma bounded_linear_dest_vec1:
3.1195 -  fixes f :: "real\<Rightarrow>'a::real_normed_vector"
3.1196 -  shows "bounded_linear f = bounded_linear (f \<circ> dest_vec1)"
3.1197 -  unfolding bounded_linear_def additive_def bounded_linear_axioms_def o_def
3.1198 -  unfolding vec1_dest_vec1_simps
3.1199 -  by auto
3.1200 -
3.1201 -lemma has_derivative_at_vec1:
3.1202 -  fixes f :: "'a::real_normed_vector\<Rightarrow>real"
3.1203 -  shows "(f has_derivative f') (at x) = ((vec1 \<circ> f) has_derivative (vec1 \<circ> f')) (at x)"
3.1204 -  unfolding has_derivative_at
3.1205 -  unfolding bounded_linear_vec1'[unfolded linear_conv_bounded_linear]
3.1206 -  unfolding o_def Lim_at
3.1207 -  unfolding vec1_dest_vec1_simps dist_vec1_0
3.1208 -  by auto
3.1209 -
3.1210 -lemma has_derivative_within_dest_vec1:
3.1211 -  fixes f :: "real\<Rightarrow>'a::real_normed_vector"
3.1212 -  shows "((f \<circ> dest_vec1) has_derivative (f' \<circ> dest_vec1)) (at (vec1 x) within vec1 ` s) =
3.1213 -    (f has_derivative f') (at x within s)"
3.1214 -  unfolding has_derivative_within bounded_linear_dest_vec1
3.1215 -  unfolding o_def Lim_within Ball_def
3.1216 -  unfolding vec1_dest_vec1_simps dist_vec1_0 image_iff
3.1217 -  by auto
3.1218 -
3.1219 -lemma has_derivative_at_dest_vec1:
3.1220 -  fixes f :: "real\<Rightarrow>'a::real_normed_vector"
3.1221 -  shows "((f \<circ> dest_vec1) has_derivative (f' \<circ> dest_vec1)) (at (vec1 x)) =
3.1222 -    (f has_derivative f') (at x)"
3.1223 -  using has_derivative_within_dest_vec1[where s=UNIV] by simp
3.1224 -
3.1225 -
3.1226 -subsection {* In particular if we have a mapping into @{typ "real^1"}. *}
3.1227 -
3.1228 -lemma onorm_vec1:
3.1229 -  fixes f::"real \<Rightarrow> real"
3.1230 -  shows "onorm (\<lambda>x. vec1 (f (dest_vec1 x))) = onorm f"
3.1231 -proof -
3.1232 -  have "\<forall>x::real^1. norm x = 1 \<longleftrightarrow> x\<in>{vec1 -1, vec1 (1::real)}"
3.1233 -    unfolding forall_vec1 by (auto simp add: vec_eq_iff)
3.1234 -  hence 1: "{x. norm x = 1} = {vec1 -1, vec1 (1::real)}" by auto
3.1235 -  have 2: "{norm (vec1 (f (dest_vec1 x))) |x. norm x = 1} =
3.1236 -      (\<lambda>x. norm (vec1 (f (dest_vec1 x)))) ` {x. norm x=1}"
3.1237 -    by auto
3.1238 -  have "\<forall>x::real. norm x = 1 \<longleftrightarrow> x\<in>{-1, 1}" by auto
3.1239 -  hence 3:"{x. norm x = 1} = {-1, (1::real)}" by auto
3.1240 -  have 4:"{norm (f x) |x. norm x = 1} = (\<lambda>x. norm (f x)) ` {x. norm x=1}" by auto
3.1241 -  show ?thesis
3.1242 -    unfolding onorm_def 1 2 3 4 by (simp add:Sup_finite_Max)
3.1243 -qed
3.1244 -
3.1245 -lemma convex_vec1:"convex (vec1 ` s) = convex (s::real set)"
3.1246 -  unfolding convex_def Ball_def forall_vec1
3.1247 -  unfolding vec1_dest_vec1_simps image_iff
3.1248 -  by auto
3.1249 -
3.1250  lemma bounded_linear_component_cart[intro]: "bounded_linear (\<lambda>x::real^'n. x \$ k)"
3.1251    apply (rule bounded_linearI[where K=1])
3.1252    using component_le_norm_cart[of _ k] unfolding real_norm_def by auto
3.1253
3.1254 -lemma bounded_vec1[intro]: "bounded s \<Longrightarrow> bounded (vec1 ` (s::real set))"
3.1255 -  unfolding bounded_def apply safe apply(rule_tac x="vec1 x" in exI,rule_tac x=e in exI)
3.1256 -  apply (auto simp add: dist_real dist_real_def)
3.1257 -  done
3.1258 -
3.1259 -(*lemma content_closed_interval_cases_cart:
3.1260 -  "content {a..b::real^'n} =
3.1261 -  (if {a..b} = {} then 0 else setprod (\<lambda>i. b\$i - a\$i) UNIV)"
3.1262 -proof(cases "{a..b} = {}")
3.1263 -  case True thus ?thesis unfolding content_def by auto
3.1264 -next case Falsethus ?thesis unfolding content_def unfolding if_not_P[OF False]
3.1265 -  proof(cases "\<forall>i. a \$ i \<le> b \$ i")
3.1266 -    case False thus ?thesis unfolding content_def using t by auto
3.1267 -  next case True note interval_eq_empty
3.1268 -   apply auto
3.1269 -
3.1270 -  sorry*)
3.1271 -
3.1272  lemma integral_component_eq_cart[simp]:
3.1273    fixes f :: "'n::ordered_euclidean_space \<Rightarrow> real^'m"
3.1274    assumes "f integrable_on s"
3.1275 @@ -2309,39 +1348,8 @@
3.1276    unfolding vec_lambda_beta
3.1277    by auto
3.1278
3.1279 -(*lemma content_split_cart:
3.1280 -  "content {a..b::real^'n} = content({a..b} \<inter> {x. x\$k \<le> c}) + content({a..b} \<inter> {x. x\$k >= c})"
3.1281 -proof- note simps = interval_split_cart content_closed_interval_cases_cart vec_lambda_beta less_eq_vec_def
3.1282 -  { presume "a\<le>b \<Longrightarrow> ?thesis" thus ?thesis apply(cases "a\<le>b") unfolding simps by auto }
3.1283 -  have *:"UNIV = insert k (UNIV - {k})" "\<And>x. finite (UNIV-{x::'n})" "\<And>x. x\<notin>UNIV-{x}" by auto
3.1284 -  have *:"\<And>X Y Z. (\<Prod>i\<in>UNIV. Z i (if i = k then X else Y i)) = Z k X * (\<Prod>i\<in>UNIV-{k}. Z i (Y i))"
3.1285 -    "(\<Prod>i\<in>UNIV. b\$i - a\$i) = (\<Prod>i\<in>UNIV-{k}. b\$i - a\$i) * (b\$k - a\$k)"
3.1286 -    apply(subst *(1)) defer apply(subst *(1)) unfolding setprod_insert[OF *(2-)] by auto
3.1287 -  assume as:"a\<le>b" moreover have "\<And>x. min (b \$ k) c = max (a \$ k) c
3.1288 -    \<Longrightarrow> x* (b\$k - a\$k) = x*(max (a \$ k) c - a \$ k) + x*(b \$ k - max (a \$ k) c)"
3.1289 -    by  (auto simp add:field_simps)
3.1290 -  moreover have "\<not> a \$ k \<le> c \<Longrightarrow> \<not> c \<le> b \$ k \<Longrightarrow> False"
3.1291 -    unfolding not_le using as[unfolded less_eq_vec_def,rule_format,of k] by auto
3.1292 -  ultimately show ?thesis
3.1293 -    unfolding simps unfolding *(1)[of "\<lambda>i x. b\$i - x"] *(1)[of "\<lambda>i x. x - a\$i"] *(2) by(auto)
3.1294 -qed*)
3.1295 -
3.1296 -lemma has_integral_vec1:
3.1297 -  assumes "(f has_integral k) {a..b}"
3.1298 -  shows "((\<lambda>x. vec1 (f x)) has_integral (vec1 k)) {a..b}"
3.1299 -proof -
3.1300 -  have *: "\<And>p. (\<Sum>(x, k)\<in>p. content k *\<^sub>R vec1 (f x)) - vec1 k =
3.1301 -      vec1 ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - k)"
3.1302 -    unfolding vec_sub vec_eq_iff by (auto simp add: split_beta)
3.1303 -  show ?thesis
3.1304 -    using assms unfolding has_integral
3.1305 -    apply safe
3.1306 -    apply(erule_tac x=e in allE,safe)
3.1307 -    apply(rule_tac x=d in exI,safe)
3.1308 -    apply(erule_tac x=p in allE,safe)
3.1309 -    unfolding * norm_vector_1
3.1310 -    apply auto
3.1311 -    done
3.1312 -qed
3.1313 +lemma interval_bij_bij_cart: fixes x::"real^'n" assumes "\<forall>i. a\$i < b\$i \<and> u\$i < v\$i"
3.1314 +  shows "interval_bij (a,b) (u,v) (interval_bij (u,v) (a,b) x) = x"
3.1315 +  using assms by (intro interval_bij_bij) (auto simp: Basis_vec_def inner_axis)
3.1316
3.1317  end
```
```     4.1 --- a/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy	Fri Dec 14 14:46:01 2012 +0100
4.2 +++ b/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy	Fri Dec 14 15:46:01 2012 +0100
4.3 @@ -101,56 +101,22 @@
4.4  lemma span_eq[simp]: "(span s = s) <-> subspace s"
4.5    unfolding span_def by (rule hull_eq, rule subspace_Inter)
4.6
4.7 -lemma basis_inj_on: "d \<subseteq> {..<DIM('n)} \<Longrightarrow> inj_on (basis :: nat => 'n::euclidean_space) d"
4.8 -  by (auto simp add: inj_on_def euclidean_eq[where 'a='n])
4.9 -
4.10 -lemma finite_substdbasis: "finite {basis i ::'n::euclidean_space |i. i : (d:: nat set)}" (is "finite ?S")
4.11 -proof -
4.12 -  have eq: "?S = basis ` d" by blast
4.13 -  show ?thesis
4.14 -    unfolding eq
4.15 -    apply (rule finite_subset[OF _ range_basis_finite])
4.16 -    apply auto
4.17 -    done
4.18 -qed
4.19 -
4.20 -lemma card_substdbasis:
4.21 -  assumes "d \<subseteq> {..<DIM('n::euclidean_space)}"
4.22 -  shows "card {basis i ::'n::euclidean_space | i. i : d} = card d" (is "card ?S = _")
4.23 -proof -
4.24 -  have eq: "?S = basis ` d" by blast
4.25 -  show ?thesis
4.26 -    unfolding eq
4.27 -    using card_image[OF basis_inj_on[of d]] assms by auto
4.28 -qed
4.29 -
4.30  lemma substdbasis_expansion_unique:
4.31 -  assumes "d\<subseteq>{..<DIM('a::euclidean_space)}"
4.32 -  shows "setsum (%i. f i *\<^sub>R basis i) d = (x::'a::euclidean_space)
4.33 -      <-> (!i<DIM('a). (i:d --> f i = x\$\$i) & (i ~: d --> x \$\$ i = 0))"
4.34 +  assumes d: "d \<subseteq> Basis"
4.35 +  shows "(\<Sum>i\<in>d. f i *\<^sub>R i) = (x::'a::euclidean_space)
4.36 +      \<longleftrightarrow> (\<forall>i\<in>Basis. (i \<in> d \<longrightarrow> f i = x \<bullet> i) \<and> (i \<notin> d \<longrightarrow> x \<bullet> i = 0))"
4.37  proof -
4.38    have *: "\<And>x a b P. x * (if P then a else b) = (if P then x*a else x*b)" by auto
4.39 -  have **: "finite d" apply(rule finite_subset[OF assms]) by fastforce
4.40 -  have ***: "\<And>i. (setsum (%i. f i *\<^sub>R ((basis i)::'a)) d) \$\$ i = (\<Sum>x\<in>d. if x = i then f x else 0)"
4.41 -    unfolding euclidean_component_setsum euclidean_component_scaleR basis_component *
4.42 -    apply (rule setsum_cong2)
4.43 -    using assms apply auto
4.44 -    done
4.45 +  have **: "finite d" by (auto intro: finite_subset[OF assms])
4.46 +  have ***: "\<And>i. i \<in> Basis \<Longrightarrow> (\<Sum>i\<in>d. f i *\<^sub>R i) \<bullet> i = (\<Sum>x\<in>d. if x = i then f x else 0)"
4.47 +    using d
4.48 +    by (auto intro!: setsum_cong simp: inner_Basis inner_setsum_left)
4.49    show ?thesis
4.50 -    unfolding euclidean_eq[where 'a='a] *** setsum_delta[OF **] using assms by auto
4.51 -qed
4.52 -
4.53 -lemma independent_substdbasis:
4.54 -  assumes "d \<subseteq> {..<DIM('a::euclidean_space)}"
4.55 -  shows "independent {basis i ::'a::euclidean_space |i. i : (d :: nat set)}"
4.56 -  (is "independent ?A")
4.57 -proof -
4.58 -  have *: "{basis i |i. i < DIM('a)} = basis ` {..<DIM('a)}" by auto
4.59 -  show ?thesis
4.60 -    apply(intro independent_mono[of "{basis i ::'a |i. i : {..<DIM('a::euclidean_space)}}" "?A"] )
4.61 -    using independent_basis[where 'a='a] assms apply (auto simp: *)
4.62 -    done
4.63 -qed
4.64 +    unfolding euclidean_eq_iff[where 'a='a] by (auto simp: setsum_delta[OF **] ***)
4.65 +qed
4.66 +
4.67 +lemma independent_substdbasis: "d \<subseteq> Basis \<Longrightarrow> independent d"
4.68 +  by (rule independent_mono[OF independent_Basis])
4.69
4.70  lemma dim_cball:
4.71    assumes "0<e"
4.72 @@ -321,8 +287,8 @@
4.73
4.74  lemma vector_choose_size:
4.75    "0 <= c ==> \<exists>(x::'a::euclidean_space). norm x = c"
4.76 -  apply (rule exI[where x="c *\<^sub>R basis 0 ::'a"])
4.77 -  using DIM_positive[where 'a='a] apply auto
4.78 +  apply (rule exI[where x="c *\<^sub>R (SOME i. i \<in> Basis)"])
4.79 +  apply (auto simp: SOME_Basis)
4.80    done
4.81
4.82  lemma setsum_delta_notmem:
4.83 @@ -1291,11 +1257,12 @@
4.84  text {* Balls, being convex, are connected. *}
4.85
4.86  lemma convex_box: fixes a::"'a::euclidean_space"
4.87 -  assumes "\<And>i. i<DIM('a) \<Longrightarrow> convex {x. P i x}"
4.88 -  shows "convex {x. \<forall>i<DIM('a). P i (x\$\$i)}"
4.89 -  using assms unfolding convex_def by auto
4.90 -
4.91 -lemma convex_positive_orthant: "convex {x::'a::euclidean_space. (\<forall>i<DIM('a). 0 \<le> x\$\$i)}"
4.92 +  assumes "\<And>i. i\<in>Basis \<Longrightarrow> convex {x. P i x}"
4.93 +  shows "convex {x. \<forall>i\<in>Basis. P i (x\<bullet>i)}"
4.94 +  using assms unfolding convex_def
4.95 +  by (auto simp: inner_add_left)
4.96 +
4.97 +lemma convex_positive_orthant: "convex {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i)}"
4.98    by (rule convex_box) (simp add: atLeast_def[symmetric] convex_real_interval)
4.99
4.100  lemma convex_local_global_minimum:
4.101 @@ -2073,40 +2040,39 @@
4.102  from this show ?thesis using assms `span B=S` by auto
4.103  qed
4.104
4.105 -lemma span_substd_basis:  assumes "d\<subseteq>{..<DIM('a::euclidean_space)}"
4.106 -  shows "(span {basis i | i. i : d}) = {x::'a::euclidean_space. (!i<DIM('a). i ~: d --> x\$\$i = 0)}"
4.107 -  (is "span ?A = ?B")
4.108 +lemma span_substd_basis:
4.109 +  assumes d: "d \<subseteq> Basis"
4.110 +  shows "span d = {x. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0}" (is "_ = ?B")
4.111  proof-
4.112 -have "?A <= ?B" by auto
4.113 +have "d <= ?B" using d by (auto simp: inner_Basis)
4.114  moreover have s: "subspace ?B" using subspace_substandard[of "%i. i ~: d"] .
4.115 -ultimately have "span ?A <= ?B" using span_mono[of "?A" "?B"] span_eq[of "?B"] by blast
4.116 -moreover have "card d <= dim (span ?A)" using independent_card_le_dim[of "?A" "span ?A"]
4.117 -   independent_substdbasis[OF assms] card_substdbasis[OF assms] span_inc[of "?A"] by auto
4.118 -moreover hence "dim ?B <= dim (span ?A)" using dim_substandard[OF assms] by auto
4.119 -ultimately show ?thesis using s subspace_dim_equal[of "span ?A" "?B"]
4.120 -  subspace_span[of "?A"] by auto
4.121 +ultimately have "span d <= ?B" using span_mono[of d "?B"] span_eq[of "?B"] by blast
4.122 +moreover have "card d <= dim (span d)" using independent_card_le_dim[of d "span d"]
4.123 +   independent_substdbasis[OF assms] span_inc[of d] by auto
4.124 +moreover hence "dim ?B <= dim (span d)" using dim_substandard[OF assms] by auto
4.125 +ultimately show ?thesis using s subspace_dim_equal[of "span d" "?B"]
4.126 +  subspace_span[of d] by auto
4.127  qed
4.128
4.129  lemma basis_to_substdbasis_subspace_isomorphism:
4.130  fixes B :: "('a::euclidean_space) set"
4.131  assumes "independent B"
4.132 -shows "EX f d. card d = card B & linear f & f ` B = {basis i::'a |i. i : (d :: nat set)} &
4.133 -       f ` span B = {x. ALL i<DIM('a). i ~: d --> x \$\$ i = (0::real)} &  inj_on f (span B) \<and> d\<subseteq>{..<DIM('a)}"
4.134 +shows "EX f (d::'a set). card d = card B \<and> linear f \<and> f ` B = d \<and>
4.135 +       f ` span B = {x. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0} \<and> inj_on f (span B) \<and> d \<subseteq> Basis"
4.136  proof-
4.137    have B:"card B=dim B" using dim_unique[of B B "card B"] assms span_inc[of B] by auto
4.138 -  def d \<equiv> "{..<dim B}" have t:"card d = dim B" unfolding d_def by auto
4.139 -  have "dim B <= DIM('a)" using dim_subset_UNIV[of B] by auto
4.140 -  hence d:"d\<subseteq>{..<DIM('a)}" unfolding d_def by auto
4.141 -  let ?t = "{x::'a::euclidean_space. !i<DIM('a). i ~: d --> x\$\$i = 0}"
4.142 -  have "EX f. linear f & f ` B = {basis i |i. i : d} &
4.143 -    f ` span B = ?t & inj_on f (span B)"
4.144 -    apply (rule basis_to_basis_subspace_isomorphism[of "span B" ?t B "{basis i |i. i : d}"])
4.145 +  have "dim B \<le> card (Basis :: 'a set)" using dim_subset_UNIV[of B] by simp
4.146 +  from ex_card[OF this] obtain d :: "'a set" where d: "d \<subseteq> Basis" and t: "card d = dim B" by auto
4.147 +  let ?t = "{x::'a::euclidean_space. \<forall>i\<in>Basis. i ~: d --> x\<bullet>i = 0}"
4.148 +  have "EX f. linear f & f ` B = d & f ` span B = ?t & inj_on f (span B)"
4.149 +    apply (rule basis_to_basis_subspace_isomorphism[of "span B" ?t B "d"])
4.150      apply(rule subspace_span) apply(rule subspace_substandard) defer
4.151      apply(rule span_inc) apply(rule assms) defer unfolding dim_span[of B] apply(rule B)
4.152 -    unfolding span_substd_basis[OF d,symmetric] card_substdbasis[OF d] apply(rule span_inc)
4.153 +    unfolding span_substd_basis[OF d, symmetric]
4.154 +    apply(rule span_inc)
4.155      apply(rule independent_substdbasis[OF d]) apply(rule,assumption)
4.156      unfolding t[symmetric] span_substd_basis[OF d] dim_substandard[OF d] by auto
4.157 -  from this t `card B=dim B` show ?thesis using d by auto
4.158 +  with t `card B = dim B` d show ?thesis by auto
4.159  qed
4.160
4.161  lemma aff_dim_empty:
4.162 @@ -2492,7 +2458,7 @@
4.163          using as affine_affine_hull[of S] mem_affine[of "affine hull S" y x "(1 / e)" "-((1 - e) / e)"] by (simp add: algebra_simps)
4.164      have "dist c ((1 / e) *\<^sub>R y - ((1 - e) / e) *\<^sub>R x) = abs(1/e) * norm (e *\<^sub>R c - y + (1 - e) *\<^sub>R x)"
4.165        unfolding dist_norm unfolding norm_scaleR[symmetric] apply(rule arg_cong[where f=norm]) using `e>0`
4.166 -      by(auto simp add:euclidean_eq[where 'a='a] field_simps)
4.167 +      by(auto simp add:euclidean_eq_iff[where 'a='a] field_simps inner_simps)
4.168      also have "... = abs(1/e) * norm (x - e *\<^sub>R (x - c) - y)" by(auto intro!:arg_cong[where f=norm] simp add: algebra_simps)
4.169      also have "... < d" using as[unfolded dist_norm] and `e>0`
4.170        by(auto simp add:pos_divide_less_eq[OF `e>0`] mult_commute)
4.171 @@ -2770,9 +2736,9 @@
4.172
4.173  subsection{* Some Properties of subset of standard basis *}
4.174
4.175 -lemma affine_hull_substd_basis: assumes "d\<subseteq>{..<DIM('a::euclidean_space)}"
4.176 -  shows "affine hull (insert 0 {basis i | i. i : d}) =
4.177 -  {x::'a::euclidean_space. (!i<DIM('a). i ~: d --> x\$\$i = 0)}"
4.178 +lemma affine_hull_substd_basis: assumes "d\<subseteq>Basis"
4.179 +  shows "affine hull (insert 0 d) =
4.180 +  {x::'a::euclidean_space. (\<forall>i\<in>Basis. i ~: d --> x\<bullet>i = 0)}"
4.181   (is "affine hull (insert 0 ?A) = ?B")
4.182  proof- have *:"\<And>A. op + (0\<Colon>'a) ` A = A" "\<And>A. op + (- (0\<Colon>'a)) ` A = A" by auto
4.183    show ?thesis unfolding affine_hull_insert_span_gen span_substd_basis[OF assms,symmetric] * ..
4.184 @@ -3230,10 +3196,10 @@
4.185    assumes "convex (s::('a::euclidean_space) set)" "closed s" "0 \<notin> s"
4.186    shows "\<exists>a b. a \<noteq> 0 \<and> 0 < b \<and> (\<forall>x\<in>s. inner a x > b)"
4.187    proof(cases "s={}")
4.188 -  case True have "norm ((basis 0)::'a) = 1" by auto
4.189 -  hence "norm ((basis 0)::'a) = 1" "basis 0 \<noteq> (0::'a)" defer
4.190 -    apply(subst norm_le_zero_iff[symmetric]) by auto
4.191 -  thus ?thesis apply(rule_tac x="basis 0" in exI, rule_tac x=1 in exI)
4.192 +  case True
4.193 +  have "norm ((SOME i. i\<in>Basis)::'a) = 1" "(SOME i. i\<in>Basis) \<noteq> (0::'a)" defer
4.194 +    apply(subst norm_le_zero_iff[symmetric]) by (auto simp: SOME_Basis)
4.195 +  thus ?thesis apply(rule_tac x="SOME i. i\<in>Basis" in exI, rule_tac x=1 in exI)
4.196      using True using DIM_positive[where 'a='a] by auto
4.197  next case False thus ?thesis using False using separating_hyperplane_closed_point[OF assms]
4.198      apply - apply(erule exE)+ unfolding inner_zero_right apply(rule_tac x=a in exI, rule_tac x=b in exI) by auto qed
4.199 @@ -3703,10 +3669,10 @@
4.200        case False thus ?thesis apply (intro continuous_intros)
4.201          using cont_surfpi unfolding continuous_on_eq_continuous_at[OF open_delete[OF open_UNIV]] o_def by auto
4.202      next obtain B where B:"\<forall>x\<in>s. norm x \<le> B" using compact_imp_bounded[OF assms(1)] unfolding bounded_iff by auto
4.203 -      hence "B > 0" using assms(2) unfolding subset_eq apply(erule_tac x="basis 0" in ballE) defer
4.204 -        apply(erule_tac x="basis 0" in ballE)
4.205 +      hence "B > 0" using assms(2) unfolding subset_eq apply(erule_tac x="SOME i. i\<in>Basis" in ballE) defer
4.206 +        apply(erule_tac x="SOME i. i\<in>Basis" in ballE)
4.207          unfolding Ball_def mem_cball dist_norm using DIM_positive[where 'a='a]
4.208 -        by auto
4.209 +        by (auto simp: SOME_Basis)
4.210        case True show ?thesis unfolding True continuous_at Lim_at apply(rule,rule) apply(rule_tac x="e / B" in exI)
4.211          apply(rule) apply(rule divide_pos_pos) prefer 3 apply(rule,rule,erule conjE)
4.212          unfolding norm_zero scaleR_zero_left dist_norm diff_0_right norm_scaleR abs_norm_cancel proof-
4.213 @@ -3849,7 +3815,8 @@
4.214      hence "a < b" unfolding * using as(4) apply(rule_tac mult_left_less_imp_less) by(auto simp add: field_simps)
4.215      hence "u * a + v * b \<le> b" unfolding ** using **(2) as(3) by(auto simp add: field_simps intro!:mult_right_mono) }
4.216    ultimately show "u *\<^sub>R x + v *\<^sub>R y \<in> s" apply- apply(rule assms[unfolded is_interval_def, rule_format, OF as(1,2)])
4.217 -    using as(3-) DIM_positive[where 'a='a] by auto qed
4.218 +    using as(3-) DIM_positive[where 'a='a] by (auto simp: inner_simps)
4.219 +qed
4.220
4.221  lemma is_interval_connected:
4.222    fixes s :: "('a::euclidean_space) set"
4.223 @@ -3892,8 +3859,8 @@
4.224  subsection {* Another intermediate value theorem formulation *}
4.225
4.226  lemma ivt_increasing_component_on_1: fixes f::"real \<Rightarrow> 'a::euclidean_space"
4.227 -  assumes "a \<le> b" "continuous_on {a .. b} f" "(f a)\$\$k \<le> y" "y \<le> (f b)\$\$k"
4.228 -  shows "\<exists>x\<in>{a..b}. (f x)\$\$k = y"
4.229 +  assumes "a \<le> b" "continuous_on {a .. b} f" "(f a)\<bullet>k \<le> y" "y \<le> (f b)\<bullet>k"
4.230 +  shows "\<exists>x\<in>{a..b}. (f x)\<bullet>k = y"
4.231  proof- have "f a \<in> f ` {a..b}" "f b \<in> f ` {a..b}" apply(rule_tac[!] imageI)
4.232      using assms(1) by auto
4.233    thus ?thesis using connected_ivt_component[of "f ` {a..b}" "f a" "f b" k y]
4.234 @@ -3902,20 +3869,20 @@
4.235
4.236  lemma ivt_increasing_component_1: fixes f::"real \<Rightarrow> 'a::euclidean_space"
4.237    shows "a \<le> b \<Longrightarrow> \<forall>x\<in>{a .. b}. continuous (at x) f
4.238 -   \<Longrightarrow> f a\$\$k \<le> y \<Longrightarrow> y \<le> f b\$\$k \<Longrightarrow> \<exists>x\<in>{a..b}. (f x)\$\$k = y"
4.239 +   \<Longrightarrow> f a\<bullet>k \<le> y \<Longrightarrow> y \<le> f b\<bullet>k \<Longrightarrow> \<exists>x\<in>{a..b}. (f x)\<bullet>k = y"
4.240  by(rule ivt_increasing_component_on_1)
4.242
4.243  lemma ivt_decreasing_component_on_1: fixes f::"real \<Rightarrow> 'a::euclidean_space"
4.244 -  assumes "a \<le> b" "continuous_on {a .. b} f" "(f b)\$\$k \<le> y" "y \<le> (f a)\$\$k"
4.245 -  shows "\<exists>x\<in>{a..b}. (f x)\$\$k = y"
4.246 +  assumes "a \<le> b" "continuous_on {a .. b} f" "(f b)\<bullet>k \<le> y" "y \<le> (f a)\<bullet>k"
4.247 +  shows "\<exists>x\<in>{a..b}. (f x)\<bullet>k = y"
4.248    apply(subst neg_equal_iff_equal[symmetric])
4.249    using ivt_increasing_component_on_1[of a b "\<lambda>x. - f x" k "- y"]
4.250    using assms using continuous_on_minus by auto
4.251
4.252  lemma ivt_decreasing_component_1: fixes f::"real \<Rightarrow> 'a::euclidean_space"
4.253    shows "a \<le> b \<Longrightarrow> \<forall>x\<in>{a .. b}. continuous (at x) f
4.254 -    \<Longrightarrow> f b\$\$k \<le> y \<Longrightarrow> y \<le> f a\$\$k \<Longrightarrow> \<exists>x\<in>{a..b}. (f x)\$\$k = y"
4.255 +    \<Longrightarrow> f b\<bullet>k \<le> y \<Longrightarrow> y \<le> f a\<bullet>k \<Longrightarrow> \<exists>x\<in>{a..b}. (f x)\<bullet>k = y"
4.256  by(rule ivt_decreasing_component_on_1)
4.257    (auto simp: continuous_at_imp_continuous_on)
4.258
4.259 @@ -3933,104 +3900,127 @@
4.260    thus "f x \<le> b" using assms(1)[unfolded convex_on[OF convex_convex_hull], rule_format, of k u v]
4.261      unfolding obt(2-3) using obt(1) and hull_subset[unfolded subset_eq, rule_format, of _ s] by auto qed
4.262
4.263 +lemma inner_setsum_Basis[simp]: "\<And>i. i \<in> Basis \<Longrightarrow> (\<Sum>Basis) \<bullet> i = 1"
4.264 +  by (simp add: One_def inner_setsum_left setsum_cases inner_Basis)
4.265 +
4.266  lemma unit_interval_convex_hull:
4.267 -  "{0::'a::ordered_euclidean_space .. (\<chi>\<chi> i. 1)} = convex hull {x. \<forall>i<DIM('a). (x\$\$i = 0) \<or> (x\$\$i = 1)}"
4.268 +  defines "One \<equiv> (\<Sum>Basis)"
4.269 +  shows "{0::'a::ordered_euclidean_space .. One} =
4.270 +    convex hull {x. \<forall>i\<in>Basis. (x\<bullet>i = 0) \<or> (x\<bullet>i = 1)}"
4.271    (is "?int = convex hull ?points")
4.272 -proof- have 01:"{0,(\<chi>\<chi> i. 1)} \<subseteq> convex hull ?points" apply rule apply(rule_tac hull_subset[unfolded subset_eq, rule_format]) by auto
4.273 -  { fix n x assume "x\<in>{0::'a::ordered_euclidean_space .. \<chi>\<chi> i. 1}" "n \<le> DIM('a)" "card {i. i<DIM('a) \<and> x\$\$i \<noteq> 0} \<le> n"
4.274 +proof -
4.275 +  have One[simp]: "\<And>i. i \<in> Basis \<Longrightarrow> One \<bullet> i = 1"
4.276 +    by (simp add: One_def inner_setsum_left setsum_cases inner_Basis)
4.277 +  have 01:"{0,One} \<subseteq> convex hull ?points"
4.278 +    apply rule apply(rule_tac hull_subset[unfolded subset_eq, rule_format]) by auto
4.279 +  { fix n x assume "x\<in>{0::'a::ordered_euclidean_space .. One}" "n \<le> DIM('a)" "card {i. i\<in>Basis \<and> x\<bullet>i \<noteq> 0} \<le> n"
4.280    hence "x\<in>convex hull ?points" proof(induct n arbitrary: x)
4.281 -    case 0 hence "x = 0" apply(subst euclidean_eq) apply rule by auto
4.282 +    case 0 hence "x = 0" apply(subst euclidean_eq_iff) apply rule by auto
4.283      thus "x\<in>convex hull ?points" using 01 by auto
4.284    next
4.285 -    case (Suc n) show "x\<in>convex hull ?points" proof(cases "{i. i<DIM('a) \<and> x\$\$i \<noteq> 0} = {}")
4.286 -      case True hence "x = 0" apply(subst euclidean_eq) by auto
4.287 +    case (Suc n) show "x\<in>convex hull ?points" proof(cases "{i. i\<in>Basis \<and> x\<bullet>i \<noteq> 0} = {}")
4.288 +      case True hence "x = 0" apply(subst euclidean_eq_iff) by auto
4.289        thus "x\<in>convex hull ?points" using 01 by auto
4.290      next
4.291 -      case False def xi \<equiv> "Min ((\<lambda>i. x\$\$i) ` {i. i<DIM('a) \<and> x\$\$i \<noteq> 0})"
4.292 -      have "xi \<in> (\<lambda>i. x\$\$i) ` {i. i<DIM('a) \<and> x\$\$i \<noteq> 0}" unfolding xi_def apply(rule Min_in) using False by auto
4.293 -      then obtain i where i':"x\$\$i = xi" "x\$\$i \<noteq> 0" "i<DIM('a)" by auto
4.294 -      have i:"\<And>j. j<DIM('a) \<Longrightarrow> x\$\$j > 0 \<Longrightarrow> x\$\$i \<le> x\$\$j"
4.295 +      case False def xi \<equiv> "Min ((\<lambda>i. x\<bullet>i) ` {i. i\<in>Basis \<and> x\<bullet>i \<noteq> 0})"
4.296 +      have "xi \<in> (\<lambda>i. x\<bullet>i) ` {i. i\<in>Basis \<and> x\<bullet>i \<noteq> 0}" unfolding xi_def apply(rule Min_in) using False by auto
4.297 +      then obtain i where i':"x\<bullet>i = xi" "x\<bullet>i \<noteq> 0" "i\<in>Basis" by auto
4.298 +      have i:"\<And>j. j\<in>Basis \<Longrightarrow> x\<bullet>j > 0 \<Longrightarrow> x\<bullet>i \<le> x\<bullet>j"
4.299          unfolding i'(1) xi_def apply(rule_tac Min_le) unfolding image_iff
4.300          defer apply(rule_tac x=j in bexI) using i' by auto
4.301 -      have i01:"x\$\$i \<le> 1" "x\$\$i > 0" using Suc(2)[unfolded mem_interval,rule_format,of i]
4.302 -        using i'(2-) `x\$\$i \<noteq> 0` by auto
4.303 -      show ?thesis proof(cases "x\$\$i=1")
4.304 -        case True have "\<forall>j\<in>{i. i<DIM('a) \<and> x\$\$i \<noteq> 0}. x\$\$j = 1" apply(rule, rule ccontr) unfolding mem_Collect_eq
4.305 -        proof(erule conjE) fix j assume as:"x \$\$ j \<noteq> 0" "x \$\$ j \<noteq> 1" "j<DIM('a)"
4.306 -          hence j:"x\$\$j \<in> {0<..<1}" using Suc(2) by(auto simp add: eucl_le[where 'a='a] elim!:allE[where x=j])
4.307 -          hence "x\$\$j \<in> op \$\$ x ` {i. i<DIM('a) \<and> x \$\$ i \<noteq> 0}" using as(3) by auto
4.308 -          hence "x\$\$j \<ge> x\$\$i" unfolding i'(1) xi_def apply(rule_tac Min_le) by auto
4.309 +      have i01:"x\<bullet>i \<le> 1" "x\<bullet>i > 0" using Suc(2)[unfolded mem_interval,rule_format,of i]
4.310 +        using i'(2-) `x\<bullet>i \<noteq> 0` by auto
4.311 +      show ?thesis proof(cases "x\<bullet>i=1")
4.312 +        case True have "\<forall>j\<in>{i. i\<in>Basis \<and> x\<bullet>i \<noteq> 0}. x\<bullet>j = 1" apply(rule, rule ccontr) unfolding mem_Collect_eq
4.313 +        proof(erule conjE) fix j assume as:"x \<bullet> j \<noteq> 0" "x \<bullet> j \<noteq> 1" "j\<in>Basis"
4.314 +          hence j:"x\<bullet>j \<in> {0<..<1}" using Suc(2)
4.315 +            by (auto simp add: eucl_le[where 'a='a] elim!:allE[where x=j])
4.316 +          hence "x\<bullet>j \<in> op \<bullet> x ` {i. i\<in>Basis \<and> x \<bullet> i \<noteq> 0}" using as(3) by auto
4.317 +          hence "x\<bullet>j \<ge> x\<bullet>i" unfolding i'(1) xi_def apply(rule_tac Min_le) by auto
4.318            thus False using True Suc(2) j by(auto simp add: elim!:ballE[where x=j]) qed
4.319          thus "x\<in>convex hull ?points" apply(rule_tac hull_subset[unfolded subset_eq, rule_format])
4.320            by auto
4.321 -      next let ?y = "\<lambda>j. if x\$\$j = 0 then 0 else (x\$\$j - x\$\$i) / (1 - x\$\$i)"
4.322 -        case False hence *:"x = x\$\$i *\<^sub>R (\<chi>\<chi> j. if x\$\$j = 0 then 0 else 1) + (1 - x\$\$i) *\<^sub>R (\<chi>\<chi> j. ?y j)"
4.323 -          apply(subst euclidean_eq) by(auto simp add: field_simps)
4.324 -        { fix j assume j:"j<DIM('a)"
4.325 -          have "x\$\$j \<noteq> 0 \<Longrightarrow> 0 \<le> (x \$\$ j - x \$\$ i) / (1 - x \$\$ i)" "(x \$\$ j - x \$\$ i) / (1 - x \$\$ i) \<le> 1"
4.326 +      next
4.327 +        let ?y = "\<Sum>j\<in>Basis. (if x\<bullet>j = 0 then 0 else (x\<bullet>j - x\<bullet>i) / (1 - x\<bullet>i)) *\<^sub>R j"
4.328 +        case False
4.329 +        then have *: "x = (x\<bullet>i) *\<^sub>R (\<Sum>j\<in>Basis. (if x\<bullet>j = 0 then 0 else 1) *\<^sub>R j) + (1 - x\<bullet>i) *\<^sub>R ?y"
4.330 +          by (subst euclidean_eq_iff) (simp add: inner_simps)
4.331 +        { fix j :: 'a assume j:"j\<in>Basis"
4.332 +          have "x\<bullet>j \<noteq> 0 \<Longrightarrow> 0 \<le> (x \<bullet> j - x \<bullet> i) / (1 - x \<bullet> i)" "(x \<bullet> j - x \<bullet> i) / (1 - x \<bullet> i) \<le> 1"
4.333              apply(rule_tac divide_nonneg_pos) using i(1)[of j] using False i01
4.334              using Suc(2)[unfolded mem_interval, rule_format, of j] using j
4.336 -          hence "0 \<le> ?y j \<and> ?y j \<le> 1" by auto }
4.337 -        moreover have "i\<in>{j. j<DIM('a) \<and> x\$\$j \<noteq> 0} - {j. j<DIM('a) \<and> ((\<chi>\<chi> j. ?y j)::'a) \$\$ j \<noteq> 0}"
4.338 +            by(auto simp add: field_simps)
4.339 +          with j have "0 \<le> ?y \<bullet> j \<and> ?y \<bullet> j \<le> 1" by (auto simp: inner_simps) }
4.340 +        moreover have "i\<in>{j. j\<in>Basis \<and> x\<bullet>j \<noteq> 0} - {j. j\<in>Basis \<and> ?y \<bullet> j \<noteq> 0}"
4.341            using i01 using i'(3) by auto
4.342 -        hence "{j. j<DIM('a) \<and> x\$\$j \<noteq> 0} \<noteq> {j. j<DIM('a) \<and> ((\<chi>\<chi> j. ?y j)::'a) \$\$ j \<noteq> 0}" using i'(3) by blast
4.343 -        hence **:"{j. j<DIM('a) \<and> ((\<chi>\<chi> j. ?y j)::'a) \$\$ j \<noteq> 0} \<subset> {j. j<DIM('a) \<and> x\$\$j \<noteq> 0}" apply - apply rule
4.344 +        hence "{j. j\<in>Basis \<and> x\<bullet>j \<noteq> 0} \<noteq> {j. j\<in>Basis \<and> ?y \<bullet> j \<noteq> 0}" using i'(3) by blast
4.345 +        hence **:"{j. j\<in>Basis \<and> ?y \<bullet> j \<noteq> 0} \<subset> {j. j\<in>Basis \<and> x\<bullet>j \<noteq> 0}"
4.346            by auto
4.347 -        have "card {j. j<DIM('a) \<and> ((\<chi>\<chi> j. ?y j)::'a) \$\$ j \<noteq> 0} \<le> n"
4.348 +        have "card {j. j\<in>Basis \<and> ?y \<bullet> j \<noteq> 0} \<le> n"
4.349            using less_le_trans[OF psubset_card_mono[OF _ **] Suc(4)] by auto
4.350 -        ultimately show ?thesis apply(subst *) apply(rule convex_convex_hull[unfolded convex_def, rule_format])
4.351 -          apply(rule_tac hull_subset[unfolded subset_eq, rule_format]) defer apply(rule Suc(1))
4.352 -          unfolding mem_interval using i01 Suc(3) by auto
4.353 -      qed qed qed } note * = this
4.354 -  have **:"DIM('a) = card {..<DIM('a)}" by auto
4.355 -  show ?thesis apply rule defer apply(rule hull_minimal) unfolding subset_eq prefer 3 apply rule
4.356 -    apply(rule_tac n2="DIM('a)" in *) prefer 3 apply(subst(2) **)
4.357 +        ultimately show ?thesis
4.358 +          apply(subst *)
4.359 +          apply(rule convex_convex_hull[unfolded convex_def, rule_format])
4.360 +          apply(rule_tac hull_subset[unfolded subset_eq, rule_format])
4.361 +          defer
4.362 +          apply(rule Suc(1))
4.363 +          unfolding mem_interval
4.364 +          using i01 Suc(3)
4.365 +          by auto
4.366 +      qed
4.367 +    qed
4.368 +  qed } note * = this
4.369 +  show ?thesis
4.370 +    apply rule defer apply(rule hull_minimal) unfolding subset_eq prefer 3 apply rule
4.371 +    apply(rule_tac n2="DIM('a)" in *) prefer 3
4.372      apply(rule card_mono) using 01 and convex_interval(1) prefer 5 apply - apply rule
4.373 -    unfolding mem_interval apply rule unfolding mem_Collect_eq apply(erule_tac x=i in allE)
4.374 -    by auto qed
4.375 +    unfolding mem_interval apply rule unfolding mem_Collect_eq apply(erule_tac x=i in ballE)
4.376 +    by auto
4.377 +qed
4.378
4.379  text {* And this is a finite set of vertices. *}
4.380
4.381 -lemma unit_cube_convex_hull: obtains s where "finite s" "{0 .. (\<chi>\<chi> i. 1)::'a::ordered_euclidean_space} = convex hull s"
4.382 -  apply(rule that[of "{x::'a. \<forall>i<DIM('a). x\$\$i=0 \<or> x\$\$i=1}"])
4.383 -  apply(rule finite_subset[of _ "(\<lambda>s. (\<chi>\<chi> i. if i\<in>s then 1::real else 0)::'a) ` Pow {..<DIM('a)}"])
4.384 +lemma unit_cube_convex_hull:
4.385 +  obtains s :: "'a::ordered_euclidean_space set" where "finite s" "{0 .. \<Sum>Basis} = convex hull s"
4.386 +  apply(rule that[of "{x::'a. \<forall>i\<in>Basis. x\<bullet>i=0 \<or> x\<bullet>i=1}"])
4.387 +  apply(rule finite_subset[of _ "(\<lambda>s. (\<Sum>i\<in>Basis. (if i\<in>s then 1 else 0) *\<^sub>R i)::'a) ` Pow Basis"])
4.388    prefer 3 apply(rule unit_interval_convex_hull) apply rule unfolding mem_Collect_eq proof-
4.389 -  fix x::"'a" assume as:"\<forall>i<DIM('a). x \$\$ i = 0 \<or> x \$\$ i = 1"
4.390 -  show "x \<in> (\<lambda>s. \<chi>\<chi> i. if i \<in> s then 1 else 0) ` Pow {..<DIM('a)}"
4.391 -    apply(rule image_eqI[where x="{i. i<DIM('a) \<and> x\$\$i = 1}"])
4.392 -    using as apply(subst euclidean_eq) by auto qed auto
4.393 +  fix x::"'a" assume as:"\<forall>i\<in>Basis. x \<bullet> i = 0 \<or> x \<bullet> i = 1"
4.394 +  show "x \<in> (\<lambda>s. \<Sum>i\<in>Basis. (if i\<in>s then 1 else 0) *\<^sub>R i) ` Pow Basis"
4.395 +    apply(rule image_eqI[where x="{i. i\<in>Basis \<and> x\<bullet>i = 1}"])
4.396 +    using as apply(subst euclidean_eq_iff) by (auto simp: inner_setsum_left_Basis)
4.397 +qed auto
4.398
4.399  text {* Hence any cube (could do any nonempty interval). *}
4.400
4.401  lemma cube_convex_hull:
4.402    assumes "0 < d" obtains s::"('a::ordered_euclidean_space) set" where
4.403 -  "finite s" "{x - (\<chi>\<chi> i. d) .. x + (\<chi>\<chi> i. d)} = convex hull s" proof-
4.404 -  let ?d = "(\<chi>\<chi> i. d)::'a"
4.405 -  have *:"{x - ?d .. x + ?d} = (\<lambda>y. x - ?d + (2 * d) *\<^sub>R y) ` {0 .. \<chi>\<chi> i. 1}" apply(rule set_eqI, rule)
4.406 +  "finite s" "{x - (\<Sum>i\<in>Basis. d*\<^sub>Ri) .. x + (\<Sum>i\<in>Basis. d*\<^sub>Ri)} = convex hull s" proof-
4.407 +  let ?d = "(\<Sum>i\<in>Basis. d*\<^sub>Ri)::'a"
4.408 +  have *:"{x - ?d .. x + ?d} = (\<lambda>y. x - ?d + (2 * d) *\<^sub>R y) ` {0 .. \<Sum>Basis}" apply(rule set_eqI, rule)
4.409      unfolding image_iff defer apply(erule bexE) proof-
4.410      fix y assume as:"y\<in>{x - ?d .. x + ?d}"
4.411 -    { fix i assume i:"i<DIM('a)" have "x \$\$ i \<le> d + y \$\$ i" "y \$\$ i \<le> d + x \$\$ i"
4.412 -        using as[unfolded mem_interval, THEN spec[where x=i]] i
4.413 -        by auto
4.414 -      hence "1 \<ge> inverse d * (x \$\$ i - y \$\$ i)" "1 \<ge> inverse d * (y \$\$ i - x \$\$ i)"
4.415 +    { fix i :: 'a assume i:"i\<in>Basis" have "x \<bullet> i \<le> d + y \<bullet> i" "y \<bullet> i \<le> d + x \<bullet> i"
4.416 +        using as[unfolded mem_interval, THEN bspec[where x=i]] i
4.417 +        by (auto simp: inner_simps)
4.418 +      hence "1 \<ge> inverse d * (x \<bullet> i - y \<bullet> i)" "1 \<ge> inverse d * (y \<bullet> i - x \<bullet> i)"
4.419          apply(rule_tac[!] mult_left_le_imp_le[OF _ assms]) unfolding mult_assoc[symmetric]
4.420          using assms by(auto simp add: field_simps)
4.421 -      hence "inverse d * (x \$\$ i * 2) \<le> 2 + inverse d * (y \$\$ i * 2)"
4.422 -            "inverse d * (y \$\$ i * 2) \<le> 2 + inverse d * (x \$\$ i * 2)" by(auto simp add:field_simps) }
4.423 -    hence "inverse (2 * d) *\<^sub>R (y - (x - ?d)) \<in> {0..\<chi>\<chi> i.1}" unfolding mem_interval using assms
4.424 -      by(auto simp add: field_simps)
4.425 -    thus "\<exists>z\<in>{0..\<chi>\<chi> i.1}. y = x - ?d + (2 * d) *\<^sub>R z" apply- apply(rule_tac x="inverse (2 * d) *\<^sub>R (y - (x - ?d))" in bexI)
4.426 +      hence "inverse d * (x \<bullet> i * 2) \<le> 2 + inverse d * (y \<bullet> i * 2)"
4.427 +            "inverse d * (y \<bullet> i * 2) \<le> 2 + inverse d * (x \<bullet> i * 2)" by(auto simp add:field_simps) }
4.428 +    hence "inverse (2 * d) *\<^sub>R (y - (x - ?d)) \<in> {0..\<Sum>Basis}" unfolding mem_interval using assms
4.429 +      by(auto simp add: field_simps inner_simps)
4.430 +    thus "\<exists>z\<in>{0..\<Sum>Basis}. y = x - ?d + (2 * d) *\<^sub>R z" apply- apply(rule_tac x="inverse (2 * d) *\<^sub>R (y - (x - ?d))" in bexI)
4.431        using assms by auto
4.432    next
4.433 -    fix y z assume as:"z\<in>{0..\<chi>\<chi> i.1}" "y = x - ?d + (2*d) *\<^sub>R z"
4.434 -    have "\<And>i. i<DIM('a) \<Longrightarrow> 0 \<le> d * z \$\$ i \<and> d * z \$\$ i \<le> d"
4.435 -      using assms as(1)[unfolded mem_interval] apply(erule_tac x=i in allE)
4.436 +    fix y z assume as:"z\<in>{0..\<Sum>Basis}" "y = x - ?d + (2*d) *\<^sub>R z"
4.437 +    have "\<And>i. i\<in>Basis \<Longrightarrow> 0 \<le> d * (z \<bullet> i) \<and> d * (z \<bullet> i) \<le> d"
4.438 +      using assms as(1)[unfolded mem_interval] apply(erule_tac x=i in ballE)
4.439        apply rule apply(rule mult_nonneg_nonneg) prefer 3 apply(rule mult_right_le_one_le)
4.440        using assms by auto
4.441      thus "y \<in> {x - ?d..x + ?d}" unfolding as(2) mem_interval apply- apply rule using as(1)[unfolded mem_interval]
4.442 -      apply(erule_tac x=i in allE) using assms by auto qed
4.443 -  obtain s where "finite s" "{0::'a..\<chi>\<chi> i.1} = convex hull s" using unit_cube_convex_hull by auto
4.444 +      apply(erule_tac x=i in ballE) using assms by (auto simp: inner_simps) qed
4.445 +  obtain s where "finite s" "{0::'a..\<Sum>Basis} = convex hull s" using unit_cube_convex_hull by auto
4.446    thus ?thesis apply(rule_tac that[of "(\<lambda>y. x - ?d + (2 * d) *\<^sub>R y)` s"]) unfolding * and convex_hull_affinity by auto qed
4.447
4.448  subsection {* Bounded convex function on open set is continuous *}
4.449 @@ -4103,6 +4093,9 @@
4.450
4.451  subsubsection {* Hence a convex function on an open set is continuous *}
4.452
4.453 +lemma real_of_nat_ge_one_iff: "1 \<le> real (n::nat) \<longleftrightarrow> 1 \<le> n"
4.454 +  by auto
4.455 +
4.456  lemma convex_on_continuous:
4.457    assumes "open (s::('a::ordered_euclidean_space) set)" "convex_on s f"
4.458    (* FIXME: generalize to euclidean_space *)
4.459 @@ -4113,29 +4106,40 @@
4.460    then obtain e where e:"cball x e \<subseteq> s" "e>0" using assms(1) unfolding open_contains_cball by auto
4.461    def d \<equiv> "e / real DIM('a)"
4.462    have "0 < d" unfolding d_def using `e>0` dimge1 by(rule_tac divide_pos_pos, auto)
4.463 -  let ?d = "(\<chi>\<chi> i. d)::'a"
4.464 +  let ?d = "(\<Sum>i\<in>Basis. d *\<^sub>R i)::'a"
4.465    obtain c where c:"finite c" "{x - ?d..x + ?d} = convex hull c" using cube_convex_hull[OF `d>0`, of x] by auto
4.466 -  have "x\<in>{x - ?d..x + ?d}" using `d>0` unfolding mem_interval by auto
4.467 +  have "x\<in>{x - ?d..x + ?d}" using `d>0` unfolding mem_interval by (auto simp: inner_setsum_left_Basis inner_simps)
4.468    hence "c\<noteq>{}" using c by auto
4.469    def k \<equiv> "Max (f ` c)"
4.470 -  have "convex_on {x - ?d..x + ?d} f" apply(rule convex_on_subset[OF assms(2)])
4.471 -    apply(rule subset_trans[OF _ e(1)]) unfolding subset_eq mem_cball proof
4.472 +  have "convex_on {x - ?d..x + ?d} f"
4.473 +    apply(rule convex_on_subset[OF assms(2)])
4.474 +    apply(rule subset_trans[OF _ e(1)])
4.475 +    unfolding subset_eq mem_cball
4.476 +  proof
4.477      fix z assume z:"z\<in>{x - ?d..x + ?d}"
4.478 -    have e:"e = setsum (\<lambda>i. d) {..<DIM('a)}" unfolding setsum_constant d_def using dimge1
4.479 +    have e:"e = setsum (\<lambda>i::'a. d) Basis" unfolding setsum_constant d_def using dimge1
4.480        unfolding real_eq_of_nat by auto
4.481      show "dist x z \<le> e" unfolding dist_norm e apply(rule_tac order_trans[OF norm_le_l1], rule setsum_mono)
4.482 -      using z[unfolded mem_interval] apply(erule_tac x=i in allE) by auto qed
4.483 +      using z[unfolded mem_interval] apply(erule_tac x=b in ballE) by (auto simp: inner_simps)
4.484 +  qed
4.485    hence k:"\<forall>y\<in>{x - ?d..x + ?d}. f y \<le> k" unfolding c(2) apply(rule_tac convex_on_convex_hull_bound) apply assumption
4.486      unfolding k_def apply(rule, rule Max_ge) using c(1) by auto
4.487 -  have "d \<le> e" unfolding d_def apply(rule mult_imp_div_pos_le) using `e>0` dimge1 unfolding mult_le_cancel_left1 by auto
4.488 +  have "d \<le> e"
4.489 +    unfolding d_def
4.490 +    apply(rule mult_imp_div_pos_le)
4.491 +    using `e>0`
4.492 +    unfolding mult_le_cancel_left1
4.493 +    apply (auto simp: real_of_nat_ge_one_iff Suc_le_eq DIM_positive)
4.494 +    done
4.495    hence dsube:"cball x d \<subseteq> cball x e" unfolding subset_eq Ball_def mem_cball by auto
4.496    have conv:"convex_on (cball x d) f" apply(rule convex_on_subset, rule convex_on_subset[OF assms(2)]) apply(rule e(1)) using dsube by auto
4.497    hence "\<forall>y\<in>cball x d. abs (f y) \<le> k + 2 * abs (f x)" apply(rule_tac convex_bounds_lemma) apply assumption proof
4.498      fix y assume y:"y\<in>cball x d"
4.499 -    { fix i assume "i<DIM('a)" hence "x \$\$ i - d \<le> y \$\$ i"  "y \$\$ i \<le> x \$\$ i + d"
4.500 -        using order_trans[OF component_le_norm y[unfolded mem_cball dist_norm], of i] by auto  }
4.501 +    { fix i :: 'a assume "i\<in>Basis" hence "x \<bullet> i - d \<le> y \<bullet> i"  "y \<bullet> i \<le> x \<bullet> i + d"
4.502 +        using order_trans[OF Basis_le_norm y[unfolded mem_cball dist_norm], of i] by (auto simp: inner_diff_left)  }
4.503      thus "f y \<le> k" apply(rule_tac k[rule_format]) unfolding mem_cball mem_interval dist_norm
4.504 -      by auto qed
4.505 +      by (auto simp: inner_simps)
4.506 +  qed
4.507    hence "continuous_on (ball x d) f" apply(rule_tac convex_on_bounded_continuous)
4.508      apply(rule open_ball, rule convex_on_subset[OF conv], rule ball_subset_cball)
4.509      apply force
4.510 @@ -4266,25 +4270,26 @@
4.511        have "norm (a - x) / norm (a - b) \<le> 1" unfolding divide_le_eq_1_pos[OF Fal2]
4.512          unfolding as[unfolded dist_norm] norm_ge_zero by auto
4.513        thus "\<exists>u. x = (1 - u) *\<^sub>R a + u *\<^sub>R b \<and> 0 \<le> u \<and> u \<le> 1" apply(rule_tac x="dist a x / dist a b" in exI)
4.514 -        unfolding dist_norm apply(subst euclidean_eq) apply rule defer apply(rule, rule divide_nonneg_pos) prefer 4
4.515 -      proof(rule,rule) fix i assume i:"i<DIM('a)"
4.516 -          have "((1 - norm (a - x) / norm (a - b)) *\<^sub>R a + (norm (a - x) / norm (a - b)) *\<^sub>R b) \$\$ i =
4.517 -            ((norm (a - b) - norm (a - x)) * (a \$\$ i) + norm (a - x) * (b \$\$ i)) / norm (a - b)"
4.518 -            using Fal by(auto simp add: field_simps)
4.519 -          also have "\<dots> = x\$\$i" apply(rule divide_eq_imp[OF Fal])
4.520 +        unfolding dist_norm apply(subst euclidean_eq_iff) apply rule defer apply(rule, rule divide_nonneg_pos) prefer 4
4.521 +      proof(rule) fix i :: 'a assume i:"i\<in>Basis"
4.522 +          have "((1 - norm (a - x) / norm (a - b)) *\<^sub>R a + (norm (a - x) / norm (a - b)) *\<^sub>R b) \<bullet> i =
4.523 +            ((norm (a - b) - norm (a - x)) * (a \<bullet> i) + norm (a - x) * (b \<bullet> i)) / norm (a - b)"
4.524 +            using Fal by(auto simp add: field_simps inner_simps)
4.525 +          also have "\<dots> = x\<bullet>i" apply(rule divide_eq_imp[OF Fal])
4.526              unfolding as[unfolded dist_norm] using as[unfolded dist_triangle_eq] apply-
4.527 -            apply(subst (asm) euclidean_eq) using i apply(erule_tac x=i in allE) by(auto simp add:field_simps)
4.528 -          finally show "x \$\$ i = ((1 - norm (a - x) / norm (a - b)) *\<^sub>R a + (norm (a - x) / norm (a - b)) *\<^sub>R b) \$\$ i"
4.529 +            apply(subst (asm) euclidean_eq_iff) using i apply(erule_tac x=i in ballE) by(auto simp add:field_simps inner_simps)
4.530 +          finally show "x \<bullet> i = ((1 - norm (a - x) / norm (a - b)) *\<^sub>R a + (norm (a - x) / norm (a - b)) *\<^sub>R b) \<bullet> i"
4.531              by auto
4.532 -        qed(insert Fal2, auto) qed qed
4.533 +        qed(insert Fal2, auto) qed
4.534 +qed
4.535
4.536  lemma between_midpoint: fixes a::"'a::euclidean_space" shows
4.537    "between (a,b) (midpoint a b)" (is ?t1)
4.538    "between (b,a) (midpoint a b)" (is ?t2)
4.539  proof- have *:"\<And>x y z. x = (1/2::real) *\<^sub>R z \<Longrightarrow> y = (1/2) *\<^sub>R z \<Longrightarrow> norm z = norm x + norm y" by auto
4.540    show ?t1 ?t2 unfolding between midpoint_def dist_norm apply(rule_tac[!] *)
4.541 -    unfolding euclidean_eq[where 'a='a]
4.542 -    by(auto simp add:field_simps) qed
4.543 +    unfolding euclidean_eq_iff[where 'a='a]
4.544 +    by(auto simp add:field_simps inner_simps) qed
4.545
4.546  lemma between_mem_convex_hull:
4.547    "between (a,b) x \<longleftrightarrow> x \<in> convex hull {a,b}"
4.548 @@ -4303,7 +4308,7 @@
4.549      have *:"y = (1 - (1 - e)) *\<^sub>R ((1 / e) *\<^sub>R y - ((1 - e) / e) *\<^sub>R x) + (1 - e) *\<^sub>R x" using `e>0` by (auto simp add: scaleR_left_diff_distrib scaleR_right_diff_distrib)
4.550      have "dist c ((1 / e) *\<^sub>R y - ((1 - e) / e) *\<^sub>R x) = abs(1/e) * norm (e *\<^sub>R c - y + (1 - e) *\<^sub>R x)"
4.551        unfolding dist_norm unfolding norm_scaleR[symmetric] apply(rule arg_cong[where f=norm]) using `e>0`
4.552 -      by(auto simp add: euclidean_eq[where 'a='a] field_simps)
4.553 +      by(auto simp add: euclidean_eq_iff[where 'a='a] field_simps inner_simps)
4.554      also have "\<dots> = abs(1/e) * norm (x - e *\<^sub>R (x - c) - y)" by(auto intro!:arg_cong[where f=norm] simp add: algebra_simps)
4.555      also have "\<dots> < d" using as[unfolded dist_norm] and `e>0`
4.556        by(auto simp add:pos_divide_less_eq[OF `e>0`] mult_commute)
4.557 @@ -4347,236 +4352,237 @@
4.558    apply(rule_tac x=u in exI) defer apply(rule_tac x="\<lambda>x. if x = 0 then 1 - setsum u s else u x" in exI) using assms(2)
4.559    unfolding if_smult and setsum_delta_notmem[OF assms(2)] by auto
4.560
4.561 -lemma substd_simplex: assumes "d\<subseteq>{..<DIM('a::euclidean_space)}"
4.562 -  shows "convex hull (insert 0 { basis i | i. i : d}) =
4.563 -        {x::'a::euclidean_space . (!i<DIM('a). 0 <= x\$\$i) & setsum (%i. x\$\$i) d <= 1 &
4.564 -  (!i<DIM('a). i ~: d --> x\$\$i = 0)}"
4.565 +lemma substd_simplex:
4.566 +  assumes d: "d \<subseteq> Basis"
4.567 +  shows "convex hull (insert 0 d) = {x. (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> (\<Sum>i\<in>d. x\<bullet>i) \<le> 1 \<and> (\<forall>i\<in>Basis. i \<notin> d --> x\<bullet>i = 0)}"
4.568    (is "convex hull (insert 0 ?p) = ?s")
4.569 -(* Proof is a modified copy of the proof of similar lemma std_simplex in Convex_Euclidean_Space.thy *)
4.570 -proof- let ?D = d (*"{..<DIM('a::euclidean_space)}"*)
4.571 +proof- let ?D = d
4.572    have "0 ~: ?p" using assms by (auto simp: image_def)
4.573 -  have "{(basis i)::'n::euclidean_space |i. i \<in> ?D} = basis ` ?D" by auto
4.574 -  note sumbas = this setsum_reindex[OF basis_inj_on[of d], unfolded o_def, OF assms]
4.575 -  show ?thesis unfolding simplex[OF finite_substdbasis `0 ~: ?p`]
4.576 +  from d have "finite d" by (blast intro: finite_subset finite_Basis)
4.577 +  show ?thesis unfolding simplex[OF `finite d` `0 ~: ?p`]
4.578      apply(rule set_eqI) unfolding mem_Collect_eq apply rule
4.579      apply(erule exE, (erule conjE)+) apply(erule_tac[2] conjE)+ proof-
4.580 -    fix x::"'a::euclidean_space" and u assume as: "\<forall>x\<in>{basis i |i. i \<in>?D}. 0 \<le> u x"
4.581 -      "setsum u {basis i |i. i \<in> ?D} \<le> 1" "(\<Sum>x\<in>{basis i |i. i \<in>?D}. u x *\<^sub>R x) = x"
4.582 -    have *:"\<forall>i<DIM('a). i:d --> u (basis i) = x\$\$i" and "(!i<DIM('a). i ~: d --> x \$\$ i = 0)" using as(3)
4.583 -      unfolding sumbas unfolding substdbasis_expansion_unique[OF assms] by auto
4.584 -    hence **:"setsum u {basis i |i. i \<in> ?D} = setsum (op \$\$ x) ?D" unfolding sumbas
4.585 +    fix x::"'a::euclidean_space" and u assume as: "\<forall>x\<in>?D. 0 \<le> u x"
4.586 +      "setsum u ?D \<le> 1" "(\<Sum>x\<in>?D. u x *\<^sub>R x) = x"
4.587 +    have *:"\<forall>i\<in>Basis. i:d --> u i = x\<bullet>i" and "(\<forall>i\<in>Basis. i ~: d --> x \<bullet> i = 0)" using as(3)
4.588 +      unfolding substdbasis_expansion_unique[OF assms] by auto
4.589 +    hence **:"setsum u ?D = setsum (op \<bullet> x) ?D"
4.590        apply-apply(rule setsum_cong2) using assms by auto
4.591 -    have " (\<forall>i<DIM('a). 0 \<le> x\$\$i) \<and> setsum (op \$\$ x) ?D \<le> 1"
4.592 -      apply - proof(rule,rule,rule)
4.593 -      fix i assume i:"i<DIM('a)" have "i : d ==> 0 \<le> x\$\$i" unfolding *[rule_format,OF i,symmetric]
4.594 +    have " (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> setsum (op \<bullet> x) ?D \<le> 1"
4.595 +      apply - proof(rule,rule)
4.596 +      fix i :: 'a assume i:"i\<in>Basis" have "i : d ==> 0 \<le> x\<bullet>i" unfolding *[rule_format,OF i,symmetric]
4.597           apply(rule_tac as(1)[rule_format]) by auto
4.598 -      moreover have "i ~: d ==> 0 \<le> x\$\$i"
4.599 -        using `(!i<DIM('a). i ~: d --> x \$\$ i = 0)`[rule_format, OF i] by auto
4.600 -      ultimately show "0 \<le> x\$\$i" by auto
4.601 +      moreover have "i ~: d ==> 0 \<le> x\<bullet>i"
4.602 +        using `(\<forall>i\<in>Basis. i ~: d --> x \<bullet> i = 0)`[rule_format, OF i] by auto
4.603 +      ultimately show "0 \<le> x\<bullet>i" by auto
4.604      qed(insert as(2)[unfolded **], auto)
4.605 -    from this show " (\<forall>i<DIM('a). 0 \<le> x\$\$i) \<and> setsum (op \$\$ x) ?D \<le> 1 & (!i<DIM('a). i ~: d --> x \$\$ i = 0)"
4.606 -      using `(!i<DIM('a). i ~: d --> x \$\$ i = 0)` by auto
4.607 -  next fix x::"'a::euclidean_space" assume as:"\<forall>i<DIM('a). 0 \<le> x \$\$ i" "setsum (op \$\$ x) ?D \<le> 1"
4.608 -      "(!i<DIM('a). i ~: d --> x \$\$ i = 0)"
4.609 -    show "\<exists>u. (\<forall>x\<in>{basis i |i. i \<in> ?D}. 0 \<le> u x) \<and>
4.610 -      setsum u {basis i |i. i \<in> ?D} \<le> 1 \<and> (\<Sum>x\<in>{basis i |i. i \<in> ?D}. u x *\<^sub>R x) = x"
4.611 -      apply(rule_tac x="\<lambda>y. inner y x" in exI) apply(rule,rule) unfolding mem_Collect_eq apply(erule exE)
4.612 -      using as(1) apply(erule_tac x=i in allE) unfolding sumbas apply safe unfolding not_less basis_zero
4.613 -      unfolding substdbasis_expansion_unique[OF assms] euclidean_component_def[symmetric]
4.614 -      using as(2,3) by(auto simp add:dot_basis not_less)
4.615 -  qed qed
4.616 +    from this show " (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> setsum (op \<bullet> x) ?D \<le> 1 & (\<forall>i\<in>Basis. i ~: d --> x \<bullet> i = 0)"
4.617 +      using `(\<forall>i\<in>Basis. i ~: d --> x \<bullet> i = 0)` by auto
4.618 +  next fix x::"'a::euclidean_space" assume as:"\<forall>i\<in>Basis. 0 \<le> x \<bullet> i" "setsum (op \<bullet> x) ?D \<le> 1"
4.619 +      "(\<forall>i\<in>Basis. i ~: d --> x \<bullet> i = 0)"
4.620 +    show "\<exists>u. (\<forall>x\<in>?D. 0 \<le> u x) \<and> setsum u ?D \<le> 1 \<and> (\<Sum>x\<in>?D. u x *\<^sub>R x) = x"
4.621 +      using as d unfolding substdbasis_expansion_unique[OF assms]
4.622 +      by (rule_tac x="inner x" in exI) auto
4.623 +  qed
4.624 +qed
4.625
4.626  lemma std_simplex:
4.627 -  "convex hull (insert 0 { basis i | i. i<DIM('a)}) =
4.628 -        {x::'a::euclidean_space . (\<forall>i<DIM('a). 0 \<le> x\$\$i) \<and> setsum (\<lambda>i. x\$\$i) {..<DIM('a)} \<le> 1 }"
4.629 -  using substd_simplex[of "{..<DIM('a)}"] by auto
4.630 +  "convex hull (insert 0 Basis) =
4.631 +        {x::'a::euclidean_space . (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> setsum (\<lambda>i. x\<bullet>i) Basis \<le> 1 }"
4.632 +  using substd_simplex[of Basis] by auto
4.633
4.634  lemma interior_std_simplex:
4.635 -  "interior (convex hull (insert 0 { basis i| i. i<DIM('a)})) =
4.636 -  {x::'a::euclidean_space. (\<forall>i<DIM('a). 0 < x\$\$i) \<and> setsum (\<lambda>i. x\$\$i) {..<DIM('a)} < 1 }"
4.637 +  "interior (convex hull (insert 0 Basis)) =
4.638 +  {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 < x\<bullet>i) \<and> setsum (\<lambda>i. x\<bullet>i) Basis < 1 }"
4.639    apply(rule set_eqI) unfolding mem_interior std_simplex unfolding subset_eq mem_Collect_eq Ball_def mem_ball
4.640    unfolding Ball_def[symmetric] apply rule apply(erule exE, (erule conjE)+) defer apply(erule conjE) proof-
4.641 -  fix x::"'a" and e assume "0<e" and as:"\<forall>xa. dist x xa < e \<longrightarrow> (\<forall>x<DIM('a). 0 \<le> xa \$\$ x) \<and> setsum (op \$\$ xa) {..<DIM('a)} \<le> 1"
4.642 -  show "(\<forall>xa<DIM('a). 0 < x \$\$ xa) \<and> setsum (op \$\$ x) {..<DIM('a)} < 1" apply(safe) proof-
4.643 -    fix i assume i:"i<DIM('a)" thus "0 < x \$\$ i" using as[THEN spec[where x="x - (e / 2) *\<^sub>R basis i"]] and `e>0`
4.644 -      unfolding dist_norm by (auto elim!:allE[where x=i])
4.645 -  next have **:"dist x (x + (e / 2) *\<^sub>R basis 0) < e" using  `e>0`
4.646 -      unfolding dist_norm by(auto intro!: mult_strict_left_mono)
4.647 -    have "\<And>i. i<DIM('a) \<Longrightarrow> (x + (e / 2) *\<^sub>R basis 0) \$\$ i = x\$\$i + (if i = 0 then e/2 else 0)"
4.648 -      by auto
4.649 -    hence *:"setsum (op \$\$ (x + (e / 2) *\<^sub>R basis 0)) {..<DIM('a)} = setsum (\<lambda>i. x\$\$i + (if 0 = i then e/2 else 0)) {..<DIM('a)}"
4.650 +  fix x::"'a" and e assume "0<e" and as:"\<forall>xa. dist x xa < e \<longrightarrow> (\<forall>x\<in>Basis. 0 \<le> xa \<bullet> x) \<and> setsum (op \<bullet> xa) Basis \<le> 1"
4.651 +  show "(\<forall>xa\<in>Basis. 0 < x \<bullet> xa) \<and> setsum (op \<bullet> x) Basis < 1" apply(safe) proof-
4.652 +    fix i :: 'a assume i:"i\<in>Basis" thus "0 < x \<bullet> i" using as[THEN spec[where x="x - (e / 2) *\<^sub>R i"]] and `e>0`
4.653 +      unfolding dist_norm
4.654 +      by (auto elim!:ballE[where x=i] simp: inner_simps)
4.655 +  next have **:"dist x (x + (e / 2) *\<^sub>R (SOME i. i\<in>Basis)) < e" using  `e>0`
4.656 +      unfolding dist_norm by(auto intro!: mult_strict_left_mono simp: SOME_Basis)
4.657 +    have "\<And>i. i\<in>Basis \<Longrightarrow> (x + (e / 2) *\<^sub>R (SOME i. i\<in>Basis)) \<bullet> i = x\<bullet>i + (if i = (SOME i. i\<in>Basis) then e/2 else 0)"
4.658 +      by (auto simp: SOME_Basis inner_Basis inner_simps)
4.659 +    hence *:"setsum (op \<bullet> (x + (e / 2) *\<^sub>R (SOME i. i\<in>Basis))) Basis = setsum (\<lambda>i. x\<bullet>i + (if (SOME i. i\<in>Basis) = i then e/2 else 0)) Basis"
4.660        apply(rule_tac setsum_cong) by auto
4.661 -    have "setsum (op \$\$ x) {..<DIM('a)} < setsum (op \$\$ (x + (e / 2) *\<^sub>R basis 0)) {..<DIM('a)}" unfolding * setsum_addf
4.662 -      using `0<e` DIM_positive[where 'a='a] apply(subst setsum_delta') by auto
4.663 +    have "setsum (op \<bullet> x) Basis < setsum (op \<bullet> (x + (e / 2) *\<^sub>R (SOME i. i\<in>Basis))) Basis" unfolding * setsum_addf
4.664 +      using `0<e` DIM_positive[where 'a='a] apply(subst setsum_delta') by (auto simp: SOME_Basis)
4.665      also have "\<dots> \<le> 1" using ** apply(drule_tac as[rule_format]) by auto
4.666 -    finally show "setsum (op \$\$ x) {..<DIM('a)} < 1" by auto qed
4.667 -next fix x::"'a" assume as:"\<forall>i<DIM('a). 0 < x \$\$ i" "setsum (op \$\$ x) {..<DIM('a)} < 1"
4.668 +    finally show "setsum (op \<bullet> x) Basis < 1" by auto qed
4.669 +next fix x::"'a" assume as:"\<forall>i\<in>Basis. 0 < x \<bullet> i" "setsum (op \<bullet> x) Basis < 1"
4.670    guess a using UNIV_witness[where 'a='b] ..
4.671 -  let ?d = "(1 - setsum (op \$\$ x) {..<DIM('a)}) / real (DIM('a))"
4.672 -  have "Min ((op \$\$ x) ` {..<DIM('a)}) > 0" apply(rule Min_grI) using as(1) by auto
4.673 -  moreover have"?d > 0" apply(rule divide_pos_pos) using as(2) by(auto simp add: Suc_le_eq)
4.674 -  ultimately show "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> (\<forall>i<DIM('a). 0 \<le> y \$\$ i) \<and> setsum (op \$\$ y) {..<DIM('a)} \<le> 1"
4.675 -    apply(rule_tac x="min (Min ((op \$\$ x) ` {..<DIM('a)})) ?D" in exI) apply rule defer apply(rule,rule) proof-
4.676 -    fix y assume y:"dist x y < min (Min (op \$\$ x ` {..<DIM('a)})) ?d"
4.677 -    have "setsum (op \$\$ y) {..<DIM('a)} \<le> setsum (\<lambda>i. x\$\$i + ?d) {..<DIM('a)}" proof(rule setsum_mono)
4.678 -      fix i assume "i\<in>{..<DIM('a)}" hence "abs (y\$\$i - x\$\$i) < ?d" apply-apply(rule le_less_trans)
4.679 -        using component_le_norm[of "y - x" i]
4.680 -        using y[unfolded min_less_iff_conj dist_norm, THEN conjunct2] by(auto simp add: norm_minus_commute)
4.681 -      thus "y \$\$ i \<le> x \$\$ i + ?d" by auto qed
4.682 +  let ?d = "(1 - setsum (op \<bullet> x) Basis) / real (DIM('a))"
4.683 +  have "Min ((op \<bullet> x) ` Basis) > 0" apply(rule Min_grI) using as(1) by auto
4.684 +  moreover have"?d > 0" apply(rule divide_pos_pos) using as(2) by (auto simp add: Suc_le_eq DIM_positive)
4.685 +  ultimately show "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> (\<forall>i\<in>Basis. 0 \<le> y \<bullet> i) \<and> setsum (op \<bullet> y) Basis \<le> 1"
4.686 +    apply(rule_tac x="min (Min ((op \<bullet> x) ` Basis)) ?D" in exI) apply rule defer apply(rule,rule) proof-
4.687 +    fix y assume y:"dist x y < min (Min (op \<bullet> x ` Basis)) ?d"
4.688 +    have "setsum (op \<bullet> y) Basis \<le> setsum (\<lambda>i. x\<bullet>i + ?d) Basis" proof(rule setsum_mono)
4.689 +      fix i :: 'a assume i: "i\<in>Basis" hence "abs (y\<bullet>i - x\<bullet>i) < ?d" apply-apply(rule le_less_trans)
4.690 +        using Basis_le_norm[OF i, of "y - x"]
4.691 +        using y[unfolded min_less_iff_conj dist_norm, THEN conjunct2] by(auto simp add: norm_minus_commute inner_diff_left)
4.692 +      thus "y \<bullet> i \<le> x \<bullet> i + ?d" by auto qed
4.693      also have "\<dots> \<le> 1" unfolding setsum_addf setsum_constant real_eq_of_nat by(auto simp add: Suc_le_eq)
4.694 -    finally show "(\<forall>i<DIM('a). 0 \<le> y \$\$ i) \<and> setsum (op \$\$ y) {..<DIM('a)} \<le> 1"
4.695 -    proof safe fix i assume i:"i<DIM('a)"
4.696 -      have "norm (x - y) < x\$\$i" apply(rule less_le_trans)
4.697 +    finally show "(\<forall>i\<in>Basis. 0 \<le> y \<bullet> i) \<and> setsum (op \<bullet> y) Basis \<le> 1"
4.698 +    proof safe fix i :: 'a assume i:"i\<in>Basis"
4.699 +      have "norm (x - y) < x\<bullet>i" apply(rule less_le_trans)
4.700          apply(rule y[unfolded min_less_iff_conj dist_norm, THEN conjunct1]) using i by auto
4.701 -      thus "0 \<le> y\$\$i" using component_le_norm[of "x - y" i] and as(1)[rule_format, of i] by auto
4.702 +      thus "0 \<le> y\<bullet>i" using Basis_le_norm[OF i, of "x - y"] and as(1)[rule_format, OF i]
4.703 +        by (auto simp: inner_simps)
4.704      qed qed auto qed
4.705
4.706  lemma interior_std_simplex_nonempty: obtains a::"'a::euclidean_space" where
4.707 -  "a \<in> interior(convex hull (insert 0 {basis i | i . i<DIM('a)}))" proof-
4.708 -  let ?D = "{..<DIM('a)}" let ?a = "setsum (\<lambda>b::'a. inverse (2 * real DIM('a)) *\<^sub>R b) {(basis i) | i. i<DIM('a)}"
4.709 -  have *:"{basis i :: 'a | i. i<DIM('a)} = basis ` ?D" by auto
4.710 -  { fix i assume i:"i<DIM('a)" have "?a \$\$ i = inverse (2 * real DIM('a))"
4.711 -      unfolding euclidean_component_setsum * and setsum_reindex[OF basis_inj] and o_def
4.712 -      apply(rule trans[of _ "setsum (\<lambda>j. if i = j then inverse (2 * real DIM('a)) else 0) ?D"]) apply(rule setsum_cong2)
4.713 -      defer apply(subst setsum_delta') unfolding euclidean_component_def using i by(auto simp add:dot_basis) }
4.714 +  "a \<in> interior(convex hull (insert 0 Basis))" proof-
4.715 +  let ?D = "Basis :: 'a set" let ?a = "setsum (\<lambda>b::'a. inverse (2 * real DIM('a)) *\<^sub>R b) Basis"
4.716 +  { fix i :: 'a assume i:"i\<in>Basis" have "?a \<bullet> i = inverse (2 * real DIM('a))"
4.717 +      by (rule trans[of _ "setsum (\<lambda>j. if i = j then inverse (2 * real DIM('a)) else 0) ?D"])
4.718 +         (simp_all add: setsum_cases i) }
4.719    note ** = this
4.720    show ?thesis apply(rule that[of ?a]) unfolding interior_std_simplex mem_Collect_eq proof safe
4.721 -    fix i assume i:"i<DIM('a)" show "0 < ?a \$\$ i" unfolding **[OF i] by(auto simp add: Suc_le_eq)
4.722 -  next have "setsum (op \$\$ ?a) ?D = setsum (\<lambda>i. inverse (2 * real DIM('a))) ?D" apply(rule setsum_cong2, rule **) by auto
4.723 +    fix i :: 'a assume i:"i\<in>Basis" show "0 < ?a \<bullet> i" unfolding **[OF i] by(auto simp add: Suc_le_eq DIM_positive)
4.724 +  next have "setsum (op \<bullet> ?a) ?D = setsum (\<lambda>i. inverse (2 * real DIM('a))) ?D" apply(rule setsum_cong2, rule **) by auto
4.725      also have "\<dots> < 1" unfolding setsum_constant real_eq_of_nat divide_inverse[symmetric] by (auto simp add:field_simps)
4.726 -    finally show "setsum (op \$\$ ?a) ?D < 1" by auto qed qed
4.727 -
4.728 -lemma rel_interior_substd_simplex: assumes "d\<subseteq>{..<DIM('a::euclidean_space)}"
4.729 -  shows "rel_interior (convex hull (insert 0 { basis i| i. i : d})) =
4.730 -  {x::'a::euclidean_space. (\<forall>i\<in>d. 0 < x\$\$i) & setsum (%i. x\$\$i) d < 1 & (!i<DIM('a). i ~: d --> x\$\$i = 0)}"
4.731 +    finally show "setsum (op \<bullet> ?a) ?D < 1" by auto qed qed
4.732 +
4.733 +lemma rel_interior_substd_simplex: assumes d: "d\<subseteq>Basis"
4.734 +  shows "rel_interior (convex hull (insert 0 d)) =
4.735 +  {x::'a::euclidean_space. (\<forall>i\<in>d. 0 < x\<bullet>i) \<and> (\<Sum>i\<in>d. x\<bullet>i) < 1 \<and> (\<forall>i\<in>Basis. i ~: d --> x\<bullet>i = 0)}"
4.736    (is "rel_interior (convex hull (insert 0 ?p)) = ?s")
4.737  (* Proof is a modified copy of the proof of similar lemma interior_std_simplex in Convex_Euclidean_Space.thy *)
4.738  proof-
4.739  have "finite d" apply(rule finite_subset) using assms by auto
4.740 -{ assume "d={}" hence ?thesis using rel_interior_sing using euclidean_eq[of _ 0] by auto }
4.741 +{ assume "d={}" hence ?thesis using rel_interior_sing using euclidean_eq_iff[of _ 0] by auto }
4.742  moreover
4.743  { assume "d~={}"
4.744 -have h0: "affine hull (convex hull (insert 0 ?p))={x::'a::euclidean_space. (!i<DIM('a). i ~: d --> x\$\$i = 0)}"
4.745 +have h0: "affine hull (convex hull (insert 0 ?p))={x::'a::euclidean_space. (\<forall>i\<in>Basis. i ~: d --> x\<bullet>i = 0)}"
4.746     using affine_hull_convex_hull affine_hull_substd_basis assms by auto
4.747 -have aux: "!x::'n::euclidean_space. !i. ((! i:d. 0 <= x\$\$i) & (!i. i ~: d --> x\$\$i = 0))--> 0 <= x\$\$i" by auto
4.748 +have aux: "!!x::'a. \<forall>i\<in>Basis. ((\<forall>i\<in>d. 0 \<le> x\<bullet>i) \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0)) \<longrightarrow> 0 \<le> x\<bullet>i"
4.749 +  by auto
4.750  { fix x::"'a::euclidean_space" assume x_def: "x : rel_interior (convex hull (insert 0 ?p))"
4.751    from this obtain e where e0: "e>0" and
4.752 -       "ball x e Int {xa. (!i<DIM('a). i ~: d --> xa\$\$i = 0)} <= convex hull (insert 0 ?p)"
4.753 +       "ball x e Int {xa. (\<forall>i\<in>Basis. i ~: d --> xa\<bullet>i = 0)} <= convex hull (insert 0 ?p)"
4.754         using mem_rel_interior_ball[of x "convex hull (insert 0 ?p)"] h0 by auto
4.755 -  hence as: "ALL xa. (dist x xa < e & (!i<DIM('a). i ~: d --> xa\$\$i = 0)) -->
4.756 -    (!i : d. 0 <= xa \$\$ i) & setsum (op \$\$ xa) d <= 1"
4.757 +  hence as: "ALL xa. (dist x xa < e & (\<forall>i\<in>Basis. i ~: d --> xa\<bullet>i = 0)) -->
4.758 +    (!i : d. 0 <= xa \<bullet> i) & setsum (op \<bullet> xa) d <= 1"
4.759      unfolding ball_def unfolding substd_simplex[OF assms] using assms by auto
4.760 -  have x0: "(!i<DIM('a). i ~: d --> x\$\$i = 0)"
4.761 +  have x0: "(\<forall>i\<in>Basis. i ~: d --> x\<bullet>i = 0)"
4.762      using x_def rel_interior_subset  substd_simplex[OF assms] by auto
4.763 -  have "(!i : d. 0 < x \$\$ i) & setsum (op \$\$ x) d < 1 & (!i<DIM('a). i ~: d --> x\$\$i = 0)" apply(rule,rule)
4.764 +  have "(\<forall>i\<in>d. 0 < x \<bullet> i) & setsum (op \<bullet> x) d < 1 & (\<forall>i\<in>Basis. i ~: d --> x\<bullet>i = 0)" apply(rule,rule)
4.765    proof-
4.766 -    fix i::nat assume "i:d"
4.767 -    hence "\<forall>ia\<in>d. 0 \<le> (x - (e / 2) *\<^sub>R basis i) \$\$ ia" apply-apply(rule as[rule_format,THEN conjunct1])
4.768 -      unfolding dist_norm using assms `e>0` x0 by auto
4.769 -    thus "0 < x \$\$ i" apply(erule_tac x=i in ballE) using `e>0` `i\<in>d` assms by auto
4.770 +    fix i::'a assume "i\<in>d"
4.771 +    hence "\<forall>ia\<in>d. 0 \<le> (x - (e / 2) *\<^sub>R i) \<bullet> ia" apply-apply(rule as[rule_format,THEN conjunct1])
4.772 +      unfolding dist_norm using d `e>0` x0 by (auto simp: inner_simps inner_Basis)
4.773 +    thus "0 < x \<bullet> i" apply(erule_tac x=i in ballE) using `e>0` `i\<in>d` d
4.774 +    by (auto simp: inner_simps inner_Basis)
4.775    next obtain a where a:"a:d" using `d ~= {}` by auto
4.776 -    have **:"dist x (x + (e / 2) *\<^sub>R basis a) < e"
4.777 -      using  `e>0` and Euclidean_Space.norm_basis[of a]
4.778 +    then have **:"dist x (x + (e / 2) *\<^sub>R a) < e"
4.779 +      using  `e>0` norm_Basis[of a] d
4.780        unfolding dist_norm by auto
4.781 -    have "\<And>i. (x + (e / 2) *\<^sub>R basis a) \$\$ i = x\$\$i + (if i = a then e/2 else 0)"
4.782 -      unfolding euclidean_simps using a assms by auto
4.783 -    hence *:"setsum (op \$\$ (x + (e / 2) *\<^sub>R basis a)) d =
4.784 -      setsum (\<lambda>i. x\$\$i + (if a = i then e/2 else 0)) d" by(rule_tac setsum_cong, auto)
4.785 -    have h1: "(ALL i<DIM('a). i ~: d --> (x + (e / 2) *\<^sub>R basis a) \$\$ i = 0)"
4.786 -      using as[THEN spec[where x="x + (e / 2) *\<^sub>R basis a"]] `a:d` using x0
4.787 -      by(auto elim:allE[where x=a])
4.788 -    have "setsum (op \$\$ x) d < setsum (op \$\$ (x + (e / 2) *\<^sub>R basis a)) d" unfolding * setsum_addf
4.789 +    have "\<And>i. i\<in>Basis \<Longrightarrow> (x + (e / 2) *\<^sub>R a) \<bullet> i = x\<bullet>i + (if i = a then e/2 else 0)"
4.790 +      using a d by (auto simp: inner_simps inner_Basis)
4.791 +    hence *:"setsum (op \<bullet> (x + (e / 2) *\<^sub>R a)) d =
4.792 +      setsum (\<lambda>i. x\<bullet>i + (if a = i then e/2 else 0)) d" using d by (intro setsum_cong) auto
4.793 +    have "a \<in> Basis" using `a \<in> d` d by auto
4.794 +    then have h1: "(\<forall>i\<in>Basis. i ~: d --> (x + (e / 2) *\<^sub>R a) \<bullet> i = 0)"
4.795 +      using x0 d `a\<in>d` by (auto simp add: inner_add_left inner_Basis)
4.796 +    have "setsum (op \<bullet> x) d < setsum (op \<bullet> (x + (e / 2) *\<^sub>R a)) d" unfolding * setsum_addf
4.797        using `0<e` `a:d` using `finite d` by(auto simp add: setsum_delta')
4.798 -    also have "\<dots> \<le> 1" using ** h1 as[rule_format, of "x + (e / 2) *\<^sub>R basis a"] by auto
4.799 -    finally show "setsum (op \$\$ x) d < 1 & (!i<DIM('a). i ~: d --> x\$\$i = 0)" using x0 by auto
4.800 +    also have "\<dots> \<le> 1" using ** h1 as[rule_format, of "x + (e / 2) *\<^sub>R a"] by auto
4.801 +    finally show "setsum (op \<bullet> x) d < 1 & (\<forall>i\<in>Basis. i ~: d --> x\<bullet>i = 0)" using x0 by auto
4.802    qed
4.803  }
4.804  moreover
4.805  {
4.806    fix x::"'a::euclidean_space" assume as: "x : ?s"
4.807 -  have "!i. ((0<x\$\$i) | (0=x\$\$i) --> 0<=x\$\$i)" by auto
4.808 +  have "!i. ((0<x\<bullet>i) | (0=x\<bullet>i) --> 0<=x\<bullet>i)" by auto
4.809    moreover have "!i. (i:d) | (i ~: d)" by auto
4.810    ultimately
4.811 -  have "!i. ( (ALL i:d. 0 < x\$\$i) & (ALL i. i ~: d --> x\$\$i = 0) ) --> 0 <= x\$\$i" by metis
4.812 +  have "!i. ( (ALL i:d. 0 < x\<bullet>i) & (ALL i. i ~: d --> x\<bullet>i = 0) ) --> 0 <= x\<bullet>i" by metis
4.813    hence h2: "x : convex hull (insert 0 ?p)" using as assms
4.814      unfolding substd_simplex[OF assms] by fastforce
4.815    obtain a where a:"a:d" using `d ~= {}` by auto
4.816 -  let ?d = "(1 - setsum (op \$\$ x) d) / real (card d)"
4.817 +  let ?d = "(1 - setsum (op \<bullet> x) d) / real (card d)"
4.818    have "0 < card d" using `d ~={}` `finite d` by (simp add: card_gt_0_iff)
4.819 -  have "Min ((op \$\$ x) ` d) > 0" using as `d \<noteq> {}` `finite d` by (simp add: Min_grI)
4.820 +  have "Min ((op \<bullet> x) ` d) > 0" using as `d \<noteq> {}` `finite d` by (simp add: Min_grI)
4.821    moreover have "?d > 0" apply(rule divide_pos_pos) using as using `0 < card d` by auto
4.822 -  ultimately have h3: "min (Min ((op \$\$ x) ` d)) ?d > 0" by auto
4.823 +  ultimately have h3: "min (Min ((op \<bullet> x) ` d)) ?d > 0" by auto
4.824
4.825    have "x : rel_interior (convex hull (insert 0 ?p))"
4.826      unfolding rel_interior_ball mem_Collect_eq h0 apply(rule,rule h2)
4.827      unfolding substd_simplex[OF assms]
4.828 -    apply(rule_tac x="min (Min ((op \$\$ x) ` d)) ?d" in exI) apply(rule,rule h3) apply safe unfolding mem_ball
4.829 -  proof- fix y::'a assume y:"dist x y < min (Min (op \$\$ x ` d)) ?d" and y2:"(!i<DIM('a). i ~: d --> y\$\$i = 0)"
4.830 -    have "setsum (op \$\$ y) d \<le> setsum (\<lambda>i. x\$\$i + ?d) d" proof(rule setsum_mono)
4.831 -      fix i assume i:"i\<in>d"
4.832 -      have "abs (y\$\$i - x\$\$i) < ?d" apply(rule le_less_trans) using component_le_norm[of "y - x" i]
4.833 +    apply(rule_tac x="min (Min ((op \<bullet> x) ` d)) ?d" in exI) apply(rule,rule h3) apply safe unfolding mem_ball
4.834 +  proof-
4.835 +    fix y::'a assume y:"dist x y < min (Min (op \<bullet> x ` d)) ?d" and y2: "\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> y\<bullet>i = 0"
4.836 +    have "setsum (op \<bullet> y) d \<le> setsum (\<lambda>i. x\<bullet>i + ?d) d"
4.837 +    proof(rule setsum_mono)
4.838 +      fix i assume "i \<in> d"
4.839 +      with d have i: "i \<in> Basis" by auto
4.840 +      have "abs (y\<bullet>i - x\<bullet>i) < ?d" apply(rule le_less_trans) using Basis_le_norm[OF i, of "y - x"]
4.841          using y[unfolded min_less_iff_conj dist_norm, THEN conjunct2]
4.842 -        by(auto simp add: norm_minus_commute)
4.843 -      thus "y \$\$ i \<le> x \$\$ i + ?d" by auto qed
4.844 +        by (auto simp add: norm_minus_commute inner_simps)
4.845 +      thus "y \<bullet> i \<le> x \<bullet> i + ?d" by auto
4.846 +    qed
4.847      also have "\<dots> \<le> 1" unfolding setsum_addf setsum_constant real_eq_of_nat
4.848        using `0 < card d` by auto
4.849 -    finally show "setsum (op \$\$ y) d \<le> 1" .
4.850 -
4.851 -    fix i assume "i<DIM('a)" thus "0 \<le> y\$\$i"
4.852 +    finally show "setsum (op \<bullet> y) d \<le> 1" .
4.853 +
4.854 +    fix i :: 'a assume i: "i \<in> Basis" thus "0 \<le> y\<bullet>i"
4.855      proof(cases "i\<in>d") case True
4.856 -      have "norm (x - y) < x\$\$i" using y[unfolded min_less_iff_conj dist_norm, THEN conjunct1]
4.857 -        using Min_gr_iff[of "op \$\$ x ` d" "norm (x - y)"] `0 < card d` `i:d`
4.858 +      have "norm (x - y) < x\<bullet>i" using y[unfolded min_less_iff_conj dist_norm, THEN conjunct1]
4.859 +        using Min_gr_iff[of "op \<bullet> x ` d" "norm (x - y)"] `0 < card d` `i:d`
4.861 -      thus "0 \<le> y\$\$i" using component_le_norm[of "x - y" i] and as(1)[rule_format] by auto
4.862 +      thus "0 \<le> y\<bullet>i" using Basis_le_norm[OF i, of "x - y"] and as(1)[rule_format]
4.863 +        by (auto simp: inner_simps)
4.864      qed(insert y2, auto)
4.865    qed
4.866  } ultimately have
4.867 -    "!!x :: 'a::euclidean_space. (x : rel_interior (convex hull insert 0 {basis i |i. i : d})) =
4.868 -    (x : {x. (ALL i:d. 0 < x \$\$ i) &
4.869 -    setsum (op \$\$ x) d < 1 & (ALL i<DIM('a). i ~: d --> x \$\$ i = 0)})" by blast
4.870 +    "\<And>x. (x : rel_interior (convex hull insert 0 d)) = (x \<in> {x. (ALL i:d. 0 < x \<bullet> i) &
4.871 +    setsum (op \<bullet> x) d < 1 & (\<forall>i\<in>Basis. i ~: d --> x \<bullet> i = 0)})" by blast
4.872  from this have ?thesis by (rule set_eqI)
4.873  } ultimately show ?thesis by blast
4.874  qed
4.875
4.876 -lemma rel_interior_substd_simplex_nonempty: assumes "d ~={}" "d\<subseteq>{..<DIM('a::euclidean_space)}"
4.877 +lemma rel_interior_substd_simplex_nonempty: assumes "d ~={}" "d\<subseteq>Basis"
4.878    obtains a::"'a::euclidean_space" where
4.879 -  "a : rel_interior(convex hull (insert 0 {basis i | i . i : d}))" proof-
4.880 +  "a : rel_interior(convex hull (insert 0 d))" proof-
4.881  (* Proof is a modified copy of the proof of similar lemma interior_std_simplex_nonempty in Convex_Euclidean_Space.thy *)
4.882 -  let ?D = d let ?a = "setsum (\<lambda>b::'a::euclidean_space. inverse (2 * real (card d)) *\<^sub>R b) {(basis i) | i. i \<in> ?D}"
4.883 -  have *:"{basis i :: 'a | i. i \<in> ?D} = basis ` ?D" by auto
4.884 +  let ?D = d let ?a = "setsum (\<lambda>b::'a::euclidean_space. inverse (2 * real (card d)) *\<^sub>R b) ?D"
4.885    have "finite d" apply(rule finite_subset) using assms(2) by auto
4.886    hence d1: "0 < real(card d)" using `d ~={}` by auto
4.887 -  { fix i assume "i:d" have "?a \$\$ i = inverse (2 * real (card d))"
4.888 -      unfolding * setsum_reindex[OF basis_inj_on, OF assms(2)] o_def
4.889 +  { fix i assume "i:d"
4.890 +    have "?a \<bullet> i = inverse (2 * real (card d))"
4.891        apply(rule trans[of _ "setsum (\<lambda>j. if i = j then inverse (2 * real (card d)) else 0) ?D"])
4.892 -      unfolding euclidean_component_setsum
4.893 +      unfolding inner_setsum_left
4.894        apply(rule setsum_cong2)
4.895        using `i:d` `finite d` setsum_delta'[of d i "(%k. inverse (2 * real (card d)))"] d1 assms(2)
4.896 -      by (auto simp add: Euclidean_Space.basis_component[of i])}
4.897 +      by (auto simp: inner_simps inner_Basis set_rev_mp[OF _ assms(2)]) }
4.898    note ** = this
4.899    show ?thesis apply(rule that[of ?a]) unfolding rel_interior_substd_simplex[OF assms(2)] mem_Collect_eq
4.900    proof safe fix i assume "i:d"
4.901      have "0 < inverse (2 * real (card d))" using d1 by auto
4.902 -    also have "...=?a \$\$ i" using **[of i] `i:d` by auto
4.903 -    finally show "0 < ?a \$\$ i" by auto
4.904 -  next have "setsum (op \$\$ ?a) ?D = setsum (\<lambda>i. inverse (2 * real (card d))) ?D"
4.905 +    also have "...=?a \<bullet> i" using **[of i] `i:d` by auto
4.906 +    finally show "0 < ?a \<bullet> i" by auto
4.907 +  next have "setsum (op \<bullet> ?a) ?D = setsum (\<lambda>i. inverse (2 * real (card d))) ?D"
4.908        by(rule setsum_cong2, rule **)
4.909      also have "\<dots> < 1" unfolding setsum_constant real_eq_of_nat divide_real_def[symmetric]
4.911 -    finally show "setsum (op \$\$ ?a) ?D < 1" by auto
4.912 -  next fix i assume "i<DIM('a)" and "i~:d"
4.913 -    have "?a : (span {basis i | i. i : d})"
4.914 -      apply (rule span_setsum[of "{basis i |i. i : d}" "(%b. b /\<^sub>R (2 * real (card d)))" "{basis i |i. i : d}"])
4.915 -      using finite_substdbasis[of d] apply blast
4.916 +    finally show "setsum (op \<bullet> ?a) ?D < 1" by auto
4.917 +  next fix i assume "i\<in>Basis" and "i~:d"
4.918 +    have "?a : (span d)"
4.919 +      apply (rule span_setsum[of d "(%b. b /\<^sub>R (2 * real (card d)))" d])
4.920 +      using finite_subset[OF assms(2) finite_Basis]
4.921 +      apply blast
4.922      proof-
4.923 -      { fix x assume "(x :: 'a::euclidean_space): {basis i |i. i : d}"
4.924 -        hence "x : span {basis i |i. i : d}"
4.925 -          using span_superset[of _ "{basis i |i. i : d}"] by auto
4.926 -        hence "(x /\<^sub>R (2 * real (card d))) : (span {basis i |i. i : d})"
4.927 -          using span_mul[of x "{basis i |i. i : d}" "(inverse (real (card d)) / 2)"] by auto
4.928 -      } thus "\<forall>x\<in>{basis i |i. i \<in> d}. x /\<^sub>R (2 * real (card d)) \<in> span {basis i ::'a |i. i \<in> d}" by auto
4.929 +      { fix x assume "(x :: 'a::euclidean_space): d"
4.930 +        hence "x : span d"
4.931 +          using span_superset[of _ "d"] by auto
4.932 +        hence "(x /\<^sub>R (2 * real (card d))) : (span d)"
4.933 +          using span_mul[of x "d" "(inverse (real (card d)) / 2)"] by auto
4.934 +      } thus "\<forall>x\<in>d. x /\<^sub>R (2 * real (card d)) \<in> span d" by auto
4.935      qed
4.936 -    thus "?a \$\$ i = 0 " using `i~:d` unfolding span_substd_basis[OF assms(2)] using `i<DIM('a)` by auto
4.937 +    thus "?a \<bullet> i = 0 " using `i~:d` unfolding span_substd_basis[OF assms(2)] using `i\<in>Basis` by auto
4.938    qed
4.939  qed
4.940
4.941 @@ -4608,14 +4614,14 @@
4.942  ultimately have **: "affine hull (convex hull insert 0 B) = affine hull S"
4.943      using affine_hull_span_0[of "convex hull insert 0 B"] affine_hull_span_0[of "S"]
4.944      assms  hull_subset[of S] by auto
4.945 -obtain d and f::"'n=>'n" where fd: "card d = card B & linear f & f ` B = {basis i |i. i : (d :: nat set)} &
4.946 -       f ` span B = {x. ALL i<DIM('n). i ~: d --> x \$\$ i = (0::real)} &  inj_on f (span B)" and d:"d\<subseteq>{..<DIM('n)}"
4.947 +obtain d and f::"'n=>'n" where fd: "card d = card B & linear f & f ` B = d &
4.948 +       f ` span B = {x. \<forall>i\<in>Basis. i ~: d --> x \<bullet> i = (0::real)} &  inj_on f (span B)" and d:"d\<subseteq>Basis"
4.949      using basis_to_substdbasis_subspace_isomorphism[of B,OF _ ] B_def by auto
4.950  hence "bounded_linear f" using linear_conv_bounded_linear by auto
4.951  have "d ~={}" using fd B_def `B ~={}` by auto
4.952 -have "(insert 0 {basis i |i. i : d}) = f ` (insert 0 B)" using fd linear_0 by auto
4.953 -hence "(convex hull (insert 0 {basis i |i. i : d})) = f ` (convex hull (insert 0 B))"
4.954 -   using convex_hull_linear_image[of f "(insert 0 {basis i |i. i : d})"]
4.955 +have "(insert 0 d) = f ` (insert 0 B)" using fd linear_0 by auto
4.956 +hence "(convex hull (insert 0 d)) = f ` (convex hull (insert 0 B))"
4.957 +   using convex_hull_linear_image[of f "(insert 0 d)"]
4.958     convex_hull_linear_image[of f "(insert 0 B)"] `bounded_linear f` by auto
4.959  moreover have "rel_interior (f ` (convex hull insert 0 B)) =
4.960     f ` rel_interior (convex hull insert 0 B)"
```
```     5.1 --- a/src/HOL/Multivariate_Analysis/Derivative.thy	Fri Dec 14 14:46:01 2012 +0100
5.2 +++ b/src/HOL/Multivariate_Analysis/Derivative.thy	Fri Dec 14 15:46:01 2012 +0100
5.3 @@ -158,9 +158,6 @@
5.4  lemmas mult_left_has_derivative =
5.5    bounded_linear.has_derivative [OF bounded_linear_mult_left]
5.6
5.7 -lemmas euclidean_component_has_derivative =
5.8 -  bounded_linear.has_derivative [OF bounded_linear_euclidean_component]
5.9 -
5.10  lemma has_derivative_neg:
5.11    assumes "(f has_derivative f') net"
5.12    shows "((\<lambda>x. -(f x)) has_derivative (\<lambda>h. -(f' h))) net"
5.13 @@ -191,20 +188,12 @@
5.15  text {* Somewhat different results for derivative of scalar multiplier. *}
5.16
5.17 -(** move **)
5.18 -lemma linear_vmul_component: (* TODO: delete *)
5.19 -  assumes lf: "linear f"
5.20 -  shows "linear (\<lambda>x. f x \$\$ k *\<^sub>R v)"
5.21 -  using lf
5.22 -  by (auto simp add: linear_def algebra_simps)
5.23 -
5.24  lemmas has_derivative_intros =
5.25    has_derivative_id has_derivative_const
5.28    scaleR_left_has_derivative scaleR_right_has_derivative
5.29    inner_left_has_derivative inner_right_has_derivative
5.30 -  euclidean_component_has_derivative
5.31
5.32  subsubsection {* Limit transformation for derivatives *}
5.33
5.34 @@ -531,7 +520,7 @@
5.35    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
5.36    assumes "(f has_derivative f') (at x within s)"
5.37    assumes "(f has_derivative f'') (at x within s)"
5.38 -  assumes "(\<forall>i<DIM('a). \<forall>e>0. \<exists>d. 0 < abs(d) \<and> abs(d) < e \<and> (x + d *\<^sub>R basis i) \<in> s)"
5.39 +  assumes "(\<forall>i\<in>Basis. \<forall>e>0. \<exists>d. 0 < abs(d) \<and> abs(d) < e \<and> (x + d *\<^sub>R i) \<in> s)"
5.40    shows "f' = f''"
5.41  proof-
5.42    note as = assms(1,2)[unfolded has_derivative_def]
5.43 @@ -540,32 +529,32 @@
5.44    have "x islimpt s" unfolding islimpt_approachable
5.45    proof(rule,rule)
5.46      fix e::real assume "0<e" guess d
5.47 -      using assms(3)[rule_format,OF DIM_positive `e>0`] ..
5.48 +      using assms(3)[rule_format,OF SOME_Basis `e>0`] ..
5.49      thus "\<exists>x'\<in>s. x' \<noteq> x \<and> dist x' x < e"
5.50 -      apply(rule_tac x="x + d *\<^sub>R basis 0" in bexI)
5.51 -      unfolding dist_norm by auto
5.52 +      apply(rule_tac x="x + d *\<^sub>R (SOME i. i \<in> Basis)" in bexI)
5.53 +      unfolding dist_norm by (auto simp: SOME_Basis nonzero_Basis)
5.54    qed
5.55    hence *:"netlimit (at x within s) = x" apply-apply(rule netlimit_within)
5.56      unfolding trivial_limit_within by simp
5.57    show ?thesis  apply(rule linear_eq_stdbasis)
5.58      unfolding linear_conv_bounded_linear
5.59      apply(rule as(1,2)[THEN conjunct1])+
5.60 -  proof(rule,rule,rule ccontr)
5.61 -    fix i assume i:"i<DIM('a)" def e \<equiv> "norm (f' (basis i) - f'' (basis i))"
5.62 -    assume "f' (basis i) \<noteq> f'' (basis i)"
5.63 +  proof(rule,rule ccontr)
5.64 +    fix i :: 'a assume i:"i \<in> Basis" def e \<equiv> "norm (f' i - f'' i)"
5.65 +    assume "f' i \<noteq> f'' i"
5.66      hence "e>0" unfolding e_def by auto
5.67      guess d using tendsto_diff [OF as(1,2)[THEN conjunct2], unfolded * Lim_within,rule_format,OF `e>0`] .. note d=this
5.68      guess c using assms(3)[rule_format,OF i d[THEN conjunct1]] .. note c=this
5.69 -    have *:"norm (- ((1 / \<bar>c\<bar>) *\<^sub>R f' (c *\<^sub>R basis i)) + (1 / \<bar>c\<bar>) *\<^sub>R f'' (c *\<^sub>R basis i)) = norm ((1 / abs c) *\<^sub>R (- (f' (c *\<^sub>R basis i)) + f'' (c *\<^sub>R basis i)))"
5.70 +    have *:"norm (- ((1 / \<bar>c\<bar>) *\<^sub>R f' (c *\<^sub>R i)) + (1 / \<bar>c\<bar>) *\<^sub>R f'' (c *\<^sub>R i)) = norm ((1 / abs c) *\<^sub>R (- (f' (c *\<^sub>R i)) + f'' (c *\<^sub>R i)))"
5.71        unfolding scaleR_right_distrib by auto
5.72 -    also have "\<dots> = norm ((1 / abs c) *\<^sub>R (c *\<^sub>R (- (f' (basis i)) + f'' (basis i))))"
5.73 +    also have "\<dots> = norm ((1 / abs c) *\<^sub>R (c *\<^sub>R (- (f' i) + f'' i)))"
5.74        unfolding f'.scaleR f''.scaleR
5.75        unfolding scaleR_right_distrib scaleR_minus_right by auto
5.76      also have "\<dots> = e" unfolding e_def using c[THEN conjunct1]
5.77 -      using norm_minus_cancel[of "f' (basis i) - f'' (basis i)"]
5.78 +      using norm_minus_cancel[of "f' i - f'' i"]
5.80      finally show False using c
5.81 -      using d[THEN conjunct2,rule_format,of "x + c *\<^sub>R basis i"]
5.82 +      using d[THEN conjunct2,rule_format,of "x + c *\<^sub>R i"]
5.83        unfolding dist_norm
5.85          scaleR_scaleR scaleR_right_diff_distrib scaleR_right_distrib
5.86 @@ -584,37 +573,38 @@
5.87
5.88  lemma frechet_derivative_unique_within_closed_interval:
5.89    fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
5.90 -  assumes "\<forall>i<DIM('a). a\$\$i < b\$\$i" "x \<in> {a..b}" (is "x\<in>?I")
5.91 +  assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i" "x \<in> {a..b}" (is "x\<in>?I")
5.92    assumes "(f has_derivative f' ) (at x within {a..b})"
5.93    assumes "(f has_derivative f'') (at x within {a..b})"
5.94    shows "f' = f''"
5.95    apply(rule frechet_derivative_unique_within)
5.96    apply(rule assms(3,4))+
5.97 -proof(rule,rule,rule,rule)
5.98 -  fix e::real and i assume "e>0" and i:"i<DIM('a)"
5.99 -  thus "\<exists>d. 0 < \<bar>d\<bar> \<and> \<bar>d\<bar> < e \<and> x + d *\<^sub>R basis i \<in> {a..b}"
5.100 -  proof(cases "x\$\$i=a\$\$i")
5.101 +proof(rule,rule,rule)
5.102 +  fix e::real and i :: 'a assume "e>0" and i:"i\<in>Basis"
5.103 +  thus "\<exists>d. 0 < \<bar>d\<bar> \<and> \<bar>d\<bar> < e \<and> x + d *\<^sub>R i \<in> {a..b}"
5.104 +  proof(cases "x\<bullet>i=a\<bullet>i")
5.105      case True thus ?thesis
5.106 -      apply(rule_tac x="(min (b\$\$i - a\$\$i)  e) / 2" in exI)
5.107 -      using assms(1)[THEN spec[where x=i]] and `e>0` and assms(2)
5.108 -      unfolding mem_interval euclidean_simps
5.109 -      using i by (auto simp add: field_simps)
5.110 -  next note * = assms(2)[unfolded mem_interval,THEN spec[where x=i]]
5.111 -    case False moreover have "a \$\$ i < x \$\$ i" using False * by auto
5.112 +      apply(rule_tac x="(min (b\<bullet>i - a\<bullet>i)  e) / 2" in exI)
5.113 +      using assms(1)[THEN bspec[where x=i]] and `e>0` and assms(2)
5.114 +      unfolding mem_interval
5.115 +      using i by (auto simp add: field_simps inner_simps inner_Basis)
5.116 +  next
5.117 +    note * = assms(2)[unfolded mem_interval, THEN bspec, OF i]
5.118 +    case False moreover have "a \<bullet> i < x \<bullet> i" using False * by auto
5.119      moreover {
5.120 -      have "a \$\$ i * 2 + min (x \$\$ i - a \$\$ i) e \<le> a\$\$i *2 + x\$\$i - a\$\$i"
5.121 +      have "a \<bullet> i * 2 + min (x \<bullet> i - a \<bullet> i) e \<le> a\<bullet>i *2 + x\<bullet>i - a\<bullet>i"
5.122          by auto
5.123 -      also have "\<dots> = a\$\$i + x\$\$i" by auto
5.124 -      also have "\<dots> \<le> 2 * x\$\$i" using * by auto
5.125 -      finally have "a \$\$ i * 2 + min (x \$\$ i - a \$\$ i) e \<le> x \$\$ i * 2" by auto
5.126 +      also have "\<dots> = a\<bullet>i + x\<bullet>i" by auto
5.127 +      also have "\<dots> \<le> 2 * (x\<bullet>i)" using * by auto
5.128 +      finally have "a \<bullet> i * 2 + min (x \<bullet> i - a \<bullet> i) e \<le> x \<bullet> i * 2" by auto
5.129      }
5.130 -    moreover have "min (x \$\$ i - a \$\$ i) e \<ge> 0" using * and `e>0` by auto
5.131 -    hence "x \$\$ i * 2 \<le> b \$\$ i * 2 + min (x \$\$ i - a \$\$ i) e" using * by auto
5.132 +    moreover have "min (x \<bullet> i - a \<bullet> i) e \<ge> 0" using * and `e>0` by auto
5.133 +    hence "x \<bullet> i * 2 \<le> b \<bullet> i * 2 + min (x \<bullet> i - a \<bullet> i) e" using * by auto
5.134      ultimately show ?thesis
5.135 -      apply(rule_tac x="- (min (x\$\$i - a\$\$i) e) / 2" in exI)
5.136 -      using assms(1)[THEN spec[where x=i]] and `e>0` and assms(2)
5.137 -      unfolding mem_interval euclidean_simps
5.138 -      using i by (auto simp add: field_simps)
5.139 +      apply(rule_tac x="- (min (x\<bullet>i - a\<bullet>i) e) / 2" in exI)
5.140 +      using assms(1)[THEN bspec, OF i] and `e>0` and assms(2)
5.141 +      unfolding mem_interval
5.142 +      using i by (auto simp add: field_simps inner_simps inner_Basis)
5.143    qed
5.144  qed
5.145
5.146 @@ -638,7 +628,7 @@
5.147
5.148  lemma frechet_derivative_within_closed_interval:
5.149    fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
5.150 -  assumes "\<forall>i<DIM('a). a\$\$i < b\$\$i" and "x \<in> {a..b}"
5.151 +  assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i" and "x \<in> {a..b}"
5.152    assumes "(f has_derivative f') (at x within {a.. b})"
5.153    shows "frechet_derivative f (at x within {a.. b}) = f'"
5.154    apply(rule frechet_derivative_unique_within_closed_interval[where f=f])
5.155 @@ -650,14 +640,14 @@
5.156  lemma linear_componentwise:
5.157    fixes f:: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
5.158    assumes lf: "linear f"
5.159 -  shows "(f x) \$\$ j = (\<Sum>i<DIM('a). (x\$\$i) * (f (basis i)\$\$j))" (is "?lhs = ?rhs")
5.160 +  shows "(f x) \<bullet> j = (\<Sum>i\<in>Basis. (x\<bullet>i) * (f i\<bullet>j))" (is "?lhs = ?rhs")
5.161  proof -
5.162 -  have fA: "finite {..<DIM('a)}" by simp
5.163 -  have "?rhs = (\<Sum>i<DIM('a). x\$\$i *\<^sub>R f (basis i))\$\$j"
5.164 -    by simp
5.165 +  have fA: "finite Basis" by simp
5.166 +  have "?rhs = (\<Sum>i\<in>Basis. (x\<bullet>i) *\<^sub>R (f i))\<bullet>j"
5.167 +    by (simp add: inner_setsum_left)
5.168    then show ?thesis
5.169      unfolding linear_setsum_mul[OF lf fA, symmetric]
5.170 -    unfolding euclidean_representation[symmetric] ..
5.171 +    unfolding euclidean_representation ..
5.172  qed
5.173
5.174  text {* We do not introduce @{text jacobian}, which is defined on matrices, instead we use
5.175 @@ -665,52 +655,54 @@
5.176
5.177  lemma jacobian_works:
5.178    "(f::('a::euclidean_space) \<Rightarrow> ('b::euclidean_space)) differentiable net \<longleftrightarrow>
5.179 -   (f has_derivative (\<lambda>h. \<chi>\<chi> i.
5.180 -      \<Sum>j<DIM('a). frechet_derivative f net (basis j) \$\$ i * h \$\$ j)) net"
5.181 -  (is "?differentiable \<longleftrightarrow> (f has_derivative (\<lambda>h. \<chi>\<chi> i. ?SUM h i)) net")
5.182 +   (f has_derivative (\<lambda>h. \<Sum>i\<in>Basis.
5.183 +      (\<Sum>j\<in>Basis. frechet_derivative f net (j) \<bullet> i * (h \<bullet> j)) *\<^sub>R i)) net"
5.184 +  (is "?differentiable \<longleftrightarrow> (f has_derivative (\<lambda>h. \<Sum>i\<in>Basis. ?SUM h i *\<^sub>R i)) net")
5.185  proof
5.186    assume *: ?differentiable
5.187    { fix h i
5.188 -    have "?SUM h i = frechet_derivative f net h \$\$ i" using *
5.189 +    have "?SUM h i = frechet_derivative f net h \<bullet> i" using *
5.190        by (auto intro!: setsum_cong
5.191                 simp: linear_componentwise[of _ h i] linear_frechet_derivative) }
5.192 -  thus "(f has_derivative (\<lambda>h. \<chi>\<chi> i. ?SUM h i)) net"
5.193 -    using * by (simp add: frechet_derivative_works)
5.194 +  with * show "(f has_derivative (\<lambda>h. \<Sum>i\<in>Basis. ?SUM h i *\<^sub>R i)) net"
5.195 +    by (simp add: frechet_derivative_works euclidean_representation)
5.196  qed (auto intro!: differentiableI)
5.197
5.198  lemma differential_zero_maxmin_component:
5.199    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
5.200 -  assumes k: "k < DIM('b)"
5.201 -    and ball: "0 < e" "((\<forall>y \<in> ball x e. (f y)\$\$k \<le> (f x)\$\$k) \<or> (\<forall>y\<in>ball x e. (f x)\$\$k \<le> (f y)\$\$k))"
5.202 +  assumes k: "k \<in> Basis"
5.203 +    and ball: "0 < e" "((\<forall>y \<in> ball x e. (f y)\<bullet>k \<le> (f x)\<bullet>k) \<or> (\<forall>y\<in>ball x e. (f x)\<bullet>k \<le> (f y)\<bullet>k))"
5.204      and diff: "f differentiable (at x)"
5.205 -  shows "(\<chi>\<chi> j. frechet_derivative f (at x) (basis j) \$\$ k) = (0::'a)" (is "?D k = 0")
5.206 +  shows "(\<Sum>j\<in>Basis. (frechet_derivative f (at x) j \<bullet> k) *\<^sub>R j) = (0::'a)" (is "?D k = 0")
5.207  proof (rule ccontr)
5.208    assume "?D k \<noteq> 0"
5.209 -  then obtain j where j: "?D k \$\$ j \<noteq> 0" "j < DIM('a)"
5.210 -    unfolding euclidean_lambda_beta euclidean_eq[of _ "0::'a"] by auto
5.211 -  hence *: "\<bar>?D k \$\$ j\<bar> / 2 > 0" by auto
5.212 +  then obtain j where j: "?D k \<bullet> j \<noteq> 0" "j \<in> Basis"
5.213 +    unfolding euclidean_eq_iff[of _ "0::'a"] by auto
5.214 +  hence *: "\<bar>?D k \<bullet> j\<bar> / 2 > 0" by auto
5.215    note as = diff[unfolded jacobian_works has_derivative_at_alt]
5.216    guess e' using as[THEN conjunct2, rule_format, OF *] .. note e' = this
5.217    guess d using real_lbound_gt_zero[OF ball(1) e'[THEN conjunct1]] .. note d = this
5.218    { fix c assume "abs c \<le> d"
5.219 -    hence *:"norm (x + c *\<^sub>R basis j - x) < e'" using norm_basis[of j] d by auto
5.220 -    let ?v = "(\<chi>\<chi> i. \<Sum>l<DIM('a). ?D i \$\$ l * (c *\<^sub>R basis j :: 'a) \$\$ l)"
5.221 +    hence *:"norm (x + c *\<^sub>R j - x) < e'" using norm_Basis[OF j(2)] d by auto
5.222 +    let ?v = "(\<Sum>i\<in>Basis. (\<Sum>l\<in>Basis. ?D i \<bullet> l * ((c *\<^sub>R j :: 'a) \<bullet> l)) *\<^sub>R i)"
5.223      have if_dist: "\<And> P a b c. a * (if P then b else c) = (if P then a * b else a * c)" by auto
5.224 -    have "\<bar>(f (x + c *\<^sub>R basis j) - f x - ?v) \$\$ k\<bar> \<le>
5.225 -        norm (f (x + c *\<^sub>R basis j) - f x - ?v)" by (rule component_le_norm)
5.226 -    also have "\<dots> \<le> \<bar>?D k \$\$ j\<bar> / 2 * \<bar>c\<bar>"
5.227 -      using e'[THEN conjunct2, rule_format, OF *] and norm_basis[of j] by fastforce
5.228 -    finally have "\<bar>(f (x + c *\<^sub>R basis j) - f x - ?v) \$\$ k\<bar> \<le> \<bar>?D k \$\$ j\<bar> / 2 * \<bar>c\<bar>" by simp
5.229 -    hence "\<bar>f (x + c *\<^sub>R basis j) \$\$ k - f x \$\$ k - c * ?D k \$\$ j\<bar> \<le> \<bar>?D k \$\$ j\<bar> / 2 * \<bar>c\<bar>"
5.230 -      unfolding euclidean_simps euclidean_lambda_beta using j k
5.231 -      by (simp add: if_dist setsum_cases field_simps) } note * = this
5.232 -  have "x + d *\<^sub>R basis j \<in> ball x e" "x - d *\<^sub>R basis j \<in> ball x e"
5.233 -    unfolding mem_ball dist_norm using norm_basis[of j] d by auto
5.234 -  hence **:"((f (x - d *\<^sub>R basis j))\$\$k \<le> (f x)\$\$k \<and> (f (x + d *\<^sub>R basis j))\$\$k \<le> (f x)\$\$k) \<or>
5.235 -         ((f (x - d *\<^sub>R basis j))\$\$k \<ge> (f x)\$\$k \<and> (f (x + d *\<^sub>R basis j))\$\$k \<ge> (f x)\$\$k)" using ball by auto
5.236 +    have "\<bar>(f (x + c *\<^sub>R j) - f x - ?v) \<bullet> k\<bar> \<le>
5.237 +        norm (f (x + c *\<^sub>R j) - f x - ?v)" by (rule Basis_le_norm[OF k])
5.238 +    also have "\<dots> \<le> \<bar>?D k \<bullet> j\<bar> / 2 * \<bar>c\<bar>"
5.239 +      using e'[THEN conjunct2, rule_format, OF *] and norm_Basis[OF j(2)] j
5.240 +      by simp
5.241 +    finally have "\<bar>(f (x + c *\<^sub>R j) - f x - ?v) \<bullet> k\<bar> \<le> \<bar>?D k \<bullet> j\<bar> / 2 * \<bar>c\<bar>" by simp
5.242 +    hence "\<bar>f (x + c *\<^sub>R j) \<bullet> k - f x \<bullet> k - c * (?D k \<bullet> j)\<bar> \<le> \<bar>?D k \<bullet> j\<bar> / 2 * \<bar>c\<bar>"
5.243 +      using j k
5.244 +      by (simp add: inner_simps field_simps inner_Basis setsum_cases if_dist) }
5.245 +  note * = this
5.246 +  have "x + d *\<^sub>R j \<in> ball x e" "x - d *\<^sub>R j \<in> ball x e"
5.247 +    unfolding mem_ball dist_norm using norm_Basis[OF j(2)] d by auto
5.248 +  hence **:"((f (x - d *\<^sub>R j))\<bullet>k \<le> (f x)\<bullet>k \<and> (f (x + d *\<^sub>R j))\<bullet>k \<le> (f x)\<bullet>k) \<or>
5.249 +         ((f (x - d *\<^sub>R j))\<bullet>k \<ge> (f x)\<bullet>k \<and> (f (x + d *\<^sub>R j))\<bullet>k \<ge> (f x)\<bullet>k)" using ball by auto
5.250    have ***: "\<And>y y1 y2 d dx::real.
5.251      (y1\<le>y\<and>y2\<le>y) \<or> (y\<le>y1\<and>y\<le>y2) \<Longrightarrow> d < abs dx \<Longrightarrow> abs(y1 - y - - dx) \<le> d \<Longrightarrow> (abs (y2 - y - dx) \<le> d) \<Longrightarrow> False" by arith
5.252 -  show False apply(rule ***[OF **, where dx="d * ?D k \$\$ j" and d="\<bar>?D k \$\$ j\<bar> / 2 * \<bar>d\<bar>"])
5.253 +  show False apply(rule ***[OF **, where dx="d * (?D k \<bullet> j)" and d="\<bar>?D k \<bullet> j\<bar> / 2 * \<bar>d\<bar>"])
5.254      using *[of "-d"] and *[of d] and d[THEN conjunct1] and j
5.255      unfolding mult_minus_left
5.257 @@ -728,13 +720,13 @@
5.258  proof -
5.259    obtain e where e:"e>0" "ball x e \<subseteq> s"
5.260      using `open s`[unfolded open_contains_ball] and `x \<in> s` by auto
5.261 -  with differential_zero_maxmin_component[where 'b=real, of 0 e x f, simplified]
5.262 -  have "(\<chi>\<chi> j. frechet_derivative f (at x) (basis j)) = (0::'a)"
5.263 -    unfolding differentiable_def using mono deriv by auto
5.264 +  with differential_zero_maxmin_component[where 'b=real, of 1 e x f] mono deriv
5.265 +  have "(\<Sum>j\<in>Basis. frechet_derivative f (at x) j *\<^sub>R j) = (0::'a)"
5.266 +    by (auto simp: Basis_real_def differentiable_def)
5.267    with frechet_derivative_at[OF deriv, symmetric]
5.268 -  have "\<forall>i<DIM('a). f' (basis i) = 0"
5.269 -    by (simp add: euclidean_eq[of _ "0::'a"])
5.270 -  with derivative_is_linear[OF deriv, THEN linear_componentwise, of _ 0]
5.271 +  have "\<forall>i\<in>Basis. f' i = 0"
5.272 +    by (simp add: euclidean_eq_iff[of _ "0::'a"] inner_setsum_left_Basis)
5.273 +  with derivative_is_linear[OF deriv, THEN linear_componentwise, of _ 1]
5.274    show ?thesis by (simp add: fun_eq_iff)
5.275  qed
5.276
5.277 @@ -1281,8 +1273,8 @@
5.278  proof-
5.279    interpret bounded_linear g' using assms by auto
5.280    note f'g' = assms(4)[unfolded id_def o_def,THEN cong]
5.281 -  have "g' (f' a (\<chi>\<chi> i.1)) = (\<chi>\<chi> i.1)" "(\<chi>\<chi> i.1) \<noteq> (0::'n)" defer
5.282 -    apply(subst euclidean_eq) using f'g' by auto
5.283 +  have "g' (f' a (\<Sum>Basis)) = (\<Sum>Basis)" "(\<Sum>Basis) \<noteq> (0::'n)" defer
5.284 +    apply(subst euclidean_eq_iff) using f'g' by auto
5.285    hence *:"0 < onorm g'"
5.286      unfolding onorm_pos_lt[OF assms(3)[unfolded linear_linear]] by fastforce
5.287    def k \<equiv> "1 / onorm g' / 2" have *:"k>0" unfolding k_def using * by auto
5.288 @@ -1726,7 +1718,7 @@
5.289    have *:"(\<lambda>x. x *\<^sub>R f') = (\<lambda>x. x *\<^sub>R f'')"
5.290      apply(rule frechet_derivative_unique_within_closed_interval[of "a" "b"])
5.291      using assms(3-)[unfolded has_vector_derivative_def] using assms(1-2)
5.292 -    by auto
5.293 +    by (auto simp: Basis_real_def)
5.294    show ?thesis
5.295    proof(rule ccontr)
5.296      assume "f' \<noteq> f''"
```
```     6.1 --- a/src/HOL/Multivariate_Analysis/Determinants.thy	Fri Dec 14 14:46:01 2012 +0100
6.2 +++ b/src/HOL/Multivariate_Analysis/Determinants.thy	Fri Dec 14 15:46:01 2012 +0100
6.3 @@ -452,7 +452,7 @@
6.4
6.5    ultimately show ?thesis
6.6      apply -
6.7 -    apply (rule span_induct_alt[of ?P ?S, OF P0, folded smult_conv_scaleR])
6.8 +    apply (rule span_induct_alt[of ?P ?S, OF P0, folded scalar_mult_eq_scaleR])
6.9      apply blast
6.10      apply (rule x)
6.11      done
6.12 @@ -746,7 +746,7 @@
6.13        apply (rule span_setsum)
6.14        apply simp
6.15        apply (rule ballI)
6.16 -      apply (rule span_mul [where 'a="real^'n", folded smult_conv_scaleR])+
6.17 +      apply (rule span_mul [where 'a="real^'n", folded scalar_mult_eq_scaleR])+
6.18        apply (rule span_superset)
6.19        apply auto
6.20        done
6.21 @@ -782,7 +782,7 @@
6.22      apply (rule det_row_span)
6.23      apply (rule span_setsum[OF fUk])
6.24      apply (rule ballI)
6.25 -    apply (rule span_mul [where 'a="real^'n", folded smult_conv_scaleR])+
6.26 +    apply (rule span_mul [where 'a="real^'n", folded scalar_mult_eq_scaleR])+
6.27      apply (rule span_superset)
6.28      apply auto
6.29      done
6.30 @@ -879,9 +879,10 @@
6.31        have th0: "\<And>b (x::'a::comm_ring_1). (if b then 1 else 0)*x = (if b then x else 0)"
6.32          "\<And>b (x::'a::comm_ring_1). x*(if b then 1 else 0) = (if b then x else 0)"
6.33          by simp_all
6.34 -      from fd[rule_format, of "cart_basis i" "cart_basis j", unfolded matrix_works[OF lf, symmetric] dot_matrix_vector_mul]
6.35 +      from fd[rule_format, of "axis i 1" "axis j 1", unfolded matrix_works[OF lf, symmetric] dot_matrix_vector_mul]
6.36        have "?A\$i\$j = ?m1 \$ i \$ j"
6.37 -        by (simp add: inner_vec_def matrix_matrix_mult_def columnvector_def rowvector_def cart_basis_def th0 setsum_delta[OF fU] mat_def)}
6.38 +        by (simp add: inner_vec_def matrix_matrix_mult_def columnvector_def rowvector_def
6.39 +            th0 setsum_delta[OF fU] mat_def axis_def) }
6.40      hence "orthogonal_matrix ?mf" unfolding orthogonal_matrix by vector
6.41      with lf have ?rhs by blast}
6.42    moreover
6.43 @@ -931,7 +932,9 @@
6.44        unfolding dot_norm_neg dist_norm[symmetric]
6.45        unfolding th0 fd[rule_format] by (simp add: power2_eq_square field_simps)}
6.46    note fc = this
6.47 -  show ?thesis unfolding linear_def vector_eq[where 'a="real^'n"] smult_conv_scaleR by (simp add: inner_add fc field_simps)
6.48 +  show ?thesis
6.49 +    unfolding linear_def vector_eq[where 'a="real^'n"] scalar_mult_eq_scaleR
6.51  qed
6.52
6.53  lemma isometry_linear:
6.54 @@ -981,7 +984,7 @@
6.55        apply (subst H(4))
6.56        using H(5-9)
6.57        apply (simp add: norm_eq norm_eq_1)
6.58 -      apply (simp add: inner_diff smult_conv_scaleR) unfolding *
6.59 +      apply (simp add: inner_diff scalar_mult_eq_scaleR) unfolding *
6.60        by (simp add: field_simps) }
6.61    note th0 = this
6.62    let ?g = "\<lambda>x. if x = 0 then 0 else norm x *\<^sub>R f (inverse (norm x) *\<^sub>R x)"
```
```     7.1 --- a/src/HOL/Multivariate_Analysis/Euclidean_Space.thy	Fri Dec 14 14:46:01 2012 +0100
7.2 +++ b/src/HOL/Multivariate_Analysis/Euclidean_Space.thy	Fri Dec 14 15:46:01 2012 +0100
7.3 @@ -23,24 +23,24 @@
7.4    assumes euclidean_all_zero_iff:
7.5      "(\<forall>u\<in>Basis. inner x u = 0) \<longleftrightarrow> (x = 0)"
7.6
7.7 -  -- "FIXME: make this a separate definition"
7.8 -  fixes dimension :: "'a itself \<Rightarrow> nat"
7.9 -  assumes dimension_def: "dimension TYPE('a) = card Basis"
7.10 -
7.11 -  -- "FIXME: eventually basis function can be removed"
7.12 -  fixes basis :: "nat \<Rightarrow> 'a"
7.13 -  assumes image_basis: "basis ` {..<dimension TYPE('a)} = Basis"
7.14 -  assumes basis_finite: "basis ` {dimension TYPE('a)..} = {0}"
7.15 +abbreviation dimension :: "('a::euclidean_space) itself \<Rightarrow> nat" where
7.16 +  "dimension TYPE('a) \<equiv> card (Basis :: 'a set)"
7.17
7.18  syntax "_type_dimension" :: "type => nat" ("(1DIM/(1'(_')))")
7.19
7.20  translations "DIM('t)" == "CONST dimension (TYPE('t))"
7.21
7.22 -lemma (in euclidean_space) norm_Basis: "u \<in> Basis \<Longrightarrow> norm u = 1"
7.23 +lemma (in euclidean_space) norm_Basis[simp]: "u \<in> Basis \<Longrightarrow> norm u = 1"
7.24    unfolding norm_eq_sqrt_inner by (simp add: inner_Basis)
7.25
7.26 +lemma (in euclidean_space) inner_same_Basis[simp]: "u \<in> Basis \<Longrightarrow> inner u u = 1"
7.27 +  by (simp add: inner_Basis)
7.28 +
7.29 +lemma (in euclidean_space) inner_not_same_Basis: "u \<in> Basis \<Longrightarrow> v \<in> Basis \<Longrightarrow> u \<noteq> v \<Longrightarrow> inner u v = 0"
7.30 +  by (simp add: inner_Basis)
7.31 +
7.32  lemma (in euclidean_space) sgn_Basis: "u \<in> Basis \<Longrightarrow> sgn u = u"
7.33 -  unfolding sgn_div_norm by (simp add: norm_Basis scaleR_one)
7.34 +  unfolding sgn_div_norm by (simp add: scaleR_one)
7.35
7.36  lemma (in euclidean_space) Basis_zero [simp]: "0 \<notin> Basis"
7.37  proof
7.38 @@ -51,184 +51,45 @@
7.39  lemma (in euclidean_space) nonzero_Basis: "u \<in> Basis \<Longrightarrow> u \<noteq> 0"
7.40    by clarsimp
7.41
7.42 -text {* Lemmas related to @{text basis} function. *}
7.43 -
7.44 -lemma (in euclidean_space) euclidean_all_zero:
7.45 -  "(\<forall>i<DIM('a). inner (basis i) x = 0) \<longleftrightarrow> (x = 0)"
7.46 -  using euclidean_all_zero_iff [of x, folded image_basis]
7.47 -  unfolding ball_simps by (simp add: Ball_def inner_commute)
7.48 -
7.49 -lemma (in euclidean_space) basis_zero [simp]:
7.50 -  "DIM('a) \<le> i \<Longrightarrow> basis i = 0"
7.51 -  using basis_finite by auto
7.52 +lemma (in euclidean_space) SOME_Basis: "(SOME i. i \<in> Basis) \<in> Basis"
7.53 +  by (metis ex_in_conv nonempty_Basis someI_ex)
7.54
7.55 -lemma (in euclidean_space) DIM_positive [intro]: "0 < DIM('a)"
7.56 -  unfolding dimension_def by (simp add: card_gt_0_iff)
7.57 -
7.58 -lemma (in euclidean_space) basis_inj [simp, intro]: "inj_on basis {..<DIM('a)}"
7.59 -  by (simp add: inj_on_iff_eq_card image_basis dimension_def [symmetric])
7.60 -
7.61 -lemma (in euclidean_space) basis_in_Basis [simp]:
7.62 -  "basis i \<in> Basis \<longleftrightarrow> i < DIM('a)"
7.63 -  by (cases "i < DIM('a)", simp add: image_basis [symmetric], simp)
7.64 -
7.65 -lemma (in euclidean_space) Basis_elim:
7.66 -  assumes "u \<in> Basis" obtains i where "i < DIM('a)" and "u = basis i"
7.67 -  using assms unfolding image_basis [symmetric] by fast
7.68 +lemma (in euclidean_space) inner_setsum_left_Basis[simp]:
7.69 +    "b \<in> Basis \<Longrightarrow> inner (\<Sum>i\<in>Basis. f i *\<^sub>R i) b = f b"
7.70 +  by (simp add: inner_setsum_left inner_Basis if_distrib setsum_cases)
7.71
7.72 -lemma (in euclidean_space) basis_orthonormal:
7.73 -    "\<forall>i<DIM('a). \<forall>j<DIM('a).
7.74 -      inner (basis i) (basis j) = (if i = j then 1 else 0)"
7.75 -  apply clarify
7.76 -  apply (simp add: inner_Basis)
7.77 -  apply (simp add: basis_inj [unfolded inj_on_def])
7.78 -  done
7.79 -
7.80 -lemma (in euclidean_space) dot_basis:
7.81 -  "inner (basis i) (basis j) = (if i = j \<and> i < DIM('a) then 1 else 0)"
7.82 -proof (cases "(i < DIM('a) \<and> j < DIM('a))")
7.83 -  case False
7.84 -  hence "inner (basis i) (basis j) = 0" by auto
7.85 -  thus ?thesis using False by auto
7.86 -next
7.87 -  case True thus ?thesis using basis_orthonormal by auto
7.88 -qed
7.89 -
7.90 -lemma (in euclidean_space) basis_eq_0_iff [simp]:
7.91 -  "basis i = 0 \<longleftrightarrow> DIM('a) \<le> i"
7.92 +lemma (in euclidean_space) euclidean_eqI:
7.93 +  assumes b: "\<And>b. b \<in> Basis \<Longrightarrow> inner x b = inner y b" shows "x = y"
7.94  proof -
7.95 -  have "inner (basis i) (basis i) = 0 \<longleftrightarrow> DIM('a) \<le> i"
7.96 -    by (simp add: dot_basis)
7.97 -  thus ?thesis by simp
7.98 +  from b have "\<forall>b\<in>Basis. inner (x - y) b = 0"
7.99 +    by (simp add: inner_diff_left)
7.100 +  then show "x = y"
7.101 +    by (simp add: euclidean_all_zero_iff)
7.102  qed
7.103
7.104 -lemma (in euclidean_space) norm_basis [simp]:
7.105 -  "norm (basis i) = (if i < DIM('a) then 1 else 0)"
7.106 -  unfolding norm_eq_sqrt_inner dot_basis by simp
7.107 -
7.108 -lemma (in euclidean_space) basis_neq_0 [intro]:
7.109 -  assumes "i<DIM('a)" shows "(basis i) \<noteq> 0"
7.110 -  using assms by simp
7.111 -
7.112 -subsubsection {* Projecting components *}
7.113 -
7.114 -definition (in euclidean_space) euclidean_component (infixl "\$\$" 90)
7.115 -  where "x \$\$ i = inner (basis i) x"
7.116 -
7.117 -lemma bounded_linear_euclidean_component:
7.118 -  "bounded_linear (\<lambda>x. euclidean_component x i)"
7.119 -  unfolding euclidean_component_def
7.120 -  by (rule bounded_linear_inner_right)
7.121 -
7.122 -lemmas tendsto_euclidean_component [tendsto_intros] =
7.123 -  bounded_linear.tendsto [OF bounded_linear_euclidean_component]
7.124 -
7.125 -lemmas isCont_euclidean_component [simp] =
7.126 -  bounded_linear.isCont [OF bounded_linear_euclidean_component]
7.127 -
7.128 -lemma euclidean_component_zero [simp]: "0 \$\$ i = 0"
7.129 -  unfolding euclidean_component_def by (rule inner_zero_right)
7.130 -
7.131 -lemma euclidean_component_add [simp]: "(x + y) \$\$ i = x \$\$ i + y \$\$ i"
7.132 -  unfolding euclidean_component_def by (rule inner_add_right)
7.133 -
7.134 -lemma euclidean_component_diff [simp]: "(x - y) \$\$ i = x \$\$ i - y \$\$ i"
7.135 -  unfolding euclidean_component_def by (rule inner_diff_right)
7.136 -
7.137 -lemma euclidean_component_minus [simp]: "(- x) \$\$ i = - (x \$\$ i)"
7.138 -  unfolding euclidean_component_def by (rule inner_minus_right)
7.139 -
7.140 -lemma euclidean_component_scaleR [simp]: "(scaleR a x) \$\$ i = a * (x \$\$ i)"
7.141 -  unfolding euclidean_component_def by (rule inner_scaleR_right)
7.142 -
7.143 -lemma euclidean_component_setsum [simp]: "(\<Sum>x\<in>A. f x) \$\$ i = (\<Sum>x\<in>A. f x \$\$ i)"
7.144 -  unfolding euclidean_component_def by (rule inner_setsum_right)
7.145 -
7.146 -lemma euclidean_eqI:
7.147 -  fixes x y :: "'a::euclidean_space"
7.148 -  assumes "\<And>i. i < DIM('a) \<Longrightarrow> x \$\$ i = y \$\$ i" shows "x = y"
7.149 -proof -
7.150 -  from assms have "\<forall>i<DIM('a). (x - y) \$\$ i = 0"
7.151 -    by simp
7.152 -  then show "x = y"
7.153 -    unfolding euclidean_component_def euclidean_all_zero by simp
7.154 -qed
7.155 -
7.156 -lemma euclidean_eq:
7.157 -  fixes x y :: "'a::euclidean_space"
7.158 -  shows "x = y \<longleftrightarrow> (\<forall>i<DIM('a). x \$\$ i = y \$\$ i)"
7.159 +lemma (in euclidean_space) euclidean_eq_iff:
7.160 +  "x = y \<longleftrightarrow> (\<forall>b\<in>Basis. inner x b = inner y b)"
7.161    by (auto intro: euclidean_eqI)
7.162
7.163 -lemma (in euclidean_space) basis_component [simp]:
7.164 -  "basis i \$\$ j = (if i = j \<and> i < DIM('a) then 1 else 0)"
7.165 -  unfolding euclidean_component_def dot_basis by auto
7.166 -
7.167 -lemma (in euclidean_space) basis_at_neq_0 [intro]:
7.168 -  "i < DIM('a) \<Longrightarrow> basis i \$\$ i \<noteq> 0"
7.169 -  by simp
7.170 -
7.171 -lemma (in euclidean_space) euclidean_component_ge [simp]:
7.172 -  assumes "i \<ge> DIM('a)" shows "x \$\$ i = 0"
7.173 -  unfolding euclidean_component_def basis_zero[OF assms] by simp
7.174 +lemma (in euclidean_space) euclidean_representation_setsum:
7.175 +  "(\<Sum>i\<in>Basis. f i *\<^sub>R i) = b \<longleftrightarrow> (\<forall>i\<in>Basis. f i = inner b i)"
7.176 +  by (subst euclidean_eq_iff) simp
7.177
7.178 -lemmas euclidean_simps =
7.180 -  euclidean_component_diff
7.181 -  euclidean_component_scaleR
7.182 -  euclidean_component_minus
7.183 -  euclidean_component_setsum
7.184 -  basis_component
7.185 -
7.186 -lemma euclidean_representation:
7.187 -  fixes x :: "'a::euclidean_space"
7.188 -  shows "x = (\<Sum>i<DIM('a). (x\$\$i) *\<^sub>R basis i)"
7.189 -  apply (rule euclidean_eqI)
7.190 -  apply (simp add: if_distrib setsum_delta cong: if_cong)
7.191 -  done
7.192 -
7.193 -subsubsection {* Binder notation for vectors *}
7.194 -
7.195 -definition (in euclidean_space) Chi (binder "\<chi>\<chi> " 10) where
7.196 -  "(\<chi>\<chi> i. f i) = (\<Sum>i<DIM('a). f i *\<^sub>R basis i)"
7.197 +lemma (in euclidean_space) euclidean_representation: "(\<Sum>b\<in>Basis. inner x b *\<^sub>R b) = x"
7.198 +  unfolding euclidean_representation_setsum by simp
7.199
7.200 -lemma euclidean_lambda_beta [simp]:
7.201 -  "((\<chi>\<chi> i. f i)::'a::euclidean_space) \$\$ j = (if j < DIM('a) then f j else 0)"
7.202 -  by (auto simp: Chi_def if_distrib setsum_cases intro!: setsum_cong)
7.203 -
7.204 -lemma euclidean_lambda_beta':
7.205 -  "j < DIM('a) \<Longrightarrow> ((\<chi>\<chi> i. f i)::'a::euclidean_space) \$\$ j = f j"
7.206 -  by simp
7.207 -
7.208 -lemma euclidean_lambda_beta'':"(\<forall>j < DIM('a::euclidean_space). P j (((\<chi>\<chi> i. f i)::'a) \$\$ j)) \<longleftrightarrow>
7.209 -  (\<forall>j < DIM('a::euclidean_space). P j (f j))" by auto
7.210 -
7.211 -lemma euclidean_beta_reduce[simp]:
7.212 -  "(\<chi>\<chi> i. x \$\$ i) = (x::'a::euclidean_space)"
7.213 -  by (simp add: euclidean_eq)
7.214 -
7.215 -lemma euclidean_lambda_beta_0[simp]:
7.216 -    "((\<chi>\<chi> i. f i)::'a::euclidean_space) \$\$ 0 = f 0"
7.217 -  by (simp add: DIM_positive)
7.218 +lemma (in euclidean_space) choice_Basis_iff:
7.219 +  fixes P :: "'a \<Rightarrow> real \<Rightarrow> bool"
7.220 +  shows "(\<forall>i\<in>Basis. \<exists>x. P i x) \<longleftrightarrow> (\<exists>x. \<forall>i\<in>Basis. P i (inner x i))"
7.221 +  unfolding bchoice_iff
7.222 +proof safe
7.223 +  fix f assume "\<forall>i\<in>Basis. P i (f i)"
7.224 +  then show "\<exists>x. \<forall>i\<in>Basis. P i (inner x i)"
7.225 +    by (auto intro!: exI[of _ "\<Sum>i\<in>Basis. f i *\<^sub>R i"])
7.226 +qed auto
7.227
7.228 -lemma euclidean_inner:
7.229 -  "inner x (y::'a) = (\<Sum>i<DIM('a::euclidean_space). (x \$\$ i) * (y \$\$ i))"
7.230 -  by (subst (1 2) euclidean_representation,
7.231 -    simp add: inner_setsum_left inner_setsum_right
7.232 -    dot_basis if_distrib setsum_cases mult_commute)
7.233 -
7.234 -lemma euclidean_dist_l2:
7.235 -  fixes x y :: "'a::euclidean_space"
7.236 -  shows "dist x y = setL2 (\<lambda>i. dist (x \$\$ i) (y \$\$ i)) {..<DIM('a)}"
7.237 -  unfolding dist_norm norm_eq_sqrt_inner setL2_def
7.238 -  by (simp add: euclidean_inner power2_eq_square)
7.239 -
7.240 -lemma component_le_norm: "\<bar>x\$\$i\<bar> \<le> norm (x::'a::euclidean_space)"
7.241 -  unfolding euclidean_component_def
7.242 -  by (rule order_trans [OF Cauchy_Schwarz_ineq2]) simp
7.243 -
7.244 -lemma dist_nth_le: "dist (x \$\$ i) (y \$\$ i) \<le> dist x (y::'a::euclidean_space)"
7.245 -  unfolding euclidean_dist_l2 [where 'a='a]
7.246 -  by (cases "i < DIM('a)", rule member_le_setL2, auto)
7.247 +lemma DIM_positive: "0 < DIM('a::euclidean_space)"
7.248 +  by (simp add: card_gt_0_iff)
7.249
7.250  subsection {* Subclass relationships *}
7.251
7.252 @@ -239,11 +100,13 @@
7.253      assume "open {x}"
7.254      then obtain e where "0 < e" and e: "\<forall>y. dist y x < e \<longrightarrow> y = x"
7.255        unfolding open_dist by fast
7.256 -    def y \<equiv> "x + scaleR (e/2) (sgn (basis 0))"
7.257 +    def y \<equiv> "x + scaleR (e/2) (SOME b. b \<in> Basis)"
7.258 +    have [simp]: "(SOME b. b \<in> Basis) \<in> Basis"
7.259 +      by (rule someI_ex) (auto simp: ex_in_conv)
7.260      from `0 < e` have "y \<noteq> x"
7.261 -      unfolding y_def by (simp add: sgn_zero_iff DIM_positive)
7.262 +      unfolding y_def by (auto intro!: nonzero_Basis)
7.263      from `0 < e` have "dist y x < e"
7.264 -      unfolding y_def by (simp add: dist_norm norm_sgn)
7.265 +      unfolding y_def by (simp add: dist_norm norm_Basis)
7.266      from `y \<noteq> x` and `dist y x < e` show "False"
7.267        using e by simp
7.268    qed
7.269 @@ -256,23 +119,17 @@
7.270  instantiation real :: euclidean_space
7.271  begin
7.272
7.273 -definition
7.274 -  "Basis = {1::real}"
7.275 -
7.276 -definition
7.277 -  "dimension (t::real itself) = 1"
7.278 -
7.279 -definition [simp]:
7.280 -  "basis i = (if i = 0 then 1 else (0::real))"
7.281 -
7.282 -lemma DIM_real [simp]: "DIM(real) = 1"
7.283 -  by (rule dimension_real_def)
7.284 +definition
7.285 +  [simp]: "Basis = {1::real}"
7.286
7.287  instance
7.288    by default (auto simp add: Basis_real_def)
7.289
7.290  end
7.291
7.292 +lemma DIM_real[simp]: "DIM(real) = 1"
7.293 +  by simp
7.294 +
7.295  subsubsection {* Type @{typ complex} *}
7.296
7.297  instantiation complex :: euclidean_space
7.298 @@ -281,20 +138,13 @@
7.299  definition Basis_complex_def:
7.300    "Basis = {1, ii}"
7.301
7.302 -definition
7.303 -  "dimension (t::complex itself) = 2"
7.304 -
7.305 -definition
7.306 -  "basis i = (if i = 0 then 1 else if i = 1 then ii else 0)"
7.307 -
7.308  instance
7.309 -  by default (auto simp add: Basis_complex_def dimension_complex_def
7.310 -    basis_complex_def intro: complex_eqI split: split_if_asm)
7.311 +  by default (auto simp add: Basis_complex_def intro: complex_eqI split: split_if_asm)
7.312
7.313  end
7.314
7.315  lemma DIM_complex[simp]: "DIM(complex) = 2"
7.316 -  by (rule dimension_complex_def)
7.317 +  unfolding Basis_complex_def by simp
7.318
7.319  subsubsection {* Type @{typ "'a \<times> 'b"} *}
7.320
7.321 @@ -304,12 +154,6 @@
7.322  definition
7.323    "Basis = (\<lambda>u. (u, 0)) ` Basis \<union> (\<lambda>v. (0, v)) ` Basis"
7.324
7.325 -definition
7.326 -  "dimension (t::('a \<times> 'b) itself) = DIM('a) + DIM('b)"
7.327 -
7.328 -definition
7.329 -  "basis i = (if i < DIM('a) then (basis i, 0) else (0, basis (i - DIM('a))))"
7.330 -
7.331  instance proof
7.332    show "(Basis :: ('a \<times> 'b) set) \<noteq> {}"
7.333      unfolding Basis_prod_def by simp
7.334 @@ -327,20 +171,12 @@
7.335    show "(\<forall>u\<in>Basis. inner x u = 0) \<longleftrightarrow> x = 0"
7.336      unfolding Basis_prod_def ball_Un ball_simps
7.337      by (simp add: inner_prod_def prod_eq_iff euclidean_all_zero_iff)
7.338 -next
7.339 -  show "DIM('a \<times> 'b) = card (Basis :: ('a \<times> 'b) set)"
7.340 -    unfolding dimension_prod_def Basis_prod_def
7.341 -    by (simp add: card_Un_disjoint disjoint_iff_not_equal
7.342 -      card_image inj_on_def dimension_def)
7.343 -next
7.344 -  show "basis ` {..<DIM('a \<times> 'b)} = (Basis :: ('a \<times> 'b) set)"
7.345 -    by (auto simp add: Basis_prod_def dimension_prod_def basis_prod_def
7.346 -      image_def elim!: Basis_elim)
7.347 -next
7.348 -  show "basis ` {DIM('a \<times> 'b)..} = {0::('a \<times> 'b)}"
7.349 -    by (auto simp add: dimension_prod_def basis_prod_def prod_eq_iff image_def)
7.350  qed
7.351
7.352 +lemma DIM_prod[simp]: "DIM('a \<times> 'b) = DIM('a) + DIM('b)"
7.353 +  unfolding Basis_prod_def
7.354 +  by (subst card_Un_disjoint) (auto intro!: card_image arg_cong2[where f="op +"] inj_onI)
7.355 +
7.356  end
7.357
7.358  end
```
```     8.1 --- a/src/HOL/Multivariate_Analysis/Fashoda.thy	Fri Dec 14 14:46:01 2012 +0100
8.2 +++ b/src/HOL/Multivariate_Analysis/Fashoda.thy	Fri Dec 14 15:46:01 2012 +0100
8.3 @@ -7,6 +7,14 @@
8.4  imports Brouwer_Fixpoint Path_Connected Cartesian_Euclidean_Space
8.5  begin
8.6
8.7 +(* move *)
8.8 +
8.9 +lemma cart_eq_inner_axis: "a \$ i = a \<bullet> axis i 1"
8.10 +  by (simp add: inner_axis)
8.11 +
8.12 +lemma axis_in_Basis: "a \<in> Basis \<Longrightarrow> axis i a \<in> Basis"
8.13 +  by (auto simp add: Basis_vec_def axis_eq_axis)
8.14 +
8.15  subsection {*Fashoda meet theorem. *}
8.16
8.17  lemma infnorm_2: "infnorm (x::real^2) = max (abs(x\$1)) (abs(x\$2))"
8.18 @@ -30,7 +38,7 @@
8.19    have lem1:"\<forall>z::real^2. infnorm(negatex z) = infnorm z"
8.20      unfolding negatex_def infnorm_2 vector_2 by auto
8.21    have lem2:"\<forall>z. z\<noteq>0 \<longrightarrow> infnorm(sqprojection z) = 1" unfolding sqprojection_def
8.22 -    unfolding infnorm_mul[unfolded smult_conv_scaleR] unfolding abs_inverse real_abs_infnorm
8.23 +    unfolding infnorm_mul[unfolded scalar_mult_eq_scaleR] unfolding abs_inverse real_abs_infnorm
8.24      apply(subst infnorm_eq_0[THEN sym]) by auto
8.25    let ?F = "(\<lambda>w::real^2. (f \<circ> (\<lambda>x. x\$1)) w - (g \<circ> (\<lambda>x. x\$2)) w)"
8.26    have *:"\<And>i. (\<lambda>x::real^2. x \$ i) ` {- 1..1} = {- 1..1::real}"
8.27 @@ -133,12 +141,6 @@
8.28      apply(rule_tac x="iscale s" in bexI) prefer 3 apply(rule_tac x="iscale t" in bexI)
8.29      using isc[unfolded subset_eq, rule_format] by auto qed
8.30
8.31 -(* move *)
8.32 -lemma interval_bij_bij_cart: fixes x::"real^'n" assumes "\<forall>i. a\$i < b\$i \<and> u\$i < v\$i"
8.33 -  shows "interval_bij (a,b) (u,v) (interval_bij (u,v) (a,b) x) = x"
8.34 -  unfolding interval_bij_cart split_conv vec_eq_iff vec_lambda_beta
8.35 -  apply(rule,insert assms,erule_tac x=i in allE) by auto
8.36 -
8.37  lemma fashoda: fixes b::"real^2"
8.38    assumes "path f" "path g" "path_image f \<subseteq> {a..b}" "path_image g \<subseteq> {a..b}"
8.39    "(pathstart f)\$1 = a\$1" "(pathfinish f)\$1 = b\$1"
8.40 @@ -184,8 +186,10 @@
8.41        "(interval_bij (a, b) (- 1, 1) \<circ> f) 1 \$ 1 = 1"
8.42        "(interval_bij (a, b) (- 1, 1) \<circ> g) 0 \$ 2 = -1"
8.43        "(interval_bij (a, b) (- 1, 1) \<circ> g) 1 \$ 2 = 1"
8.44 -      unfolding interval_bij_cart vector_component_simps o_def split_conv
8.45 -      unfolding assms[unfolded pathstart_def pathfinish_def] using as by auto qed note z=this
8.46 +      using assms as
8.47 +      by (simp_all add: axis_in_Basis cart_eq_inner_axis pathstart_def pathfinish_def interval_bij_def)
8.49 +  qed note z=this
8.50    from z(1) guess zf unfolding image_iff .. note zf=this
8.51    from z(2) guess zg unfolding image_iff .. note zg=this
8.52    have *:"\<forall>i. (- 1) \$ i < (1::real^2) \$ i \<and> a \$ i < b \$ i" unfolding forall_2 using as by auto
8.53 @@ -201,7 +205,7 @@
8.54  proof-
8.55    let ?L = "\<exists>u. (x \$ 1 = (1 - u) * a \$ 1 + u * b \$ 1 \<and> x \$ 2 = (1 - u) * a \$ 2 + u * b \$ 2) \<and> 0 \<le> u \<and> u \<le> 1"
8.56    { presume "?L \<Longrightarrow> ?R" "?R \<Longrightarrow> ?L" thus ?thesis unfolding closed_segment_def mem_Collect_eq
8.57 -      unfolding vec_eq_iff forall_2 smult_conv_scaleR[THEN sym] vector_component_simps by blast }
8.58 +      unfolding vec_eq_iff forall_2 scalar_mult_eq_scaleR[THEN sym] vector_component_simps by blast }
8.59    { assume ?L then guess u apply-apply(erule exE)apply(erule conjE)+ . note u=this
8.60      { fix b a assume "b + u * a > a + u * b"
8.61        hence "(1 - u) * b > (1 - u) * a" by(auto simp add:field_simps)
8.62 @@ -225,7 +229,7 @@
8.63  proof-
8.64    let ?L = "\<exists>u. (x \$ 1 = (1 - u) * a \$ 1 + u * b \$ 1 \<and> x \$ 2 = (1 - u) * a \$ 2 + u * b \$ 2) \<and> 0 \<le> u \<and> u \<le> 1"
8.65    { presume "?L \<Longrightarrow> ?R" "?R \<Longrightarrow> ?L" thus ?thesis unfolding closed_segment_def mem_Collect_eq
8.66 -      unfolding vec_eq_iff forall_2 smult_conv_scaleR[THEN sym] vector_component_simps by blast }
8.67 +      unfolding vec_eq_iff forall_2 scalar_mult_eq_scaleR[THEN sym] vector_component_simps by blast }
8.68    { assume ?L then guess u apply-apply(erule exE)apply(erule conjE)+ . note u=this
8.69      { fix b a assume "b + u * a > a + u * b"
8.70        hence "(1 - u) * b > (1 - u) * a" by(auto simp add:field_simps)
```
```     9.1 --- a/src/HOL/Multivariate_Analysis/Finite_Cartesian_Product.thy	Fri Dec 14 14:46:01 2012 +0100
9.2 +++ b/src/HOL/Multivariate_Analysis/Finite_Cartesian_Product.thy	Fri Dec 14 15:46:01 2012 +0100
9.3 @@ -504,96 +504,11 @@
9.5    done
9.6
9.7 -text {* A bijection between @{text "'n::finite"} and @{text "{..<CARD('n)}"} *}
9.8 -
9.9 -definition vec_bij_nat :: "nat \<Rightarrow> ('n::finite)" where
9.10 -  "vec_bij_nat = (SOME p. bij_betw p {..<CARD('n)} (UNIV::'n set) )"
9.11 -
9.12 -abbreviation "\<pi> \<equiv> vec_bij_nat"
9.13 -definition "\<pi>' = inv_into {..<CARD('n)} (\<pi>::nat \<Rightarrow> ('n::finite))"
9.14 -
9.15 -lemma bij_betw_pi:
9.16 -  "bij_betw \<pi> {..<CARD('n::finite)} (UNIV::('n::finite) set)"
9.17 -  using ex_bij_betw_nat_finite[of "UNIV::'n set"]
9.18 -  by (auto simp: vec_bij_nat_def atLeast0LessThan
9.19 -    intro!: someI_ex[of "\<lambda>x. bij_betw x {..<CARD('n)} (UNIV::'n set)"])
9.20 -
9.21 -lemma bij_betw_pi'[intro]: "bij_betw \<pi>' (UNIV::'n set) {..<CARD('n::finite)}"
9.22 -  using bij_betw_inv_into[OF bij_betw_pi] unfolding \<pi>'_def by auto
9.23 -
9.24 -lemma pi'_inj[intro]: "inj \<pi>'"
9.25 -  using bij_betw_pi' unfolding bij_betw_def by auto
9.26 -
9.27 -lemma pi'_range[intro]: "\<And>i::'n. \<pi>' i < CARD('n::finite)"
9.28 -  using bij_betw_pi' unfolding bij_betw_def by auto
9.29 -
9.30 -lemma pi_pi'[simp]: "\<And>i::'n::finite. \<pi> (\<pi>' i) = i"
9.31 -  using bij_betw_pi by (auto intro!: f_inv_into_f simp: \<pi>'_def bij_betw_def)
9.32 -
9.33 -lemma pi'_pi[simp]: "\<And>i. i\<in>{..<CARD('n::finite)} \<Longrightarrow> \<pi>' (\<pi> i::'n) = i"
9.34 -  using bij_betw_pi by (auto intro!: inv_into_f_eq simp: \<pi>'_def bij_betw_def)
9.35 -
9.36 -lemma pi_pi'_alt[simp]: "\<And>i. i<CARD('n::finite) \<Longrightarrow> \<pi>' (\<pi> i::'n) = i"
9.37 -  by auto
9.38 -
9.39 -lemma pi_inj_on: "inj_on (\<pi>::nat\<Rightarrow>'n::finite) {..<CARD('n)}"
9.40 -  using bij_betw_pi[where 'n='n] by (simp add: bij_betw_def)
9.41 -
9.42  instantiation vec :: (euclidean_space, finite) euclidean_space
9.43  begin
9.44
9.45  definition "Basis = (\<Union>i. \<Union>u\<in>Basis. {axis i u})"
9.46
9.47 -definition "dimension (t :: ('a ^ 'b) itself) = CARD('b) * DIM('a)"
9.48 -
9.49 -definition "basis i =
9.50 -  (if i < (CARD('b) * DIM('a))
9.51 -  then axis (\<pi>(i div DIM('a))) (basis (i mod DIM('a)))
9.52 -  else 0)"
9.53 -
9.54 -lemma basis_eq:
9.55 -  assumes "i < CARD('b)" and "j < DIM('a)"
9.56 -  shows "basis (j + i * DIM('a)) = axis (\<pi> i) (basis j)"
9.57 -proof -
9.58 -  have "j + i * DIM('a) <  DIM('a) * (i + 1)" using assms by (auto simp: field_simps)
9.59 -  also have "\<dots> \<le> DIM('a) * CARD('b)" using assms unfolding mult_le_cancel1 by auto
9.60 -  finally show ?thesis
9.61 -    unfolding basis_vec_def using assms by (auto simp: vec_eq_iff not_less field_simps)
9.62 -qed
9.63 -
9.64 -lemma basis_eq_pi':
9.65 -  assumes "j < DIM('a)"
9.66 -  shows "basis (j + \<pi>' i * DIM('a)) \$ k = (if k = i then basis j else 0)"
9.67 -  apply (subst basis_eq)
9.68 -  using pi'_range assms by (simp_all add: axis_def)
9.69 -
9.70 -lemma split_times_into_modulo[consumes 1]:
9.71 -  fixes k :: nat
9.72 -  assumes "k < A * B"
9.73 -  obtains i j where "i < A" and "j < B" and "k = j + i * B"
9.74 -proof
9.75 -  have "A * B \<noteq> 0"
9.76 -  proof assume "A * B = 0" with assms show False by simp qed
9.77 -  hence "0 < B" by auto
9.78 -  thus "k mod B < B" using `0 < B` by auto
9.79 -next
9.80 -  have "k div B * B \<le> k div B * B + k mod B" by (rule le_add1)
9.81 -  also have "... < A * B" using assms by simp
9.82 -  finally show "k div B < A" by auto
9.83 -qed simp
9.84 -
9.85 -lemma linear_less_than_times:
9.86 -  fixes i j A B :: nat assumes "i < B" "j < A"
9.87 -  shows "j + i * A < B * A"
9.88 -proof -
9.89 -  have "i * A + j < (Suc i)*A" using `j < A` by simp
9.90 -  also have "\<dots> \<le> B * A" using `i < B` unfolding mult_le_cancel2 by simp
9.91 -  finally show ?thesis by simp
9.92 -qed
9.93 -
9.94 -lemma DIM_cart[simp]: "DIM('a^'b) = CARD('b) * DIM('a)"
9.95 -  by (rule dimension_vec_def)
9.96 -
9.97  instance proof
9.98    show "(Basis :: ('a ^ 'b) set) \<noteq> {}"
9.99      unfolding Basis_vec_def by simp
9.100 @@ -611,27 +526,17 @@
9.101    show "(\<forall>u\<in>Basis. inner x u = 0) \<longleftrightarrow> x = 0"
9.102      unfolding Basis_vec_def
9.103      by (simp add: inner_axis euclidean_all_zero_iff vec_eq_iff)
9.104 -next
9.105 -  show "DIM('a ^ 'b) = card (Basis :: ('a ^ 'b) set)"
9.106 -    unfolding Basis_vec_def dimension_vec_def dimension_def
9.107 -    by (simp add: card_UN_disjoint [unfolded disjoint_iff_not_equal]
9.108 -      axis_eq_axis nonzero_Basis)
9.109 -next
9.110 -  show "basis ` {..<DIM('a ^ 'b)} = (Basis :: ('a ^ 'b) set)"
9.111 -    unfolding Basis_vec_def
9.112 -    apply auto
9.113 -    apply (erule split_times_into_modulo)
9.114 -    apply (simp add: basis_eq axis_eq_axis)
9.115 -    apply (erule Basis_elim)
9.116 -    apply (simp add: image_def basis_vec_def axis_eq_axis)
9.117 -    apply (rule rev_bexI, simp)
9.118 -    apply (erule linear_less_than_times [OF pi'_range])
9.119 +qed
9.120 +
9.121 +lemma DIM_cart[simp]: "DIM('a^'b) = CARD('b) * DIM('a)"
9.122 +  apply (simp add: Basis_vec_def)
9.123 +  apply (subst card_UN_disjoint)
9.124 +     apply simp
9.125      apply simp
9.126 -    done
9.127 -next
9.128 -  show "basis ` {DIM('a ^ 'b)..} = {0::'a ^ 'b}"
9.129 -    by (auto simp add: image_def basis_vec_def)
9.130 -qed
9.131 +   apply (auto simp: axis_eq_axis) [1]
9.132 +  apply (subst card_UN_disjoint)
9.133 +     apply (auto simp: axis_eq_axis)
9.134 +  done
9.135
9.136  end
9.137
```
```    10.1 --- a/src/HOL/Multivariate_Analysis/Integration.thy	Fri Dec 14 14:46:01 2012 +0100
10.2 +++ b/src/HOL/Multivariate_Analysis/Integration.thy	Fri Dec 14 15:46:01 2012 +0100
10.3 @@ -71,12 +71,8 @@
10.4    apply (auto simp: isUb_def setle_def)
10.5    done
10.6
10.7 -lemma bounded_linear_component [intro]: "bounded_linear (\<lambda>x::'a::euclidean_space. x \$\$ k)"
10.8 -  apply (rule bounded_linearI[where K=1])
10.9 -  using component_le_norm[of _ k]
10.10 -  unfolding real_norm_def
10.11 -  apply auto
10.12 -  done
10.13 +lemma bounded_linear_component [intro]: "bounded_linear (\<lambda>x::'a::euclidean_space. x \<bullet> k)"
10.14 +  by (rule bounded_linear_inner_left)
10.15
10.16  lemma transitive_stepwise_lt_eq:
10.17    assumes "(\<And>x y z::nat. R x y \<Longrightarrow> R y z \<Longrightarrow> R x z)"
10.18 @@ -162,16 +158,10 @@
10.19
10.20  subsection {* Some useful lemmas about intervals. *}
10.21
10.22 -abbreviation One  where "One \<equiv> ((\<chi>\<chi> i. 1)::_::ordered_euclidean_space)"
10.23 -
10.24 -lemma empty_as_interval: "{} = {One..0}"
10.25 -  apply (rule set_eqI, rule)
10.26 -  defer
10.27 -  unfolding mem_interval
10.28 -  using UNIV_witness[where 'a='n]
10.29 -  apply (erule_tac exE, rule_tac x = x in allE)
10.30 -  apply auto
10.31 -  done
10.32 +abbreviation One where "One \<equiv> ((\<Sum>Basis)::_::euclidean_space)"
10.33 +
10.34 +lemma empty_as_interval: "{} = {One..(0::'a::ordered_euclidean_space)}"
10.35 +  by (auto simp: set_eq_iff eucl_le[where 'a='a] intro!: bexI[OF _ SOME_Basis])
10.36
10.37  lemma interior_subset_union_intervals:
10.38    assumes "i = {a..b::'a::ordered_euclidean_space}" "j = {c..d}"
10.39 @@ -255,17 +245,17 @@
10.40              done
10.41          next
10.42            case False
10.43 -          then obtain k where "x\$\$k \<le> a\$\$k \<or> x\$\$k \<ge> b\$\$k" and k:"k<DIM('a)"
10.44 +          then obtain k where "x\<bullet>k \<le> a\<bullet>k \<or> x\<bullet>k \<ge> b\<bullet>k" and k:"k\<in>Basis"
10.45              unfolding mem_interval by (auto simp add: not_less)
10.46 -          hence "x\$\$k = a\$\$k \<or> x\$\$k = b\$\$k"
10.47 +          hence "x\<bullet>k = a\<bullet>k \<or> x\<bullet>k = b\<bullet>k"
10.48              using True unfolding ab and mem_interval
10.49 -              apply (erule_tac x = k in allE)
10.50 +              apply (erule_tac x = k in ballE)
10.51                apply auto
10.52                done
10.53            hence "\<exists>x. ball x (e/2) \<subseteq> s \<inter> (\<Union>f)"
10.54            proof (erule_tac disjE)
10.55 -            let ?z = "x - (e/2) *\<^sub>R basis k"
10.56 -            assume as: "x\$\$k = a\$\$k"
10.57 +            let ?z = "x - (e/2) *\<^sub>R k"
10.58 +            assume as: "x\<bullet>k = a\<bullet>k"
10.59              have "ball ?z (e / 2) \<inter> i = {}"
10.60                apply (rule ccontr)
10.61                unfolding ex_in_conv[THEN sym]
10.62 @@ -273,15 +263,12 @@
10.63                fix y
10.64                assume "y \<in> ball ?z (e / 2) \<inter> i"
10.65                hence "dist ?z y < e/2" and yi:"y\<in>i" by auto
10.66 -              hence "\<bar>(?z - y) \$\$ k\<bar> < e/2"
10.67 -                using component_le_norm[of "?z - y" k] unfolding dist_norm by auto
10.68 -              hence "y\$\$k < a\$\$k"
10.69 -                using e[THEN conjunct1] k by (auto simp add: field_simps as)
10.70 +              hence "\<bar>(?z - y) \<bullet> k\<bar> < e/2"
10.71 +                using Basis_le_norm[OF k, of "?z - y"] unfolding dist_norm by auto
10.72 +              hence "y\<bullet>k < a\<bullet>k"
10.73 +                using e[THEN conjunct1] k by (auto simp add: field_simps as inner_Basis inner_simps)
10.74                hence "y \<notin> i"
10.75 -                unfolding ab mem_interval not_all
10.76 -                apply (rule_tac x=k in exI)
10.77 -                using k apply auto
10.78 -                done
10.79 +                unfolding ab mem_interval by (auto intro!: bexI[OF _ k])
10.80                thus False using yi by auto
10.81              qed
10.82              moreover
10.83 @@ -290,10 +277,10 @@
10.84              proof
10.85                fix y
10.86                assume as: "y\<in> ball ?z (e/2)"
10.87 -              have "norm (x - y) \<le> \<bar>e\<bar> / 2 + norm (x - y - (e / 2) *\<^sub>R basis k)"
10.88 +              have "norm (x - y) \<le> \<bar>e\<bar> / 2 + norm (x - y - (e / 2) *\<^sub>R k)"
10.89                  apply -
10.90 -                apply (rule order_trans,rule norm_triangle_sub[of "x - y" "(e/2) *\<^sub>R basis k"])
10.91 -                unfolding norm_scaleR norm_basis
10.92 +                apply (rule order_trans,rule norm_triangle_sub[of "x - y" "(e/2) *\<^sub>R k"])
10.93 +                unfolding norm_scaleR norm_Basis[OF k]
10.94                  apply auto
10.95                  done
10.96                also have "\<dots> < \<bar>e\<bar> / 2 + \<bar>e\<bar> / 2"
10.97 @@ -310,8 +297,8 @@
10.98                apply auto
10.99                done
10.100            next
10.101 -            let ?z = "x + (e/2) *\<^sub>R basis k"
10.102 -            assume as: "x\$\$k = b\$\$k"
10.103 +            let ?z = "x + (e/2) *\<^sub>R k"
10.104 +            assume as: "x\<bullet>k = b\<bullet>k"
10.105              have "ball ?z (e / 2) \<inter> i = {}"
10.106                apply (rule ccontr)
10.107                unfolding ex_in_conv[THEN sym]
10.108 @@ -319,15 +306,12 @@
10.109                fix y
10.110                assume "y \<in> ball ?z (e / 2) \<inter> i"
10.111                hence "dist ?z y < e/2" and yi:"y\<in>i" by auto
10.112 -              hence "\<bar>(?z - y) \$\$ k\<bar> < e/2"
10.113 -                using component_le_norm[of "?z - y" k] unfolding dist_norm by auto
10.114 -              hence "y\$\$k > b\$\$k"
10.115 -                using e[THEN conjunct1] k by(auto simp add:field_simps as)
10.116 +              hence "\<bar>(?z - y) \<bullet> k\<bar> < e/2"
10.117 +                using Basis_le_norm[OF k, of "?z - y"] unfolding dist_norm by auto
10.118 +              hence "y\<bullet>k > b\<bullet>k"
10.119 +                using e[THEN conjunct1] k by(auto simp add:field_simps inner_simps inner_Basis as)
10.120                hence "y \<notin> i"
10.121 -                unfolding ab mem_interval not_all
10.122 -                using k apply (rule_tac x=k in exI)
10.123 -                apply auto
10.124 -                done
10.125 +                unfolding ab mem_interval by (auto intro!: bexI[OF _ k])
10.126                thus False using yi by auto
10.127              qed
10.128              moreover
10.129 @@ -336,11 +320,11 @@
10.130              proof
10.131                fix y
10.132                assume as: "y\<in> ball ?z (e/2)"
10.133 -              have "norm (x - y) \<le> \<bar>e\<bar> / 2 + norm (x - y + (e / 2) *\<^sub>R basis k)"
10.134 +              have "norm (x - y) \<le> \<bar>e\<bar> / 2 + norm (x - y + (e / 2) *\<^sub>R k)"
10.135                  apply -
10.136 -                apply(rule order_trans,rule norm_triangle_sub[of "x - y" "- (e/2) *\<^sub>R basis k"])
10.137 +                apply(rule order_trans,rule norm_triangle_sub[of "x - y" "- (e/2) *\<^sub>R k"])
10.138                  unfolding norm_scaleR
10.139 -                apply auto
10.140 +                apply (auto simp: k)
10.141                  done
10.142                also have "\<dots> < \<bar>e\<bar> / 2 + \<bar>e\<bar> / 2"
10.144 @@ -383,61 +367,25 @@
10.145
10.146  subsection {* Bounds on intervals where they exist. *}
10.147
10.148 -definition "interval_upperbound (s::('a::ordered_euclidean_space) set) =
10.149 -  ((\<chi>\<chi> i. Sup {a. \<exists>x\<in>s. x\$\$i = a})::'a)"
10.150 -
10.151 -definition "interval_lowerbound (s::('a::ordered_euclidean_space) set) =
10.152 -  ((\<chi>\<chi> i. Inf {a. \<exists>x\<in>s. x\$\$i = a})::'a)"
10.153 +definition interval_upperbound :: "('a::ordered_euclidean_space) set \<Rightarrow> 'a" where
10.154 +  "interval_upperbound s = (\<Sum>i\<in>Basis. Sup {a. \<exists>x\<in>s. x\<bullet>i = a} *\<^sub>R i)"
10.155 +
10.156 +definition interval_lowerbound :: "('a::ordered_euclidean_space) set \<Rightarrow> 'a" where
10.157 +  "interval_lowerbound s = (\<Sum>i\<in>Basis. Inf {a. \<exists>x\<in>s. x\<bullet>i = a} *\<^sub>R i)"
10.158
10.159  lemma interval_upperbound[simp]:
10.160 -  assumes "\<forall>i<DIM('a::ordered_euclidean_space). a\$\$i \<le> (b::'a)\$\$i"
10.161 -  shows "interval_upperbound {a..b} = b"
10.162 -  using assms
10.163 -  unfolding interval_upperbound_def
10.164 -  apply (subst euclidean_eq[where 'a='a])
10.165 -  apply safe
10.166 -  unfolding euclidean_lambda_beta'
10.167 -  apply (erule_tac x=i in allE)
10.168 -  apply (rule Sup_unique)
10.169 -  unfolding setle_def
10.170 -  apply rule
10.171 -  unfolding mem_Collect_eq
10.172 -  apply (erule bexE)
10.173 -  unfolding mem_interval
10.174 -  defer
10.175 -  apply (rule, rule)
10.176 -  apply (rule_tac x="b\$\$i" in bexI)
10.177 -  defer
10.178 -  unfolding mem_Collect_eq
10.179 -  apply (rule_tac x=b in bexI)
10.180 -  unfolding mem_interval
10.181 -  using assms apply auto
10.182 -  done
10.183 +  "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow>
10.184 +    interval_upperbound {a..b} = (b::'a::ordered_euclidean_space)"
10.185 +  unfolding interval_upperbound_def euclidean_representation_setsum
10.186 +  by (auto simp del: ex_simps simp add: Bex_def ex_simps[symmetric] eucl_le[where 'a='a] setle_def
10.187 +           intro!: Sup_unique)
10.188
10.189  lemma interval_lowerbound[simp]:
10.190 -  assumes "\<forall>i<DIM('a::ordered_euclidean_space). a\$\$i \<le> (b::'a)\$\$i"
10.191 -  shows "interval_lowerbound {a..b} = a"
10.192 -  using assms
10.193 -  unfolding interval_lowerbound_def
10.194 -  apply (subst euclidean_eq[where 'a='a])
10.195 -  apply safe
10.196 -  unfolding euclidean_lambda_beta'
10.197 -  apply (erule_tac x=i in allE)
10.198 -  apply (rule Inf_unique)
10.199 -  unfolding setge_def
10.200 -  apply rule
10.201 -  unfolding mem_Collect_eq
10.202 -  apply (erule bexE)
10.203 -  unfolding mem_interval
10.204 -  defer
10.205 -  apply (rule, rule)
10.206 -  apply (rule_tac x = "a\$\$i" in bexI)
10.207 -  defer
10.208 -  unfolding mem_Collect_eq
10.209 -  apply (rule_tac x=a in bexI)
10.210 -  unfolding mem_interval
10.211 -  using assms apply auto
10.212 -  done
10.213 +  "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow>
10.214 +    interval_lowerbound {a..b} = (a::'a::ordered_euclidean_space)"
10.215 +  unfolding interval_lowerbound_def euclidean_representation_setsum
10.216 +  by (auto simp del: ex_simps simp add: Bex_def ex_simps[symmetric] eucl_le[where 'a='a] setge_def
10.217 +           intro!: Inf_unique)
10.218
10.219  lemmas interval_bounds = interval_upperbound interval_lowerbound
10.220
10.221 @@ -449,15 +397,15 @@
10.222  subsection {* Content (length, area, volume...) of an interval. *}
10.223
10.224  definition "content (s::('a::ordered_euclidean_space) set) =
10.225 -  (if s = {} then 0 else (\<Prod>i<DIM('a). (interval_upperbound s)\$\$i - (interval_lowerbound s)\$\$i))"
10.226 -
10.227 -lemma interval_not_empty:"\<forall>i<DIM('a). a\$\$i \<le> b\$\$i \<Longrightarrow> {a..b::'a::ordered_euclidean_space} \<noteq> {}"
10.228 +  (if s = {} then 0 else (\<Prod>i\<in>Basis. (interval_upperbound s)\<bullet>i - (interval_lowerbound s)\<bullet>i))"
10.229 +
10.230 +lemma interval_not_empty:"\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow> {a..b::'a::ordered_euclidean_space} \<noteq> {}"
10.231    unfolding interval_eq_empty unfolding not_ex not_less by auto
10.232
10.233  lemma content_closed_interval:
10.234    fixes a::"'a::ordered_euclidean_space"
10.235 -  assumes "\<forall>i<DIM('a). a\$\$i \<le> b\$\$i"
10.236 -  shows "content {a..b} = (\<Prod>i<DIM('a). b\$\$i - a\$\$i)"
10.237 +  assumes "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i"
10.238 +  shows "content {a..b} = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
10.239    using interval_not_empty[OF assms]
10.240    unfolding content_def interval_upperbound[OF assms] interval_lowerbound[OF assms]
10.241    by auto
10.242 @@ -465,7 +413,7 @@
10.243  lemma content_closed_interval':
10.244    fixes a::"'a::ordered_euclidean_space"
10.245    assumes "{a..b}\<noteq>{}"
10.246 -  shows "content {a..b} = (\<Prod>i<DIM('a). b\$\$i - a\$\$i)"
10.247 +  shows "content {a..b} = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
10.248    apply (rule content_closed_interval)
10.249    using assms unfolding interval_ne_empty
10.250    apply assumption
10.251 @@ -482,13 +430,13 @@
10.252  lemma content_singleton[simp]: "content {a} = 0"
10.253  proof -
10.254    have "content {a .. a} = 0"
10.255 -    by (subst content_closed_interval) auto
10.256 +    by (subst content_closed_interval) (auto simp: ex_in_conv)
10.257    then show ?thesis by simp
10.258  qed
10.259
10.260  lemma content_unit[intro]: "content{0..One::'a::ordered_euclidean_space} = 1"
10.261  proof -
10.262 -  have *: "\<forall>i<DIM('a). (0::'a)\$\$i \<le> (One::'a)\$\$i" by auto
10.263 +  have *: "\<forall>i\<in>Basis. (0::'a)\<bullet>i \<le> (One::'a)\<bullet>i" by auto
10.264    have "0 \<in> {0..One::'a}" unfolding mem_interval by auto
10.265    thus ?thesis unfolding content_def interval_bounds[OF *] using setprod_1 by auto
10.266  qed
10.267 @@ -498,12 +446,12 @@
10.268    shows "0 \<le> content {a..b}"
10.269  proof (cases "{a..b} = {}")
10.270    case False
10.271 -  hence *: "\<forall>i<DIM('a). a \$\$ i \<le> b \$\$ i" unfolding interval_ne_empty .
10.272 -  have "(\<Prod>i<DIM('a). interval_upperbound {a..b} \$\$ i - interval_lowerbound {a..b} \$\$ i) \<ge> 0"
10.273 +  hence *: "\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i" unfolding interval_ne_empty .
10.274 +  have "(\<Prod>i\<in>Basis. interval_upperbound {a..b} \<bullet> i - interval_lowerbound {a..b} \<bullet> i) \<ge> 0"
10.275      apply (rule setprod_nonneg)
10.276      unfolding interval_bounds[OF *]
10.277      using *
10.278 -    apply (erule_tac x=x in allE)
10.279 +    apply (erule_tac x=x in ballE)
10.280      apply auto
10.281      done
10.282    thus ?thesis unfolding content_def by (auto simp del:interval_bounds')
10.283 @@ -511,75 +459,59 @@
10.284
10.285  lemma content_pos_lt:
10.286    fixes a::"'a::ordered_euclidean_space"
10.287 -  assumes "\<forall>i<DIM('a). a\$\$i < b\$\$i"
10.288 +  assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
10.289    shows "0 < content {a..b}"
10.290  proof -
10.291 -  have help_lemma1: "\<forall>i<DIM('a). a\$\$i < b\$\$i \<Longrightarrow> \<forall>i<DIM('a). a\$\$i \<le> ((b\$\$i)::real)"
10.292 -    apply (rule, erule_tac x=i in allE)
10.293 +  have help_lemma1: "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i \<Longrightarrow> \<forall>i\<in>Basis. a\<bullet>i \<le> ((b\<bullet>i)::real)"
10.294 +    apply (rule, erule_tac x=i in ballE)
10.295      apply auto
10.296      done
10.297    show ?thesis unfolding content_closed_interval[OF help_lemma1[OF assms]]
10.298      apply(rule setprod_pos)
10.299 -    using assms apply (erule_tac x=x in allE)
10.300 +    using assms apply (erule_tac x=x in ballE)
10.301      apply auto
10.302      done
10.303  qed
10.304
10.305 -lemma content_eq_0: "content{a..b::'a::ordered_euclidean_space} = 0 \<longleftrightarrow> (\<exists>i<DIM('a). b\$\$i \<le> a\$\$i)"
10.306 +lemma content_eq_0: "content{a..b::'a::ordered_euclidean_space} = 0 \<longleftrightarrow> (\<exists>i\<in>Basis. b\<bullet>i \<le> a\<bullet>i)"
10.307  proof (cases "{a..b} = {}")
10.308    case True
10.309    thus ?thesis
10.310      unfolding content_def if_P[OF True]
10.311      unfolding interval_eq_empty
10.312      apply -
10.313 -    apply (rule, erule exE)
10.314 -    apply (rule_tac x = i in exI)
10.315 +    apply (rule, erule bexE)
10.316 +    apply (rule_tac x = i in bexI)
10.317      apply auto
10.318      done
10.319  next
10.320    case False
10.321    from this[unfolded interval_eq_empty not_ex not_less]
10.322 -  have as: "\<forall>i<DIM('a). b \$\$ i \<ge> a \$\$ i" by fastforce
10.323 +  have as: "\<forall>i\<in>Basis. b \<bullet> i \<ge> a \<bullet> i" by fastforce
10.324    show ?thesis
10.325 -    unfolding content_def if_not_P[OF False] setprod_zero_iff[OF finite_lessThan]
10.326 -    apply rule
10.327 -    apply (erule_tac[!] exE bexE)
10.328 -    unfolding interval_bounds[OF as]
10.329 -    apply (rule_tac x=x in exI)
10.330 -    defer
10.331 -    apply (rule_tac x=i in bexI)
10.332 -    using as apply (erule_tac x=i in allE)
10.333 -    apply auto
10.334 -    done
10.335 +    unfolding content_def if_not_P[OF False] setprod_zero_iff[OF finite_Basis]
10.336 +    using as
10.337 +    by (auto intro!: bexI)
10.338  qed
10.339
10.340  lemma cond_cases:"(P \<Longrightarrow> Q x) \<Longrightarrow> (\<not> P \<Longrightarrow> Q y) \<Longrightarrow> Q (if P then x else y)" by auto
10.341
10.342  lemma content_closed_interval_cases:
10.343    "content {a..b::'a::ordered_euclidean_space} =
10.344 -    (if \<forall>i<DIM('a). a\$\$i \<le> b\$\$i then setprod (\<lambda>i. b\$\$i - a\$\$i) {..<DIM('a)} else 0)"
10.345 -  apply (rule cond_cases)
10.346 -  apply (rule content_closed_interval)
10.347 -  unfolding content_eq_0 not_all not_le
10.348 -  defer
10.349 -  apply (erule exE,rule_tac x=x in exI)
10.350 -  apply auto
10.351 -  done
10.352 +    (if \<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i then setprod (\<lambda>i. b\<bullet>i - a\<bullet>i) Basis else 0)"
10.353 +  by (auto simp: not_le content_eq_0 intro: less_imp_le content_closed_interval)
10.354
10.355  lemma content_eq_0_interior: "content {a..b} = 0 \<longleftrightarrow> interior({a..b}) = {}"
10.356    unfolding content_eq_0 interior_closed_interval interval_eq_empty by auto
10.357
10.358 -(*lemma content_eq_0_1: "content {a..b::real^1} = 0 \<longleftrightarrow> dest_vec1 b \<le> dest_vec1 a"
10.359 -  unfolding content_eq_0 by auto*)
10.360 -
10.361 -lemma content_pos_lt_eq: "0 < content {a..b::'a::ordered_euclidean_space} \<longleftrightarrow> (\<forall>i<DIM('a). a\$\$i < b\$\$i)"
10.362 +lemma content_pos_lt_eq: "0 < content {a..b::'a::ordered_euclidean_space} \<longleftrightarrow> (\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i)"
10.363    apply rule
10.364    defer
10.365    apply (rule content_pos_lt, assumption)
10.366  proof -
10.367    assume "0 < content {a..b}"
10.368    hence "content {a..b} \<noteq> 0" by auto
10.369 -  thus "\<forall>i<DIM('a). a\$\$i < b\$\$i"
10.370 +  thus "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
10.371      unfolding content_eq_0 not_ex not_le by fastforce
10.372  qed
10.373
10.374 @@ -593,20 +525,20 @@
10.375    thus ?thesis using content_pos_le[of c d] by auto
10.376  next
10.377    case False
10.378 -  hence ab_ne:"\<forall>i<DIM('a). a \$\$ i \<le> b \$\$ i" unfolding interval_ne_empty by auto
10.379 +  hence ab_ne:"\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i" unfolding interval_ne_empty by auto
10.380    hence ab_ab:"a\<in>{a..b}" "b\<in>{a..b}" unfolding mem_interval by auto
10.381    have "{c..d} \<noteq> {}" using assms False by auto
10.382 -  hence cd_ne:"\<forall>i<DIM('a). c \$\$ i \<le> d \$\$ i" using assms unfolding interval_ne_empty by auto
10.383 +  hence cd_ne:"\<forall>i\<in>Basis. c \<bullet> i \<le> d \<bullet> i" using assms unfolding interval_ne_empty by auto
10.384    show ?thesis
10.385      unfolding content_def
10.386      unfolding interval_bounds[OF ab_ne] interval_bounds[OF cd_ne]
10.387      unfolding if_not_P[OF False] if_not_P[OF `{c..d} \<noteq> {}`]
10.388      apply(rule setprod_mono,rule)
10.389    proof
10.390 -    fix i
10.391 -    assume i:"i\<in>{..<DIM('a)}"
10.392 -    show "0 \<le> b \$\$ i - a \$\$ i" using ab_ne[THEN spec[where x=i]] i by auto
10.393 -    show "b \$\$ i - a \$\$ i \<le> d \$\$ i - c \$\$ i"
10.394 +    fix i :: 'a
10.395 +    assume i:"i\<in>Basis"
10.396 +    show "0 \<le> b \<bullet> i - a \<bullet> i" using ab_ne[THEN bspec, OF i] i by auto
10.397 +    show "b \<bullet> i - a \<bullet> i \<le> d \<bullet> i - c \<bullet> i"
10.398        using assms[unfolded subset_eq mem_interval,rule_format,OF ab_ab(2),of i]
10.399        using assms[unfolded subset_eq mem_interval,rule_format,OF ab_ab(1),of i]
10.400        using i by auto
10.401 @@ -857,134 +789,84 @@
10.402    show "k \<noteq> {}" using k d1(3) d2(3) by auto show "\<exists>a b. k = {a..b}" using k d1(4) d2(4) by auto qed
10.403
10.404  lemma partial_division_extend_1:
10.405 -  assumes "{c..d} \<subseteq> {a..b::'a::ordered_euclidean_space}" "{c..d} \<noteq> {}"
10.406 +  assumes incl: "{c..d} \<subseteq> {a..b::'a::ordered_euclidean_space}" and nonempty: "{c..d} \<noteq> {}"
10.407    obtains p where "p division_of {a..b}" "{c..d} \<in> p"
10.408 -proof- def n \<equiv> "DIM('a)" have n:"1 \<le> n" "0 < n" "n \<noteq> 0" unfolding n_def using DIM_positive[where 'a='a] by auto
10.409 -  guess \<pi> using ex_bij_betw_nat_finite_1[OF finite_lessThan[of "DIM('a)"]] .. note \<pi>=this
10.410 -  def \<pi>' \<equiv> "inv_into {1..n} \<pi>"
10.411 -  have \<pi>':"bij_betw \<pi>' {..<DIM('a)} {1..n}" using bij_betw_inv_into[OF \<pi>] unfolding \<pi>'_def n_def by auto
10.412 -  hence \<pi>'_i:"\<And>i. i<DIM('a) \<Longrightarrow> \<pi>' i \<in> {1..n}" unfolding bij_betw_def by auto
10.413 -  have \<pi>_i:"\<And>i. i\<in>{1..n} \<Longrightarrow> \<pi> i <DIM('a)" using \<pi> unfolding bij_betw_def n_def by auto
10.414 -  have \<pi>_\<pi>'[simp]:"\<And>i. i<DIM('a) \<Longrightarrow> \<pi> (\<pi>' i) = i" unfolding \<pi>'_def
10.415 -    apply(rule f_inv_into_f) unfolding n_def using \<pi> unfolding bij_betw_def by auto
10.416 -  have \<pi>'_\<pi>[simp]:"\<And>i. i\<in>{1..n} \<Longrightarrow> \<pi>' (\<pi> i) = i" unfolding \<pi>'_def apply(rule inv_into_f_eq)
10.417 -    using \<pi> unfolding n_def bij_betw_def by auto
10.418 -  have "{c..d} \<noteq> {}" using assms by auto
10.419 -  let ?p1 = "\<lambda>l. {(\<chi>\<chi> i. if \<pi>' i < l then c\$\$i else a\$\$i)::'a .. (\<chi>\<chi> i. if \<pi>' i < l then d\$\$i else if \<pi>' i = l then c\$\$\<pi> l else b\$\$i)}"
10.420 -  let ?p2 = "\<lambda>l. {(\<chi>\<chi> i. if \<pi>' i < l then c\$\$i else if \<pi>' i = l then d\$\$\<pi> l else a\$\$i)::'a .. (\<chi>\<chi> i. if \<pi>' i < l then d\$\$i else b\$\$i)}"
10.421 -  let ?p =  "{?p1 l |l. l \<in> {1..n+1}} \<union> {?p2 l |l. l \<in> {1..n+1}}"
10.422 -  have abcd:"\<And>i. i<DIM('a) \<Longrightarrow> a \$\$ i \<le> c \$\$ i \<and> c\$\$i \<le> d\$\$i \<and> d \$\$ i \<le> b \$\$ i" using assms
10.423 -    unfolding subset_interval interval_eq_empty by auto
10.424 -  show ?thesis apply(rule that[of ?p]) apply(rule division_ofI)
10.425 -  proof- have "\<And>i. i<DIM('a) \<Longrightarrow> \<pi>' i < Suc n"
10.426 -    proof(rule ccontr,unfold not_less) fix i assume i:"i<DIM('a)" and "Suc n \<le> \<pi>' i"
10.427 -      hence "\<pi>' i \<notin> {1..n}" by auto thus False using \<pi>' i unfolding bij_betw_def by auto
10.428 -    qed hence "c = (\<chi>\<chi> i. if \<pi>' i < Suc n then c \$\$ i else a \$\$ i)"
10.429 -        "d = (\<chi>\<chi> i. if \<pi>' i < Suc n then d \$\$ i else if \<pi>' i = n + 1 then c \$\$ \<pi> (n + 1) else b \$\$ i)"
10.430 -      unfolding euclidean_eq[where 'a='a] using \<pi>' unfolding bij_betw_def by auto
10.431 -    thus cdp:"{c..d} \<in> ?p" apply-apply(rule UnI1) unfolding mem_Collect_eq apply(rule_tac x="n + 1" in exI) by auto
10.432 -    have "\<And>l. l\<in>{1..n+1} \<Longrightarrow> ?p1 l \<subseteq> {a..b}"  "\<And>l. l\<in>{1..n+1} \<Longrightarrow> ?p2 l \<subseteq> {a..b}"
10.433 -      unfolding subset_eq apply(rule_tac[!] ballI,rule_tac[!] ccontr)
10.434 -    proof- fix l assume l:"l\<in>{1..n+1}" fix x assume "x\<notin>{a..b}"
10.435 -      then guess i unfolding mem_interval not_all not_imp .. note i=conjunctD2[OF this]
10.436 -      show "x \<in> ?p1 l \<Longrightarrow> False" "x \<in> ?p2 l \<Longrightarrow> False" unfolding mem_interval apply(erule_tac[!] x=i in allE)
10.437 -        apply(case_tac[!] "\<pi>' i < l", case_tac[!] "\<pi>' i = l") using abcd[of i] i by auto
10.438 -    qed moreover have "\<And>x. x \<in> {a..b} \<Longrightarrow> x \<in> \<Union>?p"
10.439 -    proof- fix x assume x:"x\<in>{a..b}"
10.440 -      { presume "x\<notin>{c..d} \<Longrightarrow> x \<in> \<Union>?p" thus "x \<in> \<Union>?p" using cdp by blast }
10.441 -      let ?M = "{i. i\<in>{1..n+1} \<and> \<not> (c \$\$ \<pi> i \<le> x \$\$ \<pi> i \<and> x \$\$ \<pi> i \<le> d \$\$ \<pi> i)}"
10.442 -      assume "x\<notin>{c..d}" then guess i0 unfolding mem_interval not_all not_imp ..
10.443 -      hence "\<pi>' i0 \<in> ?M" using \<pi>' unfolding bij_betw_def by(auto intro!:le_SucI)
10.444 -      hence M:"finite ?M" "?M \<noteq> {}" by auto
10.445 -      def l \<equiv> "Min ?M" note l = Min_less_iff[OF M,unfolded l_def[symmetric]] Min_in[OF M,unfolded mem_Collect_eq l_def[symmetric]]
10.446 -        Min_gr_iff[OF M,unfolded l_def[symmetric]]
10.447 -      have "x\<in>?p1 l \<or> x\<in>?p2 l" using l(2)[THEN conjunct2] unfolding de_Morgan_conj not_le
10.448 -        apply- apply(erule disjE) apply(rule disjI1) defer apply(rule disjI2)
10.449 -      proof- assume as:"x \$\$ \<pi> l < c \$\$ \<pi> l"
10.450 -        show "x \<in> ?p1 l" unfolding mem_interval apply safe unfolding euclidean_lambda_beta'
10.451 -        proof- case goal1 have "\<pi>' i \<in> {1..n}" using \<pi>' unfolding bij_betw_def not_le using goal1 by auto
10.452 -          thus ?case using as x[unfolded mem_interval,rule_format,of i]
10.453 -            apply auto using l(3)[of "\<pi>' i"] using goal1 by(auto elim!:ballE[where x="\<pi>' i"])
10.454 -        next case goal2 have "\<pi>' i \<in> {1..n}" using \<pi>' unfolding bij_betw_def not_le using goal2 by auto
10.455 -          thus ?case using as x[unfolded mem_interval,rule_format,of i]
10.456 -            apply auto using l(3)[of "\<pi>' i"] using goal2 by(auto elim!:ballE[where x="\<pi>' i"])
10.457 -        qed
10.458 -      next assume as:"x \$\$ \<pi> l > d \$\$ \<pi> l"
10.459 -        show "x \<in> ?p2 l" unfolding mem_interval apply safe unfolding euclidean_lambda_beta'
10.460 -        proof- fix i assume i:"i<DIM('a)"
10.461 -          have "\<pi>' i \<in> {1..n}" using \<pi>' unfolding bij_betw_def not_le using i by auto
10.462 -          thus "(if \<pi>' i < l then c \$\$ i else if \<pi>' i = l then d \$\$ \<pi> l else a \$\$ i) \<le> x \$\$ i"
10.463 -            "x \$\$ i \<le> (if \<pi>' i < l then d \$\$ i else b \$\$ i)"
10.464 -            using as x[unfolded mem_interval,rule_format,of i]
10.465 -            apply auto using l(3)[of "\<pi>' i"] i by(auto elim!:ballE[where x="\<pi>' i"])
10.466 -        qed qed
10.467 -      thus "x \<in> \<Union>?p" using l(2) by blast
10.468 -    qed ultimately show "\<Union>?p = {a..b}" apply-apply(rule) defer apply(rule) by(assumption,blast)
10.469 -
10.470 -    show "finite ?p" by auto
10.471 -    fix k assume k:"k\<in>?p" then obtain l where l:"k = ?p1 l \<or> k = ?p2 l" "l \<in> {1..n + 1}" by auto
10.472 -    show "k\<subseteq>{a..b}" apply(rule,unfold mem_interval,rule,rule)
10.473 -    proof fix i x assume i:"i<DIM('a)" assume "x \<in> k" moreover have "\<pi>' i < l \<or> \<pi>' i = l \<or> \<pi>' i > l" by auto
10.474 -      ultimately show "a\$\$i \<le> x\$\$i" "x\$\$i \<le> b\$\$i" using abcd[of i] using l using i
10.475 -        by(auto elim!:allE[where x=i] simp add:eucl_le[where 'a='a]) (* FIXME: SLOW *)
10.476 -    qed have "\<And>l. ?p1 l \<noteq> {}" "\<And>l. ?p2 l \<noteq> {}" unfolding interval_eq_empty not_ex apply(rule_tac[!] allI)
10.477 -    proof- case goal1 thus ?case using abcd[of x] by auto
10.478 -    next   case goal2 thus ?case using abcd[of x] by auto
10.479 -    qed thus "k \<noteq> {}" using k by auto
10.480 -    show "\<exists>a b. k = {a..b}" using k by auto
10.481 -    fix k' assume k':"k' \<in> ?p" "k \<noteq> k'" then obtain l' where l':"k' = ?p1 l' \<or> k' = ?p2 l'" "l' \<in> {1..n + 1}" by auto
10.482 -    { fix k k' l l'
10.483 -      assume k:"k\<in>?p" and l:"k = ?p1 l \<or> k = ?p2 l" "l \<in> {1..n + 1}"
10.484 -      assume k':"k' \<in> ?p" "k \<noteq> k'" and  l':"k' = ?p1 l' \<or> k' = ?p2 l'" "l' \<in> {1..n + 1}"
10.485 -      assume "l \<le> l'" fix x
10.486 -      have "x \<notin> interior k \<inter> interior k'"
10.487 -      proof(rule,cases "l' = n+1") assume x:"x \<in> interior k \<inter> interior k'"
10.488 -        case True hence "\<And>i. i<DIM('a) \<Longrightarrow> \<pi>' i < l'" using \<pi>'_i using l' by(auto simp add:less_Suc_eq_le)
10.489 -        hence *:"\<And> P Q. (\<chi>\<chi> i. if \<pi>' i < l' then P i else Q i) = ((\<chi>\<chi> i. P i)::'a)" apply-apply(subst euclidean_eq) by auto
10.490 -        hence k':"k' = {c..d}" using l'(1) unfolding * by auto
10.491 -        have ln:"l < n + 1"
10.492 -        proof(rule ccontr) case goal1 hence l2:"l = n+1" using l by auto
10.493 -          hence "\<And>i. i<DIM('a) \<Longrightarrow> \<pi>' i < l" using \<pi>'_i by(auto simp add:less_Suc_eq_le)
10.494 -          hence *:"\<And> P Q. (\<chi>\<chi> i. if \<pi>' i < l then P i else Q i) = ((\<chi>\<chi> i. P i)::'a)" apply-apply(subst euclidean_eq) by auto
10.495 -          hence "k = {c..d}" using l(1) \<pi>'_i unfolding * by(auto)
10.496 -          thus False using `k\<noteq>k'` k' by auto
10.497 -        qed have **:"\<pi>' (\<pi> l) = l" using \<pi>'_\<pi>[of l] using l ln by auto
10.498 -        have "x \$\$ \<pi> l < c \$\$ \<pi> l \<or> d \$\$ \<pi> l < x \$\$ \<pi> l" using l(1) apply-
10.499 -        proof(erule disjE)
10.500 -          assume as:"k = ?p1 l" note * = conjunct1[OF x[unfolded as Int_iff interior_closed_interval mem_interval],rule_format]
10.501 -          show ?thesis using *[of "\<pi> l"] using ln l(2) using \<pi>_i[of l] by(auto simp add:** not_less)
10.502 -        next assume as:"k = ?p2 l" note * = conjunct1[OF x[unfolded as Int_iff interior_closed_interval mem_interval],rule_format]
10.503 -          show ?thesis using *[of "\<pi> l"] using ln l(2) using \<pi>_i[of l] unfolding ** by auto
10.504 -        qed thus False using x unfolding k' unfolding Int_iff interior_closed_interval mem_interval
10.505 -          by(auto elim!:allE[where x="\<pi> l"])
10.506 -      next case False hence "l < n + 1" using l'(2) using `l\<le>l'` by auto
10.507 -        hence ln:"l \<in> {1..n}" "l' \<in> {1..n}" using l l' False by auto
10.508 -        note \<pi>_l = \<pi>'_\<pi>[OF ln(1)] \<pi>'_\<pi>[OF ln(2)]
10.509 -        assume x:"x \<in> interior k \<inter> interior k'"
10.510 -        show False using l(1) l'(1) apply-
10.511 -        proof(erule_tac[!] disjE)+
10.512 -          assume as:"k = ?p1 l" "k' = ?p1 l'"
10.513 -          note * = conjunctD2[OF x[unfolded as Int_iff interior_closed_interval mem_interval],rule_format]
10.514 -          have "l \<noteq> l'" using k'(2)[unfolded as] by auto
10.515 -          thus False using *[of "\<pi> l'"] *[of "\<pi> l"] ln using \<pi>_i[OF ln(1)] \<pi>_i[OF ln(2)] apply(cases "l<l'")
10.516 -            by(auto simp add:euclidean_lambda_beta' \<pi>_l \<pi>_i n_def)
10.517 -        next assume as:"k = ?p2 l" "k' = ?p2 l'"
10.518 -          note * = conjunctD2[OF x[unfolded as Int_iff interior_closed_interval mem_interval],rule_format]
10.519 -          have "l \<noteq> l'" apply(rule) using k'(2)[unfolded as] by auto
10.520 -          thus False using *[of "\<pi> l"] *[of "\<pi> l'"]  `l \<le> l'` ln by(auto simp add:euclidean_lambda_beta' \<pi>_l \<pi>_i n_def)
10.521 -        next assume as:"k = ?p1 l" "k' = ?p2 l'"
10.522 -          note * = conjunctD2[OF x[unfolded as Int_iff interior_closed_interval mem_interval],rule_format]
10.523 -          show False using abcd[of "\<pi> l'"] using *[of "\<pi> l"] *[of "\<pi> l'"]  `l \<le> l'` ln apply(cases "l=l'")
10.524 -            by(auto simp add:euclidean_lambda_beta' \<pi>_l \<pi>_i n_def)
10.525 -        next assume as:"k = ?p2 l" "k' = ?p1 l'"
10.526 -          note * = conjunctD2[OF x[unfolded as Int_iff interior_closed_interval mem_interval],rule_format]
10.527 -          show False using *[of "\<pi> l"] *[of "\<pi> l'"] ln `l \<le> l'` apply(cases "l=l'") using abcd[of "\<pi> l'"]
10.528 -            by(auto simp add:euclidean_lambda_beta' \<pi>_l \<pi>_i n_def)
10.529 -        qed qed }
10.530 -    from this[OF k l k' l'] this[OF k'(1) l' k _ l] have "\<And>x. x \<notin> interior k \<inter> interior k'"
10.531 -      apply - apply(cases "l' \<le> l") using k'(2) by auto
10.532 -    thus "interior k \<inter> interior k' = {}" by auto
10.533 -qed qed
10.534 +proof
10.535 +  let ?B = "\<lambda>f::'a\<Rightarrow>'a \<times> 'a. {(\<Sum>i\<in>Basis. (fst (f i) \<bullet> i) *\<^sub>R i) .. (\<Sum>i\<in>Basis. (snd (f i) \<bullet> i) *\<^sub>R i)}"
10.536 +  def p \<equiv> "?B ` (Basis \<rightarrow>\<^isub>E {(a, c), (c, d), (d, b)})"
10.537 +
10.538 +  show "{c .. d} \<in> p"
10.539 +    unfolding p_def
10.540 +    by (auto simp add: interval_eq_empty eucl_le[where 'a='a]
10.541 +             intro!: image_eqI[where x="\<lambda>(i::'a)\<in>Basis. (c, d)"])
10.542 +
10.543 +  {  fix i :: 'a assume "i \<in> Basis"
10.544 +    with incl nonempty have "a \<bullet> i \<le> c \<bullet> i" "c \<bullet> i \<le> d \<bullet> i" "d \<bullet> i \<le> b \<bullet> i"
10.545 +      unfolding interval_eq_empty subset_interval by (auto simp: not_le) }
10.546 +  note ord = this
10.547 +
10.548 +  show "p division_of {a..b}"
10.549 +  proof (rule division_ofI)
10.550 +    show "finite p"
10.551 +      unfolding p_def by (auto intro!: finite_PiE)
10.552 +    { fix k assume "k \<in> p"
10.553 +      then obtain f where f: "f \<in> Basis \<rightarrow>\<^isub>E {(a, c), (c, d), (d, b)}" and k: "k = ?B f"
10.554 +        by (auto simp: p_def)
10.555 +      then show "\<exists>a b. k = {a..b}" by auto
10.556 +      have "k \<subseteq> {a..b} \<and> k \<noteq> {}"
10.557 +      proof (simp add: k interval_eq_empty subset_interval not_less, safe)
10.558 +        fix i :: 'a assume i: "i \<in> Basis"
10.559 +        moreover with f have "f i = (a, c) \<or> f i = (c, d) \<or> f i = (d, b)"
10.560 +          by (auto simp: PiE_iff)
10.561 +        moreover note ord[of i]
10.562 +        ultimately show "a \<bullet> i \<le> fst (f i) \<bullet> i" "snd (f i) \<bullet> i \<le> b \<bullet> i" "fst (f i) \<bullet> i \<le> snd (f i) \<bullet> i"
10.563 +          by (auto simp: subset_iff eucl_le[where 'a='a])
10.564 +      qed
10.565 +      then show "k \<noteq> {}" "k \<subseteq> {a .. b}" by auto
10.566 +      {
10.567 +      fix l assume "l \<in> p"
10.568 +      then obtain g where g: "g \<in> Basis \<rightarrow>\<^isub>E {(a, c), (c, d), (d, b)}" and l: "l = ?B g"
10.569 +        by (auto simp: p_def)
10.570 +      assume "l \<noteq> k"
10.571 +      have "\<exists>i\<in>Basis. f i \<noteq> g i"
10.572 +      proof (rule ccontr)
10.573 +        assume "\<not> (\<exists>i\<in>Basis. f i \<noteq> g i)"
10.574 +        with f g have "f = g"
10.575 +          by (auto simp: PiE_iff extensional_def intro!: ext)
10.576 +        with `l \<noteq> k` show False
10.577 +          by (simp add: l k)
10.578 +      qed
10.579 +      then guess i ..
10.580 +      moreover then have "f i = (a, c) \<or> f i = (c, d) \<or> f i = (d, b)"
10.581 +          "g i = (a, c) \<or> g i = (c, d) \<or> g i = (d, b)"
10.582 +        using f g by (auto simp: PiE_iff)
10.583 +      moreover note ord[of i]
10.584 +      ultimately show "interior l \<inter> interior k = {}"
10.585 +        by (auto simp add: l k interior_closed_interval disjoint_interval intro!: bexI[of _ i]) }
10.586 +      note `k \<subseteq> { a.. b}` }
10.587 +    moreover
10.588 +    { fix x assume x: "x \<in> {a .. b}"
10.589 +      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)}"
10.590 +      proof
10.591 +        fix i :: 'a assume "i \<in> Basis"
10.592 +        with x ord[of i]
10.593 +        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>
10.594 +            (d \<bullet> i \<le> x \<bullet> i \<and> x \<bullet> i \<le> b \<bullet> i)"
10.595 +          by (auto simp: eucl_le[where 'a='a])
10.596 +        then show "\<exists>l. x \<bullet> i \<in> {fst l \<bullet> i .. snd l \<bullet> i} \<and> l \<in> {(a, c), (c, d), (d, b)}"
10.597 +          by auto
10.598 +      qed
10.599 +      then guess f unfolding bchoice_iff .. note f = this
10.600 +      moreover then have "restrict f Basis \<in> Basis \<rightarrow>\<^isub>E {(a, c), (c, d), (d, b)}"
10.601 +        by auto
10.602 +      moreover from f have "x \<in> ?B (restrict f Basis)"
10.603 +        by (auto simp: mem_interval eucl_le[where 'a='a])
10.604 +      ultimately have "\<exists>k\<in>p. x \<in> k"
10.605 +        unfolding p_def by blast }
10.606 +    ultimately show "\<Union>p = {a..b}"
10.607 +      by auto
10.608 +  qed
10.609 +qed
10.610
10.611  lemma partial_division_extend_interval: assumes "p division_of (\<Union>p)" "(\<Union>p) \<subseteq> {a..b}"
10.612    obtains q where "p \<subseteq> q" "q division_of {a..b::'a::ordered_euclidean_space}" proof(cases "p = {}")
10.613 @@ -1415,9 +1297,9 @@
10.614  lemma interval_bisection_step:  fixes type::"'a::ordered_euclidean_space"
10.615    assumes "P {}" "(\<forall>s t. P s \<and> P t \<and> interior(s) \<inter> interior(t) = {} \<longrightarrow> P(s \<union> t))" "~(P {a..b::'a})"
10.616    obtains c d where "~(P{c..d})"
10.617 -  "\<forall>i<DIM('a). a\$\$i \<le> c\$\$i \<and> c\$\$i \<le> d\$\$i \<and> d\$\$i \<le> b\$\$i \<and> 2 * (d\$\$i - c\$\$i) \<le> b\$\$i - a\$\$i"
10.618 +  "\<forall>i\<in>Basis. a\<bullet>i \<le> c\<bullet>i \<and> c\<bullet>i \<le> d\<bullet>i \<and> d\<bullet>i \<le> b\<bullet>i \<and> 2 * (d\<bullet>i - c\<bullet>i) \<le> b\<bullet>i - a\<bullet>i"
10.619  proof- have "{a..b} \<noteq> {}" using assms(1,3) by auto
10.620 -  note ab=this[unfolded interval_eq_empty not_ex not_less]
10.621 +  then have ab: "\<And>i. i\<in>Basis \<Longrightarrow> a \<bullet> i \<le> b \<bullet> i" by (auto simp: interval_eq_empty not_le)
10.622    { fix f have "finite f \<Longrightarrow>
10.623          (\<forall>s\<in>f. P s) \<Longrightarrow>
10.624          (\<forall>s\<in>f. \<exists>a b. s = {a..b}) \<Longrightarrow>
10.625 @@ -1428,60 +1310,72 @@
10.626          apply rule defer apply rule defer apply(rule inter_interior_unions_intervals)
10.627          using insert by auto
10.628      qed } note * = this
10.629 -  let ?A = "{{c..d} | c d::'a. \<forall>i<DIM('a). (c\$\$i = a\$\$i) \<and> (d\$\$i = (a\$\$i + b\$\$i) / 2) \<or> (c\$\$i = (a\$\$i + b\$\$i) / 2) \<and> (d\$\$i = b\$\$i)}"
10.630 -  let ?PP = "\<lambda>c d. \<forall>i<DIM('a). a\$\$i \<le> c\$\$i \<and> c\$\$i \<le> d\$\$i \<and> d\$\$i \<le> b\$\$i \<and> 2 * (d\$\$i - c\$\$i) \<le> b\$\$i - a\$\$i"
10.631 +  let ?A = "{{c..d} | c d::'a. \<forall>i\<in>Basis. (c\<bullet>i = a\<bullet>i) \<and> (d\<bullet>i = (a\<bullet>i + b\<bullet>i) / 2) \<or> (c\<bullet>i = (a\<bullet>i + b\<bullet>i) / 2) \<and> (d\<bullet>i = b\<bullet>i)}"
10.632 +  let ?PP = "\<lambda>c d. \<forall>i\<in>Basis. a\<bullet>i \<le> c\<bullet>i \<and> c\<bullet>i \<le> d\<bullet>i \<and> d\<bullet>i \<le> b\<bullet>i \<and> 2 * (d\<bullet>i - c\<bullet>i) \<le> b\<bullet>i - a\<bullet>i"
10.633    { presume "\<forall>c d. ?PP c d \<longrightarrow> P {c..d} \<Longrightarrow> False"
10.634      thus thesis unfolding atomize_not not_all apply-apply(erule exE)+ apply(rule_tac c=x and d=xa in that) by auto }
10.635    assume as:"\<forall>c d. ?PP c d \<longrightarrow> P {c..d}"
10.636    have "P (\<Union> ?A)" proof(rule *, rule_tac[2-] ballI, rule_tac[4] ballI, rule_tac[4] impI)
10.637 -    let ?B = "(\<lambda>s.{(\<chi>\<chi> i. if i \<in> s then a\$\$i else (a\$\$i + b\$\$i) / 2)::'a ..
10.638 -      (\<chi>\<chi> i. if i \<in> s then (a\$\$i + b\$\$i) / 2 else b\$\$i)}) ` {s. s \<subseteq> {..<DIM('a)}}"
10.639 +    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 ..
10.640 +      (\<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}"
10.641      have "?A \<subseteq> ?B" proof case goal1
10.642        then guess c unfolding mem_Collect_eq .. then guess d apply- by(erule exE,(erule conjE)+) note c_d=this[rule_format]
10.643        have *:"\<And>a b c d. a = c \<Longrightarrow> b = d \<Longrightarrow> {a..b} = {c..d}" by auto
10.644 -      show "x\<in>?B" unfolding image_iff apply(rule_tac x="{i. i<DIM('a) \<and> c\$\$i = a\$\$i}" in bexI)
10.645 -        unfolding c_d apply(rule * ) unfolding euclidean_eq[where 'a='a] apply safe unfolding euclidean_lambda_beta' mem_Collect_eq
10.646 -      proof- fix i assume "i<DIM('a)" thus " c \$\$ i = (if i < DIM('a) \<and> c \$\$ i = a \$\$ i then a \$\$ i else (a \$\$ i + b \$\$ i) / 2)"
10.647 -          "d \$\$ i = (if i < DIM('a) \<and> c \$\$ i = a \$\$ i then (a \$\$ i + b \$\$ i) / 2 else b \$\$ i)"
10.648 -          using c_d(2)[of i] ab[THEN spec[where x=i]] by(auto simp add:field_simps)
10.649 +      show "x\<in>?B" unfolding image_iff
10.650 +        apply(rule_tac x="{i. i\<in>Basis \<and> c\<bullet>i = a\<bullet>i}" in bexI)
10.651 +        unfolding c_d
10.652 +        apply(rule *)
10.653 +        apply (simp_all only: euclidean_eq_iff[where 'a='a] inner_setsum_left_Basis mem_Collect_eq simp_thms
10.654 +                        cong: ball_cong)
10.655 +        apply safe
10.656 +      proof-
10.657 +        fix i :: 'a assume i: "i\<in>Basis"
10.658 +        thus " c \<bullet> i = (if c \<bullet> i = a \<bullet> i then a \<bullet> i else (a \<bullet> i + b \<bullet> i) / 2)"
10.659 +          "d \<bullet> i = (if c \<bullet> i = a \<bullet> i then (a \<bullet> i + b \<bullet> i) / 2 else b \<bullet> i)"
10.660 +          using c_d(2)[of i] ab[OF i] by(auto simp add:field_simps)
10.661        qed qed
10.662      thus "finite ?A" apply(rule finite_subset) by auto
10.663      fix s assume "s\<in>?A" then guess c unfolding mem_Collect_eq .. then guess d apply- by(erule exE,(erule conjE)+)
10.664      note c_d=this[rule_format]
10.665      show "P s" unfolding c_d apply(rule as[rule_format]) proof- case goal1 thus ?case
10.666 -        using c_d(2)[of i] using ab[THEN spec[where x=i]] by auto qed
10.667 +        using c_d(2)[of i] using ab[OF `i \<in> Basis`] by auto qed
10.668      show "\<exists>a b. s = {a..b}" unfolding c_d by auto
10.669      fix t assume "t\<in>?A" then guess e unfolding mem_Collect_eq .. then guess f apply- by(erule exE,(erule conjE)+)
10.670      note e_f=this[rule_format]
10.671      assume "s \<noteq> t" hence "\<not> (c = e \<and> d = f)" unfolding c_d e_f by auto
10.672 -    then obtain i where "c\$\$i \<noteq> e\$\$i \<or> d\$\$i \<noteq> f\$\$i" and i':"i<DIM('a)" unfolding de_Morgan_conj euclidean_eq[where 'a='a] by auto
10.673 -    hence i:"c\$\$i \<noteq> e\$\$i" "d\$\$i \<noteq> f\$\$i" apply- apply(erule_tac[!] disjE)
10.674 -    proof- assume "c\$\$i \<noteq> e\$\$i" thus "d\$\$i \<noteq> f\$\$i" using c_d(2)[of i] e_f(2)[of i] by fastforce
10.675 -    next   assume "d\$\$i \<noteq> f\$\$i" thus "c\$\$i \<noteq> e\$\$i" using c_d(2)[of i] e_f(2)[of i] by fastforce
10.676 +    then obtain i where "c\<bullet>i \<noteq> e\<bullet>i \<or> d\<bullet>i \<noteq> f\<bullet>i" and i':"i\<in>Basis"
10.677 +      unfolding euclidean_eq_iff[where 'a='a] by auto
10.678 +    hence i:"c\<bullet>i \<noteq> e\<bullet>i" "d\<bullet>i \<noteq> f\<bullet>i" apply- apply(erule_tac[!] disjE)
10.679 +    proof- assume "c\<bullet>i \<noteq> e\<bullet>i" thus "d\<bullet>i \<noteq> f\<bullet>i" using c_d(2)[OF i'] e_f(2)[OF i'] by fastforce
10.680 +    next   assume "d\<bullet>i \<noteq> f\<bullet>i" thus "c\<bullet>i \<noteq> e\<bullet>i" using c_d(2)[OF i'] e_f(2)[OF i'] by fastforce
10.681      qed have *:"\<And>s t. (\<And>a. a\<in>s \<Longrightarrow> a\<in>t \<Longrightarrow> False) \<Longrightarrow> s \<inter> t = {}" by auto
10.682      show "interior s \<inter> interior t = {}" unfolding e_f c_d interior_closed_interval proof(rule *)
10.683        fix x assume "x\<in>{c<..<d}" "x\<in>{e<..<f}"
10.684 -      hence x:"c\$\$i < d\$\$i" "e\$\$i < f\$\$i" "c\$\$i < f\$\$i" "e\$\$i < d\$\$i" unfolding mem_interval using i'
10.685 -        apply-apply(erule_tac[!] x=i in allE)+ by auto
10.686 +      hence x:"c\<bullet>i < d\<bullet>i" "e\<bullet>i < f\<bullet>i" "c\<bullet>i < f\<bullet>i" "e\<bullet>i < d\<bullet>i" unfolding mem_interval using i'
10.687 +        apply-apply(erule_tac[!] x=i in ballE)+ by auto
10.688        show False using c_d(2)[OF i'] apply- apply(erule_tac disjE)
10.689 -      proof(erule_tac[!] conjE) assume as:"c \$\$ i = a \$\$ i" "d \$\$ i = (a \$\$ i + b \$\$ i) / 2"
10.690 -        show False using e_f(2)[of i] and i x unfolding as by(fastforce simp add:field_simps)
10.691 -      next assume as:"c \$\$ i = (a \$\$ i + b \$\$ i) / 2" "d \$\$ i = b \$\$ i"
10.692 -        show False using e_f(2)[of i] and i x unfolding as by(fastforce simp add:field_simps)
10.693 +      proof(erule_tac[!] conjE) assume as:"c \<bullet> i = a \<bullet> i" "d \<bullet> i = (a \<bullet> i + b \<bullet> i) / 2"
10.694 +        show False using e_f(2)[OF i'] and i x unfolding as by(fastforce simp add:field_simps)
10.695 +      next assume as:"c \<bullet> i = (a \<bullet> i + b \<bullet> i) / 2" "d \<bullet> i = b \<bullet> i"
10.696 +        show False using e_f(2)[OF i'] and i x unfolding as by(fastforce simp add:field_simps)
10.697        qed qed qed
10.698    also have "\<Union> ?A = {a..b}" proof(rule set_eqI,rule)
10.699      fix x assume "x\<in>\<Union>?A" then guess Y unfolding Union_iff ..
10.700      from this(1) guess c unfolding mem_Collect_eq .. then guess d ..
10.701      note c_d = this[THEN conjunct2,rule_format] `x\<in>Y`[unfolded this[THEN conjunct1]]
10.702      show "x\<in>{a..b}" unfolding mem_interval proof safe
10.703 -      fix i assume "i<DIM('a)" thus "a \$\$ i \<le> x \$\$ i" "x \$\$ i \<le> b \$\$ i"
10.704 -        using c_d(1)[of i] c_d(2)[unfolded mem_interval,THEN spec[where x=i]] by auto qed
10.705 +      fix i :: 'a assume i: "i\<in>Basis" thus "a \<bullet> i \<le> x \<bullet> i" "x \<bullet> i \<le> b \<bullet> i"
10.706 +        using c_d(1)[OF i] c_d(2)[unfolded mem_interval,THEN bspec, OF i] by auto qed
10.707    next fix x assume x:"x\<in>{a..b}"
10.708 -    have "\<forall>i<DIM('a). \<exists>c d. (c = a\$\$i \<and> d = (a\$\$i + b\$\$i) / 2 \<or> c = (a\$\$i + b\$\$i) / 2 \<and> d = b\$\$i) \<and> c\<le>x\$\$i \<and> x\$\$i \<le> d"
10.709 -      (is "\<forall>i<DIM('a). \<exists>c d. ?P i c d") unfolding mem_interval proof(rule,rule) fix i
10.710 -      have "?P i (a\$\$i) ((a \$\$ i + b \$\$ i) / 2) \<or> ?P i ((a \$\$ i + b \$\$ i) / 2) (b\$\$i)"
10.711 -        using x[unfolded mem_interval,THEN spec[where x=i]] by auto thus "\<exists>c d. ?P i c d" by blast
10.712 -    qed thus "x\<in>\<Union>?A" unfolding Union_iff unfolding lambda_skolem' unfolding Bex_def mem_Collect_eq
10.713 +    have "\<forall>i\<in>Basis. \<exists>c d. (c = a\<bullet>i \<and> d = (a\<bullet>i + b\<bullet>i) / 2 \<or> c = (a\<bullet>i + b\<bullet>i) / 2 \<and> d = b\<bullet>i) \<and> c\<le>x\<bullet>i \<and> x\<bullet>i \<le> d"
10.714 +      (is "\<forall>i\<in>Basis. \<exists>c d. ?P i c d") unfolding mem_interval
10.715 +    proof
10.716 +      fix i :: 'a assume i: "i \<in> Basis"
10.717 +      have "?P i (a\<bullet>i) ((a \<bullet> i + b \<bullet> i) / 2) \<or> ?P i ((a \<bullet> i + b \<bullet> i) / 2) (b\<bullet>i)"
10.718 +        using x[unfolded mem_interval,THEN bspec, OF i] by auto thus "\<exists>c d. ?P i c d" by blast
10.719 +    qed
10.720 +    thus "x\<in>\<Union>?A"
10.721 +      unfolding Union_iff Bex_def mem_Collect_eq choice_Basis_iff
10.722        apply-apply(erule exE)+ apply(rule_tac x="{xa..xaa}" in exI) unfolding mem_interval by auto
10.723    qed finally show False using assms by auto qed
10.724
10.725 @@ -1490,8 +1384,8 @@
10.726    obtains x where "x \<in> {a..b}" "\<forall>e>0. \<exists>c d. x \<in> {c..d} \<and> {c..d} \<subseteq> ball x e \<and> {c..d} \<subseteq> {a..b} \<and> ~P({c..d})"
10.727  proof-
10.728    have "\<forall>x. \<exists>y. \<not> P {fst x..snd x} \<longrightarrow> (\<not> P {fst y..snd y} \<and>
10.729 -    (\<forall>i<DIM('a). fst x\$\$i \<le> fst y\$\$i \<and> fst y\$\$i \<le> snd y\$\$i \<and> snd y\$\$i \<le> snd x\$\$i \<and>
10.730 -                           2 * (snd y\$\$i - fst y\$\$i) \<le> snd x\$\$i - fst x\$\$i))" proof case goal1 thus ?case proof-
10.731 +    (\<forall>i\<in>Basis. fst x\<bullet>i \<le> fst y\<bullet>i \<and> fst y\<bullet>i \<le> snd y\<bullet>i \<and> snd y\<bullet>i \<le> snd x\<bullet>i \<and>
10.732 +                           2 * (snd y\<bullet>i - fst y\<bullet>i) \<le> snd x\<bullet>i - fst x\<bullet>i))" proof case goal1 thus ?case proof-
10.733        presume "\<not> P {fst x..snd x} \<Longrightarrow> ?thesis"
10.734        thus ?thesis apply(cases "P {fst x..snd x}") by auto
10.735      next assume as:"\<not> P {fst x..snd x}" from interval_bisection_step[of P, OF assms(1-2) as] guess c d .
10.736 @@ -1499,8 +1393,8 @@
10.737      qed qed then guess f apply-apply(drule choice) by(erule exE) note f=this
10.738    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
10.739    have "A 0 = a" "B 0 = b" "\<And>n. \<not> P {A(Suc n)..B(Suc n)} \<and>
10.740 -    (\<forall>i<DIM('a). A(n)\$\$i \<le> A(Suc n)\$\$i \<and> A(Suc n)\$\$i \<le> B(Suc n)\$\$i \<and> B(Suc n)\$\$i \<le> B(n)\$\$i \<and>
10.741 -    2 * (B(Suc n)\$\$i - A(Suc n)\$\$i) \<le> B(n)\$\$i - A(n)\$\$i)" (is "\<And>n. ?P n")
10.742 +    (\<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>
10.743 +    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")
10.744    proof- show "A 0 = a" "B 0 = b" unfolding ab_def by auto
10.745      case goal3 note S = ab_def funpow.simps o_def id_apply show ?case
10.746      proof(induct n) case 0 thus ?case unfolding S apply(rule f[rule_format]) using assms(3) by auto
10.747 @@ -1508,29 +1402,28 @@
10.748      qed qed note AB = this(1-2) conjunctD2[OF this(3),rule_format]
10.749
10.750    have interv:"\<And>e. 0 < e \<Longrightarrow> \<exists>n. \<forall>x\<in>{A n..B n}. \<forall>y\<in>{A n..B n}. dist x y < e"
10.751 -  proof- case goal1 guess n using real_arch_pow2[of "(setsum (\<lambda>i. b\$\$i - a\$\$i) {..<DIM('a)}) / e"] .. note n=this
10.752 +  proof- case goal1 guess n using real_arch_pow2[of "(setsum (\<lambda>i. b\<bullet>i - a\<bullet>i) Basis) / e"] .. note n=this
10.753      show ?case apply(rule_tac x=n in exI) proof(rule,rule)
10.754        fix x y assume xy:"x\<in>{A n..B n}" "y\<in>{A n..B n}"
10.755 -      have "dist x y \<le> setsum (\<lambda>i. abs((x - y)\$\$i)) {..<DIM('a)}" unfolding dist_norm by(rule norm_le_l1)
10.756 -      also have "\<dots> \<le> setsum (\<lambda>i. B n\$\$i - A n\$\$i) {..<DIM('a)}"
10.757 -      proof(rule setsum_mono) fix i show "\<bar>(x - y) \$\$ i\<bar> \<le> B n \$\$ i - A n \$\$ i"
10.758 -          using xy[unfolded mem_interval,THEN spec[where x=i]] by auto qed
10.759 -      also have "\<dots> \<le> setsum (\<lambda>i. b\$\$i - a\$\$i) {..<DIM('a)} / 2^n" unfolding setsum_divide_distrib
10.760 +      have "dist x y \<le> setsum (\<lambda>i. abs((x - y)\<bullet>i)) Basis" unfolding dist_norm by(rule norm_le_l1)
10.761 +      also have "\<dots> \<le> setsum (\<lambda>i. B n\<bullet>i - A n\<bullet>i) Basis"
10.762 +      proof(rule setsum_mono)
10.763 +        fix i :: 'a assume i: "i \<in> Basis" show "\<bar>(x - y) \<bullet> i\<bar> \<le> B n \<bullet> i - A n \<bullet> i"
10.764 +          using xy[unfolded mem_interval,THEN bspec, OF i] by (auto simp: inner_diff_left) qed
10.765 +      also have "\<dots> \<le> setsum (\<lambda>i. b\<bullet>i - a\<bullet>i) Basis / 2^n" unfolding setsum_divide_distrib
10.766        proof(rule setsum_mono) case goal1 thus ?case
10.767          proof(induct n) case 0 thus ?case unfolding AB by auto
10.768 -        next case (Suc n) have "B (Suc n) \$\$ i - A (Suc n) \$\$ i \<le> (B n \$\$ i - A n \$\$ i) / 2"
10.769 +        next case (Suc n) have "B (Suc n) \<bullet> i - A (Suc n) \<bullet> i \<le> (B n \<bullet> i - A n \<bullet> i) / 2"
10.770              using AB(4)[of i n] using goal1 by auto
10.771 -          also have "\<dots> \<le> (b \$\$ i - a \$\$ i) / 2 ^ Suc n" using Suc by(auto simp add:field_simps) finally show ?case .
10.772 +          also have "\<dots> \<le> (b \<bullet> i - a \<bullet> i) / 2 ^ Suc n" using Suc by(auto simp add:field_simps) finally show ?case .
10.773          qed qed
10.774        also have "\<dots> < e" using n using goal1 by(auto simp add:field_simps) finally show "dist x y < e" .
10.775      qed qed
10.776 -  { fix n m ::nat assume "m \<le> n" then guess d unfolding le_Suc_ex_iff .. note d=this
10.777 -    have "{A n..B n} \<subseteq> {A m..B m}" unfolding d
10.778 -    proof(induct d) case 0 thus ?case by auto
10.779 -    next case (Suc d) show ?case apply(rule subset_trans[OF _ Suc])
10.780 -        apply(rule) unfolding mem_interval apply(rule,erule_tac x=i in allE)
10.781 -      proof- case goal1 thus ?case using AB(4)[of i "m + d"] by(auto simp add:field_simps)
10.782 -      qed qed } note ABsubset = this
10.783 +  { fix n m :: nat assume "m \<le> n" then have "{A n..B n} \<subseteq> {A m..B m}"
10.784 +    proof(induct rule: inc_induct)
10.785 +      case (step i) show ?case
10.786 +        using AB(4) by (intro order_trans[OF step(2)] subset_interval_imp) auto
10.787 +    qed simp } note ABsubset = this
10.788    have "\<exists>a. \<forall>n. a\<in>{A n..B n}" apply(rule decreasing_closed_nest[rule_format,OF closed_interval _ ABsubset interv])
10.789    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
10.790    then guess x0 .. note x0=this[rule_format]
10.791 @@ -1784,7 +1677,7 @@
10.792    apply(rule integrable_linear) by assumption+
10.793
10.794  lemma integral_component_eq[simp]: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
10.795 -  assumes "f integrable_on s" shows "integral s (\<lambda>x. f x \$\$ k) = integral s f \$\$ k"
10.796 +  assumes "f integrable_on s" shows "integral s (\<lambda>x. f x \<bullet> k) = integral s f \<bullet> k"
10.797    unfolding integral_linear[OF assms(1) bounded_linear_component,unfolded o_def] ..
10.798
10.799  lemma has_integral_setsum:
10.800 @@ -1852,8 +1745,9 @@
10.801    apply(rule integral_unique) using has_integral_empty .
10.802
10.803  lemma has_integral_refl[intro]: shows "(f has_integral 0) {a..a}" "(f has_integral 0) {a::'a::ordered_euclidean_space}"
10.804 -proof- have *:"{a} = {a..a}" apply(rule set_eqI) unfolding mem_interval singleton_iff euclidean_eq[where 'a='a]
10.805 -    apply safe prefer 3 apply(erule_tac x=i in allE) by(auto simp add: field_simps)
10.806 +proof-
10.807 +  have *:"{a} = {a..a}" apply(rule set_eqI) unfolding mem_interval singleton_iff euclidean_eq_iff[where 'a='a]
10.808 +    apply safe prefer 3 apply(erule_tac x=b in ballE) by(auto simp add: field_simps)
10.809    show "(f has_integral 0) {a..a}" "(f has_integral 0) {a}" unfolding *
10.810      apply(rule_tac[!] has_integral_null) unfolding content_eq_0_interior
10.811      unfolding interior_closed_interval using interval_sing by auto qed
10.812 @@ -1913,42 +1807,48 @@
10.813
10.814  subsection {* Additivity of integral on abutting intervals. *}
10.815
10.816 -lemma interval_split: fixes a::"'a::ordered_euclidean_space" assumes "k<DIM('a)" shows
10.817 -  "{a..b} \<inter> {x. x\$\$k \<le> c} = {a .. (\<chi>\<chi> i. if i = k then min (b\$\$k) c else b\$\$i)}"
10.818 -  "{a..b} \<inter> {x. x\$\$k \<ge> c} = {(\<chi>\<chi> i. if i = k then max (a\$\$k) c else a\$\$i) .. b}"
10.819 -  apply(rule_tac[!] set_eqI) unfolding Int_iff mem_interval mem_Collect_eq using assms by auto
10.820 -
10.821 -lemma content_split: fixes a::"'a::ordered_euclidean_space" assumes "k<DIM('a)" shows
10.822 -  "content {a..b} = content({a..b} \<inter> {x. x\$\$k \<le> c}) + content({a..b} \<inter> {x. x\$\$k >= c})"
10.823 -proof- note simps = interval_split[OF assms] content_closed_interval_cases eucl_le[where 'a='a]
10.824 -  { presume "a\<le>b \<Longrightarrow> ?thesis" thus ?thesis apply(cases "a\<le>b") unfolding simps using assms by auto }
10.825 -  have *:"{..<DIM('a)} = insert k ({..<DIM('a)} - {k})" "\<And>x. finite ({..<DIM('a)}-{x})" "\<And>x. x\<notin>{..<DIM('a)}-{x}"
10.826 +lemma interval_split:
10.827 +  fixes a::"'a::ordered_euclidean_space" assumes "k \<in> Basis"
10.828 +  shows
10.829 +    "{a..b} \<inter> {x. x\<bullet>k \<le> c} = {a .. (\<Sum>i\<in>Basis. (if i = k then min (b\<bullet>k) c else b\<bullet>i) *\<^sub>R i)}"
10.830 +    "{a..b} \<inter> {x. x\<bullet>k \<ge> c} = {(\<Sum>i\<in>Basis. (if i = k then max (a\<bullet>k) c else a\<bullet>i) *\<^sub>R i) .. b}"
10.831 +  apply(rule_tac[!] set_eqI) unfolding Int_iff mem_interval mem_Collect_eq using assms
10.832 +  by auto
10.833 +
10.834 +lemma content_split: fixes a::"'a::ordered_euclidean_space" assumes "k\<in>Basis" shows
10.835 +  "content {a..b} = content({a..b} \<inter> {x. x\<bullet>k \<le> c}) + content({a..b} \<inter> {x. x\<bullet>k >= c})"
10.836 +proof cases
10.837 +  note simps = interval_split[OF assms] content_closed_interval_cases eucl_le[where 'a='a]
10.838 +  have *:"Basis = insert k (Basis - {k})" "\<And>x. finite (Basis-{x})" "\<And>x. x\<notin>Basis-{x}"
10.839      using assms by auto
10.840 -  have *:"\<And>X Y Z. (\<Prod>i\<in>{..<DIM('a)}. Z i (if i = k then X else Y i)) = Z k X * (\<Prod>i\<in>{..<DIM('a)}-{k}. Z i (Y i))"
10.841 -    "(\<Prod>i\<in>{..<DIM('a)}. b\$\$i - a\$\$i) = (\<Prod>i\<in>{..<DIM('a)}-{k}. b\$\$i - a\$\$i) * (b\$\$k - a\$\$k)"
10.842 +  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))"
10.843 +    "(\<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)"
10.844      apply(subst *(1)) defer apply(subst *(1)) unfolding setprod_insert[OF *(2-)] by auto
10.845 -  assume as:"a\<le>b" moreover have "\<And>x. min (b \$\$ k) c = max (a \$\$ k) c
10.846 -    \<Longrightarrow> x* (b\$\$k - a\$\$k) = x*(max (a \$\$ k) c - a \$\$ k) + x*(b \$\$ k - max (a \$\$ k) c)"
10.847 +  assume as:"a\<le>b" moreover have "\<And>x. min (b \<bullet> k) c = max (a \<bullet> k) c
10.848 +    \<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)"
10.850 -  moreover have **:"(\<Prod>i<DIM('a). ((\<chi>\<chi> i. if i = k then min (b \$\$ k) c else b \$\$ i)::'a) \$\$ i - a \$\$ i) =
10.851 -    (\<Prod>i<DIM('a). (if i = k then min (b \$\$ k) c else b \$\$ i) - a \$\$ i)"
10.852 -    "(\<Prod>i<DIM('a). b \$\$ i - ((\<chi>\<chi> i. if i = k then max (a \$\$ k) c else a \$\$ i)::'a) \$\$ i) =
10.853 -    (\<Prod>i<DIM('a). b \$\$ i - (if i = k then max (a \$\$ k) c else a \$\$ i))"
10.854 -    apply(rule_tac[!] setprod.cong) by auto
10.855 -  have "\<not> a \$\$ k \<le> c \<Longrightarrow> \<not> c \<le> b \$\$ k \<Longrightarrow> False"
10.856 +  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)) =
10.857 +      (\<Prod>i\<in>Basis. (if i = k then min (b \<bullet> k) c else b \<bullet> i) - a \<bullet> i)"
10.858 +    "(\<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)) =
10.859 +      (\<Prod>i\<in>Basis. b \<bullet> i - (if i = k then max (a \<bullet> k) c else a \<bullet> i))"
10.860 +    by (auto intro!: setprod_cong)
10.861 +  have "\<not> a \<bullet> k \<le> c \<Longrightarrow> \<not> c \<le> b \<bullet> k \<Longrightarrow> False"
10.862      unfolding not_le using as[unfolded eucl_le[where 'a='a],rule_format,of k] assms by auto
10.863    ultimately show ?thesis using assms unfolding simps **
10.864 -    unfolding *(1)[of "\<lambda>i x. b\$\$i - x"] *(1)[of "\<lambda>i x. x - a\$\$i"] unfolding  *(2)
10.865 -    apply(subst(2) euclidean_lambda_beta''[where 'a='a])
10.866 -    apply(subst(3) euclidean_lambda_beta''[where 'a='a]) by auto
10.867 +    unfolding *(1)[of "\<lambda>i x. b\<bullet>i - x"] *(1)[of "\<lambda>i x. x - a\<bullet>i"] unfolding *(2)
10.868 +    by auto
10.869 +next
10.870 +  assume "\<not> a \<le> b" then have "{a .. b} = {}"
10.871 +    unfolding interval_eq_empty by (auto simp: eucl_le[where 'a='a] not_le)
10.872 +  then show ?thesis by auto
10.873  qed
10.874
10.875  lemma division_split_left_inj: fixes type::"'a::ordered_euclidean_space"
10.876    assumes "d division_of i" "k1 \<in> d" "k2 \<in> d"  "k1 \<noteq> k2"
10.877 -  "k1 \<inter> {x::'a. x\$\$k \<le> c} = k2 \<inter> {x. x\$\$k \<le> c}"and k:"k<DIM('a)"
10.878 -  shows "content(k1 \<inter> {x. x\$\$k \<le> c}) = 0"
10.879 +  "k1 \<inter> {x::'a. x\<bullet>k \<le> c} = k2 \<inter> {x. x\<bullet>k \<le> c}"and k:"k\<in>Basis"
10.880 +  shows "content(k1 \<inter> {x. x\<bullet>k \<le> c}) = 0"
10.881  proof- note d=division_ofD[OF assms(1)]
10.882 -  have *:"\<And>a b::'a. \<And> c. (content({a..b} \<inter> {x. x\$\$k \<le> c}) = 0 \<longleftrightarrow> interior({a..b} \<inter> {x. x\$\$k \<le> c}) = {})"
10.883 +  have *:"\<And>a b::'a. \<And> c. (content({a..b} \<inter> {x. x\<bullet>k \<le> c}) = 0 \<longleftrightarrow> interior({a..b} \<inter> {x. x\<bullet>k \<le> c}) = {})"
10.884      unfolding  interval_split[OF k] content_eq_0_interior by auto
10.885    guess u1 v1 using d(4)[OF assms(2)] apply-by(erule exE)+ note uv1=this
10.886    guess u2 v2 using d(4)[OF assms(3)] apply-by(erule exE)+ note uv2=this
10.887 @@ -1958,10 +1858,10 @@
10.888
10.889  lemma division_split_right_inj: fixes type::"'a::ordered_euclidean_space"
10.890    assumes "d division_of i" "k1 \<in> d" "k2 \<in> d"  "k1 \<noteq> k2"
10.891 -  "k1 \<inter> {x::'a. x\$\$k \<ge> c} = k2 \<inter> {x. x\$\$k \<ge> c}" and k:"k<DIM('a)"
10.892 -  shows "content(k1 \<inter> {x. x\$\$k \<ge> c}) = 0"
10.893 +  "k1 \<inter> {x::'a. x\<bullet>k \<ge> c} = k2 \<inter> {x. x\<bullet>k \<ge> c}" and k:"k\<in>Basis"
10.894 +  shows "content(k1 \<inter> {x. x\<bullet>k \<ge> c}) = 0"
10.895  proof- note d=division_ofD[OF assms(1)]
10.896 -  have *:"\<And>a b::'a. \<And> c. (content({a..b} \<inter> {x. x\$\$k >= c}) = 0 \<longleftrightarrow> interior({a..b} \<inter> {x. x\$\$k >= c}) = {})"
10.897 +  have *:"\<And>a b::'a. \<And> c. (content({a..b} \<inter> {x. x\<bullet>k >= c}) = 0 \<longleftrightarrow> interior({a..b} \<inter> {x. x\<bullet>k >= c}) = {})"
10.898      unfolding interval_split[OF k] content_eq_0_interior by auto
10.899    guess u1 v1 using d(4)[OF assms(2)] apply-by(erule exE)+ note uv1=this
10.900    guess u2 v2 using d(4)[OF assms(3)] apply-by(erule exE)+ note uv2=this
10.901 @@ -1970,25 +1870,25 @@
10.902      defer apply(subst assms(5)[unfolded uv1 uv2]) unfolding uv1 uv2 by auto qed
10.903
10.904  lemma tagged_division_split_left_inj: fixes x1::"'a::ordered_euclidean_space"
10.905 -  assumes "d tagged_division_of i" "(x1,k1) \<in> d" "(x2,k2) \<in> d" "k1 \<noteq> k2"  "k1 \<inter> {x. x\$\$k \<le> c} = k2 \<inter> {x. x\$\$k \<le> c}"
10.906 -  and k:"k<DIM('a)"
10.907 -  shows "content(k1 \<inter> {x. x\$\$k \<le> c}) = 0"
10.908 +  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}"
10.909 +  and k:"k\<in>Basis"
10.910 +  shows "content(k1 \<inter> {x. x\<bullet>k \<le> c}) = 0"
10.911  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
10.912    show ?thesis apply(rule division_split_left_inj[OF division_of_tagged_division[OF assms(1)]])
10.913      apply(rule_tac[1-2] *) using assms(2-) by auto qed
10.914
10.915  lemma tagged_division_split_right_inj: fixes x1::"'a::ordered_euclidean_space"
10.916 -  assumes "d tagged_division_of i" "(x1,k1) \<in> d" "(x2,k2) \<in> d" "k1 \<noteq> k2"  "k1 \<inter> {x. x\$\$k \<ge> c} = k2 \<inter> {x. x\$\$k \<ge> c}"
10.917 -  and k:"k<DIM('a)"
10.918 -  shows "content(k1 \<inter> {x. x\$\$k \<ge> c}) = 0"
10.919 +  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}"
10.920 +  and k:"k\<in>Basis"
10.921 +  shows "content(k1 \<inter> {x. x\<bullet>k \<ge> c}) = 0"
10.922  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
10.923    show ?thesis apply(rule division_split_right_inj[OF division_of_tagged_division[OF assms(1)]])
10.924      apply(rule_tac[1-2] *) using assms(2-) by auto qed
10.925
10.926  lemma division_split: fixes a::"'a::ordered_euclidean_space"
10.927 -  assumes "p division_of {a..b}" and k:"k<DIM('a)"
10.928 -  shows "{l \<inter> {x. x\$\$k \<le> c} | l. l \<in> p \<and> ~(l \<inter> {x. x\$\$k \<le> c} = {})} division_of({a..b} \<inter> {x. x\$\$k \<le> c})" (is "?p1 division_of ?I1") and
10.929 -        "{l \<inter> {x. x\$\$k \<ge> c} | l. l \<in> p \<and> ~(l \<inter> {x. x\$\$k \<ge> c} = {})} division_of ({a..b} \<inter> {x. x\$\$k \<ge> c})" (is "?p2 division_of ?I2")
10.930 +  assumes "p division_of {a..b}" and k:"k\<in>Basis"
10.931 +  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
10.932 +        "{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")
10.933  proof(rule_tac[!] division_ofI) note p=division_ofD[OF assms(1)]
10.934    show "finite ?p1" "finite ?p2" using p(1) by auto show "\<Union>?p1 = ?I1" "\<Union>?p2 = ?I2" unfolding p(6)[THEN sym] by auto
10.935    { fix k assume "k\<in>?p1" then guess l unfolding mem_Collect_eq apply-by(erule exE,(erule conjE)+) note l=this
10.936 @@ -2006,34 +1906,34 @@
10.937  qed
10.938
10.939  lemma has_integral_split: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
10.940 -  assumes "(f has_integral i) ({a..b} \<inter> {x. x\$\$k \<le> c})"  "(f has_integral j) ({a..b} \<inter> {x. x\$\$k \<ge> c})" and k:"k<DIM('a)"
10.941 +  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"
10.942    shows "(f has_integral (i + j)) ({a..b})"
10.943  proof(unfold has_integral,rule,rule) case goal1 hence e:"e/2>0" by auto
10.944    guess d1 using has_integralD[OF assms(1)[unfolded interval_split[OF k]] e] . note d1=this[unfolded interval_split[THEN sym,OF k]]
10.945    guess d2 using has_integralD[OF assms(2)[unfolded interval_split[OF k]] e] . note d2=this[unfolded interval_split[THEN sym,OF k]]
10.946 -  let ?d = "\<lambda>x. if x\$\$k = c then (d1 x \<inter> d2 x) else ball x (abs(x\$\$k - c)) \<inter> d1 x \<inter> d2 x"
10.947 +  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"
10.948    show ?case apply(rule_tac x="?d" in exI,rule) defer apply(rule,rule,(erule conjE)+)
10.949    proof- show "gauge ?d" using d1(1) d2(1) unfolding gauge_def by auto
10.950      fix p assume "p tagged_division_of {a..b}" "?d fine p" note p = this tagged_division_ofD[OF this(1)]
10.951 -    have lem0:"\<And>x kk. (x,kk) \<in> p \<Longrightarrow> ~(kk \<inter> {x. x\$\$k \<le> c} = {}) \<Longrightarrow> x\$\$k \<le> c"
10.952 -         "\<And>x kk. (x,kk) \<in> p \<Longrightarrow> ~(kk \<inter> {x. x\$\$k \<ge> c} = {}) \<Longrightarrow> x\$\$k \<ge> c"
10.953 +    have lem0:"\<And>x kk. (x,kk) \<in> p \<Longrightarrow> ~(kk \<inter> {x. x\<bullet>k \<le> c} = {}) \<Longrightarrow> x\<bullet>k \<le> c"
10.954 +         "\<And>x kk. (x,kk) \<in> p \<Longrightarrow> ~(kk \<inter> {x. x\<bullet>k \<ge> c} = {}) \<Longrightarrow> x\<bullet>k \<ge> c"
10.955      proof- fix x kk assume as:"(x,kk)\<in>p"
10.956 -      show "~(kk \<inter> {x. x\$\$k \<le> c} = {}) \<Longrightarrow> x\$\$k \<le> c"
10.957 +      show "~(kk \<inter> {x. x\<bullet>k \<le> c} = {}) \<Longrightarrow> x\<bullet>k \<le> c"
10.958        proof(rule ccontr) case goal1
10.959 -        from this(2)[unfolded not_le] have "kk \<subseteq> ball x \<bar>x \$\$ k - c\<bar>"
10.960 +        from this(2)[unfolded not_le] have "kk \<subseteq> ball x \<bar>x \<bullet> k - c\<bar>"
10.961            using p(2)[unfolded fine_def,rule_format,OF as,unfolded split_conv] by auto
10.962 -        hence "\<exists>y. y \<in> ball x \<bar>x \$\$ k - c\<bar> \<inter> {x. x \$\$ k \<le> c}" using goal1(1) by blast
10.963 -        then guess y .. hence "\<bar>x \$\$ k - y \$\$ k\<bar> < \<bar>x \$\$ k - c\<bar>" "y\$\$k \<le> c" apply-apply(rule le_less_trans)
10.964 -          using component_le_norm[of "x - y" k] by(auto simp add:dist_norm)
10.965 +        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
10.966 +        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)
10.967 +          using Basis_le_norm[OF k, of "x - y"] by (auto simp add: dist_norm inner_diff_left)
10.968          thus False using goal1(2)[unfolded not_le] by(auto simp add:field_simps)
10.969        qed
10.970 -      show "~(kk \<inter> {x. x\$\$k \<ge> c} = {}) \<Longrightarrow> x\$\$k \<ge> c"
10.971 +      show "~(kk \<inter> {x. x\<bullet>k \<ge> c} = {}) \<Longrightarrow> x\<bullet>k \<ge> c"
10.972        proof(rule ccontr) case goal1
10.973 -        from this(2)[unfolded not_le] have "kk \<subseteq> ball x \<bar>x \$\$ k - c\<bar>"
10.974 +        from this(2)[unfolded not_le] have "kk \<subseteq> ball x \<bar>x \<bullet> k - c\<bar>"
10.975            using p(2)[unfolded fine_def,rule_format,OF as,unfolded split_conv] by auto
10.976 -        hence "\<exists>y. y \<in> ball x \<bar>x \$\$ k - c\<bar> \<inter> {x. x \$\$ k \<ge> c}" using goal1(1) by blast
10.977 -        then guess y .. hence "\<bar>x \$\$ k - y \$\$ k\<bar> < \<bar>x \$\$ k - c\<bar>" "y\$\$k \<ge> c" apply-apply(rule le_less_trans)
10.978 -          using component_le_norm[of "x - y" k] by(auto simp add:dist_norm)
10.979 +        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
10.980 +        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)
10.981 +          using Basis_le_norm[OF k, of "x - y"] by (auto simp add: dist_norm inner_diff_left)
10.982          thus False using goal1(2)[unfolded not_le] by(auto simp add:field_simps)
10.983        qed
10.984      qed
10.985 @@ -2053,15 +1953,15 @@
10.986      qed auto
10.987      have lem4:"\<And>g. (\<lambda>(x,l). content (g l) *\<^sub>R f x) = (\<lambda>(x,l). content l *\<^sub>R f x) o (\<lambda>(x,l). (x,g l))" apply(rule ext) by auto
10.988
10.989 -    let ?M1 = "{(x,kk \<inter> {x. x\$\$k \<le> c}) |x kk. (x,kk) \<in> p \<and> kk \<inter> {x. x\$\$k \<le> c} \<noteq> {}}"
10.990 +    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> {}}"
10.991      have "norm ((\<Sum>(x, k)\<in>?M1. content k *\<^sub>R f x) - i) < e/2" apply(rule d1(2),rule tagged_division_ofI)
10.992        apply(rule lem2 p(3))+ prefer 6 apply(rule fineI)
10.993 -    proof- show "\<Union>{k. \<exists>x. (x, k) \<in> ?M1} = {a..b} \<inter> {x. x\$\$k \<le> c}" unfolding p(8)[THEN sym] by auto
10.994 +    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
10.995        fix x l assume xl:"(x,l)\<in>?M1"
10.996        then guess x' l' unfolding mem_Collect_eq apply- unfolding Pair_eq apply((erule exE)+,(erule conjE)+) .  note xl'=this
10.997        have "l' \<subseteq> d1 x'" apply(rule order_trans[OF fineD[OF p(2) xl'(3)]]) by auto
10.998        thus "l \<subseteq> d1 x" unfolding xl' by auto
10.999 -      show "x\<in>l" "l \<subseteq> {a..b} \<inter> {x. x \$\$ k \<le> c}" unfolding xl' using p(4-6)[OF xl'(3)] using xl'(4)
10.1000 +      show "x\<in>l" "l \<subseteq> {a..b} \<inter> {x. x \<bullet> k \<le> c}" unfolding xl' using p(4-6)[OF xl'(3)] using xl'(4)
10.1001          using lem0(1)[OF xl'(3-4)] by auto
10.1002        show  "\<exists>a b. l = {a..b}" unfolding xl' using p(6)[OF xl'(3)] by(fastforce simp add: interval_split[OF k,where c=c])
10.1003        fix y r let ?goal = "interior l \<inter> interior r = {}" assume yr:"(y,r)\<in>?M1"
10.1004 @@ -2073,15 +1973,15 @@
10.1005          thus ?thesis using p(7)[OF xl'(3) yr'(3)] using as unfolding xl' yr' by auto
10.1006        qed qed moreover
10.1007
10.1008 -    let ?M2 = "{(x,kk \<inter> {x. x\$\$k \<ge> c}) |x kk. (x,kk) \<in> p \<and> kk \<inter> {x. x\$\$k \<ge> c} \<noteq> {}}"
10.1009 +    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> {}}"
10.1010      have "norm ((\<Sum>(x, k)\<in>?M2. content k *\<^sub>R f x) - j) < e/2" apply(rule d2(2),rule tagged_division_ofI)
10.1011        apply(rule lem2 p(3))+ prefer 6 apply(rule fineI)
10.1012 -    proof- show "\<Union>{k. \<exists>x. (x, k) \<in> ?M2} = {a..b} \<inter> {x. x\$\$k \<ge> c}" unfolding p(8)[THEN sym] by auto
10.1013 +    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
10.1014        fix x l assume xl:"(x,l)\<in>?M2"
10.1015        then guess x' l' unfolding mem_Collect_eq apply- unfolding Pair_eq apply((erule exE)+,(erule conjE)+) .  note xl'=this
10.1016        have "l' \<subseteq> d2 x'" apply(rule order_trans[OF fineD[OF p(2) xl'(3)]]) by auto
10.1017        thus "l \<subseteq> d2 x" unfolding xl' by auto
10.1018 -      show "x\<in>l" "l \<subseteq> {a..b} \<inter> {x. x \$\$ k \<ge> c}" unfolding xl' using p(4-6)[OF xl'(3)] using xl'(4)
10.1019 +      show "x\<in>l" "l \<subseteq> {a..b} \<inter> {x. x \<bullet> k \<ge> c}" unfolding xl' using p(4-6)[OF xl'(3)] using xl'(4)
10.1020          using lem0(2)[OF xl'(3-4)] by auto
10.1021        show  "\<exists>a b. l = {a..b}" unfolding xl' using p(6)[OF xl'(3)] by(fastforce simp add: interval_split[OF k, where c=c])
10.1022        fix y r let ?goal = "interior l \<inter> interior r = {}" assume yr:"(y,r)\<in>?M2"
10.1023 @@ -2098,98 +1998,95 @@
10.1024      also { have *:"\<And>x y. x = (0::real) \<Longrightarrow> x *\<^sub>R (y::'b) = 0" using scaleR_zero_left by auto
10.1025        have "((\<Sum>(x, k)\<in>?M1. content k *\<^sub>R f x) - i) + ((\<Sum>(x, k)\<in>?M2. content k *\<^sub>R f x) - j)
10.1026         = (\<Sum>(x, k)\<in>?M1. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>?M2. content k *\<^sub>R f x) - (i + j)" by auto
10.1027 -      also have "\<dots> = (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. x \$\$ k \<le> c}) *\<^sub>R f x) +
10.1028 -        (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. c \<le> x \$\$ k}) *\<^sub>R f x) - (i + j)"
10.1029 +      also have "\<dots> = (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. x \<bullet> k \<le> c}) *\<^sub>R f x) +
10.1030 +        (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. c \<le> x \<bullet> k}) *\<^sub>R f x) - (i + j)"
10.1031          unfolding lem3[OF p(3)] apply(subst setsum_reindex_nonzero[OF p(3)]) defer apply(subst setsum_reindex_nonzero[OF p(3)])
10.1032          defer unfolding lem4[THEN sym] apply(rule refl) unfolding split_paired_all split_conv apply(rule_tac[!] *)
10.1033        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
10.1034        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
10.1035        qed also note setsum_addf[THEN sym]
10.1036 -      also have *:"\<And>x. x\<in>p \<Longrightarrow> (\<lambda>(x, ka). content (ka \<inter> {x. x \$\$ k \<le> c}) *\<^sub>R f x) x + (\<lambda>(x, ka). content (ka \<inter> {x. c \<le> x \$\$ k}) *\<^sub>R f x) x
10.1037 +      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
10.1038          = (\<lambda>(x,ka). content ka *\<^sub>R f x) x" unfolding split_paired_all split_conv
10.1039        proof- fix a b assume "(a,b) \<in> p" from p(6)[OF this] guess u v apply-by(erule exE)+ note uv=this
10.1040 -        thus "content (b \<inter> {x. x \$\$ k \<le> c}) *\<^sub>R f a + content (b \<inter> {x. c \<le> x \$\$ k}) *\<^sub>R f a = content b *\<^sub>R f a"
10.1041 +        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"
10.1042            unfolding scaleR_left_distrib[THEN sym] unfolding uv content_split[OF k,of u v c] by auto
10.1043        qed note setsum_cong2[OF this]
10.1044 -      finally have "(\<Sum>(x, k)\<in>{(x, kk \<inter> {x. x \$\$ k \<le> c}) |x kk. (x, kk) \<in> p \<and> kk \<inter> {x. x \$\$ k \<le> c} \<noteq> {}}. content k *\<^sub>R f x) - i +
10.1045 -        ((\<Sum>(x, k)\<in>{(x, kk \<inter> {x. c \<le> x \$\$ k}) |x kk. (x, kk) \<in> p \<and> kk \<inter> {x. c \<le> x \$\$ k} \<noteq> {}}. content k *\<^sub>R f x) - j) =
10.1046 +      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 +
10.1047 +        ((\<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) =
10.1048          (\<Sum>(x, ka)\<in>p. content ka *\<^sub>R f x) - (i + j)" by auto }
10.1049      finally show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - (i + j)) < e" by auto qed qed
10.1050
10.1051 -(*lemma has_integral_split_cart: fixes f::"real^'n \<Rightarrow> 'a::real_normed_vector"
10.1052 -  assumes "(f has_integral i) ({a..b} \<inter> {x. x\$k \<le> c})"  "(f has_integral j) ({a..b} \<inter> {x. x\$k \<ge> c})"
10.1053 -  shows "(f has_integral (i + j)) ({a..b})" *)
10.1054 -
10.1055  subsection {* A sort of converse, integrability on subintervals. *}
10.1056
10.1057  lemma tagged_division_union_interval: fixes a::"'a::ordered_euclidean_space"
10.1058 -  assumes "p1 tagged_division_of ({a..b} \<inter> {x. x\$\$k \<le> (c::real)})"  "p2 tagged_division_of ({a..b} \<inter> {x. x\$\$k \<ge> c})"
10.1059 -  and k:"k<DIM('a)"
10.1060 +  assumes "p1 tagged_division_of ({a..b} \<inter> {x. x\<bullet>k \<le> (c::real)})"  "p2 tagged_division_of ({a..b} \<inter> {x. x\<bullet>k \<ge> c})"
10.1061 +  and k:"k\<in>Basis"
10.1062    shows "(p1 \<union> p2) tagged_division_of ({a..b})"
10.1063 -proof- have *:"{a..b} = ({a..b} \<inter> {x. x\$\$k \<le> c}) \<union> ({a..b} \<inter> {x. x\$\$k \<ge> c})" by auto
10.1064 +proof- have *:"{a..b} = ({a..b} \<inter> {x. x\<bullet>k \<le> c}) \<union> ({a..b} \<inter> {x. x\<bullet>k \<ge> c})" by auto
10.1065    show ?thesis apply(subst *) apply(rule tagged_division_union[OF assms(1-2)])
10.1066      unfolding interval_split[OF k] interior_closed_interval using k
10.1067 -    by(auto simp add: eucl_less[where 'a='a] elim!:allE[where x=k]) qed
10.1068 +    by(auto simp add: eucl_less[where 'a='a] elim!: ballE[where x=k]) qed
10.1069
10.1070  lemma has_integral_separate_sides: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
10.1071 -  assumes "(f has_integral i) ({a..b})" "e>0" and k:"k<DIM('a)"
10.1072 -  obtains d where "gauge d" "(\<forall>p1 p2. p1 tagged_division_of ({a..b} \<inter> {x. x\$\$k \<le> c}) \<and> d fine p1 \<and>
10.1073 -                                p2 tagged_division_of ({a..b} \<inter> {x. x\$\$k \<ge> c}) \<and> d fine p2
10.1074 +  assumes "(f has_integral i) ({a..b})" "e>0" and k:"k\<in>Basis"
10.1075 +  obtains d where "gauge d" "(\<forall>p1 p2. p1 tagged_division_of ({a..b} \<inter> {x. x\<bullet>k \<le> c}) \<and> d fine p1 \<and>
10.1076 +                                p2 tagged_division_of ({a..b} \<inter> {x. x\<bullet>k \<ge> c}) \<and> d fine p2
10.1077                                  \<longrightarrow> norm((setsum (\<lambda>(x,k). content k *\<^sub>R f x) p1 +
10.1078                                            setsum (\<lambda>(x,k). content k *\<^sub>R f x) p2) - i) < e)"
10.1079  proof- guess d using has_integralD[OF assms(1-2)] . note d=this
10.1080    show ?thesis apply(rule that[of d]) apply(rule d) apply(rule,rule,rule,(erule conjE)+)
10.1081 -  proof- fix p1 p2 assume "p1 tagged_division_of {a..b} \<inter> {x. x \$\$ k \<le> c}" "d fine p1" note p1=tagged_division_ofD[OF this(1)] this
10.1082 -                   assume "p2 tagged_division_of {a..b} \<inter> {x. c \<le> x \$\$ k}" "d fine p2" note p2=tagged_division_ofD[OF this(1)] this
10.1083 +  proof- fix p1 p2 assume "p1 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<le> c}" "d fine p1" note p1=tagged_division_ofD[OF this(1)] this
10.1084 +                   assume "p2 tagged_division_of {a..b} \<inter> {x. c \<le> x \<bullet> k}" "d fine p2" note p2=tagged_division_ofD[OF this(1)] this
10.1085      note tagged_division_union_interval[OF p1(7) p2(7)] note p12 = tagged_division_ofD[OF this] this
10.1086      have "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x) - i) = norm ((\<Sum>(x, k)\<in>p1 \<union> p2. content k *\<^sub>R f x) - i)"
10.1087        apply(subst setsum_Un_zero) apply(rule p1 p2)+ apply(rule) unfolding split_paired_all split_conv
10.1088      proof- fix a b assume ab:"(a,b) \<in> p1 \<inter> p2"
10.1089        have "(a,b) \<in> p1" using ab by auto from p1(4)[OF this] guess u v apply-by(erule exE)+ note uv =this
10.1090 -      have "b \<subseteq> {x. x\$\$k = c}" using ab p1(3)[of a b] p2(3)[of a b] by fastforce
10.1091 -      moreover have "interior {x::'a. x \$\$ k = c} = {}"
10.1092 -      proof(rule ccontr) case goal1 then obtain x where x:"x\<in>interior {x::'a. x\$\$k = c}" by auto
10.1093 +      have "b \<subseteq> {x. x\<bullet>k = c}" using ab p1(3)[of a b] p2(3)[of a b] by fastforce
10.1094 +      moreover have "interior {x::'a. x \<bullet> k = c} = {}"
10.1095 +      proof(rule ccontr) case goal1 then obtain x where x:"x\<in>interior {x::'a. x\<bullet>k = c}" by auto
10.1096          then guess e unfolding mem_interior .. note e=this
10.1097 -        have x:"x\$\$k = c" using x interior_subset by fastforce
10.1098 -        have *:"\<And>i. i<DIM('a) \<Longrightarrow> \<bar>(x - (x + (\<chi>\<chi> i. if i = k then e / 2 else 0))) \$\$ i\<bar>
10.1099 -          = (if i = k then e/2 else 0)" using e by auto
10.1100 -        have "(\<Sum>i<DIM('a). \<bar>(x - (x + (\<chi>\<chi> i. if i = k then e / 2 else 0))) \$\$ i\<bar>) =
10.1101 -          (\<Sum>i<DIM('a). (if i = k then e / 2 else 0))" apply(rule setsum_cong2) apply(subst *) by auto
10.1102 +        have x:"x\<bullet>k = c" using x interior_subset by fastforce
10.1103 +        have *:"\<And>i. i\<in>Basis \<Longrightarrow> \<bar>(x - (x + (e / 2) *\<^sub>R k)) \<bullet> i\<bar>
10.1104 +          = (if i = k then e/2 else 0)" using e k by (auto simp: inner_simps inner_not_same_Basis)
10.1105 +        have "(\<Sum>i\<in>Basis. \<bar>(x - (x + (e / 2 ) *\<^sub>R k)) \<bullet> i\<bar>) =
10.1106 +          (\<Sum>i\<in>Basis. (if i = k then e / 2 else 0))" apply(rule setsum_cong2) apply(subst *) by auto
10.1107          also have "... < e" apply(subst setsum_delta) using e by auto
10.1108 -        finally have "x + (\<chi>\<chi> i. if i = k then e/2 else 0) \<in> ball x e" unfolding mem_ball dist_norm
10.1109 -          by(rule le_less_trans[OF norm_le_l1])
10.1110 -        hence "x + (\<chi>\<chi> i. if i = k then e/2 else 0) \<in> {x. x\$\$k = c}" using e by auto
10.1111 -        thus False unfolding mem_Collect_eq using e x k by auto
10.1112 +        finally have "x + (e/2) *\<^sub>R k \<in> ball x e"
10.1113 +          unfolding mem_ball dist_norm by(rule le_less_trans[OF norm_le_l1])
10.1114 +        hence "x + (e/2) *\<^sub>R k \<in> {x. x\<bullet>k = c}" using e by auto
10.1115 +        thus False unfolding mem_Collect_eq using e x k by (auto simp: inner_simps)
10.1116        qed ultimately have "content b = 0" unfolding uv content_eq_0_interior apply-apply(drule interior_mono) by auto
10.1117        thus "content b *\<^sub>R f a = 0" by auto
10.1118      qed auto
10.1119      also have "\<dots> < e" by(rule k d(2) p12 fine_union p1 p2)+
10.1120      finally show "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x) - i) < e" . qed qed
10.1121
10.1122 -lemma integrable_split[intro]: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::{real_normed_vector,complete_space}"
10.1123 -  assumes "f integrable_on {a..b}" and k:"k<DIM('a)"
10.1124 -  shows "f integrable_on ({a..b} \<inter> {x. x\$\$k \<le> c})" (is ?t1) and "f integrable_on ({a..b} \<inter> {x. x\$\$k \<ge> c})" (is ?t2)
10.1125 +lemma integrable_split[intro]:
10.1126 +  fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::{real_normed_vector,complete_space}"
10.1127 +  assumes "f integrable_on {a..b}" and k:"k\<in>Basis"
10.1128 +  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)
10.1129  proof- guess y using assms(1) unfolding integrable_on_def .. note y=this
10.1130 -  def b' \<equiv> "(\<chi>\<chi> i. if i = k then min (b\$\$k) c else b\$\$i)::'a"
10.1131 -  and a' \<equiv> "(\<chi>\<chi> i. if i = k then max (a\$\$k) c else a\$\$i)::'a"
10.1132 +  def b' \<equiv> "\<Sum>i\<in>Basis. (if i = k then min (b\<bullet>k) c else b\<bullet>i)*\<^sub>R i::'a"
10.1133 +  def a' \<equiv> "\<Sum>i\<in>Basis. (if i = k then max (a\<bullet>k) c else a\<bullet>i)*\<^sub>R i::'a"
10.1134    show ?t1 ?t2 unfolding interval_split[OF k] integrable_cauchy unfolding interval_split[THEN sym,OF k]
10.1135    proof(rule_tac[!] allI impI)+ fix e::real assume "e>0" hence "e/2>0" by auto
10.1136      from has_integral_separate_sides[OF y this k,of c] guess d . note d=this[rule_format]
10.1137      let ?P = "\<lambda>A. \<exists>d. gauge d \<and> (\<forall>p1 p2. p1 tagged_division_of {a..b} \<inter> A \<and> d fine p1
10.1138        \<and> p2 tagged_division_of {a..b} \<inter> A \<and> d fine p2 \<longrightarrow>
10.1139        norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)) < e)"
10.1140 -    show "?P {x. x \$\$ k \<le> c}" apply(rule_tac x=d in exI) apply(rule,rule d) apply(rule,rule,rule)
10.1141 -    proof- fix p1 p2 assume as:"p1 tagged_division_of {a..b} \<inter> {x. x \$\$ k \<le> c} \<and> d fine p1
10.1142 -        \<and> p2 tagged_division_of {a..b} \<inter> {x. x \$\$ k \<le> c} \<and> d fine p2"
10.1143 +    show "?P {x. x \<bullet> k \<le> c}" apply(rule_tac x=d in exI) apply(rule,rule d) apply(rule,rule,rule)
10.1144 +    proof- fix p1 p2 assume as:"p1 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<le> c} \<and> d fine p1
10.1145 +        \<and> p2 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<le> c} \<and> d fine p2"
10.1146        show "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)) < e"
10.1147        proof- guess p using fine_division_exists[OF d(1), of a' b] . note p=this
10.1148          show ?thesis using norm_triangle_half_l[OF d(2)[of p1 p] d(2)[of p2 p]]
10.1149            using as unfolding interval_split[OF k] b'_def[symmetric] a'_def[symmetric]
10.1150            using p using assms by(auto simp add:algebra_simps)
10.1151        qed qed
10.1152 -    show "?P {x. x \$\$ k \<ge> c}" apply(rule_tac x=d in exI) apply(rule,rule d) apply(rule,rule,rule)
10.1153 -    proof- fix p1 p2 assume as:"p1 tagged_division_of {a..b} \<inter> {x. x \$\$ k \<ge> c} \<and> d fine p1
10.1154 -        \<and> p2 tagged_division_of {a..b} \<inter> {x. x \$\$ k \<ge> c} \<and> d fine p2"
10.1155 +    show "?P {x. x \<bullet> k \<ge> c}" apply(rule_tac x=d in exI) apply(rule,rule d) apply(rule,rule,rule)
10.1156 +    proof- fix p1 p2 assume as:"p1 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<ge> c} \<and> d fine p1
10.1157 +        \<and> p2 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<ge> c} \<and> d fine p2"
10.1158        show "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)) < e"
10.1159        proof- guess p using fine_division_exists[OF d(1), of a b'] . note p=this
10.1160          show ?thesis using norm_triangle_half_l[OF d(2)[of p p1] d(2)[of p p2]]
10.1161 @@ -2203,13 +2100,13 @@
10.1162  definition operative :: "('a \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> (('b::ordered_euclidean_space) set \<Rightarrow> 'a) \<Rightarrow> bool" where
10.1163    "operative opp f \<equiv>
10.1164      (\<forall>a b. content {a..b} = 0 \<longrightarrow> f {a..b} = neutral(opp)) \<and>
10.1165 -    (\<forall>a b c. \<forall>k<DIM('b). f({a..b}) =
10.1166 -                   opp (f({a..b} \<inter> {x. x\$\$k \<le> c}))
10.1167 -                       (f({a..b} \<inter> {x. x\$\$k \<ge> c})))"
10.1168 +    (\<forall>a b c. \<forall>k\<in>Basis. f({a..b}) =
10.1169 +                   opp (f({a..b} \<inter> {x. x\<bullet>k \<le> c}))
10.1170 +                       (f({a..b} \<inter> {x. x\<bullet>k \<ge> c})))"
10.1171
10.1172  lemma operativeD[dest]: fixes type::"'a::ordered_euclidean_space"  assumes "operative opp f"
10.1173    shows "\<And>a b. content {a..b} = 0 \<Longrightarrow> f {a..b::'a} = neutral(opp)"
10.1174 -  "\<And>a b c k. k<DIM('a) \<Longrightarrow> f({a..b}) = opp (f({a..b} \<inter> {x. x\$\$k \<le> c})) (f({a..b} \<inter> {x. x\$\$k \<ge> c}))"
10.1175 +  "\<And>a b c k. k\<in>Basis \<Longrightarrow> f({a..b}) = opp (f({a..b} \<inter> {x. x\<bullet>k \<le> c})) (f({a..b} \<inter> {x. x\<bullet>k \<ge> c}))"
10.1176    using assms unfolding operative_def by auto
10.1177
10.1178  lemma operative_trivial:
10.1179 @@ -2342,18 +2239,20 @@
10.1180  lemma operative_integral: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
10.1181    shows "operative (lifted(op +)) (\<lambda>i. if f integrable_on i then Some(integral i f) else None)"
10.1182    unfolding operative_def unfolding neutral_lifted[OF monoidal_monoid] neutral_add
10.1183 -  apply(rule,rule,rule,rule) defer apply(rule allI impI)+
10.1184 -proof- fix a b c k assume k:"k<DIM('a)" show "(if f integrable_on {a..b} then Some (integral {a..b} f) else None) =
10.1185 -    lifted op + (if f integrable_on {a..b} \<inter> {x. x \$\$ k \<le> c} then Some (integral ({a..b} \<inter> {x. x \$\$ k \<le> c}) f) else None)
10.1186 -    (if f integrable_on {a..b} \<inter> {x. c \<le> x \$\$ k} then Some (integral ({a..b} \<inter> {x. c \<le> x \$\$ k}) f) else None)"
10.1187 +  apply(rule,rule,rule,rule) defer apply(rule allI ballI)+
10.1188 +proof-
10.1189 +  fix a b c and k :: 'a assume k:"k\<in>Basis"
10.1190 +  show "(if f integrable_on {a..b} then Some (integral {a..b} f) else None) =
10.1191 +    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)
10.1192 +    (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)"
10.1193    proof(cases "f integrable_on {a..b}")
10.1194      case True show ?thesis unfolding if_P[OF True] using k apply-
10.1195        unfolding if_P[OF integrable_split(1)[OF True]] unfolding if_P[OF integrable_split(2)[OF True]]
10.1196        unfolding lifted.simps option.inject apply(rule integral_unique) apply(rule has_integral_split[OF _ _ k])
10.1197        apply(rule_tac[!] integrable_integral integrable_split)+ using True k by auto
10.1198 -  next case False have "(\<not> (f integrable_on {a..b} \<inter> {x. x \$\$ k \<le> c})) \<or> (\<not> ( f integrable_on {a..b} \<inter> {x. c \<le> x \$\$ k}))"
10.1199 +  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}))"
10.1200      proof(rule ccontr) case goal1 hence "f integrable_on {a..b}" apply- unfolding integrable_on_def
10.1201 -        apply(rule_tac x="integral ({a..b} \<inter> {x. x \$\$ k \<le> c}) f + integral ({a..b} \<inter> {x. x \$\$ k \<ge> c}) f" in exI)
10.1202 +        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)
10.1203          apply(rule has_integral_split[OF _ _ k]) apply(rule_tac[!] integrable_integral) by auto
10.1204        thus False using False by auto
10.1205      qed thus ?thesis using False by auto
10.1206 @@ -2365,91 +2264,110 @@
10.1207  subsection {* Points of division of a partition. *}
10.1208
10.1209  definition "division_points (k::('a::ordered_euclidean_space) set) d =
10.1210 -    {(j,x). j<DIM('a) \<and> (interval_lowerbound k)\$\$j < x \<and> x < (interval_upperbound k)\$\$j \<and>
10.1211 -           (\<exists>i\<in>d. (interval_lowerbound i)\$\$j = x \<or> (interval_upperbound i)\$\$j = x)}"
10.1212 +    {(j,x). j\<in>Basis \<and> (interval_lowerbound k)\<bullet>j < x \<and> x < (interval_upperbound k)\<bullet>j \<and>
10.1213 +           (\<exists>i\<in>d. (interval_lowerbound i)\<bullet>j = x \<or> (interval_upperbound i)\<bullet>j = x)}"
10.1214
10.1215  lemma division_points_finite: fixes i::"('a::ordered_euclidean_space) set"
10.1216    assumes "d division_of i" shows "finite (division_points i d)"
10.1217  proof- note assm = division_ofD[OF assms]
10.1218 -  let ?M = "\<lambda>j. {(j,x)|x. (interval_lowerbound i)\$\$j < x \<and> x < (interval_upperbound i)\$\$j \<and>
10.1219 -           (\<exists>i\<in>d. (interval_lowerbound i)\$\$j = x \<or> (interval_upperbound i)\$\$j = x)}"
10.1220 -  have *:"division_points i d = \<Union>(?M ` {..<DIM('a)})"
10.1221 +  let ?M = "\<lambda>j. {(j,x)|x. (interval_lowerbound i)\<bullet>j < x \<and> x < (interval_upperbound i)\<bullet>j \<and>
10.1222 +           (\<exists>i\<in>d. (interval_lowerbound i)\<bullet>j = x \<or> (interval_upperbound i)\<bullet>j = x)}"
10.1223 +  have *:"division_points i d = \<Union>(?M ` Basis)"
10.1224      unfolding division_points_def by auto
10.1225    show ?thesis unfolding * using assm by auto qed
10.1226
10.1227  lemma division_points_subset: fixes a::"'a::ordered_euclidean_space"
10.1228 -  assumes "d division_of {a..b}" "\<forall>i<DIM('a). a\$\$i < b\$\$i"  "a\$\$k < c" "c < b\$\$k" and k:"k<DIM('a)"
10.1229 -  shows "division_points ({a..b} \<inter> {x. x\$\$k \<le> c}) {l \<inter> {x. x\$\$k \<le> c} | l . l \<in> d \<and> ~(l \<inter> {x. x\$\$k \<le> c} = {})}
10.1230 +  assumes "d division_of {a..b}" "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"  "a\<bullet>k < c" "c < b\<bullet>k" and k:"k\<in>Basis"
10.1231 +  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} = {})}
10.1232                    \<subseteq> division_points ({a..b}) d" (is ?t1) and
10.1233 -        "division_points ({a..b} \<inter> {x. x\$\$k \<ge> c}) {l \<inter> {x. x\$\$k \<ge> c} | l . l \<in> d \<and> ~(l \<inter> {x. x\$\$k \<ge> c} = {})}
10.1234 +        "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} = {})}
10.1235                    \<subseteq> division_points ({a..b}) d" (is ?t2)
10.1236  proof- note assm = division_ofD[OF assms(1)]
10.1237 -  have *:"\<forall>i<DIM('a). a\$\$i \<le> b\$\$i"   "\<forall>i<DIM('a). a\$\$i \<le> ((\<chi>\<chi> i. if i = k then min (b \$\$ k) c else b \$\$ i)::'a) \$\$ i"
10.1238 -    "\<forall>i<DIM('a). ((\<chi>\<chi> i. if i = k then max (a \$\$ k) c else a \$\$ i)::'a) \$\$ i \<le> b\$\$i"  "min (b \$\$ k) c = c" "max (a \$\$ k) c = c"
10.1239 +  have *:"\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i"
10.1240 +    "\<forall>i\<in>Basis. a\<bullet>i \<le> (\<Sum>i\<in>Basis. (if i = k then min (b \<bullet> k) c else b \<bullet> i) *\<^sub>R i) \<bullet> i"
10.1241 +    "\<forall>i\<in>Basis. (\<Sum>i\<in>Basis. (if i = k then max (a \<bullet> k) c else a \<bullet> i) *\<^sub>R i) \<bullet> i \<le> b\<bullet>i"
10.1242 +    "min (b \<bullet> k) c = c" "max (a \<bullet> k) c = c"
10.1243      using assms using less_imp_le by auto
10.1244 -  show ?t1 unfolding division_points_def interval_split[OF k, of a b]
10.1245 -    unfolding interval_bounds[OF *(1)] interval_bounds[OF *(2)] interval_bounds[OF *(3)] unfolding *
10.1246 -    unfolding subset_eq apply(rule) unfolding mem_Collect_eq split_beta apply(erule bexE conjE)+
10.1247 -    unfolding mem_Collect_eq apply(erule exE conjE)+ unfolding euclidean_lambda_beta'
10.1248 -  proof- fix i l x assume as:"a \$\$ fst x < snd x" "snd x < (if fst x = k then c else b \$\$ fst x)"
10.1249 -      "interval_lowerbound i \$\$ fst x = snd x \<or> interval_upperbound i \$\$ fst x = snd x"
10.1250 -      "i = l \<inter> {x. x \$\$ k \<le> c}" "l \<in> d" "l \<inter> {x. x \$\$ k \<le> c} \<noteq> {}" and fstx:"fst x <DIM('a)"
10.1251 +  show ?t1
10.1252 +    unfolding division_points_def interval_split[OF k, of a b]
10.1253 +    unfolding interval_bounds[OF *(1)] interval_bounds[OF *(2)] interval_bounds[OF *(3)]
10.1254 +    unfolding *
10.1255 +    unfolding subset_eq
10.1256 +    apply(rule)
10.1257 +    unfolding mem_Collect_eq split_beta
10.1258 +    apply(erule bexE conjE)+
10.1259 +    apply(simp only: mem_Collect_eq inner_setsum_left_Basis simp_thms)
10.1260 +    apply(erule exE conjE)+
10.1261 +  proof
10.1262 +    fix i l x assume as:"a \<bullet> fst x < snd x" "snd x < (if fst x = k then c else b \<bullet> fst x)"
10.1263 +      "interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
10.1264 +      "i = l \<inter> {x. x \<bullet> k \<le> c}" "l \<in> d" "l \<inter> {x. x \<bullet> k \<le> c} \<noteq> {}" and fstx:"fst x \<in>Basis"
10.1265      from assm(4)[OF this(5)] guess u v apply-by(erule exE)+ note l=this
10.1266 -    have *:"\<forall>i<DIM('a). u \$\$ i \<le> ((\<chi>\<chi> i. if i = k then min (v \$\$ k) c else v \$\$ i)::'a) \$\$ i"
10.1267 +    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"
10.1268        using as(6) unfolding l interval_split[OF k] interval_ne_empty as .
10.1269 -    have **:"\<forall>i<DIM('a). u\$\$i \<le> v\$\$i" using l using as(6) unfolding interval_ne_empty[THEN sym] by auto
10.1270 -    show "fst x <DIM('a) \<and> a \$\$ fst x < snd x \<and> snd x < b \$\$ fst x \<and> (\<exists>i\<in>d. interval_lowerbound i \$\$ fst x = snd x
10.1271 -      \<or> interval_upperbound i \$\$ fst x = snd x)" apply(rule,rule fstx)
10.1272 -      using as(1-3,5) unfolding l interval_split[OF k] interval_ne_empty as interval_bounds[OF *] apply-
10.1273 -      apply(rule,assumption,rule) defer apply(rule_tac x="{u..v}" in bexI) unfolding interval_bounds[OF **]
10.1274 -      apply(case_tac[!] "fst x = k") using assms fstx apply- unfolding euclidean_lambda_beta by auto
10.1275 +    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
10.1276 +    show "\<exists>i\<in>d. interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
10.1277 +      apply (rule bexI[OF _ `l \<in> d`])
10.1278 +      using as(1-3,5) fstx
10.1279 +      unfolding l interval_bounds[OF **] interval_bounds[OF *] interval_split[OF k] as
10.1280 +      by (auto split: split_if_asm)
10.1281 +    show "snd x < b \<bullet> fst x"
10.1282 +      using as(2) `c < b\<bullet>k` by (auto split: split_if_asm)
10.1283    qed
10.1284 -  show ?t2 unfolding division_points_def interval_split[OF k, of a b]
10.1285 +  show ?t2
10.1286 +    unfolding division_points_def interval_split[OF k, of a b]
10.1287      unfolding interval_bounds[OF *(1)] interval_bounds[OF *(2)] interval_bounds[OF *(3)] unfolding *
10.1288 -    unfolding subset_eq apply(rule) unfolding mem_Collect_eq split_beta apply(erule bexE conjE)+
10.1289 -    unfolding mem_Collect_eq apply(erule exE conjE)+ unfolding euclidean_lambda_beta' apply(rule,assumption)
10.1290 -  proof- fix i l x assume as:"(if fst x = k then c else a \$\$ fst x) < snd x" "snd x < b \$\$ fst x"
10.1291 -      "interval_lowerbound i \$\$ fst x = snd x \<or> interval_upperbound i \$\$ fst x = snd x"
10.1292 -      "i = l \<inter> {x. c \<le> x \$\$ k}" "l \<in> d" "l \<inter> {x. c \<le> x \$\$ k} \<noteq> {}" and fstx:"fst x < DIM('a)"
10.1293 +    unfolding subset_eq apply(rule) unfolding mem_Collect_eq split_beta
10.1294 +    apply(erule bexE conjE)+
10.1295 +    apply(simp only: mem_Collect_eq inner_setsum_left_Basis simp_thms)
10.1296 +    apply(erule exE conjE)+
10.1297 +  proof
10.1298 +    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"
10.1299 +      "interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
10.1300 +      "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"
10.1301      from assm(4)[OF this(5)] guess u v apply-by(erule exE)+ note l=this
10.1302 -    have *:"\<forall>i<DIM('a). ((\<chi>\<chi> i. if i = k then max (u \$\$ k) c else u \$\$ i)::'a) \$\$ i \<le> v \$\$ i"
10.1303 +    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"
10.1304        using as(6) unfolding l interval_split[OF k] interval_ne_empty as .
10.1305 -    have **:"\<forall>i<DIM('a). u\$\$i \<le> v\$\$i" using l using as(6) unfolding interval_ne_empty[THEN sym] by auto
10.1306 -    show "a \$\$ fst x < snd x \<and> snd x < b \$\$ fst x \<and> (\<exists>i\<in>d. interval_lowerbound i \$\$ fst x = snd x \<or>
10.1307 -      interval_upperbound i \$\$ fst x = snd x)"
10.1308 -      using as(1-3,5) unfolding l interval_split[OF k] interval_ne_empty as interval_bounds[OF *] apply-
10.1309 -      apply rule defer apply(rule,assumption) apply(rule_tac x="{u..v}" in bexI) unfolding interval_bounds[OF **]
10.1310 -      apply(case_tac[!] "fst x = k") using assms fstx apply-  by(auto simp add:euclidean_lambda_beta'[OF k]) qed qed
10.1311 +    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
10.1312 +    show "\<exists>i\<in>d. interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
10.1313 +      apply (rule bexI[OF _ `l \<in> d`])
10.1314 +      using as(1-3,5) fstx
10.1315 +      unfolding l interval_bounds[OF **] interval_bounds[OF *] interval_split[OF k] as
10.1316 +      by (auto split: split_if_asm)
10.1317 +    show "a \<bullet> fst x < snd x"
10.1318 +      using as(1) `a\<bullet>k < c` by (auto split: split_if_asm)
10.1319 +   qed
10.1320 +qed
10.1321
10.1322  lemma division_points_psubset: fixes a::"'a::ordered_euclidean_space"
10.1323 -  assumes "d division_of {a..b}"  "\<forall>i<DIM('a). a\$\$i < b\$\$i"  "a\$\$k < c" "c < b\$\$k"
10.1324 -  "l \<in> d" "interval_lowerbound l\$\$k = c \<or> interval_upperbound l\$\$k = c" and k:"k<DIM('a)"
10.1325 -  shows "division_points ({a..b} \<inter> {x. x\$\$k \<le> c}) {l \<inter> {x. x\$\$k \<le> c} | l. l\<in>d \<and> l \<inter> {x. x\$\$k \<le> c} \<noteq> {}}
10.1326 +  assumes "d division_of {a..b}"  "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"  "a\<bullet>k < c" "c < b\<bullet>k"
10.1327 +  "l \<in> d" "interval_lowerbound l\<bullet>k = c \<or> interval_upperbound l\<bullet>k = c" and k:"k\<in>Basis"
10.1328 +  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> {}}
10.1329                \<subset> division_points ({a..b}) d" (is "?D1 \<subset> ?D")
10.1330 -        "division_points ({a..b} \<inter> {x. x\$\$k \<ge> c}) {l \<inter> {x. x\$\$k \<ge> c} | l. l\<in>d \<and> l \<inter> {x. x\$\$k \<ge> c} \<noteq> {}}
10.1331 +        "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> {}}
10.1332                \<subset> division_points ({a..b}) d" (is "?D2 \<subset> ?D")
10.1333 -proof- have ab:"\<forall>i<DIM('a). a\$\$i \<le> b\$\$i" using assms(2) by(auto intro!:less_imp_le)
10.1334 +proof- have ab:"\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i" using assms(2) by(auto intro!:less_imp_le)
10.1335    guess u v using division_ofD(4)[OF assms(1,5)] apply-by(erule exE)+ note l=this
10.1336 -  have uv:"\<forall>i<DIM('a). u\$\$i \<le> v\$\$i" "\<forall>i<DIM('a). a\$\$i \<le> u\$\$i \<and> v\$\$i \<le> b\$\$i"
10.1337 +  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"
10.1338      using division_ofD(2,2,3)[OF assms(1,5)] unfolding l interval_ne_empty
10.1339      unfolding subset_eq apply- defer apply(erule_tac x=u in ballE, erule_tac x=v in ballE) unfolding mem_interval by auto
10.1340 -  have *:"interval_upperbound ({a..b} \<inter> {x. x \$\$ k \<le> interval_upperbound l \$\$ k}) \$\$ k = interval_upperbound l \$\$ k"
10.1341 -         "interval_upperbound ({a..b} \<inter> {x. x \$\$ k \<le> interval_lowerbound l \$\$ k}) \$\$ k = interval_lowerbound l \$\$ k"
10.1342 +  have *:"interval_upperbound ({a..b} \<inter> {x. x \<bullet> k \<le> interval_upperbound l \<bullet> k}) \<bullet> k = interval_upperbound l \<bullet> k"
10.1343 +         "interval_upperbound ({a..b} \<inter> {x. x \<bullet> k \<le> interval_lowerbound l \<bullet> k}) \<bullet> k = interval_lowerbound l \<bullet> k"
10.1344      unfolding interval_split[OF k] apply(subst interval_bounds) prefer 3 apply(subst interval_bounds)
10.1345      unfolding l interval_bounds[OF uv(1)] using uv[rule_format,of k] ab k by auto
10.1346    have "\<exists>x. x \<in> ?D - ?D1" using assms(2-) apply-apply(erule disjE)
10.1347 -    apply(rule_tac x="(k,(interval_lowerbound l)\$\$k)" in exI) defer
10.1348 -    apply(rule_tac x="(k,(interval_upperbound l)\$\$k)" in exI)
10.1349 +    apply(rule_tac x="(k,(interval_lowerbound l)\<bullet>k)" in exI) defer
10.1350 +    apply(rule_tac x="(k,(interval_upperbound l)\<bullet>k)" in exI)
10.1351      unfolding division_points_def unfolding interval_bounds[OF ab] by(auto simp add:*)
10.1352    thus "?D1 \<subset> ?D" apply-apply(rule,rule division_points_subset[OF assms(1-4)]) using k by auto
10.1353
10.1354 -  have *:"interval_lowerbound ({a..b} \<inter> {x. x \$\$ k \<ge> interval_lowerbound l \$\$ k}) \$\$ k = interval_lowerbound l \$\$ k"
10.1355 -         "interval_lowerbound ({a..b} \<inter> {x. x \$\$ k \<ge> interval_upperbound l \$\$ k}) \$\$ k = interval_upperbound l \$\$ k"
10.1356 +  have *:"interval_lowerbound ({a..b} \<inter> {x. x \<bullet> k \<ge> interval_lowerbound l \<bullet> k}) \<bullet> k = interval_lowerbound l \<bullet> k"
10.1357 +         "interval_lowerbound ({a..b} \<inter> {x. x \<bullet> k \<ge> interval_upperbound l \<bullet> k}) \<bullet> k = interval_upperbound l \<bullet> k"
10.1358      unfolding interval_split[OF k] apply(subst interval_bounds) prefer 3 apply(subst interval_bounds)
10.1359      unfolding l interval_bounds[OF uv(1)] using uv[rule_format,of k] ab k by auto
10.1360    have "\<exists>x. x \<in> ?D - ?D2" using assms(2-) apply-apply(erule disjE)
10.1361 -    apply(rule_tac x="(k,(interval_lowerbound l)\$\$k)" in exI) defer
10.1362 -    apply(rule_tac x="(k,(interval_upperbound l)\$\$k)" in exI)
10.1363 +    apply(rule_tac x="(k,(interval_lowerbound l)\<bullet>k)" in exI) defer
10.1364 +    apply(rule_tac x="(k,(interval_upperbound l)\<bullet>k)" in exI)
10.1365      unfolding division_points_def unfolding interval_bounds[OF ab] by(auto simp add:*)
10.1366    thus "?D2 \<subset> ?D" apply-apply(rule,rule division_points_subset[OF assms(1-4) k]) by auto qed
10.1367
10.1368 @@ -2548,42 +2466,47 @@
10.1369              using operativeD(1)[OF assms(2)] x by auto
10.1370          qed qed }
10.1371      assume "content {a..b} \<noteq> 0" note ab = this[unfolded content_lt_nz[THEN sym] content_pos_lt_eq]
10.1372 -    hence ab':"\<forall>i<DIM('a). a\$\$i \<le> b\$\$i" by (auto intro!: less_imp_le) show ?case
10.1373 +    hence ab':"\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i" by (auto intro!: less_imp_le) show ?case
10.1374      proof(cases "division_points {a..b} d = {}")
10.1375        case True have d':"\<forall>i\<in>d. \<exists>u v. i = {u..v} \<and>
10.1376 -        (\<forall>j<DIM('a). u\$\$j = a\$\$j \<and> v\$\$j = a\$\$j \<or> u\$\$j = b\$\$j \<and> v\$\$j = b\$\$j \<or> u\$\$j = a\$\$j \<and> v\$\$j = b\$\$j)"
10.1377 +        (\<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)"
10.1378          unfolding forall_in_division[OF goal1(4)] apply(rule,rule,rule)
10.1379 -        apply(rule_tac x=a in exI,rule_tac x=b in exI) apply(rule,rule refl) apply(rule,rule)
10.1380 -      proof- fix u v j assume j:"j<DIM('a)" assume as:"{u..v} \<in> d" note division_ofD(3)[OF goal1(4) this]
10.1381 -        hence uv:"\<forall>i<DIM('a). u\$\$i \<le> v\$\$i" "u\$\$j \<le> v\$\$j" using j unfolding interval_ne_empty by auto
10.1382 -        have *:"\<And>p r Q. \<not> j<DIM('a) \<or> p \<or> r \<or> (\<forall>x\<in>d. Q x) \<Longrightarrow> p \<or> r \<or> (Q {u..v})" using as j by auto
10.1383 -        have "(j, u\$\$j) \<notin> division_points {a..b} d"
10.1384 -          "(j, v\$\$j) \<notin> division_points {a..b} d" using True by auto
10.1385 +        apply(rule_tac x=a in exI,rule_tac x=b in exI) apply(rule,rule refl)
10.1386 +      proof
10.1387 +        fix u v and j :: 'a assume j:"j\<in>Basis" assume as:"{u..v} \<in> d" note division_ofD(3)[OF goal1(4) this]
10.1388 +        hence uv:"\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i" "u\<bullet>j \<le> v\<bullet>j" using j unfolding interval_ne_empty by auto
10.1389 +        have *:"\<And>p r Q. \<not> j\<in>Basis \<or> p \<or> r \<or> (\<forall>x\<in>d. Q x) \<Longrightarrow> p \<or> r \<or> (Q {u..v})" using as j by auto
10.1390 +        have "(j, u\<bullet>j) \<notin> division_points {a..b} d"
10.1391 +          "(j, v\<bullet>j) \<notin> division_points {a..b} d" using True by auto
10.1392          note this[unfolded de_Morgan_conj division_points_def mem_Collect_eq split_conv interval_bounds[OF ab'] bex_simps]
10.1393          note *[OF this(1)] *[OF this(2)] note this[unfolded interval_bounds[OF uv(1)]]
10.1394 -        moreover have "a\$\$j \<le> u\$\$j" "v\$\$j \<le> b\$\$j" using division_ofD(2,2,3)[OF goal1(4) as]
10.1395 +        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]
10.1396            unfolding subset_eq apply- apply(erule_tac x=u in ballE,erule_tac[3] x=v in ballE)
10.1397            unfolding interval_ne_empty mem_interval using j by auto
10.1398 -        ultimately show "u\$\$j = a\$\$j \<and> v\$\$j = a\$\$j \<or> u\$\$j = b\$\$j \<and> v\$\$j = b\$\$j \<or> u\$\$j = a\$\$j \<and> v\$\$j = b\$\$j"
10.1399 +        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"
10.1400            unfolding not_less de_Morgan_disj using ab[rule_format,of j] uv(2) j by auto
10.1401 -      qed have "(1/2) *\<^sub>R (a+b) \<in> {a..b}" unfolding mem_interval using ab by(auto intro!:less_imp_le)
10.1402 +      qed
10.1403 +      have "(1/2) *\<^sub>R (a+b) \<in> {a..b}"
10.1404 +        unfolding mem_interval using ab by(auto intro!: less_imp_le simp: inner_simps)
10.1405        note this[unfolded division_ofD(6)[OF goal1(4),THEN sym] Union_iff]
10.1406        then guess i .. note i=this guess u v using d'[rule_format,OF i(1)] apply-by(erule exE conjE)+ note uv=this
10.1407        have "{a..b} \<in> d"
10.1408        proof- { presume "i = {a..b}" thus ?thesis using i by auto }
10.1409          { presume "u = a" "v = b" thus "i = {a..b}" using uv by auto }
10.1410 -        show "u = a" "v = b" unfolding euclidean_eq[where 'a='a]
10.1411 -        proof(safe) fix j assume j:"j<DIM('a)" note i(2)[unfolded uv mem_interval,rule_format,of j]
10.1412 -          thus "u \$\$ j = a \$\$ j" "v \$\$ j = b \$\$ j" using uv(2)[rule_format,of j] j by auto
10.1413 +        show "u = a" "v = b" unfolding euclidean_eq_iff[where 'a='a]
10.1414 +        proof(safe)
10.1415 +          fix j :: 'a assume j:"j\<in>Basis"
10.1416 +          note i(2)[unfolded uv mem_interval,rule_format,of j]
10.1417 +          thus "u \<bullet> j = a \<bullet> j" "v \<bullet> j = b \<bullet> j" using uv(2)[rule_format,of j] j by (auto simp: inner_simps)
10.1418          qed qed
10.1419        hence *:"d = insert {a..b} (d - {{a..b}})" by auto
10.1420        have "iterate opp (d - {{a..b}}) f = neutral opp" apply(rule iterate_eq_neutral[OF goal1(2)])
10.1421        proof fix x assume x:"x \<in> d - {{a..b}}" hence "x\<in>d" by auto note d'[rule_format,OF this]
10.1422          then guess u v apply-by(erule exE conjE)+ note uv=this
10.1423          have "u\<noteq>a \<or> v\<noteq>b" using x[unfolded uv] by auto
10.1424 -        then obtain j where "u\$\$j \<noteq> a\$\$j \<or> v\$\$j \<noteq> b\$\$j" and j:"j<DIM('a)" unfolding euclidean_eq[where 'a='a] by auto
10.1425 -        hence "u\$\$j = v\$\$j" using uv(2)[rule_format,OF j] by auto
10.1426 -        hence "content {u..v} = 0"  unfolding content_eq_0 apply(rule_tac x=j in exI) using j by auto
10.1427 +        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
10.1428 +        hence "u\<bullet>j = v\<bullet>j" using uv(2)[rule_format,OF j] by auto
10.1429 +        hence "content {u..v} = 0"  unfolding content_eq_0 apply(rule_tac x=j in bexI) using j by auto
10.1430          thus "f x = neutral opp" unfolding uv(1) by(rule operativeD(1)[OF goal1(3)])
10.1431        qed thus "iterate opp d f = f {a..b}" apply-apply(subst *)
10.1432          apply(subst iterate_insert[OF goal1(2)]) using goal1(2,4) by auto
10.1433 @@ -2591,39 +2514,40 @@
10.1434        then guess k c unfolding split_paired_Ex apply- unfolding division_points_def mem_Collect_eq split_conv
10.1435          by(erule exE conjE)+ note this(2-4,1) note kc=this[unfolded interval_bounds[OF ab']]
10.1436        from this(3) guess j .. note j=this
10.1437 -      def d1 \<equiv> "{l \<inter> {x. x\$\$k \<le> c} | l. l \<in> d \<and> l \<inter> {x. x\$\$k \<le> c} \<noteq> {}}"
10.1438 -      def d2 \<equiv> "{l \<inter> {x. x\$\$k \<ge> c} | l. l \<in> d \<and> l \<inter> {x. x\$\$k \<ge> c} \<noteq> {}}"
10.1439 -      def cb \<equiv> "(\<chi>\<chi> i. if i = k then c else b\$\$i)::'a" and ca \<equiv> "(\<chi>\<chi> i. if i = k then c else a\$\$i)::'a"
10.1440 +      def d1 \<equiv> "{l \<inter> {x. x\<bullet>k \<le> c} | l. l \<in> d \<and> l \<inter> {x. x\<bullet>k \<le> c} \<noteq> {}}"
10.1441 +      def d2 \<equiv> "{l \<inter> {x. x\<bullet>k \<ge> c} | l. l \<in> d \<and> l \<inter> {x. x\<bullet>k \<ge> c} \<noteq> {}}"
10.1442 +      def cb \<equiv> "(\<Sum>i\<in>Basis. (if i = k then c else b\<bullet>i) *\<^sub>R i)::'a"
10.1443 +      def ca \<equiv> "(\<Sum>i\<in>Basis. (if i = k then c else a\<bullet>i) *\<^sub>R i)::'a"
10.1444        note division_points_psubset[OF goal1(4) ab kc(1-2) j]
10.1445        note psubset_card_mono[OF _ this(1)] psubset_card_mono[OF _ this(2)]
10.1446 -      hence *:"(iterate opp d1 f) = f ({a..b} \<inter> {x. x\$\$k \<le> c})" "(iterate opp d2 f) = f ({a..b} \<inter> {x. x\$\$k \<ge> c})"
10.1447 +      hence *:"(iterate opp d1 f) = f ({a..b} \<inter> {x. x\<bullet>k \<le> c})" "(iterate opp d2 f) = f ({a..b} \<inter> {x. x\<bullet>k \<ge> c})"
10.1448          apply- unfolding interval_split[OF kc(4)] apply(rule_tac[!] goal1(1)[rule_format])
10.1449          using division_split[OF goal1(4), where k=k and c=c]
10.1450          unfolding interval_split[OF kc(4)] d1_def[symmetric] d2_def[symmetric] unfolding goal1(2) Suc_le_mono
10.1451          using goal1(2-3) using division_points_finite[OF goal1(4)] using kc(4) by auto
10.1452        have "f {a..b} = opp (iterate opp d1 f) (iterate opp d2 f)" (is "_ = ?prev")
10.1453          unfolding * apply(rule operativeD(2)) using goal1(3) using kc(4) by auto
10.1454 -      also have "iterate opp d1 f = iterate opp d (\<lambda>l. f(l \<inter> {x. x\$\$k \<le> c}))"
10.1455 +      also have "iterate opp d1 f = iterate opp d (\<lambda>l. f(l \<inter> {x. x\<bullet>k \<le> c}))"
10.1456          unfolding d1_def apply(rule iterate_nonzero_image_lemma[unfolded o_def])
10.1457          unfolding empty_as_interval apply(rule goal1 division_of_finite operativeD[OF goal1(3)])+
10.1458          unfolding empty_as_interval[THEN sym] apply(rule content_empty)
10.1459 -      proof(rule,rule,rule,erule conjE) fix l y assume as:"l \<in> d" "y \<in> d" "l \<inter> {x. x \$\$ k \<le> c} = y \<inter> {x. x \$\$ k \<le> c}" "l \<noteq> y"
10.1460 +      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"
10.1461          from division_ofD(4)[OF goal1(4) this(1)] guess u v apply-by(erule exE)+ note l=this
10.1462 -        show "f (l \<inter> {x. x \$\$ k \<le> c}) = neutral opp" unfolding l interval_split[OF kc(4)]
10.1463 +        show "f (l \<inter> {x. x \<bullet> k \<le> c}) = neutral opp" unfolding l interval_split[OF kc(4)]
10.1464            apply(rule operativeD(1) goal1)+ unfolding interval_split[THEN sym,OF kc(4)] apply(rule division_split_left_inj)
10.1465            apply(rule goal1) unfolding l[THEN sym] apply(rule as(1),rule as(2)) by(rule kc(4) as)+
10.1466 -      qed also have "iterate opp d2 f = iterate opp d (\<lambda>l. f(l \<inter> {x. x\$\$k \<ge> c}))"
10.1467 +      qed also have "iterate opp d2 f = iterate opp d (\<lambda>l. f(l \<inter> {x. x\<bullet>k \<ge> c}))"
10.1468          unfolding d2_def apply(rule iterate_nonzero_image_lemma[unfolded o_def])
10.1469          unfolding empty_as_interval apply(rule goal1 division_of_finite operativeD[OF goal1(3)])+
10.1470          unfolding empty_as_interval[THEN sym] apply(rule content_empty)
10.1471 -      proof(rule,rule,rule,erule conjE) fix l y assume as:"l \<in> d" "y \<in> d" "l \<inter> {x. c \<le> x \$\$ k} = y \<inter> {x. c \<le> x \$\$ k}" "l \<noteq> y"
10.1472 +      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"
10.1473          from division_ofD(4)[OF goal1(4) this(1)] guess u v apply-by(erule exE)+ note l=this
10.1474 -        show "f (l \<inter> {x. x \$\$ k \<ge> c}) = neutral opp" unfolding l interval_split[OF kc(4)]
10.1475 +        show "f (l \<inter> {x. x \<bullet> k \<ge> c}) = neutral opp" unfolding l interval_split[OF kc(4)]
10.1476            apply(rule operativeD(1) goal1)+ unfolding interval_split[THEN sym,OF kc(4)] apply(rule division_split_right_inj)
10.1477            apply(rule goal1) unfolding l[THEN sym] apply(rule as(1),rule as(2)) by(rule as kc(4))+
10.1478 -      qed also have *:"\<forall>x\<in>d. f x = opp (f (x \<inter> {x. x \$\$ k \<le> c})) (f (x \<inter> {x. c \<le> x \$\$ k}))"
10.1479 +      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}))"
10.1480          unfolding forall_in_division[OF goal1(4)] apply(rule,rule,rule,rule operativeD(2)) using goal1(3) kc by auto
10.1481 -      have "opp (iterate opp d (\<lambda>l. f (l \<inter> {x. x \$\$ k \<le> c}))) (iterate opp d (\<lambda>l. f (l \<inter> {x. c \<le> x \$\$ k})))
10.1482 +      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})))
10.1483          = iterate opp d f" apply(subst(3) iterate_eq[OF _ *[rule_format]]) prefer 3
10.1484          apply(rule iterate_op[THEN sym]) using goal1 by auto
10.1485        finally show ?thesis by auto
10.1486 @@ -2754,31 +2678,34 @@
10.1487  subsection {* Similar theorems about relationship among components. *}
10.1488
10.1489  lemma rsum_component_le: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
10.1490 -  assumes "p tagged_division_of {a..b}"  "\<forall>x\<in>{a..b}. (f x)\$\$i \<le> (g x)\$\$i"
10.1491 -  shows "(setsum (\<lambda>(x,k). content k *\<^sub>R f x) p)\$\$i \<le> (setsum (\<lambda>(x,k). content k *\<^sub>R g x) p)\$\$i"
10.1492 -  unfolding  euclidean_component_setsum apply(rule setsum_mono) apply safe
10.1493 +  assumes "p tagged_division_of {a..b}"  "\<forall>x\<in>{a..b}. (f x)\<bullet>i \<le> (g x)\<bullet>i"
10.1494 +  shows "(setsum (\<lambda>(x,k). content k *\<^sub>R f x) p)\<bullet>i \<le> (setsum (\<lambda>(x,k). content k *\<^sub>R g x) p)\<bullet>i"
10.1495 +  unfolding inner_setsum_left apply(rule setsum_mono) apply safe
10.1496  proof- fix a b assume ab:"(a,b) \<in> p" note assm = tagged_division_ofD(2-4)[OF assms(1) ab]
10.1497    from this(3) guess u v apply-by(erule exE)+ note b=this
10.1498 -  show "(content b *\<^sub>R f a) \$\$ i \<le> (content b *\<^sub>R g a) \$\$ i" unfolding b
10.1499 -    unfolding euclidean_simps real_scaleR_def apply(rule mult_left_mono)
10.1500 +  show "(content b *\<^sub>R f a) \<bullet> i \<le> (content b *\<^sub>R g a) \<bullet> i" unfolding b
10.1501 +    unfolding inner_simps real_scaleR_def apply(rule mult_left_mono)
10.1502      defer apply(rule content_pos_le,rule assms(2)[rule_format]) using assm by auto qed
10.1503
10.1504 -lemma has_integral_component_le: fixes f g::"'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
10.1505 -  assumes "(f has_integral i) s" "(g has_integral j) s"  "\<forall>x\<in>s. (f x)\$\$k \<le> (g x)\$\$k"
10.1506 -  shows "i\$\$k \<le> j\$\$k"
10.1507 +lemma has_integral_component_le:
10.1508 +  fixes f g::"'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
10.1509 +  assumes k: "k \<in> Basis"
10.1510 +  assumes "(f has_integral i) s" "(g has_integral j) s"  "\<forall>x\<in>s. (f x)\<bullet>k \<le> (g x)\<bullet>k"
10.1511 +  shows "i\<bullet>k \<le> j\<bullet>k"
10.1512  proof -
10.1513    have lem:"\<And>a b i (j::'b). \<And>g f::'a \<Rightarrow> 'b. (f has_integral i) ({a..b}) \<Longrightarrow>
10.1514 -    (g has_integral j) ({a..b}) \<Longrightarrow> \<forall>x\<in>{a..b}. (f x)\$\$k \<le> (g x)\$\$k \<Longrightarrow> i\$\$k \<le> j\$\$k"
10.1515 +    (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"
10.1516    proof (rule ccontr)
10.1517      case goal1
10.1518 -    then have *: "0 < (i\$\$k - j\$\$k) / 3" by auto
10.1519 +    then have *: "0 < (i\<bullet>k - j\<bullet>k) / 3" by auto
10.1520      guess d1 using goal1(1)[unfolded has_integral,rule_format,OF *] apply-by(erule exE conjE)+ note d1=this[rule_format]
10.1521      guess d2 using goal1(2)[unfolded has_integral,rule_format,OF *] apply-by(erule exE conjE)+ note d2=this[rule_format]
10.1522      guess p using fine_division_exists[OF gauge_inter[OF d1(1) d2(1)], of a b] unfolding fine_inter .
10.1523 -    note p = this(1) conjunctD2[OF this(2)]  note le_less_trans[OF component_le_norm, of _ _ k] term g
10.1524 +    note p = this(1) conjunctD2[OF this(2)]
10.1525 +    note le_less_trans[OF Basis_le_norm[OF k]]
10.1526      note this[OF d1(2)[OF conjI[OF p(1,2)]]] this[OF d2(2)[OF conjI[OF p(1,3)]]]
10.1527      thus False
10.1528 -      unfolding euclidean_simps
10.1529 +      unfolding inner_simps
10.1530        using rsum_component_le[OF p(1) goal1(3)]
10.1531        by (simp add: abs_real_def split: split_if_asm)
10.1532    qed let ?P = "\<exists>a b. s = {a..b}"
10.1533 @@ -2787,8 +2714,9 @@
10.1534        show ?thesis apply(rule lem) using assms[unfolded s] by auto
10.1535      qed auto } assume as:"\<not> ?P"
10.1536    { presume "\<not> ?thesis \<Longrightarrow> False" thus ?thesis by auto }
10.1537 -  assume "\<not> i\$\$k \<le> j\$\$k" hence ij:"(i\$\$k - j\$\$k) / 3 > 0" by auto
10.1538 -  note has_integral_altD[OF _ as this] from this[OF assms(1)] this[OF assms(2)] guess B1 B2 . note B=this[rule_format]
10.1539 +  assume "\<not> i\<bullet>k \<le> j\<bullet>k" hence ij:"(i\<bullet>k - j\<bullet>k) / 3 > 0" by auto
10.1540 +  note has_integral_altD[OF _ as this]
10.1541 +  from this[OF assms(2)] this[OF assms(3)] guess B1 B2 . note B=this[rule_format]
10.1542    have "bounded (ball 0 B1 \<union> ball (0::'a) B2)" unfolding bounded_Un by(rule conjI bounded_ball)+
10.1543    from bounded_subset_closed_interval[OF this] guess a b apply- by(erule exE)+
10.1544    note ab = conjunctD2[OF this[unfolded Un_subset_iff]]
10.1545 @@ -2796,69 +2724,50 @@
10.1546    guess w2 using B(4)[OF ab(2)] .. note w2=conjunctD2[OF this]
10.1547    have *:"\<And>w1 w2 j i::real .\<bar>w1 - i\<bar> < (i - j) / 3 \<Longrightarrow> \<bar>w2 - j\<bar> < (i - j) / 3 \<Longrightarrow> w1 \<le> w2 \<Longrightarrow> False"
10.1548      by (simp add: abs_real_def split: split_if_asm)
10.1549 -  note le_less_trans[OF component_le_norm[of _ k]] note this[OF w1(2)] this[OF w2(2)] moreover
10.1550 -  have "w1\$\$k \<le> w2\$\$k" apply(rule lem[OF w1(1) w2(1)]) using assms by auto ultimately
10.1551 -  show False unfolding euclidean_simps by(rule *) qed
10.1552 +  note le_less_trans[OF Basis_le_norm[OF k]] note this[OF w1(2)] this[OF w2(2)] moreover
10.1553 +  have "w1\<bullet>k \<le> w2\<bullet>k" apply(rule lem[OF w1(1) w2(1)]) using assms by auto ultimately
10.1554 +  show False unfolding inner_simps by(rule *)
10.1555 +qed
10.1556
10.1557  lemma integral_component_le: fixes g f::"'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
10.1558 -  assumes "f integrable_on s" "g integrable_on s"  "\<forall>x\<in>s. (f x)\$\$k \<le> (g x)\$\$k"
10.1559 -  shows "(integral s f)\$\$k \<le> (integral s g)\$\$k"
10.1560 +  assumes "k\<in>Basis" "f integrable_on s" "g integrable_on s"  "\<forall>x\<in>s. (f x)\<bullet>k \<le> (g x)\<bullet>k"
10.1561 +  shows "(integral s f)\<bullet>k \<le> (integral s g)\<bullet>k"
10.1562    apply(rule has_integral_component_le) using integrable_integral assms by auto
10.1563
10.1564 -(*lemma has_integral_dest_vec1_le: fixes f::"'a::ordered_euclidean_space \<Rightarrow> real^1"
10.1565 -  assumes "(f has_integral i) s"  "(g has_integral j) s" "\<forall>x\<in>s. f x \<le> g x"
10.1566 -  shows "dest_vec1 i \<le> dest_vec1 j" apply(rule has_integral_component_le[OF assms(1-2)])
10.1567 -  using assms(3) unfolding vector_le_def by auto
10.1568 -
10.1569 -lemma integral_dest_vec1_le: fixes f::"real^'n \<Rightarrow> real^1"
10.1570 -  assumes "f integrable_on s" "g integrable_on s" "\<forall>x\<in>s. f x \<le> g x"
10.1571 -  shows "dest_vec1(integral s f) \<le> dest_vec1(integral s g)"
10.1572 -  apply(rule has_integral_dest_vec1_le) apply(rule_tac[1-2] integrable_integral) using assms by auto*)
10.1573 -
10.1574  lemma has_integral_component_nonneg: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
10.1575 -  assumes "(f has_integral i) s" "\<forall>x\<in>s. 0 \<le> (f x)\$\$k" shows "0 \<le> i\$\$k"
10.1576 -  using has_integral_component_le[OF has_integral_0 assms(1)] using assms(2-) by auto
10.1577 +  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"
10.1578 +  using has_integral_component_le[OF assms(1) has_integral_0 assms(2)] using assms(3-) by auto
10.1579
10.1580  lemma integral_component_nonneg: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
10.1581 -  assumes "f integrable_on s" "\<forall>x\<in>s. 0 \<le> (f x)\$\$k" shows "0 \<le> (integral s f)\$\$k"
10.1582 +  assumes "k\<in>Basis" "f integrable_on s" "\<forall>x\<in>s. 0 \<le> (f x)\<bullet>k" shows "0 \<le> (integral s f)\<bullet>k"
10.1583    apply(rule has_integral_component_nonneg) using assms by auto
10.1584
10.1585 -(*lemma has_integral_dest_vec1_nonneg: fixes f::"real^'n \<Rightarrow> real^1"
10.1586 -  assumes "(f has_integral i) s" "\<forall>x\<in>s. 0 \<le> f x" shows "0 \<le> i"
10.1587 -  using has_integral_component_nonneg[OF assms(1), of 1]
10.1588 -  using assms(2) unfolding vector_le_def by auto
10.1589 -
10.1590 -lemma integral_dest_vec1_nonneg: fixes f::"real^'n \<Rightarrow> real^1"
10.1591 -  assumes "f integrable_on s" "\<forall>x\<in>s. 0 \<le> f x" shows "0 \<le> integral s f"
10.1592 -  apply(rule has_integral_dest_vec1_nonneg) using assms by auto*)
10.1593 -
10.1594  lemma has_integral_component_neg: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::ordered_euclidean_space"
10.1595 -  assumes "(f has_integral i) s" "\<forall>x\<in>s. (f x)\$\$k \<le> 0"shows "i\$\$k \<le> 0"
10.1596 -  using has_integral_component_le[OF assms(1) has_integral_0] assms(2-) by auto
10.1597 -
10.1598 -(*lemma has_integral_dest_vec1_neg: fixes f::"real^'n \<Rightarrow> real^1"
10.1599 -  assumes "(f has_integral i) s" "\<forall>x\<in>s. f x \<le> 0" shows "i \<le> 0"
10.1600 -  using has_integral_component_neg[OF assms(1),of 1] using assms(2) by auto*)
10.1601 -
10.1602 -lemma has_integral_component_lbound: fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
10.1603 -  assumes "(f has_integral i) {a..b}"  "\<forall>x\<in>{a..b}. B \<le> f(x)\$\$k" "k<DIM('b)" shows "B * content {a..b} \<le> i\$\$k"
10.1604 -  using has_integral_component_le[OF has_integral_const assms(1),of "(\<chi>\<chi> i. B)::'b" k] assms(2-)
10.1605 -  unfolding euclidean_simps euclidean_lambda_beta'[OF assms(3)] by(auto simp add:field_simps)
10.1606 -
10.1607 -lemma has_integral_component_ubound: fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
10.1608 -  assumes "(f has_integral i) {a..b}" "\<forall>x\<in>{a..b}. f x\$\$k \<le> B" "k<DIM('b)"
10.1609 -  shows "i\$\$k \<le> B * content({a..b})"
10.1610 -  using has_integral_component_le[OF assms(1) has_integral_const, of k "\<chi>\<chi> i. B"]
10.1611 -  unfolding euclidean_simps euclidean_lambda_beta'[OF assms(3)] using assms(2) by(auto simp add:field_simps)
10.1612 +  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"
10.1613 +  using has_integral_component_le[OF assms(1,2) has_integral_0] assms(2-) by auto
10.1614 +
10.1615 +lemma has_integral_component_lbound:
10.1616 +  fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
10.1617 +  assumes "(f has_integral i) {a..b}"  "\<forall>x\<in>{a..b}. B \<le> f(x)\<bullet>k" "k\<in>Basis"
10.1618 +  shows "B * content {a..b} \<le> i\<bullet>k"
10.1619 +  using has_integral_component_le[OF assms(3) has_integral_const assms(1),of "(\<Sum>i\<in>Basis. B *\<^sub>R i)::'b"] assms(2-)
10.1620 +  by (auto simp add:field_simps)
10.1621 +
10.1622 +lemma has_integral_component_ubound:
10.1623 +  fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
10.1624 +  assumes "(f has_integral i) {a..b}" "\<forall>x\<in>{a..b}. f x\<bullet>k \<le> B" "k\<in>Basis"
10.1625 +  shows "i\<bullet>k \<le> B * content({a..b})"
10.1626 +  using has_integral_component_le[OF assms(3,1) has_integral_const, of "\<Sum>i\<in>Basis. B *\<^sub>R i"]  assms(2-)
10.1628
10.1629  lemma integral_component_lbound: fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
10.1630 -  assumes "f integrable_on {a..b}" "\<forall>x\<in>{a..b}. B \<le> f(x)\$\$k" "k<DIM('b)"
10.1631 -  shows "B * content({a..b}) \<le> (integral({a..b}) f)\$\$k"
10.1632 +  assumes "f integrable_on {a..b}" "\<forall>x\<in>{a..b}. B \<le> f(x)\<bullet>k" "k\<in>Basis"
10.1633 +  shows "B * content({a..b}) \<le> (integral({a..b}) f)\<bullet>k"
10.1634    apply(rule has_integral_component_lbound) using assms unfolding has_integral_integral by auto
10.1635
10.1636  lemma integral_component_ubound: fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
10.1637 -  assumes "f integrable_on {a..b}" "\<forall>x\<in>{a..b}. f(x)\$\$k \<le> B" "k<DIM('b)"
10.1638 -  shows "(integral({a..b}) f)\$\$k \<le> B * content({a..b})"
10.1639 +  assumes "f integrable_on {a..b}" "\<forall>x\<in>{a..b}. f(x)\<bullet>k \<le> B" "k\<in>Basis"
10.1640 +  shows "(integral({a..b}) f)\<bullet>k \<le> B * content({a..b})"
10.1641    apply(rule has_integral_component_ubound) using assms unfolding has_integral_integral by auto
10.1642
10.1643  subsection {* Uniform limit of integrable functions is integrable. *}
10.1644 @@ -2949,68 +2858,76 @@
10.1645    apply(rule iterate_nonzero_image_lemma) apply(rule assms monoidal_monoid)+
10.1647
10.1648 -lemma interval_doublesplit:  fixes a::"'a::ordered_euclidean_space" assumes "k<DIM('a)"
10.1649 -  shows "{a..b} \<inter> {x . abs(x\$\$k - c) \<le> (e::real)} =
10.1650 -  {(\<chi>\<chi> i. if i = k then max (a\$\$k) (c - e) else a\$\$i) .. (\<chi>\<chi> i. if i = k then min (b\$\$k) (c + e) else b\$\$i)}"
10.1651 +lemma interval_doublesplit:  fixes a::"'a::ordered_euclidean_space" assumes "k\<in>Basis"
10.1652 +  shows "{a..b} \<inter> {x . abs(x\<bullet>k - c) \<le> (e::real)} =
10.1653 +  {(\<Sum>i\<in>Basis. (if i = k then max (a\<bullet>k) (c - e) else a\<bullet>i) *\<^sub>R i) ..
10.1654 +   (\<Sum>i\<in>Basis. (if i = k then min (b\<bullet>k) (c + e) else b\<bullet>i) *\<^sub>R i)}"
10.1655  proof- have *:"\<And>x c e::real. abs(x - c) \<le> e \<longleftrightarrow> x \<ge> c - e \<and> x \<le> c + e" by auto
10.1656    have **:"\<And>s P Q. s \<inter> {x. P x \<and> Q x} = (s \<inter> {x. Q x}) \<inter> {x. P x}" by blast
10.1657    show ?thesis unfolding * ** interval_split[OF assms] by(rule refl) qed
10.1658
10.1659 -lemma division_doublesplit: fixes a::"'a::ordered_euclidean_space" assumes "p division_of {a..b}" and k:"k<DIM('a)"
10.1660 -  shows "{l \<inter> {x. abs(x\$\$k - c) \<le> e} |l. l \<in> p \<and> l \<inter> {x. abs(x\$\$k - c) \<le> e} \<noteq> {}} division_of ({a..b} \<inter> {x. abs(x\$\$k - c) \<le> e})"
10.1661 +lemma division_doublesplit: fixes a::"'a::ordered_euclidean_space" assumes "p division_of {a..b}" and k:"k\<in>Basis"
10.1662 +  shows "{l \<inter> {x. abs(x\<bullet>k - c) \<le> e} |l. l \<in> p \<and> l \<inter> {x. abs(x\<bullet>k - c) \<le> e} \<noteq> {}} division_of ({a..b} \<inter> {x. abs(x\<bullet>k - c) \<le> e})"
10.1663  proof- have *:"\<And>x c. abs(x - c) \<le> e \<longleftrightarrow> x \<ge> c - e \<and> x \<le> c + e" by auto
10.1664    have **:"\<And>p q p' q'. p division_of q \<Longrightarrow> p = p' \<Longrightarrow> q = q' \<Longrightarrow> p' division_of q'" by auto
10.1665    note division_split(1)[OF assms, where c="c+e",unfolded interval_split[OF k]]
10.1666    note division_split(2)[OF this, where c="c-e" and k=k,OF k]
10.1667    thus ?thesis apply(rule **) using k apply- unfolding interval_doublesplit unfolding * unfolding interval_split interval_doublesplit
10.1668      apply(rule set_eqI) unfolding mem_Collect_eq apply rule apply(erule conjE exE)+ apply(rule_tac x=la in exI) defer
10.1669 -    apply(erule conjE exE)+ apply(rule_tac x="l \<inter> {x. c + e \<ge> x \$\$ k}" in exI) apply rule defer apply rule
10.1670 +    apply(erule conjE exE)+ apply(rule_tac x="l \<inter> {x. c + e \<ge> x \<bullet> k}" in exI) apply rule defer apply rule
10.1671      apply(rule_tac x=l in exI) by blast+ qed
10.1672
10.1673 -lemma content_doublesplit: fixes a::"'a::ordered_euclidean_space" assumes "0 < e" and k:"k<DIM('a)"
10.1674 -  obtains d where "0 < d" "content({a..b} \<inter> {x. abs(x\$\$k - c) \<le> d}) < e"
10.1675 +lemma content_doublesplit: fixes a::"'a::ordered_euclidean_space" assumes "0 < e" and k:"k\<in>Basis"
10.1676 +  obtains d where "0 < d" "content({a..b} \<inter> {x. abs(x\<bullet>k - c) \<le> d}) < e"
10.1677  proof(cases "content {a..b} = 0")
10.1678    case True show ?thesis apply(rule that[of 1]) defer unfolding interval_doublesplit[OF k]
10.1679      apply(rule le_less_trans[OF content_subset]) defer apply(subst True)
10.1680      unfolding interval_doublesplit[THEN sym,OF k] using assms by auto
10.1681 -next case False def d \<equiv> "e / 3 / setprod (\<lambda>i. b\$\$i - a\$\$i) ({..<DIM('a)} - {k})"
10.1682 +next case False def d \<equiv> "e / 3 / setprod (\<lambda>i. b\<bullet>i - a\<bullet>i) (Basis - {k})"
10.1683    note False[unfolded content_eq_0 not_ex not_le, rule_format]
10.1684 -  hence "\<And>x. x<DIM('a) \<Longrightarrow> b\$\$x > a\$\$x" by(auto simp add:not_le)
10.1685 -  hence prod0:"0 < setprod (\<lambda>i. b\$\$i - a\$\$i) ({..<DIM('a)} - {k})" apply-apply(rule setprod_pos) by(auto simp add:field_simps)
10.1686 +  hence "\<And>x. x\<in>Basis \<Longrightarrow> b\<bullet>x > a\<bullet>x" by(auto simp add:not_le)
10.1687 +  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)
10.1688    hence "d > 0" unfolding d_def using assms by(auto simp add:field_simps) thus ?thesis
10.1689 -  proof(rule that[of d]) have *:"{..<DIM('a)} = insert k ({..<DIM('a)} - {k})" using k by auto
10.1690 -    have **:"{a..b} \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d} \<noteq> {} \<Longrightarrow>
10.1691 -      (\<Prod>i\<in>{..<DIM('a)} - {k}. interval_upperbound ({a..b} \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d}) \$\$ i
10.1692 -      - interval_lowerbound ({a..b} \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d}) \$\$ i)
10.1693 -      = (\<Prod>i\<in>{..<DIM('a)} - {k}. b\$\$i - a\$\$i)" apply(rule setprod_cong,rule refl)
10.1694 +  proof(rule that[of d]) have *:"Basis = insert k (Basis - {k})" using k by auto
10.1695 +    have **:"{a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {} \<Longrightarrow>
10.1696 +      (\<Prod>i\<in>Basis - {k}. interval_upperbound ({a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<bullet> i
10.1697 +      - interval_lowerbound ({a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<bullet> i)
10.1698 +      = (\<Prod>i\<in>Basis - {k}. b\<bullet>i - a\<bullet>i)" apply(rule setprod_cong,rule refl)
10.1699        unfolding interval_doublesplit[OF k] apply(subst interval_bounds) defer apply(subst interval_bounds)
10.1700        unfolding interval_eq_empty not_ex not_less by auto
10.1701 -    show "content ({a..b} \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d}) < e" apply(cases) unfolding content_def apply(subst if_P,assumption,rule assms)
10.1702 +    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)
10.1703        unfolding if_not_P apply(subst *) apply(subst setprod_insert) unfolding **
10.1704        unfolding interval_doublesplit[OF k] interval_eq_empty not_ex not_less prefer 3
10.1705 -      apply(subst interval_bounds) defer apply(subst interval_bounds) unfolding euclidean_lambda_beta'[OF k] if_P[OF refl]
10.1706 -    proof- have "(min (b \$\$ k) (c + d) - max (a \$\$ k) (c - d)) \<le> 2 * d" by auto
10.1707 -      also have "... < e / (\<Prod>i\<in>{..<DIM('a)} - {k}. b \$\$ i - a \$\$ i)" unfolding d_def using assms prod0 by(auto simp add:field_simps)
10.1708 -      finally show "(min (b \$\$ k) (c + d) - max (a \$\$ k) (c - d)) * (\<Prod>i\<in>{..<DIM('a)} - {k}. b \$\$ i - a \$\$ i) < e"
10.1709 -        unfolding pos_less_divide_eq[OF prod0] . qed auto qed qed
10.1710 -
10.1711 -lemma negligible_standard_hyperplane[intro]: fixes type::"'a::ordered_euclidean_space" assumes k:"k<DIM('a)"
10.1712 -  shows "negligible {x::'a. x\$\$k = (c::real)}"
10.1713 +      apply(subst interval_bounds) defer apply(subst interval_bounds)
10.1714 +      apply (simp_all only: k inner_setsum_left_Basis simp_thms if_P cong: bex_cong ball_cong)
10.1715 +    proof -
10.1716 +      have "(min (b \<bullet> k) (c + d) - max (a \<bullet> k) (c - d)) \<le> 2 * d" by auto
10.1717 +      also have "... < e / (\<Prod>i\<in>Basis - {k}. b \<bullet> i - a \<bullet> i)" unfolding d_def using assms prod0 by(auto simp add:field_simps)
10.1718 +      finally show "(min (b \<bullet> k) (c + d) - max (a \<bullet> k) (c - d)) * (\<Prod>i\<in>Basis - {k}. b \<bullet> i - a \<bullet> i) < e"
10.1719 +        unfolding pos_less_divide_eq[OF prod0] .
10.1720 +    qed auto
10.1721 +  qed
10.1722 +qed
10.1723 +
10.1724 +lemma negligible_standard_hyperplane[intro]:
10.1725 +  fixes k :: "'a::ordered_euclidean_space"
10.1726 +  assumes k: "k \<in> Basis"
10.1727 +  shows "negligible {x. x\<bullet>k = c}"
10.1728    unfolding negligible_def has_integral apply(rule,rule,rule,rule)
10.1729  proof-
10.1730    case goal1 from content_doublesplit[OF this k,of a b c] guess d . note d=this
10.1731 -  let ?i = "indicator {x::'a. x\$\$k = c} :: 'a\<Rightarrow>real"
10.1732 +  let ?i = "indicator {x::'a. x\<bullet>k = c} :: 'a\<Rightarrow>real"
10.1733    show ?case apply(rule_tac x="\<lambda>x. ball x d" in exI) apply(rule,rule gauge_ball,rule d)
10.1734    proof(rule,rule) fix p assume p:"p tagged_division_of {a..b} \<and> (\<lambda>x. ball x d) fine p"
10.1735 -    have *:"(\<Sum>(x, ka)\<in>p. content ka *\<^sub>R ?i x) = (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. abs(x\$\$k - c) \<le> d}) *\<^sub>R ?i x)"
10.1736 +    have *:"(\<Sum>(x, ka)\<in>p. content ka *\<^sub>R ?i x) = (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. abs(x\<bullet>k - c) \<le> d}) *\<^sub>R ?i x)"
10.1737        apply(rule setsum_cong2) unfolding split_paired_all real_scaleR_def mult_cancel_right split_conv
10.1738        apply(cases,rule disjI1,assumption,rule disjI2)
10.1739 -    proof- fix x l assume as:"(x,l)\<in>p" "?i x \<noteq> 0" hence xk:"x\$\$k = c" unfolding indicator_def apply-by(rule ccontr,auto)
10.1740 -      show "content l = content (l \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d})" apply(rule arg_cong[where f=content])
10.1741 +    proof- fix x l assume as:"(x,l)\<in>p" "?i x \<noteq> 0" hence xk:"x\<bullet>k = c" unfolding indicator_def apply-by(rule ccontr,auto)
10.1742 +      show "content l = content (l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d})" apply(rule arg_cong[where f=content])
10.1743          apply(rule set_eqI,rule,rule) unfolding mem_Collect_eq
10.1744        proof- fix y assume y:"y\<in>l" note p[THEN conjunct2,unfolded fine_def,rule_format,OF as(1),unfolded split_conv]
10.1745 -        note this[unfolded subset_eq mem_ball dist_norm,rule_format,OF y] note le_less_trans[OF component_le_norm[of _ k] this]
10.1746 -        thus "\<bar>y \$\$ k - c\<bar> \<le> d" unfolding euclidean_simps xk by auto
10.1747 +        note this[unfolded subset_eq mem_ball dist_norm,rule_format,OF y] note le_less_trans[OF Basis_le_norm[OF k] this]
10.1748 +        thus "\<bar>y \<bullet> k - c\<bar> \<le> d" unfolding inner_simps xk by auto
10.1749        qed auto qed
10.1750      note p'= tagged_division_ofD[OF p[THEN conjunct1]] and p''=division_of_tagged_division[OF p[THEN conjunct1]]
10.1751      show "norm ((\<Sum>(x, ka)\<in>p. content ka *\<^sub>R ?i x) - 0) < e" unfolding diff_0_right * unfolding real_scaleR_def real_norm_def
10.1752 @@ -3018,33 +2935,33 @@
10.1753        apply(rule mult_nonneg_nonneg) apply(drule p'(4)) apply(erule exE)+ apply(rule_tac b=b in back_subst)
10.1754        prefer 2 apply(subst(asm) eq_commute) apply assumption
10.1755        apply(subst interval_doublesplit[OF k]) apply(rule content_pos_le) apply(rule indicator_pos_le)
10.1756 -    proof- have "(\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d}) * ?i x) \<le> (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d}))"
10.1757 +    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}))"
10.1758          apply(rule setsum_mono) unfolding split_paired_all split_conv
10.1759          apply(rule mult_right_le_one_le) apply(drule p'(4)) by(auto simp add:interval_doublesplit[OF k])
10.1760        also have "... < e" apply(subst setsum_over_tagged_division_lemma[OF p[THEN conjunct1]])
10.1761 -      proof- case goal1 have "content ({u..v} \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d}) \<le> content {u..v}"
10.1762 +      proof- case goal1 have "content ({u..v} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<le> content {u..v}"
10.1763            unfolding interval_doublesplit[OF k] apply(rule content_subset) unfolding interval_doublesplit[THEN sym,OF k] by auto
10.1764          thus ?case unfolding goal1 unfolding interval_doublesplit[OF k]
10.1765            by (blast intro: antisym)
10.1766 -      next have *:"setsum content {l \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d} |l. l \<in> snd ` p \<and> l \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d} \<noteq> {}} \<ge> 0"
10.1767 +      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"
10.1768            apply(rule setsum_nonneg,rule) unfolding mem_Collect_eq image_iff apply(erule exE bexE conjE)+ unfolding split_paired_all
10.1769 -        proof- fix x l a b assume as:"x = l \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d}" "(a, b) \<in> p" "l = snd (a, b)"
10.1770 +        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)"
10.1771            guess u v using p'(4)[OF as(2)] apply-by(erule exE)+ note * = this
10.1772            show "content x \<ge> 0" unfolding as snd_conv * interval_doublesplit[OF k] by(rule content_pos_le)
10.1773          qed have **:"norm (1::real) \<le> 1" by auto note division_doublesplit[OF p'' k,unfolded interval_doublesplit[OF k]]
10.1774          note dsum_bound[OF this **,unfolded interval_doublesplit[THEN sym,OF k]]
10.1775          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)]
10.1776 -        from this[unfolded abs_of_nonneg[OF *]] show "(\<Sum>ka\<in>snd ` p. content (ka \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d})) < e"
10.1777 +        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"
10.1778            apply(subst vsum_nonzero_image_lemma[of "snd ` p" content "{}", unfolded o_def,THEN sym])
10.1779            apply(rule finite_imageI p' content_empty)+ unfolding forall_in_division[OF p'']
10.1780          proof(rule,rule,rule,rule,rule,rule,rule,erule conjE) fix m n u v
10.1781 -          assume as:"{m..n} \<in> snd ` p" "{u..v} \<in> snd ` p" "{m..n} \<noteq> {u..v}"  "{m..n} \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d} = {u..v} \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d}"
10.1782 -          have "({m..n} \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d}) \<inter> ({u..v} \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d}) \<subseteq> {m..n} \<inter> {u..v}" by blast
10.1783 +          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}"
10.1784 +          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
10.1785            note interior_mono[OF this, unfolded division_ofD(5)[OF p'' as(1-3)] interior_inter[of "{m..n}"]]
10.1786 -          hence "interior ({m..n} \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d}) = {}" unfolding as Int_absorb by auto
10.1787 -          thus "content ({m..n} \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d}) = 0" unfolding interval_doublesplit[OF k] content_eq_0_interior[THEN sym] .
10.1788 +          hence "interior ({m..n} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) = {}" unfolding as Int_absorb by auto
10.1789 +          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] .
10.1790          qed qed
10.1791 -      finally show "(\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. \<bar>x \$\$ k - c\<bar> \<le> d}) * ?i x) < e" .
10.1792 +      finally show "(\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) * ?i x) < e" .
10.1793      qed qed qed
10.1794
10.1795  subsection {* A technical lemma about "refinement" of division. *}
10.1796 @@ -3224,7 +3141,7 @@
10.1797    using negligible_union by auto
10.1798
10.1799  lemma negligible_sing[intro]: "negligible {a::_::ordered_euclidean_space}"
10.1800 -  using negligible_standard_hyperplane[of 0 "a\$\$0"] by auto
10.1801 +  using negligible_standard_hyperplane[OF SOME_Basis, of "a \<bullet> (SOME i. i \<in> Basis)"] by auto
10.1802
10.1803  lemma negligible_insert[simp]: "negligible(insert a s) \<longleftrightarrow> negligible s"
10.1804    apply(subst insert_is_Un) unfolding negligible_union_eq by auto
10.1805 @@ -3276,11 +3193,20 @@
10.1806  subsection {* In particular, the boundary of an interval is negligible. *}
10.1807
10.1808  lemma negligible_frontier_interval: "negligible({a::'a::ordered_euclidean_space..b} - {a<..<b})"
10.1809 -proof- let ?A = "\<Union>((\<lambda>k. {x. x\$\$k = a\$\$k} \<union> {x::'a. x\$\$k = b\$\$k}) ` {..<DIM('a)})"
10.1810 -  have "{a..b} - {a<..<b} \<subseteq> ?A" apply rule unfolding Diff_iff mem_interval not_all
10.1811 -    apply(erule conjE exE)+ apply(rule_tac X="{x. x \$\$ xa = a \$\$ xa} \<union> {x. x \$\$ xa = b \$\$ xa}" in UnionI)
10.1812 -    apply(erule_tac[!] x=xa in allE) by auto
10.1813 -  thus ?thesis apply-apply(rule negligible_subset[of ?A]) apply(rule negligible_unions[OF finite_imageI]) by auto qed
10.1814 +proof-
10.1815 +  let ?A = "\<Union>((\<lambda>k. {x. x\<bullet>k = a\<bullet>k} \<union> {x::'a. x\<bullet>k = b\<bullet>k}) ` Basis)"
10.1816 +  have "{a..b} - {a<..<b} \<subseteq> ?A"
10.1817 +    apply rule unfolding Diff_iff mem_interval
10.1818 +    apply simp
10.1819 +    apply(erule conjE bexE)+
10.1820 +    apply(rule_tac x=i in bexI)
10.1821 +    by auto
10.1822 +  thus ?thesis
10.1823 +    apply-
10.1824 +    apply(rule negligible_subset[of ?A])
10.1825 +    apply(rule negligible_unions[OF finite_imageI])
10.1826 +    by auto
10.1827 +qed
10.1828
10.1829  lemma has_integral_spike_interior:
10.1830    assumes "\<forall>x\<in>{a<..<b}. g x = f x" "(f has_integral y) ({a..b})" shows "(g has_integral y) ({a..b})"
10.1831 @@ -3309,23 +3235,26 @@
10.1832
10.1833  lemma operative_approximable: assumes "0 \<le> e" fixes f::"'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
10.1834    shows "operative op \<and> (\<lambda>i. \<exists>g. (\<forall>x\<in>i. norm (f x - g (x::'b)) \<le> e) \<and> g integrable_on i)" unfolding operative_def neutral_and
10.1835 -proof safe fix a b::"'b" { assume "content {a..b} = 0"
10.1836 +proof safe
10.1837 +  fix a b::"'b"
10.1838 +  { assume "content {a..b} = 0"
10.1839      thus "\<exists>g. (\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b}"
10.1840        apply(rule_tac x=f in exI) using assms by(auto intro!:integrable_on_null) }
10.1841 -  { fix c k g assume as:"\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e" "g integrable_on {a..b}" and k:"k<DIM('b)"
10.1842 -    show "\<exists>g. (\<forall>x\<in>{a..b} \<inter> {x. x \$\$ k \<le> c}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b} \<inter> {x. x \$\$ k \<le> c}"
10.1843 -      "\<exists>g. (\<forall>x\<in>{a..b} \<inter> {x. c \<le> x \$\$ k}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b} \<inter> {x. c \<le> x \$\$ k}"
10.1844 +  { fix c g and k :: 'b
10.1845 +    assume as:"\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e" "g integrable_on {a..b}" and k:"k\<in>Basis"
10.1846 +    show "\<exists>g. (\<forall>x\<in>{a..b} \<inter> {x. x \<bullet> k \<le> c}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c}"
10.1847 +      "\<exists>g. (\<forall>x\<in>{a..b} \<inter> {x. c \<le> x \<bullet> k}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b} \<inter> {x. c \<le> x \<bullet> k}"
10.1848        apply(rule_tac[!] x=g in exI) using as(1) integrable_split[OF as(2) k] by auto }
10.1849 -  fix c k g1 g2 assume as:"\<forall>x\<in>{a..b} \<inter> {x. x \$\$ k \<le> c}. norm (f x - g1 x) \<le> e" "g1 integrable_on {a..b} \<inter> {x. x \$\$ k \<le> c}"
10.1850 -                          "\<forall>x\<in>{a..b} \<inter> {x. c \<le> x \$\$ k}. norm (f x - g2 x) \<le> e" "g2 integrable_on {a..b} \<inter> {x. c \<le> x \$\$ k}"
10.1851 -  assume k:"k<DIM('b)"
10.1852 -  let ?g = "\<lambda>x. if x\$\$k = c then f x else if x\$\$k \<le> c then g1 x else g2 x"
10.1853 +  fix c k g1 g2 assume as:"\<forall>x\<in>{a..b} \<inter> {x. x \<bullet> k \<le> c}. norm (f x - g1 x) \<le> e" "g1 integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c}"
10.1854 +                          "\<forall>x\<in>{a..b} \<inter> {x. c \<le> x \<bullet> k}. norm (f x - g2 x) \<le> e" "g2 integrable_on {a..b} \<inter> {x. c \<le> x \<bullet> k}"
10.1855 +  assume k:"k\<in>Basis"
10.1856 +  let ?g = "\<lambda>x. if x\<bullet>k = c then f x else if x\<bullet>k \<le> c then g1 x else g2 x"
10.1857    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)
10.1858 -  proof safe case goal1 thus ?case apply- apply(cases "x\$\$k=c", case_tac "x\$\$k < c") using as assms by auto
10.1859 -  next case goal2 presume "?g integrable_on {a..b} \<inter> {x. x \$\$ k \<le> c}" "?g integrable_on {a..b} \<inter> {x. x \$\$ k \<ge> c}"
10.1860 +  proof safe case goal1 thus ?case apply- apply(cases "x\<bullet>k=c", case_tac "x\<bullet>k < c") using as assms by auto
10.1861 +  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}"
10.1862      then guess h1 h2 unfolding integrable_on_def by auto from has_integral_split[OF this k]
10.1863      show ?case unfolding integrable_on_def by auto
10.1864 -  next show "?g integrable_on {a..b} \<inter> {x. x \$\$ k \<le> c}" "?g integrable_on {a..b} \<inter> {x. x \$\$ k \<ge> c}"
10.1865 +  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}"
10.1866        apply(rule_tac[!] integrable_spike[OF negligible_standard_hyperplane[of k c]]) using k as(2,4) by auto qed qed
10.1867
10.1868  lemma approximable_on_division: fixes f::"'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
10.1869 @@ -3355,11 +3284,15 @@
10.1870
10.1871  subsection {* Specialization of additivity to one dimension. *}
10.1872
10.1873 +lemma
10.1874 +  shows real_inner_1_left: "inner 1 x = x"
10.1875 +  and real_inner_1_right: "inner x 1 = x"
10.1876 +  by simp_all
10.1877 +
10.1878  lemma operative_1_lt: assumes "monoidal opp"
10.1879    shows "operative opp f \<longleftrightarrow> ((\<forall>a b. b \<le> a \<longrightarrow> f {a..b::real} = neutral opp) \<and>
10.1880                  (\<forall>a b c. a < c \<and> c < b \<longrightarrow> opp (f{a..c})(f{c..b}) = f {a..b}))"
10.1881 -  unfolding operative_def content_eq_0 DIM_real less_one simp_thms(39,41) Eucl_real_simps
10.1882 -    (* The dnf_simps simplify "\<exists> x. x= _ \<and> _" and "\<forall>k. k = _ \<longrightarrow> _" *)
10.1883 +  apply (simp add: operative_def content_eq_0 less_one)
10.1884  proof safe fix a b c::"real" assume as:"\<forall>a b c. f {a..b} = opp (f ({a..b} \<inter> {x. x \<le> c}))
10.1885      (f ({a..b} \<inter> {x. c \<le> x}))" "a < c" "c < b"
10.1886      from this(2-) have "{a..b} \<inter> {x. x \<le> c} = {a..c}" "{a..b} \<inter> {x. x \<ge> c} = {c..b}" by auto
10.1887 @@ -3376,10 +3309,11 @@
10.1888        show ?thesis unfolding * apply(subst as(1)[rule_format,of 0 1]) using assms by auto
10.1889      qed
10.1890    next case True hence *:"min (b) c = c" "max a c = c" by auto
10.1891 -    have **:"0 < DIM(real)" by auto
10.1892 -    have ***:"\<And>P Q. (\<chi>\<chi> i. if i = 0 then P i else Q i) = (P 0::real)" apply(subst euclidean_eq)
10.1893 -      apply safe unfolding euclidean_lambda_beta' by auto
10.1894 -    show ?thesis unfolding interval_split[OF **,unfolded Eucl_real_simps(1,3)] unfolding *** *
10.1895 +    have **: "(1::real) \<in> Basis" by simp
10.1896 +    have ***:"\<And>P Q. (\<Sum>i\<in>Basis. (if i = 1 then P i else Q i) *\<^sub>R i) = (P 1::real)"
10.1897 +      by simp
10.1898 +    show ?thesis
10.1899 +      unfolding interval_split[OF **, unfolded real_inner_1_right] unfolding *** *
10.1900      proof(cases "c = a \<or> c = b")
10.1901        case False thus "f {a..b} = opp (f {a..c}) (f {c..b})"
10.1902          apply-apply(subst as(2)[rule_format]) using True by auto
10.1903 @@ -3411,13 +3345,13 @@
10.1904  subsection {* Special case of additivity we need for the FCT. *}
10.1905
10.1906  lemma interval_bound_sing[simp]: "interval_upperbound {a} = a"  "interval_lowerbound {a} = a"
10.1907 -  unfolding interval_upperbound_def interval_lowerbound_def  by auto
10.1908 +  unfolding interval_upperbound_def interval_lowerbound_def by (auto simp: euclidean_representation)
10.1909
10.1910  lemma additive_tagged_division_1: fixes f::"real \<Rightarrow> 'a::real_normed_vector"
10.1911    assumes "a \<le> b" "p tagged_division_of {a..b}"
10.1912    shows "setsum (\<lambda>(x,k). f(interval_upperbound k) - f(interval_lowerbound k)) p = f b - f a"
10.1913  proof- let ?f = "(\<lambda>k::(real) set. if k = {} then 0 else f(interval_upperbound k) - f(interval_lowerbound k))"
10.1914 -  have ***:"\<forall>i<DIM(real). a \$\$ i \<le> b \$\$ i" using assms by auto
10.1915 +  have ***:"\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i" using assms by auto
10.1916    have *:"operative op + ?f" unfolding operative_1_lt[OF monoidal_monoid] interval_eq_empty by auto
10.1917    have **:"{a..b} \<noteq> {}" using assms(1) by auto note operative_tagged_division[OF monoidal_monoid * assms(2)]
10.1918    note * = this[unfolded if_not_P[OF **] interval_bounds[OF ***],THEN sym]
10.1919 @@ -3518,38 +3452,30 @@
10.1920    have "k \<subseteq> \<Union>(s - {k})" apply safe apply(rule *[unfolded closed_limpt,rule_format]) unfolding islimpt_approachable
10.1921    proof safe fix x and e::real assume as:"x\<in>k" "e>0"
10.1922      from k(2)[unfolded k content_eq_0] guess i ..
10.1923 -    hence i:"c\$\$i = d\$\$i" "i<DIM('a)" using s(3)[OF k(1),unfolded k] unfolding interval_ne_empty by auto
10.1924 -    hence xi:"x\$\$i = d\$\$i" using as unfolding k mem_interval by (metis antisym)
10.1925 -    def y \<equiv> "(\<chi>\<chi> j. if j = i then if c\$\$i \<le> (a\$\$i + b\$\$i) / 2 then c\$\$i +
10.1926 -      min e (b\$\$i - c\$\$i) / 2 else c\$\$i - min e (c\$\$i - a\$\$i) / 2 else x\$\$j)::'a"
10.1927 +    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
10.1928 +    hence xi:"x\<bullet>i = d\<bullet>i" using as unfolding k mem_interval by (metis antisym)
10.1929 +    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 +
10.1930 +      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"
10.1931      show "\<exists>x'\<in>\<Union>(s - {k}). x' \<noteq> x \<and> dist x' x < e" apply(rule_tac x=y in bexI)
10.1932      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)
10.1933 -      hence "d \<in> {a..b}" using s(2)[OF k(1)] unfolding k by auto note di = this[unfolded mem_interval,THEN spec[where x=i]]
10.1934 -      hence xyi:"y\$\$i \<noteq> x\$\$i" unfolding y_def unfolding i xi euclidean_lambda_beta'[OF i(2)] if_P[OF refl]
10.1935 -        apply(cases) apply(subst if_P,assumption) unfolding if_not_P not_le using as(2)
10.1936 -        using assms(2)[unfolded content_eq_0] using i(2)
10.1937 -        by (auto simp add: not_le min_def)
10.1938 -      thus "y \<noteq> x" unfolding euclidean_eq[where 'a='a] using i by auto
10.1939 -      have *:"{..<DIM('a)} = insert i ({..<DIM('a)} - {i})" using i by auto
10.1940 -      have "norm (y - x) < e + setsum (\<lambda>i. 0) {..<DIM('a)}" apply(rule le_less_trans[OF norm_le_l1])
10.1941 +      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]]
10.1942 +      hence xyi:"y\<bullet>i \<noteq> x\<bullet>i"
10.1943 +        unfolding y_def i xi using as(2) assms(2)[unfolded content_eq_0] i(2)
10.1944 +        by (auto elim!: ballE[of _ _ i])
10.1945 +      thus "y \<noteq> x" unfolding euclidean_eq_iff[where 'a='a] using i by auto
10.1946 +      have *:"Basis = insert i (Basis - {i})" using i by auto
10.1947 +      have "norm (y - x) < e + setsum (\<lambda>i. 0) Basis" apply(rule le_less_trans[OF norm_le_l1])
10.1948          apply(subst *,subst setsum_insert) prefer 3 apply(rule add_less_le_mono)
10.1949 -      proof- show "\<bar>(y - x) \$\$ i\<bar> < e" unfolding y_def euclidean_simps euclidean_lambda_beta'[OF i(2)] if_P[OF refl]
10.1950 -          apply(cases) apply(subst if_P,assumption) unfolding if_not_P unfolding i xi using di as(2) by auto
10.1951 -        show "(\<Sum>i\<in>{..<DIM('a)} - {i}. \<bar>(y - x) \$\$ i\<bar>) \<le> (\<Sum>i\<in>{..<DIM('a)}. 0)" unfolding y_def by auto
10.1952 +      proof-
10.1953 +        show "\<bar>(y - x) \<bullet> i\<bar> < e"
10.1954 +          using di as(2) y_def i xi by (auto simp: inner_simps)
10.1955 +        show "(\<Sum>i\<in>Basis - {i}. \<bar>(y - x) \<bullet> i\<bar>) \<le> (\<Sum>i\<in>Basis. 0)"
10.1956 +          unfolding y_def by (auto simp: inner_simps)
10.1957        qed auto thus "dist y x < e" unfolding dist_norm by auto
10.1958 -      have "y\<notin>k" unfolding k mem_interval apply rule apply(erule_tac x=i in allE) using xyi unfolding k i xi by auto
10.1959 -      moreover have "y \<in> \<Union>s" unfolding s mem_interval
10.1960 -      proof(rule,rule) note simps = y_def euclidean_lambda_beta' if_not_P
10.1961 -        fix j assume j:"j<DIM('a)" show "a \$\$ j \<le> y \$\$ j \<and> y \$\$ j \<le> b \$\$ j"
10.1962 -        proof(cases "j = i") case False have "x \<in> {a..b}" using s(2)[OF k(1)] as(1) by auto
10.1963 -          thus ?thesis using j apply- unfolding simps if_not_P[OF False] unfolding mem_interval by auto
10.1964 -        next case True note T = this show ?thesis
10.1965 -          proof(cases "c \$\$ i \<le> (a \$\$ i + b \$\$ i) / 2")
10.1966 -            case True show ?thesis unfolding simps if_P[OF T] if_P[OF True] unfolding i
10.1967 -              using True as(2) di apply-apply rule unfolding T by (auto simp add:field_simps)
10.1968 -          next case False thus ?thesis unfolding simps if_P[OF T] if_not_P[OF False] unfolding i
10.1969 -              using True as(2) di apply-apply rule unfolding T by (auto simp add:field_simps)
10.1970 -          qed qed qed
10.1971 +      have "y\<notin>k" unfolding k mem_interval apply rule apply(erule_tac x=i in ballE) using xyi k i xi by auto
10.1972 +      moreover have "y \<in> \<Union>s"
10.1973 +        using set_rev_mp[OF as(1) s(2)[OF k(1)]] as(2) di i unfolding s mem_interval y_def
10.1974 +        by (auto simp: field_simps elim!: ballE[of _ _ i])
10.1975        ultimately show "y \<in> \<Union>(s - {k})" by auto
10.1976      qed qed hence "\<Union>(s - {k}) = {a..b}" unfolding s(6)[THEN sym] by auto
10.1977    hence  "{ka \<in> s - {k}. content ka \<noteq> 0} division_of {a..b}" apply-apply(rule assm(2)[rule_format,OF card refl])
10.1978 @@ -3730,23 +3656,41 @@
10.1979   "content((\<lambda>x::'a::ordered_euclidean_space. m *\<^sub>R x + c) ` {a..b}) = (abs m) ^ DIM('a) * content {a..b}" (is "?l = ?r")
10.1980  proof- { presume *:"{a..b}\<noteq>{} \<Longrightarrow> ?thesis" show ?thesis apply(cases,rule *,assumption)
10.1981        unfolding not_not using content_empty by auto }
10.1982 -  have *:"DIM('a) = card {..<DIM('a)}" by auto
10.1983 -  assume as:"{a..b}\<noteq>{}" show ?thesis proof(cases "m \<ge> 0")
10.1984 -    case True show ?thesis unfolding image_affinity_interval if_not_P[OF as] if_P[OF True]
10.1985 -      unfolding content_closed_interval'[OF as] apply(subst content_closed_interval') defer apply(subst(2) *)
10.1986 -      apply(subst setprod_constant[THEN sym]) apply(rule finite_lessThan) unfolding setprod_timesf[THEN sym]
10.1987 -      apply(rule setprod_cong2) using True as unfolding interval_ne_empty euclidean_simps not_le
10.1988 -      by(auto simp add:field_simps intro:mult_left_mono)
10.1989 -  next case False show ?thesis unfolding image_affinity_interval if_not_P[OF as] if_not_P[OF False]
10.1990 -      unfolding content_closed_interval'[OF as] apply(subst content_closed_interval') defer apply(subst(2) *)
10.1991 -      apply(subst setprod_constant[THEN sym]) apply(rule finite_lessThan) unfolding setprod_timesf[THEN sym]
10.1992 -      apply(rule setprod_cong2) using False as unfolding interval_ne_empty euclidean_simps not_le
10.1993 -      by(auto simp add:field_simps mult_le_cancel_left_neg) qed qed
10.1994 +  assume as: "{a..b}\<noteq>{}"
10.1995 +  show ?thesis
10.1996 +  proof (cases "m \<ge> 0")
10.1997 +    case True
10.1998 +    with as have "{m *\<^sub>R a + c..m *\<^sub>R b + c} \<noteq> {}"
10.1999 +      unfolding interval_ne_empty
10.2000 +      apply (intro ballI)
10.2001 +      apply (erule_tac x=i in ballE)
10.2002 +      apply (auto simp: inner_simps intro!: mult_left_mono)
10.2003 +      done
10.2004 +    moreover from True have *: "\<And>i. (m *\<^sub>R b + c) \<bullet> i - (m *\<^sub>R a + c) \<bullet> i = m *\<^sub>R (b - a) \<bullet> i"
10.2005 +      by (simp add: inner_simps field_simps)
10.2006 +    ultimately show ?thesis
10.2007 +      by (simp add: image_affinity_interval True content_closed_interval'
10.2008 +                    setprod_timesf setprod_constant inner_diff_left)
10.2009 +  next
10.2010 +    case False
10.2011 +    moreover with as have "{m *\<^sub>R b + c..m *\<^sub>R a + c} \<noteq> {}"
10.2012 +      unfolding interval_ne_empty
10.2013 +      apply (intro ballI)
10.2014 +      apply (erule_tac x=i in ballE)
10.2015 +      apply (auto simp: inner_simps intro!: mult_left_mono)
10.2016 +      done
10.2017 +    moreover from False have *: "\<And>i. (m *\<^sub>R a + c) \<bullet> i - (m *\<^sub>R b + c) \<bullet> i = (-m) *\<^sub>R (b - a) \<bullet> i"
10.2018 +      by (simp add: inner_simps field_simps)
10.2019 +    ultimately show ?thesis
10.2020 +      by (simp add: image_affinity_interval content_closed_interval'
10.2021 +                    setprod_timesf[symmetric] setprod_constant[symmetric] inner_diff_left)
10.2022 +  qed
10.2023 +qed
10.2024
10.2025  lemma has_integral_affinity: fixes a::"'a::ordered_euclidean_space" assumes "(f has_integral i) {a..b}" "m \<noteq> 0"
10.2026    shows "((\<lambda>x. f(m *\<^sub>R x + c)) has_integral ((1 / (abs(m) ^ DIM('a))) *\<^sub>R i)) ((\<lambda>x. (1 / m) *\<^sub>R x + -((1 / m) *\<^sub>R c)) ` {a..b})"
10.2027 -  apply(rule has_integral_twiddle,safe) apply(rule zero_less_power) unfolding euclidean_eq[where 'a='a]
10.2028 -  unfolding scaleR_right_distrib euclidean_simps scaleR_scaleR
10.2029 +  apply(rule has_integral_twiddle,safe) apply(rule zero_less_power) unfolding euclidean_eq_iff[where 'a='a]
10.2030 +  unfolding scaleR_right_distrib inner_simps scaleR_scaleR
10.2032    apply(rule continuous_intros)+ apply(rule interval_image_affinity_interval)+ apply(rule content_image_affinity_interval) using assms by auto
10.2033
10.2034 @@ -3757,60 +3701,68 @@
10.2035  subsection {* Special case of stretching coordinate axes separately. *}
10.2036
10.2037  lemma image_stretch_interval:
10.2038 -  "(\<lambda>x. \<chi>\<chi> k. m k * x\$\$k) ` {a..b::'a::ordered_euclidean_space} =
10.2039 -  (if {a..b} = {} then {} else {(\<chi>\<chi> k. min (m(k) * a\$\$k) (m(k) * b\$\$k))::'a ..  (\<chi>\<chi> k. max (m(k) * a\$\$k) (m(k) * b\$\$k))})"
10.2040 -  (is "?l = ?r")
10.2041 -proof(cases "{a..b}={}") case True thus ?thesis unfolding True by auto
10.2042 -next have *:"\<And>P Q. (\<forall>i<DIM('a). P i) \<and> (\<forall>i<DIM('a). Q i) \<longleftrightarrow> (\<forall>i<DIM('a). P i \<and> Q i)" by auto
10.2043 -  case False note ab = this[unfolded interval_ne_empty]
10.2044 -  show ?thesis apply-apply(rule set_eqI)
10.2045 -  proof- fix x::"'a" have **:"\<And>P Q. (\<forall>i<DIM('a). P i = Q i) \<Longrightarrow> (\<forall>i<DIM('a). P i) = (\<forall>i<DIM('a). Q i)" by auto
10.2046 -    show "x \<in> ?l \<longleftrightarrow> x \<in> ?r" unfolding if_not_P[OF False]
10.2047 -      unfolding image_iff mem_interval Bex_def euclidean_simps euclidean_eq[where 'a='a] *
10.2048 -      unfolding imp_conjR[THEN sym] apply(subst euclidean_lambda_beta'') apply(subst lambda_skolem'[THEN sym])
10.2049 -      apply(rule **,rule,rule) unfolding euclidean_lambda_beta'
10.2050 -    proof- fix i assume i:"i<DIM('a)" show "(\<exists>xa. (a \$\$ i \<le> xa \<and> xa \<le> b \$\$ i) \<and> x \$\$ i = m i * xa) =
10.2051 -        (min (m i * a \$\$ i) (m i * b \$\$ i) \<le> x \$\$ i \<and> x \$\$ i \<le> max (m i * a \$\$ i) (m i * b \$\$ i))"
10.2052 -      proof(cases "m i = 0") case True thus ?thesis using ab i by auto
10.2053 -      next case False hence "0 < m i \<or> 0 > m i" by auto thus ?thesis apply-
10.2054 -        proof(erule disjE) assume as:"0 < m i" hence *:"min (m i * a \$\$ i) (m i * b \$\$ i) = m i * a \$\$ i"
10.2055 -            "max (m i * a \$\$ i) (m i * b \$\$ i) = m i * b \$\$ i" using ab i unfolding min_def max_def by auto
10.2056 -          show ?thesis unfolding * apply rule defer apply(rule_tac x="1 / m i * x\$\$i" in exI)
10.2057 -            using as by(auto simp add:field_simps)
10.2058 -        next assume as:"0 > m i" hence *:"max (m i * a \$\$ i) (m i * b \$\$ i) = m i * a \$\$ i"
10.2059 -            "min (m i * a \$\$ i) (m i * b \$\$ i) = m i * b \$\$ i" using ab as i unfolding min_def max_def
10.2060 -            by(auto simp add:field_simps mult_le_cancel_left_neg intro: order_antisym)
10.2061 -          show ?thesis unfolding * apply rule defer apply(rule_tac x="1 / m i * x\$\$i" in exI)
10.2062 -            using as by(auto simp add:field_simps) qed qed qed qed qed
10.2063 -
10.2064 -lemma interval_image_stretch_interval: "\<exists>u v. (\<lambda>x. \<chi>\<chi> k. m k * x\$\$k) ` {a..b::'a::ordered_euclidean_space} = {u..v::'a}"
10.2065 +  "(\<lambda>x. \<Sum>k\<in>Basis. (m k * (x\<bullet>k)) *\<^sub>R k) ` {a..b::'a::ordered_euclidean_space} =
10.2066 +  (if {a..b} = {} then {} else
10.2067 +    {(\<Sum>k\<in>Basis. (min (m k * (a\<bullet>k)) (m k * (b\<bullet>k))) *\<^sub>R k)::'a ..
10.2068 +     (\<Sum>k\<in>Basis. (max (m k * (a\<bullet>k)) (m k * (b\<bullet>k))) *\<^sub>R k)})"
10.2069 +proof cases
10.2070 +  assume *: "{a..b} \<noteq> {}"
10.2071 +  show ?thesis
10.2072 +    unfolding interval_ne_empty if_not_P[OF *]
10.2073 +    apply (simp add: interval image_Collect set_eq_iff euclidean_eq_iff[where 'a='a] ball_conj_distrib[symmetric])
10.2074 +    apply (subst choice_Basis_iff[symmetric])
10.2075 +  proof (intro allI ball_cong refl)
10.2076 +    fix x i :: 'a assume "i \<in> Basis"
10.2077 +    with * have a_le_b: "a \<bullet> i \<le> b \<bullet> i"
10.2078 +      unfolding interval_ne_empty by auto
10.2079 +    show "(\<exists>xa. x \<bullet> i = m i * xa \<and> a \<bullet> i \<le> xa \<and> xa \<le> b \<bullet> i) \<longleftrightarrow>
10.2080 +        min (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) \<le> x \<bullet> i \<and> x \<bullet> i \<le> max (m i * (a \<bullet> i)) (m i * (b \<bullet> i))"
10.2081 +    proof cases
10.2082 +      assume "m i \<noteq> 0"
10.2083 +      moreover then have *: "\<And>a b. a = m i * b \<longleftrightarrow> b = a / m i"
10.2084 +        by (auto simp add: field_simps)
10.2085 +      moreover have
10.2086 +          "min (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) = (if 0 < m i then m i * (a \<bullet> i) else m i * (b \<bullet> i))"
10.2087 +          "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))"
10.2088 +        using a_le_b by (auto simp: min_def max_def mult_le_cancel_left)
10.2089 +      ultimately show ?thesis using a_le_b
10.2090 +        unfolding * by (auto simp add: le_divide_eq divide_le_eq ac_simps)
10.2091 +    qed (insert a_le_b, auto)
10.2092 +  qed
10.2093 +qed simp
10.2094 +
10.2095 +lemma interval_image_stretch_interval:
10.2096 +    "\<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}"
10.2097    unfolding image_stretch_interval by auto
10.2098
10.2099  lemma content_image_stretch_interval:
10.2100 -  "content((\<lambda>x::'a::ordered_euclidean_space. (\<chi>\<chi> k. m k * x\$\$k)::'a) ` {a..b}) = abs(setprod m {..<DIM('a)}) * content({a..b})"
10.2101 +  "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})"
10.2102  proof(cases "{a..b} = {}") case True thus ?thesis
10.2103      unfolding content_def image_is_empty image_stretch_interval if_P[OF True] by auto
10.2104 -next case False hence "(\<lambda>x. (\<chi>\<chi> k. m k * x \$\$ k)::'a) ` {a..b} \<noteq> {}" by auto
10.2105 +next case False hence "(\<lambda>x. (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)::'a) ` {a..b} \<noteq> {}" by auto
10.2106    thus ?thesis using False unfolding content_def image_stretch_interval apply- unfolding interval_bounds' if_not_P
10.2107 -    unfolding abs_setprod setprod_timesf[THEN sym] apply(rule setprod_cong2) unfolding lessThan_iff euclidean_lambda_beta'
10.2108 -  proof- fix i assume i:"i<DIM('a)" have "(m i < 0 \<or> m i > 0) \<or> m i = 0" by auto
10.2109 -    thus "max (m i * a \$\$ i) (m i * b \$\$ i) - min (m i * a \$\$ i) (m i * b \$\$ i) = \<bar>m i\<bar> * (b \$\$ i - a \$\$ i)"
10.2110 +    unfolding abs_setprod setprod_timesf[THEN sym] apply(rule setprod_cong2) unfolding lessThan_iff
10.2111 +  proof (simp only: inner_setsum_left_Basis)
10.2112 +    fix i :: 'a assume i:"i\<in>Basis" have "(m i < 0 \<or> m i > 0) \<or> m i = 0" by auto
10.2113 +    thus "max (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) - min (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) =
10.2114 +        \<bar>m i\<bar> * (b \<bullet> i - a \<bullet> i)"
10.2115        apply-apply(erule disjE)+ unfolding min_def max_def using False[unfolded interval_ne_empty,rule_format,of i] i
10.2116        by(auto simp add:field_simps not_le mult_le_cancel_left_neg mult_le_cancel_left_pos) qed qed
10.2117
10.2118  lemma has_integral_stretch: fixes f::"'a::ordered_euclidean_space => 'b::real_normed_vector"
10.2119 -  assumes "(f has_integral i) {a..b}" "\<forall>k<DIM('a). ~(m k = 0)"
10.2120 -  shows "((\<lambda>x. f(\<chi>\<chi> k. m k * x\$\$k)) has_integral
10.2121 -             ((1/(abs(setprod m {..<DIM('a)}))) *\<^sub>R i)) ((\<lambda>x. (\<chi>\<chi> k. 1/(m k) * x\$\$k)::'a) ` {a..b})"
10.2122 +  assumes "(f has_integral i) {a..b}" "\<forall>k\<in>Basis. ~(m k = 0)"
10.2123 +  shows "((\<lambda>x. f (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)) has_integral
10.2124 +             ((1/(abs(setprod m Basis))) *\<^sub>R i)) ((\<lambda>x. (\<Sum>k\<in>Basis. (1 / m k * (x\<bullet>k))*\<^sub>R k)) ` {a..b})"
10.2125    apply(rule has_integral_twiddle[where f=f]) unfolding zero_less_abs_iff content_image_stretch_interval
10.2126 -  unfolding image_stretch_interval empty_as_interval euclidean_eq[where 'a='a] using assms
10.2127 -proof- show "\<forall>y::'a. continuous (at y) (\<lambda>x. (\<chi>\<chi> k. m k * x \$\$ k)::'a)"
10.2128 +  unfolding image_stretch_interval empty_as_interval euclidean_eq_iff[where 'a='a] using assms
10.2129 +proof- show "\<forall>y::'a. continuous (at y) (\<lambda>x. (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k))"
10.2130     apply(rule,rule linear_continuous_at) unfolding linear_linear
10.2131 -   unfolding linear_def euclidean_simps euclidean_eq[where 'a='a] by(auto simp add:field_simps) qed auto
10.2132 +   unfolding linear_def inner_simps euclidean_eq_iff[where 'a='a] by(auto simp add:field_simps)
10.2133 +qed auto
10.2134
10.2135  lemma integrable_stretch:  fixes f::"'a::ordered_euclidean_space => 'b::real_normed_vector"
10.2136 -  assumes "f integrable_on {a..b}" "\<forall>k<DIM('a). ~(m k = 0)"
10.2137 -  shows "(\<lambda>x::'a. f(\<chi>\<chi> k. m k * x\$\$k)) integrable_on ((\<lambda>x. \<chi>\<chi> k. 1/(m k) * x\$\$k) ` {a..b})"
10.2138 +  assumes "f integrable_on {a..b}" "\<forall>k\<in>Basis. ~(m k = 0)"
10.2139 +  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})"
10.2140    using assms unfolding integrable_on_def apply-apply(erule exE)
10.2141    apply(drule has_integral_stretch,assumption) by auto
10.2142
10.2143 @@ -3856,7 +3808,8 @@
10.2144      show ?thesis proof(cases,rule *,assumption)
10.2145        assume "\<not> a < b" hence "a = b" using assms(1) by auto
10.2146        hence *:"{a .. b} = {b}" "f b - f a = 0" by(auto simp add:  order_antisym)
10.2147 -      show ?thesis unfolding *(2) apply(rule has_integral_null) unfolding content_eq_0 using * `a=b` by auto
10.2148 +      show ?thesis unfolding *(2) apply(rule has_integral_null) unfolding content_eq_0 using * `a=b`
10.2149 +        by (auto simp: ex_in_conv)
10.2150      qed } assume ab:"a < b"
10.2151    let ?P = "\<lambda>e. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
10.2152                     norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f' x) - (f b - f a)) \<le> e * content {a..b})"
10.2153 @@ -4106,11 +4059,14 @@
10.2154    from this(2)[unfolded open_contains_ball,rule_format,OF this(1)] guess k .. note k=conjunctD2[OF this]
10.2155
10.2156    let ?d = "min k (c - a)/2" show ?thesis apply(rule that[of ?d])
10.2157 -  proof safe show "?d > 0" using k(1) using assms(2) by auto
10.2158 -    fix t assume as:"c - ?d < t" "t \<le> c" let ?thesis = "norm (integral {a..c} f - integral {a..t} f) < e"
10.2159 +  proof safe
10.2160 +    show "?d > 0" using k(1) using assms(2) by auto
10.2161 +    fix t assume as:"c - ?d < t" "t \<le> c"
10.2162 +    let ?thesis = "norm (integral {a..c} f - integral {a..t} f) < e"
10.2163      { presume *:"t < c \<Longrightarrow> ?thesis"
10.2164        show ?thesis apply(cases "t = c") defer apply(rule *)
10.2165 -        apply(subst less_le) using `e>0` as(2) by auto } assume "t < c"
10.2166 +        apply(subst less_le) using `e>0` as(2) by auto }
10.2167 +    assume "t < c"
10.2168
10.2169      have "f integrable_on {a..t}" apply(rule integrable_subinterval[OF assms(1)]) using assms(2-3) as(2) by auto
10.2170      from integrable_integral[OF this,unfolded has_integral,rule_format,OF *] guess d2 ..
10.2171 @@ -4123,10 +4079,10 @@
10.2172      with p(2) have "d2 fine p" unfolding fine_def d3_def apply safe apply(erule_tac x="(a,b)" in ballE)+ by auto
10.2173      note d2_fin = d2(2)[OF conjI[OF p(1) this]]
10.2174
10.2175 -    have *:"{a..c} \<inter> {x. x \$\$0 \<le> t} = {a..t}" "{a..c} \<inter> {x. x\$\$0 \<ge> t} = {t..c}"
10.2176 +    have *:"{a..c} \<inter> {x. x \<bullet> 1 \<le> t} = {a..t}" "{a..c} \<inter> {x. x \<bullet> 1 \<ge> t} = {t..c}"
10.2177        using assms(2-3) as by(auto simp add:field_simps)
10.2178      have "p \<union> {(c, {t..c})} tagged_division_of {a..c} \<and> d1 fine p \<union> {(c, {t..c})}" apply rule
10.2179 -      apply(rule tagged_division_union_interval[of _ _ _ 0 "t"]) unfolding * apply(rule p)
10.2180 +      apply(rule tagged_division_union_interval[of _ _ _ 1 "t"]) unfolding * apply(rule p)
10.2181        apply(rule tagged_division_of_self) unfolding fine_def
10.2182      proof safe fix x k y assume "(x,k)\<in>p" "y\<in>k" thus "y\<in>d1 x"
10.2183          using p(2) pt unfolding fine_def d3_def apply- apply(erule_tac x="(x,k)" in ballE)+ by auto
10.2184 @@ -4178,7 +4134,7 @@
10.2185    { presume *:"a<b \<Longrightarrow> ?thesis"
10.2186      show ?thesis apply(cases,rule *,assumption)
10.2187      proof- case goal1 hence "{a..b} = {x}" using as(1) apply-apply(rule set_eqI)
10.2188 -        unfolding atLeastAtMost_iff by(auto simp only:field_simps not_less DIM_real)
10.2189 +        unfolding atLeastAtMost_iff by(auto simp only:field_simps not_less)
10.2190        thus ?case using `e>0` by auto
10.2191      qed } assume "a<b"
10.2192    have "(x=a \<or> x=b) \<or> (a<x \<and> x<b)" using as(1) by (auto simp add:)
10.2193 @@ -4355,65 +4311,41 @@
10.2194      qed(insert B `e>0`, auto)
10.2195    next assume as:"\<forall>e>0. ?r e"
10.2196      from this[rule_format,OF zero_less_one] guess C .. note C=conjunctD2[OF this,rule_format]
10.2197 -    def c \<equiv> "(\<chi>\<chi> i. - max B C)::'n::ordered_euclidean_space" and d \<equiv> "(\<chi>\<chi> i. max B C)::'n::ordered_euclidean_space"
10.2198 +    def c \<equiv> "(\<Sum>i\<in>Basis. (- max B C) *\<^sub>R i)::'n::ordered_euclidean_space"
10.2199 +    def d \<equiv> "(\<Sum>i\<in>Basis. max B C *\<^sub>R i)::'n::ordered_euclidean_space"
10.2200      have c_d:"{a..b} \<subseteq> {c..d}" apply safe apply(drule B(2)) unfolding mem_interval
10.2201 -    proof case goal1 thus ?case using component_le_norm[of x i] unfolding c_def d_def
10.2202 -        by(auto simp add:field_simps) qed
10.2203 +    proof
10.2204 +      case goal1 thus ?case using Basis_le_norm[OF `i\<in>Basis`, of x] unfolding c_def d_def
10.2205 +        by(auto simp add:field_simps setsum_negf)
10.2206 +    qed
10.2207      have "ball 0 C \<subseteq> {c..d}" apply safe unfolding mem_interval mem_ball dist_norm
10.2208 -    proof case goal1 thus ?case using component_le_norm[of x i] unfolding c_def d_def by auto qed
10.2209 +    proof
10.2210 +      case goal1 thus ?case
10.2211 +        using Basis_le_norm[OF `i\<in>Basis`, of x] unfolding c_def d_def by (auto simp: setsum_negf)
10.2212 +    qed
10.2213      from C(2)[OF this] have "\<exists>y. (f has_integral y) {a..b}"
10.2214        unfolding has_integral_restrict_closed_subintervals_eq[OF c_d,THEN sym] unfolding s by auto
10.2215      then guess y .. note y=this
10.2216
10.2217      have "y = i" proof(rule ccontr) assume "y\<noteq>i" hence "0 < norm (y - i)" by auto
10.2218        from as[rule_format,OF this] guess C ..  note C=conjunctD2[OF this,rule_format]
10.2219 -      def c \<equiv> "(\<chi>\<chi> i. - max B C)::'n::ordered_euclidean_space" and d \<equiv> "(\<chi>\<chi> i. max B C)::'n::ordered_euclidean_space"
10.2220 +      def c \<equiv> "(\<Sum>i\<in>Basis. (- max B C) *\<^sub>R i)::'n::ordered_euclidean_space"
10.2221 +      def d \<equiv> "(\<Sum>i\<in>Basis. max B C *\<^sub>R i)::'n::ordered_euclidean_space"
10.2222        have c_d:"{a..b} \<subseteq> {c..d}" apply safe apply(drule B(2)) unfolding mem_interval
10.2223 -      proof case goal1 thus ?case using component_le_norm[of x i] unfolding c_def d_def
10.2224 -          by(auto simp add:field_simps) qed
10.2225 +      proof case goal1 thus ?case using Basis_le_norm[of i x] unfolding c_def d_def
10.2226 +          by(auto simp add:field_simps setsum_negf) qed
10.2227        have "ball 0 C \<subseteq> {c..d}" apply safe unfolding mem_interval mem_ball dist_norm
10.2228 -      proof case goal1 thus ?case using component_le_norm[of x i] unfolding c_def d_def by auto qed
10.2229 +      proof case goal1 thus ?case using Basis_le_norm[of i x] unfolding c_def d_def by (auto simp: setsum_negf) qed
10.2230        note C(2)[OF this] then guess z .. note z = conjunctD2[OF this, unfolded s]
10.2231        note this[unfolded has_integral_restrict_closed_subintervals_eq[OF c_d]]
10.2232        hence "z = y" "norm (z - i) < norm (y - i)" apply- apply(rule has_integral_unique[OF _ y(1)]) .
10.2233        thus False by auto qed
10.2234      thus ?l using y unfolding s by auto qed qed
10.2235
10.2236 -(*lemma has_integral_trans[simp]: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real" shows
10.2237 -  "((\<lambda>x. vec1 (f x)) has_integral vec1 i) s \<longleftrightarrow> (f has_integral i) s"
10.2238 -  unfolding has_integral'[unfolded has_integral]
10.2239 -proof case goal1 thus ?case apply safe
10.2240 -  apply(erule_tac x=e in allE,safe) apply(rule_tac x=B in exI,safe)
10.2241 -  apply(erule_tac x=a in allE, erule_tac x=b in allE,safe)
10.2242 -  apply(rule_tac x="dest_vec1 z" in exI,safe) apply(erule_tac x=ea in allE,safe)
10.2243 -  apply(rule_tac x=d in exI,safe) apply(erule_tac x=p in allE,safe)
10.2244 -  apply(subst(asm)(2) norm_vector_1) unfolding split_def
10.2245 -  unfolding setsum_component Cart_nth.diff cond_value_iff[of dest_vec1]
10.2246 -    Cart_nth.scaleR vec1_dest_vec1 zero_index apply assumption
10.2247 -  apply(subst(asm)(2) norm_vector_1) by auto
10.2248 -next case goal2 thus ?case apply safe
10.2249 -  apply(erule_tac x=e in allE,safe) apply(rule_tac x=B in exI,safe)
10.2250 -  apply(erule_tac x=a in allE, erule_tac x=b in allE,safe)
10.2251 -  apply(rule_tac x="vec1 z" in exI,safe) apply(erule_tac x=ea in allE,safe)
10.2252 -  apply(rule_tac x=d in exI,safe) apply(erule_tac x=p in allE,safe)
10.2253 -  apply(subst norm_vector_1) unfolding split_def
10.2254 -  unfolding setsum_component Cart_nth.diff cond_value_iff[of dest_vec1]
10.2255 -    Cart_nth.scaleR vec1_dest_vec1 zero_index apply assumption
10.2256 -  apply(subst norm_vector_1) by auto qed
10.2257 -
10.2258 -lemma integral_trans[simp]: assumes "(f::'n::ordered_euclidean_space \<Rightarrow> real) integrable_on s"
10.2259 -  shows "integral s (\<lambda>x. vec1 (f x)) = vec1 (integral s f)"
10.2260 -  apply(rule integral_unique) using assms by auto
10.2261 -
10.2262 -lemma integrable_on_trans[simp]: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real" shows
10.2263 -  "(\<lambda>x. vec1 (f x)) integrable_on s \<longleftrightarrow> (f integrable_on s)"
10.2264 -  unfolding integrable_on_def
10.2265 -  apply(subst(2) vec1_dest_vec1(1)[THEN sym]) unfolding has_integral_trans
10.2266 -  apply safe defer apply(rule_tac x="vec1 y" in exI) by auto *)
10.2267 -
10.2268  lemma has_integral_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
10.2269    assumes "(f has_integral i) s" "(g has_integral j) s"  "\<forall>x\<in>s. (f x) \<le> (g x)"
10.2270 -  shows "i \<le> j" using has_integral_component_le[OF assms(1-2), of 0] using assms(3) by auto
10.2271 +  shows "i \<le> j"
10.2272 +  using has_integral_component_le[OF _ assms(1-2), of 1] using assms(3) by auto
10.2273
10.2274  lemma integral_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
10.2275    assumes "f integrable_on s" "g integrable_on s" "\<forall>x\<in>s. f x \<le> g x"
10.2276 @@ -4422,7 +4354,7 @@
10.2277
10.2278  lemma has_integral_nonneg: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
10.2279    assumes "(f has_integral i) s" "\<forall>x\<in>s. 0 \<le> f x" shows "0 \<le> i"
10.2280 -  using has_integral_component_nonneg[of "f" "i" s 0]
10.2281 +  using has_integral_component_nonneg[of 1 f i s]
10.2282    unfolding o_def using assms by auto
10.2283
10.2284  lemma integral_nonneg: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
10.2285 @@ -4519,19 +4451,20 @@
10.2286  subsection {* More lemmas that are useful later. *}
10.2287
10.2288  lemma has_integral_subset_component_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
10.2289 -  assumes "s \<subseteq> t" "(f has_integral i) s" "(f has_integral j) t" "\<forall>x\<in>t. 0 \<le> f(x)\$\$k"
10.2290 -  shows "i\$\$k \<le> j\$\$k"
10.2291 +  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"
10.2292 +  shows "i\<bullet>k \<le> j\<bullet>k"
10.2293  proof- note has_integral_restrict_univ[THEN sym, of f]
10.2294 -  note assms(2-3)[unfolded this] note * = has_integral_component_le[OF this]
10.2295 -  show ?thesis apply(rule *) using assms(1,4) by auto qed
10.2296 +  note as(2-3)[unfolded this] note * = has_integral_component_le[OF k this]
10.2297 +  show ?thesis apply(rule *) using as(1,4) by auto qed
10.2298
10.2299  lemma has_integral_subset_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
10.2300 -  assumes "s \<subseteq> t" "(f has_integral i) s" "(f has_integral j) t" "\<forall>x\<in>t. 0 \<le> f(x)"
10.2301 -  shows "i \<le> j" using has_integral_subset_component_le[OF assms(1), of "f" "i" "j" 0] using assms by auto
10.2302 +  assumes as: "s \<subseteq> t" "(f has_integral i) s" "(f has_integral j) t" "\<forall>x\<in>t. 0 \<le> f(x)"
10.2303 +  shows "i \<le> j"
10.2304 +  using has_integral_subset_component_le[OF _ assms(1), of 1 f i j] using assms by auto
10.2305
10.2306  lemma integral_subset_component_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
10.2307 -  assumes "s \<subseteq> t" "f integrable_on s" "f integrable_on t" "\<forall>x \<in> t. 0 \<le> f(x)\$\$k"
10.2308 -  shows "(integral s f)\$\$k \<le> (integral t f)\$\$k"
10.2309 +  assumes "k\<in>Basis" "s \<subseteq> t" "f integrable_on s" "f integrable_on t" "\<forall>x \<in> t. 0 \<le> f(x)\<bullet>k"
10.2310 +  shows "(integral s f)\<bullet>k \<le> (integral t f)\<bullet>k"
10.2311    apply(rule has_integral_subset_component_le) using assms by auto
10.2312
10.2313  lemma integral_subset_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
10.2314 @@ -4553,13 +4486,13 @@
10.2315    let ?f = "\<lambda>x. if x \<in> s then f x else 0"
10.2316    show ?r proof safe fix a b::"'n::ordered_euclidean_space"
10.2317      from as[OF zero_less_one] guess B .. note B=conjunctD2[OF this,rule_format]
10.2318 -    let ?a = "(\<chi>\<chi> i. min (a\$\$i) (-B))::'n::ordered_euclidean_space" and ?b = "(\<chi>\<chi> i. max (b\$\$i) B)::'n::ordered_euclidean_space"
10.2319 +    let ?a = "\<Sum>i\<in>Basis. min (a\<bullet>i) (-B) *\<^sub>R i::'n" and ?b = "\<Sum>i\<in>Basis. max (b\<bullet>i) B *\<^sub>R i::'n"
10.2320      show "?f integrable_on {a..b}" apply(rule integrable_subinterval[of _ ?a ?b])
10.2321      proof- have "ball 0 B \<subseteq> {?a..?b}" apply safe unfolding mem_ball mem_interval dist_norm
10.2322 -      proof case goal1 thus ?case using component_le_norm[of x i] by(auto simp add:field_simps) qed
10.2323 +      proof case goal1 thus ?case using Basis_le_norm[of i x] by(auto simp add:field_simps) qed
10.2324        from B(2)[OF this] guess z .. note conjunct1[OF this]
10.2325        thus "?f integrable_on {?a..?b}" unfolding integrable_on_def by auto
10.2326 -      show "{a..b} \<subseteq> {?a..?b}" apply safe unfolding mem_interval apply(rule,erule_tac x=i in allE) by auto qed
10.2327 +      show "{a..b} \<subseteq> {?a..?b}" apply safe unfolding mem_interval apply(rule,erule_tac x=i in ballE) by auto qed
10.2328
10.2329      fix e::real assume "e>0" from as[OF this] guess B .. note B=conjunctD2[OF this,rule_format]
10.2330      show "\<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow>
10.2331 @@ -4584,14 +4517,15 @@
10.2332          using B(2)[OF goal1(1)] B(2)[OF goal1(2)] by auto qed qed
10.2333
10.2334  next assume ?r note as = conjunctD2[OF this,rule_format]
10.2335 -  have "Cauchy (\<lambda>n. integral ({(\<chi>\<chi> i. - real n)::'n .. (\<chi>\<chi> i. real n)}) (\<lambda>x. if x \<in> s then f x else 0))"
10.2336 +  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"
10.2337 +  have "Cauchy (\<lambda>n. integral (?cube n) (\<lambda>x. if x \<in> s then f x else 0))"
10.2338    proof(unfold Cauchy_def,safe) case goal1
10.2339      from as(2)[OF this] guess B .. note B = conjunctD2[OF this,rule_format]
10.2340      from real_arch_simple[of B] guess N .. note N = this
10.2341 -    { fix n assume n:"n \<ge> N" have "ball 0 B \<subseteq> {(\<chi>\<chi> i. - real n)::'n..\<chi>\<chi> i. real n}" apply safe
10.2342 +    { fix n assume n:"n \<ge> N" have "ball 0 B \<subseteq> ?cube n" apply safe
10.2343          unfolding mem_ball mem_interval dist_norm
10.2344 -      proof case goal1 thus ?case using component_le_norm[of x i]
10.2345 -          using n N by(auto simp add:field_simps) qed }
10.2346 +      proof case goal1 thus ?case using Basis_le_norm[of i x] `i\<in>Basis`
10.2347 +          using n N by(auto simp add:field_simps setsum_negf) qed }
10.2348      thus ?case apply-apply(rule_tac x=N in exI) apply safe unfolding dist_norm apply(rule B(2)) by auto
10.2349    qed from this[unfolded convergent_eq_cauchy[THEN sym]] guess i ..
10.2350    note i = this[THEN LIMSEQ_D]
10.2351 @@ -4611,9 +4545,9 @@
10.2352        proof safe show "N \<le> n" using n by auto
10.2353          fix x::"'n::ordered_euclidean_space" assume x:"x \<in> ball 0 B" hence "x\<in> ball 0 ?B" by auto
10.2354          thus "x\<in>{a..b}" using ab by blast
10.2355 -        show "x\<in>{\<chi>\<chi> i. - real n..\<chi>\<chi> i. real n}" using x unfolding mem_interval mem_ball dist_norm apply-
10.2356 -        proof case goal1 thus ?case using component_le_norm[of x i]
10.2357 -            using n by(auto simp add:field_simps) qed qed qed qed qed
10.2358 +        show "x\<in>?cube n" using x unfolding mem_interval mem_ball dist_norm apply-
10.2359 +        proof case goal1 thus ?case using Basis_le_norm[of i x] `i\<in>Basis`
10.2360 +            using n by(auto simp add:field_simps setsum_negf) qed qed qed qed qed
10.2361
10.2362  lemma integrable_altD: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
10.2363    assumes "f integrable_on s"
10.2364 @@ -4676,11 +4610,13 @@
10.2365      note g = this(1) and this(2)[OF *] from this(2) guess B1 .. note B1 = conjunctD2[OF this,rule_format]
10.2366      note obt(2)[unfolded has_integral_alt'[of h]] note conjunctD2[OF this, rule_format]
10.2367      note h = this(1) and this(2)[OF *] from this(2) guess B2 .. note B2 = conjunctD2[OF this,rule_format]
10.2368 -    def c \<equiv> "(\<chi>\<chi> i. min (a\$\$i) (- (max B1 B2)))::'n" and d \<equiv> "(\<chi>\<chi> i. max (b\$\$i) (max B1 B2))::'n"
10.2369 -    have *:"ball 0 B1 \<subseteq> {c..d}" "ball 0 B2 \<subseteq> {c..d}" apply safe unfolding mem_ball mem_interval dist_norm
10.2370 -    proof(rule_tac[!] allI)
10.2371 -      case goal1 thus ?case using component_le_norm[of x i] unfolding c_def d_def by auto next
10.2372 -      case goal2 thus ?case using component_le_norm[of x i] unfolding c_def d_def by auto qed
10.2373 +    def c \<equiv> "\<Sum>i\<in>Basis. min (a\<bullet>i) (- (max B1 B2)) *\<^sub>R i::'n"
10.2374 +    def d \<equiv> "\<Sum>i\<in>Basis. max (b\<bullet>i) (max B1 B2) *\<^sub>R i::'n"
10.2375 +    have *:"ball 0 B1 \<subseteq> {c..d}" "ball 0 B2 \<subseteq> {c..d}"
10.2376 +      apply safe unfolding mem_ball mem_interval dist_norm
10.2377 +    proof(rule_tac[!] ballI)
10.2378 +      case goal1 thus ?case using Basis_le_norm[of i x] unfolding c_def d_def by auto next
10.2379 +      case goal2 thus ?case using Basis_le_norm[of i x] unfolding c_def d_def by auto qed
10.2380      have **:"\<And>ch cg ag ah::real. norm(ah - ag) \<le> norm(ch - cg) \<Longrightarrow> norm(cg - i) < e / 4 \<Longrightarrow>
10.2381        norm(ch - j) < e / 4 \<Longrightarrow> norm(ag - ah) < e"
10.2382        using obt(3) unfolding real_norm_def by arith
10.2383 @@ -4700,7 +4636,7 @@
10.2384          unfolding integral_sub[OF h g,THEN sym] real_norm_def apply(subst **) defer apply(subst **) defer
10.2385          apply(rule has_integral_subset_le) defer apply(rule integrable_integral integrable_sub h g)+
10.2386        proof safe fix x assume "x\<in>{a..b}" thus "x\<in>{c..d}" unfolding mem_interval c_def d_def
10.2387 -          apply - apply rule apply(erule_tac x=i in allE) by auto
10.2388 +          apply - apply rule apply(erule_tac x=i in ballE) by auto
10.2389        qed(insert obt(4), auto) qed(insert obt(4), auto) qed note interv = this
10.2390
10.2391    show ?thesis unfolding integrable_alt[of f] apply safe apply(rule interv)
10.2392 @@ -5019,7 +4955,7 @@
10.2393  proof(case_tac[!] "content {a..b} = 0") assume as:"content {a..b} = 0"
10.2394    show ?thesis using integrable_on_null[OF as] unfolding integral_null[OF as] using tendsto_const by auto
10.2395  next assume ab:"content {a..b} \<noteq> 0"
10.2396 -  have fg:"\<forall>x\<in>{a..b}. \<forall> k. (f k x) \$\$ 0 \<le> (g x) \$\$ 0"
10.2397 +  have fg:"\<forall>x\<in>{a..b}. \<forall> k. (f k x) \<bullet> 1 \<le> (g x) \<bullet> 1"
10.2398    proof safe case goal1 note assms(3)[rule_format,OF this]
10.2399      note * = Lim_component_ge[OF this trivial_limit_sequentially]
10.2400      show ?case apply(rule *) unfolding eventually_sequentially
10.2401 @@ -5030,10 +4966,10 @@
10.2402      apply rule apply(rule integral_le) apply safe
10.2403      apply(rule assms(1-2)[rule_format])+ using assms(4) by auto
10.2404    then guess i .. note i=this
10.2405 -  have i':"\<And>k. (integral({a..b}) (f k)) \<le> i\$\$0"
10.2406 +  have i':"\<And>k. (integral({a..b}) (f k)) \<le> i\<bullet>1"
10.2407      apply(rule Lim_component_ge,rule i) apply(rule trivial_limit_sequentially)
10.2408      unfolding eventually_sequentially apply(rule_tac x=k in exI)
10.2409 -    apply(rule transitive_stepwise_le) prefer 3 unfolding Eucl_real_simps apply(rule integral_le)
10.2410 +    apply(rule transitive_stepwise_le) prefer 3 unfolding inner_simps real_inner_1_right apply(rule integral_le)
10.2411      apply(rule assms(1-2)[rule_format])+ using assms(2) by auto
10.2412
10.2413    have "(g has_integral i) {a..b}" unfolding has_integral
10.2414 @@ -5044,7 +4980,7 @@
10.2415        apply(rule divide_pos_pos) by auto
10.2416      from choice[OF this] guess c .. note c=conjunctD2[OF this[rule_format],rule_format]
10.2417
10.2418 -    have "\<exists>r. \<forall>k\<ge>r. 0 \<le> i\$\$0 - (integral {a..b} (f k)) \<and> i\$\$0 - (integral {a..b} (f k)) < e / 4"
10.2419 +    have "\<exists>r. \<forall>k\<ge>r. 0 \<le> i\<bullet>1 - (integral {a..b} (f k)) \<and> i\<bullet>1 - (integral {a..b} (f k)) < e / 4"
10.2420      proof- case goal1 have "e/4 > 0" using e by auto
10.2421        from LIMSEQ_D [OF i this] guess r ..
10.2422        thus ?case apply(rule_tac x=r in exI) apply rule
10.2423 @@ -5052,14 +4988,15 @@
10.2424        proof- case goal1 thus ?case using i'[of k] by auto qed qed
10.2425      then guess r .. note r=conjunctD2[OF this[rule_format]]
10.2426
10.2427 -    have "\<forall>x\<in>{a..b}. \<exists>n\<ge>r. \<forall>k\<ge>n. 0 \<le> (g x)\$\$0 - (f k x)\$\$0 \<and>
10.2428 -           (g x)\$\$0 - (f k x)\$\$0 < e / (4 * content({a..b}))"
10.2429 +    have "\<forall>x\<in>{a..b}. \<exists>n\<ge>r. \<forall>k\<ge>n. 0 \<le> (g x)\<bullet>1 - (f k x)\<bullet>1 \<and>
10.2430 +           (g x)\<bullet>1 - (f k x)\<bullet>1 < e / (4 * content({a..b}))"
10.2431      proof case goal1 have "e / (4 * content {a..b}) > 0" apply(rule divide_pos_pos,fact)
10.2432          using ab content_pos_le[of a b] by auto
10.2433        from assms(3)[rule_format, OF goal1, THEN LIMSEQ_D, OF this]
10.2434        guess n .. note n=this
10.2435        thus ?case apply(rule_tac x="n + r" in exI) apply safe apply(erule_tac[2-3] x=k in allE)
10.2436 -        unfolding dist_real_def using fg[rule_format,OF goal1] by(auto simp add:field_simps) qed
10.2437 +        unfolding dist_real_def using fg[rule_format,OF goal1]
10.2438 +        by (auto simp add:field_simps) qed
10.2439      from bchoice[OF this] guess m .. note m=conjunctD2[OF this[rule_format],rule_format]
10.2440      def d \<equiv> "\<lambda>x. c (m x) x"
10.2441
10.2442 @@ -5118,14 +5055,14 @@
10.2443
10.2444         next case goal3
10.2445           note comb = integral_combine_tagged_division_topdown[OF assms(1)[rule_format] p(1)]
10.2446 -         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\$\$0 - kr\$\$0
10.2447 -           \<and> i\$\$0 - kr\$\$0 < e/4 \<longrightarrow> abs(sx - i) < e/4" by auto
10.2448 +         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
10.2449 +           \<and> i\<bullet>1 - kr\<bullet>1 < e/4 \<longrightarrow> abs(sx - i) < e/4" by auto
10.2450           show ?case unfolding real_norm_def apply(rule *[rule_format],safe)
10.2451 -           apply(rule comb[of r],rule comb[of s]) apply(rule i'[unfolded Eucl_real_simps])
10.2452 +           apply(rule comb[of r],rule comb[of s]) apply(rule i'[unfolded real_inner_1_right])
10.2453             apply(rule_tac[1-2] setsum_mono) unfolding split_paired_all split_conv
10.2454             apply(rule_tac[1-2] integral_le[OF ])
10.2455 -         proof safe show "0 \<le> i\$\$0 - (integral {a..b} (f r))\$\$0" using r(1) by auto
10.2456 -           show "i\$\$0 - (integral {a..b} (f r))\$\$0 < e / 4" using r(2) by auto
10.2457 +         proof safe show "0 \<le> i\<bullet>1 - (integral {a..b} (f r))\<bullet>1" using r(1) by auto
10.2458 +           show "i\<bullet>1 - (integral {a..b} (f r))\<bullet>1 < e / 4" using r(2) by auto
10.2459             fix x k assume xk:"(x,k)\<in>p" from p'(4)[OF this] guess u v apply-by(erule exE)+ note uv=this
10.2460             show "f r integrable_on k" "f s integrable_on k" "f (m x) integrable_on k" "f (m x) integrable_on k"
10.2461               unfolding uv apply(rule_tac[!] integrable_on_subinterval[OF assms(1)[rule_format]])
10.2462 @@ -5147,7 +5084,7 @@
10.2463      \<forall>k. \<forall>x\<in>s. (f k x) \<le> (f (Suc k) x) \<Longrightarrow> \<forall>x\<in>s. ((\<lambda>k. f k x) ---> g x) sequentially  \<Longrightarrow>
10.2464      bounded {integral s (f k)| k. True} \<Longrightarrow> g integrable_on s \<and> ((\<lambda>k. integral s (f k)) ---> integral s g) sequentially"
10.2465    proof- case goal1 note assms=this[rule_format]
10.2466 -    have "\<forall>x\<in>s. \<forall>k. (f k x)\$\$0 \<le> (g x)\$\$0" apply safe apply(rule Lim_component_ge)
10.2467 +    have "\<forall>x\<in>s. \<forall>k. (f k x)\<bullet>1 \<le> (g x)\<bullet>1" apply safe apply(rule Lim_component_ge)
10.2468        apply(rule goal1(4)[rule_format],assumption) apply(rule trivial_limit_sequentially)
10.2469        unfolding eventually_sequentially apply(rule_tac x=k in exI)
10.2470        apply(rule transitive_stepwise_le) using goal1(3) by auto note fg=this[rule_format]
10.2471 @@ -5156,9 +5093,10 @@
10.2472        apply(rule goal1(5)) apply(rule,rule integral_le) apply(rule goal1(2)[rule_format])+
10.2473        using goal1(3) by auto then guess i .. note i=this
10.2474      have "\<And>k. \<forall>x\<in>s. \<forall>n\<ge>k. f k x \<le> f n x" apply(rule,rule transitive_stepwise_le) using goal1(3) by auto
10.2475 -    hence i':"\<forall>k. (integral s (f k))\$\$0 \<le> i\$\$0" apply-apply(rule,rule Lim_component_ge)
10.2476 +    hence i':"\<forall>k. (integral s (f k))\<bullet>1 \<le> i\<bullet>1" apply-apply(rule,rule Lim_component_ge)
10.2477        apply(rule i,rule trivial_limit_sequentially) unfolding eventually_sequentially
10.2478        apply(rule_tac x=k in exI,safe) apply(rule integral_component_le)
10.2479 +      apply simp
10.2480        apply(rule goal1(2)[rule_format])+ by auto
10.2481
10.2482      note int = assms(2)[unfolded integrable_alt[of _ s],THEN conjunct1,rule_format]
10.2483 @@ -5199,14 +5137,14 @@
10.2484            apply(rule norm_triangle_half_l) using B(2)[rule_format,OF ab] N[rule_format,of N]
10.2485            apply-defer apply(subst norm_minus_commute) by auto
10.2486          have *:"\<And>f1 f2 g. abs(f1 - i) < e / 2 \<longrightarrow> abs(f2 - g) < e / 2 \<longrightarrow> f1 \<le> f2 \<longrightarrow> f2 \<le> i
10.2487 -          \<longrightarrow> abs(g - i) < e" unfolding Eucl_real_simps by arith
10.2488 +          \<longrightarrow> abs(g - i) < e" unfolding real_inner_1_right by arith
10.2489          show "norm (integral {a..b} (\<lambda>x. if x \<in> s then g x else 0) - i) < e"
10.2490            unfolding real_norm_def apply(rule *[rule_format])
10.2491            apply(rule **[unfolded real_norm_def])
10.2492            apply(rule M[rule_format,of "M + N",unfolded real_norm_def]) apply(rule le_add1)
10.2493            apply(rule integral_le[OF int int]) defer
10.2494 -          apply(rule order_trans[OF _ i'[rule_format,of "M + N",unfolded Eucl_real_simps]])
10.2495 -        proof safe case goal2 have "\<And>m. x\<in>s \<Longrightarrow> \<forall>n\<ge>m. (f m x)\$\$0 \<le> (f n x)\$\$0"
10.2496 +          apply(rule order_trans[OF _ i'[rule_format,of "M + N",unfolded real_inner_1_right]])
10.2497 +        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"
10.2498              apply(rule transitive_stepwise_le) using assms(3) by auto thus ?case by auto
10.2499          next case goal1 show ?case apply(subst integral_restrict_univ[THEN sym,OF int])
10.2500              unfolding ifif integral_restrict_univ[OF int']
10.2501 @@ -5323,9 +5261,9 @@
10.2502
10.2503  lemma integral_norm_bound_integral_component: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
10.2504    fixes g::"'n => 'b::ordered_euclidean_space"
10.2505 -  assumes "f integrable_on s" "g integrable_on s"  "\<forall>x\<in>s. norm(f x) \<le> (g x)\$\$k"
10.2506 -  shows "norm(integral s f) \<le> (integral s g)\$\$k"
10.2507 -proof- have "norm (integral s f) \<le> integral s ((\<lambda>x. x \$\$ k) o g)"
10.2508 +  assumes "f integrable_on s" "g integrable_on s"  "\<forall>x\<in>s. norm(f x) \<le> (g x)\<bullet>k"
10.2509 +  shows "norm(integral s f) \<le> (integral s g)\<bullet>k"
10.2510 +proof- have "norm (integral s f) \<le> integral s ((\<lambda>x. x \<bullet> k) o g)"
10.2511      apply(rule integral_norm_bound_integral[OF assms(1)])
10.2512      apply(rule integrable_linear[OF assms(2)],rule)
10.2513      unfolding o_def by(rule assms)
10.2514 @@ -5333,8 +5271,8 @@
10.2515
10.2516  lemma has_integral_norm_bound_integral_component: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
10.2517    fixes g::"'n => 'b::ordered_euclidean_space"
10.2518 -  assumes "(f has_integral i) s" "(g has_integral j) s" "\<forall>x\<in>s. norm(f x) \<le> (g x)\$\$k"
10.2519 -  shows "norm(i) \<le> j\$\$k" using integral_norm_bound_integral_component[of f s g k]
10.2520 +  assumes "(f has_integral i) s" "(g has_integral j) s" "\<forall>x\<in>s. norm(f x) \<le> (g x)\<bullet>k"
10.2521 +  shows "norm(i) \<le> j\<bullet>k" using integral_norm_bound_integral_component[of f s g k]
10.2522    unfolding integral_unique[OF assms(1)] integral_unique[OF assms(2)]
10.2523    using assms by auto
10.2524
10.2525 @@ -5742,97 +5680,126 @@
10.2526    shows "(\<lambda>x. setsum (\<lambda>a. f a x) t) absolutely_integrable_on s"
10.2527    using assms(1,2) apply induct defer apply(subst setsum.insert) apply assumption+ by(rule,auto)
10.2528
10.2529 -lemma absolutely_integrable_vector_abs: fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
10.2530 -  assumes "f absolutely_integrable_on s"
10.2531 -  shows "(\<lambda>x. (\<chi>\<chi> i. abs(f x\$\$i))::'c::ordered_euclidean_space) absolutely_integrable_on s"
10.2532 -proof- have *:"\<And>x. ((\<chi>\<chi> i. abs(f x\$\$i))::'c::ordered_euclidean_space) = (setsum (\<lambda>i.
10.2533 -    (((\<lambda>y. (\<chi>\<chi> j. if j = i then y else 0)) o
10.2534 -    (((\<lambda>x. (norm((\<chi>\<chi> j. if j = i then x\$\$i else 0)::'c::ordered_euclidean_space))) o f))) x)) {..<DIM('c)})"
10.2535 -    unfolding euclidean_eq[where 'a='c] euclidean_component_setsum apply safe
10.2536 -    unfolding euclidean_lambda_beta'
10.2537 -  proof- case goal1 have *:"\<And>i xa. ((if i = xa then f x \$\$ xa else 0) * (if i = xa then f x \$\$ xa else 0)) =
10.2538 -      (if i = xa then (f x \$\$ xa) * (f x \$\$ xa) else 0)" by auto
10.2539 -    have *:"\<And>xa. norm ((\<chi>\<chi> j. if j = xa then f x \$\$ xa else 0)::'c) = (if xa<DIM('c) then abs (f x \$\$ xa) else 0)"
10.2540 -      unfolding norm_eq_sqrt_inner euclidean_inner[where 'a='c]
10.2541 -      by(auto simp add:setsum_delta[OF finite_lessThan] *)
10.2542 -    have "\<bar>f x \$\$ i\<bar> = (setsum (\<lambda>k. if k = i then abs ((f x)\$\$i) else 0) {..<DIM('c)})"
10.2543 -      unfolding setsum_delta[OF finite_lessThan] using goal1 by auto
10.2544 -    also have "... = (\<Sum>xa<DIM('c). ((\<lambda>y. (\<chi>\<chi> j. if j = xa then y else 0)::'c) \<circ>
10.2545 -                      (\<lambda>x. (norm ((\<chi>\<chi> j. if j = xa then x \$\$ xa else 0)::'c))) \<circ> f) x \$\$ i)"
10.2546 -      unfolding o_def * apply(rule setsum_cong2)
10.2547 -      unfolding euclidean_lambda_beta'[OF goal1 ] by auto
10.2548 -    finally show ?case unfolding o_def . qed
10.2549 -  show ?thesis unfolding * apply(rule absolutely_integrable_setsum) apply(rule finite_lessThan)
10.2550 -    apply(rule absolutely_integrable_linear) unfolding o_def apply(rule absolutely_integrable_norm)
10.2551 -    apply(rule absolutely_integrable_linear[OF assms,unfolded o_def]) unfolding linear_linear
10.2552 -    apply(rule_tac[!] linearI) unfolding euclidean_eq[where 'a='c]
10.2553 -    by(auto simp:euclidean_component_scaleR[where 'a=real,unfolded real_scaleR_def])
10.2554 +lemma bounded_linear_setsum:
10.2555 +  fixes f :: "'i \<Rightarrow> 'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
10.2556 +  assumes f: "\<And>i. i\<in>I \<Longrightarrow> bounded_linear (f i)"
10.2557 +  shows "bounded_linear (\<lambda>x. \<Sum>i\<in>I. f i x)"
10.2558 +proof cases
10.2559 +  assume "finite I" from this f show ?thesis
10.2560 +    by (induct I) (auto intro!: bounded_linear_add bounded_linear_zero)
```