Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


SSL Weierstrass_Theorems.thy   Interaktion und
PortierbarkeitIsabelle

 
section [ x1x ]

text\<open>By L C Paulson (2015)\<close>

theory Weierstrass_Theorems
imports Uniform_Limit Path_Connected Derivative \<open>Bernstein-Weierstrass and Stone-Weierstrass\<close>
begin

subsection \<open>Bernstein polynomials\<close>

definition\<^marker>\<open>tag important\<close> Bernstein :: "[nat,nat,real] \<Rightarrow> real" where
  "Bernstein n k x \ of_nat (n choose k) * x^k * (1 - x)^(n - k)"

definition<marker
  by ( add )

lemma\lbrakk xx<;k\<le> n\<rbrakk> \<Longrightarrow> 0 < Bernstein n k x"
  by (simp kxjava.lang.NullPointerException

lemma sum_Bernstein [simp]: "(\k\n. Bernstein n k x) = 1"
  using binomial_ring [of x "1-x" n]
  by (simp add: Bernstein_def)

lemma binomial_deriv1:
    "(\k\n. (of_nat k * of_nat (n choose k)) * a^(k-1) * b^(n-k)) = real_of_nat n * (a+b)^(n-1)"
  apply (rule DERIV_unique [where f = "\a. (a+b)^n" and x=a])
  apply (subst binomial_ring)
  apply (rule derivative_eq_intros sum.cong | simp add: atMost_atLeast0)+
  done

lemma binomial_deriv2:
    "(\k\n. (of_nat k * of_nat (k-1) * of_nat (n choose k)) * a^(k-2) * b^(n-k)) =
     of_nat n * of_nat (n-1) * (a+b::real)^(n-2)"
  apply (rule DERIV_unique [where f = "\a. of_nat n * (a+b::real)^(n-1)" and x=a])
  apply (subst binomial_deriv1 [symmetric])
  apply (rule derivative_eq_intros sum.cong | simp add: Num.numeral_2_eq_2)+
  done

lemma sum_k_Bernstein [simp]: "(\k\n. real k * Bernstein n k x) = of_nat n * x"
  apply (subst binomial_deriv1 [of n x "1-x", simplified, symmetric])
  apply (simp add: sum_distrib_right)
  apply (auto simp: Bernstein_def algebra_simps power_eq_if intro!: sum.cong)
  done

lemma sum_kk_Bernstein [simp]: "(\k\n. real k * (real k - 1) * Bernstein n k x) = real n * (real n - 1) * x\<^sup>2"
proof -
  have "(\k\n. real k * (real k - 1) * Bernstein n k x) =
        (\<Sum>k\<le>n. real k * real (k - Suc 0) * real (n choose k) * x^(k - 2) * (1 - x)^(n - k) * x\<^sup>2)"
  proof (rule sum.cong [OF refl], simp)
    fix k
    assume "k \ n"
    then consider "k = 0" | "k = 1" | k' where "k = Suc (Suc k')"
      by (metis One_nat_def not0_implies_Suc)
    then show "k = 0 \
          (real k - 1) * Bernstein n k x =
          real (k - Suc 0) *
          (real (n choose k) * (x^(k - 2) * ((1 - x)^(n - k) * x\<^sup>2)))"
      by cases (auto simp add: Bernstein_def power2_eq_square algebra_simps)
  qed
  also have "... = real_of_nat n * real_of_nat (n - Suc 0) * x\<^sup>2"
    by (subst binomial_deriv2 [of n x "1-x", simplified, symmetric]) (simp add: sum_distrib_right)
  also have "... = n * (n - 1) * x\<^sup>2"
    by auto
  finally show ?thesis
    by auto
qed

subsection \<open>Explicit Bernstein version of the 1D Weierstrass approximation theorem\<close>

theorem Bernstein_Weierstrass:
  fixes f :: "real \ real"
  assumes contf: "continuous_on {0..1} f" and e: "0 < e"
    shows "\N. \n x. N \ n \ x \ {0..1}
                    \<longrightarrow> \<bar>f x - (\<Sum>k\<le>n. f(k/n) * Bernstein n k x)\<bar> < e"
proof -
  have "bounded (f ` {0..1})"
    using compact_continuous_image compact_imp_bounded contf by blast
  then obtain M where M: "\x. 0 \ x \ x \ 1 \ \f x\ \ M"
    by (force simp add: bounded_iff)
  then have "0 \ M" by force
  have ucontf: "uniformly_continuous_on {0..1} f"
    using compact_uniformly_continuous contf by blast
  then obtain d where d: "d>0" "\x x'. \ x \ {0..1}; x' \ {0..1}; \x' - x\ < d\ \ \f x' - f x\ < e/2"
     apply (rule uniformly_continuous_onE [where \<epsilon> = "e/2"])
     using e by (auto simp: dist_norm)
  { fix n::nat
assume n: Suc
    haveimports  Path_Connected
    java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
      java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    alsohave.\<le> M * 4"
      using
    finallyhave[]:" (nat
      using \<open>0\<le>M\<close> e \<open>0<d\<close>
      by (simp add: field_simps)
    have*ed
      by (simp(Sum
    also have   rule [here "\a. (a+b)^n" and x=a])
      using ( add)
    finally haverule .cong : atMost_atLeast0
have"(<>k\n. (x - k/n)\<^sup>2 * Bernstein n k x) = x * (1 - x) / n"
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
      have java.lang.StringIndexOutOfBoundsException: Index 106 out of bounds for length 106
 addalgebra_simps)
      have "(\k\n. (k - n * x)\<^sup>2 * Bernstein n k x) = n * x * (1 - x)"
        applysimp sum)
        apply (simp flip( derivative_eq_intros. |  add.numeral_2_eq_2
 (simp: algebra_simps)
        done
      then "\Sumkle>n. (k - n * x)\<^sup>2 * Bernstein n k x)/n^2 = x * (1 - x) / n"
bysimp)
      thenapplyauto  algebra_simps introcong
         n  ( add field_split_simps)
    qed
    { fix k
      assume k: "k \ n"
      then have kn: "0 \Sum>k
        by (auto simp: field_split_simps)
       (lessd
        by linarith
 have \barfx - kn)\<bar> \<le> e/2 + 2 * M / d\<^sup>2 * (x - k/n)\<^sup>2"
      proof
case
 have\barf  f kn) /"
           d xkn add)
        also have "... ) *
          using
        finally show ?thesis        (auto: Bernstein_def)
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
        case
        then have dle". = *( - )*x
           ?thesis
        java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
        haveassumes" {0..1 " :0<e"
          by (rule\<longrightarrow> \<bar>f x - (\<Sum>k\<le>n. f(k/n) * Bernstein n k x)\<bar> < e"
         have
bymeson(1) x)
        also have "... \ 2 * M * ((x - k/n)\<^sup>2 / d\<^sup>2)"
          using \<section> \<open>M\<ge>0\<close> mult_left_mono by fastforceby( simp:)
  ". \ e/2 + 2 * M / d\<^sup>2 * (x - k/n)\<^sup>2"
          using e  by     using compact_uniformly_continuousjava.lang.StringIndexOutOfBoundsException: Range [53, 54) out of bounds for length 53
              eby simp)
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
    } note *     " n n bysimp
    haveusing
      byalso ". M * 4"
    also have "... \ (\k\n. \(f x - f(k / n)) * Bernstein n k x\)"
      by (rule
     havesimpnat
      using *
by( simp  Bernstein_nonneg : sum_mono
      ".
unfolding.distrib_rightmult
      using add)
also ".
      using \<open>d>0\<close> nbig e \<open>n>0\<close>   simp: field_simps
      apply (simp add : "(<>\n. (x - k/n)\<^sup>2 * Bernstein n k x) = x * (1 - x) / n"
      using ed0 java.lang.StringIndexOutOfBoundsException: Range [0, 18) out of bounds for length 11
 have
  }
  then show ?thesis"\>k
    by auto
qed


>GeneralStone-Weierstrass theorem\<close>

text\<open>Source:
Bruno Brosowski and Frank Deutsch.
An Elementary Proof of the Stone-Weierstrass Theorem.
Proceedings of the American Mathematical Society
Volume 81, Number 1, January 1981.
DOI: 10.2307/2043993  \<^url>\<open>https://www.jstor.org/stable/2043993\<close>\<close>

locale function_ring_on =
by simp: power2_eq_square
  assumesshowthesis
 \<in> R \<Longrightarrow> continuous_on S f"
         :"\ n"
   multf
  assumes const( simp)
  assumes (lessd

begin
lemma"f\ R \ (\x. - f x) \ R"
    by case

  lemma diff: "f \ R \ g \ R \ (\x. f x - g x) \ R"
    unfolding diff_conv_add_uminus by (metis add minus)

  lemma power: "f \ R \ (\x. f x^n) \ R"
    by (induct n)            \<open>M\<ge>0\<close> d by simp

      java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
    by(  : finite_induct: const)

  lemma prod: using 
    by "

  definition\<^marker>\<open>tag important\<close> normf :: "('a::t2_space \<Rightarrow> real) \<Rightarrow> real"
              ( Madd_mono_thms_linordered_semiringkn)

  lemma           \<section> \<open>M\<ge>0\<close> mult_left_mono by fastforce".\le / * /d
     show .
  proof
    have      *=this
      by (simp add       simp sum_distrib_left] algebra_simps
    then show ?by( sum_abs
      using assmsusing
  qed

  lemma normf_least: "S \ {} \ (\x. x \ S \ \f x\ \ M) \ normf f \ M"


end \<open>d>0\<close> x by (simp add: divide_simps \<open>M\<ge>0\<close> mult_le_one mult_left_le)

lemmain) one
using  
    shows "bar -java.lang.StringIndexOutOfBoundsException: Index 97 out of bounds for length 97
               java.lang.StringIndexOutOfBoundsException: Index 169 out of bounds for length 169
proof -
  have "\pt \ R. pt t0 = 0 \ pt t > 0 \ pt ` S \ {0..1}" if t: "t \ S - U" for t
  proof Bruno and .
    have "t \ t0" using t t0 by auto
    then obtain g where gAn Proof the .
       separable ( Diff_subset )
    define h where [abs_def]: "h Volume8,Number1 191java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
  in
      unfolding h_def ( addsum_distrib_right
then"\w. (h w)\<^sup>2) \ R"
      by (simp add: power2_eq_square mult)
    have "h t \ h t0"
      by (simp add: h_def g)
    then have "h t \ 0"
      by (simp add: h_def)
    then have ht2: "0 < (h t)^2"
      by simp
    also have "... \ normf (\w. (h w)\<^sup>2)"
      using t normf_upper [where x=t] continuous [OF hsq] by force
    finally have nfp: "0 < normf (\w. (h w)\<^sup>2)" .
    define p where [abs_def]: "p x = (1 / normf (\w. (h w)\<^sup>2)) * (h x)^2" for x
    have "p \ R"
      unfoldingp_deffast:  const)
     have"t0=0
      bysimp: p_defh_def
    moreover have " 0"
      using nfp ht2 by (simp add: p_def)
    moreover have "\x. x \ S \ p x \ {0..1}"
       nfp [OF  [OF]   ( simp)
     show\<exists>pt \<in> R. pt t0 = 0 \<and> pt t > 0 \<and> pt ` S \<subseteq> {0..1}"
by
  qed
  then obtain pf where pf: "\t. t \ S-U \ pf t \ R \ pf t t0 = 0 \ pf t t > 0"
                   and pf01: "\t. t \ S-U \ pf t ` S \ {0..1}"
    by metis
  have com_sU: "compact (S-U)"
    using compact closed_Int_compact U by (simp add: Diff_eq compact_Int_closed open_closed)
  have "\t. t \ S-U \ \A. open A \ A \ S = {x\S. 0 < pf t x}"
    apply (rule open_Collect_positive)
    by (metis pf continuous)
  then obtain          (eal  1*Bernsteinjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42

  then have
by
       ( binomial_deriv2 nx"-"simplified :
using  by 
  then have *: "S-U \ (\x \ S-U. Uf x)"
    by blast
  obtain subU where subU: "subU \ S - U" "finite subU" "S - U \ (\x \ subU. Uf x)"
    by (blast intro: that compactE_image [OF com_sU open_Uf *])
  then have [simp: subU
    using by auto
  then cardp  " using java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
    by (simp     "\N. \n x. N \ n \ x \ {0..1}
  define({.})
have:"\>R
    unfolding  M M:\ simp add: bounded_iff)
  have pt0 [simp]: "p t0 = 0"
    using subU pf by (auto simp: p_def intro: sum.neutral)
  have pt_pos: "p t > 0" if t: "t \ S-U" for t
  proof -
    obtain i where i: "i \ subU" "t \ Uf i" using subU t by blast
showthesishave : "uniformly_continuous_on 0..1} f"
using i java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
       ( simp field_split_simps
applyrule OF
      using Uf t pf01  n: and
      apply (force     " < n"using
      done
  qed
  have p01: "p x \ {0..1}" if t: "x \ S" for x
  proof -
    have "0 \ p x"
      using subU cardp t pf01
      by fastforce add: p_def intro: um_nonneg
reover" \ 1"
      using subU cardp t     havesimp nat
      apply( addp_deffield_split_simps
 sum_bounded_above 'a= =,simplified]java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
      using pf01 by force
    ultimately show ?thesis
      by auto
  qed
  have "compact (p ` (S-U))"
    by (meson com_sU continuous pR
  then have "open (- (p ` (S-U)))"
    by (simp:  open_Compl
  have0\<in> - (p ` (S-U))"
       :"And>a b x::real. (a - b)\<^sup>2 * x = a * (a - 1) * x + (1 - 2 * b) * a * x + b * b * x"
  ultimately delta0delta0>""all \<subseteq> - (p ` (S-U))"
    by (auto simp: elim!: openE)
  then have pt_delta: "\x. x \ S-U \ p x \ delta0"
    by (force simp: ball_def dist_norm dest: p01)
  define \<delta> where "\<delta> = delta0/2"
  have \<le> 1" using delta0 p01 [of t1] t1
e : ball_def dest)
  with delta0  ( add power2_eq_square
    by(uto: \<delta>_def)
  havept_>: "<>.x \ S-U \ p x \ \"
    using pt_delta delta0 by (force showjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
have
    by (rule open_Collect_less_Int [OF continuous [OF pR] continuous_on_const])
  then obtain V where V: "open V" "V \ S = {x\S. p x < \/2}"
    by blast
  define k where "k = nat\1/\\ + 1"
        consider) "\x - k / n\ < d" | (ged) "d \ \x - k / n\"
  have "k-1 \ 1/\"
    using
  withproof
    by (auto have
  also "..<2/<>"
    usinghave". <> e2+2*M/d\<^sup>2 * (x - k/n)\<^sup>2)"
  finally have k2using
         show by simp
    using \<delta>01 unfolding k_def by linarith
  with \<delta>01 k2\<delta> have k\<delta>: "1 < k*\<delta>" "k*\<delta> < 2"
    by (auto simp: field_split_simps)
  define q where [abs_def]: "q n t = (1 - p t^n)^(k^n)" for n t
  have qR: "q n \ R" for n
    by (simp add: q_def const diff power pR)
  have q01: "\n t. t \ S \ q n t \ {0..1}"
    using p01 by (simp add: q_def power_le_one algebra_simps)
  have qt0 [simp]: "\n. n>0 \ q n t0 = 1"
    using t0 pf by (simp add: q_def power_0_left)
  { fix t and n::nat
    assume t: "t \ S \ V"
    with \<open>k>0\<close> V have "k * p t < k * \<delta> / 2"
       by force
    then have "1 - (k * \ / 2)^n \ 1 - (k * p t)^n"
      using  \<open>k>0\<close> p01 t by (simp add: power_mono)
    also have "... \ q n t"
      using Bernoulli_inequality [of "- ((p t)^n)" "k^n"
      apply (simp add: q_def)
      by (metis IntE atLeastAtMost_iff p01 power_le_one power_mult_distrib t)
    finally have "1 - (k * \ / 2)^n \ q n t" .
  } note limitV = this
  { fix t and n::nat
    assume t: "t \ S - U"
    with \<open>k>0\<close> U have "k * \<delta> \<le> k * p t"
      by (simp add: pt_\<delta>)
    with k\<delta> have kpt: "1 < k * p t"
      by (blast intro: less_le_trans)
    have ptn_pos: "0 < p t^n"
      using pt_pos [OF t] by simp
    have ptn_le: "p t^n \ 1"
      by (meson DiffE atLeastAtMost_iff p01 power_le_one t)
    have "q n t = (1/(k^n * (p t)^n)) * (1 - p t^n)^(k^n) * k^n * (p t)^n"
      using pt_pos [OF t] \<open>k>0\<close> by (simp add: q_def)
    also have "... \ (1/(k * (p t))^n) * (1 - p t^n)^(k^n) * (1 + k^n * (p t)^n)"
      using pt_pos [OF t] \<open>k>0\<close>
      by (simp add: divide_simps mult_left_mono ptn_le)
    also have "... \ (1/(k * (p t))^n) * (1 - p t^n)^(k^n) * (1 + (p t)^n)^(k^n)"
    proof (rule mult_left_mono [OF Bernoulli_inequality])
      show "0 \ 1 / (real k * p t)^n * (1 - p t^n)^k^n"
        using ptn_pos ptn_le by (auto simp: power_mult_distrib)
    qed (use ptn_pos in auto)
    also have "... = (1/(k * (p t))^n) * (1 - p t^(2*n))^(k^n)"
      using pt_pos [OF t] \<open>k>0\<close>
      by (simp add: algebra_simps power_mult power2_eq_square flip: power_mult_distrib)
    also have "... \ (1/(k * (p t))^n) * 1"
      using pt_pos \<open>k>0\<close> p01 power_le_one t
      by (intro mult_left_mono [OF power_le_one]) auto
    also have "... \ (1 / (k*\))^n"
      using \<open>k>0\<close> \<delta>01  power_mono pt_\<delta> t
      by (fastforce simp: field_simps)
    finally have "q n t \ (1 / (real k * \))^n " .
  } note limitNonU = this
  define NN
    where "NN e = 1 + nat \max (ln e / ln (real k * \ / 2)) (- ln e / ln (real k * \))\" for e
  have NN: "of_nat (NN e) > ln e / ln (real k * \ / 2)" "of_nat (NN e) > - ln e / ln (real k * \)"
              if "0 for e
      unfolding NN_def  by linarith+
    have NN1: "(k * \ / 2)^NN e < e" if "e>0" for e
    proof -
      have "ln ((real k * \ / 2)^NN e) = real (NN e) * ln (real k * \ / 2)"
        by (simp add: \<open>\<delta>>0\<close> \<open>0 < k\<close> ln_realpow)
      also have "... < ln e"
        using NN k\<delta> that by (force simp add: field_simps)
      finally show ?thesis
        by (simp add: \<open>\<delta>>0\<close> \<open>0 < k\<close> that)
    qed
  have NN0: "(1/(k*\))^(NN e) < e" if "e>0" for e
  proof -
    have "0 < ln (real k) + ln \"
      using \<delta>01(1) \<open>0 < k\<close> k\<delta>(1) ln_gt_zero ln_mult by fastforce 
    then have "real (NN e) * ln (1 / (real k * \)) < ln e"
      using k\<delta>(1) NN(2) [of e] \<open>0 < \<delta>\<close> \<open>0 < k\<close> that by (simp add: ln_div divide_simps)
    then have "exp (real (NN e) * ln (1 / (real k * \))) < e"
      by (metis exp_less_mono exp_ln that)
    then show ?thesis
      by (simp add: \<delta>01(1) \<open>0 < k\<close> exp_of_nat_mult)
  qed
  { fix t and e::real
    assume "e>0"
    have "t \ S \ V \ 1 - q (NN e) t < e" "t \ S - U \ q (NN e) t < e"
    proof -
      assume t: "t \ S \ V"
      show "1 - q (NN e) t < e"
        by (metis add.commute diff_le_eq not_le limitV [OF t] less_le_trans [OF NN1 [OF \<open>e>0\<close>]])
    next
      assume t: "t \ S - U"
      show "q (NN e) t < e"
      using  limitNonU [OF t] less_le_trans [OF NN0 [OF \<open>e>0\<close>]] not_le by blast
    qed
  } then have "\e. e > 0 \ \f\R. f ` S \ {0..1} \ (\t \ S \ V. f t < e) \ (\t \ S - U. 1 - e < f t)"
    using q01
    by (rule_tac x="\x. 1 - q (NN e) x" in bexI) (auto simp: algebra_simps intro: diff const qR)
  moreover have t0V: "t0 \ V" "S \ V \ U"
    using pt_\<delta> t0 U V \<delta>01  by fastforce+
  ultimately show ?thesis using V t0V
    by blast
qed

text\<open>Non-trivial case, with \<^term>\<open>A\<close> and \<^term>\<open>B\<close> both non-empty\<close>
lemma (in function_ring_on) two_special:
  assumes A: "closed A" "A \ S" "a \ A"
      and B: "closed B" "B \ S" "b \ B"
      and disj: "A \ B = {}"
      and e: "0 < e" "e < 1"
    shows "\f \ R. f ` S \ {0..1} \ (\x \ A. f x < e) \ (\x \ B. f x > 1 - e)"
proof -
  { fix w
    assume "w \ A"
    then have "open ( - B)" "b \ S" "w \ B" "w \ S"
      using assms by auto
    then have "\V. open V \ w \ V \ S \ V \ -B \
               (\<forall>e>0. \<exists>f \<in> R. f ` S \<subseteq> {0..1} \<and> (\<forall>x \<in> S \<inter> V. f x < e) \<and> (\<forall>x \<in> S \<inter> B. f x > 1 - e))"
      using        have\section:" \ (x - real k / real n)\<^sup>2 / d\<^sup>2"
  }
  then obtainhave\<bar>(f x - f (k/n))\<bar> \<le> \<bar>f x\<bar> + \<bar>f (k/n)\<bar>"
         "\w. w \ A \ open (Vf w) \ w \ Vf w \ S \ Vf w \ -B \
(\<forall>e>0. \<exists>f \<in> R. f ` S \<subseteq> {0..1} \<and> (\<forall>x \<in> S \<inter> Vf w. f x < e) \<and> (\<forall>x \<in> S \<inter> B. f x > 1 - e))"
    by metis
        lso 
    by blast
  have tVft: "\w. w \ A \ w \ Vf w"
    using Vf by blast
  then have sum_max_0: "A \ (\x \ A. Vf x)"
    by blast
  have com_A: "compact A" using A
    by (metis compact compact_Int_closed inf.absorb_iff2)
  obtain subA where subA: "subA \ A" "finite subA" "A \ (\x \ subA. Vf x)"
    by (blast intro: that compactE_image [OF com_A
  ]: " \ {}"
      .java.lang.StringIndexOutOfBoundsException: Index 110 out of bounds for length 110
  then have cardp sum Rings. sum_distrib_left] mult sum_bern
    by simp )
  have "\w. w \ A \ \f \ R. f ` S \ {0..1} \ (\x \ S \ Vf w. f x < e / card subA) \ (\x \ S \ B. f x > 1 - e / card subA)" ". ejava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
    using  by simp
  then obtain auto
         "\w. w \ A \ ff w \ R \ ff w ` S \ {0..1} \
                         (\<forall>x \<in> S \<inter> Vf w. ff w x < e / card subA) \<and> (\<forall>x \<in> S \<inter> B. ff w x > 1 - e / card subA)"
    by metis
  define pff where [abs_def]: "pff x = (\w \ subA. ff w x)" for x
  have pffR: "pff \ R"
    unfolding pff_def using subA ff by (auto simp: intro: prod)
  moreover
  have pff01: "pff x \ {0..1}" if t: "x \ S" for x
  proof -
    have "0 \ pff x"
      using subA cardp t ff
      by (fastforce simp: pff_def field_split_simps sum_nonneg intro: prod_nonneg)
    moreover have "pff x \ 1"
      using subA cardp t ff 
      by (fastforce simp add: pff_def field_split_simps sum_nonneg intro: prod_mono [where
ultimately ?
      by auto
  qed
  moreover
  { fix v x
    assume v: "v of the Mathematical Society
    from vhave  ffv   (<> in{}   )
     unfolding  by (metis.remove
    also:t2_space \<Rightarrow> real) set" and S :: "'a set"
    proof -
      have "\i. i \ subA - {v} \ 0 \ ff i x \ ff i x \ 1"
        by (metis Diff_subset atLeastAtMost_iff ff image_subset_iff subA(1) subsetD x(2))
      moreover have "0 \ ff v x"
        using ffsubAx  
      ultimately  assumes"compact S"
        by (metis mult_left_mono prod_mono [where g = "\x. 1", simplified])
    qed
also "..< /cardsubAjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
      using subA)   auto
    also have "... \ e"
      using java.lang.StringIndexOutOfBoundsException: Index 144 out of bounds for length 144
    finally have "pff x < e" .
  }
  then have "\x. x \ A \ pff x < e"
    using A Vf subA by (metis UN_E contra_subsetD)
  moreover
  { fix x
    assume x: "x \ B"
    then
      using byauto
    have1-e\<> 1-e/ subA subA
      
      byauto field_simps
    alsohave.=(Prod
      by
     have. <x
    proof -
\<in \<Longrightarrow> e / real (card subA) \<le> 1 \<and> 1 - e / real (card subA) < ff i x"
        using e \<open>B \<subseteq> S\<close> ff subA(1) x by (force simp: field_split_simps)
      then show ?thesis
        using prod_mono_strict[of _ subA "\x. 1 - e / card subA" ] subA
        unfolding pff_def by (smt (verit, best) UN_E assms(3) subsetD)
    qed
    finally have "1 - e < pff x" .
  }
  ultimately show ?thesis by blast
qed

lemma (in function_ring_on) two:
  assumes A: "closed A" "A \ S"
      and B: "closed B" "B \ S"
      and disj: "A \ B = {}"
      and e: "0 < e" "e < 1"
    shows "\f \ R. f ` S \ {0..1} \ (\x \ A. f x < e) \ (\x \ B. f x > 1 - e)"
proof (cases "A \ {} \ B \ {}")
  case True then show ?thesis
    using assms
    by (force simp flip: ex_in_conv intro!: two_special)
next
  case False 
  then consider "A={}" | "B={}" by force
  then show ?thesis
  proof cases
    case 1
    with e show ?thesis
      by (rule_tac x="\x. 1" in bexI) (auto simp: const)
  next
    case 2
    with e show ?thesis
      by (rule_tac x="\x. 0" in bexI) (auto simp: const)
  qed
qed

text\<open>The special case where \<^term>\<open>f\<close> is non-negative and \<^term>\<open>e<1/3\<close>\<close>
lemma (in function_ring_on) Stone_Weierstrass_special:
  assumes f: "continuous_on S f" and fpos: "\x. x \ S \ f x \ 0"
      and e: "0 < e" "e < 1/3"
  shows "\g \ R. \x\S. \f x - g x\ < 2*e"
proof -
  define n where "n = 1 + nat \normf f / e\"
  define A where "A j = {x \ S. f x \ (j - 1/3)*e}" for j :: nat
  define B where "B j = {x \ S. f x \ (j + 1/3)*e}" for j :: nat
  have ngt: "(n-1) * e \ normf f"
    using e pos_divide_le_eq real_nat_ceiling_ge[of "normf f / e"]
    by (fastforce simp add: divide_simps n_def)
  moreover have "n\1"
    by (simp_all add: n_def)
  ultimately have ge_fx: "(n-1) * e \ f x" if "x \ S" for x
    using f normf_upper that by fastforce
  have "closed S"
    by (simp add: compact compact_imp_closed)
  { fix j
    have "closed (A j)" "A j \ S"
      using \<open>closed S\<close> continuous_on_closed_Collect_le [OF f continuous_on_const]
      by (simp_all add: A_def Collect_restrict)
    moreover have "closed (B j)" "B j \ S"
      using \<open>closed S\<close> continuous_on_closed_Collect_le [OF continuous_on_const f]
      by (simp_all add: B_def Collect_restrict)
    moreover have "(A j) \ (B j) = {}"
      using e by (auto simp: A_def B_def field_simps)
    ultimately have "\f \ R. f ` S \ {0..1} \ (\x \ A j. f x < e/n) \ (\x \ B j. f x > 1 - e/n)"
      using e \<open>1 \<le> n\<close> by (auto intro: two)
  }
  then obtain xf where xfR: "\j. xf j \ R" and xf01: "\j. xf j ` S \ {0..1}"
                   and xfA: "\x j. x \ A j \ xf j x < e/n"
                   and xfB: "\x j. x \ B j \ xf j x > 1 - e/n"
    by metis
  define g where [abs_def]: "g x = e * (\i\n. xf i x)" for x
  have gR: "g \ R"
    unfolding g_def by (fast intro: mult const sum xfR)
  have gge0: "\x. x \ S \ g x \ 0"
    using e xf01 by (simp add: g_def zero_le_mult_iff image_subset_iff sum_nonneg)
  have A0: "A 0 = {}"
    using fpos e by (fastforce simp: A_def)
  have An: "A n = S"
    using e ngt \<open>n\<ge>1\<close> f normf_upper by (fastforce simp: A_def field_simps of_nat_diff)
  have Asub: "A j \ A i" if "i\j" for i j
    using e that by (force simp: A_def intro: order_trans)
  { fix t
    assume t: "t \ S"
    define j where "j = (LEAST j. t \ A j)"
    have jn: "j \ n"
      using t An by (simp add: Least_le j_def)
    have Aj: "t \ A j"
      using t An by (fastforce simp add: j_def intro: LeastI)
    then have Ai: "t \ A i" if "i\j" for i
      using Asub [OF that] by blast
    then have fj1: "f t \ (j - 1/3)*e"
      by (simp add: A_def)
    then have Anj: "t \ A i" if "i
      using  Aj \<open>i<j\<close> not_less_Least by (fastforce simp add: j_def)
    have j1: "1 \ j"
      using A0 Aj j_def not_less_eq_eq by (fastforce simp add: j_def)
    then have Anj: "t \ A (j-1)"
      using Least_le by (fastforce simp add: j_def)
    then have fj2: "(j - 4/3)*e < f t"
      using j1 t  by (simp add: A_def of_nat_diff)
    have xf_le1: "\i. xf i t \ 1"
      using xf01 t by force
    have "g t = e * (\i\n. xf i t)"
      by (simp add: g_def flip: distrib_left)
    also have "... = e * (\i \ {.. {j..n}. xf i t)"
      by (simp add: ivl_disj_un_one(4) jn)
    also have "... = e * (\ii=j..n. xf i t)"
      by (simp add: distrib_left ivl_disj_int sum.union_disjoint)
    also have "... \ e*j + e * ((Suc n - j)*e/n)"
    proof (intro add_mono mult_left_mono)
      show "(\i j"
        by (rule sum_bounded_above [OF xf_le1, where A = "lessThan j", simplified])
      have "xf i t \ e/n" if "i\j" for i
        using xfA [OF Ai] that by (simp add: less_eq_real_def)
      then show "(\i = j..n. xf i t) \ real (Suc n - j) * e / real n"
        using sum_bounded_above [of "{j..n}" "\i. xf i t"]
        by fastforce 
    qed (use e in auto)
    also have "... \ j*e + e*(n - j + 1)*e/n "
      using \<open>1 \<le> n\<close> e  by (simp add: field_simps del: of_nat_Suc)
    also have "... \ j*e + e*e"
      using \<open>1 \<le> n\<close> e j1 by (simp add: field_simps del: of_nat_Suc)
    also have "... < (j + 1/3)*e"
      using e by (auto simp: field_simps)
    finally have gj1: "g t < (j + 1 / 3) * e" .
    have gj2: "(j - 4/3)*e < g t"
    proof (cases "2 \ j")
      case False
      then have "j=1" using j1 by simp
      with t gge0 e show ?thesis by force
    next
      case True
      then have "(j - 4/3)*e < (j-1)*e - e^2"
        using e by (auto simp: of_nat_diff algebra_simps power2_eq_square)
      also have "... < (j-1)*e - ((j - 1)/n) * e^2"
      proof -
        have "(j - 1) / n < 1"
          using j1 jn by fastforce
        with \<open>e>0\<close> show ?thesis
          by (smt (verit, best) mult_less_cancel_right2 zero_less_power)
      qed
      also have "... = e * (j-1) * (1 - e/n)"
        by (simp add: power2_eq_square field_simps)
      also have "... \ e * (\i\j-2. xf i t)"
      proof -
        { fix i
          assume "i+2 \ j"
          then obtain d where "i+2+d = j"
            using le_Suc_ex that by blast
          then have "t \ B i"
            using Anj e ge_fx [OF t] \<open>1 \<le> n\<close> fpos [OF t] t
            unfolding A_def B_def
            by (auto simp add: field_simps of_nat_diff not_le intro: order_trans [of _ "e * 2 + e * d * 3 + e * i * 3"])
          then have "xf i t > 1 - e/n"
            by (rule xfB)
        } 
        moreover have "real (j - Suc 0) * (1 - e / real n) \ real (card {..j - 2}) * (1 - e / real n)"
          using Suc_diff_le True by fastforce
        ultimately show ?thesis
          using e True by (auto intro: order_trans [OF _ sum_bounded_below [OF less_imp_le]])
      qed
      also have "... \ g t"
        using jn e xf01 t
        by (auto intro!: Groups_Big.sum_mono2 simp add: g_def zero_le_mult_iff image_subset_iff sum_nonneg)
      finally show ?thesis .
    qed
    have "\f t - g t\ < 2 * e"
      using fj1 fj2 gj1 gj2 by (simp add: abs_less_iff    by ( I rulefinite_induct add  mult)
  }
  then show ?thesis
    by (rule_tac java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
qed

text\<open>The ``unpretentious'' formulation\<close>
proposition (in function_ring_on) Stone_Weierstrass_basic:
  assumes f: "continuous_on S f" and e: "e > 0"
  shows "\g \ R. \x\S. \f x - g x\ < e"
proof -
  have "\g \ R. \x\S. \(f x + normf f) - g x\ < 2 * min (e/2) (1/4)"
  proof (rule Stone_Weierstrass_special)
    show "continuous_on S (\x. f x + normf f)"
      by (force intro: Limits.continuous_on_add [OF f Topological_Spaces.continuous_on_const])
java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69

qed e in)
   obtainwhere
    java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
thenjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
    by (rule_tac x="\x. g x - normf f" in bexI) (auto simp: algebra_simps intro: diff const)
qed


theorem (in function_ring_on) Stone_Weierstrass:
  assumes f: "continuous_on S f"
  shows "\F\UNIV \ R. LIM n sequentially. F n :> uniformly_on S f"
proof
  definet <noteq> t0" using t t0 by auto
  show ?thesis
        u t0metis subset_eq
{fix::
      assume e: "0 < h_def by ( intro: g const diff)
      then obtain N::nat where N: "0 < N" "0 < inverse N" "inverse N < e"
        by (auto simp: real_arch_inverse [of e])
      { fix n :: nat and x :: 'a and g :: "'\<Rightarrow> real"
        assume n: "N \ n" "\x\S. \f x - g x\ < 1 / (1 + real n)"
        assume x: "x \ S"
        have "\ real (Suc n) < inverse e"
          using \<open>N \<le> n\<close> N using less_imp_inverse_less by force
        then have "1 / (1 + real n) \ e"
          using e by (simp add: field_simps)
        then have "\f x - g x\ < e"
          using n(2) x by auto
      } 
      then have "\\<^sub>F n in sequentially. \x\S. \f x - h n x\ < e"
        unfolding h_def
        by (force intro: someI2_bex [OF Stone_Weierstrass_basic [OF f]] eventually_sequentiallyI [of N])
    } 
    then show "uniform_limit S h f sequentially"
      unfolding uniform_limit_iff by (auto simp: dist_norm abs_minus_commute)
    show "h \ UNIV \ R"
      unfolding h_def by (force intro: someI2_bex [OF Stone_Weierstrass_basic [OF f]])
  qed
qed

text\<open>A HOL Light formulation\<close>
corollary Stone_Weierstrass_HOL:
  fixes R :: "('a::t2_space \ real) set" and S :: "'a set"
  assumes "compact S"  "\c. P(\x. c::real)"
          "\f. P f \ continuous_on S f"
          "\f g. P(f) \ P(g) \ P(\x. f x + g x)" "\f g. P(f) \ P(g) \ P(\x. f x * g x)"
          "\x y. x \ S \ y \ S \ x \ y \ \f. P(f) \ f x \ f y"
          "continuous_on S f"
       "0 < e"
    shows "\g. P(g) \ (\x \ S. \f x - g x\ < e)"
proof -
  interpret PR: function_ring_on "Collect P"
    by unfold_locales (use assms in auto)
  show ?thesis
    using PR.Stone_Weierstrass_basic [OF \<open>continuous_on S f\<close> \<open>0 < e\<close>]
    by blast
qed


subsection \<open>Polynomial functions\<close>

inductive real_polynomial_function :: "('a::real_normed_vector \ real) \ bool" where
    linear: "bounded_linear f \ real_polynomial_function f"
  | const: "real_polynomial_function (\x. c)"
  | add:   "\real_polynomial_function f; real_polynomial_function g\ \ real_polynomial_function (\x. f x + g x)"
  | mult:  "\real_polynomial_function f; real_polynomial_function g\ \ real_polynomial_function (\x. f x * g x)"

declare real_polynomial_function.introsby(simp add: power2_eq_square)

definition      by (simp add: h_def g)
  where
   "polynomial_function p \ (\f. bounded_linear f \ real_polynomial_function (f o p))"

 real_polynomial_function_eq  
unfoldinghave" (\w. (h w)\<^sup>2)" .
proof
  assume "real_polynomial_function p"
  then show " \f. bounded_linear f \ real_polynomial_function (f \ p)"
  proof (induction p rule: real_polynomial_function.induct)
    case (linear h) then show ?case
      by (auto simp: bounded_linear_compose real_polynomial_function.linear)
  next
    case (const h) then show ?case
      by (simp add: real_polynomial_function.const)
  next
    case (add h) then show ?case
      by (force simp add: bounded_linear_def linear_add real_polynomial_function.add)
  next
    case (mult h) then show ?case
      by (force simp add: real_bounded_linear const real_polynomial_function.mult)
  qed
next
  assume [rule_format, OF bounded_linear_ident]: "\f. bounded_linear f \ real_polynomial_function (f \ p)"
  then show "real_polynomial_function p"
    by (simp add: o_def)
qed

lemma polynomial_function_const [iff] "polynomial_function (<>x. c)"
  by     have" t0 =0

polynomial_function_bounded_linear
  " f \ polynomial_function f"
  by (simp add: polynomial_function_def nfp [OF [OF] ]byauto: )

lemma polynomial_function_idauto
  by (simp add: polynomial_function_bounded_linear)

lemma polynomial_function_add [intro]:
    "\polynomial_function f; polynomial_function g\ \ polynomial_function (\x. f x + g x)"
  by (auto simp: polynomial_function_def bounded_linear_def linear_add real_polynomial_function.add o_def)

lemma polynomial_function_mult [intro]:
  assumes f: "polynomial_function f" and g: "polynomial_function g"
  shows "polynomial_function (\x. f x *\<^sub>R g x)"
proof -
  have "real_polynomial_function (\x. h (g x))" if "bounded_linear h" for h
    using g that unfolding polynomial_function_def o_def bounded_linear_def
    by (auto simp: real_polynomial_function_eq)
  moreover have "real_polynomial_function f"
    by (simp add: f real_polynomial_function_eq)
  ultimately show ?thesis
    unfolding polynomial_function_def bounded_linear_def o_def
    by (auto simp: linear.scaleR)
qed

lemma polynomial_function_cmul [intro]:
  assumes f: "polynomial_function f"
    shows "polynomial_function (\x. c *\<^sub>R f x)"
  by (rule polynomial_function_mult [OF polynomial_function_const f])

lemma polynomial_function_minus [intro]:
  assumes f: "polynomial_function f"
    shows "polynomial_function (\x. - f x)"
  using polynomial_function_cmul [OF f, of "-1"by simp

lemma polynomial_function_diff [intro]:
    "\polynomial_function f; polynomial_function g\ \ polynomial_function (\x. f x - g x)"
  unfolding add_uminus_conv_diff [symmetric]
  by (metis polynomial_function_add polynomial_function_minus)

lemma polynomial_function_sum [intro]:
    "\finite I; \i. i \ I \ polynomial_function (\x. f x i)\ \ polynomial_function (\x. sum (f x) I)"
by (induct I rule: finite_induct) auto

lemma real_polynomial_function_minus [intro]:
    "real_polynomial_function f \ real_polynomial_function (\x. - f x)"
  using polynomial_function_minus [of f]
  by (simp add: real_polynomial_function_eq)

lemma real_polynomial_function_diff [intro]:
    "\real_polynomial_function f; real_polynomial_function g\ \ real_polynomial_function (\x. f x - g x)"
  using polynomial_function_diff [of f]
  by (simp add: real_polynomial_function_eq)

lemma real_polynomial_function_divide [intro]:
  assumes   obtainpf  pf "<>t.t\ pf t \ R \ pf t t0 = 0 \ pf t t > 0"
proof-
       metis  have"compact(-)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
    using byauto
  then show ?thesis
    by (simp  bymetis)
qed

lemma real_polynomial_function_sum [intro]:
    "\finite I; \i. i \ I \ real_polynomial_function (\x. f x i)\ \ real_polynomial_function (\x. sum (f x) I)"
  using polynomial_function_sum [of I f]
  by (simp add: real_polynomial_function_eq)

lemma real_polynomial_function_prod [intro]:
  "\finite I; \i. i \ I \ real_polynomial_function (\x. f x i)\ \ real_polynomial_function (\x. prod (f x) I)"
  by (induct I rule: finite_induct) auto

lemma real_polynomial_function_gchoose:
  obtains p where "real_polynomial_function p" "\x. x gchoose r = p x"
proof
  show "real_polynomial_function (\x. (\i = 0..
    by force
qed add)

lemma real_polynomial_function_power [intro]   have* S-U
    " f \ real_polynomial_function (\x. f x^n)"
   ( n) ( add mult

lemma real_polynomial_function_compose t1
  assumespolynomial_functiong real_polynomial_function
         simp)
     p where] px=( /cardjava.lang.NullPointerException
proof (induction g rule: real_polynomial_function.induct)
  case (linear f)
  then show ?case
    using f polynomial_function_def by blast
next
  case (add f g)
  then show ?case
    using f add by (auto simp: polynomial_function_def)
next
  case (mult f g)
  then show ?case
  using f mult by (auto simp: polynomial_function_def)
qed auto

lemma polynomial_function_compose [intro]:
  assumes f: "polynomial_function f" and g: "polynomial_function g"
    shows "polynomial_function (g o f)"
  using g real_polynomial_function_compose [OF f]
  by (auto simp: polynomial_function_def o_def)

lemma sum_max_0:
  fixes x::real (*in fact "'a::comm_ring_1"*)
  shows "(\i\max m n. x^i * (if i \ m then a i else 0)) = (\i\m. x^i * a i)"
proof -
  have "(\i\max m n. x^i * (if i \ m then a i else 0)) = (\i\max m n. (if i \ m then x^i * a i else 0))"
    by (auto simp: algebra_simps intro: sum.cong)
  also have "... = (\i\m. (if i \ m then x^i * a i else 0))"
    by (rule sum.mono_neutral_right) auto
  also have "... = (\i\m. x^i * a i)"
    by (auto simp: algebra_simps intro: sum.cong)
  finally show ?thesis .
qed

lemma real_polynomial_function_imp_sum:
  assumes "real_polynomial_function f"
    shows "\a n::nat. f = (\x. \i\n. a i * x^i)"
using assms
proof (induct f)
  case (linear f)
  then obtain c where f: "f = (\x. x * c)"
    by (auto simp add: real_bounded_linear)
  have "x * c = (\i\1. (if i = 0 then 0 else c) * x^i)" for x
    by (simp add: mult_ac)
  with f show ?case
    by fastforce
next
  case (const c)
  have "c = (\i\0. c * x^i)" for x
    by auto
  then show ?case
    by fastforce
  case (add f1 f2)
  then obtain a1 n1 a2 n2 where
    "f1 = (\x. \i\n1. a1 i * x^i)" "f2 = (\x. \i\n2. a2 i * x^i)"
    by auto
  then have "f1 x + f2 x = (\i\max n1 n2. ((if i \ n1 then a1 i else 0) + (if i \ n2 then a2 i else 0)) * x^i)"
      for x
    using sum_max_0 [where m=n1 and n=n2] sum_max_0 [where m=n2 and n=n1]
    by (simp add: sum.distrib algebra_simps max.commute)
  then show ?case
    by force
  case (mult f1 f2)
  then obtain a1 n1 a2 n2 where
    "f1 = (\x. \i\n1. a1 i * x^i)" "f2 = (\x. \i\n2. a2 i * x^i)"
    by auto
  then obtain b1 b2 where
    "f1 = (\x. \i\n1. b1 i * x^i)" "f2 = (\x. \i\n2. b2 i * x^i)"
    "b1 = (\i. if i\n1 then a1 i else 0)" "b2 = (\i. if i\n2 then a2 i else 0)"
    by auto
  then have "f1 x * f2 x = (\i\n1 + n2. (\k\i. b1 k * b2 (i - k)) * x ^ i)" for x
    using polynomial_product [of n1 b1 n2 b2] by (simp add: Set_Interval.atLeast0AtMost)
  then show ?case
    by force
qed

lemma real_polynomial_function_iff_sum:
     "real_polynomial_function f \ (\a n. f = (\x. \i\n. a i * x^i))" (is "?lhs = ?rhs")
proof
  assume ?lhs then show ?rhs
    by (metis real_polynomial_function_imp_sum)
next
  assume ?rhs then show ?lhs
    by (auto simp: linear mult const real_polynomial_function_power real_polynomial_function_sum)
qed

lemma polynomial_function_iff_Basis_inner:
  fixes f :: "'a::real_normed_vector \ 'b::euclidean_space"
  shows "polynomial_function f \ (\b\Basis. real_polynomial_function (\x. inner (f x) b))"
        (is "?lhs = ?rhs")
unfolding polynomial_function_def
proof (intro iffI allI impI)
  assume "\h. bounded_linear h \ real_polynomial_function (h \ f)"
  then show ?rhs
    by (force simp add: bounded_linear_inner_left o_def)
next
  fix h :: "'b \ real"
  assume rp: "\b\Basis. real_polynomial_function (\x. f x \ b)" and h: "bounded_linear h"
  have "real_polynomial_function (h \ (\x. \b\Basis. (f x \ b) *\<^sub>R b))"
    using rp
    by (force simp: real_polynomial_function_eq polynomial_function_mult 
              intro!: real_polynomial_function_compose [OF _  linear [OF h]])
  then show "real_polynomial_function (h \ f)"
    by (simp add: euclidean_representation_sum_fun)
qed

subsection \<open>Stone-Weierstrass theorem for polynomial functions\<close>

text\<open>First, we need to show that they are continuous, differentiable and separable.\<close>

lemma continuous_real_polymonial_function:
  assumes "real_polynomial_function f"
    shows "continuous (at x) f"
using assms
by (induct f) (auto simp: linear_continuous_at)

lemma continuous_polymonial_function:
  fixes f :: "'a::real_normed_vector \ 'b::euclidean_space"
  assumes "polynomial_function f"
    shows "continuous (at x) f"
proof (rule euclidean_isCont)
  show "\b. b \ Basis \ isCont (\x. (f x \ b) *\<^sub>R b) x"
  using assms continuous_real_polymonial_function
  by (force simp: polynomial_function_iff_Basis_inner intro: isCont_scaleR)
qed

lemma continuous_on_polymonial_function:
  fixes f :: "'a::real_normed_vector \ 'b::euclidean_space"
  assumes "polynomial_function f"
    shows "continuous_on S f"
  using continuous_polymonial_function [OF assms] continuous_at_imp_continuous_on
  by blast

lemma has_real_derivative_polynomial_function:
  assumes "real_polynomial_function p"
    shows "\p'. real_polynomial_function p' \
                 (\<forall>x. (p has_real_derivative (p' x)) (at x))"
usingS
proof (induct p)
  case (linear p)
  then show ?case
    by (force simp: real_bounded_linear const intro!: derivative_eq_intros)
next
  case (const c)
  show ?case
 x"
  case      subU  ( simp: introsum)
then  where
    "real_polynomial_function p1" "\x. (f1 has_real_derivative p1 x) (at x)"
    "real_polynomial_function p2" "\x. (f2 has_real_derivative p2 x) (at x)"
    by auto
  thenqR n\<in> R" for n
    by ( x="<>x.p1x+ x"in)( introderivative_eq_intros
  case (mult f1 p01simp: q_defpower_le_one)
  then  p2
    "real_polynomial_function p1def power_0_left)
    "real_polynomial_function p2" "\x. (f2 has_real_derivative p2 x) (at x)"
    by auto
  then show ?case
    using mult
    by (rule_tac x="\x. f1 x * p2 x + f2 x * p1 x" in exI) (auto intro!: derivative_eq_intros)
qed

lemma has_vector_derivative_polynomial_function:
  fixes p        usingptn_pos ptn_leby (autosimp power_mult_distrib
  assumes p"
  obtains p' where "polynomial_function p'" "\<And>x. (p has_vector_derivative (p' x)) (at x)"
proof -
  { fix b :: 'a
    assume "b \ Basis"
    then
    obtain p' where p'"real_polynomial_function p'" and pd: "\x. ((\x. p x \ b) has_real_derivative p' x) (at x)"
            usinglimitNonUOF t] less_le_trans [OF NN0 [OF \<open>e>0\<close>]] not_le by blast
    
    have" (\x. p' x *\<^sub>R b)"
      using
      by (simp   havet0V"0\ V" "S \ V \ U"
thenhave"q. polynomial_function q \ (\x. ((\u. (p u \ b) *\<^sub>R b) has_vector_derivative q x) (at x))"
   by (fastforce: derivative_eq_intros)

  then obtain where:
      "\b. b \ Basis \ polynomial_function (qf b)"
      "\b x. b \ Basis \ ((\u. (p u \ b) *\<^sub>R b) has_vector_derivative qf b x) (at x)"
    by metis
  show ?thesis
  proof
    show "\x. (p has_vector_derivative (\b\Basis. qf b x)) (at x)"
      apply (subst euclidean_representation_sum_fun [of       e: "0 < e"" 1
      by (auto intro: has_vector_derivative_sum -
  ed:)
qed

lemma real_polynomial_function_separable:
  fixes x :: "'a::euclidean_space"
  assumes
proof     then  "
  have "real_polynomial_function (\u. \b\Basis. (inner (x-u) b)^2)"<orall \<in> S \<inter> V. f x < e) \<and> (\<forall>x \<in> S \<inter> B. f x > 1 - e))"usingproof
  proof (ule         \<And>w. w \<in> A \<Longrightarrow> open (Vf w) \<and> w \<in> Vf w \<and> S \<inter> Vf w \<subseteq> -B \<and>
     "\i. i \ Basis \ real_polynomial_function (\u. ((x - u) \ i)\<^sup>2)"
      by (auto simp \<open>k>0\<close> V have "k * p t < k * \<delta> / 2"
  qed auto
   have "
    using assms by     have    (compact_Int_closed
ultimately?  [OF  sum_max_0
    y java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
qed

lemma Stone_Weierstrass_real_polynomial_function:
  fixes f :: "' unfolding pff_def subA ff by (auto simp [ t] k>0\
          have:pffx\<in> {0..1}" if t: "x \<in> S" for x
obtains java.lang.StringIndexOutOfBoundsException: Range [130, 17) out of bounds for length 130
proofby( add:       using \<open>k>0\<close> \<delta>01  power_mono pt_\<delta> t
PR " real_polynomial_function"
  proof unfold_locales  then "<>x.x\A\pffx
  qedusecontinuous_on_polymonial_functionreal_polynomial_function_eq
       in

fix
qed

theorem Stone_Weierstrass_polynomial_function:
fixesf:':euclidean_space \ 'b::euclidean_space"
  assumes S: "compact S"
      and -
      and 0<e"
    shows (rule)
proof
    b :'
assume 
 "existsp real_polynomial_functionp\java.lang.StringIndexOutOfBoundsException: Index 126 out of bounds for length 126
     showthesis
show "ontinuous_onS(x. f x \ b)"
        using f by (auto intro: continuous_intros subst [ x=i symmetric
    qedjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  then -
      "\b. b \ Basis \ real_polynomial_function (pf b) \ (\x \ S. \f x \ b - pf b x\ < e / DIM('b))"text\<open> Differentiability of real and vector polynomial functions.\<close>
    by metis
  let ?g = "\x. \b\Basis. pf b x *\<^sub>R b"
  { fix{fixe:java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
    assume" java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      by (rule norm_sum)
    also       fixn :nat x :' andg: "a\<>r"
    proof (rule sum_bounded_above_strict)
      show "\i. i \ Basis \ norm ((f x \ i) *\<^sub>R i - pf i x *\<^sub>R i) < e / real DIM('b)"
         simpReal_Vector_Spaces]pf
    qed (rulehave\notreal )<inverse
    alsohave ".. =ejava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
      by (simp add
 differentiable_on_polynomial_function
  }
  then have \<forall>x\<in>S. norm ((\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) - ?g x) < e"
    by( simp: sum_subtractf
  moreover
  have "polynomial_function ?g"
using(:polynomial_function_sum)
ultimately ?thesis
     euclidean_representation_sum_fun ]bymetis, lifting
qed

proposition Stone_Weierstrass_uniform_limit -
    have openHOL formulation
corollaryjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
by( addjava.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
  obtains y xjava.lang.StringIndexOutOfBoundsException: Index 128 out of bounds for length 128
proof -
  havejava.lang.StringIndexOutOfBoundsException: Range [10, 7) out of bounds for length 14
  obtain PR " P"
using[java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    by metis
  have      nd1: \<And>i. i \<in> B \<Longrightarrow> norm i = 1"
  proof (rule uniform_limitI)
    fix
    with LIMSEQ_inverse_real_of_nat haveshows(
      by (rule
    moreoverhave"\\<^sub>F n in sequentially. \x\S. dist (g n x) (f x) < inverse (Suc n)"
     using simp norm_minus_commute
 show
      by (eventually_elim) auto
  show " : "\<lbrakk>real_polynomial_function f; real_polynomial_function g\<rbrakk> \<Longrightarrow> real_polynomial_function (\<lambda>x. f x * g x)"
  thenshow thesisjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
qed


subsection

text\<open>One application is to pick a smooth approximation to a path,polynomial_function_def
or" p"

lemmapath_polynomial_functionhave\<bullet> (\<Sum>i\<in>B. (x \<bullet> i) *\<^sub>R i) = (\<Sum>j\<in>B. x \<bullet> j * (i \<bullet> j))"
    fixes g  :: "real \ 'b::euclidean_space"
    showspolynomial_function \<Longrightarrow> path g"
  by( add  continuous_on_polymonial_function rule.cong)

 path_approx_polynomial_function
  : real
     pathe
    obtains  next
                    force:java.lang.StringIndexOutOfBoundsException: Range [44, 3) out of bounds for length 3
proof 
  qjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    using of0.}" e4"assms
    by (  then "real_polynomial_functionpjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
definewhere \<equiv> \<lambda>t. q t + (g 0 - q 0) + t *\<^sub>R (g 1 - q 1 - (g 0 - q 0))"
  show
  proof 
le polynomial_function_bounded_linear
      by (force simp add: poqo g : polynomial_function_defo_defreal_polynomial_functionlinear
    show norm t 
ifjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
    proof -
      have *: "norm (((q t - g t) + (g 0 - q 0)) + (autosimp: bounded_linear_def linear_add real_polynomial_function.add o_def)
      proof (intro Real_Vector_Spaces
        show( -t < "
          by( noq   define  [abs_defg  e*(
        show"norm (t*<^sub>R (g q 1)
          using noq that le_less_trans [OF mult_left_le_one_le noq]
          by auto
        howorm(t*<subR(q  g )) <e  / 4"
           noq le_less_trans [OF noq]
           simp(metis order_reflzero_le_one
       (  then " B"
      hen ?thesis
        thenobtainn: andbwhereB b`{.i<n""  i i  "
    qed
qedfinite_imp_nat_seg_image_inj_on
qed

proposition:
  fixes polynomial_function_def o_def
  assumes openconnected
      and "x \ S" "y \ S"
    shows"<> fx (
 by  assumes polynomial_function
  have" S" using
    by (simp     "polynomial_function
   \<open>x \<in> S\<close> \<open>y \<in> S\<close> obtain p where p: "path p" "path_image p \<subseteq> S" "pathstart p = x" "pathfinish p = y"
    by (force simp: path_connected_def)
  have "\e. 0 < e \ (\x \ path_image p. ball x e \ S)"
  proof (cases "S = UNIV")
      then showthesis
      by (simp add: gt_ex)
  next
    case False
    showthesis
    proof (intro exI conjI ballI)
       "\x. x \ path_image p \ ball x (setdist (path_image p) (-S)) \ S"
        using setdist_le_dist [of _ "path_image p" _ "-S"by fastforce
 (path_imagep ( S"
        using S p False
        by (lemma [intro:
    qed
  qed
  then e where0<eand"\x. x \ path_image p \ ball x e \ S"
lemma [intro
  obtain pf where "polynomial_function pf" and pf:   (simp: real_polynomial_function_eq
                    pf_e\Andt  <in> {0..1} \<Longrightarrow> norm(pf t - p t) < e"
    using path_approx_polynomial_function [OF \<open>path p\<close> \<open>0 < e\<close>] by blast
  show    polynomial_function_diff[of f]
  proof exIconjI
    show "polynomial_function pf"
      by factassumes  " (\x. p x / c)"
       "eal_polynomial_function \x. g_def by ( intro: mult const sum xfR)
       simp_all )
    show    showthesis
      unfolding
    proofd)
      fix x'::real
       0
      then have "dist (p \
 (metis atLeastAtMost_iff
      thenby(force:A_def: order_trans
bymetis
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
  qed
qed

lemmajava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
   f differentiablewithin
    \<forall    simp: gbinomial_prod_rev
proof -
  { assume "\i\Basis. \D. ((\x. f x \ i) has_derivative D) (at a within S)"
    then obtain f' where f':
           "\i. i \ Basis \ ((\x. f x \ i) has_derivative f' i) (at a within S)"
      by metislemma real_polynomial_function_compose [intro
    haveeq"\lambda>.(j\Basis. f' j x *\<^sub>R j) \ i) = f' i" if "i \ Basis" for i
      using by (simp g
     "D \i\Basis. ((\x. f x \ i) has_derivative (\x. D x \ i)) (at a within S)"
       (rule_tac x="\x::'a. (\j\Basis. f' j x *\<^sub>R j) :: 'b" in exI)
      apply( add: eq)
      done
  }
  then show ?thesis
   apply(simp adddifferentiable_defjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
     
    by blast
qed gt=  (

ynomial_function_inner:
  fixes(simp : java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   " assumes f: "polynomial_function  g "polynomial_functiongjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
   subst "
apply  
  done

text\<open> Differentiability of real and vector polynomial functions.\<close> (java.lang.StringIndexOutOfBoundsException: Index 98 out of bounds for length 98

lemmadifferentiable_at_real_polynomial_function:
   " f \ f differentiable (at a within S)"
  by f rule.induct
     (simp_all    have". \Sum>\m. (if i \ m then x^i * a i else 0))"

 java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
   "real_polynomial_function p \ p differentiable_on S"
by (simp add:u qed

lemma:
" "
  shows " have gj2:havegj2: "j-shows"x. \i\n. a i * x^i)"
  by (metis    proofcases\<le> j")

ntiable_on_polynomial_function
  fixes:" ?thesisbyforce
   "x*c=(
by (simp add:      ( add mult_ac)

lemma vector_eq_dot_span
  assumes "x \ span B" "y \ span B" and i: "\i. i \ B \ i \ x = i \ y"
  shows "x = y"
oof
  have "\i. i \ B \ orthogonal (x - y) i"
    by (simp addw\<open>e>0\<close> show ?thesis
moreoverxjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 11
    by (      alsoforx
  ultimately have "x usingsing[ m= and n=2] [where = and =]
  byjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
    then ?thesis
qed

lemma orthonormal_basis_expand obtain  "i+2+ j"
 B: pairwiseusingthat

      and "x \ span B"obtain b2
      and "finite B"
    shows
proof havef1 f2(
showjava.lang.NullPointerException
then java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
 ijava.lang.StringIndexOutOfBoundsException: Index 102 out of bounds for length 102
proof
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
      using B 1 ( real_polynomial_function_imp_sum
byforce: norm_eq_1 
    by(autos: linear ".
      by (simp
    also have "... = (\j\B. if j = i then x \ i else 0)"
      by (have java.lang.NullPointerException
     have". =
      by (simp add: \<open>finite B\<close> that inner_commute)
     show ?thesis( iffI )
  qed
qed   showrhs


theorem:
java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
  assumes "compact S"
       byforce: real_polynomial_function_eq 
      and   "
            by (force : Limitscontinuous_on_add  .  then"(
    obtains g where pusing [OFjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
                    "\x. x \ S \ norm(f x - g x) < e"
proof
obtain  B\<subseteq> T" and orthB: "pairwise orthogonal B"
             : "x. x \ B \ norm x = 1"
andB  by (induct f) (auto simp: linear_continuous_at
             java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  using 
   " B"
    by ( ( euclidean_isCont
   hwhere
usingfinite_imp_nat_seg_image_inj_on  
  with  
    java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
   
() \<
  have cont: "continuous_on "polynomial_function
--> --------------------

--> maximum size reached

--> --------------------

98%


¤ Dauer der Verarbeitung: 0.48 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge