# HG changeset patch # User paulson # Date 1554928172 -3600 # Node ID c8deb8ba6d05321bb7c4e30a233713f42a310189 # Parent 4005298550a69e1af773eb4da784ede61b3e7037 Fixing the main Homology theory; also moving a lot of sum/prod lemmas into their generic context diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Analysis/Cartesian_Euclidean_Space.thy --- a/src/HOL/Analysis/Cartesian_Euclidean_Space.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Analysis/Cartesian_Euclidean_Space.thy Wed Apr 10 21:29:32 2019 +0100 @@ -13,7 +13,7 @@ lemma sum_mult_product: "sum h {..i\{..j\{..j. j + i * B) {..i\n. 0 a i = 0") case True then have [simp]: "\z. f z = a 0" - by (simp add: that sum_atMost_shift) + by (simp add: that sum.atMost_shift) have False using compf [of "{a 0}"] by simp then show ?thesis .. next diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Analysis/FPS_Convergence.thy --- a/src/HOL/Analysis/FPS_Convergence.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Analysis/FPS_Convergence.thy Wed Apr 10 21:29:32 2019 +0100 @@ -333,7 +333,7 @@ have "norm (natfun_inverse f (Suc n)) = norm (\i = Suc 0..Suc n. fps_nth f i * natfun_inverse f (Suc n - i))" (is "_ = norm ?S") using assms - by (simp add: field_simps norm_mult norm_divide del: sum_cl_ivl_Suc) + by (simp add: field_simps norm_mult norm_divide del: sum.cl_ivl_Suc) also have "norm ?S \ (\i = Suc 0..Suc n. norm (fps_nth f i * natfun_inverse f (Suc n - i)))" by (rule norm_sum) also have "\ \ (\i = Suc 0..Suc n. norm (fps_nth f i) / \ ^ (Suc n - i))" diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Analysis/Gamma_Function.thy --- a/src/HOL/Analysis/Gamma_Function.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Analysis/Gamma_Function.thy Wed Apr 10 21:29:32 2019 +0100 @@ -510,7 +510,7 @@ by (simp add: fact_prod) (subst prod_dividef [symmetric], simp_all add: field_simps) also from m have "z * ... = (\k=0..n. z + k) / fact n" - by (simp add: prod.atLeast0_atMost_Suc_shift prod.atLeast_Suc_atMost_Suc_shift) + by (simp add: prod.atLeast0_atMost_Suc_shift prod.atLeast_Suc_atMost_Suc_shift del: prod.cl_ivl_Suc) also have "(\k=0..n. z + k) = pochhammer z (Suc n)" unfolding pochhammer_prod by (simp add: prod.atLeast0_atMost_Suc atLeastLessThanSuc_atLeastAtMost) @@ -535,7 +535,7 @@ proof eventually_elim fix n :: nat assume n: "n > 0" have "(\kk=1..n. z / of_nat k - ln (1 + z / of_nat k))" - by (subst atLeast0LessThan [symmetric], subst sum_shift_bounds_Suc_ivl [symmetric], + by (subst atLeast0LessThan [symmetric], subst sum.shift_bounds_Suc_ivl [symmetric], subst atLeastLessThanSuc_atLeastAtMost) simp_all also have "\ = z * of_real (harm n) - (\k=1..n. ln (1 + z / of_nat k))" by (simp add: harm_def sum_subtractf sum_distrib_left divide_inverse) @@ -653,7 +653,7 @@ also have "(\n\\. f n) = (\nn=k..n=k..n=0..nnna. sum f {.. lim (\m. sum f {..k=1..n. 1 + 1 / of_nat k :: real) = (\k=1..n. (of_nat k + 1) / of_nat k)" by (intro prod.cong) (simp_all add: divide_simps) also have "(\k=1..n. (of_nat k + 1) / of_nat k :: real) = of_nat n + 1" - by (induction n) (simp_all add: prod_nat_ivl_Suc' divide_simps) + by (induction n) (simp_all add: prod.nat_ivl_Suc' divide_simps) finally show ?thesis .. qed @@ -2515,8 +2515,13 @@ (simp_all add: Gamma_series_euler'_def prod.distrib prod_inversef[symmetric] divide_inverse) also have "(\k=1..n. (1 + z / of_nat k)) = pochhammer (z + 1) n / fact n" - by (cases n) (simp_all add: pochhammer_prod fact_prod atLeastLessThanSuc_atLeastAtMost - prod_dividef [symmetric] field_simps prod.atLeast_Suc_atMost_Suc_shift) + proof (cases n) + case (Suc n') + then show ?thesis + unfolding pochhammer_prod fact_prod + by (simp add: atLeastLessThanSuc_atLeastAtMost field_simps prod_dividef + prod.atLeast_Suc_atMost_Suc_shift del: prod.cl_ivl_Suc) + qed auto also have "z * \ = pochhammer z (Suc n) / fact n" by (simp add: pochhammer_rec) finally show "?r n = Gamma_series_euler' z n / Gamma_series z n" by simp qed @@ -2561,7 +2566,7 @@ have "(\n. \k=1..n. z / of_nat k - ln (1 + z / of_nat k)) \ ln_Gamma z + euler_mascheroni * z + ln z" using ln_Gamma_series'_aux[OF False] by (simp only: atLeastLessThanSuc_atLeastAtMost [symmetric] One_nat_def - sum_shift_bounds_Suc_ivl sums_def atLeast0LessThan) + sum.shift_bounds_Suc_ivl sums_def atLeast0LessThan) from tendsto_exp[OF this] False z have "?f \ z * exp (euler_mascheroni * z) * Gamma z" by (simp add: exp_add exp_sum exp_diff mult_ac Gamma_complex_altdef A) from tendsto_mult[OF tendsto_const[of "exp (-euler_mascheroni * z) / z"] this] z @@ -2842,7 +2847,7 @@ also have "?A = (\t. ?f t * ?g' t)" by (intro ext) (simp_all add: field_simps) also have "?B = - (of_nat (Suc n) * fact n / pochhammer z (n+2))" by (simp add: divide_simps pochhammer_rec - prod_shift_bounds_cl_Suc_ivl del: of_nat_Suc) + prod.shift_bounds_cl_Suc_ivl del: of_nat_Suc) finally show "((\t. ?f t * ?g' t) has_integral (?f 1 * ?g 1 - ?f 0 * ?g 0 - ?I)) {0..1}" by simp qed (simp_all add: bounded_bilinear_mult) @@ -3248,7 +3253,7 @@ have "(\n. P x n - P x (Suc n)) sums (P x 0 - sin (pi * x) / (pi * x))" unfolding P_def using x by (intro telescope_sums' sin_product_formula_real') also have "(\n. P x n - P x (Suc n)) = (\n. (x^2 / of_nat (Suc n)^2) * P x n)" - unfolding P_def by (simp add: prod_nat_ivl_Suc' algebra_simps) + unfolding P_def by (simp add: prod.nat_ivl_Suc' algebra_simps) also have "P x 0 = 1" by (simp add: P_def) finally have "(\n. x\<^sup>2 / (of_nat (Suc n))\<^sup>2 * P x n) sums (1 - sin (pi * x) / (pi * x))" . from sums_divide[OF this, of "x^2"] x show ?thesis unfolding g_def by simp diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Analysis/Harmonic_Numbers.thy --- a/src/HOL/Analysis/Harmonic_Numbers.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Analysis/Harmonic_Numbers.thy Wed Apr 10 21:29:32 2019 +0100 @@ -61,7 +61,7 @@ also have "\ \ convergent (\n. \k=Suc 0..Suc n. inverse (of_nat k) :: real)" unfolding harm_def[abs_def] by (subst convergent_Suc_iff) simp_all also have "... \ convergent (\n. \k\n. inverse (of_nat (Suc k)) :: real)" - by (subst sum_shift_bounds_cl_Suc_ivl) (simp add: atLeast0AtMost) + by (subst sum.shift_bounds_cl_Suc_ivl) (simp add: atLeast0AtMost) also have "... \ summable (\n. inverse (of_nat n) :: real)" by (subst summable_Suc_iff [symmetric]) (simp add: summable_iff_convergent') also have "\..." by (rule not_summable_harmonic) @@ -123,7 +123,7 @@ "euler_mascheroni.sum_integral_diff_series n = harm (Suc n) - ln (of_nat (Suc n))" proof - have "harm (Suc n) = (\k=0..n. inverse (of_nat k + 1) :: real)" unfolding harm_def - unfolding One_nat_def by (subst sum_shift_bounds_cl_Suc_ivl) (simp add: add_ac) + unfolding One_nat_def by (subst sum.shift_bounds_cl_Suc_ivl) (simp add: add_ac) moreover have "((\x. inverse (x + 1) :: real) has_integral ln (of_nat n + 1) - ln (0 + 1)) {0..of_nat n}" by (intro fundamental_theorem_of_calculus) diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Analysis/Infinite_Products.thy --- a/src/HOL/Analysis/Infinite_Products.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Analysis/Infinite_Products.thy Wed Apr 10 21:29:32 2019 +0100 @@ -620,7 +620,7 @@ then have "prod f {..n+M} = prod f {.. = prod f {..i\n. f (i + M))" - by (metis (mono_tags, lifting) add.left_neutral atMost_atLeast0 prod_shift_bounds_cl_nat_ivl) + by (metis (mono_tags, lifting) add.left_neutral atMost_atLeast0 prod.shift_bounds_cl_nat_ivl) finally show ?thesis by metis qed ultimately have "(\n. prod f {..n}) \ prod f {..\n. 1 \ prod f n\ \prodinf f = 1\ antisym f convergent_prod_has_prod ge1 order_trans prod_le_prodinf zero_le_one) then have "(\n\{i}. f n) \ prod f {.. Suc i" for i n - by (metis mult.left_neutral order_refl prod.cong prod.neutral_const prod_lessThan_Suc) + by (metis mult.left_neutral order_refl prod.cong prod.neutral_const prod.lessThan_Suc) then show "\N. \n\N. (\n\{i}. f n) \ prod f {..n \ i\ le_trans less_eq_real_def) ultimately show ?thesis - by (metis le_less_trans mult.commute not_le prod_lessThan_Suc) + by (metis le_less_trans mult.commute not_le prod.lessThan_Suc) qed lemma prod_less_prodinf: @@ -1187,7 +1187,8 @@ have "raw_has_prod f M (a * f M) \ (\i. \j\Suc i. f (j+M)) \ a * f M \ a * f M \ 0" by (subst LIMSEQ_Suc_iff) (simp add: raw_has_prod_def) also have "\ \ (\i. (\j\i. f (Suc j + M)) * f M) \ a * f M \ a * f M \ 0" - by (simp add: ac_simps atMost_Suc_eq_insert_0 image_Suc_atMost prod_atLeast1_atMost_eq lessThan_Suc_atMost) + by (simp add: ac_simps atMost_Suc_eq_insert_0 image_Suc_atMost prod.atLeast1_atMost_eq lessThan_Suc_atMost + del: prod.cl_ivl_Suc) also have "\ \ raw_has_prod (\n. f (Suc n)) M a \ f M \ 0" proof safe assume tends: "(\i. (\j\i. f (Suc j + M)) * f M) \ a * f M" and 0: "a * f M \ 0" diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Analysis/Poly_Roots.thy --- a/src/HOL/Analysis/Poly_Roots.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Analysis/Poly_Roots.thy Wed Apr 10 21:29:32 2019 +0100 @@ -23,7 +23,7 @@ also have "... = (x - y) * (\i\n. (\jji=Suc j..n. a i * y^(i - Suc j) * x^j))" - by (simp add: nested_sum_swap') + by (simp add: sum.nested_swap') finally show ?thesis . qed diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Analysis/Summation_Tests.thy --- a/src/HOL/Analysis/Summation_Tests.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Analysis/Summation_Tests.thy Wed Apr 10 21:29:32 2019 +0100 @@ -209,7 +209,7 @@ from Bseq_mult[OF Bfun_const[of 2] this] have "Bseq (\n. \kn. (\k=Suc 0..n. (\k=0..n. (\kk=Suc m..n. r * f k) = (\k=Suc m..n. r * f k)" by simp also have "(\k=Suc m..n. r * f k) = (\k=m.. \ (\k=m..kk=Suc 0..k=Suc 0..kkkk=Suc 0..k=Suc 0..kk = (\k\n. of_nat (n choose k) * a^k * b^(n + 1 - k)) + (\k=1..n+1. of_nat (n choose (k - 1)) * a^k * b^(n + 1 - k))" - by (simp add: atMost_atLeast0 sum_shift_bounds_cl_Suc_ivl Suc_diff_le field_simps del: sum_cl_ivl_Suc) + by (simp add: atMost_atLeast0 sum.shift_bounds_cl_Suc_ivl Suc_diff_le field_simps del: sum.cl_ivl_Suc) also have "\ = a^(n + 1) + b^(n + 1) + (\k=1..n. of_nat (n choose (k - 1)) * a^k * b^(n + 1 - k)) + (\k=1..n. of_nat (n choose k) * a^k * b^(n + 1 - k))" @@ -337,7 +337,7 @@ lemma gbinomial_0 [simp]: "a gchoose 0 = 1" "0 gchoose (Suc k) = 0" - by (simp_all add: gbinomial_prod_rev prod.atLeast0_lessThan_Suc_shift) + by (simp_all add: gbinomial_prod_rev prod.atLeast0_lessThan_Suc_shift del: prod.op_ivl_Suc) lemma gbinomial_Suc: "a gchoose (Suc k) = prod (\i. a - of_nat i) {0..k} div fact (Suc k)" by (simp add: gbinomial_prod_rev atLeastLessThanSuc_atLeastAtMost) @@ -358,11 +358,14 @@ lemma gbinomial_pochhammer: "a gchoose k = (- 1) ^ k * pochhammer (- a) k / fact k" for a :: "'a::field_char_0" - by (cases k) - (simp_all add: pochhammer_minus, - simp_all add: gbinomial_prod_rev pochhammer_prod_rev - power_mult_distrib [symmetric] atLeastLessThanSuc_atLeastAtMost - prod.atLeast_Suc_atMost_Suc_shift of_nat_diff) +proof (cases k) + case (Suc k') + then show ?thesis + apply (simp add: pochhammer_minus) + apply (simp add: gbinomial_prod_rev pochhammer_prod_rev power_mult_distrib [symmetric] atLeastLessThanSuc_atLeastAtMost + prod.atLeast_Suc_atMost_Suc_shift of_nat_diff del: prod.cl_ivl_Suc) + done +qed auto lemma gbinomial_pochhammer': "a gchoose k = pochhammer (a - of_nat k + 1) k / fact k" for a :: "'a::field_char_0" @@ -411,7 +414,7 @@ also have "\ = ((\i\{0.. {k..i = 0..i. of_nat (m + k - i) :: 'a" 0 k m] + using prod.shift_bounds_nat_ivl [of "\i. of_nat (m + k - i) :: 'a" 0 k m] by (simp add: fact_prod_rev [of m] prod.union_disjoint of_nat_diff) then have "fact n / fact (n - k) = ((\i = 0.. = (a gchoose Suc h) * of_nat (Suc (Suc h) * fact (Suc h)) + (\i=0..Suc h. a - of_nat i)" - apply (simp del: fact_Suc add: gbinomial_mult_fact field_simps mult.left_commute [of _ "2"]) + apply (simp del: fact_Suc prod.op_ivl_Suc add: gbinomial_mult_fact field_simps mult.left_commute [of _ "2"]) apply (simp del: fact_Suc add: fact_Suc [of "Suc h"] field_simps gbinomial_mult_fact mult.left_commute [of _ "2"] atLeastLessThanSuc_atLeastAtMost) done @@ -487,7 +490,7 @@ by (simp add: field_simps Suc atLeastLessThanSuc_atLeastAtMost) also have "\ = (\i\{0..k}. (a + 1) - of_nat i)" using eq0 - by (simp add: Suc prod.atLeast0_atMost_Suc_shift) + by (simp add: Suc prod.atLeast0_atMost_Suc_shift del: prod.cl_ivl_Suc) also have "\ = (fact (Suc k)) * ((a + 1) gchoose (Suc k))" by (simp only: gbinomial_mult_fact atLeastLessThanSuc_atLeastAtMost) finally show ?thesis @@ -536,7 +539,7 @@ have "(\i\n. i * (n choose i)) = (\i\Suc m. i * (Suc m choose i))" by (simp add: Suc) also have "\ = Suc m * 2 ^ m" - unfolding sum_atMost_Suc_shift Suc_times_binomial sum_distrib_left[symmetric] + unfolding sum.atMost_Suc_shift Suc_times_binomial sum_distrib_left[symmetric] by (simp add: choose_row_sum) finally show ?thesis using Suc by simp @@ -556,7 +559,7 @@ (\i\Suc m. (-1) ^ i * of_nat i * of_nat (Suc m choose i))" by (simp add: Suc) also have "\ = (\i\m. (-1) ^ (Suc i) * of_nat (Suc i * (Suc m choose Suc i)))" - by (simp only: sum_atMost_Suc_shift sum_distrib_left[symmetric] mult_ac of_nat_mult) simp + by (simp only: sum.atMost_Suc_shift sum_distrib_left[symmetric] mult_ac of_nat_mult) simp also have "\ = - of_nat (Suc m) * (\i\m. (-1) ^ i * of_nat (m choose i))" by (subst sum_distrib_left, rule sum.cong[OF refl], subst Suc_times_binomial) (simp add: algebra_simps) @@ -597,7 +600,7 @@ (\i\n. of_nat (n choose i) * pochhammer a (Suc i) * pochhammer b (n - i)) + ((\i\n. of_nat (n choose Suc i) * pochhammer a (Suc i) * pochhammer b (n - i)) + pochhammer b (Suc n))" - by (subst sum_atMost_Suc_shift) (simp add: ring_distribs sum.distrib) + by (subst sum.atMost_Suc_shift) (simp add: ring_distribs sum.distrib) also have "(\i\n. of_nat (n choose i) * pochhammer a (Suc i) * pochhammer b (n - i)) = a * pochhammer ((a + 1) + b) n" by (subst Suc) (simp add: sum_distrib_left pochhammer_rec mult_ac) @@ -606,7 +609,7 @@ (\i=0..Suc n. of_nat (n choose i) * pochhammer a i * pochhammer b (Suc n - i))" apply (subst sum.atLeast_Suc_atMost) apply simp - apply (subst sum_shift_bounds_cl_Suc_ivl) + apply (subst sum.shift_bounds_cl_Suc_ivl) apply (simp add: atLeast0AtMost) done also have "\ = (\i\n. of_nat (n choose i) * pochhammer a i * pochhammer b (Suc n - i))" @@ -675,7 +678,7 @@ then have "((a + 1) gchoose (Suc (Suc b))) = (\i = 0..Suc b. a + (1 - of_nat i)) / fact (b + 2)" by (simp add: field_simps gbinomial_prod_rev atLeastLessThanSuc_atLeastAtMost) also have "(\i = 0..Suc b. a + (1 - of_nat i)) = (a + 1) * (\i = 0..b. a - of_nat i)" - by (simp add: prod.atLeast0_atMost_Suc_shift) + by (simp add: prod.atLeast0_atMost_Suc_shift del: prod.cl_ivl_Suc) also have "\ / fact (b + 2) = (a + 1) / of_nat (Suc (Suc b)) * (a gchoose Suc b)" by (simp_all add: gbinomial_prod_rev atLeastLessThanSuc_atLeastAtMost) finally show ?thesis by (simp add: Suc field_simps del: of_nat_Suc) @@ -690,7 +693,7 @@ then have "((a + 1) gchoose (Suc (Suc b))) = (\i = 0 .. Suc b. a + (1 - of_nat i)) / fact (b + 2)" by (simp add: field_simps gbinomial_prod_rev atLeastLessThanSuc_atLeastAtMost) also have "(\i = 0 .. Suc b. a + (1 - of_nat i)) = (a + 1) * (\i = 0..b. a - of_nat i)" - by (simp add: prod.atLeast0_atMost_Suc_shift) + by (simp add: prod.atLeast0_atMost_Suc_shift del: prod.cl_ivl_Suc) also have "\ / fact (b + 2) = (a + 1) / of_nat (Suc (Suc b)) * (a gchoose Suc b)" by (simp_all add: gbinomial_prod_rev atLeastLessThanSuc_atLeastAtMost atLeast0AtMost) finally show ?thesis @@ -860,7 +863,7 @@ have "S (Suc mm) = G (Suc mm) 0 + (\k=Suc 0..Suc mm. G (Suc mm) k)" using SG_def by (simp add: sum.atLeast_Suc_atMost atLeast0AtMost [symmetric]) also have "(\k=Suc 0..Suc mm. G (Suc mm) k) = (\k=0..mm. G (Suc mm) (Suc k))" - by (subst sum_shift_bounds_cl_Suc_ivl) simp + by (subst sum.shift_bounds_cl_Suc_ivl) simp also have "\ = (\k=0..mm. ((of_nat mm + a gchoose (Suc k)) + (of_nat mm + a gchoose k)) * x^(Suc k) * y^(mm - k))" unfolding G_def by (subst gbinomial_addition_formula) simp @@ -929,11 +932,11 @@ also have "(\k = 0..(2 * m + 1). (2 * m + 1 choose k)) = (\k = 0..m. (2 * m + 1 choose k)) + (\k = m+1..2*m+1. (2 * m + 1 choose k))" - using sum_ub_add_nat[of 0 m "\k. 2 * m + 1 choose k" "m+1"] + using sum.ub_add_nat[of 0 m "\k. 2 * m + 1 choose k" "m+1"] by (simp add: mult_2) also have "(\k = m+1..2*m+1. (2 * m + 1 choose k)) = (\k = 0..m. (2 * m + 1 choose (k + (m + 1))))" - by (subst sum_shift_bounds_cl_nat_ivl [symmetric]) (simp add: mult_2) + by (subst sum.shift_bounds_cl_nat_ivl [symmetric]) (simp add: mult_2) also have "\ = (\k = 0..m. (2 * m + 1 choose (m - k)))" by (intro sum.cong[OF refl], subst binomial_symmetric) simp_all also have "\ = (\k = 0..m. (2 * m + 1 choose k))" diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Computational_Algebra/Formal_Power_Series.thy --- a/src/HOL/Computational_Algebra/Formal_Power_Series.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Computational_Algebra/Formal_Power_Series.thy Wed Apr 10 21:29:32 2019 +0100 @@ -1125,7 +1125,7 @@ using sum.atLeast_Suc_atMost[of 0 "n+1" "\i. a$i * b$(n+1-i)"] by (simp add: fps_mult_nth nth_less_subdegree_zero) thus "fps_shift 1 (a*b) $ n = (fps_shift 1 a * b) $ n" - using sum_shift_bounds_cl_Suc_ivl[of "\i. a$i * b$(n+1-i)" 0 n] + using sum.shift_bounds_cl_Suc_ivl[of "\i. a$i * b$(n+1-i)" 0 n] by (simp add: fps_mult_nth) qed have "n \ subdegree g \ fps_shift n (g*h) = fps_shift n g * h" @@ -2220,7 +2220,7 @@ "fps_left_inverse (f^2) 1 $ Suc (Suc (Suc k)) = fps_left_inverse (f\<^sup>2) 1 $ Suc (Suc k) * of_nat 2 - fps_left_inverse (f\<^sup>2) 1 $ Suc k" - using sum_ub_add_nat f2_nth_simps(1,2) by simp + using sum.ub_add_nat f2_nth_simps(1,2) by simp also have "\ = of_nat (2 * Suc (Suc (Suc k))) - of_nat (Suc (Suc k))" by (subst A, subst B) (simp add: invf2_def mult.commute) also have "\ = of_nat (Suc (Suc (Suc k)) + 1)" @@ -4136,7 +4136,7 @@ from v have "k = sum_list v" by (simp add: A_def natpermute_def) also have "\ = (\i=0..m. v ! i)" - by (simp add: sum_list_sum_nth atLeastLessThanSuc_atLeastAtMost del: sum_op_ivl_Suc) + by (simp add: sum_list_sum_nth atLeastLessThanSuc_atLeastAtMost del: sum.op_ivl_Suc) also from j have "{0..m} = insert j ({0..m}-{j})" by auto also from j have "(\i\\. v ! i) = k + (\i\{0..m}-{j}. v ! i)" by (subst sum.insert) simp_all @@ -5927,10 +5927,10 @@ done have th20: "?m1 n * ?p b n = prod (\i. b - of_nat i) {0..m}" apply (simp add: pochhammer_minus field_simps m) - apply (auto simp add: pochhammer_prod_rev of_nat_diff prod.atLeast_Suc_atMost_Suc_shift) + apply (auto simp add: pochhammer_prod_rev of_nat_diff prod.atLeast_Suc_atMost_Suc_shift simp del: prod.cl_ivl_Suc) done have th21:"pochhammer (b - of_nat n + 1) k = prod (\i. b - of_nat i) {n - k .. n - 1}" - using kn apply (simp add: pochhammer_prod_rev m h prod.atLeast_Suc_atMost_Suc_shift) + using kn apply (simp add: pochhammer_prod_rev m h prod.atLeast_Suc_atMost_Suc_shift del: prod.op_ivl_Suc del: prod.cl_ivl_Suc) using prod.atLeastAtMost_shift_0 [of "m - h" m, where ?'a = 'a] apply (auto simp add: of_nat_diff field_simps) done diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Computational_Algebra/Polynomial.thy --- a/src/HOL/Computational_Algebra/Polynomial.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Computational_Algebra/Polynomial.thy Wed Apr 10 21:29:32 2019 +0100 @@ -523,7 +523,7 @@ also have "a + x * (\i\degree p. coeff p i * x ^ i) = coeff ?p' 0 * x^0 + (\i\degree p. coeff ?p' (Suc i) * x^Suc i)" by (simp add: field_simps sum_distrib_left coeff_pCons) - also note sum_atMost_Suc_shift[symmetric] + also note sum.atMost_Suc_shift[symmetric] also note degree_pCons_eq[OF \p \ 0\, of a, symmetric] finally show ?thesis . qed @@ -1000,7 +1000,7 @@ next case (pCons a p n) then show ?case - by (cases n) (simp_all add: sum_atMost_Suc_shift del: sum.atMost_Suc) + by (cases n) (simp_all add: sum.atMost_Suc_shift del: sum.atMost_Suc) qed lemma degree_mult_le: "degree (p * q) \ degree p + degree q" diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Decision_Procs/Approximation.thy --- a/src/HOL/Decision_Procs/Approximation.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Decision_Procs/Approximation.thy Wed Apr 10 21:29:32 2019 +0100 @@ -1182,7 +1182,7 @@ hence prod_head_Suc: "\k i. \{k ..< k + Suc i} = k * \{Suc k ..< Suc k + i}" by auto have sum_move0: "\k F. sum F {0.. k. F (Suc k)) {0..{1..n})" lemma fact_prod_Suc: "fact n = of_nat (prod Suc {0..i = 0..i. i" 1 n] - by (cases n) - (simp_all add: fact_prod_Suc prod.atLeast_Suc_atMost_Suc_shift - atLeastLessThanSuc_atLeastAtMost) +proof - + have "prod Suc {0..{1..n}" + by (simp add: atLeast0LessThan prod.atLeast1_atMost_eq) + then have "prod Suc {0..i. i" 1 n] by presburger + then show ?thesis + unfolding fact_prod_Suc by (simp add: atLeast0LessThan prod.atLeast1_atMost_eq) +qed lemma fact_0 [simp]: "fact 0 = 1" by (simp add: fact_prod) @@ -216,7 +218,8 @@ by (simp add: pochhammer_prod atLeastLessThanSuc_atLeastAtMost) lemma pochhammer_Suc_prod_rev: "pochhammer a (Suc n) = prod (\i. a + of_nat (n - i)) {0..n}" - by (simp add: pochhammer_prod_rev prod.atLeast_Suc_atMost_Suc_shift) + using prod.atLeast_Suc_atMost_Suc_shift + by (simp add: pochhammer_prod_rev prod.atLeast_Suc_atMost_Suc_shift del: prod.cl_ivl_Suc) lemma pochhammer_0 [simp]: "pochhammer a 0 = 1" by (simp add: pochhammer_prod) @@ -259,7 +262,7 @@ end lemma pochhammer_rec: "pochhammer a (Suc n) = a * pochhammer (a + 1) n" - by (simp add: pochhammer_prod prod.atLeast0_lessThan_Suc_shift ac_simps) + by (simp add: pochhammer_prod prod.atLeast0_lessThan_Suc_shift ac_simps del: prod.op_ivl_Suc) lemma pochhammer_rec': "pochhammer z (Suc n) = (z + of_nat n) * pochhammer z n" by (simp add: pochhammer_prod prod.atLeast0_lessThan_Suc ac_simps) diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Homology/Homology.thy --- a/src/HOL/Homology/Homology.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Homology/Homology.thy Wed Apr 10 21:29:32 2019 +0100 @@ -1,5 +1,5 @@ theory Homology - imports Brouwer_Degree + imports Invariance_of_Domain begin end diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Homology/Invariance_of_Domain.thy --- a/src/HOL/Homology/Invariance_of_Domain.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Homology/Invariance_of_Domain.thy Wed Apr 10 21:29:32 2019 +0100 @@ -1,7 +1,7 @@ section\Invariance of Domain\ theory Invariance_of_Domain - imports Brouwer_Degree + imports Brouwer_Degree "HOL-Analysis.Continuous_Extension" "HOL-Analysis.Homeomorphism" begin @@ -2426,4 +2426,549 @@ by (simp add: eq) qed +lemma invariance_of_domain_homeomorphism: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "open S" "continuous_on S f" "DIM('b) \ DIM('a)" "inj_on f S" + obtains g where "homeomorphism S (f ` S) f g" +proof + show "homeomorphism S (f ` S) f (inv_into S f)" + by (simp add: assms continuous_on_inverse_open homeomorphism_def) +qed + +corollary invariance_of_domain_homeomorphic: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "open S" "continuous_on S f" "DIM('b) \ DIM('a)" "inj_on f S" + shows "S homeomorphic (f ` S)" + using%unimportant invariance_of_domain_homeomorphism [OF assms] + by%unimportant (meson homeomorphic_def) + +lemma continuous_image_subset_interior: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "continuous_on S f" "inj_on f S" "DIM('b) \ DIM('a)" + shows "f ` (interior S) \ interior(f ` S)" +proof (rule interior_maximal) + show "f ` interior S \ f ` S" + by (simp add: image_mono interior_subset) + show "open (f ` interior S)" + using assms + by (auto simp: subset_inj_on interior_subset continuous_on_subset invariance_of_domain_gen) +qed + +lemma homeomorphic_interiors_same_dimension: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + assumes "S homeomorphic T" and dimeq: "DIM('a) = DIM('b)" + shows "(interior S) homeomorphic (interior T)" + using assms [unfolded homeomorphic_minimal] + unfolding homeomorphic_def +proof (clarify elim!: ex_forward) + fix f g + assume S: "\x\S. f x \ T \ g (f x) = x" and T: "\y\T. g y \ S \ f (g y) = y" + and contf: "continuous_on S f" and contg: "continuous_on T g" + then have fST: "f ` S = T" and gTS: "g ` T = S" and "inj_on f S" "inj_on g T" + by (auto simp: inj_on_def intro: rev_image_eqI) metis+ + have fim: "f ` interior S \ interior T" + using continuous_image_subset_interior [OF contf \inj_on f S\] dimeq fST by simp + have gim: "g ` interior T \ interior S" + using continuous_image_subset_interior [OF contg \inj_on g T\] dimeq gTS by simp + show "homeomorphism (interior S) (interior T) f g" + unfolding homeomorphism_def + proof (intro conjI ballI) + show "\x. x \ interior S \ g (f x) = x" + by (meson \\x\S. f x \ T \ g (f x) = x\ subsetD interior_subset) + have "interior T \ f ` interior S" + proof + fix x assume "x \ interior T" + then have "g x \ interior S" + using gim by blast + then show "x \ f ` interior S" + by (metis T \x \ interior T\ image_iff interior_subset subsetCE) + qed + then show "f ` interior S = interior T" + using fim by blast + show "continuous_on (interior S) f" + by (metis interior_subset continuous_on_subset contf) + show "\y. y \ interior T \ f (g y) = y" + by (meson T subsetD interior_subset) + have "interior S \ g ` interior T" + proof + fix x assume "x \ interior S" + then have "f x \ interior T" + using fim by blast + then show "x \ g ` interior T" + by (metis S \x \ interior S\ image_iff interior_subset subsetCE) + qed + then show "g ` interior T = interior S" + using gim by blast + show "continuous_on (interior T) g" + by (metis interior_subset continuous_on_subset contg) + qed +qed + +lemma homeomorphic_open_imp_same_dimension: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + assumes "S homeomorphic T" "open S" "S \ {}" "open T" "T \ {}" + shows "DIM('a) = DIM('b)" + using assms + apply (simp add: homeomorphic_minimal) + apply (rule order_antisym; metis inj_onI invariance_of_dimension) + done + +proposition homeomorphic_interiors: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + assumes "S homeomorphic T" "interior S = {} \ interior T = {}" + shows "(interior S) homeomorphic (interior T)" +proof (cases "interior T = {}") + case True + with assms show ?thesis by auto +next + case False + then have "DIM('a) = DIM('b)" + using assms + apply (simp add: homeomorphic_minimal) + apply (rule order_antisym; metis continuous_on_subset inj_onI inj_on_subset interior_subset invariance_of_dimension open_interior) + done + then show ?thesis + by (rule homeomorphic_interiors_same_dimension [OF \S homeomorphic T\]) +qed + +lemma homeomorphic_frontiers_same_dimension: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + assumes "S homeomorphic T" "closed S" "closed T" and dimeq: "DIM('a) = DIM('b)" + shows "(frontier S) homeomorphic (frontier T)" + using assms [unfolded homeomorphic_minimal] + unfolding homeomorphic_def +proof (clarify elim!: ex_forward) + fix f g + assume S: "\x\S. f x \ T \ g (f x) = x" and T: "\y\T. g y \ S \ f (g y) = y" + and contf: "continuous_on S f" and contg: "continuous_on T g" + then have fST: "f ` S = T" and gTS: "g ` T = S" and "inj_on f S" "inj_on g T" + by (auto simp: inj_on_def intro: rev_image_eqI) metis+ + have "g ` interior T \ interior S" + using continuous_image_subset_interior [OF contg \inj_on g T\] dimeq gTS by simp + then have fim: "f ` frontier S \ frontier T" + apply (simp add: frontier_def) + using continuous_image_subset_interior assms(2) assms(3) S by auto + have "f ` interior S \ interior T" + using continuous_image_subset_interior [OF contf \inj_on f S\] dimeq fST by simp + then have gim: "g ` frontier T \ frontier S" + apply (simp add: frontier_def) + using continuous_image_subset_interior T assms(2) assms(3) by auto + show "homeomorphism (frontier S) (frontier T) f g" + unfolding homeomorphism_def + proof (intro conjI ballI) + show gf: "\x. x \ frontier S \ g (f x) = x" + by (simp add: S assms(2) frontier_def) + show fg: "\y. y \ frontier T \ f (g y) = y" + by (simp add: T assms(3) frontier_def) + have "frontier T \ f ` frontier S" + proof + fix x assume "x \ frontier T" + then have "g x \ frontier S" + using gim by blast + then show "x \ f ` frontier S" + by (metis fg \x \ frontier T\ imageI) + qed + then show "f ` frontier S = frontier T" + using fim by blast + show "continuous_on (frontier S) f" + by (metis Diff_subset assms(2) closure_eq contf continuous_on_subset frontier_def) + have "frontier S \ g ` frontier T" + proof + fix x assume "x \ frontier S" + then have "f x \ frontier T" + using fim by blast + then show "x \ g ` frontier T" + by (metis gf \x \ frontier S\ imageI) + qed + then show "g ` frontier T = frontier S" + using gim by blast + show "continuous_on (frontier T) g" + by (metis Diff_subset assms(3) closure_closed contg continuous_on_subset frontier_def) + qed +qed + +lemma homeomorphic_frontiers: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + assumes "S homeomorphic T" "closed S" "closed T" + "interior S = {} \ interior T = {}" + shows "(frontier S) homeomorphic (frontier T)" +proof (cases "interior T = {}") + case True + then show ?thesis + by (metis Diff_empty assms closure_eq frontier_def) +next + case False + show ?thesis + apply (rule homeomorphic_frontiers_same_dimension) + apply (simp_all add: assms) + using False assms homeomorphic_interiors homeomorphic_open_imp_same_dimension by blast +qed + +lemma continuous_image_subset_rel_interior: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes contf: "continuous_on S f" and injf: "inj_on f S" and fim: "f ` S \ T" + and TS: "aff_dim T \ aff_dim S" + shows "f ` (rel_interior S) \ rel_interior(f ` S)" +proof (rule rel_interior_maximal) + show "f ` rel_interior S \ f ` S" + by(simp add: image_mono rel_interior_subset) + show "openin (top_of_set (affine hull f ` S)) (f ` rel_interior S)" + proof (rule invariance_of_domain_affine_sets) + show "openin (top_of_set (affine hull S)) (rel_interior S)" + by (simp add: openin_rel_interior) + show "aff_dim (affine hull f ` S) \ aff_dim (affine hull S)" + by (metis aff_dim_affine_hull aff_dim_subset fim TS order_trans) + show "f ` rel_interior S \ affine hull f ` S" + by (meson \f ` rel_interior S \ f ` S\ hull_subset order_trans) + show "continuous_on (rel_interior S) f" + using contf continuous_on_subset rel_interior_subset by blast + show "inj_on f (rel_interior S)" + using inj_on_subset injf rel_interior_subset by blast + qed auto +qed + +lemma homeomorphic_rel_interiors_same_dimension: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + assumes "S homeomorphic T" and aff: "aff_dim S = aff_dim T" + shows "(rel_interior S) homeomorphic (rel_interior T)" + using assms [unfolded homeomorphic_minimal] + unfolding homeomorphic_def +proof (clarify elim!: ex_forward) + fix f g + assume S: "\x\S. f x \ T \ g (f x) = x" and T: "\y\T. g y \ S \ f (g y) = y" + and contf: "continuous_on S f" and contg: "continuous_on T g" + then have fST: "f ` S = T" and gTS: "g ` T = S" and "inj_on f S" "inj_on g T" + by (auto simp: inj_on_def intro: rev_image_eqI) metis+ + have fim: "f ` rel_interior S \ rel_interior T" + by (metis \inj_on f S\ aff contf continuous_image_subset_rel_interior fST order_refl) + have gim: "g ` rel_interior T \ rel_interior S" + by (metis \inj_on g T\ aff contg continuous_image_subset_rel_interior gTS order_refl) + show "homeomorphism (rel_interior S) (rel_interior T) f g" + unfolding homeomorphism_def + proof (intro conjI ballI) + show gf: "\x. x \ rel_interior S \ g (f x) = x" + using S rel_interior_subset by blast + show fg: "\y. y \ rel_interior T \ f (g y) = y" + using T mem_rel_interior_ball by blast + have "rel_interior T \ f ` rel_interior S" + proof + fix x assume "x \ rel_interior T" + then have "g x \ rel_interior S" + using gim by blast + then show "x \ f ` rel_interior S" + by (metis fg \x \ rel_interior T\ imageI) + qed + moreover have "f ` rel_interior S \ rel_interior T" + by (metis \inj_on f S\ aff contf continuous_image_subset_rel_interior fST order_refl) + ultimately show "f ` rel_interior S = rel_interior T" + by blast + show "continuous_on (rel_interior S) f" + using contf continuous_on_subset rel_interior_subset by blast + have "rel_interior S \ g ` rel_interior T" + proof + fix x assume "x \ rel_interior S" + then have "f x \ rel_interior T" + using fim by blast + then show "x \ g ` rel_interior T" + by (metis gf \x \ rel_interior S\ imageI) + qed + then show "g ` rel_interior T = rel_interior S" + using gim by blast + show "continuous_on (rel_interior T) g" + using contg continuous_on_subset rel_interior_subset by blast + qed +qed + +lemma homeomorphic_rel_interiors: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + assumes "S homeomorphic T" "rel_interior S = {} \ rel_interior T = {}" + shows "(rel_interior S) homeomorphic (rel_interior T)" +proof (cases "rel_interior T = {}") + case True + with assms show ?thesis by auto +next + case False + obtain f g + where S: "\x\S. f x \ T \ g (f x) = x" and T: "\y\T. g y \ S \ f (g y) = y" + and contf: "continuous_on S f" and contg: "continuous_on T g" + using assms [unfolded homeomorphic_minimal] by auto + have "aff_dim (affine hull S) \ aff_dim (affine hull T)" + apply (rule invariance_of_dimension_affine_sets [of _ "rel_interior S" _ f]) + apply (simp_all add: openin_rel_interior False assms) + using contf continuous_on_subset rel_interior_subset apply blast + apply (meson S hull_subset image_subsetI rel_interior_subset rev_subsetD) + apply (metis S inj_on_inverseI inj_on_subset rel_interior_subset) + done + moreover have "aff_dim (affine hull T) \ aff_dim (affine hull S)" + apply (rule invariance_of_dimension_affine_sets [of _ "rel_interior T" _ g]) + apply (simp_all add: openin_rel_interior False assms) + using contg continuous_on_subset rel_interior_subset apply blast + apply (meson T hull_subset image_subsetI rel_interior_subset rev_subsetD) + apply (metis T inj_on_inverseI inj_on_subset rel_interior_subset) + done + ultimately have "aff_dim S = aff_dim T" by force + then show ?thesis + by (rule homeomorphic_rel_interiors_same_dimension [OF \S homeomorphic T\]) +qed + + +lemma homeomorphic_rel_boundaries_same_dimension: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + assumes "S homeomorphic T" and aff: "aff_dim S = aff_dim T" + shows "(S - rel_interior S) homeomorphic (T - rel_interior T)" + using assms [unfolded homeomorphic_minimal] + unfolding homeomorphic_def +proof (clarify elim!: ex_forward) + fix f g + assume S: "\x\S. f x \ T \ g (f x) = x" and T: "\y\T. g y \ S \ f (g y) = y" + and contf: "continuous_on S f" and contg: "continuous_on T g" + then have fST: "f ` S = T" and gTS: "g ` T = S" and "inj_on f S" "inj_on g T" + by (auto simp: inj_on_def intro: rev_image_eqI) metis+ + have fim: "f ` rel_interior S \ rel_interior T" + by (metis \inj_on f S\ aff contf continuous_image_subset_rel_interior fST order_refl) + have gim: "g ` rel_interior T \ rel_interior S" + by (metis \inj_on g T\ aff contg continuous_image_subset_rel_interior gTS order_refl) + show "homeomorphism (S - rel_interior S) (T - rel_interior T) f g" + unfolding homeomorphism_def + proof (intro conjI ballI) + show gf: "\x. x \ S - rel_interior S \ g (f x) = x" + using S rel_interior_subset by blast + show fg: "\y. y \ T - rel_interior T \ f (g y) = y" + using T mem_rel_interior_ball by blast + show "f ` (S - rel_interior S) = T - rel_interior T" + using S fST fim gim by auto + show "continuous_on (S - rel_interior S) f" + using contf continuous_on_subset rel_interior_subset by blast + show "g ` (T - rel_interior T) = S - rel_interior S" + using T gTS gim fim by auto + show "continuous_on (T - rel_interior T) g" + using contg continuous_on_subset rel_interior_subset by blast + qed +qed + +lemma homeomorphic_rel_boundaries: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + assumes "S homeomorphic T" "rel_interior S = {} \ rel_interior T = {}" + shows "(S - rel_interior S) homeomorphic (T - rel_interior T)" +proof (cases "rel_interior T = {}") + case True + with assms show ?thesis by auto +next + case False + obtain f g + where S: "\x\S. f x \ T \ g (f x) = x" and T: "\y\T. g y \ S \ f (g y) = y" + and contf: "continuous_on S f" and contg: "continuous_on T g" + using assms [unfolded homeomorphic_minimal] by auto + have "aff_dim (affine hull S) \ aff_dim (affine hull T)" + apply (rule invariance_of_dimension_affine_sets [of _ "rel_interior S" _ f]) + apply (simp_all add: openin_rel_interior False assms) + using contf continuous_on_subset rel_interior_subset apply blast + apply (meson S hull_subset image_subsetI rel_interior_subset rev_subsetD) + apply (metis S inj_on_inverseI inj_on_subset rel_interior_subset) + done + moreover have "aff_dim (affine hull T) \ aff_dim (affine hull S)" + apply (rule invariance_of_dimension_affine_sets [of _ "rel_interior T" _ g]) + apply (simp_all add: openin_rel_interior False assms) + using contg continuous_on_subset rel_interior_subset apply blast + apply (meson T hull_subset image_subsetI rel_interior_subset rev_subsetD) + apply (metis T inj_on_inverseI inj_on_subset rel_interior_subset) + done + ultimately have "aff_dim S = aff_dim T" by force + then show ?thesis + by (rule homeomorphic_rel_boundaries_same_dimension [OF \S homeomorphic T\]) +qed + +proposition uniformly_continuous_homeomorphism_UNIV_trivial: + fixes f :: "'a::euclidean_space \ 'a" + assumes contf: "uniformly_continuous_on S f" and hom: "homeomorphism S UNIV f g" + shows "S = UNIV" +proof (cases "S = {}") + case True + then show ?thesis + by (metis UNIV_I hom empty_iff homeomorphism_def image_eqI) +next + case False + have "inj g" + by (metis UNIV_I hom homeomorphism_apply2 injI) + then have "open (g ` UNIV)" + by (blast intro: invariance_of_domain hom homeomorphism_cont2) + then have "open S" + using hom homeomorphism_image2 by blast + moreover have "complete S" + unfolding complete_def + proof clarify + fix \ + assume \: "\n. \ n \ S" and "Cauchy \" + have "Cauchy (f o \)" + using uniformly_continuous_imp_Cauchy_continuous \Cauchy \\ \ contf by blast + then obtain l where "(f \ \) \ l" + by (auto simp: convergent_eq_Cauchy [symmetric]) + show "\l\S. \ \ l" + proof + show "g l \ S" + using hom homeomorphism_image2 by blast + have "(g \ (f \ \)) \ g l" + by (meson UNIV_I \(f \ \) \ l\ continuous_on_sequentially hom homeomorphism_cont2) + then show "\ \ g l" + proof - + have "\n. \ n = (g \ (f \ \)) n" + by (metis (no_types) \ comp_eq_dest_lhs hom homeomorphism_apply1) + then show ?thesis + by (metis (no_types) LIMSEQ_iff \(g \ (f \ \)) \ g l\) + qed + qed + qed + then have "closed S" + by (simp add: complete_eq_closed) + ultimately show ?thesis + using clopen [of S] False by simp +qed + +proposition invariance_of_domain_sphere_affine_set_gen: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes contf: "continuous_on S f" and injf: "inj_on f S" and fim: "f ` S \ T" + and U: "bounded U" "convex U" + and "affine T" and affTU: "aff_dim T < aff_dim U" + and ope: "openin (top_of_set (rel_frontier U)) S" + shows "openin (top_of_set T) (f ` S)" +proof (cases "rel_frontier U = {}") + case True + then show ?thesis + using ope openin_subset by force +next + case False + obtain b c where b: "b \ rel_frontier U" and c: "c \ rel_frontier U" and "b \ c" + using \bounded U\ rel_frontier_not_sing [of U] subset_singletonD False by fastforce + obtain V :: "'a set" where "affine V" and affV: "aff_dim V = aff_dim U - 1" + proof (rule choose_affine_subset [OF affine_UNIV]) + show "- 1 \ aff_dim U - 1" + by (metis aff_dim_empty aff_dim_geq aff_dim_negative_iff affTU diff_0 diff_right_mono not_le) + show "aff_dim U - 1 \ aff_dim (UNIV::'a set)" + by (metis aff_dim_UNIV aff_dim_le_DIM le_cases not_le zle_diff1_eq) + qed auto + have SU: "S \ rel_frontier U" + using ope openin_imp_subset by auto + have homb: "rel_frontier U - {b} homeomorphic V" + and homc: "rel_frontier U - {c} homeomorphic V" + using homeomorphic_punctured_sphere_affine_gen [of U _ V] + by (simp_all add: \affine V\ affV U b c) + then obtain g h j k + where gh: "homeomorphism (rel_frontier U - {b}) V g h" + and jk: "homeomorphism (rel_frontier U - {c}) V j k" + by (auto simp: homeomorphic_def) + with SU have hgsub: "(h ` g ` (S - {b})) \ S" and kjsub: "(k ` j ` (S - {c})) \ S" + by (simp_all add: homeomorphism_def subset_eq) + have [simp]: "aff_dim T \ aff_dim V" + by (simp add: affTU affV) + have "openin (top_of_set T) ((f \ h) ` g ` (S - {b}))" + proof (rule invariance_of_domain_affine_sets [OF _ \affine V\]) + show "openin (top_of_set V) (g ` (S - {b}))" + apply (rule homeomorphism_imp_open_map [OF gh]) + by (meson Diff_mono Diff_subset SU ope openin_delete openin_subset_trans order_refl) + show "continuous_on (g ` (S - {b})) (f \ h)" + apply (rule continuous_on_compose) + apply (meson Diff_mono SU homeomorphism_def homeomorphism_of_subsets gh set_eq_subset) + using contf continuous_on_subset hgsub by blast + show "inj_on (f \ h) (g ` (S - {b}))" + using kjsub + apply (clarsimp simp add: inj_on_def) + by (metis SU b homeomorphism_def inj_onD injf insert_Diff insert_iff gh rev_subsetD) + show "(f \ h) ` g ` (S - {b}) \ T" + by (metis fim image_comp image_mono hgsub subset_trans) + qed (auto simp: assms) + moreover + have "openin (top_of_set T) ((f \ k) ` j ` (S - {c}))" + proof (rule invariance_of_domain_affine_sets [OF _ \affine V\]) + show "openin (top_of_set V) (j ` (S - {c}))" + apply (rule homeomorphism_imp_open_map [OF jk]) + by (meson Diff_mono Diff_subset SU ope openin_delete openin_subset_trans order_refl) + show "continuous_on (j ` (S - {c})) (f \ k)" + apply (rule continuous_on_compose) + apply (meson Diff_mono SU homeomorphism_def homeomorphism_of_subsets jk set_eq_subset) + using contf continuous_on_subset kjsub by blast + show "inj_on (f \ k) (j ` (S - {c}))" + using kjsub + apply (clarsimp simp add: inj_on_def) + by (metis SU c homeomorphism_def inj_onD injf insert_Diff insert_iff jk rev_subsetD) + show "(f \ k) ` j ` (S - {c}) \ T" + by (metis fim image_comp image_mono kjsub subset_trans) + qed (auto simp: assms) + ultimately have "openin (top_of_set T) ((f \ h) ` g ` (S - {b}) \ ((f \ k) ` j ` (S - {c})))" + by (rule openin_Un) + moreover have "(f \ h) ` g ` (S - {b}) = f ` (S - {b})" + proof - + have "h ` g ` (S - {b}) = (S - {b})" + proof + show "h ` g ` (S - {b}) \ S - {b}" + using homeomorphism_apply1 [OF gh] SU + by (fastforce simp add: image_iff image_subset_iff) + show "S - {b} \ h ` g ` (S - {b})" + apply clarify + by (metis SU subsetD homeomorphism_apply1 [OF gh] image_iff member_remove remove_def) + qed + then show ?thesis + by (metis image_comp) + qed + moreover have "(f \ k) ` j ` (S - {c}) = f ` (S - {c})" + proof - + have "k ` j ` (S - {c}) = (S - {c})" + proof + show "k ` j ` (S - {c}) \ S - {c}" + using homeomorphism_apply1 [OF jk] SU + by (fastforce simp add: image_iff image_subset_iff) + show "S - {c} \ k ` j ` (S - {c})" + apply clarify + by (metis SU subsetD homeomorphism_apply1 [OF jk] image_iff member_remove remove_def) + qed + then show ?thesis + by (metis image_comp) + qed + moreover have "f ` (S - {b}) \ f ` (S - {c}) = f ` (S)" + using \b \ c\ by blast + ultimately show ?thesis + by simp +qed + +lemma invariance_of_domain_sphere_affine_set: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes contf: "continuous_on S f" and injf: "inj_on f S" and fim: "f ` S \ T" + and "r \ 0" "affine T" and affTU: "aff_dim T < DIM('a)" + and ope: "openin (top_of_set (sphere a r)) S" + shows "openin (top_of_set T) (f ` S)" +proof (cases "sphere a r = {}") + case True + then show ?thesis + using ope openin_subset by force +next + case False + show ?thesis + proof (rule invariance_of_domain_sphere_affine_set_gen [OF contf injf fim bounded_cball convex_cball \affine T\]) + show "aff_dim T < aff_dim (cball a r)" + by (metis False affTU aff_dim_cball assms(4) linorder_cases sphere_empty) + show "openin (top_of_set (rel_frontier (cball a r))) S" + by (simp add: \r \ 0\ ope) + qed +qed + +lemma no_embedding_sphere_lowdim: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes contf: "continuous_on (sphere a r) f" and injf: "inj_on f (sphere a r)" and "r > 0" + shows "DIM('a) \ DIM('b)" +proof - + have "False" if "DIM('a) > DIM('b)" + proof - + have "compact (f ` sphere a r)" + using compact_continuous_image + by (simp add: compact_continuous_image contf) + then have "\ open (f ` sphere a r)" + using compact_open + by (metis assms(3) image_is_empty not_less_iff_gr_or_eq sphere_eq_empty) + then show False + using invariance_of_domain_sphere_affine_set [OF contf injf subset_UNIV] \r > 0\ + by (metis aff_dim_UNIV affine_UNIV less_irrefl of_nat_less_iff open_openin openin_subtopology_self subtopology_UNIV that) + qed + then show ?thesis + using not_less by blast +qed + end \ No newline at end of file diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Homology/Simplices.thy --- a/src/HOL/Homology/Simplices.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Homology/Simplices.thy Wed Apr 10 21:29:32 2019 +0100 @@ -1190,7 +1190,7 @@ by (simp add: oriented_simplex_def standard_simplex_def) have "oriented_simplex (Suc p) (\i. if i = 0 then v else l (i -1)) x \ T" if "x \ standard_simplex (Suc p)" for x - proof (simp add: that oriented_simplex_def sum_atMost_Suc_shift del: sum.atMost_Suc) + proof (simp add: that oriented_simplex_def sum.atMost_Suc_shift del: sum.atMost_Suc) have x01: "\i. 0 \ x i \ x i \ 1" and x0: "\i. i > Suc p \ x i = 0" and x1: "sum x {..Suc p} = 1" using that by (auto simp: oriented_simplex_def standard_simplex_def) obtain a where "a \ S" @@ -1224,7 +1224,7 @@ have "(\i. (\j\p. l j i * (x (Suc j) * inverse (1 - x 0)))) \ S" proof (rule S) have "x 0 + (\j\p. x (Suc j)) = sum x {..Suc p}" - by (metis sum_atMost_Suc_shift) + by (metis sum.atMost_Suc_shift) with x1 have "(\j\p. x (Suc j)) = 1 - x 0" by simp with False show "(\j\p. x (Suc j) * inverse (1 - x 0)) = 1" @@ -2936,7 +2936,7 @@ fix x assume x: "x \ standard_simplex q" have "(\j\Suc q. if j = 0 then 0 else x (j - Suc 0)) = (\j\q. x j)" - by (simp add: sum_atMost_Suc_shift) + by (simp add: sum.atMost_Suc_shift) with x have "simp q 0 (simplical_face 0 x) 0 = 1" apply (simp add: oriented_simplex_def simp_def simplical_face_in_standard_simplex) apply (simp add: simplical_face_def if_distrib ww_def standard_simplex_def cong: if_cong) @@ -3230,7 +3230,7 @@ apply (simp add: chain_boundary_sum chain_boundary_cmul) apply (subst chain_boundary_def) apply (simp add: frag_cmul_sum sum.cartesian_product eq sum.union_disjoint disjoint_iff_not_equal - sum.atLeast_Suc_atMost_Suc_shift del: sum_cl_ivl_Suc flip: comm_monoid_add_class.sum.Sigma) + sum.atLeast_Suc_atMost_Suc_shift del: sum.cl_ivl_Suc flip: comm_monoid_add_class.sum.Sigma) apply (simp add: comm_monoid_add_class.sum.Sigma eq2 [of _ "\i. {_ i.._ i}"]) apply (simp add: sum.union_disjoint disjoint_iff_not_equal * [OF 1 2]) done diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Library/Stirling.thy --- a/src/HOL/Library/Stirling.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Library/Stirling.thy Wed Apr 10 21:29:32 2019 +0100 @@ -156,7 +156,7 @@ next case (Suc n) have "(\k\Suc n. stirling (Suc n) k) = stirling (Suc n) 0 + (\k\n. stirling (Suc n) (Suc k))" - by (simp only: sum_atMost_Suc_shift) + by (simp only: sum.atMost_Suc_shift) also have "\ = (\k\n. stirling (Suc n) (Suc k))" by simp also have "\ = (\k\n. n * stirling n (Suc k) + stirling n k)" @@ -166,7 +166,7 @@ also have "\ = n * fact n + fact n" proof - have "n * (\k\n. stirling n (Suc k)) = n * ((\k\Suc n. stirling n k) - stirling n 0)" - by (metis add_diff_cancel_left' sum_atMost_Suc_shift) + by (metis add_diff_cancel_left' sum.atMost_Suc_shift) also have "\ = n * (\k\n. stirling n k)" by (cases n) simp_all also have "\ = n * fact n" @@ -192,9 +192,9 @@ (of_nat (n * stirling n 0) * x ^ 0 + (\i\n. of_nat (n * stirling n (Suc i)) * (x ^ Suc i))) + (\i\n. of_nat (stirling n i) * (x ^ Suc i))" - by (subst sum_atMost_Suc_shift) (simp add: sum.distrib ring_distribs) + by (subst sum.atMost_Suc_shift) (simp add: sum.distrib ring_distribs) also have "\ = pochhammer x (Suc n)" - by (subst sum_atMost_Suc_shift [symmetric]) + by (subst sum.atMost_Suc_shift [symmetric]) (simp add: algebra_simps sum.distrib sum_distrib_left pochhammer_Suc flip: Suc) finally show ?case . qed diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Library/Uprod.thy --- a/src/HOL/Library/Uprod.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Library/Uprod.thy Wed Apr 10 21:29:32 2019 +0100 @@ -210,7 +210,7 @@ by (subst card_SigmaI) simp_all also have "\ = sum of_nat {Suc 0..?A}" using sum.atLeastLessThan_reindex [symmetric, of Suc 0 ?A id] - by (simp del: sum_op_ivl_Suc add: atLeastLessThanSuc_atLeastAtMost) + by (simp del: sum.op_ivl_Suc add: atLeastLessThanSuc_atLeastAtMost) also have "\ = ?A * (?A + 1) div 2" using gauss_sum_from_Suc_0 [of ?A, where ?'a = nat] by simp finally show ?thesis . diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Nonstandard_Analysis/HSeries.thy --- a/src/HOL/Nonstandard_Analysis/HSeries.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Nonstandard_Analysis/HSeries.thy Wed Apr 10 21:29:32 2019 +0100 @@ -81,7 +81,7 @@ lemma sumhr_shift_bounds: "\m n. sumhr (m + hypnat_of_nat k, n + hypnat_of_nat k, f) = sumhr (m, n, \i. f (i + k))" - unfolding sumhr_app by transfer (rule sum_shift_bounds_nat_ivl) + unfolding sumhr_app by transfer (rule sum.shift_bounds_nat_ivl) subsection \Nonstandard Sums\ diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Real_Asymp/Multiseries_Expansion.thy --- a/src/HOL/Real_Asymp/Multiseries_Expansion.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Real_Asymp/Multiseries_Expansion.thy Wed Apr 10 21:29:32 2019 +0100 @@ -3707,7 +3707,7 @@ using h_nz by (intro bigthetaI_cong) (auto elim!: eventually_mono simp: f'_def field_simps) also from spec[OF asymp_powser, of "Suc n"] have "(\x. f x - c - h x * (\i O[F](\x. h x * h x ^ n)" - unfolding sum_lessThan_Suc_shift + unfolding sum.lessThan_Suc_shift by (simp add: MSSCons algebra_simps sum_distrib_left sum_distrib_right) finally show ?thesis by (subst (asm) landau_o.big.mult_cancel_left) (insert h_nz, auto) diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Series.thy --- a/src/HOL/Series.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Series.thy Wed Apr 10 21:29:32 2019 +0100 @@ -80,7 +80,7 @@ by (rule sums_zero [THEN sums_summable]) lemma sums_group: "f sums s \ 0 < k \ (\n. sum f {n * k ..< n * k + k}) sums s" - apply (simp only: sums_def sum_nat_group tendsto_def eventually_sequentially) + apply (simp only: sums_def sum.nat_group tendsto_def eventually_sequentially) apply (erule all_forward imp_forward exE| assumption)+ apply (rule_tac x="N" in exI) by (metis le_square mult.commute mult.left_neutral mult_le_cancel2 mult_le_mono) @@ -303,7 +303,7 @@ using assms by (auto intro!: tendsto_add simp: sums_def) moreover have "(\ii (\i. \j s + f 0" by (subst LIMSEQ_Suc_iff) (simp add: sums_def) also have "\ \ (\i. (\j s + f 0" - by (simp add: ac_simps lessThan_Suc_eq_insert_0 image_Suc_lessThan sum_atLeast1_atMost_eq) + by (simp add: ac_simps lessThan_Suc_eq_insert_0 image_Suc_lessThan sum.atLeast1_atMost_eq) also have "\ \ (\n. f (Suc n)) sums s" proof assume "(\i. (\j s + f 0" @@ -940,7 +940,7 @@ with 1 have "(\n. sum ?g (?S2 n)) \ (\k. a k) * (\k. b k)" by (rule Lim_transform2) then show ?thesis - by (simp only: sums_def sum_triangle_reindex) + by (simp only: sums_def sum.triangle_reindex) qed lemma Cauchy_product: @@ -1083,7 +1083,7 @@ with m have "norm ((\kkkkk=m..n. f k)" - by (subst sum_diff [symmetric]) (simp_all add: sum_last_plus) + by (subst sum_diff [symmetric]) (simp_all add: sum.last_plus) finally show ?thesis . next case False diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Set_Interval.thy --- a/src/HOL/Set_Interval.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Set_Interval.thy Wed Apr 10 21:29:32 2019 +0100 @@ -1861,82 +1861,158 @@ "F g {..* g n" by (simp add: lessThan_Suc ac_simps) -end - -(* FIXME why are the following simp rules but the corresponding eqns -on intervals are not? *) - -lemma sum_cl_ivl_Suc [simp]: - "sum f {m..Suc n} = (if Suc n < m then 0 else sum f {m..n} + f(Suc n))" +lemma cl_ivl_Suc [simp]: + "F g {m..Suc n} = (if Suc n < m then \<^bold>1 else F g {m..n} \<^bold>* g(Suc n))" by (auto simp: ac_simps atLeastAtMostSuc_conv) -lemma sum_op_ivl_Suc [simp]: - "sum f {m..1 else F g {m..* g(n))" by (auto simp: ac_simps atLeastLessThanSuc) -lemma sum_head: +lemma head: fixes n :: nat assumes mn: "m \ n" - shows "(\x\{m..n}. P x) = P m + (\x\{m<..n}. P x)" (is "?lhs = ?rhs") + shows "F g {m..n} = g m \<^bold>* F g {m<..n}" (is "?lhs = ?rhs") proof - from mn have "{m..n} = {m} \ {m<..n}" by (auto intro: ivl_disj_un_singleton) - hence "?lhs = (\x\{m} \ {m<..n}. P x)" + hence "?lhs = F g ({m} \ {m<..n})" by (simp add: atLeast0LessThan) also have "\ = ?rhs" by simp finally show ?thesis . qed -lemma sum_ub_add_nat: assumes "(m::nat) \ n + 1" - shows "sum f {m..n + p} = sum f {m..n} + sum f {n + 1..n + p}" +lemma ub_add_nat: + assumes "(m::nat) \ n + 1" + shows "F g {m..n + p} = F g {m..n} \<^bold>* F g {n + 1..n + p}" proof- have "{m .. n+p} = {m..n} \ {n+1..n+p}" using \m \ n+1\ by auto - thus ?thesis by (auto simp: ivl_disj_int sum.union_disjoint - atLeastSucAtMost_greaterThanAtMost) + thus ?thesis by (auto simp: ivl_disj_int union_disjoint atLeastSucAtMost_greaterThanAtMost) qed +lemma nat_group: + fixes k::nat shows "F (\m. F g {m * k ..< m*k + k}) {.. 0" + by auto + then show ?thesis + by (induct n) (simp_all add: atLeastLessThan_concat add.commute atLeast0LessThan[symmetric]) +qed auto + +lemma triangle_reindex: + fixes n :: nat + shows "F (\(i,j). g i j) {(i,j). i+j < n} = F (\k. F (\i. g i (k - i)) {..k}) {..(i,j). g i j) {(i,j). i+j \ n} = F (\k. F (\i. g i (k - i)) {..k}) {..n}" +using triangle_reindex [of g "Suc n"] +by (simp only: Nat.less_Suc_eq_le lessThan_Suc_atMost) + +lemma nat_diff_reindex: "F (\i. g (n - Suc i)) {..i. g(i + k)){m..i. g(i + k)){m..n::nat}" + by (rule reindex_bij_witness[where i="\i. i + k" and j="\i. i - k"]) auto + +corollary shift_bounds_cl_Suc_ivl: + "F g {Suc m..Suc n} = F (\i. g(Suc i)){m..n}" +by (simp add: shift_bounds_cl_nat_ivl[where k="Suc 0", simplified]) + +corollary shift_bounds_Suc_ivl: + "F g {Suc m..i. g(Suc i)){m..* F (\i. g (Suc i)) {..n}" +proof (induct n) + case 0 show ?case by simp +next + case (Suc n) note IH = this + have "F g {..Suc (Suc n)} = F g {..Suc n} \<^bold>* g (Suc (Suc n))" + by (rule atMost_Suc) + also have "F g {..Suc n} = g 0 \<^bold>* F (\i. g (Suc i)) {..n}" + by (rule IH) + also have "g 0 \<^bold>* F (\i. g (Suc i)) {..n} \<^bold>* g (Suc (Suc n)) = + g 0 \<^bold>* (F (\i. g (Suc i)) {..n} \<^bold>* g (Suc (Suc n)))" + by (rule assoc) + also have "F (\i. g (Suc i)) {..n} \<^bold>* g (Suc (Suc n)) = F (\i. g (Suc i)) {..Suc n}" + by (rule atMost_Suc [symmetric]) + finally show ?case . +qed + +lemma lessThan_Suc_shift: + "F g {..* F (\i. g (Suc i)) {..* F (\i. g (Suc i)) {.. n \ F g {m..n} = g n \<^bold>* F g {m..i. F (\j. a i j) {0..j. F (\i. a i j) {Suc j..n}) {0..i. F (\j. a i j) {..j. F (\i. a i j) {Suc j..n}) {..k. g (Suc k)) {.. = F (\k. g (Suc k)) {.. b \ F g {a..* g b" + by (simp add: atLeastLessThanSuc commute) + +lemma nat_ivl_Suc': + assumes "m \ Suc n" + shows "F g {m..Suc n} = g (Suc n) \<^bold>* F g {m..n}" +proof - + from assms have "{m..Suc n} = insert (Suc n) {m..n}" by auto + also have "F g \ = g (Suc n) \<^bold>* F g {m..n}" by simp + finally show ?thesis . +qed + +end + +lemma sum_natinterval_diff: + fixes f:: "nat \ ('a::ab_group_add)" + shows "sum (\k. f k - f(k + 1)) {(m::nat) .. n} = + (if m \ n then f m - f(n + 1) else 0)" +by (induct n, auto simp add: algebra_simps not_le le_Suc_eq) + lemma sum_diff_nat_ivl: fixes f :: "nat \ 'a::ab_group_add" shows "\ m \ n; n \ p \ \ sum f {m.. ('a::ab_group_add)" - shows "sum (\k. f k - f(k + 1)) {(m::nat) .. n} = - (if m \ n then f m - f(n + 1) else 0)" -by (induct n, auto simp add: algebra_simps not_le le_Suc_eq) - -lemma sum_nat_group: "(\m 0" - by auto - then show ?thesis - by (induct n) (simp_all add: sum.atLeastLessThan_concat add.commute atLeast0LessThan[symmetric]) -qed auto - -lemma sum_triangle_reindex: - fixes n :: nat - shows "(\(i,j)\{(i,j). i+j < n}. f i j) = (\ki\k. f i (k - i))" - apply (simp add: sum.Sigma) - apply (rule sum.reindex_bij_witness[where j="\(i, j). (i+j, i)" and i="\(k, i). (i, k - i)"]) - apply auto - done - -lemma sum_triangle_reindex_eq: - fixes n :: nat - shows "(\(i,j)\{(i,j). i+j \ n}. f i j) = (\k\n. \i\k. f i (k - i))" -using sum_triangle_reindex [of f "Suc n"] -by (simp only: Nat.less_Suc_eq_le lessThan_Suc_atMost) - -lemma nat_diff_sum_reindex: "(\iix. Q x \ P x \ (\xxxShifting bounds\ -lemma sum_shift_bounds_nat_ivl: - "sum f {m+k..i. f(i + k)){m..i. f(i + k)){m..n::nat}" - by (rule sum.reindex_bij_witness[where i="\i. i + k" and j="\i. i - k"]) auto - -corollary sum_shift_bounds_cl_Suc_ivl: - "sum f {Suc m..Suc n} = sum (\i. f(Suc i)){m..n}" -by (simp add:sum_shift_bounds_cl_nat_ivl[where k="Suc 0", simplified]) - -corollary sum_shift_bounds_Suc_ivl: - "sum f {Suc m..i. f(Suc i)){m.. 'a::comm_monoid_add" - shows "(\i\Suc n. f i) = f 0 + (\i\n. f (Suc i))" -proof (induct n) - case 0 show ?case by simp -next - case (Suc n) note IH = this - have "(\i\Suc (Suc n). f i) = (\i\Suc n. f i) + f (Suc (Suc n))" - by (rule sum.atMost_Suc) - also have "(\i\Suc n. f i) = f 0 + (\i\n. f (Suc i))" - by (rule IH) - also have "f 0 + (\i\n. f (Suc i)) + f (Suc (Suc n)) = - f 0 + ((\i\n. f (Suc i)) + f (Suc (Suc n)))" - by (rule add.assoc) - also have "(\i\n. f (Suc i)) + f (Suc (Suc n)) = (\i\Suc n. f (Suc i))" - by (rule sum.atMost_Suc [symmetric]) - finally show ?case . -qed - -lemma sum_lessThan_Suc_shift: - "(\ii 'a::comm_monoid_add" - shows "(\i\n. f i) = f 0 + (\i n \ (\i = m..n. f i) = f n + (\i = m.. 'a::ab_group_add" assumes "m \ Suc n" @@ -2062,24 +2091,6 @@ shows "(\i = m..i = 0..n. (\j = 0..j = 0..i = Suc j..n. a i j)" - by (induction n) (auto simp: sum.distrib) - -lemma nested_sum_swap': - "(\i\n. (\jji = Suc j..n. a i j)" - by (induction n) (auto simp: sum.distrib) - -lemma sum_atLeast1_atMost_eq: - "sum f {Suc 0..n} = (\k = (\kTelescoping\ @@ -2158,7 +2169,7 @@ lemma one_diff_power_eq: fixes x :: "'a::{comm_ring,monoid_mult}" shows "n \ 0 \ 1 - x^n = (1 - x) * (\ii\n. x^i) = (if x = 1 then of_nat(n + 1) else (1 - x^Suc n) / (1 - x))" + shows "(\i\n. x^i) = (if x = 1 then of_nat(n + 1) else (1 - x^Suc n) / (1 - x))" using sum_gp_basic[of x n] by (simp add: mult.commute divide_simps) @@ -2387,16 +2398,6 @@ "\i\n. t" \ "CONST prod (\i. t) {..n}" "\i "CONST prod (\i. t) {..k = (\k{int i..int (i+j)}" by (induct j) (auto simp add: atLeastAtMostSuc_conv atLeastAtMostPlus1_int_conv) @@ -2411,55 +2412,6 @@ by auto qed - -subsubsection \Shifting bounds\ - -lemma prod_shift_bounds_nat_ivl: - "prod f {m+k..i. f(i + k)){m..i. f(i + k)){m..n::nat}" - by (rule prod.reindex_bij_witness[where i="\i. i + k" and j="\i. i - k"]) auto - -corollary prod_shift_bounds_cl_Suc_ivl: - "prod f {Suc m..Suc n} = prod (\i. f(Suc i)){m..n}" -by (simp add:prod_shift_bounds_cl_nat_ivl[where k="Suc 0", simplified]) - -corollary prod_shift_bounds_Suc_ivl: - "prod f {Suc m..i. f(Suc i)){m..ii b \ prod f {a.. Suc n" - shows "prod f {m..Suc n} = f (Suc n) * prod f {m..n}" -proof - - from assms have "{m..Suc n} = insert (Suc n) {m..n}" by auto - also have "prod f \ = f (Suc n) * prod f {m..n}" by simp - finally show ?thesis . -qed - -lemma prod_nat_group: "(\mEfficient folding over intervals\ function fold_atLeastAtMost_nat where diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/Transcendental.thy --- a/src/HOL/Transcendental.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/Transcendental.thy Wed Apr 10 21:29:32 2019 +0100 @@ -400,7 +400,7 @@ have "?s sums y" using sums_if'[OF \f sums y\] . from this[unfolded sums_def, THEN LIMSEQ_Suc] have "(\n. if even n then f (n div 2) else 0) sums y" - by (simp add: lessThan_Suc_eq_insert_0 sum_atLeast1_atMost_eq image_Suc_lessThan + by (simp add: lessThan_Suc_eq_insert_0 sum.atLeast1_atMost_eq image_Suc_lessThan if_eq sums_def cong del: if_weak_cong) from sums_add[OF g_sums this] show ?thesis by (simp only: if_sum) @@ -620,7 +620,7 @@ lemma lemma_realpow_rev_sumr: "(\ppi\n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) = (\i\Suc n. real i *\<^sub>R (S x i * S y (Suc n - i)))" - by (subst sum_atMost_Suc_shift) simp + by (subst sum.atMost_Suc_shift) simp also have "(\i\n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) = (\i\Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))" by simp @@ -1462,7 +1462,7 @@ also have "\ = real (Suc n) *\<^sub>R (\i\Suc n. S x i * S y (Suc n - i))" by (simp only: scaleR_right.sum) finally show "S (x + y) (Suc n) = (\i\Suc n. S x i * S y (Suc n - i))" - by (simp del: sum_cl_ivl_Suc) + by (simp del: sum.cl_ivl_Suc) qed lemma exp_add_commuting: "x * y = y * x \ exp (x + y) = exp x * exp y" @@ -6025,7 +6025,7 @@ by auto lemma sum_up_index_split: "(\k\m + n. f k) = (\k\m. f k) + (\k = Suc m..m + n. f k)" - by (metis atLeast0AtMost Suc_eq_plus1 le0 sum_ub_add_nat) + by (metis atLeast0AtMost Suc_eq_plus1 le0 sum.ub_add_nat) lemma Sigma_interval_disjoint: "(SIGMA i:A. {..v i}) \ (SIGMA i:A.{v i<..w}) = {}" for w :: "'a::order" @@ -6054,7 +6054,7 @@ also have "\ = (\(i,j)\{(i,j). i+j \ m+n}. (a i * x ^ i) * (b j * x ^ j))" by (auto simp: pairs_le_eq_Sigma sum.Sigma) also have "\ = (\r\m + n. (\k\r. (a k) * (b (r - k))) * x ^ r)" - apply (subst sum_triangle_reindex_eq) + apply (subst sum.triangle_reindex_eq) apply (auto simp: algebra_simps sum_distrib_left intro!: sum.cong) apply (metis le_add_diff_inverse power_add) done @@ -6165,7 +6165,7 @@ have "(\i\Suc n. c i * w^i) = w * (\i\n. c (Suc i) * w^i)" for w proof - have "(\i\Suc n. c i * w^i) = (\i\n. c (Suc i) * w ^ Suc i)" - unfolding Set_Interval.sum_atMost_Suc_shift + unfolding Set_Interval.sum.atMost_Suc_shift by simp also have "\ = w * (\i\n. c (Suc i) * w^i)" by (simp add: sum_distrib_left ac_simps) diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/ex/HarmonicSeries.thy --- a/src/HOL/ex/HarmonicSeries.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/ex/HarmonicSeries.thy Wed Apr 10 21:29:32 2019 +0100 @@ -147,7 +147,7 @@ "\ = (\n\{(1::nat)..2}. 1/real n)" by simp also have "\ = ((\n\{Suc 1..2}. 1/real n) + 1/(real (1::nat)))" - by (subst sum_head) + by (subst sum.head) (auto simp: atLeastSucAtMost_greaterThanAtMost) also have "\ = ((\n\{2..2::nat}. 1/real n) + 1/(real (1::nat)))" @@ -283,7 +283,7 @@ have "\m\j. 0 < ?f m" by simp with sf have "(\ii\{Suc 0..i\{1..< Suc ((2::nat)^n)}. 1 / (real i)) < ?s" by simp then have diff -r 4005298550a6 -r c8deb8ba6d05 src/HOL/ex/ThreeDivides.thy --- a/src/HOL/ex/ThreeDivides.thy Wed Apr 10 13:34:55 2019 +0100 +++ b/src/HOL/ex/ThreeDivides.thy Wed Apr 10 21:29:32 2019 +0100 @@ -199,7 +199,7 @@ by (simp add: div_mult2_eq[symmetric]) also have "\ = (\x\{Suc 0.. = (\x