src/HOL/Analysis/Tagged_Division.thy
changeset 64267 b9a1486e79be
parent 63957 c3da799b1b45
child 64910 6108dddad9f0
equal deleted inserted replaced
64265:8eb6365f5916 64267:b9a1486e79be
    28 qed auto
    28 qed auto
    29 
    29 
    30 lemma sum_sum_product:
    30 lemma sum_sum_product:
    31   assumes "finite s"
    31   assumes "finite s"
    32     and "\<forall>i\<in>s. finite (t i)"
    32     and "\<forall>i\<in>s. finite (t i)"
    33   shows "setsum (\<lambda>i. setsum (x i) (t i)::real) s =
    33   shows "sum (\<lambda>i. sum (x i) (t i)::real) s =
    34     setsum (\<lambda>(i,j). x i j) {(i,j) | i j. i \<in> s \<and> j \<in> t i}"
    34     sum (\<lambda>(i,j). x i j) {(i,j) | i j. i \<in> s \<and> j \<in> t i}"
    35   using assms
    35   using assms
    36 proof induct
    36 proof induct
    37   case (insert a s)
    37   case (insert a s)
    38   have *: "{(i, j) |i j. i \<in> insert a s \<and> j \<in> t i} =
    38   have *: "{(i, j) |i j. i \<in> insert a s \<and> j \<in> t i} =
    39     (\<lambda>y. (a,y)) ` (t a) \<union> {(i, j) |i j. i \<in> s \<and> j \<in> t i}" by auto
    39     (\<lambda>y. (a,y)) ` (t a) \<union> {(i, j) |i j. i \<in> s \<and> j \<in> t i}" by auto
    40   show ?case
    40   show ?case
    41     unfolding *
    41     unfolding *
    42     apply (subst setsum.union_disjoint)
    42     apply (subst sum.union_disjoint)
    43     unfolding setsum.insert[OF insert(1-2)]
    43     unfolding sum.insert[OF insert(1-2)]
    44     prefer 4
    44     prefer 4
    45     apply (subst insert(3))
    45     apply (subst insert(3))
    46     unfolding add_right_cancel
    46     unfolding add_right_cancel
    47   proof -
    47   proof -
    48     show "setsum (x a) (t a) = (\<Sum>(xa, y)\<in> Pair a ` t a. x xa y)"
    48     show "sum (x a) (t a) = (\<Sum>(xa, y)\<in> Pair a ` t a. x xa y)"
    49       apply (subst setsum.reindex)
    49       apply (subst sum.reindex)
    50       unfolding inj_on_def
    50       unfolding inj_on_def
    51       apply auto
    51       apply auto
    52       done
    52       done
    53     show "finite {(i, j) |i j. i \<in> s \<and> j \<in> t i}"
    53     show "finite {(i, j) |i j. i \<in> s \<and> j \<in> t i}"
    54       apply (rule finite_product_dependent)
    54       apply (rule finite_product_dependent)
   194   where "interval_lowerbound s = (\<Sum>i\<in>Basis. (INF x:s. x\<bullet>i) *\<^sub>R i)"
   194   where "interval_lowerbound s = (\<Sum>i\<in>Basis. (INF x:s. x\<bullet>i) *\<^sub>R i)"
   195 
   195 
   196 lemma interval_upperbound[simp]:
   196 lemma interval_upperbound[simp]:
   197   "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow>
   197   "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow>
   198     interval_upperbound (cbox a b) = (b::'a::euclidean_space)"
   198     interval_upperbound (cbox a b) = (b::'a::euclidean_space)"
   199   unfolding interval_upperbound_def euclidean_representation_setsum cbox_def
   199   unfolding interval_upperbound_def euclidean_representation_sum cbox_def
   200   by (safe intro!: cSup_eq) auto
   200   by (safe intro!: cSup_eq) auto
   201 
   201 
   202 lemma interval_lowerbound[simp]:
   202 lemma interval_lowerbound[simp]:
   203   "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow>
   203   "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow>
   204     interval_lowerbound (cbox a b) = (a::'a::euclidean_space)"
   204     interval_lowerbound (cbox a b) = (a::'a::euclidean_space)"
   205   unfolding interval_lowerbound_def euclidean_representation_setsum cbox_def
   205   unfolding interval_lowerbound_def euclidean_representation_sum cbox_def
   206   by (safe intro!: cInf_eq) auto
   206   by (safe intro!: cInf_eq) auto
   207 
   207 
   208 lemmas interval_bounds = interval_upperbound interval_lowerbound
   208 lemmas interval_bounds = interval_upperbound interval_lowerbound
   209 
   209 
   210 lemma
   210 lemma
   228       by (subst (2) fst_image_times') (simp del: fst_image_times add: o_def inner_Pair_0)
   228       by (subst (2) fst_image_times') (simp del: fst_image_times add: o_def inner_Pair_0)
   229   moreover from assms have snd_image_times': "B = snd ` (A \<times> B)" by simp
   229   moreover from assms have snd_image_times': "B = snd ` (A \<times> B)" by simp
   230   have "(\<Sum>i\<in>Basis. (SUP x:A \<times> B. x \<bullet> (0, i)) *\<^sub>R i) = (\<Sum>i\<in>Basis. (SUP x:B. x \<bullet> i) *\<^sub>R i)"
   230   have "(\<Sum>i\<in>Basis. (SUP x:A \<times> B. x \<bullet> (0, i)) *\<^sub>R i) = (\<Sum>i\<in>Basis. (SUP x:B. x \<bullet> i) *\<^sub>R i)"
   231       by (subst (2) snd_image_times') (simp del: snd_image_times add: o_def inner_Pair_0)
   231       by (subst (2) snd_image_times') (simp del: snd_image_times add: o_def inner_Pair_0)
   232   ultimately show ?thesis unfolding interval_upperbound_def
   232   ultimately show ?thesis unfolding interval_upperbound_def
   233       by (subst setsum_Basis_prod_eq) (auto simp add: setsum_prod)
   233       by (subst sum_Basis_prod_eq) (auto simp add: sum_prod)
   234 qed
   234 qed
   235 
   235 
   236 lemma interval_lowerbound_Times:
   236 lemma interval_lowerbound_Times:
   237   assumes "A \<noteq> {}" and "B \<noteq> {}"
   237   assumes "A \<noteq> {}" and "B \<noteq> {}"
   238   shows "interval_lowerbound (A \<times> B) = (interval_lowerbound A, interval_lowerbound B)"
   238   shows "interval_lowerbound (A \<times> B) = (interval_lowerbound A, interval_lowerbound B)"
   242       by (subst (2) fst_image_times') (simp del: fst_image_times add: o_def inner_Pair_0)
   242       by (subst (2) fst_image_times') (simp del: fst_image_times add: o_def inner_Pair_0)
   243   moreover from assms have snd_image_times': "B = snd ` (A \<times> B)" by simp
   243   moreover from assms have snd_image_times': "B = snd ` (A \<times> B)" by simp
   244   have "(\<Sum>i\<in>Basis. (INF x:A \<times> B. x \<bullet> (0, i)) *\<^sub>R i) = (\<Sum>i\<in>Basis. (INF x:B. x \<bullet> i) *\<^sub>R i)"
   244   have "(\<Sum>i\<in>Basis. (INF x:A \<times> B. x \<bullet> (0, i)) *\<^sub>R i) = (\<Sum>i\<in>Basis. (INF x:B. x \<bullet> i) *\<^sub>R i)"
   245       by (subst (2) snd_image_times') (simp del: snd_image_times add: o_def inner_Pair_0)
   245       by (subst (2) snd_image_times') (simp del: snd_image_times add: o_def inner_Pair_0)
   246   ultimately show ?thesis unfolding interval_lowerbound_def
   246   ultimately show ?thesis unfolding interval_lowerbound_def
   247       by (subst setsum_Basis_prod_eq) (auto simp add: setsum_prod)
   247       by (subst sum_Basis_prod_eq) (auto simp add: sum_prod)
   248 qed
   248 qed
   249 
   249 
   250 subsection \<open>The notion of a gauge --- simply an open set containing the point.\<close>
   250 subsection \<open>The notion of a gauge --- simply an open set containing the point.\<close>
   251 
   251 
   252 definition "gauge d \<longleftrightarrow> (\<forall>x. x \<in> d x \<and> open (d x))"
   252 definition "gauge d \<longleftrightarrow> (\<forall>x. x \<in> d x \<and> open (d x))"
  1357 
  1357 
  1358 lemma (in comm_monoid) operative_empty:
  1358 lemma (in comm_monoid) operative_empty:
  1359   assumes g: "operative g" shows "g {} = \<^bold>1"
  1359   assumes g: "operative g" shows "g {} = \<^bold>1"
  1360 proof -
  1360 proof -
  1361   have *: "cbox One (-One) = ({}::'b set)"
  1361   have *: "cbox One (-One) = ({}::'b set)"
  1362     by (auto simp: box_eq_empty inner_setsum_left inner_Basis setsum.If_cases ex_in_conv)
  1362     by (auto simp: box_eq_empty inner_sum_left inner_Basis sum.If_cases ex_in_conv)
  1363   moreover have "box One (-One) = ({}::'b set)"
  1363   moreover have "box One (-One) = ({}::'b set)"
  1364     using box_subset_cbox[of One "-One"] by (auto simp: *)
  1364     using box_subset_cbox[of One "-One"] by (auto simp: *)
  1365   ultimately show ?thesis
  1365   ultimately show ?thesis
  1366     using operativeD(1)[OF g, of One "-One"] by simp
  1366     using operativeD(1)[OF g, of One "-One"] by simp
  1367 qed
  1367 qed
  1436     unfolding *
  1436     unfolding *
  1437     unfolding subset_eq
  1437     unfolding subset_eq
  1438     apply rule
  1438     apply rule
  1439     unfolding mem_Collect_eq split_beta
  1439     unfolding mem_Collect_eq split_beta
  1440     apply (erule bexE conjE)+
  1440     apply (erule bexE conjE)+
  1441     apply (simp only: mem_Collect_eq inner_setsum_left_Basis simp_thms)
  1441     apply (simp only: mem_Collect_eq inner_sum_left_Basis simp_thms)
  1442     apply (erule exE conjE)+
  1442     apply (erule exE conjE)+
  1443   proof
  1443   proof
  1444     fix i l x
  1444     fix i l x
  1445     assume as:
  1445     assume as:
  1446       "(if fst x = k then c else a \<bullet> fst x) < snd x" "snd x < b \<bullet> fst x"
  1446       "(if fst x = k then c else a \<bullet> fst x) < snd x" "snd x < b \<bullet> fst x"
  1929 
  1929 
  1930 lemma additive_tagged_division_1:
  1930 lemma additive_tagged_division_1:
  1931   fixes f :: "real \<Rightarrow> 'a::real_normed_vector"
  1931   fixes f :: "real \<Rightarrow> 'a::real_normed_vector"
  1932   assumes "a \<le> b"
  1932   assumes "a \<le> b"
  1933     and "p tagged_division_of {a..b}"
  1933     and "p tagged_division_of {a..b}"
  1934   shows "setsum (\<lambda>(x,k). f(Sup k) - f(Inf k)) p = f b - f a"
  1934   shows "sum (\<lambda>(x,k). f(Sup k) - f(Inf k)) p = f b - f a"
  1935 proof -
  1935 proof -
  1936   let ?f = "(\<lambda>k::(real) set. if k = {} then 0 else f(interval_upperbound k) - f(interval_lowerbound k))"
  1936   let ?f = "(\<lambda>k::(real) set. if k = {} then 0 else f(interval_upperbound k) - f(interval_lowerbound k))"
  1937   have ***: "\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i"
  1937   have ***: "\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i"
  1938     using assms by auto
  1938     using assms by auto
  1939   have *: "add.operative ?f"
  1939   have *: "add.operative ?f"
  1940     unfolding add.operative_1_lt box_eq_empty
  1940     unfolding add.operative_1_lt box_eq_empty
  1941     by auto
  1941     by auto
  1942   have **: "cbox a b \<noteq> {}"
  1942   have **: "cbox a b \<noteq> {}"
  1943     using assms(1) by auto
  1943     using assms(1) by auto
  1944   note setsum.operative_tagged_division[OF * assms(2)[simplified box_real[symmetric]]]
  1944   note sum.operative_tagged_division[OF * assms(2)[simplified box_real[symmetric]]]
  1945   note * = this[unfolded if_not_P[OF **] interval_bounds[OF ***],symmetric]
  1945   note * = this[unfolded if_not_P[OF **] interval_bounds[OF ***],symmetric]
  1946   show ?thesis
  1946   show ?thesis
  1947     unfolding *
  1947     unfolding *
  1948     apply (rule setsum.cong)
  1948     apply (rule sum.cong)
  1949     unfolding split_paired_all split_conv
  1949     unfolding split_paired_all split_conv
  1950     using assms(2)
  1950     using assms(2)
  1951     apply auto
  1951     apply auto
  1952     done
  1952     done
  1953 qed
  1953 qed
  1957 
  1957 
  1958 lemma additive_tagged_division_1':
  1958 lemma additive_tagged_division_1':
  1959   fixes f :: "real \<Rightarrow> 'a::real_normed_vector"
  1959   fixes f :: "real \<Rightarrow> 'a::real_normed_vector"
  1960   assumes "a \<le> b"
  1960   assumes "a \<le> b"
  1961     and "p tagged_division_of {a..b}"
  1961     and "p tagged_division_of {a..b}"
  1962   shows "setsum (\<lambda>(x,k). f (Sup k) - f(Inf k)) p = f b - f a"
  1962   shows "sum (\<lambda>(x,k). f (Sup k) - f(Inf k)) p = f b - f a"
  1963   using additive_tagged_division_1[OF _ assms(2), of f]
  1963   using additive_tagged_division_1[OF _ assms(2), of f]
  1964   using assms(1)
  1964   using assms(1)
  1965   by auto
  1965   by auto
  1966 
  1966 
  1967 subsection \<open>Fine-ness of a partition w.r.t. a gauge.\<close>
  1967 subsection \<open>Fine-ness of a partition w.r.t. a gauge.\<close>
  2262 
  2262 
  2263   have interv: "\<exists>n. \<forall>x\<in>cbox (A n) (B n). \<forall>y\<in>cbox (A n) (B n). dist x y < e"
  2263   have interv: "\<exists>n. \<forall>x\<in>cbox (A n) (B n). \<forall>y\<in>cbox (A n) (B n). dist x y < e"
  2264     if e: "0 < e" for e
  2264     if e: "0 < e" for e
  2265   proof -
  2265   proof -
  2266     obtain n where n: "(\<Sum>i\<in>Basis. b \<bullet> i - a \<bullet> i) / e < 2 ^ n"
  2266     obtain n where n: "(\<Sum>i\<in>Basis. b \<bullet> i - a \<bullet> i) / e < 2 ^ n"
  2267       using real_arch_pow[of 2 "(setsum (\<lambda>i. b\<bullet>i - a\<bullet>i) Basis) / e"] by auto
  2267       using real_arch_pow[of 2 "(sum (\<lambda>i. b\<bullet>i - a\<bullet>i) Basis) / e"] by auto
  2268     show ?thesis
  2268     show ?thesis
  2269     proof (rule exI [where x=n], clarify)
  2269     proof (rule exI [where x=n], clarify)
  2270       fix x y
  2270       fix x y
  2271       assume xy: "x\<in>cbox (A n) (B n)" "y\<in>cbox (A n) (B n)"
  2271       assume xy: "x\<in>cbox (A n) (B n)" "y\<in>cbox (A n) (B n)"
  2272       have "dist x y \<le> setsum (\<lambda>i. \<bar>(x - y)\<bullet>i\<bar>) Basis"
  2272       have "dist x y \<le> sum (\<lambda>i. \<bar>(x - y)\<bullet>i\<bar>) Basis"
  2273         unfolding dist_norm by(rule norm_le_l1)
  2273         unfolding dist_norm by(rule norm_le_l1)
  2274       also have "\<dots> \<le> setsum (\<lambda>i. B n\<bullet>i - A n\<bullet>i) Basis"
  2274       also have "\<dots> \<le> sum (\<lambda>i. B n\<bullet>i - A n\<bullet>i) Basis"
  2275       proof (rule setsum_mono)
  2275       proof (rule sum_mono)
  2276         fix i :: 'a
  2276         fix i :: 'a
  2277         assume i: "i \<in> Basis"
  2277         assume i: "i \<in> Basis"
  2278         show "\<bar>(x - y) \<bullet> i\<bar> \<le> B n \<bullet> i - A n \<bullet> i"
  2278         show "\<bar>(x - y) \<bullet> i\<bar> \<le> B n \<bullet> i - A n \<bullet> i"
  2279           using xy[unfolded mem_box,THEN bspec, OF i]
  2279           using xy[unfolded mem_box,THEN bspec, OF i]
  2280           by (auto simp: inner_diff_left)
  2280           by (auto simp: inner_diff_left)
  2281       qed
  2281       qed
  2282       also have "\<dots> \<le> setsum (\<lambda>i. b\<bullet>i - a\<bullet>i) Basis / 2^n"
  2282       also have "\<dots> \<le> sum (\<lambda>i. b\<bullet>i - a\<bullet>i) Basis / 2^n"
  2283         unfolding setsum_divide_distrib
  2283         unfolding sum_divide_distrib
  2284       proof (rule setsum_mono)
  2284       proof (rule sum_mono)
  2285         show "B n \<bullet> i - A n \<bullet> i \<le> (b \<bullet> i - a \<bullet> i) / 2 ^ n" if i: "i \<in> Basis" for i
  2285         show "B n \<bullet> i - A n \<bullet> i \<le> (b \<bullet> i - a \<bullet> i) / 2 ^ n" if i: "i \<in> Basis" for i
  2286         proof (induct n)
  2286         proof (induct n)
  2287           case 0
  2287           case 0
  2288           then show ?case
  2288           then show ?case
  2289             unfolding AB by auto
  2289             unfolding AB by auto
  2598             using openE by blast
  2598             using openE by blast
  2599           have "norm (x - y) < \<epsilon>"
  2599           have "norm (x - y) < \<epsilon>"
  2600                if "(\<And>i. i \<in> Basis \<Longrightarrow> \<bar>x \<bullet> i - y \<bullet> i\<bar> \<le> \<epsilon> / (2 * real DIM('a)))" for y
  2600                if "(\<And>i. i \<in> Basis \<Longrightarrow> \<bar>x \<bullet> i - y \<bullet> i\<bar> \<le> \<epsilon> / (2 * real DIM('a)))" for y
  2601           proof -
  2601           proof -
  2602             have "norm (x - y) \<le> (\<Sum>i\<in>Basis. \<bar>x \<bullet> i - y \<bullet> i\<bar>)"
  2602             have "norm (x - y) \<le> (\<Sum>i\<in>Basis. \<bar>x \<bullet> i - y \<bullet> i\<bar>)"
  2603               by (metis (no_types, lifting) inner_diff_left norm_le_l1 setsum.cong)
  2603               by (metis (no_types, lifting) inner_diff_left norm_le_l1 sum.cong)
  2604             also have "... \<le> DIM('a) * (\<epsilon> / (2 * real DIM('a)))"
  2604             also have "... \<le> DIM('a) * (\<epsilon> / (2 * real DIM('a)))"
  2605               by (meson setsum_bounded_above that)
  2605               by (meson sum_bounded_above that)
  2606             also have "... = \<epsilon> / 2"
  2606             also have "... = \<epsilon> / 2"
  2607               by (simp add: divide_simps)
  2607               by (simp add: divide_simps)
  2608             also have "... < \<epsilon>"
  2608             also have "... < \<epsilon>"
  2609               by (simp add: \<open>0 < \<epsilon>\<close>)
  2609               by (simp add: \<open>0 < \<epsilon>\<close>)
  2610             finally show ?thesis .
  2610             finally show ?thesis .