equal
deleted
inserted
replaced
63 |
63 |
64 lemma Bernstein_Weierstrass: |
64 lemma Bernstein_Weierstrass: |
65 fixes f :: "real \<Rightarrow> real" |
65 fixes f :: "real \<Rightarrow> real" |
66 assumes contf: "continuous_on {0..1} f" and e: "0 < e" |
66 assumes contf: "continuous_on {0..1} f" and e: "0 < e" |
67 shows "\<exists>N. \<forall>n x. N \<le> n \<and> x \<in> {0..1} |
67 shows "\<exists>N. \<forall>n x. N \<le> n \<and> x \<in> {0..1} |
68 \<longrightarrow> abs(f x - (\<Sum>k = 0..n. f(k/n) * Bernstein n k x)) < e" |
68 \<longrightarrow> \<bar>f x - (\<Sum>k = 0..n. f(k/n) * Bernstein n k x)\<bar> < e" |
69 proof - |
69 proof - |
70 have "bounded (f ` {0..1})" |
70 have "bounded (f ` {0..1})" |
71 using compact_continuous_image compact_imp_bounded contf by blast |
71 using compact_continuous_image compact_imp_bounded contf by blast |
72 then obtain M where M: "\<And>x. 0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> \<bar>f x\<bar> \<le> M" |
72 then obtain M where M: "\<And>x. 0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> \<bar>f x\<bar> \<le> M" |
73 by (force simp add: bounded_iff) |
73 by (force simp add: bounded_iff) |
108 qed |
108 qed |
109 { fix k |
109 { fix k |
110 assume k: "k \<le> n" |
110 assume k: "k \<le> n" |
111 then have kn: "0 \<le> k / n" "k / n \<le> 1" |
111 then have kn: "0 \<le> k / n" "k / n \<le> 1" |
112 by (auto simp: divide_simps) |
112 by (auto simp: divide_simps) |
113 consider (lessd) "abs(x - k / n) < d" | (ged) "d \<le> abs(x - k / n)" |
113 consider (lessd) "\<bar>x - k / n\<bar> < d" | (ged) "d \<le> \<bar>x - k / n\<bar>" |
114 by linarith |
114 by linarith |
115 then have "\<bar>(f x - f (k/n))\<bar> \<le> e/2 + 2 * M / d\<^sup>2 * (x - k/n)\<^sup>2" |
115 then have "\<bar>(f x - f (k/n))\<bar> \<le> e/2 + 2 * M / d\<^sup>2 * (x - k/n)\<^sup>2" |
116 proof cases |
116 proof cases |
117 case lessd |
117 case lessd |
118 then have "\<bar>(f x - f (k/n))\<bar> < e/2" |
118 then have "\<bar>(f x - f (k/n))\<bar> < e/2" |
756 "\<And>f. P f \<Longrightarrow> continuous_on s f" |
756 "\<And>f. P f \<Longrightarrow> continuous_on s f" |
757 "\<And>f g. P(f) \<and> P(g) \<Longrightarrow> P(\<lambda>x. f x + g x)" "\<And>f g. P(f) \<and> P(g) \<Longrightarrow> P(\<lambda>x. f x * g x)" |
757 "\<And>f g. P(f) \<and> P(g) \<Longrightarrow> P(\<lambda>x. f x + g x)" "\<And>f g. P(f) \<and> P(g) \<Longrightarrow> P(\<lambda>x. f x * g x)" |
758 "\<And>x y. x \<in> s \<and> y \<in> s \<and> ~(x = y) \<Longrightarrow> \<exists>f. P(f) \<and> ~(f x = f y)" |
758 "\<And>x y. x \<in> s \<and> y \<in> s \<and> ~(x = y) \<Longrightarrow> \<exists>f. P(f) \<and> ~(f x = f y)" |
759 "continuous_on s f" |
759 "continuous_on s f" |
760 "0 < e" |
760 "0 < e" |
761 shows "\<exists>g. P(g) \<and> (\<forall>x \<in> s. abs(f x - g x) < e)" |
761 shows "\<exists>g. P(g) \<and> (\<forall>x \<in> s. \<bar>f x - g x\<bar> < e)" |
762 proof - |
762 proof - |
763 interpret PR: function_ring_on "Collect P" |
763 interpret PR: function_ring_on "Collect P" |
764 apply unfold_locales |
764 apply unfold_locales |
765 using assms |
765 using assms |
766 by auto |
766 by auto |
1079 qed |
1079 qed |
1080 |
1080 |
1081 lemma Stone_Weierstrass_real_polynomial_function: |
1081 lemma Stone_Weierstrass_real_polynomial_function: |
1082 fixes f :: "'a::euclidean_space \<Rightarrow> real" |
1082 fixes f :: "'a::euclidean_space \<Rightarrow> real" |
1083 assumes "compact s" "continuous_on s f" "0 < e" |
1083 assumes "compact s" "continuous_on s f" "0 < e" |
1084 shows "\<exists>g. real_polynomial_function g \<and> (\<forall>x \<in> s. abs(f x - g x) < e)" |
1084 shows "\<exists>g. real_polynomial_function g \<and> (\<forall>x \<in> s. \<bar>f x - g x\<bar> < e)" |
1085 proof - |
1085 proof - |
1086 interpret PR: function_ring_on "Collect real_polynomial_function" |
1086 interpret PR: function_ring_on "Collect real_polynomial_function" |
1087 apply unfold_locales |
1087 apply unfold_locales |
1088 using assms continuous_on_polymonial_function real_polynomial_function_eq |
1088 using assms continuous_on_polymonial_function real_polynomial_function_eq |
1089 apply (auto intro: real_polynomial_function_separable) |
1089 apply (auto intro: real_polynomial_function_separable) |
1100 and e: "0 < e" |
1100 and e: "0 < e" |
1101 shows "\<exists>g. polynomial_function g \<and> (\<forall>x \<in> s. norm(f x - g x) < e)" |
1101 shows "\<exists>g. polynomial_function g \<and> (\<forall>x \<in> s. norm(f x - g x) < e)" |
1102 proof - |
1102 proof - |
1103 { fix b :: 'b |
1103 { fix b :: 'b |
1104 assume "b \<in> Basis" |
1104 assume "b \<in> Basis" |
1105 have "\<exists>p. real_polynomial_function p \<and> (\<forall>x \<in> s. abs(f x \<bullet> b - p x) < e / DIM('b))" |
1105 have "\<exists>p. real_polynomial_function p \<and> (\<forall>x \<in> s. \<bar>f x \<bullet> b - p x\<bar> < e / DIM('b))" |
1106 apply (rule exE [OF Stone_Weierstrass_real_polynomial_function [OF s _, of "\<lambda>x. f x \<bullet> b" "e / card Basis"]]) |
1106 apply (rule exE [OF Stone_Weierstrass_real_polynomial_function [OF s _, of "\<lambda>x. f x \<bullet> b" "e / card Basis"]]) |
1107 using e f |
1107 using e f |
1108 apply (auto simp: Euclidean_Space.DIM_positive intro: continuous_intros) |
1108 apply (auto simp: Euclidean_Space.DIM_positive intro: continuous_intros) |
1109 done |
1109 done |
1110 } |
1110 } |
1111 then obtain pf where pf: |
1111 then obtain pf where pf: |
1112 "\<And>b. b \<in> Basis \<Longrightarrow> real_polynomial_function (pf b) \<and> (\<forall>x \<in> s. abs(f x \<bullet> b - pf b x) < e / DIM('b))" |
1112 "\<And>b. b \<in> Basis \<Longrightarrow> real_polynomial_function (pf b) \<and> (\<forall>x \<in> s. \<bar>f x \<bullet> b - pf b x\<bar> < e / DIM('b))" |
1113 apply (rule bchoice [rule_format, THEN exE]) |
1113 apply (rule bchoice [rule_format, THEN exE]) |
1114 apply assumption |
1114 apply assumption |
1115 apply (force simp add: intro: that) |
1115 apply (force simp add: intro: that) |
1116 done |
1116 done |
1117 have "polynomial_function (\<lambda>x. \<Sum>b\<in>Basis. pf b x *\<^sub>R b)" |
1117 have "polynomial_function (\<lambda>x. \<Sum>b\<in>Basis. pf b x *\<^sub>R b)" |