src/HOL/Analysis/Weierstrass_Theorems.thy
changeset 72221 98ef41a82b73
parent 71633 07bec530f02e
child 72379 504fe7365820
equal deleted inserted replaced
72220:bb29e4eb938d 72221:98ef41a82b73
    75 proof -
    75 proof -
    76   have "bounded (f ` {0..1})"
    76   have "bounded (f ` {0..1})"
    77     using compact_continuous_image compact_imp_bounded contf by blast
    77     using compact_continuous_image compact_imp_bounded contf by blast
    78   then obtain M where M: "\<And>x. 0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> \<bar>f x\<bar> \<le> M"
    78   then obtain M where M: "\<And>x. 0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> \<bar>f x\<bar> \<le> M"
    79     by (force simp add: bounded_iff)
    79     by (force simp add: bounded_iff)
    80   then have Mge0: "0 \<le> M" by force
    80   then have "0 \<le> M" by force
    81   have ucontf: "uniformly_continuous_on {0..1} f"
    81   have ucontf: "uniformly_continuous_on {0..1} f"
    82     using compact_uniformly_continuous contf by blast
    82     using compact_uniformly_continuous contf by blast
    83   then obtain d where d: "d>0" "\<And>x x'. \<lbrakk> x \<in> {0..1}; x' \<in> {0..1}; \<bar>x' - x\<bar> < d\<rbrakk> \<Longrightarrow> \<bar>f x' - f x\<bar> < e/2"
    83   then obtain d where d: "d>0" "\<And>x x'. \<lbrakk> x \<in> {0..1}; x' \<in> {0..1}; \<bar>x' - x\<bar> < d\<rbrakk> \<Longrightarrow> \<bar>f x' - f x\<bar> < e/2"
    84      apply (rule uniformly_continuous_onE [where e = "e/2"])
    84      apply (rule uniformly_continuous_onE [where e = "e/2"])
    85      using e by (auto simp: dist_norm)
    85      using e by (auto simp: dist_norm)
   122       proof cases
   122       proof cases
   123         case lessd
   123         case lessd
   124         then have "\<bar>(f x - f (k/n))\<bar> < e/2"
   124         then have "\<bar>(f x - f (k/n))\<bar> < e/2"
   125           using d x kn by (simp add: abs_minus_commute)
   125           using d x kn by (simp add: abs_minus_commute)
   126         also have "... \<le> (e/2 + 2 * M / d\<^sup>2 * (x - k/n)\<^sup>2)"
   126         also have "... \<le> (e/2 + 2 * M / d\<^sup>2 * (x - k/n)\<^sup>2)"
   127           using Mge0 d by simp
   127           using \<open>M\<ge>0\<close> d by simp
   128         finally show ?thesis by simp
   128         finally show ?thesis by simp
   129       next
   129       next
   130         case ged
   130         case ged
   131         then have dle: "d\<^sup>2 \<le> (x - k/n)\<^sup>2"
   131         then have dle: "d\<^sup>2 \<le> (x - k/n)\<^sup>2"
   132           by (metis d(1) less_eq_real_def power2_abs power_mono)
   132           by (metis d(1) less_eq_real_def power2_abs power_mono)
       
   133         have \<section>: "1 \<le> (x - real k / real n)\<^sup>2 / d\<^sup>2"
       
   134           using dle \<open>d>0\<close> by auto
   133         have "\<bar>(f x - f (k/n))\<bar> \<le> \<bar>f x\<bar> + \<bar>f (k/n)\<bar>"
   135         have "\<bar>(f x - f (k/n))\<bar> \<le> \<bar>f x\<bar> + \<bar>f (k/n)\<bar>"
   134           by (rule abs_triangle_ineq4)
   136           by (rule abs_triangle_ineq4)
   135         also have "... \<le> M+M"
   137         also have "... \<le> M+M"
   136           by (meson M add_mono_thms_linordered_semiring(1) kn x)
   138           by (meson M add_mono_thms_linordered_semiring(1) kn x)
   137         also have "... \<le> 2 * M * ((x - k/n)\<^sup>2 / d\<^sup>2)"
   139         also have "... \<le> 2 * M * ((x - k/n)\<^sup>2 / d\<^sup>2)"
   138           apply simp
   140           using \<section> \<open>M\<ge>0\<close> mult_left_mono by fastforce
   139           apply (rule Rings.ordered_semiring_class.mult_left_mono [of 1 "((x - k/n)\<^sup>2 / d\<^sup>2)", simplified])
       
   140           using dle \<open>d>0\<close> \<open>M\<ge>0\<close> by auto
       
   141         also have "... \<le> e/2 + 2 * M / d\<^sup>2 * (x - k/n)\<^sup>2"
   141         also have "... \<le> e/2 + 2 * M / d\<^sup>2 * (x - k/n)\<^sup>2"
   142           using e  by simp
   142           using e  by simp
   143         finally show ?thesis .
   143         finally show ?thesis .
   144         qed
   144         qed
   145     } note * = this
   145     } note * = this
   146     have "\<bar>f x - (\<Sum>k\<le>n. f(k / n) * Bernstein n k x)\<bar> \<le> \<bar>\<Sum>k\<le>n. (f x - f(k / n)) * Bernstein n k x\<bar>"
   146     have "\<bar>f x - (\<Sum>k\<le>n. f(k / n) * Bernstein n k x)\<bar> \<le> \<bar>\<Sum>k\<le>n. (f x - f(k / n)) * Bernstein n k x\<bar>"
   147       by (simp add: sum_subtractf sum_distrib_left [symmetric] algebra_simps)
   147       by (simp add: sum_subtractf sum_distrib_left [symmetric] algebra_simps)
       
   148     also have "... \<le> (\<Sum>k\<le>n. \<bar>(f x - f(k / n)) * Bernstein n k x\<bar>)"
       
   149       by (rule sum_abs)
   148     also have "... \<le> (\<Sum>k\<le>n. (e/2 + (2 * M / d\<^sup>2) * (x - k / n)\<^sup>2) * Bernstein n k x)"
   150     also have "... \<le> (\<Sum>k\<le>n. (e/2 + (2 * M / d\<^sup>2) * (x - k / n)\<^sup>2) * Bernstein n k x)"
   149       apply (rule order_trans [OF sum_abs sum_mono])
       
   150       using *
   151       using *
   151       apply (simp add: abs_mult Bernstein_nonneg x mult_right_mono)
   152       by (force simp add: abs_mult Bernstein_nonneg x mult_right_mono intro: sum_mono)
   152       done
       
   153     also have "... \<le> e/2 + (2 * M) / (d\<^sup>2 * n)"
   153     also have "... \<le> e/2 + (2 * M) / (d\<^sup>2 * n)"
   154       apply (simp only: sum.distrib Rings.semiring_class.distrib_right sum_distrib_left [symmetric] mult.assoc sum_bern)
   154       unfolding sum.distrib Rings.semiring_class.distrib_right sum_distrib_left [symmetric] mult.assoc sum_bern
   155       using \<open>d>0\<close> x
   155       using \<open>d>0\<close> x by (simp add: divide_simps \<open>M\<ge>0\<close> mult_le_one mult_left_le)
   156       apply (simp add: divide_simps Mge0 mult_le_one mult_left_le)
       
   157       done
       
   158     also have "... < e"
   156     also have "... < e"
   159       apply (simp add: field_simps)
   157       using \<open>d>0\<close> nbig e \<open>n>0\<close> 
   160       using \<open>d>0\<close> nbig e \<open>n>0\<close>
       
   161       apply (simp add: field_split_simps)
   158       apply (simp add: field_split_simps)
   162       using ed0 by linarith
   159       using ed0 by linarith
   163     finally have "\<bar>f x - (\<Sum>k\<le>n. f (real k / real n) * Bernstein n k x)\<bar> < e" .
   160     finally have "\<bar>f x - (\<Sum>k\<le>n. f (real k / real n) * Bernstein n k x)\<bar> < e" .
   164   }
   161   }
   165   then show ?thesis
   162   then show ?thesis
   202     by (induct I rule: finite_induct; simp add: const mult)
   199     by (induct I rule: finite_induct; simp add: const mult)
   203 
   200 
   204   definition\<^marker>\<open>tag important\<close> normf :: "('a::t2_space \<Rightarrow> real) \<Rightarrow> real"
   201   definition\<^marker>\<open>tag important\<close> normf :: "('a::t2_space \<Rightarrow> real) \<Rightarrow> real"
   205     where "normf f \<equiv> SUP x\<in>S. \<bar>f x\<bar>"
   202     where "normf f \<equiv> SUP x\<in>S. \<bar>f x\<bar>"
   206 
   203 
   207   lemma normf_upper: "\<lbrakk>continuous_on S f; x \<in> S\<rbrakk> \<Longrightarrow> \<bar>f x\<bar> \<le> normf f"
   204   lemma normf_upper: 
   208     apply (simp add: normf_def)
   205     assumes "continuous_on S f" "x \<in> S" shows "\<bar>f x\<bar> \<le> normf f"
   209     apply (rule cSUP_upper, assumption)
   206   proof -
   210     by (simp add: bounded_imp_bdd_above compact compact_continuous_image compact_imp_bounded continuous_on_rabs)
   207     have "bdd_above ((\<lambda>x. \<bar>f x\<bar>) ` S)"
       
   208       by (simp add: assms(1) bounded_imp_bdd_above compact compact_continuous_image compact_imp_bounded continuous_on_rabs)
       
   209     then show ?thesis
       
   210       using assms cSUP_upper normf_def by fastforce
       
   211   qed
   211 
   212 
   212   lemma normf_least: "S \<noteq> {} \<Longrightarrow> (\<And>x. x \<in> S \<Longrightarrow> \<bar>f x\<bar> \<le> M) \<Longrightarrow> normf f \<le> M"
   213   lemma normf_least: "S \<noteq> {} \<Longrightarrow> (\<And>x. x \<in> S \<Longrightarrow> \<bar>f x\<bar> \<le> M) \<Longrightarrow> normf f \<le> M"
   213     by (simp add: normf_def cSUP_least)
   214     by (simp add: normf_def cSUP_least)
   214 
   215 
   215 end
   216 end
   369     have "q n t = (1/(k^n * (p t)^n)) * (1 - p t ^ n) ^ (k^n) * k^n * (p t)^n"
   370     have "q n t = (1/(k^n * (p t)^n)) * (1 - p t ^ n) ^ (k^n) * k^n * (p t)^n"
   370       using pt_pos [OF t] \<open>k>0\<close> by (simp add: q_def)
   371       using pt_pos [OF t] \<open>k>0\<close> by (simp add: q_def)
   371     also have "... \<le> (1/(k * (p t))^n) * (1 - p t ^ n) ^ (k^n) * (1 + k^n * (p t)^n)"
   372     also have "... \<le> (1/(k * (p t))^n) * (1 - p t ^ n) ^ (k^n) * (1 + k^n * (p t)^n)"
   372       using pt_pos [OF t] \<open>k>0\<close>
   373       using pt_pos [OF t] \<open>k>0\<close>
   373       apply simp
   374       apply simp
   374       apply (simp only: times_divide_eq_right [symmetric])
   375       apply (simp flip: times_divide_eq_right)
   375       apply (rule mult_left_mono [of "1::real", simplified])
   376       apply (rule mult_left_mono [of "1::real", simplified])
   376       apply (simp_all add: power_mult_distrib)
   377        apply (simp_all add: power_mult_distrib ptn_le)
   377       apply (rule zero_le_power)
   378       done
   378       using ptn_le by linarith
       
   379     also have "... \<le> (1/(k * (p t))^n) * (1 - p t ^ n) ^ (k^n) * (1 + (p t)^n) ^ (k^n)"
   379     also have "... \<le> (1/(k * (p t))^n) * (1 - p t ^ n) ^ (k^n) * (1 + (p t)^n) ^ (k^n)"
   380       apply (rule mult_left_mono [OF Bernoulli_inequality [of "p t ^ n" "k^n"]])
   380       apply (rule mult_left_mono [OF Bernoulli_inequality [of "p t ^ n" "k^n"]])
   381       using \<open>k>0\<close> ptn_pos ptn_le
   381       using \<open>k>0\<close> ptn_pos ptn_le
   382       apply (auto simp: power_mult_distrib)
   382       apply (auto simp: power_mult_distrib)
   383       done
   383       done
   396   define NN
   396   define NN
   397     where "NN e = 1 + nat \<lceil>max (ln e / ln (real k * \<delta> / 2)) (- ln e / ln (real k * \<delta>))\<rceil>" for e
   397     where "NN e = 1 + nat \<lceil>max (ln e / ln (real k * \<delta> / 2)) (- ln e / ln (real k * \<delta>))\<rceil>" for e
   398   have NN: "of_nat (NN e) > ln e / ln (real k * \<delta> / 2)"  "of_nat (NN e) > - ln e / ln (real k * \<delta>)"
   398   have NN: "of_nat (NN e) > ln e / ln (real k * \<delta> / 2)"  "of_nat (NN e) > - ln e / ln (real k * \<delta>)"
   399               if "0<e" for e
   399               if "0<e" for e
   400       unfolding NN_def  by linarith+
   400       unfolding NN_def  by linarith+
   401   have NN1: "\<And>e. e>0 \<Longrightarrow> (k * \<delta> / 2)^NN e < e"
   401     have NN1: "(k * \<delta> / 2)^NN e < e" if "e>0" for e
   402     apply (subst Transcendental.ln_less_cancel_iff [symmetric])
   402     proof -
   403       prefer 3 apply (subst ln_realpow)
   403       have "ln ((real k * \<delta> / 2) ^ NN e) < ln e"
   404     using \<open>k>0\<close> \<open>\<delta>>0\<close> NN  k\<delta>
   404         apply (subst ln_realpow)
   405     apply (force simp add: field_simps)+
   405         using NN k\<delta> that
   406     done
   406         by (force simp add: field_simps)+
       
   407       then show ?thesis
       
   408         by (simp add: \<open>\<delta>>0\<close> \<open>0 < k\<close> that)
       
   409     qed
   407   have NN0: "(1/(k*\<delta>)) ^ (NN e) < e" if "e>0" for e
   410   have NN0: "(1/(k*\<delta>)) ^ (NN e) < e" if "e>0" for e
   408   proof -
   411   proof -
   409     have "0 < ln (real k) + ln \<delta>"
   412     have "0 < ln (real k) + ln \<delta>"
   410       using \<delta>01(1) \<open>0 < k\<close> k\<delta>(1) ln_gt_zero ln_mult by fastforce 
   413       using \<delta>01(1) \<open>0 < k\<close> k\<delta>(1) ln_gt_zero ln_mult by fastforce 
   411     then have "real (NN e) * ln (1 / (real k * \<delta>)) < ln e"
   414     then have "real (NN e) * ln (1 / (real k * \<delta>)) < ln e"
   481     unfolding pff_def using subA ff by (auto simp: intro: prod)
   484     unfolding pff_def using subA ff by (auto simp: intro: prod)
   482   moreover
   485   moreover
   483   have pff01: "pff x \<in> {0..1}" if t: "x \<in> S" for x
   486   have pff01: "pff x \<in> {0..1}" if t: "x \<in> S" for x
   484   proof -
   487   proof -
   485     have "0 \<le> pff x"
   488     have "0 \<le> pff x"
   486       using subA cardp t
   489       using subA cardp t ff
   487       apply (simp add: pff_def field_split_simps sum_nonneg)
   490       by (fastforce simp: pff_def field_split_simps sum_nonneg intro: prod_nonneg)
   488       apply (rule Groups_Big.linordered_semidom_class.prod_nonneg)
       
   489       using ff by fastforce
       
   490     moreover have "pff x \<le> 1"
   491     moreover have "pff x \<le> 1"
   491       using subA cardp t
   492       using subA cardp t ff 
   492       apply (simp add: pff_def field_split_simps sum_nonneg)
   493       by (fastforce simp add: pff_def field_split_simps sum_nonneg intro: prod_mono [where g = "\<lambda>x. 1", simplified])
   493       apply (rule prod_mono [where g = "\<lambda>x. 1", simplified])
       
   494       using ff by fastforce
       
   495     ultimately show ?thesis
   494     ultimately show ?thesis
   496       by auto
   495       by auto
   497   qed
   496   qed
   498   moreover
   497   moreover
   499   { fix v x
   498   { fix v x
   500     assume v: "v \<in> subA" and x: "x \<in> Vf v" "x \<in> S"
   499     assume v: "v \<in> subA" and x: "x \<in> Vf v" "x \<in> S"
   501     from subA v have "pff x = ff v x * (\<Prod>w \<in> subA - {v}. ff w x)"
   500     from subA v have "pff x = ff v x * (\<Prod>w \<in> subA - {v}. ff w x)"
   502       unfolding pff_def  by (metis prod.remove)
   501       unfolding pff_def  by (metis prod.remove)
   503     also have "... \<le> ff v x * 1"
   502     also have "... \<le> ff v x * 1"
   504       apply (rule Rings.ordered_semiring_class.mult_left_mono)
   503     proof -
   505       apply (rule prod_mono [where g = "\<lambda>x. 1", simplified])
   504       have "\<And>i. i \<in> subA - {v} \<Longrightarrow> 0 \<le> ff i x \<and> ff i x \<le> 1"
   506       using ff [THEN conjunct2, THEN conjunct1] v subA x
   505         by (metis Diff_subset atLeastAtMost_iff ff image_subset_iff subA(1) subsetD x(2))
   507       apply auto
   506       moreover have "0 \<le> ff v x"
   508       apply (meson atLeastAtMost_iff contra_subsetD imageI)
   507         using ff subA(1) v x(2) by fastforce
   509       apply (meson atLeastAtMost_iff contra_subsetD image_eqI)
   508       ultimately show ?thesis
   510       using atLeastAtMost_iff by blast
   509         by (metis mult_left_mono prod_mono [where g = "\<lambda>x. 1", simplified])
       
   510     qed
   511     also have "... < e / card subA"
   511     also have "... < e / card subA"
   512       using ff [THEN conjunct2, THEN conjunct2, THEN conjunct1] v subA x
   512       using ff subA(1) v x by auto
   513       by auto
       
   514     also have "... \<le> e"
   513     also have "... \<le> e"
   515       using cardp e by (simp add: field_split_simps)
   514       using cardp e by (simp add: field_split_simps)
   516     finally have "pff x < e" .
   515     finally have "pff x < e" .
   517   }
   516   }
   518   then have "\<And>x. x \<in> A \<Longrightarrow> pff x < e"
   517   then have "\<And>x. x \<in> A \<Longrightarrow> pff x < e"
   526       using Bernoulli_inequality [of "-e / card subA" "card subA"] e cardp
   525       using Bernoulli_inequality [of "-e / card subA" "card subA"] e cardp
   527       by (auto simp: field_simps)
   526       by (auto simp: field_simps)
   528     also have "... = (\<Prod>w \<in> subA. 1 - e / card subA)"
   527     also have "... = (\<Prod>w \<in> subA. 1 - e / card subA)"
   529       by (simp add: subA(2))
   528       by (simp add: subA(2))
   530     also have "... < pff x"
   529     also have "... < pff x"
       
   530     proof -
       
   531       have "\<And>i. i \<in> subA \<Longrightarrow> e / real (card subA) \<le> 1 \<and> 1 - e / real (card subA) < ff i x"
       
   532         using e \<open>B \<subseteq> S\<close> ff subA(1) x by (force simp: field_split_simps)
       
   533       then show ?thesis
   531       apply (simp add: pff_def)
   534       apply (simp add: pff_def)
   532       apply (rule prod_mono_strict [where f = "\<lambda>x. 1 - e / card subA", simplified])
   535       apply (rule prod_mono_strict [where f = "\<lambda>x. 1 - e / card subA", simplified])
   533       apply (simp_all add: subA(2))
   536           apply (simp_all add: subA(2))
   534       apply (intro ballI conjI)
   537         done
   535       using e apply (force simp: field_split_simps)
   538     qed
   536       using ff [THEN conjunct2, THEN conjunct2, THEN conjunct2] subA B x
       
   537       apply blast
       
   538       done
       
   539     finally have "1 - e < pff x" .
   539     finally have "1 - e < pff x" .
   540   }
   540   }
   541   ultimately
   541   ultimately show ?thesis by blast
   542   show ?thesis by blast
       
   543 qed
   542 qed
   544 
   543 
   545 lemma (in function_ring_on) two:
   544 lemma (in function_ring_on) two:
   546   assumes A: "closed A" "A \<subseteq> S"
   545   assumes A: "closed A" "A \<subseteq> S"
   547       and B: "closed B" "B \<subseteq> S"
   546       and B: "closed B" "B \<subseteq> S"
   548       and disj: "A \<inter> B = {}"
   547       and disj: "A \<inter> B = {}"
   549       and e: "0 < e" "e < 1"
   548       and e: "0 < e" "e < 1"
   550     shows "\<exists>f \<in> R. f ` S \<subseteq> {0..1} \<and> (\<forall>x \<in> A. f x < e) \<and> (\<forall>x \<in> B. f x > 1 - e)"
   549     shows "\<exists>f \<in> R. f ` S \<subseteq> {0..1} \<and> (\<forall>x \<in> A. f x < e) \<and> (\<forall>x \<in> B. f x > 1 - e)"
   551 proof (cases "A \<noteq> {} \<and> B \<noteq> {}")
   550 proof (cases "A \<noteq> {} \<and> B \<noteq> {}")
   552   case True then show ?thesis
   551   case True then show ?thesis
   553     apply (simp flip: ex_in_conv)
       
   554     using assms
   552     using assms
   555     apply safe
   553     by (force simp flip: ex_in_conv intro!: two_special)
   556     apply (force simp add: intro!: two_special)
       
   557     done
       
   558 next
   554 next
   559   case False with e show ?thesis
   555   case False with e show ?thesis
   560     apply simp
   556     apply simp
   561     apply (erule disjE)
   557     apply (erule disjE)
   562     apply (rule_tac [2] x="\<lambda>x. 0" in bexI)
   558     apply (rule_tac [2] x="\<lambda>x. 0" in bexI)
  1385                  (\<Sum>i\<in>B. (norm ((f x \<bullet> i) *\<^sub>R i - (g x \<bullet> i) *\<^sub>R i))\<^sup>2)"
  1381                  (\<Sum>i\<in>B. (norm ((f x \<bullet> i) *\<^sub>R i - (g x \<bullet> i) *\<^sub>R i))\<^sup>2)"
  1386         by (simp add:  norm_sum_Pythagorean [OF \<open>finite B\<close> orth'])
  1382         by (simp add:  norm_sum_Pythagorean [OF \<open>finite B\<close> orth'])
  1387       also have "... = (\<Sum>i\<in>B. (norm (((f x - g x) \<bullet> i) *\<^sub>R i))\<^sup>2)"
  1383       also have "... = (\<Sum>i\<in>B. (norm (((f x - g x) \<bullet> i) *\<^sub>R i))\<^sup>2)"
  1388         by (simp add: algebra_simps)
  1384         by (simp add: algebra_simps)
  1389       also have "... \<le> (\<Sum>i\<in>B. (norm (f x - g x))\<^sup>2)"
  1385       also have "... \<le> (\<Sum>i\<in>B. (norm (f x - g x))\<^sup>2)"
  1390         apply (rule sum_mono)
  1386       proof -
  1391         apply (simp add: B1)
  1387         have "\<And>i. i \<in> B \<Longrightarrow> ((f x - g x) \<bullet> i)\<^sup>2 \<le> (norm (f x - g x))\<^sup>2"
  1392         apply (rule order_trans [OF Cauchy_Schwarz_ineq])
  1388           by (metis B1 Cauchy_Schwarz_ineq inner_commute mult.left_neutral norm_eq_1 power2_norm_eq_inner)
  1393         by (simp add: B1 dot_square_norm)
  1389         then show ?thesis
       
  1390           by (intro sum_mono) (simp add: sum_mono B1)
       
  1391       qed
  1394       also have "... = n * norm (f x - g x)^2"
  1392       also have "... = n * norm (f x - g x)^2"
  1395         by (simp add: \<open>n = card B\<close>)
  1393         by (simp add: \<open>n = card B\<close>)
  1396       also have "... \<le> n * (e / (n+2))^2"
  1394       also have "... \<le> n * (e / (n+2))^2"
  1397         apply (rule mult_left_mono)
  1395       proof (rule mult_left_mono)
  1398          apply (meson dual_order.order_iff_strict g norm_ge_zero power_mono that, simp)
  1396         show "(norm (f x - g x))\<^sup>2 \<le> (e / real (n + 2))\<^sup>2"
  1399         done
  1397           by (meson dual_order.order_iff_strict g norm_ge_zero power_mono that)
       
  1398       qed auto
  1400       also have "... \<le> e^2 / (n+2)"
  1399       also have "... \<le> e^2 / (n+2)"
  1401         using \<open>0 < e\<close> by (simp add: divide_simps power2_eq_square)
  1400         using \<open>0 < e\<close> by (simp add: divide_simps power2_eq_square)
  1402       also have "... < e^2"
  1401       also have "... < e^2"
  1403         using \<open>0 < e\<close> by (simp add: divide_simps)
  1402         using \<open>0 < e\<close> by (simp add: divide_simps)
  1404       finally have "(norm (\<Sum>i\<in>B. (f x \<bullet> i) *\<^sub>R i - (g x \<bullet> i) *\<^sub>R i))\<^sup>2 < e^2" .
  1403       finally have "(norm (\<Sum>i\<in>B. (f x \<bullet> i) *\<^sub>R i - (g x \<bullet> i) *\<^sub>R i))\<^sup>2 < e^2" .
  1405       then have "(norm (\<Sum>i\<in>B. (f x \<bullet> i) *\<^sub>R i - (g x \<bullet> i) *\<^sub>R i)) < e"
  1404       then have "(norm (\<Sum>i\<in>B. (f x \<bullet> i) *\<^sub>R i - (g x \<bullet> i) *\<^sub>R i)) < e"
  1406         apply (rule power2_less_imp_less)
  1405         by (simp add: \<open>0 < e\<close> norm_lt_square power2_norm_eq_inner)
  1407         using  \<open>0 < e\<close> by auto
       
  1408       then show ?thesis
  1406       then show ?thesis
  1409         using fx that by (simp add: sum_subtractf)
  1407         using fx that by (simp add: sum_subtractf)
  1410     qed
  1408     qed
  1411   qed
  1409   qed
  1412 qed
  1410 qed