src/HOL/Analysis/Weierstrass_Theorems.thy
changeset 71633 07bec530f02e
parent 71172 575b3a818de5
child 72221 98ef41a82b73
equal deleted inserted replaced
71629:2e8f861d21d4 71633:07bec530f02e
   108         apply (simp add: algebra_simps power2_eq_square)
   108         apply (simp add: algebra_simps power2_eq_square)
   109         done
   109         done
   110       then have "(\<Sum>k\<le>n. (k - n * x)\<^sup>2 * Bernstein n k x)/n^2 = x * (1 - x) / n"
   110       then have "(\<Sum>k\<le>n. (k - n * x)\<^sup>2 * Bernstein n k x)/n^2 = x * (1 - x) / n"
   111         by (simp add: power2_eq_square)
   111         by (simp add: power2_eq_square)
   112       then show ?thesis
   112       then show ?thesis
   113         using n by (simp add: sum_divide_distrib field_split_simps mult.commute power2_commute)
   113         using n by (simp add: sum_divide_distrib field_split_simps power2_commute)
   114     qed
   114     qed
   115     { fix k
   115     { fix k
   116       assume k: "k \<le> n"
   116       assume k: "k \<le> n"
   117       then have kn: "0 \<le> k / n" "k / n \<le> 1"
   117       then have kn: "0 \<le> k / n" "k / n \<le> 1"
   118         by (auto simp: field_split_simps)
   118         by (auto simp: field_split_simps)
   156       apply (simp add: divide_simps Mge0 mult_le_one mult_left_le)
   156       apply (simp add: divide_simps Mge0 mult_le_one mult_left_le)
   157       done
   157       done
   158     also have "... < e"
   158     also have "... < e"
   159       apply (simp add: field_simps)
   159       apply (simp add: field_simps)
   160       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 algebra_simps)
   161       apply (simp add: field_split_simps)
   162       using ed0 by linarith
   162       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" .
   163     finally have "\<bar>f x - (\<Sum>k\<le>n. f (real k / real n) * Bernstein n k x)\<bar> < e" .
   164   }
   164   }
   165   then show ?thesis
   165   then show ?thesis
   166     by auto
   166     by auto
   574   define n where "n = 1 + nat \<lceil>normf f / e\<rceil>"
   574   define n where "n = 1 + nat \<lceil>normf f / e\<rceil>"
   575   define A where "A j = {x \<in> S. f x \<le> (j - 1/3)*e}" for j :: nat
   575   define A where "A j = {x \<in> S. f x \<le> (j - 1/3)*e}" for j :: nat
   576   define B where "B j = {x \<in> S. f x \<ge> (j + 1/3)*e}" for j :: nat
   576   define B where "B j = {x \<in> S. f x \<ge> (j + 1/3)*e}" for j :: nat
   577   have ngt: "(n-1) * e \<ge> normf f" "n\<ge>1"
   577   have ngt: "(n-1) * e \<ge> normf f" "n\<ge>1"
   578     using e
   578     using e
   579     apply (simp_all add: n_def field_simps of_nat_Suc)
   579     apply (simp_all add: n_def field_simps)
   580     by (metis real_nat_ceiling_ge mult.commute not_less pos_less_divide_eq)
   580     by (metis real_nat_ceiling_ge mult.commute not_less pos_less_divide_eq)
   581   then have ge_fx: "(n-1) * e \<ge> f x" if "x \<in> S" for x
   581   then have ge_fx: "(n-1) * e \<ge> f x" if "x \<in> S" for x
   582     using f normf_upper that by fastforce
   582     using f normf_upper that by fastforce
   583   { fix j
   583   { fix j
   584     have A: "closed (A j)" "A j \<subseteq> S"
   584     have A: "closed (A j)" "A j \<subseteq> S"
   644       then obtain d where "i+2+d = j"
   644       then obtain d where "i+2+d = j"
   645         using le_Suc_ex that by blast
   645         using le_Suc_ex that by blast
   646       then have "t \<in> B i"
   646       then have "t \<in> B i"
   647         using Anj e ge_fx [OF t] \<open>1 \<le> n\<close> fpos [OF t] t
   647         using Anj e ge_fx [OF t] \<open>1 \<le> n\<close> fpos [OF t] t
   648         apply (simp add: A_def B_def)
   648         apply (simp add: A_def B_def)
   649         apply (clarsimp simp add: field_simps of_nat_diff not_le of_nat_Suc)
   649         apply (clarsimp simp add: field_simps of_nat_diff not_le)
   650         apply (rule order_trans [of _ "e * 2 + (e * (real d * 3) + e * (real i * 3))"])
   650         apply (rule order_trans [of _ "e * 2 + (e * (real d * 3) + e * (real i * 3))"])
   651         apply auto
   651         apply auto
   652         done
   652         done
   653       then have "xf i t > 1 - e/n"
   653       then have "xf i t > 1 - e/n"
   654         by (rule xfB)
   654         by (rule xfB)
   691       also have "... \<le> e * (\<Sum>i\<le>j-2. xf i t)"
   691       also have "... \<le> e * (\<Sum>i\<le>j-2. xf i t)"
   692         using e
   692         using e
   693         apply simp
   693         apply simp
   694         apply (rule order_trans [OF _ sum_bounded_below [OF less_imp_le [OF ****]]])
   694         apply (rule order_trans [OF _ sum_bounded_below [OF less_imp_le [OF ****]]])
   695         using True
   695         using True
   696         apply (simp_all add: of_nat_Suc of_nat_diff)
   696         apply (simp_all add: of_nat_diff)
   697         done
   697         done
   698       also have "... \<le> g t"
   698       also have "... \<le> g t"
   699         using jn e
   699         using jn e
   700         using e xf01 t
   700         using e xf01 t
   701         apply (simp add: g_def zero_le_mult_iff image_subset_iff sum_nonneg)
   701         apply (simp add: g_def zero_le_mult_iff image_subset_iff sum_nonneg)
   742       assume n: "N \<le> n"  "\<forall>x\<in>S. \<bar>f x - g x\<bar> < 1 / (1 + real n)"
   742       assume n: "N \<le> n"  "\<forall>x\<in>S. \<bar>f x - g x\<bar> < 1 / (1 + real n)"
   743       assume x: "x \<in> S"
   743       assume x: "x \<in> S"
   744       have "\<not> real (Suc n) < inverse e"
   744       have "\<not> real (Suc n) < inverse e"
   745         using \<open>N \<le> n\<close> N using less_imp_inverse_less by force
   745         using \<open>N \<le> n\<close> N using less_imp_inverse_less by force
   746       then have "1 / (1 + real n) \<le> e"
   746       then have "1 / (1 + real n) \<le> e"
   747         using e by (simp add: field_simps of_nat_Suc)
   747         using e by (simp add: field_simps)
   748       then have "\<bar>f x - g x\<bar> < e"
   748       then have "\<bar>f x - g x\<bar> < e"
   749         using n(2) x by auto
   749         using n(2) x by auto
   750     } note * = this
   750     } note * = this
   751     have "\<forall>\<^sub>F n in sequentially. \<forall>x\<in>S. \<bar>f x - (SOME g. g \<in> R \<and> (\<forall>x\<in>S. \<bar>f x - g x\<bar> < 1 / (1 + real n))) x\<bar> < e"
   751     have "\<forall>\<^sub>F n in sequentially. \<forall>x\<in>S. \<bar>f x - (SOME g. g \<in> R \<and> (\<forall>x\<in>S. \<bar>f x - g x\<bar> < 1 / (1 + real n))) x\<bar> < e"
   752       apply (rule eventually_sequentiallyI [of N])
   752       apply (rule eventually_sequentiallyI [of N])
   925 next
   925 next
   926   case (const c)
   926   case (const c)
   927   show ?case
   927   show ?case
   928     apply (rule_tac x="\<lambda>i. c" in exI)
   928     apply (rule_tac x="\<lambda>i. c" in exI)
   929     apply (rule_tac x=0 in exI)
   929     apply (rule_tac x=0 in exI)
   930     apply (auto simp: mult_ac of_nat_Suc)
   930     apply (auto simp: mult_ac)
   931     done
   931     done
   932   case (add f1 f2)
   932   case (add f1 f2)
   933   then obtain a1 n1 a2 n2 where
   933   then obtain a1 n1 a2 n2 where
   934     "f1 = (\<lambda>x. \<Sum>i\<le>n1. a1 i * x ^ i)" "f2 = (\<lambda>x. \<Sum>i\<le>n2. a2 i * x ^ i)"
   934     "f1 = (\<lambda>x. \<Sum>i\<le>n1. a1 i * x ^ i)" "f2 = (\<lambda>x. \<Sum>i\<le>n2. a2 i * x ^ i)"
   935     by auto
   935     by auto
  1326     have "i \<bullet> (\<Sum>i\<in>B. (x \<bullet> i) *\<^sub>R i) = (\<Sum>j\<in>B. x \<bullet> j * (i \<bullet> j))"
  1326     have "i \<bullet> (\<Sum>i\<in>B. (x \<bullet> i) *\<^sub>R i) = (\<Sum>j\<in>B. x \<bullet> j * (i \<bullet> j))"
  1327       by (simp add: inner_sum_right)
  1327       by (simp add: inner_sum_right)
  1328     also have "... = (\<Sum>j\<in>B. if j = i then x \<bullet> i else 0)"
  1328     also have "... = (\<Sum>j\<in>B. if j = i then x \<bullet> i else 0)"
  1329       by (rule sum.cong; simp)
  1329       by (rule sum.cong; simp)
  1330     also have "... = i \<bullet> x"
  1330     also have "... = i \<bullet> x"
  1331       by (simp add: \<open>finite B\<close> that inner_commute sum.delta)
  1331       by (simp add: \<open>finite B\<close> that inner_commute)
  1332     finally show ?thesis .
  1332     finally show ?thesis .
  1333   qed
  1333   qed
  1334 qed
  1334 qed
  1335 
  1335 
  1336 
  1336